huminmin
17 小时以前 802796c22d7d21a6d572cd4c11844e6865521666
新增库存,采购入库关联供应商,外协入库关联厂家
已修改12个文件
134 ■■■■ 文件已修改
doc/万通新型建材.sql 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/stock/dto/StockInventoryDto.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/stock/dto/StockUninventoryDto.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/stock/execl/StockUnInventoryExportData.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/stock/pojo/StockInRecord.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/stock/pojo/StockInventory.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/stock/pojo/StockUninventory.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/stock/service/impl/StockInRecordServiceImpl.java 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/stock/service/impl/StockInventoryServiceImpl.java 44 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/stock/service/impl/StockUninventoryServiceImpl.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/stock/StockInventoryMapper.xml 31 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/stock/StockUninventoryMapper.xml 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
doc/ÍòͨÐÂÐͽ¨²Ä.sql
@@ -40,17 +40,25 @@
    tenant_id                   bigint not null default 0 comment '租户ID',
    is_white                    bigint not null default 0 comment '是否白名单'
);
alter table stock_inventory
    add manufacturer_id bigint not null default 0 comment '厂家id',
    add source varchar(255) not null default '' comment '来源';
    add source varchar(255) not null default '' comment '来源',
    add supplier_id bigint null comment '供应商id';
alter table stock_in_record
    add manufacturer_id bigint not null default 0 comment '厂家id',
    add source varchar(255) not null default '' comment '来源';
    add source varchar(255) not null default '' comment '来源',
    add supplier_id bigint null comment '供应商id';
alter table stock_uninventory
    add manufacturer_id bigint not null default 0 comment '厂家id',
    add source varchar(255) not null default '' comment '来源';
alter table stock_uninventory
    drop column manufacturer_id;
alter table stock_in_record
    add supplier_id bigint null comment '供应商id';
alter table stock_inventory
    add supplier_id bigint null comment '供应商id';
alter table stock_in_record
    add is_contains_water boolean default false comment '是否含水',
    add water_content decimal(16, 4) default 0 comment '含水量',
src/main/java/com/ruoyi/stock/dto/StockInventoryDto.java
@@ -87,6 +87,12 @@
    @Schema(description = "合格库存来源文本")
    private String qualifiedSourceText;
    @Schema(description = "厂家名称")
    private String manufacturerName;
    @Schema(description = "供应商名称")
    private String supplierName;
    @Schema(description = "不合格库存来源")
    private String unQualifiedSource;
src/main/java/com/ruoyi/stock/dto/StockUninventoryDto.java
@@ -12,7 +12,6 @@
    private String unit;
    private Long productId;
    private Long topParentProductId;
    private String manufacturerName;
    private BigDecimal pendingOutQuantity;
    private String sourceText;
src/main/java/com/ruoyi/stock/execl/StockUnInventoryExportData.java
@@ -17,9 +17,6 @@
    @Excel(name = "规格")
    private String model;
    @Excel(name = "厂家")
    private String manufacturerName;
    @Excel(name = "来源")
    private String sourceText;
src/main/java/com/ruoyi/stock/pojo/StockInRecord.java
@@ -80,6 +80,9 @@
    @Schema(description = "来源")
    private String source;
    @Schema(description = "供应商id")
    private Long supplierId;
    @Schema(description = "是否含水")
    private Boolean isContainsWater;
