From ffa49475fcd35b7d0085e4760ff4f6bf2fabe133 Mon Sep 17 00:00:00 2001 From: sunyuchao Date: Tue, 22 Dec 2020 09:46:50 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=AC=E5=85=B6=E4=BB=96=E9=83=A8=E9=97=A8V2?= =?UTF-8?q?=E3=80=81sql=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/ProjectProcessAttachmentDTO.java | 2 +- .../com/epmet/dto/form/TransferFormDTO.java | 8 + .../controller/ProjectTraceController.java | 15 ++ .../ProjectProcessAttachmentEntity.java | 2 +- .../excel/ProjectProcessAttachmentExcel.java | 2 +- .../epmet/service/ProjectProcessService.java | 8 + .../impl/ProjectProcessServiceImpl.java | 164 ++++++++++++++++++ .../V0.0.5__create_project_attachment.sql | 41 +++++ 8 files changed, 239 insertions(+), 3 deletions(-) create mode 100644 epmet-module/gov-project/gov-project-server/src/main/resources/db/migration/V0.0.5__create_project_attachment.sql diff --git a/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/ProjectProcessAttachmentDTO.java b/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/ProjectProcessAttachmentDTO.java index e149c211ca..08613dc2d2 100644 --- a/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/ProjectProcessAttachmentDTO.java +++ b/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/ProjectProcessAttachmentDTO.java @@ -89,7 +89,7 @@ public class ProjectProcessAttachmentDTO implements Serializable { private String attachmentUrl; /** - * 排序(按文件所属节点的所属位置分组,在按文件类型排序) + * 排序(需求确定,按上传顺序排序) */ private Integer sort; diff --git a/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/form/TransferFormDTO.java b/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/form/TransferFormDTO.java index 9d078a27b5..4b9718122c 100644 --- a/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/form/TransferFormDTO.java +++ b/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/form/TransferFormDTO.java @@ -32,5 +32,13 @@ public class TransferFormDTO implements Serializable { @Valid private List staffList; + /** + * 公开答复对应文件集合 + */ + private List publicFile; + /** + * 内部备注对应文件集合 + */ + private List internalFile; } diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/controller/ProjectTraceController.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/controller/ProjectTraceController.java index d0c1124bdc..7ce5869bbe 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/controller/ProjectTraceController.java +++ b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/controller/ProjectTraceController.java @@ -279,5 +279,20 @@ public class ProjectTraceController { ValidatorUtils.validateEntity(formDTO, ProcessListV2FormDTO.ProcessListV2Form.class); return new Result>().ok(projectTraceService.processListV2(formDTO)); } + + /** + * @param formDTO + * @return + * @Author sun + * @Description 项目跟踪-转其他部门2.0接口 + **/ + @PostMapping("transfer-v2") + @RequirePermission(requirePermission = RequirePermissionEnum.WORK_PROJECT_TRACE_TRANSFER) + public Result transferV2(@LoginUser TokenDto tokenDTO, @RequestBody TransferFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO); + projectProcessService.transferV2(formDTO); + return new Result(); + } + } diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/entity/ProjectProcessAttachmentEntity.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/entity/ProjectProcessAttachmentEntity.java index aa82b11777..276bd9ea1f 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/entity/ProjectProcessAttachmentEntity.java +++ b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/entity/ProjectProcessAttachmentEntity.java @@ -89,7 +89,7 @@ public class ProjectProcessAttachmentEntity extends BaseEpmetEntity { private String attachmentUrl; /** - * 排序(按文件所属节点的所属位置分组,在按文件类型排序) + * 排序(需求确定,按上传顺序排序) */ private Integer sort; diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/excel/ProjectProcessAttachmentExcel.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/excel/ProjectProcessAttachmentExcel.java index 150132c106..38f5fb15f9 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/excel/ProjectProcessAttachmentExcel.java +++ b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/excel/ProjectProcessAttachmentExcel.java @@ -64,7 +64,7 @@ public class ProjectProcessAttachmentExcel { @Excel(name = "url地址") private String attachmentUrl; - @Excel(name = "排序(按文件所属节点的所属位置分组,在按文件类型排序)") + @Excel(name = "排序(需求确定,按上传顺序排序)") private Integer sort; @Excel(name = "语音或视频时长,秒") diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/ProjectProcessService.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/ProjectProcessService.java index 59f41ab307..3a7643f3a5 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/ProjectProcessService.java +++ b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/ProjectProcessService.java @@ -151,4 +151,12 @@ public interface ProjectProcessService extends BaseService **/ List selectResponseTrace(List projects); + /** + * @param formDTO + * @return + * @Author sun + * @Description 项目跟踪-转其他部门2.0接口 + **/ + void transferV2(TransferFormDTO formDTO); + } \ No newline at end of file diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectProcessServiceImpl.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectProcessServiceImpl.java index 759d57bcb2..0bf154cd54 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectProcessServiceImpl.java +++ b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectProcessServiceImpl.java @@ -521,4 +521,168 @@ public class ProjectProcessServiceImpl extends BaseServiceImpl 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()); + } + } + } + + //1:更新项目人员关联表数据状态为已处理 + ProjectStaffEntity staffEntity = projectStaffDao.selectById(formDTO.getProjectStaffId()); + if (null == staffEntity) { + throw new RenException(ProjectConstant.SELECT_PROJECTSTAFF_EXCEPTION); + } + if (!ProjectConstant.UNHANDLED.equals(staffEntity.getIsHandle())) { + throw new RenException(ProjectConstant.UNHANDLED_EXCEPTION); + } + staffEntity.setIsHandle(ProjectConstant.HANDLE); + if (projectStaffDao.updateById(staffEntity) < NumConstant.ONE) { + throw new RenException(ProjectConstant.UPDATE_PROJECTSTAFF_EXCEPTION); + } + + //2:项目处理进展列表新增数据 + ProjectProcessEntity processEntity = ConvertUtils.sourceToTarget(formDTO, ProjectProcessEntity.class); + processEntity.setCustomerId(staffEntity.getCustomerId()); + processEntity.setDepartmentName(staffEntity.getDepartmentName()); + processEntity.setStaffId(staffEntity.getStaffId()); + processEntity.setOperation(ProjectConstant.OPERATION_TRANSFER); + processEntity.setOperationName(ProjectConstant.OPERATION_TRANSFER_NAME); + processEntity.setAgencyId(staffEntity.getOrgId()); + processEntity.setDepartmentId(staffEntity.getDepartmentId()); + processEntity.setGridId(staffEntity.getGridId()); + processEntity.setOrgIdPath(staffEntity.getOrgIdPath()); + projectProcessDao.insert(processEntity); + //2-1.项目附件表新增数据 + if (formDTO.getPublicFile().size() > NumConstant.ZERO || formDTO.getInternalFile().size() > NumConstant.ZERO) { + projectService.saveFile(formDTO.getPublicFile(), formDTO.getInternalFile(), staffEntity.getCustomerId(), formDTO.getProjectId(), processEntity.getId()); + } + + //3:项目人员关联表新增部门流转数据 + List staffList = formDTO.getStaffList(); + if (null == staffList || staffList.size() < NumConstant.ONE) { + throw new RenException(ProjectConstant.DATE_EXCEPTION); + } + //3.1:调用gov-org服务,获取所有勾选人员对应的组织信息、部门信息、网格信息用于对处理部门和ORG_ID_PATH字段的赋值 + List agencyIdList = staffList.stream().map(TickStaffFormDTO::getAgencyId).collect(Collectors.toList()); + agencyIdList = new ArrayList(new LinkedHashSet<>(agencyIdList));agencyIdList.removeAll(Collections.singleton("")); + List deptIdList = staffList.stream().map(TickStaffFormDTO::getDepartmentId).collect(Collectors.toList()); + deptIdList = new ArrayList(new LinkedHashSet<>(deptIdList));deptIdList.removeAll(Collections.singleton("")); + List gridIdList = staffList.stream().map(TickStaffFormDTO::getGridId).collect(Collectors.toList()); + gridIdList = new ArrayList(new LinkedHashSet<>(gridIdList));gridIdList.removeAll(Collections.singleton("")); + AgencyDeptGridFormDTO agencyDeptGridFormDTO = new AgencyDeptGridFormDTO(); + agencyDeptGridFormDTO.setAgencyIdList(agencyIdList); + agencyDeptGridFormDTO.setDeptIdList(deptIdList); + agencyDeptGridFormDTO.setGridIdList(gridIdList); + Result resultDTO = govOrgFeignClient.getAgencyDeptGridList(agencyDeptGridFormDTO); + if (!resultDTO.success() || null == resultDTO.getData()) { + throw new RenException(ProjectConstant.SELECT_GOV_ORG_EXCEPTION); + } + AgencyDeptGridResultDTO agencyDeptGrid = resultDTO.getData(); + //3.2:批量新增项目人员关联表数据 + List entityList = new ArrayList<>(); + staffList.forEach(ts->{ + ProjectStaffEntity entity = ConvertUtils.sourceToTarget(ts, ProjectStaffEntity.class); + entity.setOrgId(ts.getAgencyId()); + entity.setProjectId(formDTO.getProjectId()); + 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 (StringUtils.isNotBlank(ts.getDepartmentId())) { + agencyDeptGrid.getDeptList().forEach(dept -> { + if (ts.getDepartmentId().equals(dept.getId())) { + entity.setDepartmentName(entity.getDepartmentName() + "-" + dept.getDepartmentName()); + } + }); + } + if (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.3 项目机关历时关系 project_org_relation 更新原来的 + ProjectOrgRelationEntity orientRelation = relationDao.selectByProjectStaffId(staffEntity.getId()); + if(null == orientRelation){ + log.error("com.epmet.service.impl.ProjectProcessServiceImpl.transfer,找不到项目节点机关历时记录,参数:{}",JSON.toJSONString(formDTO)); + } + Date current = new Date(); + WorkMinuteFormDTO timeParam = new WorkMinuteFormDTO(); + timeParam.setIfPrecise(ProjectConstant.IMPRECISE_CALCULATION); + timeParam.setIfCustom(ProjectConstant.CALCULATION_TYPE_DEFAULT); + TimestampIntervalFormDTO interval = new TimestampIntervalFormDTO(orientRelation.getProjectStaffId(),orientRelation.getInformedDate(),current); + List intervalList = new LinkedList<>();intervalList.add(interval); + timeParam.setTimeList(intervalList); + Result> timeResult = epmetCommonServiceOpenFeignClient.workMinutes(timeParam); + + if(timeResult.success() && !CollectionUtils.isEmpty(timeResult.getData()) && null != timeResult.getData().get(staffEntity.getId())){ + + ProjectOrgRelationEntity relationDto = new ProjectOrgRelationEntity(); + relationDto.setProjectStaffId(orientRelation.getProjectStaffId()); + relationDto.setHandledDate(current); + relationDto.setTotalPeriod(timeResult.getData().get(staffEntity.getId())); + relationDto.setOperation(ProjectConstant.OPERATION_TRANSFER); + if(null == orientRelation.getFirstDealtDate()){ + relationDto.setFirstDealtDate(current); + relationDto.setFirstReplyPeriod(relationDto.getTotalPeriod()); + } + relationDao.maintainTimePropertyConsistency(relationDto); + }else{ + log.error("com.epmet.service.impl.ProjectProcessServiceImpl.transfer,计算节点耗时失败,参数:{}", JSON.toJSONString(timeParam)); + throw new RenException("计算节点耗时失败"); + } + + //3.4 项目机关历时关系 project_org_relation 插入新增的 + List relationList = new LinkedList<>(); + entityList.forEach(staff -> { + ProjectOrgRelationEntity relation = new ProjectOrgRelationEntity(); + relation.setProjectStaffId(staff.getId()); + relation.setInformedDate(current); + relation.setSourceOperation(ProjectConstant.OPERATION_TRANSFER); + relationList.add(relation); + }); + relationDao.insertBatch(relationList); + + //4:调用epmet-message服务,给项目流转过程中的工作人员发送消息 + if (!transferMessage(formDTO).success()) { + throw new RenException(ProjectConstant.SAVE_MSG_EXCEPTION); + } + + //5:调用epmet-message服务,给项目流转过程中的工作人员发送订阅的微信消息 + if (!transferWxmpMessage(formDTO).success()) { + logger.error("项目流转,推送微信订阅消息失败"); + //throw new RenException(ProjectConstant.SAVE_WXMP_MSG_EXCEPTION); + } + } + } \ No newline at end of file diff --git a/epmet-module/gov-project/gov-project-server/src/main/resources/db/migration/V0.0.5__create_project_attachment.sql b/epmet-module/gov-project/gov-project-server/src/main/resources/db/migration/V0.0.5__create_project_attachment.sql new file mode 100644 index 0000000000..6dd706bf39 --- /dev/null +++ b/epmet-module/gov-project/gov-project-server/src/main/resources/db/migration/V0.0.5__create_project_attachment.sql @@ -0,0 +1,41 @@ + +CREATE TABLE `project_process_attachment` ( + `ID` varchar(64) NOT NULL COMMENT '唯一标识', + `CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户ID', + `PROJECT_ID` varchar(64) NOT NULL COMMENT '项目ID', + `PROCESS_ID` varchar(64) NOT NULL COMMENT '项目进展表ID', + `FILE_PLACE` varchar(64) NOT NULL COMMENT '文件所属位置(内部备注: internal 公开答复:public)', + `FILE_NAME` varchar(255) DEFAULT NULL COMMENT '文件名', + `ATTACHMENT_NAME` varchar(255) DEFAULT NULL COMMENT '附件名(uuid随机生成)', + `ATTACHMENT_SIZE` int(11) DEFAULT NULL COMMENT '文件大小', + `ATTACHMENT_FORMAT` varchar(64) DEFAULT NULL COMMENT '文件格式(JPG、PNG、JPEG、BMP、GIF、PDF、PPT、PPTX、DOC、DOCX、XLS、XLSX、MP3、WMA、M4A、MP4、AVI、MOV、RMVB、RM、WMV)', + `ATTACHMENT_TYPE` varchar(64) DEFAULT NULL COMMENT '文件类型((图片 - image、 视频 - video、 语音 - voice、 文档 - doc))', + `ATTACHMENT_URL` varchar(255) NOT NULL COMMENT 'url地址', + `SORT` int(11) NOT NULL COMMENT '排序(需求确定,按上传顺序排序)', + `DURATION` int(11) unsigned zerofill DEFAULT '00000000000' COMMENT '语音或视频时长,秒', + `IS_RELEASE` int(1) NOT NULL DEFAULT '0' COMMENT '是否强制发布(0:否 1:是)', + `DEL_FLAG` char(1) NOT NULL COMMENT '删除标识:0.未删除 1.已删除', + `REVISION` int(11) NOT NULL COMMENT '乐观锁', + `CREATED_BY` varchar(32) NOT NULL COMMENT '创建人', + `CREATED_TIME` datetime NOT NULL COMMENT '创建时间', + `UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人', + `UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='项目节点附件表'; + +CREATE TABLE `project_process_scan_task` ( + `ID` varchar(64) NOT NULL COMMENT '唯一标识', + `CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户ID', + `PROJECT_ID` varchar(64) NOT NULL COMMENT '项目ID', + `PROCESS_ID` varchar(64) NOT NULL COMMENT '项目进展表(project_process)ID', + `PROJECT_PROCESS_ATTACHMENT_ID` varchar(64) NOT NULL COMMENT '项目附件表主键,对应dataId', + `TASK_ID` varchar(64) NOT NULL COMMENT '阿里云审核任务Id', + `STATUS` varchar(32) NOT NULL COMMENT '审核状态【auditing: 审核中;\r\nauto_passed: 自动通过;\r\nreview:结果不确定,需要人工审核;\r\nblock: 结果违规;】', + `ATTACHMENT_TYPE` varchar(64) NOT NULL COMMENT '附件类型(视频 - video、 语音 - voice 文件 - doc)', + `DEL_FLAG` char(1) NOT NULL COMMENT '删除标识:0.未删除 1.已删除', + `REVISION` int(11) NOT NULL COMMENT '乐观锁', + `CREATED_TIME` datetime NOT NULL COMMENT '创建时间', + `UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人', + `UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='项目节点附件安全校验任务表';