guoyuji
2024-07-05 4098ea2b95d6da283ac62f2ebb30ce37fe0d6d3f
north-glass-erp/src/main/resources/mapper/pp/FolwCard.xml
@@ -49,6 +49,8 @@
        <result column="g_type" property="glassTypes.type"/>-->
    </resultMap>
    <!--    流程卡管理查询-->
    <select id="selectFlowCard" resultMap="flowCardMap">
        select
@@ -61,8 +63,10 @@
        sum(c.compute_gross_area) as compute_gross_area,
        a.founder,
        c.processing_note,
        b.customer_name,
        if(a.layout_status=0,'不可排版',if(a.layout_status=1,'可排版','已排版')) as layout_status
        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
        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 != ''">
@@ -81,8 +85,18 @@
        <if test="flowCard.order.project != null and flowCard.order.project!= ''">
            and b.project regexp #{flowCard.order.project}
        </if>
        <if test="flowCard.layoutStatus != null and flowCard.layoutStatus != '' and  flowCard.layoutStatus == '不可排版'">
            and a.layout_status regexp 0
        </if>
        <if test="flowCard.layoutStatus != null and flowCard.layoutStatus != '' and  flowCard.layoutStatus == '可排版'">
            and a.layout_status regexp 1
        </if>
        <if test="flowCard.layoutStatus != null and flowCard.layoutStatus != '' and  flowCard.layoutStatus == '已排版'">
            and a.layout_status regexp 2
        </if>
        <if test="flowCard.order.customerName != null and flowCard.order.customerName!= ''">
            and b.customer_name regexp #{flowCard.order.customerName}
        </if>
        group by a.process_Id
        ORDER BY a.id desc
        limit #{offset},#{pageSize};
@@ -99,8 +113,8 @@
        <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}
@@ -111,6 +125,15 @@
        <if test="flowCard.order.project != null and flowCard.order.project!= ''">
            and b.project regexp #{flowCard.order.project}
        </if>
        <if test="flowCard.layoutStatus != null and flowCard.layoutStatus != '' and  flowCard.layoutStatus == '不可排版'">
            and a.layout_status regexp 0
        </if>
        <if test="flowCard.layoutStatus != null and flowCard.layoutStatus != '' and  flowCard.layoutStatus == '可排版'">
            and a.layout_status regexp 1
        </if>
        <if test="flowCard.layoutStatus != null and flowCard.layoutStatus != '' and  flowCard.layoutStatus == '已排版'">
            and a.layout_status regexp 2
        </if>
        ORDER BY a.id desc
@@ -169,17 +192,20 @@
    <!--    分架明细查询-->
    <select id="detailsSelectMp">
        select od.order_id,
        ogd.production_id,
        od.product_id,
        od.product_name,
        SUM( od.quantity) as quantity,
        SUM(od.compute_gross_area) as compute_gross_area,
        sum(od.perimeter) as perimeter
        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
               ogd.production_id,
               od.product_id,
               od.product_name,
               SUM(od.quantity)            as quantity,
               SUM(od.compute_gross_area)  as compute_gross_area,
               round(sum(od.perimeter), 2) as perimeter
        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
        group by od.order_id, ogd.production_id
        order by od.id desc
