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)){