廖井涛
2024-03-15 5a5e59f8aaa2a030511ef245886bf6d1db9bf774
north-glass-erp/src/main/resources/mapper/pp/FolwCard.xml
@@ -62,25 +62,25 @@
        a.founder,
        c.processing_note,
        if(a.layout_status=0,"不可排版",if(a.layout_status=1,"可排版","已排版")) as layout_status
        from flow_card as a left join sd.`order` as b on a.order_Id=b.order_id
        from (select  id,order_id,process_id,order_number, quantity,founder,layout_status,create_time from flow_card group by process_Id,order_number) as a left join sd.`order` as b on a.order_Id=b.order_id
        left join sd.order_detail as c on a.order_Id=c.order_id and a.order_Number=c.order_number
        where a.create_time between #{selectTime1} and #{selectTime2}
                    <if test="flowCard.orderId != null and flowCard.orderId != ''">
                        and a.order_id regexp #{flowCard.orderId}
                    </if>
                    <if test="flowCard.processId != null and flowCard.processId != ''">
                        and a.process_Id regexp #{flowCard.processId}
                    </if>
                    <if test="flowCard.orderDetail.productId != null and flowCard.orderDetail.productId != ''">
                        and c.product_id regexp #{flowCard.orderDetail.productId}
                    </if>
                    <if test="flowCard.orderDetail.productName != null and flowCard.orderDetail.productName!= ''">
                        and c.product_name regexp #{flowCard.orderDetail.productName}
                    </if>
        <if test="flowCard.orderId != null and flowCard.orderId != ''">
            and a.order_id regexp #{flowCard.orderId}
        </if>
        <if test="flowCard.processId != null and flowCard.processId != ''">
            and a.process_Id regexp #{flowCard.processId}
        </if>
        <if test="flowCard.orderDetail.productId != null and flowCard.orderDetail.productId != ''">
            and c.product_id regexp #{flowCard.orderDetail.productId}
        </if>
        <if test="flowCard.orderDetail.productName != null and flowCard.orderDetail.productName!= ''">
            and c.product_name regexp #{flowCard.orderDetail.productName}
        </if>
                    <if test="flowCard.order.project != null and flowCard.order.project!= ''">
                        and b.project regexp #{flowCard.order.project}
                    </if>
        <if test="flowCard.order.project != null and flowCard.order.project!= ''">
            and b.project regexp #{flowCard.order.project}
        </if>
        group by a.process_Id
@@ -131,7 +131,8 @@
        o.delivery_address
        from sd.`order` as o
        left join sd.order_glass_detail ogd on o.order_id = ogd.order_id
        where o.production_order=2 and ogd.splitting_status=0 and o.create_time between #{selectTime1} and #{selectTime2}
        where o.production_order=2 and ogd.splitting_status=0 and o.create_time between #{selectTime1} and
        #{selectTime2}
        <if test="flowCard.order.orderId != null and flowCard.order.orderId != ''">
            and o.order_id regexp #{flowCard.order.orderId}
@@ -165,7 +166,7 @@
        ;
    </select>
<!--    分架明细查询-->
    <!--    分架明细查询-->
    <select id="detailsSelectMp" resultMap="flowCardMap">
        select od.order_id,
        ogd.production_id,
@@ -174,7 +175,7 @@
        SUM( od.quantity) as quantity,
        SUM(od.compute_gross_area) as compute_gross_area,
        od.perimeter
        from  sd.order_detail as od left join
        from sd.order_detail as od left join
        (select order_id,order_number,production_id,splitting_status from sd.order_glass_detail
        GROUP BY order_id,order_number
        ) as ogd on od.order_id=ogd.order_id and od.order_number=ogd.order_number
