| | |
| | | import com.ruoyi.basic.pojo.Product; |
| | | import com.ruoyi.basic.pojo.ProductModel; |
| | | import com.ruoyi.basic.service.IProductModelService; |
| | | import com.ruoyi.common.enums.FileNameType; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.OrderUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | |
| | | import com.ruoyi.common.utils.uuid.IdUtils; |
| | | import com.ruoyi.other.mapper.TempFileMapper; |
| | | import com.ruoyi.other.service.impl.TempFileServiceImpl; |
| | | import com.ruoyi.production.mapper.ProductProcessMapper; |
| | | import com.ruoyi.production.pojo.ProductProcess; |
| | | import com.ruoyi.sales.mapper.CommonFileMapper; |
| | | import com.ruoyi.sales.mapper.SalesLedgerProductMapper; |
| | | import com.ruoyi.sales.pojo.SalesLedgerProduct; |
| | |
| | | import java.io.IOException; |
| | | import java.time.LocalDate; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.AbstractMap; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | private final SalesLedgerProductMapper salesLedgerProductMapper; |
| | | private ProductModelMapper productModelMapper; |
| | | private final CommonFileServiceImpl commonFileService; |
| | | private final ProductProcessMapper productProcessMapper; |
| | | |
| | | private final TempFileServiceImpl tempFileService; |
| | | |
| | |
| | | product1.setProductName(productModelDto.getProductName()); |
| | | productMapper.updateById(product1); |
| | | } |
| | | commonFileService.deleteByBusinessIds(Collections.singletonList(productModelDto.getId()), FileNameType.PRODUCT_MODEL.getValue()); |
| | | if(CollectionUtils.isNotEmpty(productModelDto.getTempFileIds())){ |
| | | commonFileService.migrateTempFilesToFormal(productModelDto.getId(), productModelDto.getTempFileIds()); |
| | | } |
| | |
| | | */ |
| | | private void processProductModel(List<ProductModelExcelCopyDto> dtoList, |
| | | Long productId, String model, String drawingNumber) { |
| | | // 查询所有工艺路线 |
| | | List<ProductProcess> productRoutes = productProcessMapper.selectList(new QueryWrapper<ProductProcess>()); |
| | | if(CollectionUtils.isEmpty(productRoutes)){ |
| | | throw new ServiceException("请先创建产品工艺路线"); |
| | | } |
| | | for (ProductModelExcelCopyDto dto : dtoList) { |
| | | // 查询条件:型号+图纸编号(更精准,符合分组逻辑) |
| | | ProductModel productModel = productModelMapper.selectOne(new LambdaQueryWrapper<ProductModel>() |
| | | .eq(ProductModel::getModel, model) |
| | | .last("limit 1")); |
| | | |
| | | // 通过工艺路线名称匹配最新一条工艺路线 |
| | | ProductProcess productRoute = productRoutes.stream() |
| | | .filter(route -> route.getName().equals(dto.getProcessRoute())) |
| | | .max(Comparator.comparing(ProductProcess::getCreateTime)) |
| | | .orElse(null); |
| | | if (productModel == null) { |
| | | productModel = new ProductModel(); |
| | | BeanUtils.copyProperties(dto, productModel); |
| | | if (productRoute != null) { |
| | | productModel.setRouteId(productRoute.getId()); |
| | | } |
| | | // 兜底默认值,避免空值 |
| | | if (productModel.getProductType() == null) { |
| | | productModel.setProductType(1); |
| | |
| | | productModel.setProductId(productId); |
| | | productModelMapper.insert(productModel); |
| | | } else { |
| | | productModel.setRouteId(productRoute != null ? productRoute.getId() : null); |
| | | BeanUtils.copyProperties(dto, productModel); |
| | | productModel.setProductId(productId); |
| | | productModelMapper.updateById(productModel); |