diff --git a/laws-modules/src/main/java/com/jero/modules/activiti/process/standardinterpret/service/impl/StandardInterpretFlowServiceImpl.java b/laws-modules/src/main/java/com/jero/modules/activiti/process/standardinterpret/service/impl/StandardInterpretFlowServiceImpl.java index d4db1e83..2ba3bda4 100644 --- a/laws-modules/src/main/java/com/jero/modules/activiti/process/standardinterpret/service/impl/StandardInterpretFlowServiceImpl.java +++ b/laws-modules/src/main/java/com/jero/modules/activiti/process/standardinterpret/service/impl/StandardInterpretFlowServiceImpl.java @@ -348,55 +348,56 @@ public class StandardInterpretFlowServiceImpl implements StandardInterpretFlowSe queryWrapper.in(ProcessStandardInterpretClause::getId, Arrays.asList(distributeIdList.split(","))); } - List processStandardInterpretClauseList = - processStandardInterpretClauseService.list(queryWrapper); - for (ProcessStandardInterpretClause processStandardInterpretClause : - processStandardInterpretClauseList) { LambdaQueryWrapper queryWrapper1 = new LambdaQueryWrapper<>(); - queryWrapper1.eq(ProcessStandardInterpretClauseSublist::getStandardInterpretClauseId, - processStandardInterpretClause.getId()); if (StringUtils.isNotBlank(distributeIdSubList)){ queryWrapper1.in(ProcessStandardInterpretClauseSublist::getId, Arrays.asList(distributeIdSubList.split(","))); } List list = processStandardInterpretClauseSublistService.list(queryWrapper1); - for (ProcessStandardInterpretClauseSublist processStandardInterpretClauseSublist : list) { - // 解读人 - String interpretPersonId = processStandardInterpretClauseSublist.getInterpretPersonId(); - variables.put(StandardInterpretCommon.INTERPRETING_PEOPLE, interpretPersonId); - StandardInterpretFlowDTO standardInterpretFlowDTO = new StandardInterpretFlowDTO(); - // 流程信息 - ProcessAll processAll = new ProcessAll(); - processAll.setProjectId(processAlls.getProjectId()); - standardInterpretFlowDTO.setProcessAll(processAll); - ProcessApprovalRecord processApprovalRecord = new ProcessApprovalRecord(); - processApprovalRecord.setParentTaskId(taskId); - processApprovalRecord.setUserId(interpretPersonId); - processApprovalRecord.setFinishFlag(FinishFlagEnum.INCOMPLETE.getValue()); - standardInterpretFlowDTO.setProcessApprovalRecord(processApprovalRecord); - standardInterpretFlowDTO.setMap(variables); - // 添加唯一标识,用于数据权限 - String snowFlake = String.valueOf(SnowflakeUtils.snowflake()); - variables.put(StandardInterpretCommon.SNOWFLAKE, snowFlake); - // 发起子流程 - childrenFlowStart(standardInterpretFlowDTO); - processStandardInterpretClauseService.update( - new LambdaUpdateWrapper() - .eq(ProcessStandardInterpretClause::getId, - processStandardInterpretClause.getId()) - .set(ProcessStandardInterpretClause::getIsDistribute, - YesOrNoEnum.YES.getValue())); + // 根据解读人分组 + Map> mapList = list.stream() + .collect(Collectors.groupingBy(ProcessStandardInterpretClauseSublist::getInterpretPersonId)); + mapList.forEach((k, v) -> { - processStandardInterpretClauseSublistService.update( - new LambdaUpdateWrapper() - .eq(ProcessStandardInterpretClauseSublist::getId, - processStandardInterpretClauseSublist.getId()) - .set(ProcessStandardInterpretClauseSublist::getSnowFlake, snowFlake)); - } - } + // 解读人 + String interpretPersonId = k; + variables.put(StandardInterpretCommon.INTERPRETING_PEOPLE, interpretPersonId); + StandardInterpretFlowDTO standardInterpretFlowDTO = new StandardInterpretFlowDTO(); + // 流程信息 + ProcessAll processAll = new ProcessAll(); + processAll.setProjectId(processAlls.getProjectId()); + standardInterpretFlowDTO.setProcessAll(processAll); + ProcessApprovalRecord processApprovalRecord = new ProcessApprovalRecord(); + processApprovalRecord.setParentTaskId(taskId); + processApprovalRecord.setUserId(interpretPersonId); + processApprovalRecord.setFinishFlag(FinishFlagEnum.INCOMPLETE.getValue()); + standardInterpretFlowDTO.setProcessApprovalRecord(processApprovalRecord); + standardInterpretFlowDTO.setMap(variables); + // 添加唯一标识,用于数据权限 + String snowFlake = String.valueOf(SnowflakeUtils.snowflake()); + variables.put(StandardInterpretCommon.SNOWFLAKE, snowFlake); + // 发起子流程 + childrenFlowStart(standardInterpretFlowDTO); + + processStandardInterpretClauseService.update( + new LambdaUpdateWrapper() + .in(ProcessStandardInterpretClause::getId, + v.stream().map(ProcessStandardInterpretClauseSublist + ::getStandardInterpretClauseId) + .collect(Collectors.toList())) + .set(ProcessStandardInterpretClause::getIsDistribute, + YesOrNoEnum.YES.getValue())); + + processStandardInterpretClauseSublistService.update( + new LambdaUpdateWrapper() + .in(ProcessStandardInterpretClauseSublist::getId, + v.stream().map(ProcessStandardInterpretClauseSublist::getId) + .collect(Collectors.toList())) + .set(ProcessStandardInterpretClauseSublist::getSnowFlake, snowFlake)); + }); } }else if (StandardInterpretCommon.AUTO_TASK_2.equals(taskDefinitionKey)){ @@ -414,23 +415,27 @@ public class StandardInterpretFlowServiceImpl implements StandardInterpretFlowSe childrenFlowStart2(standardInterpretFlowDTO); // 处理数据 - ProcessStandardInterpretClauseSublist processStandardInterpretClauseSublist = - processStandardInterpretClauseSublistService.getOne( + List processStandardInterpretClauseSublistList = + processStandardInterpretClauseSublistService.list( new LambdaQueryWrapper() .eq(ProcessStandardInterpretClauseSublist::getSnowFlake, snowflake)); // 清除中间表解读人,设置驳回标识 processStandardInterpretClauseService.update( new LambdaUpdateWrapper() - .eq(ProcessStandardInterpretClause::getId, - processStandardInterpretClauseSublist.getStandardInterpretClauseId()) + .in(ProcessStandardInterpretClause::getId, + processStandardInterpretClauseSublistList.stream() + .map(ProcessStandardInterpretClauseSublist::getStandardInterpretClauseId) + .collect(Collectors.toList())) .set(ProcessStandardInterpretClause::getIsReject, YesOrNoEnum.YES.getValue()) .set(ProcessStandardInterpretClause::getInterpretPersonIds, null)); // 删除旧分发数据 processStandardInterpretClauseSublistService.remove( new LambdaQueryWrapper() - .eq(ProcessStandardInterpretClauseSublist::getStandardInterpretClauseId, - processStandardInterpretClauseSublist.getStandardInterpretClauseId()) + .in(ProcessStandardInterpretClauseSublist::getStandardInterpretClauseId, + processStandardInterpretClauseSublistList.stream() + .map(ProcessStandardInterpretClauseSublist::getStandardInterpretClauseId) + .collect(Collectors.toList())) .eq(ProcessStandardInterpretClauseSublist::getSnowFlake, snowflake)); }else if (StandardInterpretCommon.MASTER_INTERPRET_SUMMARY.equals(taskDefinitionKey)){ // 标准主解读汇总 合并条款