buhuazhen
2026-05-12 15999f1d20063dec73abeeea435d6e0d5a55c491
src/main/java/com/ruoyi/production/service/impl/ProductionPrintOrderServiceImpl.java
@@ -16,10 +16,10 @@
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.dto.SimplePersonDto;
import com.ruoyi.production.dto.*;
import com.ruoyi.production.mapper.ProductOrderMapper;
import com.ruoyi.production.mapper.ProductionPrintOrderMapper;
import com.ruoyi.production.pojo.ProductOrder;
import com.ruoyi.production.pojo.ProductionPrintOrder;
import com.ruoyi.production.mapper.*;
import com.ruoyi.production.pojo.*;
import com.ruoyi.production.service.ProductBomService;
import com.ruoyi.production.service.ProductProcessRouteService;
import com.ruoyi.production.service.ProductionPrintOrderService;
import lombok.RequiredArgsConstructor;
import org.jetbrains.annotations.Nullable;
@@ -46,13 +46,30 @@
    private final ProductOrderMapper productOrderMapper;
    private final ProcessRouteServiceImpl processRouteService;
    private final ProductionPrintOrderExcel productionPrintOrderExcel;
    private final ProductWorkOrderMapper productWorkOrderMapper;
    private final ProductProcessRouteService productProcessRouteService;
    private final ProductBomService productBomService;
    private final CustomerFollowUpFileService customerFollowUpFileService;
    @Override
    @Transactional
    public void save(SaveProductionPrintOrderDto dto) {
        ProductionPrintOrder productionPrintOrder = BeanUtil.copyProperties(dto, ProductionPrintOrder.class);
        if(dto.getId() != null){
            // 先删除生产工单数据
            LambdaQueryWrapper<ProductWorkOrder> l1 = new LambdaQueryWrapper<>();
            l1.eq(ProductWorkOrder::getProductOrderId,dto.getProductOrderId());
            productWorkOrderMapper.delete(l1);
            LambdaQueryWrapper<ProductProcessRoute> l2 = new LambdaQueryWrapper<>();
            l2.eq(ProductProcessRoute::getProductOrderId,dto.getProductOrderId());
            List<ProductProcessRoute> needDeleteRoute = productProcessRouteService.list(l2);
            List<Long> needDeleteRouteIds = needDeleteRoute.stream().map(ProductProcessRoute::getId).collect(Collectors.toList());
            if(CollUtil.isNotEmpty(needDeleteRouteIds)){
                productProcessRouteService.removeBatchByIds(needDeleteRouteIds);
                List<Integer> needDeleteBom = needDeleteRoute.stream().map(ProductProcessRoute::getBomId).collect(Collectors.toList());
                productProcessRouteService.removeByIds(needDeleteBom);
            }
        }
        List<ProcessContentDto> processContentDtoList = productionPrintOrder.getProcessContent();
        // 给没有id的信息设置uuid
        processContentDtoList.forEach(processContentDto -> {
@@ -85,7 +102,18 @@
        productOrder.setId(dto.getProductOrderId());
        productOrder.setRemark(remark);
        productOrderMapper.updateById(productOrder);
        int i = dto.getId() == null ? productionPrintOrderMapper.insert(productionPrintOrder) : productionPrintOrderMapper.updateById(productionPrintOrder);
        LambdaQueryWrapper<ProductionPrintOrder> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(ProductionPrintOrder::getProductOrderId,dto.getProductModelId());
        queryWrapper.last("limit 1");
        ProductionPrintOrder ifExitPrint = productionPrintOrderMapper.selectOne(queryWrapper);
        if (ifExitPrint == null) {
            productionPrintOrderMapper.insert(productionPrintOrder);
        }else {
            productionPrintOrder.setId(ifExitPrint.getId());
            productionPrintOrderMapper.updateById(productionPrintOrder);
        }
    }
    @Override
@@ -133,9 +161,9 @@
        exportProductionPrintOrderDto.setUnitSuffix(materialInfoDto.getUnitSuffix());
        exportProductionPrintOrderDto.setPriceSuffix(materialInfoDto.getPriceSuffix());
        StringUtils.fillStringNull(exportProductionPrintOrderDto);
        // 日期修正为 yyyy年 MM 月 mm 日
        exportProductionPrintOrderDto.setPrintOrderTimeStr(DateUtil.format(exportProductionPrintOrderDto.getPrintOrderTime(),"yyyy年 MM 月 mm 日"));
        exportProductionPrintOrderDto.setFinishTimeStr(DateUtil.format(exportProductionPrintOrderDto.getFinishTime(),"yyyy年 MM 月 mm 日"));
        // 日期修正为 yyyy年 MM 月 mm 日yyyy-MM-dd
        exportProductionPrintOrderDto.setPrintOrderTimeStr(DateUtil.format(exportProductionPrintOrderDto.getPrintOrderTime(),"yyyy年 MM 月 dd 日"));
        exportProductionPrintOrderDto.setFinishTimeStr(DateUtil.format(exportProductionPrintOrderDto.getFinishTime(),"yyyy年 MM 月 dd 日"));
        // 介绍信 勾选框
        String introductionLetter = exportProductionPrintOrderDto.getIntroductionLetter();