| | |
| | | if (CollUtil.isEmpty(productList)) { |
| | | throw exception(PRO_ROUTE_LAST_OUTPUT_INVALID, processList.get(processList.size() - 1).getProcessId()); |
| | | } |
| | | Set<Long> boundItemIds = productList.stream().map(MesProRouteProductDO::getItemId).collect(Collectors.toSet()); |
| | | Set<Long> finishedItemIds = productList.stream() |
| | | .map(MesProRouteProductDO::getItemId) |
| | | .filter(itemId -> isItemUnderCategory(itemId, "FG")) |
| | | .collect(Collectors.toSet()); |
| | | if (finishedItemIds.size() != productList.size()) { |
| | | throw exception(PRO_ROUTE_PRODUCT_ITEM_TYPE_INVALID); |
| | | } |
| | | MesProRouteProcessDO lastProcess = processList.stream() |
| | | .max(Comparator.comparing(MesProRouteProcessDO::getSort)).orElseThrow(); |
| | | for (MesProRouteProcessDO process : processList) { |
| | |
| | | throw exception(PRO_ROUTE_LAST_OUTPUT_INVALID, process.getProcessId()); |
| | | } |
| | | continue; |
| | | } |
| | | for (Long outputId : outputIds) { |
| | | if (!boundItemIds.contains(outputId)) { |
| | | MesMdItemDO item = itemService.validateItemExists(outputId); |
| | | throw exception(PRO_ROUTE_PROCESS_OUTPUT_NOT_BOUND, item.getName()); |
| | | } |
| | | } |
| | | if (last) { |
| | | if (finishedItemIds.isEmpty() || !outputIds.equals(finishedItemIds)) { |
| | |
| | | routeMapper.insert(route); |
| | | respVO.getCreateCodes().add(importItem.getCode()); |
| | | } else if (updateSupport) { |
| | | if (CommonStatusEnum.ENABLE.getStatus().equals(existRoute.getStatus())) { |
| | | respVO.getFailureCodes().put(key, "路线已启用,请先停用后再更新"); |
| | | return; |
| | | } |
| | | // 2.1.2 更新(状态由启用/禁用接口单独维护,导入不修改状态) |
| | | MesProRouteDO updateObj = BeanUtils.toBean(importItem, MesProRouteDO.class); |
| | | updateObj.setId(existRoute.getId()); |