diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/PatrolRoutineWorkDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/PatrolRoutineWorkDTO.java
deleted file mode 100644
index d0c66c1a07..0000000000
--- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/PatrolRoutineWorkDTO.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/**
- * Copyright 2018 人人开源 https://www.renren.io
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.epmet.dto;
-
-import lombok.Data;
-
-import java.io.Serializable;
-import java.util.Date;
-
-
-/**
- * 巡查例行工作
- *
- * @author generator generator@elink-cn.com
- * @since v1.0.0 2021-12-21
- */
-@Data
-public class PatrolRoutineWorkDTO implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- /**
- * 唯一标识
- */
- private String id;
-
- /**
- * 客户Id customer.id
- */
- private String customerId;
-
- /**
- * 网格表Id(CUSTOMER_GRID.id)【居民党员角色值为all,热心居民角色对应的网格Id】
- */
- private String gridId;
-
- /**
- * 网格所有上级id
- */
- private String pids;
-
- /**
- * 用户Id user.id
- */
- private String userId;
-
- /**
- * 事项名称
- */
- private String title;
-
- /**
- * 工作日期 格式为“YYYY-MM-DD”
- */
- private String happenTime;
-
- /**
- * 有无变动(异常)1:是、0:否
- */
- private Integer isNormal;
-
- /**
- * 工作内容
- */
- private String workContent;
-
- /**
- * 经度
- */
- private String longitude;
-
- /**
- * 纬度
- */
- private String latitude;
-
- /**
- * 删除标识:0.未删除 1.已删除
- */
- private Integer delFlag;
-
- /**
- * 乐观锁
- */
- private Integer revision;
-
- /**
- * 创建人
- */
- private String createdBy;
-
- /**
- * 创建时间
- */
- private Date createdTime;
-
- /**
- * 更新人
- */
- private String updatedBy;
-
- /**
- * 更新时间
- */
- private Date updatedTime;
-
-}
diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/PatrolRoutineWorkTypeDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/PatrolRoutineWorkTypeDTO.java
deleted file mode 100644
index 505384ec36..0000000000
--- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/PatrolRoutineWorkTypeDTO.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/**
- * Copyright 2018 人人开源 https://www.renren.io
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.epmet.dto;
-
-import java.io.Serializable;
-import java.util.Date;
-import lombok.Data;
-
-
-/**
- * 巡查例行工作
- *
- * @author generator generator@elink-cn.com
- * @since v1.0.0 2021-12-21
- */
-@Data
-public class PatrolRoutineWorkTypeDTO implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- /**
- * 唯一标识
- */
- private String id;
-
- /**
- * 客户Id customer.id
- */
- private String customerId;
-
- /**
- * 例行工作Id
- */
- private String routineWorkId;
-
- /**
- * 例行工作字典项值;type:patrol_work_type
- */
- private String workTypeCode;
-
- /**
- * 所有上级类别code组合
- */
- private String allPCode;
-
- /**
- * 删除标识:0.未删除 1.已删除
- */
- private Integer delFlag;
-
- /**
- * 乐观锁
- */
- private Integer revision;
-
- /**
- * 创建人
- */
- private String createdBy;
-
- /**
- * 创建时间
- */
- private Date createdTime;
-
- /**
- * 更新人
- */
- private String updatedBy;
-
- /**
- * 更新时间
- */
- private Date updatedTime;
-
-}
\ No newline at end of file
diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/GridUserWorkFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/PatrolRoutineWorkFormDTO.java
similarity index 56%
rename from epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/GridUserWorkFormDTO.java
rename to epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/PatrolRoutineWorkFormDTO.java
index f9b029d423..520e04d105 100644
--- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/GridUserWorkFormDTO.java
+++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/PatrolRoutineWorkFormDTO.java
@@ -16,36 +16,39 @@ import java.util.List;
* @DESC
*/
@Data
-public class GridUserWorkFormDTO implements Serializable {
+public class PatrolRoutineWorkFormDTO implements Serializable {
private static final long serialVersionUID = 3411355616849866888L;
- public interface AddOrUpdateForm {}
+ public interface AddOrUpdateForm {
+ }
private String customerId;
- @NotBlank(message = "网格ID不能为空",groups = AddOrUpdateForm.class)
+ @NotBlank(message = "网格ID不能为空", groups = AddOrUpdateForm.class)
private String gridId;
- @NotBlank(message = "事项名称不能为空",groups = AddOrUpdateForm.class)
+ @NotBlank(message = "事项名称不能为空", groups = AddOrUpdateForm.class)
private String title;
- @NotEmpty(message = "例行工作类型不能为空",groups = AddOrUpdateForm.class)
+ @NotEmpty(message = "例行工作类型不能为空", groups = AddOrUpdateForm.class)
private List workTypeList;
- @Range(min = 0,max = 1, message = "有无变动(异常)不能为空",groups = AddOrUpdateForm.class)
+ @Range(min = 0, max = 1, message = "有无变动(异常)格式错误", groups = AddOrUpdateForm.class)
+ @NotNull(message = "有无变动(异常)不能为空", groups = AddOrUpdateForm.class)
private Integer isNormal;
@JsonFormat(pattern = "yyyy-MM-dd")
- @NotNull(message = "发生时间不能为空",groups = AddOrUpdateForm.class)
+ @NotNull(message = "发生时间不能为空", groups = AddOrUpdateForm.class)
private String happenTime;
- @NotBlank(message = "工作简介不能为空",groups = AddOrUpdateForm.class)
+ @NotBlank(message = "工作简介不能为空", groups = AddOrUpdateForm.class)
private String workContent;
- @NotBlank(message = "工作地点不能为空",groups = AddOrUpdateForm.class)
+ @NotBlank(message = "工作地点不能为空", groups = AddOrUpdateForm.class)
private String address;
+
/**
* 基础信息ID【相关信息】暂时没有
*/
@@ -60,5 +63,4 @@ public class GridUserWorkFormDTO implements Serializable {
private String latitude;
-
}
diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/PatrolRoutineWorkController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/PatrolRoutineWorkController.java
index fada3dca9a..aa970dee00 100644
--- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/PatrolRoutineWorkController.java
+++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/PatrolRoutineWorkController.java
@@ -3,13 +3,13 @@ package com.epmet.controller;
import com.epmet.commons.tools.aop.NoRepeatSubmit;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
-import com.epmet.dto.form.GridUserWorkFormDTO;
+import com.epmet.dto.form.PatrolRoutineWorkFormDTO;
import com.epmet.service.PatrolRoutineWorkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
- * 网格员例行工作
+ * 例行工作
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-10-19
@@ -22,16 +22,16 @@ public class PatrolRoutineWorkController {
private PatrolRoutineWorkService gridUserWorkService;
/**
- * @Description 网格员例行工作
+ * @Description 添加例行工作
* @param formDTO
* @author zxc
* @date 2021/10/19 1:35 下午
*/
@NoRepeatSubmit
@PostMapping("add")
- public Result gridUserWork( @RequestBody GridUserWorkFormDTO formDTO){
- ValidatorUtils.validateEntity(formDTO, GridUserWorkFormDTO.AddOrUpdateForm.class);
- gridUserWorkService.gridUserWork(formDTO);
+ public Result gridUserWork( @RequestBody PatrolRoutineWorkFormDTO formDTO){
+ ValidatorUtils.validateEntity(formDTO, PatrolRoutineWorkFormDTO.AddOrUpdateForm.class);
+ gridUserWorkService.add(formDTO);
return new Result().ok(true);
}
diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/PatrolRoutineWorkService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/PatrolRoutineWorkService.java
index f463510d5f..f30a19f244 100644
--- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/PatrolRoutineWorkService.java
+++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/PatrolRoutineWorkService.java
@@ -18,14 +18,9 @@
package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService;
-import com.epmet.commons.tools.page.PageData;
-import com.epmet.dto.PatrolRoutineWorkDTO;
-import com.epmet.dto.form.GridUserWorkFormDTO;
+import com.epmet.dto.form.PatrolRoutineWorkFormDTO;
import com.epmet.entity.PatrolRoutineWorkEntity;
-import java.util.List;
-import java.util.Map;
-
/**
* 巡查例行工作
*
@@ -34,5 +29,9 @@ import java.util.Map;
*/
public interface PatrolRoutineWorkService extends BaseService {
- void gridUserWork(GridUserWorkFormDTO formDTO);
+ /**
+ * desc:添加例行工作
+ * @param formDTO
+ */
+ void add(PatrolRoutineWorkFormDTO formDTO);
}
diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/PatrolRoutineWorkServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/PatrolRoutineWorkServiceImpl.java
index 9a4b73bb26..91e2c520df 100644
--- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/PatrolRoutineWorkServiceImpl.java
+++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/PatrolRoutineWorkServiceImpl.java
@@ -17,11 +17,11 @@
package com.epmet.service.impl;
+import com.alibaba.fastjson.JSON;
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.dto.form.DictListFormDTO;
-import com.epmet.commons.tools.dto.result.DictListResultDTO;
+import com.epmet.commons.tools.dto.result.DictTreeResultDTO;
import com.epmet.commons.tools.enums.DictTypeEnum;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
@@ -31,13 +31,14 @@ import com.epmet.commons.tools.utils.Result;
import com.epmet.dao.PatrolRoutineWorkDao;
import com.epmet.dto.CustomerGridDTO;
import com.epmet.dto.form.CustomerGridFormDTO;
-import com.epmet.dto.form.GridUserWorkFormDTO;
+import com.epmet.dto.form.PatrolRoutineWorkFormDTO;
import com.epmet.entity.PatrolRoutineWorkEntity;
import com.epmet.entity.PatrolRoutineWorkTypeEntity;
import com.epmet.feign.EpmetAdminOpenFeignClient;
import com.epmet.feign.GovOrgOpenFeignClient;
import com.epmet.service.PatrolRoutineWorkService;
import com.epmet.service.PatrolRoutineWorkTypeService;
+import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -47,7 +48,6 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.stream.Collectors;
/**
* 巡查例行工作
@@ -55,6 +55,7 @@ import java.util.stream.Collectors;
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-12-21
*/
+@Slf4j
@Service
public class PatrolRoutineWorkServiceImpl extends BaseServiceImpl implements PatrolRoutineWorkService {
@Autowired
@@ -62,71 +63,100 @@ public class PatrolRoutineWorkServiceImpl extends BaseServiceImpl gridBaseInfoData = govOrgOpenFeignClient.getGridBaseInfoByGridId(gridFormDTO);
- if (!gridBaseInfoData.success()){
+ if (!gridBaseInfoData.success()) {
throw new EpmetException("查询网格基本信息失败......");
}
CustomerGridDTO gridBaseInfo = gridBaseInfoData.getData();
entity.setPids(gridBaseInfo.getPids());
- //entity.setUserId(loginUserUtil.getLoginUserId());
- //entity.setCustomerId(loginUserUtil.getLoginUserCustomerId());
+ entity.setUserId(loginUserUtil.getLoginUserId());
+ entity.setCustomerId(loginUserUtil.getLoginUserCustomerId());
- entity.setUserId("loginUserUtil.getLoginUserId()");
- entity.setCustomerId("loginUserUtil.getLoginUserCustomerId()");
+ //entity.setUserId("loginUserUtil.getLoginUserId()");
+ //entity.setCustomerId("loginUserUtil.getLoginUserCustomerId()");
baseDao.insert(entity);
- DictListFormDTO param = new DictListFormDTO();
- param.setDictType(DictTypeEnum.PATROL_WORK_TYPE.getCode());
- Result> mapResult = adminOpenFeignClient.dictList(param);
- if (mapResult == null || !mapResult.success() || CollectionUtils.isEmpty(mapResult.getData())){
- throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"例行工作类型字典获取失败!");
+ Result> mapResult = adminOpenFeignClient.dictTree(DictTypeEnum.PATROL_WORK_TYPE.getCode());
+ if (mapResult == null || !mapResult.success() || CollectionUtils.isEmpty(mapResult.getData())) {
+ throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "例行工作类型字典获取失败!");
}
- Map> dictMap = mapResult.getData().stream().collect(Collectors.groupingBy(DictListResultDTO::getPValue));
+ List dictTree = mapResult.getData();
- Map allPCodeMap = new HashMap<>();
- dictMap.forEach((pCode,list)->{
- if (NumConstant.ZERO_STR.equals(pCode)){
- return;
- }
- list.forEach(dict->{
- String code = dict.getValue();
- StringBuilder stringBuilder = allPCodeMap.get(code);
- if (stringBuilder == null){
- stringBuilder = new StringBuilder();
- allPCodeMap.put(code, stringBuilder);
- }
- stringBuilder.insert(dict.getPValue().length()/2,code).append(StrConstant.COLON);
- });
+ Map pidsMap = new HashMap<>();
+
+ dictTree.forEach(dto -> buildAllParentIdPath(pidsMap, dto));
- });
List workTypeList = new ArrayList<>();
- formDTO.getWorkTypeList().forEach(code->{
+ formDTO.getWorkTypeList().forEach(code -> {
PatrolRoutineWorkTypeEntity typeEntity = new PatrolRoutineWorkTypeEntity();
typeEntity.setCustomerId(loginUserUtil.getLoginUserCustomerId());
typeEntity.setRoutineWorkId(entity.getId());
typeEntity.setWorkTypeCode(code);
- typeEntity.setAllPCode(allPCodeMap.get(code).toString());
+ StringBuilder pids = pidsMap.get(code);
+ typeEntity.setAllPCode(pids.length() == 0 ? NumConstant.ZERO_STR : pids.toString());
workTypeList.add(typeEntity);
});
patrolRoutineWorkTypeService.insertBatch(workTypeList);
}
+ /**
+ * desc:递归遍历树形结构 构建pids 根节点pids 为空字符串
+ *
+ * @param result 构建的结果
+ * @param crurent
+ */
+ private static void buildAllParentIdPath(Map result, DictTreeResultDTO crurent) {
+ String id = crurent.getId();
+ String pid = crurent.getPid();
+
+ StringBuilder pidsPath = new StringBuilder();
+ StringBuilder pidSb = result.get(pid);
+ if (pidSb == null) {
+ pidSb = new StringBuilder();
+ } else if (pidSb.indexOf(pid) == -1) {
+ if (pidSb.length() > 0) {
+ pidSb.append(StrConstant.COLON);
+ }
+ pidSb.append(pid);
+ }
+ pidsPath.append(pidSb);
+ result.put(id, pidsPath);
+
+ log.debug("id:" + id + " pids:" + pidsPath.toString());
+
+ List children = crurent.getChildren();
+ if (children != null) {
+ crurent.getChildren().forEach(item -> buildAllParentIdPath(result, item));
+ }
+ }
+
+ public static void main(String[] args) {
+ String str = "[{\"id\":\"01\",\"pid\":\"0\",\"children\":[{\"id\":\"0101\",\"pid\":\"01\",\"children\":[{\"id\":\"010101\",\"pid\":\"0101\",\"children\":[],\"name\":\"出租房屋巡查\"}],\"name\":\"出租房屋巡查\"},{\"id\":\"0102\",\"pid\":\"01\",\"children\":[],\"name\":\"重点场所巡查\"},{\"id\":\"0103\",\"pid\":\"01\",\"children\":[],\"name\":\"宗教活动\"},{\"id\":\"0199\",\"pid\":\"01\",\"children\":[],\"name\":\"其他\"}],\"name\":\"重点巡查\"},{\"id\":\"02\",\"pid\":\"0\",\"children\":[{\"id\":\"0201\",\"pid\":\"02\",\"children\":[],\"name\":\"刑满释放人员\"},{\"id\":\"0202\",\"pid\":\"02\",\"children\":[],\"name\":\"社区矫正\"},{\"id\":\"0203\",\"pid\":\"02\",\"children\":[],\"name\":\"吸毒人员\"},{\"id\":\"0204\",\"pid\":\"02\",\"children\":[],\"name\":\"信访人员\"},{\"id\":\"0205\",\"pid\":\"02\",\"children\":[],\"name\":\"重点青少年\"},{\"id\":\"0206\",\"pid\":\"02\",\"children\":[],\"name\":\"精神障碍者\"}],\"name\":\"特殊人群\"},{\"id\":\"09\",\"pid\":\"0\",\"children\":[{\"id\":\"0901\",\"pid\":\"09\",\"children\":[],\"name\":\"公共服务\"},{\"id\":\"0902\",\"pid\":\"09\",\"children\":[],\"name\":\"权益保障\"},{\"id\":\"0903\",\"pid\":\"09\",\"children\":[],\"name\":\"政策宣传\"},{\"id\":\"0904\",\"pid\":\"09\",\"children\":[],\"name\":\"便利服务\"},{\"id\":\"0999\",\"pid\":\"09\",\"children\":[],\"name\":\"其他\"}],\"name\":\"为民服务\"}]";
+ List dtos = JSON.parseArray(str, DictTreeResultDTO.class);
+ Map result = new HashMap<>();
+ dtos.forEach(dto -> {
+ buildAllParentIdPath(result, dto);
+ });
+ System.out.println(result.get("010101"));
+ System.out.println(JSON.toJSONString(result));
+ }
+
}