|
@ -17,11 +17,11 @@ |
|
|
|
|
|
|
|
|
package com.epmet.service.impl; |
|
|
package com.epmet.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
import com.epmet.commons.tools.constant.StrConstant; |
|
|
import com.epmet.commons.tools.constant.StrConstant; |
|
|
import com.epmet.commons.tools.dto.form.DictListFormDTO; |
|
|
import com.epmet.commons.tools.dto.result.DictTreeResultDTO; |
|
|
import com.epmet.commons.tools.dto.result.DictListResultDTO; |
|
|
|
|
|
import com.epmet.commons.tools.enums.DictTypeEnum; |
|
|
import com.epmet.commons.tools.enums.DictTypeEnum; |
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
import com.epmet.commons.tools.exception.EpmetException; |
|
|
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.dao.PatrolRoutineWorkDao; |
|
|
import com.epmet.dto.CustomerGridDTO; |
|
|
import com.epmet.dto.CustomerGridDTO; |
|
|
import com.epmet.dto.form.CustomerGridFormDTO; |
|
|
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.PatrolRoutineWorkEntity; |
|
|
import com.epmet.entity.PatrolRoutineWorkTypeEntity; |
|
|
import com.epmet.entity.PatrolRoutineWorkTypeEntity; |
|
|
import com.epmet.feign.EpmetAdminOpenFeignClient; |
|
|
import com.epmet.feign.EpmetAdminOpenFeignClient; |
|
|
import com.epmet.feign.GovOrgOpenFeignClient; |
|
|
import com.epmet.feign.GovOrgOpenFeignClient; |
|
|
import com.epmet.service.PatrolRoutineWorkService; |
|
|
import com.epmet.service.PatrolRoutineWorkService; |
|
|
import com.epmet.service.PatrolRoutineWorkTypeService; |
|
|
import com.epmet.service.PatrolRoutineWorkTypeService; |
|
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
@ -47,7 +48,6 @@ import java.util.ArrayList; |
|
|
import java.util.HashMap; |
|
|
import java.util.HashMap; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
import java.util.Map; |
|
|
import java.util.Map; |
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 巡查例行工作 |
|
|
* 巡查例行工作 |
|
@ -55,6 +55,7 @@ import java.util.stream.Collectors; |
|
|
* @author generator generator@elink-cn.com |
|
|
* @author generator generator@elink-cn.com |
|
|
* @since v1.0.0 2021-12-21 |
|
|
* @since v1.0.0 2021-12-21 |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
@Slf4j |
|
|
@Service |
|
|
@Service |
|
|
public class PatrolRoutineWorkServiceImpl extends BaseServiceImpl<PatrolRoutineWorkDao, PatrolRoutineWorkEntity> implements PatrolRoutineWorkService { |
|
|
public class PatrolRoutineWorkServiceImpl extends BaseServiceImpl<PatrolRoutineWorkDao, PatrolRoutineWorkEntity> implements PatrolRoutineWorkService { |
|
|
@Autowired |
|
|
@Autowired |
|
@ -62,71 +63,100 @@ public class PatrolRoutineWorkServiceImpl extends BaseServiceImpl<PatrolRoutineW |
|
|
@Autowired |
|
|
@Autowired |
|
|
private EpmetAdminOpenFeignClient adminOpenFeignClient; |
|
|
private EpmetAdminOpenFeignClient adminOpenFeignClient; |
|
|
@Autowired |
|
|
@Autowired |
|
|
private LoginUserUtil loginUserUtil; |
|
|
private LoginUserUtil loginUserUtil; |
|
|
@Autowired |
|
|
@Autowired |
|
|
PatrolRoutineWorkTypeService patrolRoutineWorkTypeService; |
|
|
PatrolRoutineWorkTypeService patrolRoutineWorkTypeService; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @Description 网格员例行工作 |
|
|
|
|
|
* @param formDTO |
|
|
* @param formDTO |
|
|
|
|
|
* @Description 网格员例行工作 |
|
|
* @author zxc |
|
|
* @author zxc |
|
|
* @date 2021/10/19 1:35 下午 |
|
|
* @date 2021/10/19 1:35 下午 |
|
|
*/ |
|
|
*/ |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Override |
|
|
@Override |
|
|
public void gridUserWork(GridUserWorkFormDTO formDTO) { |
|
|
public void add(PatrolRoutineWorkFormDTO formDTO) { |
|
|
PatrolRoutineWorkEntity entity = ConvertUtils.sourceToTarget(formDTO, PatrolRoutineWorkEntity.class); |
|
|
PatrolRoutineWorkEntity entity = ConvertUtils.sourceToTarget(formDTO, PatrolRoutineWorkEntity.class); |
|
|
|
|
|
|
|
|
CustomerGridFormDTO gridFormDTO = new CustomerGridFormDTO(); |
|
|
CustomerGridFormDTO gridFormDTO = new CustomerGridFormDTO(); |
|
|
gridFormDTO.setGridId(formDTO.getGridId()); |
|
|
gridFormDTO.setGridId(formDTO.getGridId()); |
|
|
Result<CustomerGridDTO> gridBaseInfoData = govOrgOpenFeignClient.getGridBaseInfoByGridId(gridFormDTO); |
|
|
Result<CustomerGridDTO> gridBaseInfoData = govOrgOpenFeignClient.getGridBaseInfoByGridId(gridFormDTO); |
|
|
if (!gridBaseInfoData.success()){ |
|
|
if (!gridBaseInfoData.success()) { |
|
|
throw new EpmetException("查询网格基本信息失败......"); |
|
|
throw new EpmetException("查询网格基本信息失败......"); |
|
|
} |
|
|
} |
|
|
CustomerGridDTO gridBaseInfo = gridBaseInfoData.getData(); |
|
|
CustomerGridDTO gridBaseInfo = gridBaseInfoData.getData(); |
|
|
entity.setPids(gridBaseInfo.getPids()); |
|
|
entity.setPids(gridBaseInfo.getPids()); |
|
|
//entity.setUserId(loginUserUtil.getLoginUserId());
|
|
|
entity.setUserId(loginUserUtil.getLoginUserId()); |
|
|
//entity.setCustomerId(loginUserUtil.getLoginUserCustomerId());
|
|
|
entity.setCustomerId(loginUserUtil.getLoginUserCustomerId()); |
|
|
|
|
|
|
|
|
entity.setUserId("loginUserUtil.getLoginUserId()"); |
|
|
//entity.setUserId("loginUserUtil.getLoginUserId()");
|
|
|
entity.setCustomerId("loginUserUtil.getLoginUserCustomerId()"); |
|
|
//entity.setCustomerId("loginUserUtil.getLoginUserCustomerId()");
|
|
|
baseDao.insert(entity); |
|
|
baseDao.insert(entity); |
|
|
|
|
|
|
|
|
DictListFormDTO param = new DictListFormDTO(); |
|
|
Result<List<DictTreeResultDTO>> mapResult = adminOpenFeignClient.dictTree(DictTypeEnum.PATROL_WORK_TYPE.getCode()); |
|
|
param.setDictType(DictTypeEnum.PATROL_WORK_TYPE.getCode()); |
|
|
if (mapResult == null || !mapResult.success() || CollectionUtils.isEmpty(mapResult.getData())) { |
|
|
Result<List<DictListResultDTO>> mapResult = adminOpenFeignClient.dictList(param); |
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "例行工作类型字典获取失败!"); |
|
|
if (mapResult == null || !mapResult.success() || CollectionUtils.isEmpty(mapResult.getData())){ |
|
|
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"例行工作类型字典获取失败!"); |
|
|
|
|
|
} |
|
|
} |
|
|
Map<String, List<DictListResultDTO>> dictMap = mapResult.getData().stream().collect(Collectors.groupingBy(DictListResultDTO::getPValue)); |
|
|
List<DictTreeResultDTO> dictTree = mapResult.getData(); |
|
|
|
|
|
|
|
|
Map<String, StringBuilder> allPCodeMap = new HashMap<>(); |
|
|
Map<String, StringBuilder> pidsMap = new HashMap<>(); |
|
|
dictMap.forEach((pCode,list)->{ |
|
|
|
|
|
if (NumConstant.ZERO_STR.equals(pCode)){ |
|
|
dictTree.forEach(dto -> buildAllParentIdPath(pidsMap, dto)); |
|
|
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); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
List<PatrolRoutineWorkTypeEntity> workTypeList = new ArrayList<>(); |
|
|
List<PatrolRoutineWorkTypeEntity> workTypeList = new ArrayList<>(); |
|
|
formDTO.getWorkTypeList().forEach(code->{ |
|
|
formDTO.getWorkTypeList().forEach(code -> { |
|
|
PatrolRoutineWorkTypeEntity typeEntity = new PatrolRoutineWorkTypeEntity(); |
|
|
PatrolRoutineWorkTypeEntity typeEntity = new PatrolRoutineWorkTypeEntity(); |
|
|
typeEntity.setCustomerId(loginUserUtil.getLoginUserCustomerId()); |
|
|
typeEntity.setCustomerId(loginUserUtil.getLoginUserCustomerId()); |
|
|
typeEntity.setRoutineWorkId(entity.getId()); |
|
|
typeEntity.setRoutineWorkId(entity.getId()); |
|
|
typeEntity.setWorkTypeCode(code); |
|
|
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); |
|
|
workTypeList.add(typeEntity); |
|
|
}); |
|
|
}); |
|
|
patrolRoutineWorkTypeService.insertBatch(workTypeList); |
|
|
patrolRoutineWorkTypeService.insertBatch(workTypeList); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* desc:递归遍历树形结构 构建pids 根节点pids 为空字符串 |
|
|
|
|
|
* |
|
|
|
|
|
* @param result 构建的结果 |
|
|
|
|
|
* @param crurent |
|
|
|
|
|
*/ |
|
|
|
|
|
private static void buildAllParentIdPath(Map<String, StringBuilder> 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<DictTreeResultDTO> 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<DictTreeResultDTO> dtos = JSON.parseArray(str, DictTreeResultDTO.class); |
|
|
|
|
|
Map<String, StringBuilder> result = new HashMap<>(); |
|
|
|
|
|
dtos.forEach(dto -> { |
|
|
|
|
|
buildAllParentIdPath(result, dto); |
|
|
|
|
|
}); |
|
|
|
|
|
System.out.println(result.get("010101")); |
|
|
|
|
|
System.out.println(JSON.toJSONString(result)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|