| | |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | |
| | | ProductProcessRouteItem productProcessRouteItem = productProcessRouteItemMapper.selectById(dto.getProductProcessRouteItemId()); |
| | | if (productProcessRouteItem == null) { |
| | | throw new RuntimeException("工艺路线项不存在"); |
| | | } |
| | | //检查上一个工序是否已报工 |
| | | Integer currentDragSort = productProcessRouteItem.getDragSort(); |
| | | if (currentDragSort != null && currentDragSort > 1) { |
| | | ProductProcessRouteItem previousItem = productProcessRouteItemMapper.selectOne( |
| | | Wrappers.<ProductProcessRouteItem>lambdaQuery() |
| | | .eq(ProductProcessRouteItem::getProductRouteId, productProcessRouteItem.getProductRouteId()) |
| | | .eq(ProductProcessRouteItem::getDragSort, currentDragSort - 1) |
| | | ); |
| | | |
| | | if (previousItem != null) { |
| | | //检查上一个工序是否有报工记录 |
| | | Long count = productionProductMainMapper.selectCount( |
| | | Wrappers.<ProductionProductMain>lambdaQuery() |
| | | .eq(ProductionProductMain::getProductProcessRouteItemId, previousItem.getId()) |
| | | ); |
| | | |
| | | if (count == 0) { |
| | | throw new RuntimeException("上一个工序尚未报工,不能进行当前工序报工"); |
| | | } |
| | | } |
| | | } |
| | | //当前具体工序 |
| | | ProductProcess productProcess = productProcessMapper.selectById(productProcessRouteItem.getProcessId()); |
| | |
| | | public ArrayList<Long> listMain(List<Long> idList) { |
| | | return productionProductMainMapper.listMain(idList); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public List<ProductionProductMainDto> getByProductWorkOrderId(Long productWorkOrderId) { |
| | | List<ProductionProductMainDto> productionProductMainDtos = productionProductMainMapper.getByProductWorkOrderId(productWorkOrderId); |
| | | |
| | | if (productionProductMainDtos == null || productionProductMainDtos.isEmpty()) { |
| | | return productionProductMainDtos; |
| | | } |
| | | |
| | | // 收集所有产品主记录ID |
| | | List<Long> productMainIds = productionProductMainDtos.stream() |
| | | .map(ProductionProductMainDto::getId) |
| | | .collect(Collectors.toList()); |
| | | |
| | | // 批量查询所有相关的质检记录 |
| | | List<QualityInspect> qualityInspects = qualityInspectMapper.selectList( |
| | | Wrappers.<QualityInspect>lambdaQuery() |
| | | .in(QualityInspect::getProductMainId, productMainIds) |
| | | ); |
| | | |
| | | if (!qualityInspects.isEmpty()) { |
| | | // 收集所有质检记录ID |
| | | List<Long> inspectIds = qualityInspects.stream() |
| | | .map(QualityInspect::getId) |
| | | .collect(Collectors.toList()); |
| | | |
| | | // 批量查询所有相关的不合格处理记录 |
| | | List<QualityUnqualified> qualityUnqualifieds = qualityUnqualifiedMapper.selectList( |
| | | Wrappers.<QualityUnqualified>lambdaQuery() |
| | | .in(QualityUnqualified::getInspectId, inspectIds) |
| | | ); |
| | | |
| | | // 构建质检ID到不合格处理记录的映射 |
| | | Map<Long, QualityUnqualified> inspectIdToUnqualifiedMap = qualityUnqualifieds.stream() |
| | | .collect(Collectors.toMap(QualityUnqualified::getInspectId, q -> q, (q1, q2) -> q1)); |
| | | |
| | | // 构建产品主ID到质检记录的映射 |
| | | Map<Long, QualityInspect> productMainIdToInspectMap = qualityInspects.stream() |
| | | .collect(Collectors.toMap(QualityInspect::getProductMainId, q -> q, (q1, q2) -> q1)); |
| | | |
| | | // 关联处理结果到产品主记录 |
| | | productionProductMainDtos.forEach(p -> { |
| | | QualityInspect qualityInspect = productMainIdToInspectMap.get(p.getId()); |
| | | if (qualityInspect != null) { |
| | | QualityUnqualified qualityUnqualified = inspectIdToUnqualifiedMap.get(qualityInspect.getId()); |
| | | if (qualityUnqualified != null) { |
| | | p.setDealResult(qualityUnqualified.getDealResult() == null ? "" : qualityUnqualified.getDealResult()); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | return productionProductMainDtos; |
| | | } |
| | | } |