From 5ac27c5c41d2b2b0d911d27187d948a078025795 Mon Sep 17 00:00:00 2001 From: wangzhijiang <12345678> Date: Thu, 9 Mar 2023 09:33:23 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A4=E8=AF=81=E6=B8=85=E5=8D=95=E6=B5=81?= =?UTF-8?q?=E7=A8=8B-=E8=B4=A3=E4=BB=BB=E4=BA=BA=E6=8E=A5=E5=8F=97?= =?UTF-8?q?=E3=80=81=E8=B4=A3=E4=BB=BB=E4=BA=BA=E6=8B=92=E7=BB=9D=E3=80=81?= =?UTF-8?q?=E8=B4=A3=E4=BB=BB=E4=BA=BA=E6=8F=90=E4=BA=A4=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=BC=80=E5=8F=91=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ctCertificationInventoryEOServiceImpl.java | 235 +++++++++++++++++- 1 file changed, 231 insertions(+), 4 deletions(-) diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/service/impl/ProjectCertificationInventoryEOServiceImpl.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/service/impl/ProjectCertificationInventoryEOServiceImpl.java index c305d85ff..2b9f36c08 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/service/impl/ProjectCertificationInventoryEOServiceImpl.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/service/impl/ProjectCertificationInventoryEOServiceImpl.java @@ -689,11 +689,11 @@ public class ProjectCertificationInventoryEOServiceImpl extends ServiceImpl dutyPersonSubmitTask(JSONObject json) { + LoginUser currentUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + + String ids = json.getString("ids"); + if(StringUtils.isEmpty(ids)){ + throw new JeroBootException("至少选择一条数据进行操作!"); + } + List idList = Arrays.asList(ids.split(",")); + + List flowStatusList = new ArrayList<>(); + flowStatusList.add(CertificationInventoryFlowStatusEnum.RESULTS_TO_BE_SUBMITTED.getValue()); + + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().in(ProjectCertificationInventoryEO::getId,idList); + queryWrapper.lambda().in(ProjectCertificationInventoryEO::getFlowStatus,flowStatusList); + List projectCertificationInventoryEOList = this.list(queryWrapper); + + if(CollectionUtils.isEmpty(projectCertificationInventoryEOList)){ + throw new JeroBootException("至少选择一条数据流程状态为'结果待提交'的数据!"); + } + + ProjectLibraryBase projectLibraryBase = JSONObject.parseObject(JSONObject.toJSONString(json.get("projectLibraryBase")), ProjectLibraryBase.class); + + // 给认证工程师分配待办中心的任务 + String certificationEngineer = projectLibraryBase.getCertificationEngineer(); + if(StringUtils.isEmpty(certificationEngineer)){ + throw new JeroBootException("该项目中认证工程师为空,请先维护认证工程师!"); + } + + List processInfoDetailEOList = new ArrayList<>(); + List certificationEngineerList = Arrays.asList(certificationEngineer.split(",")); + // 给认证工程师分配任务 + for (String userId : certificationEngineerList) { + ProcessInfoDetailEO processInfoDetailEO = new ProcessInfoDetailEO(); + processInfoDetailEO.setUserId(userId); + processInfoDetailEO.setTaskDefinitionKey(CertificationFlowNodeEnum.RZGCSSC.getKey()); + processInfoDetailEO.setCreateTime(new Date()); + processInfoDetailEO.setStatus(TaskStatusEnum.NOT_DONE.getValue()); + processInfoDetailEO.setProcessInfoId(projectLibraryBase.getId()); + processInfoDetailEO.setActiProcInstId(projectLibraryBase.getId()); + processInfoDetailEO.setFlowType(FlowTypeEnum.CERTIFICATION_LC.getValue()); + processInfoDetailEOList.add(processInfoDetailEO); + } + // 数据更新为结果待审查 + for (ProjectCertificationInventoryEO projectCertificationInventoryEO : projectCertificationInventoryEOList) { + projectCertificationInventoryEO.setFlowStatus(CertificationInventoryFlowStatusEnum.RESULTS_TO_BE_REVIEWED.getValue()); + } + try { + this.updateBatchById(projectCertificationInventoryEOList); + + List certificationIdList = projectCertificationInventoryEOList.stream().map(ProjectCertificationInventoryEO::getId).distinct().collect(Collectors.toList()); + + // 将当前责任人的待办任务转为已办 + LambdaUpdateWrapper detailUpdateWrap = new LambdaUpdateWrapper<>(); + detailUpdateWrap.eq(ProcessInfoDetailEO::getProcessInfoId,projectLibraryBase.getId()); + detailUpdateWrap.eq(ProcessInfoDetailEO::getUserId,currentUser.getId()); + detailUpdateWrap.eq(ProcessInfoDetailEO::getTaskDefinitionKey,CertificationFlowNodeEnum.ZRRTJRW.getKey()); + detailUpdateWrap.eq(ProcessInfoDetailEO::getProjectLawsInventoryId,certificationIdList); + detailUpdateWrap.set(ProcessInfoDetailEO::getStatus,TaskStatusEnum.HAVE_DONE.getValue()); + this.processInfoDetailEOService.update(detailUpdateWrap); + + // 给认证工程师分配待办中心的任务 认证工程师审查 + this.addProcessInfoDetailEO(processInfoDetailEOList,projectLibraryBase.getId(),CertificationFlowNodeEnum.RZGCSSC.getKey()); + }catch (Exception ex){ + ex.printStackTrace(); + log.error("责任人-提交任务失败:" + ex.getMessage()); + throw new JeroBootException("提交任务失败!"); + } + + return Result.OK("提交任务成功!"); + } + + /** + * 责任人接受任务 + * @param json + * @return + */ + private Result dutyPersonAcceptTask(JSONObject json) { + LoginUser currentUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + + String ids = json.getString("ids"); + if(StringUtils.isEmpty(ids)){ + throw new JeroBootException("至少选择一条数据进行操作!"); + } + List idList = Arrays.asList(ids.split(",")); + + List flowStatusList = new ArrayList<>(); + flowStatusList.add(CertificationInventoryFlowStatusEnum.TASK_TO_BE_CONFIRMED.getValue()); + + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().in(ProjectCertificationInventoryEO::getId,idList); + queryWrapper.lambda().in(ProjectCertificationInventoryEO::getFlowStatus,flowStatusList); + List projectCertificationInventoryEOList = this.list(queryWrapper); + + if(CollectionUtils.isEmpty(projectCertificationInventoryEOList)){ + throw new JeroBootException("至少选择一条数据流程状态为'任务待确认'的数据!"); + } + + ProjectLibraryBase projectLibraryBase = JSONObject.parseObject(JSONObject.toJSONString(json.get("projectLibraryBase")), ProjectLibraryBase.class); + + List processInfoDetailEOList = new ArrayList<>(); + for (ProjectCertificationInventoryEO projectCertificationInventoryEO : projectCertificationInventoryEOList) { + projectCertificationInventoryEO.setFlowStatus(CertificationInventoryFlowStatusEnum.RESULTS_TO_BE_SUBMITTED.getValue()); + + ProcessInfoDetailEO processInfoDetailEO = new ProcessInfoDetailEO(); + processInfoDetailEO.setUserId(projectCertificationInventoryEO.getDutyPerson()); + processInfoDetailEO.setEndTime(projectCertificationInventoryEO.getEndTime()); + processInfoDetailEO.setProjectLawsInventoryId(projectCertificationInventoryEO.getId()); + processInfoDetailEOList.add(processInfoDetailEO); + } + + try { + List certificationIdList = projectCertificationInventoryEOList.stream().map(ProjectCertificationInventoryEO::getId).distinct().collect(Collectors.toList()); + // 将当前责任人的待办任务转为已办 + LambdaUpdateWrapper detailUpdateWrap = new LambdaUpdateWrapper<>(); + detailUpdateWrap.eq(ProcessInfoDetailEO::getProcessInfoId,projectLibraryBase.getId()); + detailUpdateWrap.eq(ProcessInfoDetailEO::getUserId,currentUser.getId()); + detailUpdateWrap.eq(ProcessInfoDetailEO::getTaskDefinitionKey,CertificationFlowNodeEnum.ZRRJSRW.getKey()); + detailUpdateWrap.eq(ProcessInfoDetailEO::getProjectLawsInventoryId,certificationIdList); + detailUpdateWrap.set(ProcessInfoDetailEO::getStatus,TaskStatusEnum.HAVE_DONE.getValue()); + this.processInfoDetailEOService.update(detailUpdateWrap); + + // 给责任人分配待办中心的任务 (待提交) + this.addProcessInfoDetailEO(processInfoDetailEOList,projectLibraryBase.getId(),CertificationFlowNodeEnum.ZRRTJRW.getKey()); + + // 责任人接受任务,将数据的状态更新为 结果待提交。 + this.updateBatchById(projectCertificationInventoryEOList); + }catch (Exception ex){ + ex.printStackTrace(); + log.error("责任人-接受任务失败:" + ex.getMessage()); + throw new JeroBootException("接受任务失败!"); + } + + return Result.OK("接受任务成功!"); + } + + /** + * 责任人拒绝任务 + * @param json + * @return + */ + private Result dutyPersonRejectTask(JSONObject json) { + LoginUser currentUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + + String ids = json.getString("ids"); + if(StringUtils.isEmpty(ids)){ + throw new JeroBootException("至少选择一条数据进行操作!"); + } + List idList = Arrays.asList(ids.split(",")); + + List flowStatusList = new ArrayList<>(); + flowStatusList.add(CertificationInventoryFlowStatusEnum.TASK_TO_BE_CONFIRMED.getValue()); + + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().in(ProjectCertificationInventoryEO::getId,idList); + queryWrapper.lambda().in(ProjectCertificationInventoryEO::getFlowStatus,flowStatusList); + List projectCertificationInventoryEOList = this.list(queryWrapper); + + if(CollectionUtils.isEmpty(projectCertificationInventoryEOList)){ + throw new JeroBootException("至少选择一条数据流程状态为'任务待确认'的数据!"); + } + + ProjectLibraryBase projectLibraryBase = JSONObject.parseObject(JSONObject.toJSONString(json.get("projectLibraryBase")), ProjectLibraryBase.class); + + // 给认证工程师分配待办中心的任务 + String certificationEngineer = projectLibraryBase.getCertificationEngineer(); + if(StringUtils.isEmpty(certificationEngineer)){ + throw new JeroBootException("该项目中认证工程师为空,请先维护认证工程师!"); + } + + for (ProjectCertificationInventoryEO projectCertificationInventoryEO : projectCertificationInventoryEOList) { + projectCertificationInventoryEO.setFlowStatus(CertificationInventoryFlowStatusEnum.REFUSAL_OF_RESPONSIBLE_PERSON.getValue()); + } + + try { + // 将当前责任人的待办任务转为已办 + LambdaUpdateWrapper detailUpdateWrap = new LambdaUpdateWrapper<>(); + detailUpdateWrap.eq(ProcessInfoDetailEO::getProcessInfoId,projectLibraryBase.getId()); + detailUpdateWrap.eq(ProcessInfoDetailEO::getUserId,currentUser.getId()); + detailUpdateWrap.eq(ProcessInfoDetailEO::getTaskDefinitionKey,CertificationFlowNodeEnum.ZRRJSRW.getKey()); + detailUpdateWrap.set(ProcessInfoDetailEO::getStatus,TaskStatusEnum.HAVE_DONE.getValue()); + this.processInfoDetailEOService.update(detailUpdateWrap); + + List processInfoDetailEOList = new ArrayList<>(); + List certificationEngineerList = Arrays.asList(certificationEngineer.split(",")); + // 给认证工程师分配任务 + for (String userId : certificationEngineerList) { + ProcessInfoDetailEO processInfoDetailEO = new ProcessInfoDetailEO(); + processInfoDetailEO.setUserId(userId); + processInfoDetailEO.setTaskDefinitionKey(CertificationFlowNodeEnum.RZGCSJSRW.getKey()); + processInfoDetailEO.setCreateTime(new Date()); + processInfoDetailEO.setStatus(TaskStatusEnum.NOT_DONE.getValue()); + processInfoDetailEO.setProcessInfoId(projectLibraryBase.getId()); + processInfoDetailEO.setActiProcInstId(projectLibraryBase.getId()); + processInfoDetailEO.setFlowType(FlowTypeEnum.CERTIFICATION_LC.getValue()); + processInfoDetailEOList.add(processInfoDetailEO); + } + + // 删除该项目数据的待办任务,key为 认证工程师接受任务的数据 + QueryWrapper deleteDetailWrap = new QueryWrapper<>(); + deleteDetailWrap.lambda().eq(ProcessInfoDetailEO::getProcessInfoId,projectLibraryBase.getId()); + deleteDetailWrap.lambda().eq(ProcessInfoDetailEO::getTaskDefinitionKey,CertificationFlowNodeEnum.RZGCSJSRW.getKey()); + deleteDetailWrap.lambda().eq(ProcessInfoDetailEO::getFlowType,FlowTypeEnum.CERTIFICATION_LC.getValue()); + this.processInfoDetailEOService.remove(deleteDetailWrap); + this.processInfoDetailEOService.saveBatch(processInfoDetailEOList); + + // 责任人接受任务,将数据的状态更新为 结果待提交。 + this.updateBatchById(projectCertificationInventoryEOList); + }catch (Exception ex){ + ex.printStackTrace(); + log.error("责任人-拒绝任务失败:" + ex.getMessage()); + throw new JeroBootException("拒绝任务失败!"); + } + return Result.OK("拒绝任务成功!"); + } + + /** + * 认证工程师退回至studio任务 + * @param json + * @return + */ private Result certificationReturnedStudioTask(JSONObject json) { String ids = json.getString("ids"); if(StringUtils.isEmpty(ids)){