Browse Source

改掉错误

dev
jianjun 4 years ago
parent
commit
d436a9a22e
  1. 8
      epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/dto/form/UpsertPatrolRecordForm.java
  2. 4
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/BaseGridDailyworkController.java
  3. 2
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/BaseGridDailyworkDao.java
  4. 5
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/entity/BaseGridDailyworkEntity.java
  5. 51
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/BaseGridDailyworkServiceImpl.java
  6. 2
      epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/BaseGridDailyworkDao.xml

8
epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/dto/form/UpsertPatrolRecordForm.java

@ -1,6 +1,8 @@
package com.epmet.opendata.dto.form;
import com.epmet.commons.tools.dto.form.PageFormDTO;
import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.DefaultGroup;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
@ -11,15 +13,17 @@ import javax.validation.constraints.NotEmpty;
*/
@Data
public class UpsertPatrolRecordForm extends PageFormDTO {
/**
* 客户Id
*/
@NotEmpty(message = "customerId不能为空")
@NotEmpty(message = "customerId不能为空",groups = {DefaultGroup.class,AddGroup.class})
private String customerId;
/**
* 记录id
*/
@NotEmpty(message = "id不能为空",groups = AddGroup.class)
private String id;
/**
@ -27,7 +31,7 @@ public class UpsertPatrolRecordForm extends PageFormDTO {
* SystemMessageType.USER_PATROL_START
* SystemMessageTypSTOP
*/
@NotEmpty(message = "actionType不能为空")
@NotEmpty(message = "actionType不能为空",groups = DefaultGroup.class)
private String actionType;
}

4
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/BaseGridDailyworkController.java

@ -20,6 +20,7 @@ package com.epmet.opendata.controller;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.opendata.dto.form.UpsertPatrolRecordForm;
import com.epmet.opendata.service.BaseGridDailyworkService;
import org.springframework.beans.factory.annotation.Autowired;
@ -42,14 +43,13 @@ public class BaseGridDailyworkController {
@Autowired
private BaseGridDailyworkService baseGridDailyworkService;
/**
* @Author sun
* @Description 巡查信息中间库同步 分页
**/
@PostMapping("sync")
public Result getStaffBaseInfo(@RequestBody(required = false) UpsertPatrolRecordForm formDTO) {
ValidatorUtils.validateEntity(formDTO);
ValidatorUtils.validateEntity(formDTO, DefaultGroup.class);
baseGridDailyworkService.insertPatrolRecord(formDTO);
return new Result();
}

2
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/PatrolRoutineWorkDao.java → epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/BaseGridDailyworkDao.java

@ -29,6 +29,6 @@ import org.apache.ibatis.annotations.Mapper;
* @since v1.0.0 2021-12-24
*/
@Mapper
public interface PatrolRoutineWorkDao extends BaseDao<BaseGridDailyworkEntity> {
public interface BaseGridDailyworkDao extends BaseDao<BaseGridDailyworkEntity> {
}

5
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/entity/BaseGridDailyworkEntity.java

@ -17,6 +17,7 @@
package com.epmet.opendata.entity;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -127,8 +128,8 @@ public class BaseGridDailyworkEntity implements Serializable {
/**
* 抽取状态0是未抽取1代表已抽取2是抽取失败
*/
private String flag;
//private String flag;
@TableLogic
private String delFlag;
/**

51
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/BaseGridDailyworkServiceImpl.java

@ -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);

2
epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/PatrolRoutineWorkDao.xml → epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/BaseGridDailyworkDao.xml

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.opendata.dao.PatrolRoutineWorkDao">
<mapper namespace="com.epmet.opendata.dao.BaseGridDailyworkDao">
<resultMap type="com.epmet.opendata.entity.BaseGridDailyworkEntity" id="patrolRoutineWorkMap">
<result property="id" column="ID"/>
Loading…
Cancel
Save