| | |
| | | import com.ruoyi.basic.pojo.Product; |
| | | import com.ruoyi.basic.pojo.ProductModel; |
| | | import com.ruoyi.basic.pojo.SupplierManage; |
| | | import com.ruoyi.basic.service.IProductService; |
| | | import com.ruoyi.basic.utils.FileUtil; |
| | | import com.ruoyi.common.enums.ApprovalStatusEnum; |
| | | import com.ruoyi.common.enums.ReviewStatusEnum; |
| | |
| | | private final SupplierManageMapper supplierManageMapper; |
| | | private final ProductMapper productMapper; |
| | | private final ProductModelMapper productModelMapper; |
| | | private final IProductService productService; |
| | | private final SysUserMapper sysUserMapper; |
| | | private final StringRedisTemplate redisTemplate; |
| | | private final QualityInspectMapper qualityInspectMapper; |
| | |
| | | } |
| | | Integer ledgerType = type == null ? 2 : type; |
| | | |
| | | // 手工录入「品名+材质+规格型号」时,自动注册到产品维护 |
| | | for (SalesLedgerProduct product : products) { |
| | | registerProductFromLedgerProduct(product); |
| | | } |
| | | |
| | | // 提前收集所有需要查询的ID |
| | | Set<Long> productIds = products.stream() |
| | | .map(SalesLedgerProduct::getProductId) |
| | |
| | | // 设置字段 |
| | | for (SalesLedgerProduct product : products) { |
| | | product.setSalesLedgerId(salesLedgerId); |
| | | |
| | | // 手工录入品名/材质/规格型号的行已在注册时写入,不再用产品树节点名称覆盖 |
| | | if (StringUtils.isNotEmpty(product.getMaterial())) { |
| | | continue; |
| | | } |
| | | |
| | | Long productId = product.getProductId(); |
| | | if (productId != null && productMap.containsKey(productId)) { |
| | |
| | | if (salesLedgerId != null) { |
| | | // 直接更新指定ID的记录的contractAmount字段为totalTaxInclusiveAmount |
| | | purchaseLedgerMapper.updateContractAmountById(salesLedgerId, totalTaxInclusiveAmount); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 手工录入「品名+材质+规格型号」时,在产品维护自动注册: |
| | | * 品名=一级大类,材质=大类下的子类,规格型号=子类下的规格 |
| | | */ |
| | | private void registerProductFromLedgerProduct(SalesLedgerProduct product) { |
| | | String productName = StringUtils.trim(product.getProductCategory()); |
| | | String material = StringUtils.trim(product.getMaterial()); |
| | | String modelName = StringUtils.trim(product.getSpecificationModel()); |
| | | if (StringUtils.isEmpty(productName) || StringUtils.isEmpty(material) || StringUtils.isEmpty(modelName)) { |
| | | return; |
| | | } |
| | | product.setProductCategory(productName); |
| | | product.setMaterial(material); |
| | | product.setSpecificationModel(modelName); |
| | | |
| | | ProductModel productModel = productService.ensureProductHierarchy(productName, material, modelName, product.getUnit()); |
| | | if (productModel != null) { |
| | | product.setProductId(productModel.getProductId()); |
| | | product.setProductModelId(productModel.getId()); |
| | | } |
| | | } |
| | | |