|
|
@ -19,6 +19,7 @@ package com.epmet.service.impl; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.epmet.commons.rocketmq.messages.BaseMQMsgDTO; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.constant.StrConstant; |
|
|
|
import com.epmet.commons.tools.dto.result.DictTreeResultDTO; |
|
|
@ -28,6 +29,7 @@ import com.epmet.commons.tools.exception.EpmetException; |
|
|
|
import com.epmet.commons.tools.security.user.LoginUserUtil; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.constant.SystemMessageType; |
|
|
|
import com.epmet.dao.PatrolRoutineWorkDao; |
|
|
|
import com.epmet.dto.CustomerGridDTO; |
|
|
|
import com.epmet.dto.form.CustomerGridFormDTO; |
|
|
@ -35,7 +37,9 @@ 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.EpmetMessageOpenFeignClient; |
|
|
|
import com.epmet.feign.GovOrgOpenFeignClient; |
|
|
|
import com.epmet.send.SendMqMsgUtil; |
|
|
|
import com.epmet.service.PatrolRoutineWorkService; |
|
|
|
import com.epmet.service.PatrolRoutineWorkTypeService; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
@ -66,7 +70,9 @@ public class PatrolRoutineWorkServiceImpl extends BaseServiceImpl<PatrolRoutineW |
|
|
|
@Autowired |
|
|
|
private LoginUserUtil loginUserUtil; |
|
|
|
@Autowired |
|
|
|
PatrolRoutineWorkTypeService patrolRoutineWorkTypeService; |
|
|
|
private PatrolRoutineWorkTypeService patrolRoutineWorkTypeService; |
|
|
|
@Autowired |
|
|
|
private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; |
|
|
|
|
|
|
|
/** |
|
|
|
* @param formDTO |
|
|
@ -77,12 +83,14 @@ public class PatrolRoutineWorkServiceImpl extends BaseServiceImpl<PatrolRoutineW |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Override |
|
|
|
public void add(PatrolRoutineWorkFormDTO formDTO) { |
|
|
|
PatrolRoutineWorkEntity entity = null; |
|
|
|
try { |
|
|
|
if (formDTO.getWorkTypeList().toString().contains("02") |
|
|
|
&& (formDTO.getIsKeyPeopleLocate() == null || StringUtils.isBlank(formDTO.getKeyPeopleStatus()))) { |
|
|
|
log.warn("add patrolRoutineWork fail,param is error,param:{}", JSON.toJSONString(formDTO)); |
|
|
|
throw new EpmetException(EpmetErrorCode.ORG_ADD_FAILED.getCode()); |
|
|
|
} |
|
|
|
PatrolRoutineWorkEntity entity = ConvertUtils.sourceToTarget(formDTO, PatrolRoutineWorkEntity.class); |
|
|
|
entity = ConvertUtils.sourceToTarget(formDTO, PatrolRoutineWorkEntity.class); |
|
|
|
|
|
|
|
CustomerGridFormDTO gridFormDTO = new CustomerGridFormDTO(); |
|
|
|
gridFormDTO.setGridId(formDTO.getGridId()); |
|
|
@ -109,8 +117,9 @@ public class PatrolRoutineWorkServiceImpl extends BaseServiceImpl<PatrolRoutineW |
|
|
|
|
|
|
|
dictTree.forEach(dto -> buildAllParentIdPath(pidsMap, dto)); |
|
|
|
|
|
|
|
//插入分类
|
|
|
|
List<PatrolRoutineWorkTypeEntity> workTypeList = new ArrayList<>(); |
|
|
|
formDTO.getWorkTypeList().forEach(code -> { |
|
|
|
for (String code : formDTO.getWorkTypeList()) { |
|
|
|
PatrolRoutineWorkTypeEntity typeEntity = new PatrolRoutineWorkTypeEntity(); |
|
|
|
typeEntity.setCustomerId(loginUserUtil.getLoginUserCustomerId()); |
|
|
|
typeEntity.setRoutineWorkId(entity.getId()); |
|
|
@ -118,8 +127,13 @@ public class PatrolRoutineWorkServiceImpl extends BaseServiceImpl<PatrolRoutineW |
|
|
|
StringBuilder pids = pidsMap.get(code); |
|
|
|
typeEntity.setAllPCode(pids.length() == NumConstant.ZERO ? NumConstant.ZERO_STR : pids.toString()); |
|
|
|
workTypeList.add(typeEntity); |
|
|
|
}); |
|
|
|
} |
|
|
|
patrolRoutineWorkTypeService.insertBatch(workTypeList); |
|
|
|
} finally { |
|
|
|
if (entity != null){ |
|
|
|
sendPatrolMsg(entity.getCustomerId(),entity.getId(),SystemMessageType.PATROL_ROUTINE_WORK_ADD); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
@ -154,6 +168,18 @@ public class PatrolRoutineWorkServiceImpl extends BaseServiceImpl<PatrolRoutineW |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void sendPatrolMsg(String customerId, String id, String messageType) { |
|
|
|
//发送巡查消息
|
|
|
|
BaseMQMsgDTO baseMQMsgDTO = new BaseMQMsgDTO(); |
|
|
|
baseMQMsgDTO.setCustomerId(customerId); |
|
|
|
baseMQMsgDTO.setObjectId(id); |
|
|
|
|
|
|
|
boolean b = SendMqMsgUtil.build().openFeignClient(epmetMessageOpenFeignClient).sendPatrolMqMsg(baseMQMsgDTO, messageType); |
|
|
|
if (!b) { |
|
|
|
log.error("发送{}巡查消息到mq失败,patrolId:{}", messageType, id); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
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); |
|
|
|