|
|
@ -1,10 +1,27 @@ |
|
|
|
package com.epmet.opendata.service.impl; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.dto.basereport.form.EventInfoFormDTO; |
|
|
|
import com.epmet.dto.basereport.result.EventInfoResultDTO; |
|
|
|
import com.epmet.feign.DataStatisticalOpenFeignClient; |
|
|
|
import com.epmet.opendata.dao.EventreportPingyinDao; |
|
|
|
import com.epmet.opendata.dao.GridstaffInfoPingyinDao; |
|
|
|
import com.epmet.opendata.entity.EventreportPingyinEntity; |
|
|
|
import com.epmet.opendata.entity.GridstaffInfoPingyinEntity; |
|
|
|
import com.epmet.opendata.service.EventreportPingyinService; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.util.List; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* 平阴区事件上报中间表 |
|
|
@ -12,8 +29,116 @@ import org.springframework.stereotype.Service; |
|
|
|
* @author generator generator@elink-cn.com |
|
|
|
* @since v1.0.0 2022-07-22 |
|
|
|
*/ |
|
|
|
@Slf4j |
|
|
|
@Service |
|
|
|
public class EventreportPingyinServiceImpl extends BaseServiceImpl<EventreportPingyinDao, EventreportPingyinEntity> implements EventreportPingyinService { |
|
|
|
@Resource |
|
|
|
private DataStatisticalOpenFeignClient dataStatisticalOpenFeignClient; |
|
|
|
@Resource |
|
|
|
private GridstaffInfoPingyinDao gridstaffInfoPingyinDao; |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取上报事件 |
|
|
|
* |
|
|
|
* @param formDTO |
|
|
|
* @Param formDTO |
|
|
|
* @Return |
|
|
|
* @Author zhaoqifeng |
|
|
|
* @Date 2021/10/15 16:59 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void getEventInfo(EventInfoFormDTO formDTO) { |
|
|
|
formDTO.setPageSize(1000); |
|
|
|
long start = System.currentTimeMillis(); |
|
|
|
if (NumConstant.ONE_STR.equals(formDTO.getInitFlag())) { |
|
|
|
//清空表里数据
|
|
|
|
baseDao.deleteAllData(); |
|
|
|
} |
|
|
|
Result<List<EventInfoResultDTO>> result = dataStatisticalOpenFeignClient.getEventInfoV2(formDTO); |
|
|
|
if (!result.success()) { |
|
|
|
log.error("getEventinfo cost:{}ms",System.currentTimeMillis()-start); |
|
|
|
throw new RenException(result.getInternalMsg()); |
|
|
|
} |
|
|
|
List<EventInfoResultDTO> list = result.getData(); |
|
|
|
saveEvent(list, formDTO.getInitFlag()); |
|
|
|
//分批次循环
|
|
|
|
while (CollectionUtils.isNotEmpty(list) && list.size() == formDTO.getPageSize()) { |
|
|
|
formDTO.setPageNo(formDTO.getPageNo() + NumConstant.ONE); |
|
|
|
result = dataStatisticalOpenFeignClient.getEventInfo(formDTO); |
|
|
|
list = result.getData(); |
|
|
|
saveEvent(list, formDTO.getInitFlag()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void saveEvent(List<EventInfoResultDTO> list, String initFlag) { |
|
|
|
if (CollectionUtils.isEmpty(list)) { |
|
|
|
log.warn("no event data to save table base_conflicts_resolve"); |
|
|
|
return; |
|
|
|
} |
|
|
|
List<EventreportPingyinEntity> entityList = list.stream().map(item -> { |
|
|
|
EventreportPingyinEntity entity = new EventreportPingyinEntity(); |
|
|
|
entity.setQxBm("370124"); |
|
|
|
entity.setQxMc("平阴县"); |
|
|
|
entity.setGridCode(item.getOrgCode()); |
|
|
|
entity.setGridName(item.getOrgName()); |
|
|
|
entity.setEventCode(("py_").concat(item.getId())); |
|
|
|
entity.setEventName(item.getEventName()); |
|
|
|
entity.setEventCategory(item.getEventCategory()); |
|
|
|
entity.setGridUserCardid(""); |
|
|
|
entity.setGridUserName(""); |
|
|
|
LambdaQueryWrapper<GridstaffInfoPingyinEntity> staffWrapper = new LambdaQueryWrapper<>(); |
|
|
|
staffWrapper.eq(GridstaffInfoPingyinEntity::getGridUserId, item.getReporterId()); |
|
|
|
List<GridstaffInfoPingyinEntity> staffList = gridstaffInfoPingyinDao.selectList(staffWrapper); |
|
|
|
if (CollectionUtils.isNotEmpty(staffList)) { |
|
|
|
entity.setGridUserCardid(staffList.get(NumConstant.ZERO).getCardNum()); |
|
|
|
entity.setGridUserName(staffList.get(NumConstant.ZERO).getNickName()); |
|
|
|
} |
|
|
|
|
|
|
|
entity.setReportTime(item.getReportTime()); |
|
|
|
entity.setHappenTime(item.getHappenDate()); |
|
|
|
entity.setHappenPlace(item.getHappenPlace()); |
|
|
|
String eventDescription = item.getEventDescription(); |
|
|
|
//如果不为空 长度控制1000以内
|
|
|
|
if (StringUtils.isNotBlank(eventDescription) && eventDescription.length() > NumConstant.ONE_THOUSAND) { |
|
|
|
eventDescription = eventDescription.substring(NumConstant.ZERO, NumConstant.ONE_THOUSAND); |
|
|
|
} |
|
|
|
entity.setEventDescription(eventDescription); |
|
|
|
entity.setWaysOfResolving(item.getWaysOfResolving()); |
|
|
|
//业务不确定
|
|
|
|
if (("03").equals(item.getStatus())) { |
|
|
|
entity.setSuccessfulOrNo("Y"); |
|
|
|
} else { |
|
|
|
entity.setSuccessfulOrNo("N"); |
|
|
|
} |
|
|
|
entity.setCompleteLevel(item.getCompleteLevel()); |
|
|
|
entity.setCompleteTime(item.getCompleteTime()); |
|
|
|
entity.setLng(null == item.getLng() ? null : item.getLng()); |
|
|
|
entity.setLat(null == item.getLat() ? null : item.getLat()); |
|
|
|
entity.setIsDel("N"); |
|
|
|
|
|
|
|
//业务不包含 一级分类里 如果是03 矛盾纠纷 则涉及人数写2(目前业务不支持 所以应产品需求 填2)
|
|
|
|
if ("03".equals(item.getParentEventCategory())) { |
|
|
|
entity.setNumberInvolved(NumConstant.TWO); |
|
|
|
} |
|
|
|
return entity; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
if (NumConstant.ZERO_STR.equals(initFlag)) { |
|
|
|
entityList.forEach(entity -> { |
|
|
|
LambdaQueryWrapper<EventreportPingyinEntity> wrapper = new LambdaQueryWrapper<>(); |
|
|
|
wrapper.eq(EventreportPingyinEntity::getEventCode, entity.getEventCode()); |
|
|
|
EventreportPingyinEntity event = baseDao.selectOne(wrapper); |
|
|
|
if (null == event) { |
|
|
|
baseDao.insert(entity); |
|
|
|
} else { |
|
|
|
entity.setId(event.getId()); |
|
|
|
baseDao.updateById(entity); |
|
|
|
} |
|
|
|
}); |
|
|
|
} else { |
|
|
|
insertBatch(entityList); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |