廖井涛
2025-09-09 b2cefd84dfd1aa051ae4ab342874fbafef74ab3b
north-glass-erp/src/main/resources/mapper/mm/FinishedGlassShelf.xml
@@ -151,11 +151,16 @@
            fed.price,
            fed.money,
            fed.unit,
            fed.remarks
            fed.remarks,
            fed.withdraw_quantity as withdrawQuantity,
            fed.quantity-fed.withdraw_quantity as quantity2,
            fed.emit_id as emitId,
            fed.emit_number as emitNumber
            from
            mm.finished_glass_shelf_emit_details fed left join mm.finished_glass_shelf_information fi on fed.information_id=fi.id
        where emit_id=#{emitId}
    </select>
    <select id="getSelectFinishedGlassShelfEmitDetailsByemitId1" >
        select * from mm.finished_glass_shelf_emit_details where emit_id=#{emitId}
@@ -167,7 +172,7 @@
    </select>
    <select id="getmaximumWithdraw" >
        select ifnull(SUBSTR(max(right(emit_id,8)) from 7),0) from  mm.finished_glass_shelf_withdraw where  date(create_time)=CURDATE()
        select ifnull(SUBSTR(max(right(withdraw_id,8)) from 7),0) from  mm.finished_glass_shelf_withdraw where  date(create_time)=CURDATE()
    </select>
@@ -194,9 +199,7 @@
        insert into mm.finished_glass_shelf_log(document_id,document_number,type,glass_shelf_number,glass_shelf_name,quantity,price,money,unit,
                                                remarks,create_time)
        values (
                   #{emitId},#{emitNumber},1, #{finishedGlassShelfEmitDetails.glassShelfNumber},#{finishedGlassShelfEmitDetails.glassShelfName},
               #{finishedGlassShelfEmitDetails.quantity},#{finishedGlassShelfEmitDetails.price},
                #{finishedGlassShelfEmitDetails.money},#{finishedGlassShelfEmitDetails.unit},#{finishedGlassShelfEmitDetails.remarks},now()
                   #{emitId},#{emitNumber},#{type}, #{glassShelfNumber},#{glassShelfName},#{quantity},#{price},#{money},#{unit},#{remarks},now()
               )
    </insert>
@@ -253,8 +256,8 @@
            <if test="emit.operator != null and emit.operator != ''">
                and operator regexp #{emit.operator}
            </if>
            <if test="emit.state != null and emit.state != ''">
                and state regexp #{emit.state}
            <if test="emit.state != null">
                and `state` = #{emit.state}
            </if>
            <if test="emit.remarks != null and emit.remarks != ''">
                and remarks regexp #{emit.remarks}
@@ -284,8 +287,8 @@
            <if test="emit.operator != null and emit.operator != ''">
                and operator regexp #{emit.operator}
            </if>
            <if test="emit.state != null and emit.state != ''">
                and state regexp #{emit.state}
            <if test="emit.state != null">
                and state = #{emit.state}
            </if>
            <if test="emit.remarks != null and emit.remarks != ''">
                and remarks regexp #{emit.remarks}
