diff --git a/src/main/java/com/wms/service/business/serviceImplements/WorkServiceImplements.java b/src/main/java/com/wms/service/business/serviceImplements/WorkServiceImplements.java index d22c192..21ab088 100644 --- a/src/main/java/com/wms/service/business/serviceImplements/WorkServiceImplements.java +++ b/src/main/java/com/wms/service/business/serviceImplements/WorkServiceImplements.java @@ -522,55 +522,103 @@ public class WorkServiceImplements implements IWorkService { List allFlows = new ArrayList<>(); // 获取当天所有的装载机工作 List thisDayMWLWorks = new ArrayList<>(); - findWorks("", thisDayMWLWorks, "MWL", currentWorkDate); // 获取到当天所有的平地机工作 List thisDayMGWorks = new ArrayList<>(); // 需要合并第二天的平地机工作 List nextDayMGWorks = new ArrayList<>(); - findWorks("", thisDayMGWorks, "NOT_MWL", currentWorkDate); - if (!thisDayMGWorks.isEmpty()) { - // 查询配置是否需要合并第二天的配置 - String ifMergeTomorrow = configMap.get(ConfigMapKeyEnum.IF_MERGE_TOMORROW.getConfigKey()); - if (!StringUtils.isEmpty(ifMergeTomorrow) && ifMergeTomorrow.equals("1")) { - // 获取下一个工作日 - LocalDate nextWorkDate = nextWorkDate(currentWorkDate); - if (nextWorkDate != null && nextWorkDate.isAfter(currentWorkDate)) { - findWorks("", nextDayMGWorks, "NOT_MWL", nextWorkDate); - } - } - } // 获取工作优先级 String workPriority = configMap.get(ConfigMapKeyEnum.WORK_PRIORITY.getConfigKey()); + // 获取目前已经存在的工作流 + List allOldWorkFlows = workFlowService.list(); if (!StringUtils.isEmpty(workPriority) && workPriority.equals("1")) { - // 先平地机再装载机 - if (!thisDayMGWorks.isEmpty()) { - allFlows.addAll(thisDayMGWorks); - if (!nextDayMGWorks.isEmpty()) { - // 添加第二天的平地机工作进汇总 - allFlows.addAll(nextDayMGWorks); + List oldMwlWorkFlows = allOldWorkFlows.stream().filter(workFlow -> workFlow.getMachineType() == 1).toList(); + if (oldMwlWorkFlows.isEmpty()) { + // 先平地机再装载机 + findWorks("", thisDayMGWorks, "NOT_MWL", currentWorkDate); + if (!thisDayMGWorks.isEmpty()) { + allFlows.addAll(thisDayMGWorks); + // 查询配置是否需要合并第二天的配置 + String ifMergeTomorrow = configMap.get(ConfigMapKeyEnum.IF_MERGE_TOMORROW.getConfigKey()); + if (!StringUtils.isEmpty(ifMergeTomorrow) && ifMergeTomorrow.equals("1")) { + // 获取下一个工作日 + LocalDate nextWorkDate = nextWorkDate(currentWorkDate); + if (nextWorkDate != null && nextWorkDate.isAfter(currentWorkDate)) { + findWorks("", nextDayMGWorks, "NOT_MWL", nextWorkDate); + } + if (!nextDayMGWorks.isEmpty()) { + // 添加第二天的平地机工作进汇总 + allFlows.addAll(nextDayMGWorks); + } + } + } else { + List oldMgWorkFlows = allOldWorkFlows.stream().filter(workFlow -> workFlow.getMachineType() == 2).toList(); + if (oldMgWorkFlows.isEmpty()) { + // 装载机 + findWorks("", thisDayMWLWorks, "MWL", currentWorkDate); + if (!thisDayMWLWorks.isEmpty()) { + allFlows.addAll(thisDayMWLWorks); + } + } } } else { - List oldMgWorkFlows = workFlowService.list(new LambdaQueryWrapper() - .eq(WorkFlow::getMachineType, 2)); - if (!thisDayMWLWorks.isEmpty() && oldMgWorkFlows.isEmpty()) { + // 装载机 + findWorks("", thisDayMWLWorks, "MWL", currentWorkDate); + if (!thisDayMWLWorks.isEmpty()) { allFlows.addAll(thisDayMWLWorks); } } + } else { - // 先装载机再平地机 - if (!thisDayMWLWorks.isEmpty()) { - allFlows.addAll(thisDayMWLWorks); + List oldMgWorkFlows = allOldWorkFlows.stream().filter(workFlow -> workFlow.getMachineType() == 2).toList(); + if (oldMgWorkFlows.isEmpty()) { + // 先装载机再平地机 + findWorks("", thisDayMWLWorks, "MWL", currentWorkDate); + if (!thisDayMWLWorks.isEmpty()) { + allFlows.addAll(thisDayMWLWorks); + } else { + List oldMwlWorkFlows = allOldWorkFlows.stream().filter(workFlow -> workFlow.getMachineType() == 1).toList(); + if (oldMwlWorkFlows.isEmpty()) { + // 平地机 + findWorks("", thisDayMGWorks, "NOT_MWL", currentWorkDate); + if (!thisDayMGWorks.isEmpty()) { + allFlows.addAll(thisDayMGWorks); + // 查询配置是否需要合并第二天的配置 + String ifMergeTomorrow = configMap.get(ConfigMapKeyEnum.IF_MERGE_TOMORROW.getConfigKey()); + if (!StringUtils.isEmpty(ifMergeTomorrow) && ifMergeTomorrow.equals("1")) { + // 获取下一个工作日 + LocalDate nextWorkDate = nextWorkDate(currentWorkDate); + if (nextWorkDate != null && nextWorkDate.isAfter(currentWorkDate)) { + findWorks("", nextDayMGWorks, "NOT_MWL", nextWorkDate); + } + if (!nextDayMGWorks.isEmpty()) { + // 添加第二天的平地机工作进汇总 + allFlows.addAll(nextDayMGWorks); + } + } + } + } + } } else { - List oldMwlWorkFlows = workFlowService.list(new LambdaQueryWrapper() - .eq(WorkFlow::getMachineType, 1)); - if (!thisDayMGWorks.isEmpty() && oldMwlWorkFlows.isEmpty()) { + // 平地机 + findWorks("", thisDayMGWorks, "NOT_MWL", currentWorkDate); + if (!thisDayMGWorks.isEmpty()) { allFlows.addAll(thisDayMGWorks); - if (!nextDayMGWorks.isEmpty()) { - // 添加第二天的平地机工作进汇总 - allFlows.addAll(nextDayMGWorks); + // 查询配置是否需要合并第二天的配置 + String ifMergeTomorrow = configMap.get(ConfigMapKeyEnum.IF_MERGE_TOMORROW.getConfigKey()); + if (!StringUtils.isEmpty(ifMergeTomorrow) && ifMergeTomorrow.equals("1")) { + // 获取下一个工作日 + LocalDate nextWorkDate = nextWorkDate(currentWorkDate); + if (nextWorkDate != null && nextWorkDate.isAfter(currentWorkDate)) { + findWorks("", nextDayMGWorks, "NOT_MWL", nextWorkDate); + } + if (!nextDayMGWorks.isEmpty()) { + // 添加第二天的平地机工作进汇总 + allFlows.addAll(nextDayMGWorks); + } } } } + } if (!allFlows.isEmpty()) { // 处理这些工作流