huminmin
11 小时以前 189fe18f9aaabc39cc4bb4cc00f531bc43fe152e
新增台账时增加库存类型
已添加1个文件
已修改4个文件
67 ■■■■■ 文件已修改
doc/20260609_add_stock_type_to_sales_ledger_product.sql 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/sales/dto/SalesLedgerDto.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/sales/pojo/SalesLedgerProduct.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/sales/service/impl/ShippingInfoServiceImpl.java 46 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
doc/20260609_add_stock_type_to_sales_ledger_product.sql
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,6 @@
ALTER TABLE sales_ledger_product
    ADD COLUMN stock_type VARCHAR(20) NOT NULL DEFAULT 'qualified' COMMENT '库存类型:qualified/waste' AFTER product_model_id;
UPDATE sales_ledger_product
SET stock_type = 'qualified'
WHERE stock_type IS NULL OR stock_type = '';
src/main/java/com/ruoyi/sales/dto/SalesLedgerDto.java
@@ -61,6 +61,9 @@
    @Schema(description = "交货日期")
    private LocalDate deliveryDate;
    @Schema(description = "库存类型:qualified/waste")
    private String stockType;
    private List<StorageBlobDTO> storageBlobDTOs;
    private List<StorageBlobVO> StorageBlobVOs;
}
src/main/java/com/ruoyi/sales/pojo/SalesLedgerProduct.java
@@ -125,6 +125,9 @@
     */
    private Long productModelId;
    @Schema(description = "库存类型:qualified/waste")
    private String stockType;
    @Schema(description = "登记人")
    private String register;
src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
@@ -585,6 +585,15 @@
        // 4. å¤„理子表数据
        List<SalesLedgerProduct> productList = salesLedgerDto.getProductData();
        if (productList != null && !productList.isEmpty()) {
            String ledgerStockType = StringUtils.trim(salesLedgerDto.getStockType());
            if (StringUtils.isEmpty(ledgerStockType)) {
                ledgerStockType = "qualified";
            }
            for (SalesLedgerProduct product : productList) {
                if (StringUtils.isEmpty(StringUtils.trim(product.getStockType()))) {
                    product.setStockType(ledgerStockType);
                }
            }
            handleSalesLedgerProducts(salesLedger.getId(), productList, EnumUtil.fromCode(SaleEnum.class, salesLedgerDto.getType()));
            updateMainContractAmount(
                    salesLedger.getId(),
src/main/java/com/ruoyi/sales/service/impl/ShippingInfoServiceImpl.java
@@ -26,6 +26,7 @@
import com.ruoyi.sales.mapper.SalesLedgerProductMapper;
import com.ruoyi.sales.mapper.ShippingInfoMapper;
import com.ruoyi.sales.mapper.ShippingProductDetailMapper;
import com.ruoyi.sales.pojo.SalesLedgerProduct;
import com.ruoyi.sales.pojo.ShippingInfo;
import com.ruoyi.sales.pojo.ShippingProductDetail;
import com.ruoyi.sales.service.ShippingInfoService;
@@ -148,8 +149,12 @@
    @Override
    public boolean add(ShippingInfoDto req) {
        String ledgerStockType = resolveLedgerStockType(req.getSalesLedgerProductId());
        this.save(req);
        req.getBatchNoDetailList().forEach(item -> item.setShippingInfoId(req.getId()));
        req.getBatchNoDetailList().forEach(item -> {
            item.setShippingInfoId(req.getId());
            item.setStockType(ledgerStockType);
        });
        shippingProductDetailMapper.insert(req.getBatchNoDetailList());
        // ä¿å­˜æ–‡ä»¶
        fileUtil.saveStorageAttachment(ApplicationTypeEnum.IMAGE, RecordTypeEnum.SHIPPING_INFO, req.getId(), req.getStorageBlobDTOs());
@@ -197,11 +202,16 @@
    }
    private void addShippingStockOutRecord(ShippingProductDetail shippingProductDetail, Long shippingInfoId) {
        String stockType = shippingProductDetail.getStockType();
        if (stockType != null) {
            stockType = stockType.trim().toLowerCase();
        ShippingInfo shippingInfo = this.getById(shippingInfoId);
        String stockType = resolveLedgerStockType(shippingInfo != null ? shippingInfo.getSalesLedgerProductId() : null);
        if (stockType == null) {
            stockType = normalizeStockType(shippingProductDetail.getStockType());
        }
        if ("waste".equals(stockType) || "unqualified".equals(stockType)) {
        String detailStockType = normalizeStockType(shippingProductDetail.getStockType());
        if (detailStockType != null && stockType != null && !stockType.equals(detailStockType)) {
            throw new RuntimeException("发货明细库存类型与销售台账产品库存类型不一致");
        }
        if ("waste".equals(stockType)) {
            StockUninventoryDto stockUninventoryDto = new StockUninventoryDto();
            stockUninventoryDto.setRecordId(shippingInfoId);
            stockUninventoryDto.setRecordType(StockOutQualifiedRecordTypeEnum.SALE_SHIP_STOCK_OUT.getCode());
@@ -231,4 +241,30 @@
        String normalized = batchNo.trim();
        return normalized.isEmpty() ? null : normalized;
    }
    private String normalizeStockType(String stockType) {
        if (stockType == null) {
            return null;
        }
        String normalized = stockType.trim().toLowerCase();
        if (normalized.isEmpty()) {
            return null;
        }
        if ("unqualified".equals(normalized)) {
            return "waste";
        }
        return normalized;
    }
    private String resolveLedgerStockType(Long salesLedgerProductId) {
        if (salesLedgerProductId == null) {
            return null;
        }
        SalesLedgerProduct salesLedgerProduct = salesLedgerProductMapper.selectById(salesLedgerProductId);
        if (salesLedgerProduct == null) {
            throw new RuntimeException("销售台账产品不存在");
        }
        String stockType = normalizeStockType(salesLedgerProduct.getStockType());
        return stockType == null ? "qualified" : stockType;
    }
}