| | |
| | | import com.ruoyi.basic.mapper.ProductMapper; |
| | | import com.ruoyi.basic.mapper.ProductModelMapper; |
| | | import com.ruoyi.basic.pojo.Customer; |
| | | import com.ruoyi.basic.pojo.ProductModel; |
| | | import com.ruoyi.basic.service.IProductService; |
| | | import com.ruoyi.basic.utils.FileUtil; |
| | | import com.ruoyi.common.enums.FileNameType; |
| | | import com.ruoyi.common.enums.SaleEnum; |
| | |
| | | private final FileUtil fileUtil; |
| | | private final AccountInvoiceApplicationMapper accountInvoiceApplicationMapper; |
| | | private final AccountSalesCollectionMapper accountSalesCollectionMapper; |
| | | private final IProductService productService; |
| | | |
| | | @Autowired |
| | | private SysDeptMapper sysDeptMapper; |
| | |
| | | |
| | | @Override |
| | | public void handleSalesLedgerProducts(Long salesLedgerId, List<SalesLedgerProduct> products, SaleEnum type) { |
| | | // 销售台账手工录入「品名+材质+规格型号」时,自动注册到产品维护 |
| | | if (SaleEnum.SALE.equals(type)) { |
| | | for (SalesLedgerProduct product : products) { |
| | | registerProductFromLedgerProduct(product); |
| | | } |
| | | } |
| | | |
| | | // 按ID分组,区分新增和更新的记录 |
| | | Map<Boolean, List<SalesLedgerProduct>> partitionedProducts = products.stream() |
| | | .peek(p -> p.setSalesLedgerId(salesLedgerId)) |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 手工录入「品名+材质+规格型号」时,在产品维护自动注册: |
| | | * 品名=一级大类,材质=大类下的子类,规格型号=子类下的规格 |
| | | */ |
| | | 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()); |
| | | } |
| | | } |
| | | |
| | | private SalesLedger convertToEntity(SalesLedgerDto dto) { |
| | | SalesLedger entity = new SalesLedger(); |
| | | BeanUtils.copyProperties(dto, entity); |