@@ -295,4 +298,232 @@
    </select>
    <select id="getSelectFinishedGlassShelfWithdrawByemitId">
        select * from
            mm.finished_glass_shelf_withdraw
        where withdraw_id=#{withdrawId}
    </select>
    <select id="getSelectFinishedGlassShelfWithdrawDetailsBywithdrawId1" >
        select * from mm.finished_glass_shelf_withdraw_details where withdraw_id=#{withdrawId}
    </select>
    <select id="getSelectFinishedGlassShelfWithdrawDetailsBywithdrawId" >
        select
            fgw.emit_id as emitId,
            fgw.emit_number as emitNumber,
            fgw.glass_shelf_number as glassShelfNumber,
            fgw.glass_shelf_name as glassShelfName,
            fgw.quantity,
            fge.quantity-fge.withdraw_quantity+fgw.quantity as quantity2,
            fgw.unit,
            fgw.price,
            fgw.money,
            fgw.remarks
        from mm.finished_glass_shelf_withdraw_details fgw
            left join mm.finished_glass_shelf_emit_details fge
                 on fgw.emit_id=fge.emit_id and fgw.emit_number=fge.emit_number
                 where withdraw_id=#{withdrawId}
    </select>
    <select id="getSelectFinishedGlassShelfWithdraw">
        select * from mm.finished_glass_shelf_withdraw
        <where>
            date(create_time)>=#{startDate} and date(create_time) &lt;= #{endDate}
            <if test="withdraw.withdrawId != null and withdraw.withdrawId != ''">
                and withdraw_id regexp #{withdraw.withdrawId}
            </if>
            <if test="withdraw.customerName != null and withdraw.customerName != ''">
                and customer_name regexp #{withdraw.customerName}
            </if>
            <if test="withdraw.project != null and withdraw.project != ''">
                and project regexp #{withdraw.project}
            </if>
            <if test="withdraw.operator != null and withdraw.operator != ''">
                and operator regexp #{withdraw.operator}
            </if>
            <if test="withdraw.remarks != null and withdraw.remarks != ''">
                and remarks regexp #{withdraw.remarks}
            </if>
        </where>
        group by withdraw_id
        limit #{offset},#{pageSize};
    </select>
    <select id="getSelectFinishedGlassShelfWithdrawPageTotal">
        select
        CEILING(count(id)/#{pageSize}) as 'pageTotal',
        count(id) as 'total'
        from mm.finished_glass_shelf_withdraw
        <where>
            date(create_time)>=#{startDate} and date(create_time) &lt;= #{endDate}
            <if test="withdraw.withdrawId != null and withdraw.withdrawId != ''">
                and withdraw_id regexp #{withdraw.withdrawId}
            </if>
            <if test="withdraw.customerName != null and withdraw.customerName != ''">
                and customer_name regexp #{withdraw.customerName}
            </if>
            <if test="withdraw.project != null and withdraw.project != ''">
                and project regexp #{withdraw.project}
            </if>
            <if test="withdraw.operator != null and withdraw.operator != ''">
                and operator regexp #{withdraw.operator}
            </if>
            <if test="withdraw.remarks != null and withdraw.remarks != ''">
                and remarks regexp #{withdraw.remarks}
            </if>
        </where>
        limit #{offset},#{pageSize};
    </select>
    <update id="updateEmitDetailsWithdrawQuantityInt">
        update mm.finished_glass_shelf_emit_details set withdraw_quantity=withdraw_quantity+#{finishedGlassShelfWithdrawDetails.quantity}
        where emit_id=#{finishedGlassShelfWithdrawDetails.emitId} and emit_number=#{finishedGlassShelfWithdrawDetails.emitNumber}
    </update>
    <update id="updateEmitDetailsWithdrawQuantityOut">
        update mm.finished_glass_shelf_emit_details set withdraw_quantity=withdraw_quantity-#{finishedGlassShelfWithdrawDetails.quantity}
        where emit_id=#{finishedGlassShelfWithdrawDetails.emitId} and emit_number=#{finishedGlassShelfWithdrawDetails.emitNumber}
    </update>
    <delete id="deleteFinishedGlassShelfWithdrawDetails"  >
        delete from mm.finished_glass_shelf_withdraw_details  where withdraw_id=#{withdrawId}
    </delete>
    <delete id="deleteFinishedGlassShelfWithdraw"  >
        delete from mm.finished_glass_shelf_withdraw  where withdraw_id=#{withdrawId}
    </delete>
    <update id="updateFinishedGlassShelfWithdraw"  >
        update mm.finished_glass_shelf_withdraw set create_time=now() where withdraw_id=#{withdrawId}
    </update>
    <insert id="insertFinishedGlassShelfWithdraw"  useGeneratedKeys="true" >
        insert into mm.finished_glass_shelf_withdraw(withdraw_id,create_time,customer_name,project,operator,remarks)
        values (
                   #{withdrawId},now(),#{finishedGlassShelfWithdraw.customerName}
               ,#{finishedGlassShelfWithdraw.project},#{finishedGlassShelfWithdraw.operator},#{finishedGlassShelfWithdraw.remarks}
               )
    </insert>
    <insert id="insertFinishedGlassShelfWithdrawDetails"  useGeneratedKeys="true" >
        insert into mm.finished_glass_shelf_withdraw_details(withdraw_id,withdraw_number,emit_id,emit_number,glass_shelf_number,glass_shelf_name,
                                                         quantity,price,unit,money,remarks)
        values (
                   #{withdrawId},#{withdrawNumber},#{finishedGlassShelfWithdrawDetails.emitId},#{finishedGlassShelfWithdrawDetails.emitNumber},
                    #{finishedGlassShelfWithdrawDetails.glassShelfNumber},#{finishedGlassShelfWithdrawDetails.glassShelfName}
                   ,#{finishedGlassShelfWithdrawDetails.quantity},#{finishedGlassShelfWithdrawDetails.price},#{finishedGlassShelfWithdrawDetails.unit},
                   #{finishedGlassShelfWithdrawDetails.money},#{finishedGlassShelfWithdrawDetails.remarks}
               )
    </insert>
    <update id="updateFinishedGlassShelfEmitState">
        update mm.finished_glass_shelf_emit set state=#{state}
        where emit_id=#{emitId}
    </update>
    <select id="getFinishedGlassShelfLogReport">
        select *
        from mm.finished_glass_shelf_log
        <where>
            date(create_time)>=#{startDate} and date(create_time) &lt;= #{endDate} and type=#{type} and state=0
            <if test="finishedGlassShelfLog.documentId != null and finishedGlassShelfLog.documentId != ''">
                and document_id regexp #{finishedGlassShelfLog.documentId}
            </if>
            <if test="finishedGlassShelfLog.documentNumber != null and finishedGlassShelfLog.documentNumber != ''">
                and document_number regexp #{finishedGlassShelfLog.documentNumber}
            </if>
            <if test="finishedGlassShelfLog.glassShelfNumber != null and finishedGlassShelfLog.glassShelfNumber != ''">
                and glass_shelf_number regexp #{finishedGlassShelfLog.glassShelfNumber}
            </if>
            <if test="finishedGlassShelfLog.glassShelfName != null and finishedGlassShelfLog.glassShelfName != ''">
                and glass_shelf_name regexp #{finishedGlassShelfLog.glassShelfName}
            </if>
            <if test="finishedGlassShelfLog.quantity != null and finishedGlassShelfLog.quantity != ''">
                and quantity regexp #{finishedGlassShelfLog.quantity}
            </if>
            <if test="finishedGlassShelfLog.unit != null and finishedGlassShelfLog.unit != ''">
                and unit regexp #{finishedGlassShelfLog.unit}
            </if>
            <if test="finishedGlassShelfLog.price != null and finishedGlassShelfLog.price != ''">
                and price regexp REGEXP_REPLACE(#{finishedGlassShelfLog.price},'\\.0+$','')
            </if>
            <if test="finishedGlassShelfLog.money != null and finishedGlassShelfLog.money != ''">
                and money regexp REGEXP_REPLACE(#{finishedGlassShelfLog.money},'\\.0+$','')
            </if>
            <if test="finishedGlassShelfLog.remarks != null and finishedGlassShelfLog.remarks != ''">
                and remarks regexp #{finishedGlassShelfLog.remarks}
            </if>
            <if test="finishedGlassShelfLog.maxWeight != null and finishedGlassShelfLog.maxWeight != ''">
                and max_weight regexp #{finishedGlassShelfLog.maxWeight}
            </if>
            <if test="finishedGlassShelfLog.maxWidth != null and finishedGlassShelfLog.maxWidth != ''">
                and max_width regexp #{finishedGlassShelfLog.maxWidth}
            </if>
            <if test="finishedGlassShelfLog.maxHeight != null and finishedGlassShelfLog.maxHeight != ''">
                and max_height regexp #{finishedGlassShelfLog.maxHeight}
            </if>
        </where>
        order by id desc
        limit #{offset},#{pageSize};
    </select>
    <select id="getFinishedGlassShelfLogReportTotal">
        select CEILING(count(id)/#{pageSize}) as 'pageTotal',
        count(id) as 'total'
        from finished_glass_shelf_log
        <where>
            date(create_time)>=#{startDate} and date(create_time) &lt;= #{endDate} and type=#{type} and state=0
            <if test="finishedGlassShelfLog.documentId != null and finishedGlassShelfLog.documentId != ''">
                and document_id regexp #{finishedGlassShelfLog.documentId}
            </if>
            <if test="finishedGlassShelfLog.documentNumber != null and finishedGlassShelfLog.documentNumber != ''">
                and document_number regexp #{finishedGlassShelfLog.documentNumber}
            </if>
            <if test="finishedGlassShelfLog.glassShelfNumber != null and finishedGlassShelfLog.glassShelfNumber != ''">
                and glass_shelf_number regexp #{finishedGlassShelfLog.glassShelfNumber}
            </if>
            <if test="finishedGlassShelfLog.glassShelfName != null and finishedGlassShelfLog.glassShelfName != ''">
                and glass_shelf_name regexp #{finishedGlassShelfLog.glassShelfName}
            </if>
            <if test="finishedGlassShelfLog.quantity != null and finishedGlassShelfLog.quantity != ''">
                and quantity regexp #{finishedGlassShelfLog.quantity}
            </if>
            <if test="finishedGlassShelfLog.unit != null and finishedGlassShelfLog.unit != ''">
                and unit regexp #{finishedGlassShelfLog.unit}
            </if>
            <if test="finishedGlassShelfLog.price != null and finishedGlassShelfLog.price != ''">
                and price regexp REGEXP_REPLACE(#{finishedGlassShelfLog.price},'\\.0+$','')
            </if>
            <if test="finishedGlassShelfLog.money != null and finishedGlassShelfLog.money != ''">
                and money regexp REGEXP_REPLACE(#{finishedGlassShelfLog.money},'\\.0+$','')
            </if>
            <if test="finishedGlassShelfLog.remarks != null and finishedGlassShelfLog.remarks != ''">
                and remarks regexp #{finishedGlassShelfLog.remarks}
            </if>
            <if test="finishedGlassShelfLog.maxWeight != null and finishedGlassShelfLog.maxWeight != ''">
                and max_weight regexp #{finishedGlassShelfLog.maxWeight}
            </if>
            <if test="finishedGlassShelfLog.maxWidth != null and finishedGlassShelfLog.maxWidth != ''">
                and max_width regexp #{finishedGlassShelfLog.maxWidth}
            </if>
            <if test="finishedGlassShelfLog.maxHeight != null and finishedGlassShelfLog.maxHeight != ''">
                and max_height regexp #{finishedGlassShelfLog.maxHeight}
            </if>
        </where>
    </select>
    <select id="exportFinishedGlassShelfLogReport">
        select * from mm.finished_glass_shelf_log
        where  date(create_time)>=#{dates[0]} and date(create_time) &lt;= #{dates[1]} and type=#{type} and state=0
    </select>
</mapper>