|
|
@ -18,25 +18,23 @@ |
|
|
|
package com.epmet.opendata.service.impl; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
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.constant.StrConstant; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.commons.tools.validator.ValidatorUtils; |
|
|
|
import com.epmet.commons.tools.validator.group.AddGroup; |
|
|
|
import com.epmet.dto.form.patrol.PatrolQueryFormDTO; |
|
|
|
import com.epmet.dto.result.PatrolRoutineWorkResult; |
|
|
|
import com.epmet.dto.user.result.MidPatrolRecordResult; |
|
|
|
import com.epmet.feign.EpmetUserOpenFeignClient; |
|
|
|
import com.epmet.opendata.dao.PatrolRoutineWorkDao; |
|
|
|
import com.epmet.opendata.dao.BaseGridDailyworkDao; |
|
|
|
import com.epmet.opendata.dto.ExDeptDTO; |
|
|
|
import com.epmet.opendata.dto.ExUserDTO; |
|
|
|
import com.epmet.opendata.dto.form.UpsertPatrolRecordForm; |
|
|
|
import com.epmet.opendata.entity.BaseGridDailyworkEntity; |
|
|
|
import com.epmet.opendata.entity.UserPatrolDetailEntity; |
|
|
|
import com.epmet.opendata.service.BaseGridDailyworkService; |
|
|
|
import com.epmet.opendata.service.ExDeptService; |
|
|
|
import com.epmet.opendata.service.ExUserService; |
|
|
|
import com.epmet.opendata.service.BaseGridDailyworkService; |
|
|
|
import com.epmet.opendata.service.UserPatrolDetailService; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.jetbrains.annotations.NotNull; |
|
|
@ -57,7 +55,7 @@ import java.util.Map; |
|
|
|
*/ |
|
|
|
@Slf4j |
|
|
|
@Service |
|
|
|
public class BaseGridDailyworkServiceImpl extends BaseServiceImpl<PatrolRoutineWorkDao, BaseGridDailyworkEntity> implements BaseGridDailyworkService { |
|
|
|
public class BaseGridDailyworkServiceImpl extends BaseServiceImpl<BaseGridDailyworkDao, BaseGridDailyworkEntity> implements BaseGridDailyworkService { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private EpmetUserOpenFeignClient epmetUserOpenFeignClient; |
|
|
@ -71,7 +69,7 @@ public class BaseGridDailyworkServiceImpl extends BaseServiceImpl<PatrolRoutineW |
|
|
|
@Override |
|
|
|
public Boolean insertPatrolRecord(UpsertPatrolRecordForm patrolRecordForm) { |
|
|
|
log.info("upsertPatrolRecord param:{}", JSON.toJSONString(patrolRecordForm)); |
|
|
|
ValidatorUtils.validateEntity(patrolRecordForm); |
|
|
|
ValidatorUtils.validateEntity(patrolRecordForm, AddGroup.class); |
|
|
|
PatrolQueryFormDTO midPatrolFormDTO = buildParam(patrolRecordForm); |
|
|
|
Result<List<PatrolRoutineWorkResult>> record = epmetUserOpenFeignClient.getPatrolRoutineWorkList(midPatrolFormDTO); |
|
|
|
if (record == null || !record.success()) { |
|
|
@ -89,7 +87,7 @@ public class BaseGridDailyworkServiceImpl extends BaseServiceImpl<PatrolRoutineW |
|
|
|
log.warn("del effectRow:{}", effectRow); |
|
|
|
return true; |
|
|
|
} |
|
|
|
insertRecordBatch(data,false, deptMap, userMap); |
|
|
|
insertRecordBatch(data, deptMap, userMap); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
@ -115,12 +113,12 @@ public class BaseGridDailyworkServiceImpl extends BaseServiceImpl<PatrolRoutineW |
|
|
|
log.warn("不存在例行工作记录,param:{}", JSON.toJSONString(param)); |
|
|
|
return false; |
|
|
|
} |
|
|
|
insertRecordBatch(resultList,true, deptMap, userMap); |
|
|
|
insertRecordBatch(resultList, deptMap, userMap); |
|
|
|
}while (!CollectionUtils.isEmpty(resultList) && resultList.size()> pageSize ); |
|
|
|
|
|
|
|
return null; |
|
|
|
} |
|
|
|
private Boolean insertRecordBatch(List<PatrolRoutineWorkResult> list, boolean isReload, Map<String, ExDeptDTO> deptMap, Map<String, ExUserDTO> userMap){ |
|
|
|
private Boolean insertRecordBatch(List<PatrolRoutineWorkResult> list, Map<String, ExDeptDTO> deptMap, Map<String, ExUserDTO> userMap){ |
|
|
|
List<BaseGridDailyworkEntity> insertList = new ArrayList<>(); |
|
|
|
list.forEach(o-> insertList.add(buildEntity(o, deptMap, userMap))); |
|
|
|
//insert
|
|
|
@ -128,34 +126,11 @@ public class BaseGridDailyworkServiceImpl extends BaseServiceImpl<PatrolRoutineW |
|
|
|
log.error("构建要插入的数据为空,param:{}", JSON.toJSONString(list)); |
|
|
|
return false; |
|
|
|
} |
|
|
|
if (isReload){ |
|
|
|
int i = userPatrolDetailService.deleteByCustomerId(list.get(0).getCustomerId()); |
|
|
|
log.info("insertRecordBatch del patrol effectRow:{}",i); |
|
|
|
} |
|
|
|
LambdaQueryWrapper<BaseGridDailyworkEntity> wrapper = new LambdaQueryWrapper<>(); |
|
|
|
wrapper.eq(BaseGridDailyworkEntity::getCustomerId, list.get(0).getCustomerId()); |
|
|
|
int delete = baseDao.delete(wrapper); |
|
|
|
log.info("insertRecordBatch del patrol effectRow:{}",delete); |
|
|
|
this.saveOrUpdateBatch(insertList, NumConstant.ONE_HUNDRED); |
|
|
|
|
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
@NotNull |
|
|
|
private UserPatrolDetailEntity buildDetailEntity(MidPatrolRecordResult recordResult) { |
|
|
|
UserPatrolDetailEntity detailEntity = new UserPatrolDetailEntity(); |
|
|
|
detailEntity.setCustomerId(recordResult.getCustomerId()); |
|
|
|
detailEntity.setStaffPatrolRecId(recordResult.getId()); |
|
|
|
detailEntity.setRoute(recordResult.getRoute()); |
|
|
|
detailEntity.setId(recordResult.getId()); |
|
|
|
detailEntity.setRevision(recordResult.getRevision()); |
|
|
|
detailEntity.setCreatedBy(recordResult.getCreatedBy()); |
|
|
|
detailEntity.setCreatedTime(recordResult.getCreatedTime()); |
|
|
|
detailEntity.setUpdatedBy(recordResult.getUpdatedBy()); |
|
|
|
detailEntity.setUpdatedTime(recordResult.getUpdatedTime()); |
|
|
|
detailEntity.setDelFlag(String.valueOf(recordResult.getDelFlag())); |
|
|
|
return detailEntity; |
|
|
|
} |
|
|
|
|
|
|
|
private BaseGridDailyworkEntity buildEntity(PatrolRoutineWorkResult record, Map<String, ExDeptDTO> deptMap, Map<String, ExUserDTO> userMap) { |
|
|
|
BaseGridDailyworkEntity entity = new BaseGridDailyworkEntity(); |
|
|
@ -178,13 +153,15 @@ public class BaseGridDailyworkServiceImpl extends BaseServiceImpl<PatrolRoutineW |
|
|
|
entity.setIsKeyareaState(StrConstant.EPMETY_STR); |
|
|
|
entity.setIsKeyPeopleLocate(NumConstant.ONE == record.getIsKeyPeopleLocate()?"Y":"N"); |
|
|
|
entity.setKeyPeopleStatus(record.getKeyPeopleStatus()); |
|
|
|
entity.setHappenPlace(record.getHappenTime()); |
|
|
|
entity.setHappenPlace(record.getAddress()); |
|
|
|
entity.setLng(record.getLongitude()); |
|
|
|
entity.setLat(record.getLatitude()); |
|
|
|
entity.setFlag(NumConstant.ZERO_STR); |
|
|
|
entity.setCreateBy(userMap.getOrDefault(record.getCreatedBy(), new ExUserDTO()).getUserId()+""); |
|
|
|
//entity.setFlag(NumConstant.ZERO_STR);
|
|
|
|
Integer userId = userMap.getOrDefault(record.getCreatedBy(), new ExUserDTO()).getUserId(); |
|
|
|
entity.setCreateBy(userId == null?record.getCreatedBy():userId.toString()); |
|
|
|
entity.setCreateTime(record.getCreatedTime()); |
|
|
|
entity.setUpdateBy(userMap.getOrDefault(record.getUpdatedBy(), new ExUserDTO()).getUserId()+""); |
|
|
|
Integer userIdU = userMap.getOrDefault(record.getUpdatedBy(), new ExUserDTO()).getUserId(); |
|
|
|
entity.setUpdateBy(userIdU == null? record.getCreatedBy():userIdU.toString()); |
|
|
|
entity.setUpdateTime(record.getUpdatedTime()); |
|
|
|
entity.setId(record.getId()+"_PY"); |
|
|
|
entity.setDelFlag(NumConstant.ZERO_STR); |
|
|
|