| | |
| | | |
| | | @Override |
| | | public void handleSalesLedgerProducts(Long salesLedgerId, List<SalesLedgerProduct> products, SaleEnum type) { |
| | | // 销售台账手工录入「品名+材质+规格型号」时,自动注册到产品维护 |
| | | // 销售台账手工录入「产品大类+规格型号」时,自动注册到产品维护(统一挂「成品」大类下) |
| | | if (SaleEnum.SALE.equals(type)) { |
| | | for (SalesLedgerProduct product : products) { |
| | | registerProductFromLedgerProduct(product); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 手工录入「品名+材质+规格型号」时,在产品维护自动注册: |
| | | * 品名=一级大类,材质=大类下的子类,规格型号=子类下的规格 |
| | | * 手工录入「产品大类+规格型号」时,在产品维护自动注册: |
| | | * 统一挂在「成品」大类下 —— 成品=一级大类,产品大类=子类,规格型号=子类下的规格 |
| | | */ |
| | | 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)) { |
| | | if (StringUtils.isEmpty(productName) || StringUtils.isEmpty(modelName)) { |
| | | return; |
| | | } |
| | | product.setProductCategory(productName); |
| | | product.setMaterial(material); |
| | | product.setSpecificationModel(modelName); |
| | | |
| | | ProductModel productModel = productService.ensureProductHierarchy(productName, material, modelName, product.getUnit()); |
| | | ProductModel productModel = productService.ensureProductHierarchy(productName, modelName, product.getUnit()); |
| | | if (productModel != null) { |
| | | product.setProductId(productModel.getProductId()); |
| | | product.setProductModelId(productModel.getId()); |