| | |
| | | import com.ruoyi.basic.utils.FileUtil; |
| | | import com.ruoyi.common.constant.StorageAttachmentConstants; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.production.bean.dto.ProductionOperationTaskDto; |
| | | import com.ruoyi.production.bean.dto.ProductionOrderDto; |
| | | import com.ruoyi.production.bean.vo.ProductionBomStructureVo; |
| | | import com.ruoyi.production.bean.vo.ProductionOperationTaskVo; |
| | | import com.ruoyi.production.bean.vo.ProductionOrderPickVo; |
| | | import com.ruoyi.production.bean.vo.ProductionOrderVo; |
| | | import com.ruoyi.production.bean.vo.ProductionPlanVo; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public ProductionOrderWorkOrderDetailVo getWorkOrderReportInspectDetail(Long productionOrderId) { |
| | | if (productionOrderId == null) { |
| | | throw new ServiceException("productionOrderId can not be null"); |
| | | } |
| | | public ProductionOrderWorkOrderDetailVo getWorkOrderReportInspectDetail(ProductionOrderDto dto) { |
| | | Long productionOrderId = resolveProductionOrderId(dto); |
| | | ProductionOrderVo orderInfo = getProductionOrderInfo(productionOrderId); |
| | | if (orderInfo == null) { |
| | | throw new ServiceException("production order not found"); |
| | | throw new ServiceException("生产订单不存在"); |
| | | } |
| | | |
| | | ProductionOrderWorkOrderDetailVo detailVo = new ProductionOrderWorkOrderDetailVo(); |
| | | detailVo.setProductionOrder(orderInfo); |
| | | |
| | | List<ProductionOperationTask> workOrderList = productionOperationTaskMapper.selectList( |
| | | Wrappers.<ProductionOperationTask>lambdaQuery() |
| | | .eq(ProductionOperationTask::getProductionOrderId, productionOrderId) |
| | | .orderByAsc(ProductionOperationTask::getId)); |
| | | ProductionOperationTaskDto taskQuery = new ProductionOperationTaskDto(); |
| | | taskQuery.setProductionOrderId(productionOrderId); |
| | | IPage<ProductionOperationTaskVo> workOrderPage = productionOperationTaskMapper.pageProductionOperationTask( |
| | | 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()); |
| | | if (workOrderList == null || workOrderList.isEmpty()) { |
| | | detailVo.setWorkOrderList(Collections.emptyList()); |
| | | return detailVo; |
| | | } |
| | | |
| | | List<Long> workOrderIdList = workOrderList.stream() |
| | | .map(ProductionOperationTask::getId) |
| | | .map(ProductionOperationTaskVo::getId) |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toList()); |
| | | List<ProductionProductMain> reportMainList = workOrderIdList.isEmpty() |
| | |
| | | Wrappers.<ProductionProductMain>lambdaQuery() |
| | | .in(ProductionProductMain::getProductionOperationTaskId, workOrderIdList) |
| | | .orderByAsc(ProductionProductMain::getId)); |
| | | Map<Long, List<ProductionProductMain>> reportMainMap = new LinkedHashMap<>(); |
| | | Map<Long, List<ProductionProductMain>> reportMainByWorkOrderMap = new LinkedHashMap<>(); |
| | | for (ProductionProductMain reportMain : reportMainList) { |
| | | if (reportMain == null || reportMain.getProductionOperationTaskId() == null) { |
| | | continue; |
| | | } |
| | | reportMainMap.computeIfAbsent(reportMain.getProductionOperationTaskId(), k -> new ArrayList<>()).add(reportMain); |
| | | reportMainByWorkOrderMap.computeIfAbsent(reportMain.getProductionOperationTaskId(), key -> new ArrayList<>()).add(reportMain); |
| | | } |
| | | |
| | | List<Long> reportMainIdList = reportMainList.stream() |
| | |
| | | if (inspect == null || inspect.getProductMainId() == null) { |
| | | continue; |
| | | } |
| | | inspectMap.computeIfAbsent(inspect.getProductMainId(), k -> new ArrayList<>()).add(inspect); |
| | | inspectMap.computeIfAbsent(inspect.getProductMainId(), key -> new ArrayList<>()).add(inspect); |
| | | } |
| | | |
| | | List<Long> inspectIdList = inspectList.stream() |
| | |
| | | } |
| | | |
| | | List<ProductionOrderWorkOrderDetailVo.WorkOrderDetail> workOrderDetailList = new ArrayList<>(); |
| | | for (ProductionOperationTask workOrder : workOrderList) { |
| | | for (ProductionOperationTaskVo workOrder : workOrderList) { |
| | | ProductionOrderWorkOrderDetailVo.WorkOrderDetail workOrderDetail = new ProductionOrderWorkOrderDetailVo.WorkOrderDetail(); |
| | | workOrderDetail.setWorkOrder(workOrder); |
| | | |
| | | List<ProductionProductMain> workOrderReportMainList = reportMainMap.get(workOrder.getId()); |
| | | if (workOrderReportMainList == null || workOrderReportMainList.isEmpty()) { |
| | | List<ProductionProductMain> workOrderReportMainList = reportMainByWorkOrderMap.getOrDefault(workOrder.getId(), Collections.emptyList()); |
| | | if (workOrderReportMainList.isEmpty()) { |
| | | workOrderDetail.setReportList(Collections.emptyList()); |
| | | workOrderDetail.setInspectList(Collections.emptyList()); |
| | | workOrderDetailList.add(workOrderDetail); |
| | | continue; |
| | | } |
| | | |
| | | List<ProductionOrderWorkOrderDetailVo.ReportDetail> reportDetailList = new ArrayList<>(); |
| | | List<ProductionOrderWorkOrderDetailVo.InspectDetail> inspectDetailList = new ArrayList<>(); |
| | | for (ProductionProductMain reportMain : workOrderReportMainList) { |
| | | Long reportMainId = reportMain.getId(); |
| | | |
| | | ProductionOrderWorkOrderDetailVo.ReportDetail reportDetail = new ProductionOrderWorkOrderDetailVo.ReportDetail(); |
| | | reportDetail.setReportMain(reportMain); |
| | | reportDetail.setReportOutputList(reportOutputMap.getOrDefault(reportMainId, Collections.emptyList())); |
| | | reportDetail.setReportParamList(reportParamMap.getOrDefault(reportMainId, Collections.emptyList())); |
| | | |
| | | List<QualityInspect> reportInspectList = inspectMap.get(reportMainId); |
| | | if (reportInspectList == null || reportInspectList.isEmpty()) { |
| | | reportDetail.setInspectList(Collections.emptyList()); |
| | | } else { |
| | | List<ProductionOrderWorkOrderDetailVo.InspectDetail> inspectDetailList = new ArrayList<>(); |
| | | for (QualityInspect inspect : reportInspectList) { |
| | | ProductionOrderWorkOrderDetailVo.InspectDetail inspectDetail = new ProductionOrderWorkOrderDetailVo.InspectDetail(); |
| | | inspectDetail.setInspect(inspect); |
| | | inspectDetail.setInspectParamList(inspectParamMap.getOrDefault(inspect.getId(), Collections.emptyList())); |
| | | inspectDetail.setInspectFileList(inspectFileMap.getOrDefault(inspect.getId(), Collections.emptyList())); |
| | | inspectDetailList.add(inspectDetail); |
| | | } |
| | | reportDetail.setInspectList(inspectDetailList); |
| | | } |
| | | reportDetailList.add(reportDetail); |
| | | |
| | | List<QualityInspect> reportInspectList = inspectMap.getOrDefault(reportMainId, Collections.emptyList()); |
| | | for (QualityInspect inspect : reportInspectList) { |
| | | ProductionOrderWorkOrderDetailVo.InspectDetail inspectDetail = new ProductionOrderWorkOrderDetailVo.InspectDetail(); |
| | | inspectDetail.setReportId(reportMainId); |
| | | inspectDetail.setReportNo(reportMain.getProductNo()); |
| | | inspectDetail.setReportMain(reportMain); |
| | | inspectDetail.setInspect(inspect); |
| | | inspectDetail.setInspectParamList(inspectParamMap.getOrDefault(inspect.getId(), Collections.emptyList())); |
| | | inspectDetail.setInspectFileList(inspectFileMap.getOrDefault(inspect.getId(), Collections.emptyList())); |
| | | inspectDetailList.add(inspectDetail); |
| | | } |
| | | } |
| | | |
| | | workOrderDetail.setReportList(reportDetailList); |
| | | workOrderDetail.setInspectList(inspectDetailList); |
| | | workOrderDetailList.add(workOrderDetail); |
| | | } |
| | | |
| | | detailVo.setWorkOrderList(workOrderDetailList); |
| | | return detailVo; |
| | | } |
| | | |
| | | private Long resolveProductionOrderId(ProductionOrderDto dto) { |
| | | if (dto == null) { |
| | | throw new ServiceException("请传入生产订单ID或生产订单号"); |
| | | } |
| | | if (dto.getId() != null) { |
| | | return dto.getId(); |
| | | } |
| | | if (dto.getNpsNo() == null || dto.getNpsNo().trim().isEmpty()) { |
| | | throw new ServiceException("请传入生产订单ID或生产订单号"); |
| | | } |
| | | ProductionOrder productionOrder = baseMapper.selectOne( |
| | | Wrappers.<ProductionOrder>lambdaQuery() |
| | | .eq(ProductionOrder::getNpsNo, dto.getNpsNo().trim()) |
| | | .last("limit 1")); |
| | | if (productionOrder == null || productionOrder.getId() == null) { |
| | | throw new ServiceException("生产订单不存在"); |
| | | } |
| | | return productionOrder.getId(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | return new ArrayList<>(mergedPickMap.values()); |
| | | } |
| | | |
| | | @Override |
| | | public int updateOrder(ProductionOrderDto productionOrderDto) { |
| | | productionOrderDto.setStatus(5); |
| | | return baseMapper.updateById(productionOrderDto); |
| | | } |
| | | } |