src/main/java/com/ruoyi/stock/pojo/StockInventory.java
@@ -77,4 +77,7 @@
    @Schema(description = "来源")
    private String source;
    @Schema(description = "供应商id")
    private Long supplierId;
}
src/main/java/com/ruoyi/stock/pojo/StockUninventory.java
@@ -71,9 +71,6 @@
    @TableField(fill = FieldFill.INSERT)
    private Long deptId;
    @Schema(description = "厂家ID")
    private Long manufacturerId;
    @Schema(description = "来源")
    private String source;
}
src/main/java/com/ruoyi/stock/service/impl/StockInRecordServiceImpl.java
@@ -281,8 +281,12 @@
                            setBatchNo(stockInRecord.getBatchNo());
                            setRemark(stockInRecord.getRemark());
                            setWarnNum(stockInRecord.getWarnNum());
                            setManufacturerId(stockInRecord.getManufacturerId());
                            setSource(stockInRecord.getSource());
                            if (StockInventorySourceEnum.PURCHASE_RECEIPT.getCode().equals(stockInRecord.getSource())) {
                                setSupplierId(stockInRecord.getSupplierId());
                            } else if (StockInventorySourceEnum.OUTSOURCED_RECEIPT.getCode().equals(stockInRecord.getSource())) {
                                setManufacturerId(stockInRecord.getManufacturerId());
                            }
                            setVersion(1);
                        }});
                    } else {
@@ -297,7 +301,6 @@
                    stockUninventoryDto.setBatchNo(stockInRecord.getBatchNo());
                    stockUninventoryDto.setQualitity(finalStockInNum);
                    stockUninventoryDto.setRemark(stockInRecord.getRemark());
                    stockUninventoryDto.setManufacturerId(stockInRecord.getManufacturerId());
                    stockUninventoryDto.setSource(stockInRecord.getSource());
                    stockUninventoryDto.setType(uninventoryType);
                    if (stockUninventory == null) {
@@ -307,7 +310,6 @@
                            setBatchNo(stockInRecord.getBatchNo());
                            setType(uninventoryType);
                            setRemark(stockInRecord.getRemark());
                            setManufacturerId(stockInRecord.getManufacturerId());
                            setSource(stockInRecord.getSource());
                            setVersion(1);
                        }});
@@ -355,8 +357,12 @@
        stockInventoryDto.setBatchNo(stockInRecord.getBatchNo());
        stockInventoryDto.setQualitity(stockInRecord.getStockInNum());
        stockInventoryDto.setRemark(stockInRecord.getRemark());
        stockInventoryDto.setManufacturerId(stockInRecord.getManufacturerId());
        stockInventoryDto.setSource(stockInRecord.getSource());
        if (StockInventorySourceEnum.PURCHASE_RECEIPT.getCode().equals(stockInRecord.getSource())) {
            stockInventoryDto.setSupplierId(stockInRecord.getSupplierId());
        } else if (StockInventorySourceEnum.OUTSOURCED_RECEIPT.getCode().equals(stockInRecord.getSource())) {
            stockInventoryDto.setManufacturerId(stockInRecord.getManufacturerId());
        }
        return stockInventoryDto;
    }
src/main/java/com/ruoyi/stock/service/impl/StockInventoryServiceImpl.java
@@ -105,12 +105,7 @@
        eq.eq(StockInventory::getBatchNo, stockInventoryDto.getBatchNo());
        //新增入库记录再添加库存
        StockInRecordDto stockInRecordDto = new StockInRecordDto();
        stockInRecordDto.setRecordId(stockInventoryDto.getRecordId());
        stockInRecordDto.setRecordType(stockInventoryDto.getRecordType());
        stockInRecordDto.setStockInNum(stockInventoryDto.getQualitity());
        stockInRecordDto.setBatchNo(stockInventoryDto.getBatchNo());
        stockInRecordDto.setProductModelId(stockInventoryDto.getProductModelId());
        stockInRecordDto.setType("0");
        populateStockInRecord(stockInventoryDto, stockInRecordDto);
        stockInRecordService.add(stockInRecordDto);
        //再进行新增库存数量库存
        //先查询库存表中的产品是否存在,不存在新增,存在更新
@@ -124,8 +119,10 @@
            newStockInventory.setBatchNo(stockInventoryDto.getBatchNo());
            newStockInventory.setLockedQuantity(stockInventoryDto.getLockedQuantity());
            newStockInventory.setWarnNum(stockInventoryDto.getWarnNum());
            applySourceBindingFields(newStockInventory, stockInventoryDto);
            stockInventoryMapper.insert(newStockInventory);
        } else {
            applySourceBindingFields(stockInventoryDto, stockInventoryDto);
            stockInventoryMapper.updateAddStockInventory(stockInventoryDto);
        }
        return true;
