|
|
@ -102,6 +102,8 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectDao, ProjectEntit |
|
|
|
private String textSyncScanMethod; |
|
|
|
@Autowired |
|
|
|
private ProjectOrgRelationDao relationDao; |
|
|
|
@Autowired |
|
|
|
private ProjectProcessAttachmentService projectProcessAttachmentService; |
|
|
|
|
|
|
|
private final static String ONE_DAY = "<1"; |
|
|
|
|
|
|
@ -408,22 +410,158 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectDao, ProjectEntit |
|
|
|
projectProcessEntity.setCostWorkdays(getDetentionDays(projectDto)); |
|
|
|
projectProcessService.insert(projectProcessEntity); |
|
|
|
|
|
|
|
//对项目节点耗时记录进行更新,更新全部未处理节点以及结案人的节点耗时
|
|
|
|
//List<ProjectOrgRelationEntity> periodsToUpdate = relationDao.selectAllUnhandledProcess(fromDTO.getProjectId());
|
|
|
|
//if(CollectionUtils.isEmpty(periodsToUpdate)){
|
|
|
|
// log.error("com.epmet.service.impl.ProjectServiceImpl.closed,至少存在一条处理时间为空的项目节点耗时记录,但是没有找到,参数:{}",JSON.toJSONString(fromDTO));
|
|
|
|
// throw new RenException("至少存在一条处理时间为空的项目节点耗时记录,但是没有找到");
|
|
|
|
//}
|
|
|
|
ProjectOrgRelationEntity orientRelation = relationDao.selectByProjectStaffId(operatorProjectReference.getId()); |
|
|
|
if(null == orientRelation){ |
|
|
|
log.error("com.epmet.service.impl.ProjectServiceImpl.closed,找不到结案工作人员的节点耗时相关记录,参数:{}",JSON.toJSONString(fromDTO)); |
|
|
|
throw new RenException("找不到结案工作人员的节点耗时相关记录"); |
|
|
|
} |
|
|
|
|
|
|
|
Integer delta_t = calculateDelta_T(ProjectConstant.IMPRECISE_CALCULATION, |
|
|
|
ProjectConstant.CALCULATION_TYPE_DEFAULT, operatorProjectReference.getId(),orientRelation.getInformedDate(),current); |
|
|
|
|
|
|
|
//List<TimestampIntervalFormDTO> intervalList = new LinkedList<>();
|
|
|
|
//periodsToUpdate.forEach(local -> {
|
|
|
|
// TimestampIntervalFormDTO obj = new TimestampIntervalFormDTO();
|
|
|
|
// obj.setId(local.getProjectStaffId());
|
|
|
|
// obj.setLeft(local.getInformedDate());
|
|
|
|
// obj.setRight(current);
|
|
|
|
// intervalList.add(obj);
|
|
|
|
//});
|
|
|
|
ProjectOrgRelationEntity carrier = new ProjectOrgRelationEntity(); |
|
|
|
carrier.setProjectStaffId(operatorProjectReference.getId()); |
|
|
|
carrier.setOperation(ProjectConstant.OPERATION_CLOSE); |
|
|
|
carrier.setTotalPeriod(delta_t); |
|
|
|
carrier.setHandledDate(current); |
|
|
|
if(null == orientRelation.getFirstDealtDate()){ |
|
|
|
carrier.setFirstReplyPeriod(delta_t); |
|
|
|
carrier.setFirstDealtDate(current); |
|
|
|
} |
|
|
|
|
|
|
|
relationDao.maintainTimePropertyConsistency(carrier); |
|
|
|
|
|
|
|
//通知
|
|
|
|
List<UserMessageFormDTO> msgList = new ArrayList<>(); |
|
|
|
//2020.10.26 添加项目结案发送微信订阅消息操作 sun
|
|
|
|
List<WxSubscribeMessageFormDTO> wxmpMsgList = new ArrayList<>(); |
|
|
|
//通知项目相关人员
|
|
|
|
List<ProjectRelatedPersonnelDTO> personnelList = projectRelatedPersonnelService.getPersonnelListByProjectId(fromDTO.getProjectId()); |
|
|
|
personnelList.forEach(p -> { |
|
|
|
UserMessageFormDTO messageFormDTO = new UserMessageFormDTO(); |
|
|
|
messageFormDTO.setCustomerId(projectEntity.getCustomerId()); |
|
|
|
messageFormDTO.setApp(p.getApp()); |
|
|
|
messageFormDTO.setGridId(p.getGridId()); |
|
|
|
messageFormDTO.setUserId(p.getUserId()); |
|
|
|
messageFormDTO.setTitle(UserMessageConstant.PROJECT_TITLE); |
|
|
|
messageFormDTO.setMessageContent(String.format(UserMessageConstant.PROJECT_CLOSED_MSG, projectEntity.getTitle(), fromDTO.getPublicReply())); |
|
|
|
messageFormDTO.setReadFlag(Constant.UNREAD); |
|
|
|
msgList.add(messageFormDTO); |
|
|
|
WxSubscribeMessageFormDTO msg = new WxSubscribeMessageFormDTO(); |
|
|
|
msg.setCustomerId(projectEntity.getCustomerId()); |
|
|
|
msg.setClientType(p.getApp()); |
|
|
|
msg.setUserId(p.getUserId()); |
|
|
|
msg.setBehaviorType("项目消息"); |
|
|
|
msg.setMessageContent(String.format(UserMessageConstant.PROJECT_CLOSED_MSG, projectEntity.getTitle(), fromDTO.getPublicReply())); |
|
|
|
msg.setMessageTime(new Date()); |
|
|
|
msg.setGridId(p.getGridId()); |
|
|
|
wxmpMsgList.add(msg); |
|
|
|
}); |
|
|
|
//通知项目关联的部门人员
|
|
|
|
List<String> staffList = projectStaffService.getStaffsByProjectId(fromDTO.getProjectId()); |
|
|
|
staffList.add(projectEntity.getCreatedBy()); |
|
|
|
staffList.stream().distinct().forEach(s -> { |
|
|
|
UserMessageFormDTO messageFormDTO = new UserMessageFormDTO(); |
|
|
|
messageFormDTO.setCustomerId(projectEntity.getCustomerId()); |
|
|
|
messageFormDTO.setApp(ProjectConstant.GOV); |
|
|
|
messageFormDTO.setGridId("*"); |
|
|
|
messageFormDTO.setUserId(s); |
|
|
|
messageFormDTO.setTitle(UserMessageConstant.PROJECT_TITLE); |
|
|
|
messageFormDTO.setMessageContent(String.format(UserMessageConstant.PROJECT_CLOSED_MSG, projectEntity.getTitle(), fromDTO.getPublicReply())); |
|
|
|
messageFormDTO.setReadFlag(Constant.UNREAD); |
|
|
|
msgList.add(messageFormDTO); |
|
|
|
WxSubscribeMessageFormDTO msg = new WxSubscribeMessageFormDTO(); |
|
|
|
msg.setCustomerId(projectEntity.getCustomerId()); |
|
|
|
msg.setClientType(AppClientConstant.APP_GOV); |
|
|
|
msg.setUserId(s); |
|
|
|
msg.setBehaviorType("项目消息"); |
|
|
|
msg.setMessageContent(String.format(UserMessageConstant.PROJECT_CLOSED_MSG, projectEntity.getTitle(), fromDTO.getPublicReply())); |
|
|
|
msg.setMessageTime(new Date()); |
|
|
|
msg.setGridId("*"); |
|
|
|
wxmpMsgList.add(msg); |
|
|
|
}); |
|
|
|
messageFeignClient.saveUserMessageList(msgList); |
|
|
|
//2020.10.26 发送微信订阅消息 sun
|
|
|
|
logger.info("项目结案,开始推送微信订阅消息"); |
|
|
|
Result result = epmetMessageOpenFeignClient.sendWxSubscribeMessage(wxmpMsgList); |
|
|
|
if (!result.success()) { |
|
|
|
logger.error("项目结案成功,发送微信订阅消息失败" + JSON.toJSONString(result)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 项目结案 |
|
|
|
* |
|
|
|
* @param fromDTO 参数 |
|
|
|
* @return void |
|
|
|
* @author zhaoqifeng |
|
|
|
* @date 2020/5/13 9:54 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void closedV2(ProjectClosedFromDTO fromDTO) { |
|
|
|
//公开回复内容审核
|
|
|
|
if (StringUtils.isNotBlank(fromDTO.getPublicReply())) { |
|
|
|
TextScanParamDTO textScanParamDTO = new TextScanParamDTO(); |
|
|
|
TextTaskDTO taskDTO = new TextTaskDTO(); |
|
|
|
taskDTO.setDataId(UUID.randomUUID().toString().replace("-", "")); |
|
|
|
taskDTO.setContent(fromDTO.getPublicReply()); |
|
|
|
textScanParamDTO.getTasks().add(taskDTO); |
|
|
|
Result<SyncScanResult> textSyncScanResult = ScanContentUtils.textSyncScan(scanApiUrl.concat(textSyncScanMethod), textScanParamDTO); |
|
|
|
if (!textSyncScanResult.success()) { |
|
|
|
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); |
|
|
|
} else { |
|
|
|
if (!textSyncScanResult.getData().isAllPass()) { |
|
|
|
throw new RenException(EpmetErrorCode.TEXT_SCAN_FAILED.getCode()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//更新项目表状态
|
|
|
|
ProjectEntity projectEntity = baseDao.selectById(fromDTO.getProjectId()); |
|
|
|
if (ProjectConstant.CLOSED.equals(projectEntity.getStatus())) { |
|
|
|
throw new RenException(EpmetErrorCode.PROJECT_IS_CLOSED.getCode()); |
|
|
|
} |
|
|
|
|
|
|
|
Date current = new Date(); |
|
|
|
projectEntity.setStatus(ProjectConstant.CLOSED); |
|
|
|
projectEntity.setClosedStatus(fromDTO.getClosedStatus()); |
|
|
|
baseDao.updateById(projectEntity); |
|
|
|
//更新项目关联表
|
|
|
|
ProjectStaffEntity projectStaffEntity = new ProjectStaffEntity(); |
|
|
|
projectStaffEntity.setId(fromDTO.getProjectStaffId()); |
|
|
|
projectStaffEntity.setIsHandle(ProjectConstant.HANDLE); |
|
|
|
projectStaffService.updateById(projectStaffEntity); |
|
|
|
|
|
|
|
//查询结案人员的信息
|
|
|
|
ProjectStaffEntity operatorProjectReference = projectStaffService.selectById(fromDTO.getProjectStaffId()); |
|
|
|
if(null == operatorProjectReference){ |
|
|
|
log.error("com.epmet.service.impl.ProjectServiceImpl.closed,找不到结案工作人员的相关记录,参数:{}",JSON.toJSONString(fromDTO)); |
|
|
|
throw new RenException("找不到结案工作人员的相关记录"); |
|
|
|
} |
|
|
|
|
|
|
|
//结案记录加入项目进展表
|
|
|
|
ProjectProcessEntity projectProcessEntity = new ProjectProcessEntity(); |
|
|
|
projectProcessEntity.setProjectId(fromDTO.getProjectId()); |
|
|
|
projectProcessEntity.setCustomerId(operatorProjectReference.getCustomerId()); |
|
|
|
projectProcessEntity.setDepartmentName(fromDTO.getDepartmentName()); |
|
|
|
projectProcessEntity.setAgencyId(operatorProjectReference.getOrgId()); |
|
|
|
projectProcessEntity.setGridId(operatorProjectReference.getGridId()); |
|
|
|
projectProcessEntity.setDepartmentId(operatorProjectReference.getDepartmentId()); |
|
|
|
projectProcessEntity.setOrgIdPath(operatorProjectReference.getOrgIdPath()); |
|
|
|
projectProcessEntity.setEndTime(new Date()); |
|
|
|
projectProcessEntity.setOperation(ProjectConstant.OPERATION_CLOSE); |
|
|
|
projectProcessEntity.setOperationName(ProjectConstant.OPERATION_CLOSE_NAME); |
|
|
|
projectProcessEntity.setPublicReply(fromDTO.getPublicReply()); |
|
|
|
projectProcessEntity.setInternalRemark(fromDTO.getInternalRemark()); |
|
|
|
projectProcessEntity.setStaffId(fromDTO.getUserId()); |
|
|
|
ProjectDTO projectDto = ConvertUtils.sourceToTarget(projectEntity, ProjectDTO.class); |
|
|
|
projectDto.setUpdatedTime(projectDto.getCreatedTime()); |
|
|
|
projectProcessEntity.setCostWorkdays(getDetentionDays(projectDto)); |
|
|
|
projectProcessService.insert(projectProcessEntity); |
|
|
|
|
|
|
|
//保存附件
|
|
|
|
saveFile(fromDTO.getPublicFile(), fromDTO.getInternalFile(), operatorProjectReference.getCustomerId(), fromDTO.getProjectId(), |
|
|
|
projectProcessEntity.getId()); |
|
|
|
|
|
|
|
ProjectOrgRelationEntity orientRelation = relationDao.selectByProjectStaffId(operatorProjectReference.getId()); |
|
|
|
if(null == orientRelation){ |
|
|
@ -1422,4 +1560,56 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectDao, ProjectEntit |
|
|
|
}); |
|
|
|
return projects; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void saveFile(List<FileDTO> publicFile, List<FileDTO> internalFile, String customerId, String projectId, String processId) { |
|
|
|
if (CollectionUtils.isNotEmpty(internalFile)) { |
|
|
|
int i = 0; |
|
|
|
List<ProjectProcessAttachmentEntity> list = new ArrayList<>(); |
|
|
|
for (FileDTO item : internalFile) { |
|
|
|
ProjectProcessAttachmentEntity entity = new ProjectProcessAttachmentEntity(); |
|
|
|
entity.setCustomerId(customerId); |
|
|
|
entity.setProjectId(projectId); |
|
|
|
entity.setProcessId(processId); |
|
|
|
entity.setFilePlace("internal"); |
|
|
|
entity.setFileName(item.getName()); |
|
|
|
entity.setAttachmentName(""); |
|
|
|
entity.setAttachmentSize(item.getSize()); |
|
|
|
entity.setAttachmentFormat(item.getFormat()); |
|
|
|
entity.setAttachmentType(item.getType()); |
|
|
|
entity.setAttachmentUrl(item.getUrl()); |
|
|
|
entity.setSort(i); |
|
|
|
entity.setDuration(item.getDuration()); |
|
|
|
entity.setIsRelease(NumConstant.ONE); |
|
|
|
list.add(entity); |
|
|
|
i++; |
|
|
|
} |
|
|
|
projectProcessAttachmentService.insertBatch(list); |
|
|
|
} |
|
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(publicFile)) { |
|
|
|
//TODO 内容安全检查
|
|
|
|
int i = 0; |
|
|
|
List<ProjectProcessAttachmentEntity> list = new ArrayList<>(); |
|
|
|
for (FileDTO item : publicFile) { |
|
|
|
ProjectProcessAttachmentEntity entity = new ProjectProcessAttachmentEntity(); |
|
|
|
entity.setCustomerId(customerId); |
|
|
|
entity.setProjectId(projectId); |
|
|
|
entity.setProcessId(processId); |
|
|
|
entity.setFilePlace("public"); |
|
|
|
entity.setFileName(item.getName()); |
|
|
|
entity.setAttachmentName(""); |
|
|
|
entity.setAttachmentSize(item.getSize()); |
|
|
|
entity.setAttachmentFormat(item.getFormat()); |
|
|
|
entity.setAttachmentType(item.getType()); |
|
|
|
entity.setAttachmentUrl(item.getUrl()); |
|
|
|
entity.setSort(i); |
|
|
|
entity.setDuration(item.getDuration()); |
|
|
|
entity.setIsRelease(NumConstant.ZERO); |
|
|
|
list.add(entity); |
|
|
|
i++; |
|
|
|
} |
|
|
|
projectProcessAttachmentService.insertBatch(list); |
|
|
|
} |
|
|
|
} |
|
|
|
} |