chenhj
2026-04-24 b5f260b2364fad1e74a7eb1f5985268056e3a9e7
src/main/resources/mapper/stock/StockInventoryMapper.xml
@@ -34,6 +34,12 @@
            update_time = now()
        </set>
        where product_model_id = #{ew.productModelId}
            <if test="ew.batchNo == null">
                and batch_no is null
            </if>
            <if test="ew.batchNo != null">
                and batch_no = #{ew.batchNo}
            </if>
    </update>
    <update id="updateSubtractStockInventory">
        update stock_inventory
@@ -50,6 +56,12 @@
            update_time = now()
        </set>
        where product_model_id = #{ew.productModelId} and qualitity >= #{ew.qualitity}
            <if test="ew.batchNo == null">
                and batch_no is null
            </if>
            <if test="ew.batchNo != null">
                and batch_no = #{ew.batchNo}
            </if>
    </update>
    <select id="pagestockInventory" resultType="com.ruoyi.stock.dto.StockInventoryDto">
        select si.id,
@@ -87,6 +99,7 @@
        INNER JOIN product_tree pt ON p.parent_id = pt.id
        )
        select
            batch_no,
            MAX(qualifiedId) as qualifiedId,
            MAX(unQualifiedId) as unQualifiedId,
            SUM(qualifiedQuantity) as qualifiedQuantity,
@@ -108,6 +121,7 @@
            'combined' as stockType
        from (
            select
            si.batch_no,
            si.id as qualifiedId,
            null as unQualifiedId,
            si.qualitity as qualifiedQuantity,
@@ -133,6 +147,7 @@
            union all
            select
            su.batch_no,
            null as qualifiedId,
            su.id as unQualifiedId,
            0 as qualifiedQuantity,
@@ -168,7 +183,7 @@
                and combined.product_id in (select id from product_tree)
            </if>
        </where>
        group by product_model_id, model, unit, product_name, product_id
        group by batch_no, product_model_id, model, unit, product_name, product_id
    </select>
    <select id="listStockInventoryExportData" resultType="com.ruoyi.stock.execl.StockInventoryExportData">
@@ -395,4 +410,4 @@
        ORDER BY DATE(sor.create_time) ASC
    </select>
</mapper>
</mapper>