@@ -180,23 +177,50 @@
        stockInventoryDto.setBatchNo(batchNo);
        StockInRecordDto stockInRecordDto = new StockInRecordDto();
        populateStockInRecord(stockInventoryDto, stockInRecordDto);
        stockInRecordService.add(stockInRecordDto);
        return true;
    }
    private void applySourceBindingFields(StockInventory target, StockInventoryDto source) {
        if (target == null || source == null) {
            return;
        }
        target.setSource(source.getSource());
        if (StockInventorySourceEnum.PURCHASE_RECEIPT.getCode().equals(source.getSource())) {
            target.setSupplierId(source.getSupplierId());
            target.setManufacturerId(null);
            return;
        }
        if (StockInventorySourceEnum.OUTSOURCED_RECEIPT.getCode().equals(source.getSource())) {
            target.setManufacturerId(source.getManufacturerId());
            target.setSupplierId(null);
            return;
        }
        target.setManufacturerId(null);
        target.setSupplierId(null);
    }
    private void populateStockInRecord(StockInventoryDto stockInventoryDto, StockInRecordDto stockInRecordDto) {
        stockInRecordDto.setRecordId(stockInventoryDto.getRecordId());
        stockInRecordDto.setRecordType(stockInventoryDto.getRecordType());
        stockInRecordDto.setStockInNum(stockInventoryDto.getQualitity());
        stockInRecordDto.setBatchNo(batchNo);
        stockInRecordDto.setBatchNo(stockInventoryDto.getBatchNo());
        stockInRecordDto.setProductModelId(stockInventoryDto.getProductModelId());
        stockInRecordDto.setType("0");
        stockInRecordDto.setRemark(stockInventoryDto.getRemark());
        stockInRecordDto.setWarnNum(stockInventoryDto.getWarnNum());
        stockInRecordDto.setManufacturerId(stockInventoryDto.getManufacturerId());
        stockInRecordDto.setSource(stockInventoryDto.getSource());
        if (StockInventorySourceEnum.PURCHASE_RECEIPT.getCode().equals(stockInventoryDto.getSource())) {
            stockInRecordDto.setSupplierId(stockInventoryDto.getSupplierId());
        } else if (StockInventorySourceEnum.OUTSOURCED_RECEIPT.getCode().equals(stockInventoryDto.getSource())) {
            stockInRecordDto.setManufacturerId(stockInventoryDto.getManufacturerId());
        }
        // è®¾ç½®å«æ°´é‡ç›¸å…³ä¿¡æ¯
        stockInRecordDto.setIsContainsWater(stockInventoryDto.getIsContainsWater());
        stockInRecordDto.setWaterContent(stockInventoryDto.getWaterContent());
        stockInRecordDto.setTheoryStockInNum(stockInventoryDto.getTheoryStockInNum());
        stockInRecordDto.setDifferenceNum(stockInventoryDto.getDifferenceNum());
        stockInRecordService.add(stockInRecordDto);
        return true;
    }
    //规则生成:20260424-产品编号-001
src/main/java/com/ruoyi/stock/service/impl/StockUninventoryServiceImpl.java
@@ -114,7 +114,6 @@
        } else {
            stockInRecordDto.setType("2");
        }
        stockInRecordDto.setManufacturerId(stockUninventoryDto.getManufacturerId());
        stockInRecordDto.setSource(stockUninventoryDto.getSource());
        stockInRecordService.add(stockInRecordDto);
        //审批再添加
src/main/resources/mapper/stock/StockInventoryMapper.xml
@@ -12,6 +12,9 @@
        <result column="version" property="version"/>
        <result column="locked_quantity" property="lockedQuantity"/>
        <result column="warn_num" property="warnNum"/>
        <result column="manufacturer_id" property="manufacturerId"/>
        <result column="source" property="source"/>
        <result column="supplier_id" property="supplierId"/>
    </resultMap>
    <update id="updateAddStockInventory">
        update stock_inventory
@@ -33,6 +36,12 @@
            </if>
            <if test="ew.source != null and ew.source != ''">
                source = #{ew.source},
            </if>
            <if test="ew.manufacturerId != null">
                manufacturer_id = #{ew.manufacturerId},
            </if>
            <if test="ew.supplierId != null">
                supplier_id = #{ew.supplierId},
            </if>
            update_time = now()
        </set>
@@ -75,6 +84,9 @@
        si.update_time,
        COALESCE(si.warn_num, 0) as warn_num,
        si.version,
        si.source,
        si.manufacturer_id,
        si.supplier_id,
        (si.qualitity - COALESCE(si.locked_quantity, 0)) as un_locked_quantity,
        pm.model,
        si.remark,
@@ -118,6 +130,7 @@
        MAX(update_time) as update_time,
        MAX(warn_num) as warn_num,
        MAX(version) as version,
        MAX(supplier_id) as supplier_id,
        model,
        MAX(remark) as remark,
        unit,
