| | |
| | | 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; |
| | | } |
| | | |
| | |
| | | || !Objects.equals(oldOrder.getProductModelId(), productionOrder.getProductModelId()) |
| | | || compareDecimal(oldOrder.getQuantity(), productionOrder.getQuantity()) != 0 |
| | | || productionOrderRoutingMapper.selectCount(Wrappers.<ProductionOrderRouting>lambdaQuery() |
| | | .eq(ProductionOrderRouting::getProductionOrderId, productionOrder.getId())) == 0); |
| | | .eq(ProductionOrderRouting::getProductionOrderId, productionOrder.getId())) == 0); |
| | | if (needSync) { |
| | | syncProductionOrderSnapshot(productionOrder.getId()); |
| | | } |
| | |
| | | Map<String, BigDecimal> operationDemandedQuantityMap = |
| | | buildOperationDemandedQuantityMap(orderBomStructureList, rootProductModelId); |
| | | Map<Long, String> operationNameMap = technologyOperationMapper.selectBatchIds( |
| | | // 遍历处理数据并组装结果 |
| | | // 遍历处理数据并组装结果 |
| | | routingOperations.stream() |
| | | .map(TechnologyRoutingOperation::getTechnologyOperationId) |
| | | .filter(Objects::nonNull) |
| | |
| | | private void clearProductionSnapshot(Long productionOrderId) { |
| | | // 清理订单已生成的工艺与BOM快照数据 |
| | | boolean hasPickRecord = productionOrderPickRecordMapper.selectCount( |
| | | // 查询并准备业务数据 |
| | | // 查询并准备业务数据 |
| | | Wrappers.<ProductionOrderPickRecord>lambdaQuery() |
| | | .eq(ProductionOrderPickRecord::getProductionOrderId, productionOrderId)) > 0; |
| | | // 参数与前置条件校验 |
| | |
| | | List<Long> taskIds = productionOperationTaskMapper.selectList( |
| | | Wrappers.<ProductionOperationTask>lambdaQuery() |
| | | .eq(ProductionOperationTask::getProductionOrderId, productionOrderId)) |
| | | // 遍历处理数据并组装结果 |
| | | // 遍历处理数据并组装结果 |
| | | .stream().map(ProductionOperationTask::getId).collect(Collectors.toList()); |
| | | if (!taskIds.isEmpty()) { |
| | | // 已有报工记录说明订单已开工,此时不允许再重建快照。 |
| | |
| | | } |
| | | } |
| | | |
| | | 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); |
| | |
| | | new Page<ProductionOperationTaskVo>(1, -1), taskQuery); |
| | | List<ProductionOperationTaskVo> workOrderList = workOrderPage == null || workOrderPage.getRecords() == null |
| | | ? Collections.emptyList() |
| | | // 遍历处理数据并组装结果 |
| | | // 遍历处理数据并组装结果 |
| | | : workOrderPage.getRecords().stream() |
| | | .filter(Objects::nonNull) |
| | | .sorted(Comparator.comparing(ProductionOperationTaskVo::getId, Comparator.nullsLast(Comparator.naturalOrder()))) |
| | |
| | | .collect(Collectors.toList()); |
| | | List<ProductionProductMain> reportMainList = workOrderIdList.isEmpty() |
| | | ? Collections.emptyList() |
| | | // 查询并准备业务数据 |
| | | // 查询并准备业务数据 |
| | | : productionProductMainMapper.selectList( |
| | | Wrappers.<ProductionProductMain>lambdaQuery() |
| | | .in(ProductionProductMain::getProductionOperationTaskId, workOrderIdList) |
| | |
| | | if (!productModelIds.isEmpty()) { |
| | | List<StockInventory> stockList = stockInventoryMapper.selectList( |
| | | Wrappers.<StockInventory>lambdaQuery() |
| | | .in(StockInventory::getProductModelId, productModelIds)); |
| | | .in(StockInventory::getProductModelId, productModelIds) |
| | | .gt(StockInventory::getQualitity, BigDecimal.ZERO)); |
| | | for (StockInventory stockItem : stockList) { |
| | | if (stockItem == null || stockItem.getProductModelId() == null) { |
| | | continue; |