|  |  | @ -22,7 +22,6 @@ import com.epmet.constant.UserMessageConstant; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dao.ProjectOrgRelationDao; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dao.ProjectProcessAttachmentDao; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dao.ProjectProcessDao; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.CustomerStaffDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.IssueProjectCategoryDictDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.IssueProjectTagDictDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.ProjectStaffDTO; | 
			
		
	
	
		
			
				
					|  |  | @ -93,6 +92,8 @@ public class ProjectTraceServiceImpl<ProjectTagService> implements ProjectTraceS | 
			
		
	
		
			
				
					|  |  |  | 	private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; | 
			
		
	
		
			
				
					|  |  |  | 	@Autowired | 
			
		
	
		
			
				
					|  |  |  | 	private LoginUserUtil loginUserUtil; | 
			
		
	
		
			
				
					|  |  |  | 	@Autowired | 
			
		
	
		
			
				
					|  |  |  | 	private ResiEventService resiEventService; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 	@Override | 
			
		
	
		
			
				
					|  |  |  | 	public List<PendProjectListResultDTO> getPendProjectList(TokenDto tokenDto, ProjectListFromDTO fromDTO) { | 
			
		
	
	
		
			
				
					|  |  | @ -615,5 +616,354 @@ public class ProjectTraceServiceImpl<ProjectTagService> implements ProjectTraceS | 
			
		
	
		
			
				
					|  |  |  | 		return epmetMessageOpenFeignClient.sendWxSubscribeMessage(msgList); | 
			
		
	
		
			
				
					|  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 	/** | 
			
		
	
		
			
				
					|  |  |  | 	 * 事件立项 | 
			
		
	
		
			
				
					|  |  |  | 	 * | 
			
		
	
		
			
				
					|  |  |  | 	 * @param formDTO | 
			
		
	
		
			
				
					|  |  |  | 	 * @return com.epmet.dto.result.EventToProjectResultDTO | 
			
		
	
		
			
				
					|  |  |  | 	 * @author yinzuomei | 
			
		
	
		
			
				
					|  |  |  | 	 * @date 2021/8/5 15:38 | 
			
		
	
		
			
				
					|  |  |  | 	 */ | 
			
		
	
		
			
				
					|  |  |  | 	@Override | 
			
		
	
		
			
				
					|  |  |  | 	public EventToProjectResultDTO eventToProject(EventToProjectFormDTO formDTO) { | 
			
		
	
		
			
				
					|  |  |  | 		//事件已经立项,不能重复操作
 | 
			
		
	
		
			
				
					|  |  |  | 		ResiEventEntity resiEventEntity=resiEventService.getById(formDTO.getEventId()); | 
			
		
	
		
			
				
					|  |  |  | 		if(null==resiEventEntity||resiEventEntity.getShiftProject()){ | 
			
		
	
		
			
				
					|  |  |  | 			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获取当前工作人员基本信息
 | 
			
		
	
		
			
				
					|  |  |  | 		LoginUserDetailsResultDTO loginUser=queryLoginUserInfo(formDTO); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 		//2-2.调用gov-org服务,获取所有勾选人员以及议题数据对应的组织信息、部门信息、网格信息用于对处理部门和ORG_ID_PATH字段的赋值使用
 | 
			
		
	
		
			
				
					|  |  |  | 		AgencyDeptGridResultDTO agencyDeptGrid = getAgencyDeptGridRes(formDTO.getStaffList(),loginUser.getAgencyId()); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 		//2-3.调用issue服务,查询分类、标签数据信息
 | 
			
		
	
		
			
				
					|  |  |  | 		CategoryTagResultDTO categoryTagResultDTO=queryCategoryTagRes(formDTO); | 
			
		
	
		
			
				
					|  |  |  | 		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()); | 
			
		
	
		
			
				
					|  |  |  | 		// 项目来源新增:resi_event
 | 
			
		
	
		
			
				
					|  |  |  | 		projectEntity.setOrigin(ProjectConstant.RESI_EVENT); | 
			
		
	
		
			
				
					|  |  |  | 		projectEntity.setOriginId(formDTO.getEventId()); | 
			
		
	
		
			
				
					|  |  |  | 		projectEntity.setTitle(formDTO.getTitle()); | 
			
		
	
		
			
				
					|  |  |  | 		projectEntity.setBackGround(formDTO.getPublicReply()); | 
			
		
	
		
			
				
					|  |  |  | 		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()); | 
			
		
	
		
			
				
					|  |  |  | 		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()); | 
			
		
	
		
			
				
					|  |  |  | 						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()).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)); | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 		//项目实时统计消息
 | 
			
		
	
		
			
				
					|  |  |  | 		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("项目实时统计消息发送失败"); | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 		// 报事人、被艾特的人显示红点
 | 
			
		
	
		
			
				
					|  |  |  | 		EventShiftProjectDTO eventShiftProjectDTO=new EventShiftProjectDTO(); | 
			
		
	
		
			
				
					|  |  |  | 		eventShiftProjectDTO.setEventId(formDTO.getEventId()); | 
			
		
	
		
			
				
					|  |  |  | 		eventShiftProjectDTO.setProjectId(projectEntity.getId()); | 
			
		
	
		
			
				
					|  |  |  | 		eventShiftProjectDTO.setShiftProjectTime(projectEntity.getCreatedTime()); | 
			
		
	
		
			
				
					|  |  |  | 		eventShiftProjectDTO.setUserId(formDTO.getUserId()); | 
			
		
	
		
			
				
					|  |  |  | 		eventShiftProjectDTO.setUserAgencyId(projectEntity.getAgencyId()); | 
			
		
	
		
			
				
					|  |  |  | 		resiEventService.shiftProject(eventShiftProjectDTO); | 
			
		
	
		
			
				
					|  |  |  | 		EventToProjectResultDTO resultDTO=new EventToProjectResultDTO(); | 
			
		
	
		
			
				
					|  |  |  | 		resultDTO.setProjectId(projectEntity.getId()); | 
			
		
	
		
			
				
					|  |  |  | 		return resultDTO; | 
			
		
	
		
			
				
					|  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 	private List<StaffListResultDTO> queryStaffListRes(List<TickStaffFormDTO> staffList,String currentUserId) { | 
			
		
	
		
			
				
					|  |  |  | 		List<String> staffIdList = staffList.stream().map(TickStaffFormDTO::getStaffId).collect(Collectors.toList()); | 
			
		
	
		
			
				
					|  |  |  | 		staffIdList.add(currentUserId); | 
			
		
	
		
			
				
					|  |  |  | 		staffIdList = new ArrayList<String>(new LinkedHashSet<>(staffIdList)); | 
			
		
	
		
			
				
					|  |  |  | 		Result<CustomerStaffListResultDTO> resultStaff = epmetUserOpenFeignClient.getCustomerStaffList(staffIdList); | 
			
		
	
		
			
				
					|  |  |  | 		if (!resultStaff.success() || null == resultStaff.getData()) { | 
			
		
	
		
			
				
					|  |  |  | 			throw new RenException("项目立项,调用user服务获取被勾选工作人员基本信息失败"); | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 		return resultStaff.getData().getStaffList(); | 
			
		
	
		
			
				
					|  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 	private CategoryTagResultDTO queryCategoryTagRes(EventToProjectFormDTO formDTO) { | 
			
		
	
		
			
				
					|  |  |  | 		CategoryTagListFormDTO categoryTag = new CategoryTagListFormDTO(); | 
			
		
	
		
			
				
					|  |  |  | 		List<String> categoryIdList = formDTO.getCategoryList().stream().map(CategoryOrTagFormDTO::getId).collect(Collectors.toList()); | 
			
		
	
		
			
				
					|  |  |  | 		List<String> tagIdList = formDTO.getTagList().stream().map(CategoryOrTagFormDTO::getId).collect(Collectors.toList()); | 
			
		
	
		
			
				
					|  |  |  | 		categoryTag.setCustomerId(formDTO.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  | 		categoryTag.setCategoryIdList(categoryIdList); | 
			
		
	
		
			
				
					|  |  |  | 		categoryTag.setTagIdList(tagIdList); | 
			
		
	
		
			
				
					|  |  |  | 		Result<CategoryTagResultDTO> resultDTOResult = govIssueOpenFeignClient.getCategoryTagList(categoryTag); | 
			
		
	
		
			
				
					|  |  |  | 		if (!resultDTOResult.success()) { | 
			
		
	
		
			
				
					|  |  |  | 			throw new RenException("项目立项,调用issue服务查询分类、标签基础信息失败"); | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 		return resultDTOResult.getData(); | 
			
		
	
		
			
				
					|  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 	private AgencyDeptGridResultDTO getAgencyDeptGridRes(List<TickStaffFormDTO> staffList, String userAgencyId) { | 
			
		
	
		
			
				
					|  |  |  | 		List<String> agencyIdList = staffList.stream().map(TickStaffFormDTO::getAgencyId).collect(Collectors.toList()); | 
			
		
	
		
			
				
					|  |  |  | 		agencyIdList.add(userAgencyId); | 
			
		
	
		
			
				
					|  |  |  | 		agencyIdList = new ArrayList<String>(new LinkedHashSet<>(agencyIdList)); | 
			
		
	
		
			
				
					|  |  |  | 		agencyIdList.removeAll(Collections.singleton("")); | 
			
		
	
		
			
				
					|  |  |  | 		List<String> deptIdList = staffList.stream().map(TickStaffFormDTO::getDepartmentId).collect(Collectors.toList()); | 
			
		
	
		
			
				
					|  |  |  | 		deptIdList = new ArrayList<String>(new LinkedHashSet<>(deptIdList)); | 
			
		
	
		
			
				
					|  |  |  | 		deptIdList.removeAll(Collections.singleton("")); | 
			
		
	
		
			
				
					|  |  |  | 		List<String> gridIdList = staffList.stream().map(TickStaffFormDTO::getGridId).collect(Collectors.toList()); | 
			
		
	
		
			
				
					|  |  |  | 		gridIdList = new ArrayList<String>(new LinkedHashSet<>(gridIdList)); | 
			
		
	
		
			
				
					|  |  |  | 		gridIdList.removeAll(Collections.singleton("")); | 
			
		
	
		
			
				
					|  |  |  | 		AgencyDeptGridFormDTO agencyDeptGridFormDTO = new AgencyDeptGridFormDTO(); | 
			
		
	
		
			
				
					|  |  |  | 		agencyDeptGridFormDTO.setAgencyIdList(agencyIdList); | 
			
		
	
		
			
				
					|  |  |  | 		agencyDeptGridFormDTO.setDeptIdList(deptIdList); | 
			
		
	
		
			
				
					|  |  |  | 		agencyDeptGridFormDTO.setGridIdList(gridIdList); | 
			
		
	
		
			
				
					|  |  |  | 		Result<AgencyDeptGridResultDTO> resultDTO = govOrgFeignClient.getAgencyDeptGridList(agencyDeptGridFormDTO); | 
			
		
	
		
			
				
					|  |  |  | 		if (!resultDTO.success() || null == resultDTO.getData()) { | 
			
		
	
		
			
				
					|  |  |  | 			throw new RenException(ProjectConstant.SELECT_GOV_ORG_EXCEPTION); | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 		return resultDTO.getData(); | 
			
		
	
		
			
				
					|  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 	/** | 
			
		
	
		
			
				
					|  |  |  | 	 * 获取当前工作人员的基本信息 | 
			
		
	
		
			
				
					|  |  |  | 	 * | 
			
		
	
		
			
				
					|  |  |  | 	 * @param formDTO | 
			
		
	
		
			
				
					|  |  |  | 	 * @return com.epmet.dto.result.LoginUserDetailsResultDTO | 
			
		
	
		
			
				
					|  |  |  | 	 * @author yinzuomei | 
			
		
	
		
			
				
					|  |  |  | 	 * @date 2021/8/5 15:42 | 
			
		
	
		
			
				
					|  |  |  | 	 */ | 
			
		
	
		
			
				
					|  |  |  | 	private LoginUserDetailsResultDTO queryLoginUserInfo(EventToProjectFormDTO formDTO) { | 
			
		
	
		
			
				
					|  |  |  | 		//2.数据准备,查询需要用到的数据
 | 
			
		
	
		
			
				
					|  |  |  | 		//2-1.获取token用户所属组织信息
 | 
			
		
	
		
			
				
					|  |  |  | 		LoginUserDetailsFormDTO dto = new LoginUserDetailsFormDTO(); | 
			
		
	
		
			
				
					|  |  |  | 		dto.setApp(formDTO.getApp()); | 
			
		
	
		
			
				
					|  |  |  | 		dto.setClient(formDTO.getClient()); | 
			
		
	
		
			
				
					|  |  |  | 		dto.setUserId(formDTO.getUserId()); | 
			
		
	
		
			
				
					|  |  |  | 		Result<LoginUserDetailsResultDTO> resultDto = epmetUserOpenFeignClient.getLoginUserDetails(dto); | 
			
		
	
		
			
				
					|  |  |  | 		if (!resultDto.success() || StringUtils.isEmpty(resultDto.getData().getAgencyId())) { | 
			
		
	
		
			
				
					|  |  |  | 			throw new RenException(String.format("事件立项调用user服务查询用户数据失败,userId->", formDTO.getUserId())); | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 		return resultDto.getData(); | 
			
		
	
		
			
				
					|  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 	/** | 
			
		
	
		
			
				
					|  |  |  | 	 * @Description 项目立项给勾选的工作人员推送站内信消息 | 
			
		
	
		
			
				
					|  |  |  | 	 * @author yinzuomei | 
			
		
	
		
			
				
					|  |  |  | 	 */ | 
			
		
	
		
			
				
					|  |  |  | 	private Result shiftProjectMessage(List<TickStaffFormDTO> staffList,String customerId,String title) { | 
			
		
	
		
			
				
					|  |  |  | 		List<UserMessageFormDTO> msgList = new ArrayList<>(); | 
			
		
	
		
			
				
					|  |  |  | 		//1.创建项目工作人员消息对象
 | 
			
		
	
		
			
				
					|  |  |  | 		String projectStaffMessage = String.format(UserMessageConstant.PROJECT_RESOLVED_MSG, title); | 
			
		
	
		
			
				
					|  |  |  | 		//所选人员如果即在部门下又在网格下则只发一条消息
 | 
			
		
	
		
			
				
					|  |  |  | 		Map<String,String> map = new HashMap<>(); | 
			
		
	
		
			
				
					|  |  |  | 		staffList.forEach(staff->{ | 
			
		
	
		
			
				
					|  |  |  | 			if(!map.containsKey(staff.getStaffId())){ | 
			
		
	
		
			
				
					|  |  |  | 				UserMessageFormDTO msg = new UserMessageFormDTO(); | 
			
		
	
		
			
				
					|  |  |  | 				msg.setCustomerId(customerId); | 
			
		
	
		
			
				
					|  |  |  | 				msg.setGridId("*"); | 
			
		
	
		
			
				
					|  |  |  | 				msg.setApp(AppClientConstant.APP_GOV); | 
			
		
	
		
			
				
					|  |  |  | 				msg.setTitle(UserMessageConstant.PROJECT_TITLE); | 
			
		
	
		
			
				
					|  |  |  | 				msg.setMessageContent(projectStaffMessage); | 
			
		
	
		
			
				
					|  |  |  | 				msg.setReadFlag(ReadFlagConstant.UN_READ); | 
			
		
	
		
			
				
					|  |  |  | 				msg.setUserId(staff.getStaffId()); | 
			
		
	
		
			
				
					|  |  |  | 				msgList.add(msg); | 
			
		
	
		
			
				
					|  |  |  | 				map.put(staff.getStaffId(),staff.getStaffId()); | 
			
		
	
		
			
				
					|  |  |  | 			} | 
			
		
	
		
			
				
					|  |  |  | 		}); | 
			
		
	
		
			
				
					|  |  |  | 		return epmetMessageOpenFeignClient.saveUserMessageList(msgList); | 
			
		
	
		
			
				
					|  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 	/** | 
			
		
	
		
			
				
					|  |  |  | 	 * @Description 项目立项给勾选的工作人员推送微信订阅消息 | 
			
		
	
		
			
				
					|  |  |  | 	 * @author yinzuomei | 
			
		
	
		
			
				
					|  |  |  | 	 */ | 
			
		
	
		
			
				
					|  |  |  | 	private Result wxmpShiftProjectMessage(List<TickStaffFormDTO> staffList,String customerId,String title) { | 
			
		
	
		
			
				
					|  |  |  | 		List<WxSubscribeMessageFormDTO> msgList = new ArrayList<>(); | 
			
		
	
		
			
				
					|  |  |  | 		//1.创建项目工作人员消息对象
 | 
			
		
	
		
			
				
					|  |  |  | 		String projectStaffMessage = String.format(UserMessageConstant.PROJECT_RESOLVED_MSG, title); | 
			
		
	
		
			
				
					|  |  |  | 		//所选人员如果即在部门下又在网格下则只发一条消息
 | 
			
		
	
		
			
				
					|  |  |  | 		Map<String,String> map = new HashMap<>(); | 
			
		
	
		
			
				
					|  |  |  | 		staffList.forEach(staff->{ | 
			
		
	
		
			
				
					|  |  |  | 			if(!map.containsKey(staff.getStaffId())){ | 
			
		
	
		
			
				
					|  |  |  | 				WxSubscribeMessageFormDTO msg = new WxSubscribeMessageFormDTO(); | 
			
		
	
		
			
				
					|  |  |  | 				msg.setCustomerId(customerId); | 
			
		
	
		
			
				
					|  |  |  | 				msg.setClientType(AppClientConstant.APP_GOV); | 
			
		
	
		
			
				
					|  |  |  | 				msg.setUserId(staff.getStaffId()); | 
			
		
	
		
			
				
					|  |  |  | 				msg.setBehaviorType("项目消息"); | 
			
		
	
		
			
				
					|  |  |  | 				msg.setMessageContent(projectStaffMessage); | 
			
		
	
		
			
				
					|  |  |  | 				msg.setMessageTime(new Date()); | 
			
		
	
		
			
				
					|  |  |  | 				msg.setGridId("*"); | 
			
		
	
		
			
				
					|  |  |  | 				msgList.add(msg); | 
			
		
	
		
			
				
					|  |  |  | 				map.put(staff.getStaffId(),staff.getStaffId()); | 
			
		
	
		
			
				
					|  |  |  | 			} | 
			
		
	
		
			
				
					|  |  |  | 		}); | 
			
		
	
		
			
				
					|  |  |  | 		logger.info("事件立项,推送微信订阅消息"); | 
			
		
	
		
			
				
					|  |  |  | 		return epmetMessageOpenFeignClient.sendWxSubscribeMessage(msgList); | 
			
		
	
		
			
				
					|  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  | } | 
			
		
	
	
		
			
				
					|  |  | 
 |