| | |
| | | import com.ruoyi.production.bean.vo.ProductionOrderVo; |
| | | import com.ruoyi.production.bean.vo.ProductionPlanVo; |
| | | import com.ruoyi.production.bean.vo.ProductionOrderWorkOrderDetailVo; |
| | | import com.ruoyi.production.bean.vo.ProcessRouteStatusVo; |
| | | import com.ruoyi.production.bean.vo.ProductionOrderProcessTaskVo; |
| | | import com.ruoyi.production.enums.ProductOrderStatusEnum; |
| | | import com.ruoyi.production.mapper.*; |
| | | import com.ruoyi.production.pojo.*; |
| | |
| | | // 分页查询生产订单 |
| | | Page<ProductionOrderVo> result = (Page<ProductionOrderVo>) baseMapper.pageProductionOrder(page, dto); |
| | | fillProductImages(result.getRecords()); |
| | | fillProcessRouteStatus(result.getRecords()); |
| | | return result; |
| | | } |
| | | |
| | |
| | | // 查询生产订单列表 |
| | | List<ProductionOrderVo> records = baseMapper.listProductionOrder(dto); |
| | | fillProductImages(records); |
| | | fillProcessRouteStatus(records); |
| | | return records; |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | private void fillProcessRouteStatus(List<ProductionOrderVo> records) { |
| | | if (records == null || records.isEmpty()) { |
| | | return; |
| | | } |
| | | List<Long> orderIds = records.stream() |
| | | .map(ProductionOrderVo::getId) |
| | | .filter(Objects::nonNull) |
| | | .distinct() |
| | | .collect(Collectors.toList()); |
| | | if (orderIds.isEmpty()) { |
| | | return; |
| | | } |
| | | |
| | | List<ProductionOrderProcessTaskVo> tasks = productionOperationTaskMapper.listProcessStatusByOrderIds(orderIds); |
| | | Map<Long, List<ProcessRouteStatusVo>> statusMap = new LinkedHashMap<>(); |
| | | if (tasks != null) { |
| | | for (ProductionOrderProcessTaskVo task : tasks) { |
| | | if (task == null || task.getProductionOrderId() == null) { |
| | | continue; |
| | | } |
| | | ProcessRouteStatusVo status = new ProcessRouteStatusVo(); |
| | | status.setName(task.getOperationName() != null && !task.getOperationName().isBlank() |
| | | ? task.getOperationName() |
| | | : "未知工序"); |
| | | BigDecimal percentage = task.getCompletionStatus() == null |
| | | ? BigDecimal.ZERO |
| | | : task.getCompletionStatus(); |
| | | if (percentage.compareTo(new BigDecimal("100")) > 0) { |
| | | percentage = new BigDecimal("100"); |
| | | } |
| | | status.setPercentage(percentage); |
| | | statusMap.computeIfAbsent(task.getProductionOrderId(), key -> new ArrayList<>()).add(status); |
| | | } |
| | | } |
| | | |
| | | for (ProductionOrderVo record : records) { |
| | | record.setProcessRouteStatus(statusMap.getOrDefault(record.getId(), Collections.emptyList())); |
| | | } |
| | | } |
| | | |
| | | private StorageBlobVO toStorageBlobVO(StorageBlob blob) { |
| | | // 将存储文件对象转换为VO |
| | | StorageBlobVO vo = BeanUtil.copyProperties(blob, StorageBlobVO.class); |
| | |
| | | } |
| | | } |
| | | |
| | | // 过滤出非根节点(实际领料项) |
| | | // 收集订单成品规格ID:包含生产订单成品规格与BOM根节点规格,用于排除“自己”这一物料 |
| | | Set<Long> finishedProductModelIds = new HashSet<>(); |
| | | if (productionOrder != null && productionOrder.getProductModelId() != null) { |
| | | finishedProductModelIds.add(productionOrder.getProductModelId()); |
| | | } |
| | | bomStructureList.stream() |
| | | .filter(s -> s != null && (s.getParentId() == null || s.getParentId() == 0)) |
| | | .map(ProductionBomStructureVo::getProductModelId) |
| | | .filter(Objects::nonNull) |
| | | .forEach(finishedProductModelIds::add); |
| | | |
| | | // 收集所有被引用为父级的节点ID:BOM从最后一道工序往里配置前一道工序, |
| | | // 中间节点是上一道工序的产出(自制),只有每条分支最里层的叶子节点才是真正需要领用的物料。 |
| | | Set<Long> parentNodeIds = bomStructureList.stream() |
| | | .filter(s -> s != null && s.getParentId() != null && s.getParentId() != 0) |
| | | .map(ProductionBomStructureVo::getParentId) |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toSet()); |
| | | |
| | | // 过滤出叶子节点(实际领料项):非根节点、非中间节点,并排除与订单成品同规格的物料(自制成品无需领料) |
| | | List<ProductionBomStructureVo> childStructureList = bomStructureList.stream() |
| | | .filter(s -> s != null && s.getParentId() != null && s.getParentId() != 0) |
| | | .filter(s -> s.getId() == null || !parentNodeIds.contains(s.getId())) |
| | | .filter(s -> s.getProductModelId() == null || !finishedProductModelIds.contains(s.getProductModelId())) |
| | | .collect(Collectors.toList()); |
| | | |
| | | // 遍历处理数据并组装结果 |