@@ -192,7 +218,7 @@
                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 ogd.production_id = left(#{processId},11)
          and ogd.production_id = left(#{processId}, 11)
    </update>
@@ -200,7 +226,7 @@
    <update id="deleteFlowCardMp">
        delete
        from flow_card as fc
        where fc.production_id = left(#{processId},11)
        where fc.production_id = left(#{processId}, 11)
    </update>
    <!--    分架新增明细查询-->
@@ -345,13 +371,13 @@
               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 / 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,
                     2)                                               as pendingProductionArea,
               IFNULL(ps.scheduling_quantity, 0)                      as productionScheduledQuantity,
               round(od.width * od.height * (IFNULL(ps.scheduling_quantity, 0)) / 1000000,
                     2)                                                                                     as productionScheduledArea,
                     2)                                               as productionScheduledArea,
               od.product_name,
               od.shape
        from sd.order_detail as od
@@ -387,41 +413,58 @@
               od.product_name,
               ogd.glass_child,
               fc.founder,
               date(fc.splitFrame_time) as splitFrame_time
               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,fc.technology_number
        order by fc.order_number,fc.technology_number
        GROUP BY fc.order_id, fc.process_id, fc.order_number, fc.technology_number
        order by fc.order_number, fc.technology_number
    </select>
    <delete id="deleteReportingWork">
        delete from sd.order_process_detail
        where  left(process_id,11) = left(#{processId},11)
        delete
        from sd.order_process_detail
        where left(process_id, 11) = left(#{processId}, 11)
    </delete>
    <select id="selectPrintFlowCardMp">
        select * from  sd.order where create_time between #{selectTime1} and #{selectTime2} and
                                      position(#{orderId} in order_id ) and position(#{project} in project)
        and processing_card=2
        select *
        from sd.order
        where create_time between #{selectTime1} and #{selectTime2}
          and position(#{orderId} in order_id)
          and position(#{project} in project)
          and processing_card = 2
        order by create_time desc
    </select>
    <select id="selectPrintFlowCard">
        select *
        from pp.optimize_project
        where create_time between #{selectTime1} and #{selectTime2}
          and state >= 20
        order by create_time desc
    </select>
    <select id="selectPrintMp">
        select fc.order_id,
        select fc.id,
               fc.order_id,
               fc.process_id,
               o.customer_name,
               o.project,
               fc.order_number,
               ogd.technology_number,
               ogd.glass_address,
               od.quantity,
               ogd.total_area,
               sum(od.quantity)         as quantity,
               sum(ogd.total_area)      as total_area,
               od.product_name,
               ogd.glass_child,
               fc.founder,
               date(fc.splitFrame_time) as splitFrame_time
               date(fc.splitFrame_time) as splitFrame_time,
              /* if(fc.print_status=0,'未打印','已打印') as  print_status*/
        fc.print_status
        from flow_card as fc
                 left join sd.order_glass_detail as ogd
                           on ogd.order_id = fc.order_id and ogd.order_number = fc.order_number and
@@ -433,4 +476,322 @@
        order by fc.process_id, ogd.technology_number
    </select>
    <select id="getPrimaryList">
        select o.customer_name,
               o.project,
               ogd.process,
               od.edging_type,
               ogd.glass_child,
               od.product_name,
               o.processing_note,
               fc.process_id,
               SUM(od.quantity)                                as quantity,
               round(SUM(ogd.total_area), 2)                   as gross_area,
               sum(od.weight)                   as weight,
               #{technologyNumber}                             as technologyNumber,
               concat(fc.process_id, '/', #{technologyNumber}) as processIdNumber
        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 = fc.order_id and od.order_number = fc.order_number
                 left join sd.`order` as o on o.order_id = fc.order_id
                 left join sd.product as p on p.id=od.product_id
        where fc.process_id = #{processId}
          and fc.technology_number = #{technologyNumber}
        group by fc.process_id, fc.technology_number
    </select>
    <select id="getDetailList">
        select fc.order_number,
               concat(round(ogd.child_width), "*", round(ogd.child_height)) as child_width,
               od.quantity,
               round(ogd.total_area, 2)                                     as total_area,
               od.perimeter,
               od.bend_radius,
               concat(od.processing_note,od.remarks) as remarks
        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 = fc.order_id and od.order_number = fc.order_number
        where fc.process_id = #{processId}
          and fc.technology_number = #{technologyNumber}
        group by fc.process_id, fc.order_number
        order by IF(sort != NULL || sort != '', sort, fc.order_number)
    </select>
    <select id="getProcessList">
        select *
        from sd.order_process_detail
        where process_id = #{processId}
          and technology_number = #{technologyNumber}
        group by process
    </select>
    <update id="updateInventory">
        update flow_card
        set inventory_quantity=#{completedQuantity}
        where process_id = #{processId}
          and order_number = #{orderNumber}
          and technology_number = #{technologyNumber}
    </update>
    <!--    复选框修改排版状态-->
    <update id="updateComposing">
        update flow_card as fc
        set fc.layout_status=1
        where fc.process_id = #{processId}
    </update>
    <select id="getPrintLabel">
        select o.order_id,
               o.customer_name,
               o.project,
               od.building_number,
               od.processing_note,
               od.width,
               od.height,
               ogd.glass_child,
               e.type_name,
               opd.stock_id,
               od.quantity,
               od.other_columns
        from pp.optimize_detail opd
                 left join sd.`order` o on SUBSTR(opd.process_id, 1, 10) = o.order_id
                 left join sd.order_detail od
                           on SUBSTR(opd.process_id, 1, 10) = od.order_id and opd.order_sort = od.order_number
                 left join sd.order_glass_detail ogd
                           on SUBSTR(opd.process_id, 1, 10) = ogd.order_id and opd.order_sort = ogd.order_number
                 left join sd.product p on od.product_id = p.id
                 left join sd.basic_glass_type e on e.type_id = p.type_id
        where opd.project_no = #{projectNo}
        order by opd.stock_id
    </select>
    <select id="getPrintLabel1">
        select o.order_id ,
               o.project,
               o.customer_id ,
               od.width,
               od.height,
               od.quantity,
               od.order_number as orderNumber,
               fc.technology_number as technologyNumber,
               ogd.glass_child,
               c.customer_abbreviation as customer_name,
               ifnull(od.processing_note,'') as processing_note,
               bgt.type_name,
               od.other_columns,
               od.building_number
        from sd.order as o
                 left join sd.order_detail as od on o.order_id = od.order_id
                 left join sd.order_glass_detail as ogd on ogd.order_id=od.order_id and ogd.order_number=od.order_number
                 left join pp.flow_card as fc on o.order_id = fc.order_id and
                                                 od.order_number = fc.order_number and fc.technology_number=ogd.technology_number
                 left join sd.product pt on pt.id=od.product_id
                 left join sd.customer c on c.id=o.customer_id
                 left join sd.basic_glass_type bgt on bgt.type_id=pt.type_id
        where fc.process_id = #{processId}
          and fc.technology_number=#{technologyNumber}
        group by od.order_number,od.width,od.height
    </select>
    <select id="printFlowCardDetailsMp">
        SELECT fc.process_id,
               fc.order_number,
               fc.technology_number,
               ogd.glass_address,
               ogd.child_width,
               ogd.child_height,
               fc.quantity,
               ROUND(ogd.child_width * ogd.child_height * fc.quantity / 1000000, 2) as area,
               fc.sort
        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
        where fc.process_id = #{processId}
          and fc.technology_number = #{technologyNumber}
        order by IF(fc.sort != NULL || fc.sort != '', fc.sort, fc.order_number)
    </select>
    <update id="printSortMp">
        update flow_card
        set sort = #{sort}
        where process_id = #{processId}
          and order_number = #{orderNumber}
          and technology_number = #{technologyNumber}
    </update>
    <select id="selectType">
        select *
        from pp.tag_style
    </select>
    <select id="getPrintTitle">
        select value
        from pp.tag_style as a
        where a.name = #{type}
    </select>
    <select id="getCustomLabelDetailMp">
        select #{name}
        from #{form}
        where order_id = #{id}
    </select>
    <resultMap id="orderDetial" type="com.example.erp.entity.sd.OrderDetail">
        <result column="width" property="width"/>
        <result column="height" property="height"/>
        <result column="order_id" property="order.orderId"/>
        <result column="project" property="order.project"/>
        <result column="customer_id" property="order.customerId"/>
        <result column="customer_name" property="order.customerName"/>
        <result column="order_type" property="order.orderType"/>
        <result column="order_classify" property="order.orderClassify"/>
        <result column="batch" property="order.batch"/>
        <result column="icon" property="order.icon"/>
        <result column="pack_type" property="order.packType"/>
        <result column="delivery_date" property="order.deliveryDate"/>
        <result column="al_type" property="order.alType"/>
        <result column="money" property="order.money"/>
        <result column="contract_id" property="order.contractId"/>
        <result column="customer_batch" property="order.customerBatch"/>
        <result column="contacts" property="order.contacts"/>
        <result column="delivery_address" property="order.deliveryAddress"/>
        <result column="processing_note" property="processingNote"/>
        <result column="quantity" property="quantity"/>
        <result column="edging_type" property="edgingType"/>
        <result column="product_name" property="productName"/>
        <result column="building_number" property="buildingNumber"/>
    </resultMap>
    <select id="getPrintCustomData">
        select o.order_id           as orderId,
               project,
               customer_id          as customerId,
               o.customer_name        as customerName,
               order_type           as orderType,
               order_classify       as orderClassify,
               batch,
               o.icon,
               pack_type            as packType,
               delivery_date        as deliveryDate,
               al_type              as alType,
               money,
               contract_id          as contractId,
               customer_batch          customerBatch,
               contacts,
               delivery_address     as deliveryAddress,
               od.processing_note   as processingNote,
               width,
               height,
               od.quantity,
               od.order_number      as orderNumber,
               fc.technology_number as technologyNumber,
               od.building_number   as buildingNumber,
               od.product_name      as productName,
               od.edging_type       as edgingType,
               p.remarks,
               c.customer_abbreviation as customerAbbreviation,
               od.other_columns
        from sd.order as o
                 left join sd.order_detail as od on o.order_id = od.order_id
                 left join flow_card as fc on o.order_id = fc.order_id and
                                              od.order_number = fc.order_number
                 left join sd.product as p on p.id=od.product_id
                 left join sd.customer as c on c.id = o.customer_id
        where fc.process_id = #{processId}
          and fc.technology_number = #{technologyNumber}
        group by od.order_number, width, height
        order by IF(fc.sort != NULL || fc.sort != '', fc.sort, fc.order_number)
    </select>
    <select id="selectReplenishPrintMp">
        select fc.id,
               fc.order_id,
               fc.process_id,
               o.customer_name,
               o.project,
               fc.order_number,
               ogd.technology_number,
               ogd.glass_address,
               pl.patch_num,
               pl.patch_area,
               pl.responsible_team,
               pl.responsible_equipment,
               pl.responsible_personnel,
               pl.patch_type,
               pl.patch_reason,
               pl.patch_processes,
               od.product_name,
               ogd.glass_child
        from flow_card as fc
                 left join sd.order_glass_detail as ogd
                           on ogd.order_id = fc.order_id and ogd.order_number = fc.order_number and
                              ogd.technology_number = fc.technology_number
                 left join sd.order_detail as od on od.order_id = fc.order_id and od.order_number = fc.order_number
                 left join sd.`order` as o on o.order_id = fc.order_id
                 left join patch_log as pl on pl.order_id = fc.order_id and pl.process_id = fc.process_id and
                                              pl.order_sort = fc.order_number and
                                              pl.technology_number = fc.technology_number
        where pl.create_time between #{selectTime1} and #{selectTime2}
        GROUP BY fc.process_id, ogd.technology_number
        order by fc.process_id, ogd.technology_number
    </select>
    <select id="getRepairPrintCustomData">
        select o.order_id           as orderId,
               project,
               customer_id          as customerId,
               customer_name        as customerName,
               order_type           as orderType,
               order_classify       as orderClassify,
               batch,
               o.icon,
               pack_type            as packType,
               delivery_date        as deliveryDate,
               al_type              as alType,
               money,
               contract_id          as contractId,
               customer_batch          customerBatch,
               contacts,
               delivery_address     as deliveryAddress,
               od.processing_note   as processingNote,
               width,
               height,
               pl.patch_num         as quantity,
               pl.order_sort        as orderNumber,
               pl.technology_number as technologyNumber,
               od.building_number   as buildingNumber,
               od.product_name      as productName,
               od.edging_type       as edgingType
        from sd.order as o
                 left join sd.order_detail as od on o.order_id = od.order_id
                 left join flow_card as fc on o.order_id = fc.order_id and
                                              od.order_number = fc.order_number
                 left join patch_log as pl on pl.process_id = fc.process_id and pl.order_sort = fc.order_number and
                                              pl.technology_number = fc.technology_number
        where pl.process_id = #{processId}
          and pl.technology_number = #{technologyNumber}
        group by od.order_number, width, height
        order by IF(fc.sort != NULL || fc.sort != '', fc.sort, pl.order_sort)
    </select>
    <select id="getGlassNumber">
        select other_columns
        from sd.order_detail as od
                 left join flow_card as fc on od.order_id = fc.order_id and od.order_number = fc.order_number
        where fc.process_id = #{processId}
          and fc.technology_number = #{technologyNumber}
        order by IF(fc.sort != NULL || fc.sort != '', fc.sort, fc.order_number)
    </select>
    <update id="updatePrintStateMp">
        update  pp.flow_card
        set print_status = #{printState}
        where process_id = #{processId} and technology_number = #{technologyNumber}
    </update>
</mapper>