认证清单流程-责任人接受、责任人拒绝、责任人提交功能开发。

This commit is contained in:
wangzhijiang
2023-03-09 09:33:23 +08:00
parent e6759c73fc
commit 5ac27c5c41
@@ -689,11 +689,11 @@ public class ProjectCertificationInventoryEOServiceImpl extends ServiceImpl<Proj
case RZGCSTHRW:
return this.certificationReturnedStudioTask(json);
case ZRRJSRW:
break;
return this.dutyPersonAcceptTask(json);
case ZRRJJRW:
return this.dutyPersonRejectTask(json);
case ZRRTJRW:
break;
return this.dutyPersonSubmitTask(json);
case RZGCSSC:
break;
@@ -704,6 +704,233 @@ public class ProjectCertificationInventoryEOServiceImpl extends ServiceImpl<Proj
return Result.OK("提交任务成功!");
}
/**
* 责任人提交任务
* @param json
* @return
*/
private Result<?> dutyPersonSubmitTask(JSONObject json) {
LoginUser currentUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
String ids = json.getString("ids");
if(StringUtils.isEmpty(ids)){
throw new JeroBootException("至少选择一条数据进行操作!");
}
List<String> idList = Arrays.asList(ids.split(","));
List<String> flowStatusList = new ArrayList<>();
flowStatusList.add(CertificationInventoryFlowStatusEnum.RESULTS_TO_BE_SUBMITTED.getValue());
QueryWrapper<ProjectCertificationInventoryEO> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().in(ProjectCertificationInventoryEO::getId,idList);
queryWrapper.lambda().in(ProjectCertificationInventoryEO::getFlowStatus,flowStatusList);
List<ProjectCertificationInventoryEO> 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<ProcessInfoDetailEO> processInfoDetailEOList = new ArrayList<>();
List<String> 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<String> certificationIdList = projectCertificationInventoryEOList.stream().map(ProjectCertificationInventoryEO::getId).distinct().collect(Collectors.toList());
// 将当前责任人的待办任务转为已办
LambdaUpdateWrapper<ProcessInfoDetailEO> 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<String> idList = Arrays.asList(ids.split(","));
List<String> flowStatusList = new ArrayList<>();
flowStatusList.add(CertificationInventoryFlowStatusEnum.TASK_TO_BE_CONFIRMED.getValue());
QueryWrapper<ProjectCertificationInventoryEO> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().in(ProjectCertificationInventoryEO::getId,idList);
queryWrapper.lambda().in(ProjectCertificationInventoryEO::getFlowStatus,flowStatusList);
List<ProjectCertificationInventoryEO> projectCertificationInventoryEOList = this.list(queryWrapper);
if(CollectionUtils.isEmpty(projectCertificationInventoryEOList)){
throw new JeroBootException("至少选择一条数据流程状态为'任务待确认'的数据!");
}
ProjectLibraryBase projectLibraryBase = JSONObject.parseObject(JSONObject.toJSONString(json.get("projectLibraryBase")), ProjectLibraryBase.class);
List<ProcessInfoDetailEO> 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<String> certificationIdList = projectCertificationInventoryEOList.stream().map(ProjectCertificationInventoryEO::getId).distinct().collect(Collectors.toList());
// 将当前责任人的待办任务转为已办
LambdaUpdateWrapper<ProcessInfoDetailEO> 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<String> idList = Arrays.asList(ids.split(","));
List<String> flowStatusList = new ArrayList<>();
flowStatusList.add(CertificationInventoryFlowStatusEnum.TASK_TO_BE_CONFIRMED.getValue());
QueryWrapper<ProjectCertificationInventoryEO> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().in(ProjectCertificationInventoryEO::getId,idList);
queryWrapper.lambda().in(ProjectCertificationInventoryEO::getFlowStatus,flowStatusList);
List<ProjectCertificationInventoryEO> 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<ProcessInfoDetailEO> 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<ProcessInfoDetailEO> processInfoDetailEOList = new ArrayList<>();
List<String> 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<ProcessInfoDetailEO> 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)){