diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/PageFormDTO.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/PageFormDTO.java
index c699557bac..4820f4d50b 100644
--- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/PageFormDTO.java
+++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/PageFormDTO.java
@@ -30,11 +30,6 @@ public class PageFormDTO {
*/
private Integer offset;
- /**
- * 是否分页 默认分页
- */
- private boolean isPage = true;
-
public Integer getOffset() {
return (pageNo-1)*pageSize;
}
diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/MidPatrolRecordResult.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/MidPatrolRecordResult.java
index a08d7cba17..12c18962d1 100644
--- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/MidPatrolRecordResult.java
+++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/MidPatrolRecordResult.java
@@ -129,4 +129,9 @@ public class MidPatrolRecordResult implements Serializable {
*/
private String longitude;
+ /**
+ * 经纬度组合成的路线 经度,维度;
+ */
+ private String route;
+
}
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/UserDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/UserDao.xml
index 78e124791c..bc20519148 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/UserDao.xml
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/UserDao.xml
@@ -1006,20 +1006,38 @@
diff --git a/epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/dto/form/UpsertPatrolRecordForm.java b/epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/dto/form/UpsertPatrolRecordForm.java
index 3fd1db81ac..d80157031e 100644
--- a/epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/dto/form/UpsertPatrolRecordForm.java
+++ b/epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/dto/form/UpsertPatrolRecordForm.java
@@ -1,5 +1,6 @@
package com.epmet.opendata.dto.form;
+import com.epmet.commons.tools.dto.form.PageFormDTO;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
@@ -9,7 +10,7 @@ import javax.validation.constraints.NotEmpty;
* @author liujianjun
*/
@Data
-public class UpsertPatrolRecordForm {
+public class UpsertPatrolRecordForm extends PageFormDTO {
/**
* 客户Id
*/
@@ -19,7 +20,6 @@ public class UpsertPatrolRecordForm {
/**
* 巡查记录id
*/
- @NotEmpty(message = "patrolId不能为空")
private String patrolId;
/**
diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/InitDataController.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/InitDataController.java
index e8da4e413e..38fe35fd15 100644
--- a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/InitDataController.java
+++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/InitDataController.java
@@ -18,10 +18,14 @@
package com.epmet.opendata.controller;
import com.epmet.commons.tools.utils.Result;
+import com.epmet.constant.SystemMessageType;
import com.epmet.opendata.dto.form.UpsertPatrolRecordForm;
import com.epmet.opendata.service.UserPatrolRecordService;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
/**
@@ -42,9 +46,7 @@ public class InitDataController {
* @Description 网格员信息中间库同步
**/
@PostMapping("patrol/{customerId}")
- public Result getStaffBaseInfo(@PathVariable String customerId) {
- UpsertPatrolRecordForm formDTO = new UpsertPatrolRecordForm();
- formDTO.setCustomerId(customerId);
- return new Result().ok(userPatrolRecordService.insertPatrolRecord(formDTO));
+ public Result reloadPatrolData(@PathVariable String customerId) {
+ return new Result().ok(userPatrolRecordService.reloadPatrolData(customerId));
}
}
diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/UserPatrolDetailService.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/UserPatrolDetailService.java
index b6ca5b2c47..13cde46235 100644
--- a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/UserPatrolDetailService.java
+++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/UserPatrolDetailService.java
@@ -29,4 +29,7 @@ import com.epmet.opendata.entity.UserPatrolDetailEntity;
public interface UserPatrolDetailService extends BaseService {
+ int deleteByPatrolId(String patrolId);
+
+ int deleteByCustomerId(String customerId);
}
diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/UserPatrolRecordService.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/UserPatrolRecordService.java
index 45d894e531..e6896f32b8 100644
--- a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/UserPatrolRecordService.java
+++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/UserPatrolRecordService.java
@@ -42,4 +42,12 @@ public interface UserPatrolRecordService extends BaseService implements UserPatrolDetailService {
+ @Override
+ public int deleteByPatrolId(String patrolId) {
+ LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>();
+ wrapper.eq(UserPatrolDetailEntity::getStaffPatrolRecId, patrolId);
+ return baseDao.delete(wrapper);
+ }
+ @Override
+ public int deleteByCustomerId(String customerId) {
+ LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>();
+ wrapper.eq(UserPatrolDetailEntity::getCustomerId, customerId);
+ return baseDao.delete(wrapper);
+ }
}
diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/UserPatrolRecordServiceImpl.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/UserPatrolRecordServiceImpl.java
index 105b170038..cfa413dbe2 100644
--- a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/UserPatrolRecordServiceImpl.java
+++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/UserPatrolRecordServiceImpl.java
@@ -18,21 +18,19 @@
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.dto.user.param.MidPatrolFormDTO;
import com.epmet.dto.user.result.MidPatrolDetailResult;
import com.epmet.dto.user.result.MidPatrolRecordResult;
import com.epmet.feign.DataStatisticalOpenFeignClient;
-import com.epmet.opendata.dao.UserPatrolDetailDao;
import com.epmet.opendata.dao.UserPatrolRecordDao;
import com.epmet.opendata.dto.form.UpsertPatrolRecordForm;
import com.epmet.opendata.entity.UserPatrolDetailEntity;
import com.epmet.opendata.entity.UserPatrolRecordEntity;
+import com.epmet.opendata.service.UserPatrolDetailService;
import com.epmet.opendata.service.UserPatrolRecordService;
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
@@ -57,13 +55,12 @@ public class UserPatrolRecordServiceImpl extends BaseServiceImpl> record = dataStatisticalOpenFeignClient.getPatrolRecordList(midPatrolFormDTO);
if (record == null || !record.success()) {
@@ -73,7 +70,6 @@ public class UserPatrolRecordServiceImpl extends BaseServiceImpl data = record.getData();
if (CollectionUtils.isEmpty(data)) {
//数据已被删除了
- delFlag = true;
//暂时设置error 用于排错
log.error("获取巡查记录返回为空,param:{}", JSON.toJSONString(midPatrolFormDTO));
int effectRow = baseDao.deleteById(patrolRecordForm.getPatrolId());
@@ -117,37 +113,82 @@ public class UserPatrolRecordServiceImpl extends BaseServiceImpl> detailResult = dataStatisticalOpenFeignClient.getPatrolDetailList(midPatrolFormDTO);
if (detailResult == null || !detailResult.success()) {
log.error("获取巡查记录明细失败,param:{}", JSON.toJSONString(midPatrolFormDTO));
return;
}
- UserPatrolDetailEntity detailEntity = buildDetailEntity(o, detailResult);
+ UserPatrolDetailEntity detailEntity = buildDetailEntity(o);
//先删除再新增
- LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>();
- wrapper.eq(UserPatrolDetailEntity::getStaffPatrolRecId, recordEntity.getId());
- userPatrolDetailDao.delete(wrapper);
- int insert = userPatrolDetailDao.insert(detailEntity);
+ userPatrolDetailService.deleteByPatrolId(recordEntity.getId());
+ boolean insert = userPatrolDetailService.insert(detailEntity);
});
return true;
}
+ @Override
+ public Boolean reloadPatrolData(String customerId) {
+ int pageNo = 1;
+ int pageSize = 1000;
+ List resultList = null;
+ do {
+ MidPatrolFormDTO param = new MidPatrolFormDTO();
+ param.setCustomerId(customerId);
+ param.setPageNo(pageNo++);
+ param.setPageSize(pageSize);
+ Result> record = dataStatisticalOpenFeignClient.getPatrolRecordList(param);
+ if (record == null || !record.success()) {
+ log.error("获取巡查记录失败,param:{}", JSON.toJSONString(param));
+ return false;
+ }
+ resultList = record.getData();
+ if (CollectionUtils.isEmpty(resultList)){
+ log.warn("不存在巡查记录,param:{}", JSON.toJSONString(param));
+ return false;
+ }
+ insertRecordBatch(resultList,true);
+
+
+
+ }while (!CollectionUtils.isEmpty(resultList) && resultList.size()> pageSize );
+
+ return null;
+ }
+ private Boolean insertRecordBatch(List list,boolean isReload){
+ List insertList = new ArrayList<>();
+ list.forEach(o-> insertList.add(buildEntity(o)));
+ //insert
+ if (CollectionUtils.isEmpty(insertList)){
+ log.error("构建要插入的数据为空,param:{}", JSON.toJSONString(list));
+ return false;
+ }
+ if (isReload){
+ userPatrolDetailService.deleteByCustomerId(list.get(0).getCustomerId());
+ }
+ this.insertBatch(insertList, NumConstant.ONE_HUNDRED);
+ List insertDetailList = new ArrayList<>();
+ list.forEach(o-> {
+ insertDetailList.add(buildDetailEntity(o));
+ if (!isReload){
+ //先删除再新增
+ userPatrolDetailService.deleteByPatrolId(o.getId());
+ }
+ });
+ if (CollectionUtils.isEmpty(insertList)){
+ log.warn("构建要插入的数据为空,param:{}", JSON.toJSONString(list));
+ }
+ userPatrolDetailService.insertBatch(insertDetailList, NumConstant.ONE_HUNDRED);
+ return true;
+ }
+
@NotNull
- private UserPatrolDetailEntity buildDetailEntity(MidPatrolRecordResult recordResult, Result> detailResult) {
+ private UserPatrolDetailEntity buildDetailEntity(MidPatrolRecordResult recordResult) {
UserPatrolDetailEntity detailEntity = new UserPatrolDetailEntity();
detailEntity.setCustomerId(recordResult.getCustomerId());
detailEntity.setStaffPatrolRecId(recordResult.getId());
- StringBuilder sb = new StringBuilder();
- detailResult.getData().forEach(o -> {
- sb.append(o.getLongitude())
- .append(StrConstant.COMMA)
- .append(o.getLatitude())
- .append(StrConstant.SEMICOLON);
- });
- detailEntity.setRoute(sb.toString());
+ detailEntity.setRoute(recordResult.getRoute());
detailEntity.setId(recordResult.getId());
detailEntity.setRevision(recordResult.getRevision());
detailEntity.setCreatedBy(recordResult.getCreatedBy());
@@ -188,8 +229,8 @@ public class UserPatrolRecordServiceImpl extends BaseServiceImpl