guoyuji
2024-03-13 829ff8fb5991f77b578eb64e88089c41f34aae9e
north-glass-erp/src/main/resources/mapper/pp/FolwCard.xml
@@ -9,6 +9,7 @@
        <result column="quantity" property="quantity"/>
        <result column="founder" property="founder"/>
        <result column="create_time" property="createTime"/>
        <result column="layout_status" property="layoutStatus"/>
        <!--接收其他外键实体类数据-->
        <association property="order" javaType="com.example.erp.entity.sd.Order">
            <result column="project" property="project"/>
@@ -56,18 +57,19 @@
        c.product_id,
        c.product_name,
        b.project,
        a.quantity,
        c.compute_gross_area,
        sum(a.quantity) as quantity,
        sum(c.compute_gross_area) as compute_gross_area,
        a.founder,
        c.processing_note
        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
        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.productionId != null and flowCard.productionId != ''">
                        and a.process_Id regexp #{flowCard.productionId}
                    <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}
@@ -81,7 +83,38 @@
                    </if>
        group by a.process_Id;
        group by a.process_Id
        ORDER BY a.id desc
        limit #{offset},#{pageSize};
    </select>
    <select id="getPageTotal">
        select
        CEILING(count(a.process_Id)/#{pageSize}) as 'pageTotal',
        count(distinct a.process_Id) as 'total'
        from flow_card 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.productionId != null and flowCard.productionId != ''">
            and a.process_Id regexp #{flowCard.productionId}
        </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>
        ORDER BY a.id desc
        limit #{offset},#{pageSize};
    </select>
    <!--分架查询-->
@@ -127,12 +160,13 @@
            and o.salesman regexp #{flowCard.order.salesman}
        </if>
        group by o.order_id
        order by o.id desc
        ;
    </select>
<!--    分架明细查询-->
    <select id="DetailsSelectMp" resultMap="flowCardMap">
    <select id="detailsSelectMp" resultMap="flowCardMap">
        select od.order_id,
        ogd.production_id,
        od.product_id,
@@ -140,11 +174,13 @@
        SUM( od.quantity) as quantity,
        SUM(od.compute_gross_area) as compute_gross_area,
        od.perimeter
        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
        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
        where od.order_id = #{orderId} and ogd.splitting_status=0
        <if test="flowCard.orderDetail.orderId != null and flowCard.orderDetail.orderId != ''">
            and od.order_id regexp #{flowCard.orderDetail.orderId}
        <if test="flowCard.orderId != null and flowCard.orderId != ''">
            and od.order_id regexp #{flowCard.orderId}
        </if>
        <if test="flowCard.orderGlassDetail.productionId != null and flowCard.orderGlassDetail.productionId != ''">
            and ogd.production_id regexp #{flowCard.orderGlassDetail.productionId}
@@ -156,10 +192,11 @@
            and od.product_name regexp #{flowCard.orderDetail.productName}
        </if>
        group by od.order_id, ogd.production_id
        order by od.id desc
    </select>
    <!--    更新分架状态-->
    <update id="UpdateDeleteState">
    <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
@@ -169,14 +206,14 @@
    </update>
    <!--    删除流程卡-->
    <update id="DeleteFlowCardMp">
    <update id="deleteFlowCardMp">
        delete from flow_card as fc where fc.process_id=#{processId}
    </update>
    <!--    分架新增明细查询-->
    <!--resultMap="flowCardMap"-->
    <select id="SelectNoCardMp" >
    <select id="selectNoCardMp" >
        select
        od.order_number,
@@ -197,20 +234,20 @@
        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;
        GROUP BY od.order_number
        order by od.id desc
    </select>
    <!--修改排版状态-->
    <update id="UpdateLayoutStatusMp">
    <update id="updateLayoutStatusMp">
        update flow_card as fc
        set fc.layout_status=2
        set fc.layout_status=#{state}
        where fc.process_id = #{processId}
    </update>
<!--    查询对应流程卡号排版状态-->
    <select id="SelectLayoutStatus">
    <select id="selectLayoutStatus">
        select fc.layout_status
        from flow_card as fc
        where fc.process_id = #{processId}
@@ -218,13 +255,13 @@
    </select>
<!--    查询报工表内是否有对应流程卡-->
    <select id="ReportingWorkCount">
    <select id="reportingWorkCount">
        select COUNT(rw.process_id)
        from reporting_work as rw
        where rw.process_id = #{processId}
    </select>
<!--    插入Flow_card表-->
    <insert id="AddFlowCardMp">
    <insert id="addFlowCardMp">
        insert into
            flow_card (
            order_id,
@@ -260,27 +297,27 @@
    </insert>
<!--    更新分架状态-->
    <update id="UpdateFlowState">
    <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}
    </update>
<!--    查询未分架的条数-->
    <select id="SelectFlowCount">
    <select id="selectFlowCount">
        select COUNT(*)
        from sd.order_glass_detail as ogd
        where ogd.order_id = left(#{productionId},10)
          and ogd.splitting_status = 0
    </select>
<!--   修改订单表分架状态-->
    <update id="UpdateProcessingCard">
    <update id="updateProcessingCard">
        update sd.`order` as o
        set o.processing_card=#{state}
        where o.order_id=left(#{productionId},10)
    </update>
<!--    查询已排版数据-->
    <select id="SelectOkSchedulingMp">
    <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)),
@@ -291,10 +328,10 @@
        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 id="selectNoSchedulingMp">
    </select>
<!--    首次查询排版数据-->
@@ -312,10 +349,14 @@
    </select>
<!--   查询对应序号的层数-->
    <select id="SelectLayer">
    <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}
    </select>
<!--  查询该订单流程卡条数  -->
    <select id="selectFlowCardCount">
        select COUNT(*) from flow_card where order_id=#{orderId}
    </select>
</mapper>