工序调整, 报工反改订单数量,判断是最后一道工序才修改订单完成数量
已修改2个文件
65 ■■■■ 文件已修改
src/main/java/com/ruoyi/production/service/impl/ProductProcessServiceImpl.java 38 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/service/impl/ProductProcessServiceImpl.java
@@ -84,18 +84,18 @@
            throw new ServiceException("新增失败,计划工时不能为空");
        }
        // 判断产品是否存在
        if (ObjectUtils.isEmpty(productProcessDto.getProductModelId())) {
            throw new ServiceException("新增失败,部件不能为空");
        }
        ProductModel productModel = productModelService.getById(productProcessDto.getProductModelId());
        if (productModel == null) {
            throw new ServiceException("新增失败,该部件不存在");
        }
        validateDuplicateTypeForSameProduct(productModel.getId(), productProcessDto.getType(), null);
//        if (ObjectUtils.isEmpty(productProcessDto.getProductModelId())) {
//            throw new ServiceException("新增失败,部件不能为空");
//        }
//        ProductModel productModel = productModelService.getById(productProcessDto.getProductModelId());
//        if (productModel == null) {
//            throw new ServiceException("新增失败,该部件不存在");
//        }
//        validateDuplicateTypeForSameProduct(productModel.getId(), productProcessDto.getType(), null);
        ProductProcess productProcess = new ProductProcess();
        BeanUtils.copyProperties(productProcessDto, productProcess);
        productProcess.setProductModelId(productModel.getId());
//        productProcess.setProductModelId(productModel.getId());
        validatePlanner(productProcessDto.getPlannerId(), productProcessDto.getPlannerName(), null);
@@ -129,17 +129,17 @@
        if (oldProductProcess == null) {
            throw new ServiceException("修改失败,工序不存在");
        }
        Long finalProductModelId = ObjectUtils.isNotEmpty(productProcessDto.getProductModelId())
                ? productProcessDto.getProductModelId() : oldProductProcess.getProductModelId();
        Integer finalType = ObjectUtils.isNotEmpty(productProcessDto.getType())
                ? productProcessDto.getType() : oldProductProcess.getType();
//        Long finalProductModelId = ObjectUtils.isNotEmpty(productProcessDto.getProductModelId())
//                ? productProcessDto.getProductModelId() : oldProductProcess.getProductModelId();
//        Integer finalType = ObjectUtils.isNotEmpty(productProcessDto.getType())
//                ? productProcessDto.getType() : oldProductProcess.getType();
//
        // 判断关联产品是否存在
        ProductModel productModel = productModelService.getById(finalProductModelId);
        if (productModel == null) {
            throw new ServiceException("修改失败,关联部件不存在");
        }
        validateDuplicateTypeForSameProduct(productModel.getId(), finalType, productProcessDto.getId());
//        ProductModel productModel = productModelService.getById(finalProductModelId);
//        if (productModel == null) {
//            throw new ServiceException("修改失败,关联部件不存在");
//        }
//        validateDuplicateTypeForSameProduct(productModel.getId(), finalType, productProcessDto.getId());
        // 校验计划人员
        validatePlanner(productProcessDto.getPlannerId(), productProcessDto.getPlannerName(), null);
src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java
@@ -19,11 +19,7 @@
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.procurementrecord.utils.StockUtils;
import com.ruoyi.production.dto.ProductionProductMainDetailExportDto;
import com.ruoyi.production.dto.ProductionProductMainDto;
import com.ruoyi.production.dto.ProductionProductMainSummaryExportDto;
import com.ruoyi.production.dto.ProductionReportDailySummaryDto;
import com.ruoyi.production.dto.ProductionReportStateDto;
import com.ruoyi.production.dto.*;
import com.ruoyi.production.mapper.ProductionProductReportDailyMapper;
import com.ruoyi.production.pojo.ProductionProductReportDaily;
import com.ruoyi.production.mapper.*;
@@ -351,6 +347,7 @@
        LocalDateTime endTime = LocalDateTime.now();
        long durationSeconds = Duration.between(productionProductMain.getReportStartTime(), endTime).getSeconds();
        BigDecimal durationMinutes = secondsToMinutesExact(durationSeconds);
        int finishRows = productionProductMainMapper.update(
                null,
                Wrappers.<ProductionProductMain>lambdaUpdate()
@@ -437,18 +434,26 @@
            }
            // 无工艺路线场景:报工即计入生产订单完成数量
//            int poRows = productOrderMapper.addCompleteQtyIfNotExceed(productOrder.getId(), productQty);
//            if (poRows <= 0) {
//                ProductOrder currentOrder = productOrderMapper.selectById(productOrder.getId());
//                throw new ServiceException("本次生产数量不能大于订单剩余数量,剩余数量: "
//                        + (currentOrder == null ? "0" : currentOrder.getQuantity().subtract(currentOrder.getCompleteQuantity())));
//            }
            List<ProductProcessRouteItemDto> productProcessRouteItemDtos = productProcessRouteItemMapper.listItem(productOrder.getId());
            ProductOrder currentOrder = productOrderMapper.selectById(productOrder.getId());
            if (productProcessRouteItemDtos.get(productProcessRouteItemDtos.size() - 1).getId().equals(dto.getProductProcessRouteItemId())) {
            int poRows = productOrderMapper.addCompleteQtyIfNotExceed(productOrder.getId(), productQty);
            if (poRows <= 0) {
                ProductOrder currentOrder = productOrderMapper.selectById(productOrder.getId());
                throw new ServiceException("本次生产数量不能大于订单剩余数量,剩余数量: "
                        + (currentOrder == null ? "0" : currentOrder.getQuantity().subtract(currentOrder.getCompleteQuantity())));
            }
            ProductOrder latestOrder = productOrderMapper.selectById(productOrder.getId());
            }
            if (needQuality
                    && latestOrder != null
                    && latestOrder.getCompleteQuantity() != null
                    && latestOrder.getQuantity() != null
                    && latestOrder.getCompleteQuantity().compareTo(latestOrder.getQuantity()) >= 0) {
                    && currentOrder != null
                    && currentOrder.getCompleteQuantity() != null
                    && currentOrder.getQuantity() != null
                    && currentOrder.getCompleteQuantity().compareTo(currentOrder.getQuantity()) >= 0) {
                // 订单完成时新增出厂检
                createQualityInspect(productionProductMain.getId(), outputProductModelId, productQty, 2, null);
            }