| | |
| | | import cn.hutool.core.io.IoUtil; |
| | | import cn.hutool.core.lang.Assert; |
| | | import cn.hutool.core.util.IdUtil; |
| | | import cn.hutool.core.util.NumberUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | |
| | | 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; |
| | |
| | | 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 -> { |
| | |
| | | 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.getProductOrderId()); |
| | | queryWrapper.last("limit 1"); |
| | | ProductionPrintOrder ifExitPrint = productionPrintOrderMapper.selectOne(queryWrapper); |
| | | if (ifExitPrint == null) { |
| | | productionPrintOrder.setId(null); |
| | | productionPrintOrderMapper.insert(productionPrintOrder); |
| | | }else { |
| | | productionPrintOrder.setId(ifExitPrint.getId()); |
| | | productionPrintOrderMapper.updateById(productionPrintOrder); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void exportPrintExcelByWordId(@Nullable Long orderId) { |
| | | public byte[] exportPrintExcelByWordId(@Nullable Long orderId) { |
| | | ProductionPrintOrderDto printOrderDto = this.getByProductWordId(orderId); |
| | | List<MaterialInfoDto> materialInfo = printOrderDto.getMaterialInfo(); |
| | | Assert.isTrue(CollUtil.isNotEmpty(materialInfo),"未有材料信息,请添加改信息!"); |
| | |
| | | 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(); |
| | |
| | | byte[] bytes = FileUtil.readBytes(exportProductionPrintOrderDto.getCuttingFileVo().getFileUrl()); |
| | | exportProductionPrintOrderDto.setCuttingImage(bytes); |
| | | } |
| | | // cutNum 为小盒数量+中盒数量 |
| | | exportProductionPrintOrderDto.setCutNum(String.valueOf(NumberUtil.add(exportProductionPrintOrderDto.getSmallBoxQty(),exportProductionPrintOrderDto.getMediumBoxQty()))); |
| | | |
| | | productionPrintOrderExcel.createPrintOrderTemplate(exportProductionPrintOrderDto, IoUtil.toStream(new File("/Users/ONEX/Downloads/printOrderTemp.xlsx"))); |
| | | |
| | | |
| | | byte[] printOrderTemplate = productionPrintOrderExcel.createPrintOrderTemplate(exportProductionPrintOrderDto, this.getClass().getResourceAsStream("/static/printOrderTemp.xlsx")); |
| | | return printOrderTemplate; |
| | | } |
| | | |
| | | |