你好啊
2024-08-09 9eb61cbf0da06bb41c4f8f3e9a53ae48b77cdb5e
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,93 @@
        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>
    <select id="getSelectSurplusMaterialsDate" >
        select *
        from mm.surplus_materials
        <where>
                and date(create_time)>=#{startDate} and date(create_time) &lt;= #{endDate} and quantity>0
            <if test="surplusMaterials.width != null and surplusMaterials.width != ''">
                and width regexp #{surplusMaterials.width}
            </if>
            <if test="surplusMaterials.height != null and surplusMaterials.height != ''">
                and height regexp #{surplusMaterials.height}
            </if>
            <if test="surplusMaterials.thickness != null and surplusMaterials.thickness != ''">
                and thickness regexp #{surplusMaterials.thickness}
            </if>
            <if test="surplusMaterials.quantity != null and surplusMaterials.quantity != ''">
                and quantity regexp #{surplusMaterials.quantity}
            </if>
            <if test="surplusMaterials.colour != null and surplusMaterials.colour != ''">
                and colour regexp #{surplusMaterials.colour}
            </if>
            <if test="surplusMaterials.remarks != null and surplusMaterials.remarks != ''">
                and remarks regexp #{surplusMaterials.remarks}
            </if>
        </where>
        limit #{offset},#{pageSize};
    </select>
    <select id="getSelectSurplusMaterialsDatePageTotal" >
        select CEILING(count(id)/#{pageSize}) as 'pageTotal',
        count(id) as 'total'
        from mm.surplus_materials
        <where>
            and date(create_time)>=#{startDate} and date(create_time) &lt;= #{endDate} and quantity>0
            <if test="surplusMaterials.width != null and surplusMaterials.width != ''">
                and width regexp #{surplusMaterials.width}
            </if>
            <if test="surplusMaterials.height != null and surplusMaterials.height != ''">
                and height regexp #{surplusMaterials.height}
            </if>
            <if test="surplusMaterials.thickness != null and surplusMaterials.thickness != ''">
                and thickness regexp #{surplusMaterials.thickness}
            </if>
            <if test="surplusMaterials.quantity != null and surplusMaterials.quantity != ''">
                and quantity regexp #{surplusMaterials.quantity}
            </if>
            <if test="surplusMaterials.colour != null and surplusMaterials.colour != ''">
                and colour regexp #{surplusMaterials.colour}
            </if>
            <if test="surplusMaterials.remarks != null and surplusMaterials.remarks != ''">
                and remarks regexp #{surplusMaterials.remarks}
            </if>
        </where>
    </select>
    <select id="selectSurplusMaterialsCount" >
        select *
        from mm.surplus_materials
        where width=#{surplusMaterials.width} and height=#{surplusMaterials.height}
          and thickness=#{surplusMaterials.thickness} and colour=#{surplusMaterials.colour} limit 0,1
    </select>
    <insert id="insertSurplusMaterials">
        insert into mm.surplus_materials (width,height,thickness,quantity,colour,create_time)
        values (#{surplusMaterials.width},#{surplusMaterials.height},#{surplusMaterials.thickness},#{surplusMaterials.quantity},#{surplusMaterials.colour},now())
    </insert>
    <insert id="insertSurplusMaterialsLog">
        insert into mm.surplus_materials_log (width,height,thickness,quantity,colour,type,creator,create_time)
        values (#{surplusMaterials.width},#{surplusMaterials.height},#{surplusMaterials.thickness},
                #{surplusMaterials.quantity},#{surplusMaterials.colour},#{type},#{creator},now())
    </insert>
    <update id="updateSurplusMaterialsOutQuantity">
        update mm.surplus_materials set quantity=quantity-#{surplusMaterials.quantity} where id=#{surplusMaterials.id}
    </update>
    <update id="updateSurplusMaterialsIntQuantity">
        update mm.surplus_materials set quantity=quantity+#{surplusMaterials.quantity} where id=#{surplusMaterials.id}
    </update>
</mapper>