@@ -199,43 +200,47 @@
    <update id="updateDeleteState">
        update
            sd.order_glass_detail as ogd left join flow_card as fc
                on ogd.order_id=fc.order_id and ogd.order_number=fc.order_number
                on ogd.order_id = fc.order_id and ogd.order_number = fc.order_number
        set ogd.splitting_status=0
        where ogd.order_id=#{orderId}  and fc.process_id=#{processId}
        where ogd.order_id = #{orderId}
          and fc.process_id = #{processId}
    </update>
    <!--    删除流程卡-->
    <update id="deleteFlowCardMp">
        delete from flow_card as fc where fc.process_id=#{processId}
        delete
        from flow_card as fc
        where fc.production_id = left(#{processId},11)
    </update>
    <!--    分架新增明细查询-->
    <!--resultMap="flowCardMap"-->
    <select id="selectNoCardMp" >
    <select id="selectNoCardMp">
        select
        od.order_number,
        od.order_number AS 'orderNumber',
        od.width,
        od.height,
        od.shape,
        od.quantity,
        od.compute_gross_area,
        p.total_thickness,
        od.quantity as baiscQuantity,
        od.compute_gross_area as 'computeGrossArea',
        p.total_thickness AS 'totalThickness',
        p.thickness,
        od.weight
        from
        sd.order_detail as od
        left join sd.order_glass_detail as ogd on od.order_id=ogd.order_id and od.order_number=ogd.order_number
        left join sd.product as p on od.product_name=p.product_name
        where od.order_id=#{orderId} and ogd.production_id=#{productionId} and ogd.splitting_status=0
        select od.order_number,
               od.order_number       AS 'orderNumber',
               od.width,
               od.height,
               od.shape,
               od.quantity,
               od.compute_gross_area,
               p.total_thickness,
               od.quantity           as baiscQuantity,
               od.compute_gross_area as 'computeGrossArea',
               p.total_thickness     AS 'totalThickness',
               p.thickness,
               od.weight
        from sd.order_detail as od
                 left join sd.order_glass_detail as ogd
                           on od.order_id = ogd.order_id and od.order_number = ogd.order_number
                 left join sd.product as p on od.product_name = p.product_name
        where od.order_id = #{orderId}
          and ogd.production_id = #{productionId}
          and ogd.splitting_status = 0
        GROUP BY od.order_number
        order by od.id desc
        order by od.id
    </select>
@@ -246,7 +251,7 @@
        where fc.process_id = #{processId}
    </update>
<!--    查询对应流程卡号排版状态-->
    <!--    查询对应流程卡号排版状态-->
    <select id="selectLayoutStatus">
        select fc.layout_status
        from flow_card as fc
@@ -254,109 +259,153 @@
        LIMIT 1
    </select>
<!--    查询报工表内是否有对应流程卡-->
    <!--    查询报工表内是否有对应流程卡-->
    <select id="reportingWorkCount">
        select COUNT(rw.process_id)
        from reporting_work as rw
        where rw.process_id = #{processId}
    </select>
<!--    插入Flow_card表-->
    <!--    插入Flow_card表-->
    <insert id="addFlowCardMp">
        insert into
            flow_card (
            order_id,
            production_id,
            process_id,
            landing_sequence,
            order_number,
            technology_number,
            quantity,
            founder,
            layers_number,
            splitFrame_time,
            create_time
        )
        select
            ogd.order_id,
            ogd.production_id,
            #{processId},
            #{landingSequence},
            ogd.order_number,
            ogd.technology_number,
            #{quantity},
            #{userName},
            #{layer},
            NOW(),
            NOW()
        insert into flow_card (order_id,
                               production_id,
                               process_id,
                               landing_sequence,
                               order_number,
                               technology_number,
                               quantity,
                               founder,
                               layers_number,
                               splitFrame_time,
                               create_time)
        select ogd.order_id,
               ogd.production_id,
               #{processId},
               #{landingSequence},
               ogd.order_number,
               ogd.technology_number,
               #{quantity},
               #{userName},
               #{layer},
               NOW(),
               NOW()
        from sd.order_glass_detail as ogd
        where ogd.production_id=#{productionId} and ogd.order_number=#{orderNumber}
        where ogd.production_id = #{productionId}
          and ogd.order_number = #{orderNumber}
        GROUP BY ogd.technology_number
    </insert>
<!--    更新分架状态-->
    <!--    更新分架状态-->
    <update id="updateFlowState">
        update sd.order_glass_detail as ogd
        set ogd.splitting_status=1
        where ogd.production_id=#{productionId} and ogd.order_number=#{orderNumber}
        where ogd.production_id = #{productionId}
          and ogd.order_number = #{orderNumber}
    </update>
<!--    查询未分架的条数-->
    <!--    查询未分架的条数-->
    <select id="selectFlowCount">
        select COUNT(*)
        from sd.order_glass_detail as ogd
        where ogd.order_id = left(#{productionId},10)
        where ogd.order_id = left(#{productionId}, 10)
          and ogd.splitting_status = 0
    </select>
<!--   修改订单表分架状态-->
    <!--   修改订单表分架状态-->
    <update id="updateProcessingCard">
        update sd.`order` as o
        set o.processing_card=#{state}
        where o.order_id=left(#{productionId},10)
        where o.order_id = left(#{productionId}, 10)
    </update>
<!--    查询已排版数据-->
    <!--    查询已排版数据-->
    <select id="selectOkSchedulingMp">
        select od.order_id,o.customer_name,o.project,od.order_number,od.width,od.height,od.quantity,
               round(od.width*od.height*od.quantity/1000000,2),
               (od.quantity-IFNULL(ps.scheduling_quantity,0)),
               round(od.width*od.height*(od.quantity-IFNULL(ps.scheduling_quantity,0))/1000000,2),
               IFNULL(ps.scheduling_quantity,0),
               round(od.width*od.height*(IFNULL(ps.scheduling_quantity,0))/1000000,2),
               od.product_name,od.shape
        from sd.order_detail as od left join sd.order as o on od.order_id=o.order_id
                                   left join production_scheduling as ps on ps.order_id=od.order_id and ps.order_number=od.order_number
        where od.order_id=#{orderId} and ps.processes=#{processes} and ps.scheduling_id IS NOT NULL
        select od.order_id,
               o.customer_name,
               o.project,
               od.order_number,
               od.width,
               od.height,
               od.quantity,
               round(od.width * od.height * od.quantity / 1000000, 2),
               (od.quantity - IFNULL(ps.scheduling_quantity, 0)),
               round(od.width * od.height * (od.quantity - IFNULL(ps.scheduling_quantity, 0)) / 1000000, 2),
               IFNULL(ps.scheduling_quantity, 0),
               round(od.width * od.height * (IFNULL(ps.scheduling_quantity, 0)) / 1000000, 2),
               od.product_name,
               od.shape
        from sd.order_detail as od
                 left join sd.order as o on od.order_id = o.order_id
                 left join production_scheduling as ps
                           on ps.order_id = od.order_id and ps.order_number = od.order_number
        where od.order_id = #{orderId}
          and ps.processes = #{processes}
          and ps.scheduling_id IS NOT NULL
        order by ps.id desc
    </select>
<!--    查询未排版数据-->
    <!--    查询未排版数据-->
    <select id="selectNoSchedulingMp">
    </select>
<!--    首次查询排版数据-->
    <!--    首次查询排版数据-->
    <select id="selectLastSchedulingMp">
        select od.order_id,o.customer_name,o.project,od.order_number,od.width,od.height,od.quantity,
               round(od.width*od.height*od.quantity/1000000,2) as area,
               (od.quantity-IFNULL(ps.scheduling_quantity,0)) as pendingProductionQuantity,
               round(od.width*od.height*(od.quantity-IFNULL(ps.scheduling_quantity,0))/1000000,2) as pendingProductionArea,
               IFNULL(ps.scheduling_quantity,0) as productionScheduledQuantity,
               round(od.width*od.height*(IFNULL(ps.scheduling_quantity,0))/1000000,2) as productionScheduledArea,
               od.product_name,od.shape
        from sd.order_detail as od left join sd.order as o on od.order_id=o.order_id
                                   left join production_scheduling as ps on ps.order_id=od.order_id and ps.order_number=od.order_number
        select od.order_id,
               o.customer_name,
               o.project,
               od.order_number,
               od.width,
               od.height,
               od.quantity,
               round(od.width * od.height * od.quantity / 1000000, 2)                                       as area,
               (od.quantity - IFNULL(ps.scheduling_quantity, 0))                                            as pendingProductionQuantity,
               round(od.width * od.height * (od.quantity - IFNULL(ps.scheduling_quantity, 0)) / 1000000,
                     2)                                                                                     as pendingProductionArea,
               IFNULL(ps.scheduling_quantity, 0)                                                            as productionScheduledQuantity,
               round(od.width * od.height * (IFNULL(ps.scheduling_quantity, 0)) / 1000000,
                     2)                                                                                     as productionScheduledArea,
               od.product_name,
               od.shape
        from sd.order_detail as od
                 left join sd.order as o on od.order_id = o.order_id
                 left join production_scheduling as ps
                           on ps.order_id = od.order_id and ps.order_number = od.order_number
        where od.create_time between #{selectTime1} and #{selectTime2}
    </select>
<!--   查询对应序号的层数-->
    <!--   查询对应序号的层数-->
    <select id="selectLayer">
        select COUNT(ogd.order_number)
        from sd.order_glass_detail as ogd
        where ogd.production_id = #{productionId}
          and ogd.order_number=#{orderNumber}
          and ogd.order_number = #{orderNumber}
    </select>
<!--  查询该订单流程卡条数  -->
    <!--  查询该订单流程卡条数  -->
    <select id="selectFlowCardCount">
        select COUNT(*) from flow_card where order_id=#{orderId}
        select COUNT(*)
        from flow_card
        where order_id = #{orderId}
    </select>
    <select id="flowCardDetailMp">
        select fc.order_id,
               fc.process_id,
               fc.order_number,
               fc.quantity,
               round(ogd.child_width * ogd.child_height * fc.quantity / 1000000, 2) as area,
               od.product_name,
               fc.founder,
               date(fc.splitFrame_time) as splitFrame_time
        from flow_card as fc
                 left join sd.order_glass_detail as ogd
                           on fc.order_id = ogd.order_id and fc.order_number = ogd.order_number and
                              fc.technology_number = ogd.technology_number
                 left join sd.order_detail as od on od.order_id = ogd.order_id and od.order_number = ogd.order_number
        where fc.process_id = #{processId}
        GROUP BY fc.order_id, fc.process_id, fc.order_number
    </select>
    <delete id="deleteReportingWork">
        delete from sd.order_process_detail
        where  left(process_id,11) = left(#{processId},11)
    </delete>
</mapper>