diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesAssemblyExtService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesAssemblyExtService.java index 3eba8ce..bbdfb4b 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesAssemblyExtService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesAssemblyExtService.java @@ -160,12 +160,15 @@ public class MesAssemblyExtService implements IMesAssemblyExtService { //【排序线】获取生产工单装配件清单 List workOrderAssemblyList = getWorkOrderAssemblyList(prodRuleContext, true); - if (CollectionUtils.isEmpty(workOrderAssemblyList)) return workOrderAssemblyList; + if (CollectionUtils.isEmpty(workOrderAssemblyList) || (!isFilterParallel && !isFilterAfterCraft)) return workOrderAssemblyList; + + //获取当前工位的第一个装配件的工艺顺序号 + Integer processSeq = isFilterAfterCraft ? getProcessSeq(workOrderAssemblyList, prodRuleContext.getWorkCellCode()) : null; //平行工位 if (isFilterParallel) { //返回涉及到的平行工位代码集合 - List parallelCellCodeList = checkIsExistParallelCellCode(workOrderAssemblyList, prodRuleContext.getWorkCellCode()); + List parallelCellCodeList = checkIsExistParallelCellCode(workOrderAssemblyList, prodRuleContext.getWorkCellCode(), processSeq); if (!CollectionUtils.isEmpty(parallelCellCodeList)) { prodRuleContext.setParallelInfo(String.format("{%s:%s}", MesPcnExtConstWords.WORK_CELL_CODE, JSONObject.toJSONString(parallelCellCodeList))); //剔除平行工位的装配件 @@ -177,13 +180,9 @@ public class MesAssemblyExtService implements IMesAssemblyExtService { if (CollectionUtils.isEmpty(workOrderAssemblyList)) return workOrderAssemblyList; //根据工序顺序号过滤后道 - if (isFilterAfterCraft) { - //获取当前工位的第一个装配件的工艺顺序号 - Integer processSeq = getProcessSeq(workOrderAssemblyList, prodRuleContext.getWorkCellCode()); - if (!StringUtils.isEmpty(processSeq)) { - workOrderAssemblyList = workOrderAssemblyList.stream().filter(o -> (null != o && - (StringUtils.isEmpty(o.getProcessSeq()) || o.getProcessSeq().compareTo(processSeq) <= 0))).collect(Collectors.toList()); - } + if (isFilterAfterCraft && !StringUtils.isEmpty(processSeq)) { + workOrderAssemblyList = workOrderAssemblyList.stream().filter(o -> (null != o && + (StringUtils.isEmpty(o.getProcessSeq()) || o.getProcessSeq().compareTo(processSeq) <= 0))).collect(Collectors.toList()); } return workOrderAssemblyList; @@ -196,7 +195,7 @@ public class MesAssemblyExtService implements IMesAssemblyExtService { } //返回涉及到的平行工位代码集合 - private List checkIsExistParallelCellCode(List workOrderAssemblyList, String workCellCode) { + private List checkIsExistParallelCellCode(List workOrderAssemblyList, String workCellCode, Integer processSeq) { //根据工艺顺序号分组 Map> processSeqMap = CollectionUtils.isEmpty(workOrderAssemblyList) ? null : workOrderAssemblyList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getWorkCellCode()) && @@ -210,13 +209,24 @@ public class MesAssemblyExtService implements IMesAssemblyExtService { List workCellCodeList = (entry.getValue().stream().filter(o -> null != o).map(MesWorkOrderAssembly::getWorkCellCode) .collect(Collectors.toList())).stream().filter(o -> !StringUtils.isEmpty(o)).distinct().collect(Collectors.toList()); if (CollectionUtils.isEmpty(workCellCodeList) || workCellCodeList.size() == 1) continue; - //判断是否是当前工位 - if (workCellCodeList.contains(workCellCode)) { - workCellCodeList.remove(workCellCode); - } else { + //判断是否是当前工位的平行工位 + if (!workCellCodeList.contains(workCellCode)) { + //存在processSeq则表示需要过滤后道, 判断当前循环的工艺顺序号是否属于后道 + if (!StringUtils.isEmpty(processSeq)) { + List processSeqList = (entry.getValue().stream().filter(o -> null != o).map(MesWorkOrderAssembly::getProcessSeq) + .collect(Collectors.toList())).stream().filter(o -> !StringUtils.isEmpty(o)).distinct().collect(Collectors.toList()); + //工艺顺序号升序 + processSeqList.sort(Comparator.naturalOrder()); + if (processSeqList.get(0).compareTo(processSeq) > 0) continue; + } + //工艺顺序号升序 workCellCodeList.sort(Comparator.naturalOrder()); workCellCodeList.remove(0); + } else { + //当前工位 + workCellCodeList.remove(workCellCode); } + if (CollectionUtils.isEmpty(parallelCellCodeList)) parallelCellCodeList = new ArrayList<>(); parallelCellCodeList.addAll(workCellCodeList); }