8 小时以前 7782a7e1191a0e98ffb20bca8b59248e98c556a8
feat(stock): 添加库存位置功能支持

- 在入库记录导出数据中添加Location字段映射
- 在出库记录导出数据中添加Location字段映射
- 在非库存导出数据中添加Location字段映射
- 更新入库记录查询映射,增加位置条件筛选
- 更新出库记录查询映射,增加位置条件筛选
- 修改入库记录服务实现,添加库存位置关联逻辑
- 修改出库记录服务实现,添加库存位置关联逻辑
- 更新库存映射文件,添加位置和备注字段结果映射
- 更新库存更新操作,增加位置条件限制
- 更新库存分页查询,添加位置筛选条件
- 更新库存左连接查询,增加位置匹配条件
已修改9个文件
76 ■■■■ 文件已修改
src/main/java/com/ruoyi/stock/execl/StockInRecordExportData.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/stock/execl/StockOutRecordExportData.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/stock/execl/StockUnInventoryExportData.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/stock/service/impl/StockInRecordServiceImpl.java 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/stock/service/impl/StockOutRecordServiceImpl.java 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/stock/StockInRecordMapper.xml 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/stock/StockInventoryMapper.xml 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/stock/StockOutRecordMapper.xml 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/stock/StockUninventoryMapper.xml 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/stock/execl/StockInRecordExportData.java
@@ -22,6 +22,8 @@
    private String recordType;
    @Excel(name = "入库数量")
    private String stockInNum;
    @Excel(name = "Location")
    private String stockLocation;
    @Excel(name = "入库时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
src/main/java/com/ruoyi/stock/execl/StockOutRecordExportData.java
@@ -21,6 +21,8 @@
    private String recordType;
    @Excel(name = "出库数量")
    private String stockInNum;
    @Excel(name = "Location")
    private String stockLocation;
    @Excel(name = "出库时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
src/main/java/com/ruoyi/stock/execl/StockUnInventoryExportData.java
@@ -27,6 +27,8 @@
    @Excel(name = "备注")
    private String remark;
    @Excel(name = "Location")
    private String stockLocation;
//
//    @Excel(name = "最新更新时间")
//    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
src/main/java/com/ruoyi/stock/service/impl/StockInRecordServiceImpl.java
@@ -80,17 +80,22 @@
        for (Long id : ids) {
            StockInRecord stockInRecord = stockInRecordMapper.selectById(id);
            if (stockInRecord.getType().equals("0")) {
                StockInventory stockInventory = stockInventoryMapper.selectOne(new LambdaQueryWrapper<StockInventory>().eq(StockInventory::getProductModelId, stockInRecord.getProductModelId()));
                StockInventory stockInventory = stockInventoryMapper.selectOne(new LambdaQueryWrapper<StockInventory>()
                        .eq(StockInventory::getProductModelId, stockInRecord.getProductModelId())
                        .eq(StockInventory::getStockLocation, stockInRecord.getStockLocation()));
                if (stockInventory == null) {
                    throw new BaseException("库存记录中没有对应的产品,无法删除!!!");
                }else {
                    StockInventoryDto stockInRecordDto = new StockInventoryDto();
                    stockInRecordDto.setProductModelId(stockInventory.getProductModelId());
                    stockInRecordDto.setQualitity(stockInRecord.getStockInNum());
                    stockInRecordDto.setStockLocation(stockInRecord.getStockLocation());
                    stockInventoryMapper.updateSubtractStockInventory(stockInRecordDto);
                }
            }else if (stockInRecord.getType().equals("1")) {
                StockUninventory stockUninventory = stockUninventoryMapper.selectOne(new LambdaQueryWrapper<StockUninventory>().eq(StockUninventory::getProductModelId, stockInRecord.getProductModelId()));
                StockUninventory stockUninventory = stockUninventoryMapper.selectOne(new LambdaQueryWrapper<StockUninventory>()
                        .eq(StockUninventory::getProductModelId, stockInRecord.getProductModelId())
                        .eq(StockUninventory::getStockLocation, stockInRecord.getStockLocation()));
                if (stockUninventory == null) {
                    throw new BaseException("库存记录中没有对应的产品,无法删除!!!");
                }else {
@@ -136,9 +141,12 @@
        if (ObjectUtils.isEmpty(oldStockInventory)) {
            stockInventoryMapper.insert(newStockInventory);
        }else {
            StockInventoryDto oldStockInventoryDto = new StockInventoryDto();
            BeanUtils.copyProperties(oldStockInventory, oldStockInventoryDto);
            stockInventoryMapper.updateAddStockInventory(oldStockInventoryDto);
            StockInventoryDto stockInventoryDto = new StockInventoryDto();
            stockInventoryDto.setProductModelId(stockInRecordDto.getProductModelId());
            stockInventoryDto.setQualitity(stockInRecordDto.getActualStockInNum() == null ? stockInRecordDto.getWaitAuditNum() : stockInRecordDto.getActualStockInNum());
            stockInventoryDto.setRemark(stockInRecordDto.getRemark());
            stockInventoryDto.setStockLocation(stockInRecordDto.getStockLocation());
            stockInventoryMapper.updateAddStockInventory(stockInventoryDto);
        }
        stockInRecordDto.setStatus(2);
        stockInRecordDto.setStockInNum(stockInRecordDto.getActualStockInNum() == null ? stockInRecordDto.getWaitAuditNum() : stockInRecordDto.getActualStockInNum());
src/main/java/com/ruoyi/stock/service/impl/StockOutRecordServiceImpl.java
@@ -76,17 +76,22 @@
        for (Long id : ids) {
            StockOutRecord stockOutRecord = stockOutRecordMapper.selectById(id);
            if (stockOutRecord.getType().equals("0")) {
                StockInventory stockInventory = stockInventoryMapper.selectOne(new LambdaQueryWrapper<StockInventory>().eq(StockInventory::getProductModelId, stockOutRecord.getProductModelId()));
                StockInventory stockInventory = stockInventoryMapper.selectOne(new LambdaQueryWrapper<StockInventory>()
                        .eq(StockInventory::getProductModelId, stockOutRecord.getProductModelId())
                        .eq(StockInventory::getStockLocation, stockOutRecord.getStockLocation()));
                if (stockInventory == null) {
                    throw new BaseException("库存记录中没有对应的产品,无法删除!!!");
                }else {
                    StockInventoryDto stockInRecordDto = new StockInventoryDto();
                    stockInRecordDto.setProductModelId(stockInventory.getProductModelId());
                    stockInRecordDto.setQualitity(stockOutRecord.getStockOutNum());
                    stockInRecordDto.setStockLocation(stockOutRecord.getStockLocation());
                    stockInventoryMapper.updateAddStockInventory(stockInRecordDto);
                }
            }else if (stockOutRecord.getType().equals("1")) {
                StockUninventory stockUninventory = stockUninventoryMapper.selectOne(new LambdaQueryWrapper<StockUninventory>().eq(StockUninventory::getProductModelId, stockOutRecord.getProductModelId()));
                StockUninventory stockUninventory = stockUninventoryMapper.selectOne(new LambdaQueryWrapper<StockUninventory>()
                        .eq(StockUninventory::getProductModelId, stockOutRecord.getProductModelId())
                        .eq(StockUninventory::getStockLocation, stockOutRecord.getStockLocation()));
                if (stockUninventory == null) {
                    throw new BaseException("库存记录中没有对应的产品,无法删除!!!");
                }else {
src/main/resources/mapper/stock/StockInRecordMapper.xml
@@ -30,6 +30,9 @@
            <if test="params.recordType != null and params.recordType != ''">
                and sir.record_type = #{params.recordType}
            </if>
            <if test="params.stockLocation != null and params.stockLocation != ''">
                and sir.stock_location = #{params.stockLocation}
            </if>
        </where>
        order by sir.id desc
    </select>
@@ -57,7 +60,10 @@
            <if test="params.recordType != null and params.recordType != ''">
                and sir.record_type = #{params.recordType}
            </if>
            <if test="params.stockLocation != null and params.stockLocation != ''">
                and sir.stock_location = #{params.stockLocation}
            </if>
        </where>
        order by sir.id desc
    </select>
</mapper>
</mapper>
src/main/resources/mapper/stock/StockInventoryMapper.xml
@@ -12,6 +12,8 @@
        <result column="version" property="version"/>
        <result column="locked_quantity" property="lockedQuantity"/>
        <result column="warn_num" property="warnNum"/>
        <result column="remark" property="remark"/>
        <result column="stock_location" property="stockLocation"/>
    </resultMap>
    <update id="updateAddStockInventory">
        update stock_inventory
@@ -34,6 +36,7 @@
            update_time = now()
        </set>
        where product_model_id = #{ew.productModelId}
          and stock_location = #{ew.stockLocation}
    </update>
    <update id="updateSubtractStockInventory">
        update stock_inventory
@@ -49,7 +52,9 @@
            </if>
            update_time = now()
        </set>
        where product_model_id = #{ew.productModelId} and qualitity >= #{ew.qualitity}
        where product_model_id = #{ew.productModelId}
          and stock_location = #{ew.stockLocation}
          and qualitity >= #{ew.qualitity}
    </update>
    <select id="pagestockInventory" resultType="com.ruoyi.stock.dto.StockInventoryDto">
        select si.id,
@@ -76,6 +81,9 @@
        <if test="ew.productModelId != null">
            and pm.id = #{ew.productModelId}
        </if>
        <if test="ew.stockLocation != null and ew.stockLocation != ''">
            and si.stock_location = #{ew.stockLocation}
        </if>
    </select>
    <select id="listStockInventoryExportData" resultType="com.ruoyi.stock.execl.StockInventoryExportData">
        select si.qualitity,
@@ -85,6 +93,7 @@
        coalesce(si.warn_num, 0) as warn_num,
        coalesce(si.locked_quantity, 0) as locked_quantity,
        si.remark,
        si.stock_location,
        si.update_time
        from stock_inventory si
        left join product_model pm on si.product_model_id = pm.id
@@ -92,6 +101,9 @@
        where 1 = 1
        <if test="ew.productName != null and ew.productName !=''">
            and p.product_name like concat('%',#{ew.productName},'%')
        </if>
        <if test="ew.stockLocation != null and ew.stockLocation != ''">
            and si.stock_location = #{ew.stockLocation}
        </if>
    </select>
    <select id="stockInventoryPage" resultType="com.ruoyi.stock.dto.StockInRecordDto">
@@ -103,6 +115,7 @@
        from
        stock_in_record sir
        left join stock_inventory si on sir.product_model_id = si.product_model_id
        and sir.stock_location = si.stock_location
        left join product_model pm on sir.product_model_id = pm.id
        left join product p on pm.product_id = p.id
        left join sys_user su on sir.create_user = su.user_id
@@ -117,6 +130,9 @@
            <if test="ew.endMonth != null">
                and sir.create_time &lt;= #{ew.endMonth}
            </if>
            <if test="ew.stockLocation != null and ew.stockLocation != ''">
                and sir.stock_location = #{ew.stockLocation}
            </if>
        </where>
    </select>
src/main/resources/mapper/stock/StockOutRecordMapper.xml
@@ -42,6 +42,9 @@
            <if test="params.recordType != null and params.recordType != ''">
                and sor.record_type = #{params.recordType}
            </if>
            <if test="params.stockLocation != null and params.stockLocation != ''">
                and sor.stock_location = #{params.stockLocation}
            </if>
        </where>
        order by sor.id desc
    </select>
@@ -69,6 +72,9 @@
            <if test="params.recordType != null and params.recordType != ''">
                and sor.record_type = #{params.recordType}
            </if>
            <if test="params.stockLocation != null and params.stockLocation != ''">
                and sor.stock_location = #{params.stockLocation}
            </if>
        </where>
        order by sor.id desc
    </select>
src/main/resources/mapper/stock/StockUninventoryMapper.xml
@@ -10,6 +10,9 @@
        <result column="create_time" property="createTime" />
        <result column="update_time" property="updateTime" />
        <result column="version" property="version" />
        <result column="remark" property="remark" />
        <result column="locked_quantity" property="lockedQuantity" />
        <result column="stock_location" property="stockLocation" />
    </resultMap>
    <update id="updateSubtractStockUnInventory">
        update stock_uninventory
@@ -53,6 +56,8 @@
        su.version,
        su.update_time,
        (su.qualitity - COALESCE(su.locked_quantity, 0)) as un_locked_quantity,
        su.remark,
        su.stock_location,
        pm.model,
        pm.unit,
        p.product_name
@@ -62,6 +67,9 @@
        where pm.product_type = #{ew.productType}
        <if test="ew.productName != null and ew.productName !=''">
            and p.product_name like concat('%',#{ew.productName},'%')
        </if>
        <if test="ew.stockLocation != null and ew.stockLocation != ''">
            and su.stock_location = #{ew.stockLocation}
        </if>
    </select>
    <select id="listStockInventoryExportData" resultType="com.ruoyi.stock.execl.StockUnInventoryExportData">
@@ -76,6 +84,9 @@
        <if test="ew.productName != null and ew.productName !=''">
            and p.product_name like concat('%',#{ew.productName},'%')
        </if>
        <if test="ew.stockLocation != null and ew.stockLocation != ''">
            and su.stock_location = #{ew.stockLocation}
        </if>
    </select>
</mapper>