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);
            }