@@ -139,6 +152,7 @@
        si.update_time,
        COALESCE(si.warn_num, 0) as warn_num,
        si.version,
        si.supplier_id,
        (si.qualitity - COALESCE(si.locked_quantity, 0)) as un_locked_quantity,
        pm.model,
        si.remark,
@@ -177,6 +191,7 @@
        su.update_time,
        0 as warn_num,
        su.version,
        null as supplier_id,
        (su.qualitity - COALESCE(su.locked_quantity, 0)) as un_locked_quantity,
        pm.model,
        su.remark,
@@ -568,7 +583,9 @@
        product_name,
        product_id,
        MAX(manufacturer_id) as manufacturer_id,
        MAX(supplier_id) as supplier_id,
        MAX(manufacturer_name) as manufacturerName,
        MAX(supplier_name) as supplierName,
        MAX(qualifiedSource) as qualifiedSource,
        MAX(unQualifiedSource) as unQualifiedSource,
@@ -597,7 +614,9 @@
        p.product_name,
        p.id as product_id,
        si.manufacturer_id,
        si.supplier_id,
        m.name as manufacturer_name,
        sm.supplier_name as supplier_name,
        si.source as qualifiedSource,
        null as unQualifiedSource,
@@ -624,6 +643,7 @@
        left join product_model pm on si.product_model_id = pm.id
        left join product p on pm.product_id = p.id
        left join manufacturer m on si.manufacturer_id = m.id
        left join supplier_manage sm on si.supplier_id = sm.id
        union all
@@ -643,8 +663,10 @@
        pm.unit,
        p.product_name,
        p.id as product_id,
        su.manufacturer_id,
        m.name as manufacturer_name,
        null as manufacturer_id,
        null as supplier_id,
        null as manufacturer_name,
        null as supplier_name,
        null as qualifiedSource,
        su.source as unQualifiedSource,
@@ -670,7 +692,6 @@
        from stock_uninventory su
        left join product_model pm on su.product_model_id = pm.id
        left join product p on pm.product_id = p.id
        left join manufacturer m on su.manufacturer_id = m.id
        ) as combined
        <where>
            <if test="ew.productModelId != null and ew.productModelId > 0">
@@ -689,7 +710,9 @@
        product_name,
        product_id,
        manufacturer_id,
        manufacturer_name
        supplier_id,
        manufacturer_name,
        supplier_name
        order by
        batch_no
    </select>
src/main/resources/mapper/stock/StockUninventoryMapper.xml
@@ -30,7 +30,6 @@
        from stock_uninventory su
        left join product_model pm on su.product_model_id = pm.id
        left join product p on pm.product_id = p.id
        left join manufacturer m on su.manufacturer_id = m.id
    </sql>
    <sql id="WastePageColumns">
@@ -48,7 +47,6 @@
        pm.model,
        pm.unit,
        p.product_name,
        m.name as manufacturer_name,
        su.source
    </sql>
@@ -164,7 +162,6 @@
        pm.model,
        pm.unit,
        p.product_name,
        m.name as manufacturer_name,
        su.source
        <include refid="BaseWasteFromClause" />
        <where>
@@ -191,8 +188,7 @@
        su.*,
        pm.model,
        pm.unit,
        p.product_name,
        m.name as manufacturer_name
        p.product_name
        <include refid="BaseWasteFromClause" />
        <where>
            <if test="ew.type != null and ew.type != ''">
@@ -210,7 +206,6 @@
        pm.model,
        pm.unit,
        p.product_name,
        m.name as manufacturer_name,
        su.source,
        su.type,
        GROUP_CONCAT(DISTINCT su.batch_no ORDER BY su.batch_no SEPARATOR ',') as batch_no,
@@ -244,7 +239,6 @@
        su.id,
        p.product_name,
        pm.model,
        m.name as manufacturer_name,
        su.source,
        pm.unit,
        su.batch_no,
@@ -257,7 +251,6 @@
        from stock_uninventory su
        left join product_model pm on su.product_model_id = pm.id
        left join product p on pm.product_id = p.id
        left join manufacturer m on su.manufacturer_id = m.id
        <where>
            and su.type = 'waste'
            <if test="ew.productModelId != null and ew.productModelId > 0">