廖井涛
2024-05-20 da497e4c08c46cbde5dfcd7ea0cf2e455ee6f592
north-glass-erp/src/main/resources/mapper/mm/MaterialInventory.xml
@@ -82,7 +82,7 @@
        select
        ou.id as useId,
        ou.project_no as projectNo,
        ou.use_count AS inventoryQuantity,
        mi.inventory_quantity AS inventoryQuantity,
        mi.plan_quantity AS availableQuantity,
        mi.plan_quantity AS planQuantity,
        mi.id,
@@ -98,9 +98,10 @@
        mi.dead_stock AS deadStock,
        mi.remarks,
        date(mi.create_time) AS createTime,
        ms.json from pp.optimize_use ou left join mm.material_inventory mi on ou.stock_code=mi.id left join mm.material_store ms on mi.material_code=ms.id
        ms.json from pp.optimize_use ou left join mm.material_inventory mi on ou.raw_stock_code=mi.id left join mm.material_store ms on mi.material_code=ms.id
        left join pp.optimize_project op on op.project_no=ou.project_no
        <where>
            ou.not_use_count>0 and ou.state=1 and
            mi.plan_quantity>0 and op.state>=100 and
            date(ou.create_time)>=#{startDate} and date(ou.create_time) &lt;= #{endDate}
        </where>
@@ -144,7 +145,10 @@
        from mm.material_inventory mi left join mm.material_store ms on mi.material_code=ms.id
        <where>
            <if test="materialInventory.stockId != null and materialInventory.stockId != ''">
                and mi.id regexp #{materialInventory.stockId}
                and mi.id in
                <foreach item="id" collection="ids" open="(" separator="," close=")">
                    #{id}
                </foreach>
            </if>
        </where>
@@ -171,7 +175,7 @@
        select
        ou.id as useId,
        ou.project_no as projectNo,
        ou.use_count AS inventoryQuantity,
        mi.inventory_quantity AS inventoryQuantity,
        mi.plan_quantity AS availableQuantity,
        mi.plan_quantity AS planQuantity,
        mi.id,
@@ -187,11 +191,14 @@
        mi.dead_stock AS deadStock,
        mi.remarks,
        date(mi.create_time) AS createTime,
        ms.json from pp.optimize_use ou left join mm.material_inventory mi on ou.stock_code=mi.id left join mm.material_store ms on mi.material_code=ms.id
        ms.json from pp.optimize_use ou left join mm.material_inventory mi on ou.raw_stock_code=mi.id left join mm.material_store ms on mi.material_code=ms.id
        <where>
            <if test="optimizeUse.rawStockCode != null and optimizeUse.rawStockCode != ''">
                and ou.id regexp #{optimizeUse.rawStockCode}
                and ou.id in
                <foreach item="id" collection="ids" open="(" separator="," close=")">
                    #{id}
                </foreach>
            </if>
        </where>
@@ -207,7 +214,10 @@
        pp.optimize_use ou
        <where>
            <if test="optimizeUse.rawStockCode != null and optimizeUse.rawStockCode != ''">
                and ou.id regexp #{optimizeUse.rawStockCode}
                and ou.id in
                <foreach item="id" collection="ids" open="(" separator="," close=")">
                    #{id}
                </foreach>
            </if>
        </where>
@@ -678,25 +688,25 @@
    <update id="updateMaterialInventoryInventoryOut">
        update mm.material_inventory
        set inventory_quantity=inventory_quantity-#{quantity},plan_quantity=if(plan_quantity-#{quantity}>=0,plan_quantity-#{quantity},0)
        set inventory_quantity=inventory_quantity-#{quantity},plan_quantity=if(plan_quantity-#{quantity}>=0,plan_quantity-#{quantity},0),total_area=inventory_quantity*single_piece_area
        where id=#{inventoryId}
    </update>
    <update id="updateMaterialInventoryInventoryInt">
        update mm.material_inventory
        set inventory_quantity=inventory_quantity+#{quantity},plan_quantity=plan_quantity+#{quantity}
        set inventory_quantity=inventory_quantity+#{quantity},plan_quantity=plan_quantity+#{quantity},total_area=inventory_quantity*single_piece_area
        where id=#{inventoryId}
    </update>
    <update id="updateMaterialInventoryAvailableInventoryOut">
        update mm.material_inventory
        set available_quantity=available_quantity-#{quantity},inventory_quantity=inventory_quantity-#{quantity}
        set available_quantity=available_quantity-#{quantity},inventory_quantity=inventory_quantity-#{quantity},total_area=inventory_quantity*single_piece_area
        where id=#{inventoryId}
    </update>
    <update id="updateMaterialInventoryAvailableInventoryInt">
        update mm.material_inventory
        set available_quantity=available_quantity+#{quantity},inventory_quantity=inventory_quantity+#{quantity}
        set available_quantity=available_quantity+#{quantity},inventory_quantity=inventory_quantity+#{quantity},total_area=inventory_quantity*single_piece_area
        where id=#{inventoryId}
    </update>
@@ -729,7 +739,7 @@
    </update>
    <update id="updateMaterialInventoryReturning" >
        update mm.material_inventory set inventory_quantity=inventory_quantity+#{returningWarehouseDetail.returnQuantity},
        update mm.material_inventory set available_quantity=available_quantity+#{returningWarehouseDetail.returnQuantity},
                                         total_area=total_area+#{totalArea}
       where  material_code=#{materialCode} and
                date_of_manufacture=#{returningWarehouseDetail.dateOfManufacture}
@@ -738,7 +748,7 @@
    </update>
    <update id="updateMaterialInventoryReturningNull" >
        update mm.material_inventory set inventory_quantity=inventory_quantity+#{returningWarehouseDetail.returnQuantity},
        update mm.material_inventory set available_quantity=available_quantity+#{returningWarehouseDetail.returnQuantity},
                                         total_area=total_area+#{totalArea}
        where  material_code=#{materialCode} and
            date_of_manufacture is null
@@ -751,5 +761,11 @@
        where  returning_id=#{number} and returning_number=#{returningWarehouseNumber}
    </update>
    <update id="updateMaterialInventoryArea" >
        update mm.material_inventory set single_piece_area=#{singlePieceArea},
                                         total_area=inventory_quantity*#{singlePieceArea}
        where  material_code=#{materialCode}
    </update>
</mapper>