|
|
@ -705,7 +705,7 @@ public class ProjectTraceServiceImpl<ProjectTagService> implements ProjectTraceS |
|
|
|
//事件已经立项,不能重复操作
|
|
|
|
ResiEventEntity resiEventEntity=resiEventService.getById(formDTO.getEventId()); |
|
|
|
//TODO 兼容新事件表
|
|
|
|
String gridId = ""; |
|
|
|
String gridId = formDTO.getGridId(); |
|
|
|
if(null==resiEventEntity||resiEventEntity.getShiftProject()){ |
|
|
|
throw new RenException(EpmetErrorCode.RESI_EVENT_SHIFT_PROJECT.getCode(),EpmetErrorCode.RESI_EVENT_SHIFT_PROJECT.getMsg()); |
|
|
|
} |
|
|
@ -1225,4 +1225,234 @@ public class ProjectTraceServiceImpl<ProjectTagService> implements ProjectTraceS |
|
|
|
epmetMessageOpenFeignClient.saveUserMessage(userMessage); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 事件管理-事件立项【赶时间没空兼容】 |
|
|
|
* @author sun |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public EventToProjectResultDTO icEventToProject(IcEventToProjectFormDTO formDTO) { |
|
|
|
//判断是否存在已立项
|
|
|
|
List<ProjectEntity> projectEntityList = projectService.getByOriginId(formDTO.getIcEventId()); |
|
|
|
if (!CollectionUtils.isEmpty(projectEntityList)) { |
|
|
|
throw new RenException(EpmetErrorCode.RESI_EVENT_SHIFT_PROJECT.getCode(), EpmetErrorCode.RESI_EVENT_SHIFT_PROJECT.getMsg()); |
|
|
|
} |
|
|
|
List<TickStaffFormDTO> staffList = formDTO.getStaffList(); |
|
|
|
//1.文字内容安全校验
|
|
|
|
List<String> list = new ArrayList<>(); |
|
|
|
list.add(formDTO.getTitle()); |
|
|
|
list.add(formDTO.getPublicReply()); |
|
|
|
list.add(formDTO.getPublicReply()); |
|
|
|
list.add(formDTO.getInternalRemark()); |
|
|
|
safetyCheck(list); |
|
|
|
//2.数据准备
|
|
|
|
//2-1获取当前工作人员基本信息
|
|
|
|
EventToProjectFormDTO eventToProjectFormDTO = ConvertUtils.sourceToTarget(formDTO, EventToProjectFormDTO.class); |
|
|
|
LoginUserDetailsResultDTO loginUser = queryLoginUserInfo(eventToProjectFormDTO); |
|
|
|
|
|
|
|
//2-2.调用gov-org服务,获取所有勾选人员以及议题数据对应的组织信息、部门信息、网格信息用于对处理部门和ORG_ID_PATH字段的赋值使用
|
|
|
|
AgencyDeptGridResultDTO agencyDeptGrid = getAgencyDeptGridRes(formDTO.getStaffList(), loginUser.getAgencyId()); |
|
|
|
|
|
|
|
//2-3.调用issue服务,查询分类、标签数据信息
|
|
|
|
CategoryTagResultDTO categoryTagResultDTO = queryCategoryTagRes(eventToProjectFormDTO); |
|
|
|
List<IssueProjectCategoryDictDTO> categoryList = categoryTagResultDTO.getCategoryList(); |
|
|
|
List<IssueProjectTagDictDTO> tagList = categoryTagResultDTO.getTagList(); |
|
|
|
|
|
|
|
//2-4.批量查询被勾选工作人员基础信息
|
|
|
|
List<StaffListResultDTO> staffInfoList = queryStaffListRes(formDTO.getStaffList(), formDTO.getUserId()); |
|
|
|
|
|
|
|
//3.封装保存业务数据
|
|
|
|
//3-1.项目主表新增数据
|
|
|
|
ProjectEntity projectEntity = new ProjectEntity(); |
|
|
|
projectEntity.setCustomerId(formDTO.getCustomerId()); |
|
|
|
//立项人的所属组织id
|
|
|
|
projectEntity.setAgencyId(loginUser.getAgencyId()); |
|
|
|
projectEntity.setOrigin("ic_event"); |
|
|
|
projectEntity.setOriginId(formDTO.getIcEventId()); |
|
|
|
projectEntity.setTitle(formDTO.getTitle()); |
|
|
|
projectEntity.setBackGround(formDTO.getPublicReply()); |
|
|
|
projectEntity.setGridId(formDTO.getGridId()); |
|
|
|
projectEntity.setStatus(ProjectConstant.PENDING); |
|
|
|
projectEntity.setOrgIdPath(loginUser.getOrgIdPath()); |
|
|
|
projectEntity.setLocateAddress(null == formDTO.getLocateAddress() ? "" : formDTO.getLocateAddress()); |
|
|
|
projectEntity.setLocateLongitude(null == formDTO.getLocateLongitude() ? "" : formDTO.getLocateLongitude()); |
|
|
|
projectEntity.setLocateDimension(null == formDTO.getLocateDimension() ? "" : formDTO.getLocateDimension()); |
|
|
|
projectService.insert(projectEntity); |
|
|
|
|
|
|
|
//3-2.项目进展表新增第一个节点数据
|
|
|
|
ProjectProcessEntity processEntity = new ProjectProcessEntity(); |
|
|
|
processEntity.setProjectId(projectEntity.getId()); |
|
|
|
processEntity.setCustomerId(formDTO.getCustomerId()); |
|
|
|
processEntity.setStaffId(formDTO.getUserId()); |
|
|
|
processEntity.setOperation(ProjectConstant.OPERATION_CREATED); |
|
|
|
processEntity.setOperationName(ProjectConstant.OPERATION_PROJECT_APPROVAL); |
|
|
|
processEntity.setPublicReply(formDTO.getPublicReply()); |
|
|
|
processEntity.setInternalRemark(formDTO.getInternalRemark()); |
|
|
|
processEntity.setAssistanceUnitId(formDTO.getAssistanceUnitId()); |
|
|
|
processEntity.setAssistanceUnitType(formDTO.getAssistanceUnitType()); |
|
|
|
agencyDeptGrid.getAgencyList().forEach(agency -> { |
|
|
|
if (loginUser.getAgencyId().equals(agency.getId())) { |
|
|
|
processEntity.setDepartmentName(agency.getOrganizationName()); |
|
|
|
processEntity.setAgencyId(agency.getId()); |
|
|
|
if (org.apache.commons.lang3.StringUtils.isBlank(agency.getPids()) || org.apache.commons.lang3.StringUtils.equals(NumConstant.ZERO_STR, agency.getPids().trim()) || "".equals(agency.getPids().trim())) { |
|
|
|
processEntity.setOrgIdPath(agency.getId()); |
|
|
|
} else { |
|
|
|
processEntity.setOrgIdPath(agency.getPids().concat(":").concat(agency.getId())); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
projectProcessService.insert(processEntity); |
|
|
|
|
|
|
|
//3-3.项目人员表批量新增数据
|
|
|
|
List<ProjectStaffEntity> entityList = new ArrayList<>(); |
|
|
|
staffList.forEach(ts -> { |
|
|
|
ProjectStaffEntity entity = ConvertUtils.sourceToTarget(ts, ProjectStaffEntity.class); |
|
|
|
entity.setOrgId(ts.getAgencyId()); |
|
|
|
entity.setProjectId(projectEntity.getId()); |
|
|
|
entity.setProcessId(processEntity.getId()); |
|
|
|
entity.setIsHandle(ProjectConstant.UNHANDLED); |
|
|
|
agencyDeptGrid.getAgencyList().forEach(agency -> { |
|
|
|
if (ts.getAgencyId().equals(agency.getId())) { |
|
|
|
entity.setCustomerId(agency.getCustomerId()); |
|
|
|
entity.setOrgIdPath(("".equals(agency.getPids()) ? "" : agency.getPids() + ":") + agency.getId()); |
|
|
|
entity.setDepartmentName(agency.getOrganizationName()); |
|
|
|
} |
|
|
|
}); |
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(ts.getDepartmentId())) { |
|
|
|
agencyDeptGrid.getDeptList().forEach(dept -> { |
|
|
|
if (ts.getDepartmentId().equals(dept.getId())) { |
|
|
|
entity.setDepartmentName(entity.getDepartmentName() + "-" + dept.getDepartmentName()); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(ts.getGridId())) { |
|
|
|
agencyDeptGrid.getGridList().forEach(grid -> { |
|
|
|
if (ts.getGridId().equals(grid.getId())) { |
|
|
|
entity.setDepartmentName(entity.getDepartmentName() + "-" + grid.getGridName()); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
entityList.add(entity); |
|
|
|
}); |
|
|
|
projectStaffService.insertBatch(entityList); |
|
|
|
|
|
|
|
//3-4.项目附件表新增数据
|
|
|
|
if ((null != formDTO.getPublicFile() && formDTO.getPublicFile().size() > NumConstant.ZERO) |
|
|
|
|| (null != formDTO.getInternalFile() && formDTO.getInternalFile().size() > NumConstant.ZERO)) { |
|
|
|
projectService.saveFile(formDTO.getPublicFile(), formDTO.getInternalFile(), formDTO.getCustomerId(), projectEntity.getId(), processEntity.getId()); |
|
|
|
} |
|
|
|
|
|
|
|
//3-5.项目分类表新增数据
|
|
|
|
if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(formDTO.getCategoryList())) { |
|
|
|
List<ProjectCategoryEntity> categoryEntityList = new ArrayList<>(); |
|
|
|
formDTO.getCategoryList().forEach(item -> { |
|
|
|
categoryList.forEach(ca -> { |
|
|
|
if (item.getId().equals(ca.getId())) { |
|
|
|
ProjectCategoryEntity entity = new ProjectCategoryEntity(); |
|
|
|
entity.setCustomerId(formDTO.getCustomerId()); |
|
|
|
entity.setProjectId(projectEntity.getId()); |
|
|
|
entity.setCategoryId(item.getId()); |
|
|
|
entity.setCategoryPids(ca.getPids()); |
|
|
|
entity.setCategoryCode(ca.getCategoryCode()); |
|
|
|
entity.setGridId(formDTO.getGridId()); |
|
|
|
categoryEntityList.add(entity); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
projectCategoryService.insertBatch(categoryEntityList); |
|
|
|
} |
|
|
|
|
|
|
|
//3-6.项目标签表新增数据
|
|
|
|
if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(formDTO.getTagList())) { |
|
|
|
List<ProjectTagsEntity> tagEntityList = new ArrayList<>(); |
|
|
|
formDTO.getTagList().forEach(item -> { |
|
|
|
tagList.forEach(ta -> { |
|
|
|
if (item.getId().equals(ta.getId())) { |
|
|
|
ProjectTagsEntity entity = new ProjectTagsEntity(); |
|
|
|
entity.setCustomerId(formDTO.getCustomerId()); |
|
|
|
entity.setProjectId(projectEntity.getId()); |
|
|
|
entity.setTagId(item.getId()); |
|
|
|
entity.setTagName(ta.getTagName()); |
|
|
|
tagEntityList.add(entity); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
projectTagsService.insertBatch(tagEntityList); |
|
|
|
} |
|
|
|
|
|
|
|
//3-7:初始化机关-项目时间关联数据
|
|
|
|
Date current = new Date(); |
|
|
|
List<String> projectStaffIds = entityList.stream().map(ProjectStaffEntity::getId).distinct().collect(Collectors.toList()); |
|
|
|
if (!org.apache.commons.collections4.CollectionUtils.isEmpty(projectStaffIds)) { |
|
|
|
List<ProjectOrgRelationEntity> container = new LinkedList<>(); |
|
|
|
projectStaffIds.forEach(o -> { |
|
|
|
ProjectOrgRelationEntity period = new ProjectOrgRelationEntity(); |
|
|
|
period.setProjectStaffId(o); |
|
|
|
period.setInformedDate(current); |
|
|
|
period.setSourceOperation(ProjectConstant.OPERATION_CREATED); |
|
|
|
period.setCreatedBy(formDTO.getUserId()); |
|
|
|
container.add(period); |
|
|
|
}); |
|
|
|
relationDao.insertBatch(container); |
|
|
|
} |
|
|
|
|
|
|
|
//4.推送站内信、微信、短信消息
|
|
|
|
//4-1.调用epmet-message服务,给工作端勾选的工作人员发送消息
|
|
|
|
if (!shiftProjectMessage(formDTO.getStaffList(), formDTO.getCustomerId(), formDTO.getTitle(), projectEntity.getId()).success()) { |
|
|
|
throw new RenException("事件转为项目,推送站内信失败"); |
|
|
|
} |
|
|
|
|
|
|
|
//4-2.以及政府端调用epmet-message服务,给工作端工作人员推送微信订阅消息
|
|
|
|
if (!wxmpShiftProjectMessage(formDTO.getStaffList(), formDTO.getCustomerId(), formDTO.getTitle()).success()) { |
|
|
|
logger.error("事件转为项目,推送微信订阅消息失败!"); |
|
|
|
} |
|
|
|
|
|
|
|
//4-3.吹哨短信消息
|
|
|
|
List<ProjectSendMsgFormDTO> smsList = new ArrayList<>(); |
|
|
|
staffList.forEach(staff -> { |
|
|
|
staffInfoList.forEach(st -> { |
|
|
|
if (staff.getStaffId().equals(st.getStaffId())) { |
|
|
|
ProjectSendMsgFormDTO sms = new ProjectSendMsgFormDTO(); |
|
|
|
sms.setCustomerId(st.getCustomerId()); |
|
|
|
sms.setMobile(st.getMobile()); |
|
|
|
sms.setAliyunTemplateCode(SmsTemplateConstant.PROJECT_TRANSFER); |
|
|
|
sms.setParameterKey("send_msg"); |
|
|
|
smsList.add(sms); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
Result result = epmetMessageOpenFeignClient.projectSendMsg(smsList); |
|
|
|
if (!result.success()) { |
|
|
|
logger.error("项目吹哨,发送手机短信失败" + JSON.toJSONString(result)); |
|
|
|
} |
|
|
|
|
|
|
|
//5.项目实时统计消息
|
|
|
|
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
|
|
|
String mqMsgBrief = String.format("创建了\"%s\"的项目", formDTO.getTitle()); |
|
|
|
ProjectChangedMQMsg mqMsg = new ProjectChangedMQMsg(projectEntity.getCustomerId(), ProjectConstant.OPERATION_CREATED, |
|
|
|
projectEntity.getId(), |
|
|
|
formDTO.getUserId(), |
|
|
|
new Date(), |
|
|
|
mqMsgBrief, |
|
|
|
IpUtils.getIpAddr(request), |
|
|
|
loginUserUtil.getLoginUserApp(), |
|
|
|
loginUserUtil.getLoginUserClient()); |
|
|
|
boolean msgResult = SendMqMsgUtil.build().openFeignClient(epmetMessageOpenFeignClient).sendProjectChangedMqMsg(mqMsg); |
|
|
|
if (!msgResult) { |
|
|
|
log.error("项目实时统计消息发送失败"); |
|
|
|
} |
|
|
|
// 数据上链
|
|
|
|
try { |
|
|
|
blockChainUploadService.send2BlockChain(projectEntity, processEntity, entityList, null); |
|
|
|
} catch (Exception e) { |
|
|
|
String errorMsg = ExceptionUtils.getThrowableErrorStackTrace(e); |
|
|
|
log.error("【项目流转】上链失败,错误信息:{}", errorMsg); |
|
|
|
} |
|
|
|
|
|
|
|
EventToProjectResultDTO resultDTO = new EventToProjectResultDTO(); |
|
|
|
resultDTO.setProjectId(projectEntity.getId()); |
|
|
|
return resultDTO; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|