| | |
| | | List<ProductStructureDto> productStructureDtos = productStructureMapper.listBybomAndProcess(productProcessRoute.getBomId(), productProcess.getId()); |
| | | |
| | | List<Long> lastProcessIds = new ArrayList<>(); |
| | | List<Long> firstProcessIds = new ArrayList<>(); |
| | | |
| | | if (!allProcess.isEmpty()) { |
| | | String lastProcessName = allProcess.get(allProcess.size() - 1).getProcessName(); |
| | | String firstProcessName = allProcess.get(0).getProcessName(); |
| | | |
| | | for (int i = allProcess.size() - 1; i >= 0; i--) { |
| | | ProductStructureDto d = allProcess.get(i); |
| | | |
| | | if (lastProcessName.equals(d.getProcessName())) { |
| | | lastProcessIds.add(d.getId()); |
| | | } else { |
| | | break; |
| | | } |
| | | } |
| | | for (ProductStructureDto d : allProcess) { |
| | | if (firstProcessName.equals(d.getProcessName())) { |
| | | firstProcessIds.add(d.getId()); |
| | | } else { |
| | | break; |
| | | } |
| | |
| | | ProductModel productModel1 = productModelMapper.selectById(productStructureDto.getProductModelId()); |
| | | Product product = productMapper.selectById(productModel1.getProductId()); |
| | | |
| | | // 判断是否为最后一道工序 |
| | | // 判断是否为最后一道工序 或者为第一道工序 |
| | | BigDecimal needQuantity = dto.getQuantity().divide(productStructureDto.getUnitQuantity(), 2, BigDecimal.ROUND_HALF_UP); |
| | | if (lastProcessIds.contains(productStructureDto.getId())) { |
| | | if (lastProcessIds.contains(productStructureDto.getId()) || firstProcessIds.contains(productStructureDto.getId())) { |
| | | needQuantity = dto.getQuantity().multiply(productStructureDto.getUnitQuantity()); |
| | | } |
| | | |