north-glass-erp/src/main/resources/mapper/pp/Report.xml
@@ -50,19 +50,21 @@
    </resultMap>
    <resultMap id="damageDetailsTableMap" type="com.example.erp.entity.pp.DamageDetails">
    <resultMap id="damageDetailsTableMap" type="com.example.erp.dto.pp.CrossProcessBreakingDTO">
        <result column="responsible_process" property="responsibleProcess"/>
        <result column="responsible_team" property="responsibleTeam"/>
        <result column="breakage_type" property="breakageType"/>
        <result column="breakage_reason" property="breakageReason"/>
        <result column="breakage_quantity" property="breakageQuantity"/>
        <result column="area" property="area"/>
            <result column="reporting_work_id" property="reportingWork.reportingWorkId"/>
            <result column="reporting_work_time" property="reportingWork.reportingWorkTime"/>
            <result column="this_process" property="reportingWork.thisProcess"/>
            <result column="project" property="order.project"/>
            <result column="order_id" property="order.orderId"/>
            <result column="glass_child" property="orderGlassDetail.glassChild"/>
        <result column="reporting_work_time" property="reportingWorkTime"/>
        <result column="this_process" property="thisProcess"/>
        <result column="project" property="project"/>
        <result column="order_id" property="orderId"/>
        <result column="glass_child" property="glassChild"/>
        <result column="process_id" property="processId"/>
        <result column="code" property="code"/>
        <result column="responsible_personnel" property="responsiblePersonnel"/>
    </resultMap>
@@ -91,6 +93,7 @@
        <result column="area" property="area"/>
        <result column="breakage_quantity" property="breakageQuantity"/>
        <result column="project" property="project"/>
        <result column="batch" property="batch"/>
        <result column="process_id" property="processId"/>
        <result column="order_number" property="orderNumber"/>
        <result column="technology_number" property="technologyNumber"/>
@@ -101,25 +104,111 @@
        <result column="breakage_reason" property="breakageReason"/>
        <result column="personnel" property="personnel"/>
        <result column="glass_child" property="glassChild"/>
        <result column="glassNumber" property="glassNumber"/>
        <result column="child_width" property="childWidth"/>
        <result column="child_height" property="childHeight"/>
        <result column="this_process" property="thisProcess"/>
        <result column="creator" property="creator"/>
    </resultMap>
    <resultMap id="teamOutputMap" type="com.example.erp.dto.pp.TeamOutputDTO">
        <result column="reporting_work_time" property="reportingWorkTime"/>
        <result column="this_process" property="thisProcess"/>
        <result column="teams_groups_name" property="teamsGroupsName"/>
        <result column="project" property="project"/>
        <result column="process_id" property="processId"/>
        <result column="order_number" property="orderNumber"/>
        <result column="width" property="width"/>
        <result column="height" property="height"/>
        <result column="shape" property="shape"/>
        <result column="thickness" property="thickness"/>
        <result column="edging_type" property="edgingType"/>
        <result column="completed_quantity" property="completedQuantity"/>
        <result column="area" property="area"/>
        <result column="product_name" property="productName"/>
        <result column="code" property="code"/>
        <result column="reviewed" property="reviewed"/>
        <result column="examine_time" property="examineTime"/>
        <result column="workProcessName" property="workProcessName"/>
        <result column="device_name" property="deviceName"/>
        <result column="order_type" property="orderType"/>
        <result column="thicknessSum" property="thicknessSum"/>
        <result column="thicknessArea" property="thicknessArea"/>
    </resultMap>
<!--    流程卡进度-->
    <resultMap id="scheduleProductionScheduleMap" type="com.example.erp.dto.pp.ScheduleProductionScheduleDTO">
        <result column="order_id" property="orderId"/>
        <result column="project" property="project"/>
        <result column="processes" property="processes"/>
        <result column="scheduling_quantity" property="schedulingQuantity"/>
        <result column="notes" property="notes"/>
        <result column="scheduled_start_time" property="scheduledStartTime"/>
        <result column="plan_end_time" property="planEndTime"/>
    </resultMap>
    <resultMap id="workInProgressMap" type="com.example.erp.dto.pp.WorkInProgressDTO">
        <result column="thisProcess" property="thisProcess"/>
        <result column="order_id" property="orderId"/>
        <result column="process_id" property="processId"/>
        <result column="customer_name" property="customerName"/>
        <result column="project" property="project"/>
        <result column="batch" property="batch"/>
        <result column="order_number" property="orderNumber"/>
        <result column="technology_number" property="technologyNumber"/>
        <result column="shape" property="shape"/>
        <result column="process" property="process"/>
        <result column="quantity" property="quantity"/>
        <result column="child_width" property="childWidth"/>
        <result column="child_height" property="childHeight"/>
        <result column="stockNum" property="stockNum"/>
        <result column="stockArea" property="stockArea"/>
        <result column="product_name" property="productName"/>
        <result column="bend_radius" property="bendRadius"/>
        <result column="glassNumber" property="glassNumber"/>
        <result column="teams_groups_name" property="teamsGroupsName"/>
    </resultMap>
    <!--    流程卡进度-->
    <select id="processCardProgressMp">
        select a.product_name,
               b.glass_child,
               d.order_type,
               concat(c.process_id, '/', c.technology_number) as process_id,
               c.process_id as 'processId',
               c.order_id,
               c.order_number,
               c.technology_number,
               c.quantity,
               b.child_width,
               b.child_height,
              if(c.technology_number=1,c.quantity-ifnull(c.termination_quantity,0),0) as quantity,
               c.quantity-ifnull(c.termination_quantity,0) as thisQuantity,/*用于判断是否改变颜色*/
               e.reportWorkQuantity,
               e.reportWorkQuantityShow,
               e.reportWorkQuantityCount,
               e.reportWorkTime,
               e.broken_num,
               ifnull(f.inventory, 0)                         as inventory,
               round(ifnull(f.inventory, 0) * a.area, 2)      as inventoryArea,
               ifnull(dd.quantity, 0)                         as shippedQuantity
        from flow_card as c
               c.quantity-ifnull(c.termination_quantity,0) as glassQuantity,
               c.quantity-ifnull(c.termination_quantity,0) as quantityShow,
               round( (c.quantity-ifnull(c.termination_quantity,0))*a.compute_area,2) as grossAreaShow,
               ifnull(c.received_quantity, 0) as StorageShow,
               ifnull(dd.quantity, 0) as shippedQuantityShow, -- 发货数量
               round(ifnull(dd.quantity, 0)*a.compute_area,2) as shippedAreaShow, -- 发货面积
               round((ifnull(c.received_quantity, 0))*a.compute_area,2)  as StorageAreaShow,-- 入库面积
               if(c.technology_number=1, round((c.quantity-ifnull(c.termination_quantity,0))*a.compute_area,2),0) as grossArea,
               if(c.technology_number=1,ifnull(c.received_quantity, 0) ,0)                        as Storage,
               if(c.technology_number=1,ifnull(dd.quantity, 0) ,0)                          as shippedQuantity,
               if(c.technology_number=1,round(ifnull(dd.quantity, 0)*a.compute_area,2),0)         as shippedArea,
               if(c.technology_number=1, round((ifnull(c.received_quantity, 0))*a.compute_area,2),0)  as StorageArea,
               ifnull(JSON_UNQUOTE(JSON_EXTRACT(a.other_columns, '$.S01')),'') AS glassNumber,
               b.`group`,
               c.termination_status
        from pp.flow_card as c
                 left join
             sd.order_detail as a
             on c.order_id = a.order_id
@@ -130,28 +219,41 @@
                               and c.technology_number = b.technology_number
                 left join sd.`order` as d
                           on c.order_id = d.order_id
                 left join mm.finished_goods_inventory as f
                           on c.order_id = f.order_id and f.order_number = c.order_number
#                  left join mm.finished_goods_inventory as f
#                            on c.order_id = f.order_id and f.order_number = c.order_number
                 left join sd.delivery_detail as dd on dd.order_id = a.order_id and dd.order_number = a.order_number
                 left join (SELECT process_id,
                                   order_number,
                                   technology_number,
                                   sum(a.broken_num) as broken_num,
                                   concat('{',
                                          GROUP_CONCAT(concat("\"", process, "\":\"", reporting_work_num, "\"")),
                                          GROUP_CONCAT(concat("\"", process, "\":\"", if(technology_number!=1 and (bd.nickname='stepD' || bd.nickname='stepB' ) ,0,reporting_work_num), "\"")),
                                          '}'
                                       )             as reportWorkQuantity,
                                   concat('{',
                                          GROUP_CONCAT(concat("\"", process, "\":\"", reporting_work_num, "\"")),
                                          '}'
                                       )             as reportWorkQuantityShow,
                                   concat('{',
                                          GROUP_CONCAT(concat("\"", process, "\":\"", reporting_work_num_count, "\"")),
                                          '}'
                                       )             as reportWorkQuantityCount
                                       )             as reportWorkQuantityCount,
                                   concat('{',
                                          GROUP_CONCAT(concat("\"", process, "\":\"", IFNULL(date(update_time),''), "\"")),
                                          '}'
                                       )             as reportWorkTime
                            FROM sd.order_process_detail as a
                            left join (SELECT DISTINCT basic_name,nickname from sd.basic_data as bd where  bd.basic_category = 'process') as bd
                            on a.process = bd.basic_name
                            where a.order_id = #{orderId}
                            GROUP BY process_id, a.order_number, a.technology_number) as e
                               on e.process_id = c.process_id
                            GROUP BY process_id, a.order_number, a.technology_number
                            ) as e
                           on e.process_id = c.process_id
                               and e.technology_number = c.technology_number
                               and e.order_number = c.order_number
        where a.order_id = #{orderId}
        where a.order_id = #{orderId} and d.create_order>0
        group by c.order_number,
                 c.technology_number,
                 c.process_id
@@ -159,185 +261,458 @@
    </select>
    <select id="getProcessBreaking" resultMap="damageDetailsTableMap">
        select rw.reporting_work_id,rw.reporting_work_time,dd.responsible_process,dd.responsible_team,
               dd.breakage_type,dd.breakage_reason,ROUND((dd.breakage_quantity)) as breakage_quantity,
               round(ogd.child_width*ogd.child_height*(dd.breakage_quantity)/1000000,2) as area,rw.this_process,
               o.project,o.order_id,ogd.glass_child
        select rw.reporting_work_id,
               rw.reporting_work_time,
               dd.responsible_process,
               dd.responsible_team,
               dd.breakage_type,
               dd.breakage_reason,
               dd.responsible_personnel,
               ROUND((dd.breakage_quantity))                                                   as breakage_quantity,
               round(ogd.child_width * ogd.child_height * (dd.breakage_quantity) / 1000000, 2) as area,
               rw.this_process,
               o.project,
               o.order_id,
               ogd.glass_child,
               rw.this_process,
               JSON_UNQUOTE( JSON_EXTRACT( od.other_columns, '$.S01' )) AS code,
               CONCAT(rw.process_id,'/',GROUP_CONCAT(distinct dd.technology_number SEPARATOR '')) as process_id,
               rw.creator,
               rw.reporting_work_id
        from
            damage_details as dd
                left join reporting_work as rw
                    on rw.reporting_work_id=dd.reporting_work_id
                left join sd.order as o
                    on rw.order_id=o.order_id
                left join sd.order_glass_detail as ogd
                          on ogd.order_id=o.order_id and ogd.order_number=dd.order_number
                                 and ogd.technology_number and dd.technology_number
        where date(rw.reporting_work_time)>=#{startDate} and date(rw.reporting_work_time) &lt;= #{endDate}
          and rw.this_worn_quantity>0 and dd.available=0
          and reviewed_state!=2
            and rw.this_process!=dd.responsible_process
            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.reporting_work as rw on rw.order_id=o.order_id
                             left join pp.damage_details as dd on dd.reporting_work_id=rw.reporting_work_id and dd.order_number=ogd.order_number
            and dd.technology_number=ogd.technology_number
        where (rw.reporting_work_time) >= #{startDate}
          and (rw.reporting_work_time) &lt;= #{endDate}
          and rw.this_worn_quantity > 0
          and dd.available = 0
          and reviewed_state >-1
          and rw.this_process != dd.responsible_process
        and o.create_order>0
        <if test="crossProcessBreakingDTO.code != null and crossProcessBreakingDTO.code != ''">
            and JSON_UNQUOTE( JSON_EXTRACT( od.other_columns, '$.S01' )) like concat('%', #{crossProcessBreakingDTO.code}, '%')
        </if>
        <if test="crossProcessBreakingDTO.processId != null and crossProcessBreakingDTO.processId != ''">
            and rw.process_id  like concat('%', #{crossProcessBreakingDTO.processId}, '%')
        </if>
        <if test="crossProcessBreakingDTO.thisProcess != null and crossProcessBreakingDTO.thisProcess != ''">
            and rw.this_process  like concat('%', #{crossProcessBreakingDTO.thisProcess}, '%')
        </if>
        <if test="crossProcessBreakingDTO.responsibleProcess != null and crossProcessBreakingDTO.responsibleProcess != ''">
            and dd.responsible_process like concat('%', #{crossProcessBreakingDTO.responsibleProcess}, '%')
        </if>
        <if test="crossProcessBreakingDTO.responsibleTeam != null and crossProcessBreakingDTO.responsibleTeam != ''">
            and dd.responsible_team like concat('%', #{crossProcessBreakingDTO.responsibleTeam}, '%')
        </if>
        <if test="crossProcessBreakingDTO.glassChild != null and crossProcessBreakingDTO.glassChild != ''">
            and ogd.glass_child like concat('%', #{crossProcessBreakingDTO.glassChild}, '%')
        </if>
        <if test="crossProcessBreakingDTO.breakageType != null and crossProcessBreakingDTO.breakageType != ''">
            and dd.breakage_type like concat('%', #{crossProcessBreakingDTO.breakageType}, '%')
        </if>
        <if test="crossProcessBreakingDTO.project != null and crossProcessBreakingDTO.project != ''">
            and o.project like concat('%', #{crossProcessBreakingDTO.project}, '%')
        </if>
        <if test="crossProcessBreakingDTO.orderId != null and crossProcessBreakingDTO.orderId != ''">
            and o.order_id like concat('%', #{crossProcessBreakingDTO.orderId}, '%')
        </if>
        <if test="crossProcessBreakingDTO.responsiblePersonnel != null and crossProcessBreakingDTO.responsiblePersonnel != ''">
            and dd.responsible_personnel like concat('%', #{crossProcessBreakingDTO.responsiblePersonnel}, '%')
        </if>
        <if test="crossProcessBreakingDTO.creator != null and crossProcessBreakingDTO.creator != ''">
            and rw.creator like concat('%', #{crossProcessBreakingDTO.creator}, '%')
        </if>
        <if test="crossProcessBreakingDTO.code != null and crossProcessBreakingDTO.code != ''">
            and ifnull(JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')),'') like concat('%', #{crossProcessBreakingDTO.code}, '%')
        </if>
        <if test="crossProcessBreakingDTO.reportingWorkId != null and crossProcessBreakingDTO.reportingWorkId != ''">
            and rw.reporting_work_id like concat('%', #{crossProcessBreakingDTO.reportingWorkId}, '%')
        </if>
        GROUP BY dd.id
        order by dd.id desc
        limit #{offset},#{pageSize}
    </select>
    <select id="getNotProcessBreaking" resultMap="damageDetailsTableMap">
        select rw.reporting_work_id,
        rw.reporting_work_time,
        dd.responsible_process,
        dd.responsible_team,
        dd.breakage_type,
        dd.breakage_reason,
        dd.responsible_personnel,
        ROUND((dd.breakage_quantity))                                                   as breakage_quantity,
        round(ogd.child_width * ogd.child_height * (dd.breakage_quantity) / 1000000, 2) as area,
        rw.this_process,
        o.project,
        o.order_id,
        ogd.glass_child,
        rw.this_process,
        JSON_UNQUOTE( JSON_EXTRACT( od.other_columns, '$.S01' )) AS code,
        CONCAT(rw.process_id,'/',GROUP_CONCAT(distinct dd.technology_number SEPARATOR '')) as process_id,
        rw.creator,
        rw.reporting_work_id
        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.reporting_work as rw on rw.order_id=o.order_id
        left join pp.damage_details as dd on dd.reporting_work_id=rw.reporting_work_id and dd.order_number=ogd.order_number
        and dd.technology_number=ogd.technology_number
        where (rw.reporting_work_time) >= #{startDate}
        and (rw.reporting_work_time) &lt;= #{endDate}
        and rw.this_worn_quantity > 0
        and dd.available = 0
        and reviewed_state >-1
        and rw.this_process = dd.responsible_process
        and o.create_order>0
        <if test="crossProcessBreakingDTO.code != null and crossProcessBreakingDTO.code != ''">
            and JSON_UNQUOTE( JSON_EXTRACT( od.other_columns, '$.S01' )) like concat('%', #{crossProcessBreakingDTO.code}, '%')
        </if>
        <if test="crossProcessBreakingDTO.processId != null and crossProcessBreakingDTO.processId != ''">
            and rw.process_id  like concat('%', #{crossProcessBreakingDTO.processId}, '%')
        </if>
        <if test="crossProcessBreakingDTO.thisProcess != null and crossProcessBreakingDTO.thisProcess != ''">
            and rw.this_process  like concat('%', #{crossProcessBreakingDTO.thisProcess}, '%')
        </if>
        <if test="crossProcessBreakingDTO.responsibleProcess != null and crossProcessBreakingDTO.responsibleProcess != ''">
            and dd.responsible_process like concat('%', #{crossProcessBreakingDTO.responsibleProcess}, '%')
        </if>
        <if test="crossProcessBreakingDTO.responsibleTeam != null and crossProcessBreakingDTO.responsibleTeam != ''">
            and dd.responsible_team like concat('%', #{crossProcessBreakingDTO.responsibleTeam}, '%')
        </if>
        <if test="crossProcessBreakingDTO.glassChild != null and crossProcessBreakingDTO.glassChild != ''">
            and ogd.glass_child like concat('%', #{crossProcessBreakingDTO.glassChild}, '%')
        </if>
        <if test="crossProcessBreakingDTO.breakageType != null and crossProcessBreakingDTO.breakageType != ''">
            and dd.breakage_type like concat('%', #{crossProcessBreakingDTO.breakageType}, '%')
        </if>
        <if test="crossProcessBreakingDTO.project != null and crossProcessBreakingDTO.project != ''">
            and o.project like concat('%', #{crossProcessBreakingDTO.project}, '%')
        </if>
        <if test="crossProcessBreakingDTO.orderId != null and crossProcessBreakingDTO.orderId != ''">
            and o.order_id like concat('%', #{crossProcessBreakingDTO.orderId}, '%')
        </if>
        <if test="crossProcessBreakingDTO.responsiblePersonnel != null and crossProcessBreakingDTO.responsiblePersonnel != ''">
            and dd.responsible_personnel like concat('%', #{crossProcessBreakingDTO.responsiblePersonnel}, '%')
        </if>
        <if test="crossProcessBreakingDTO.creator != null and crossProcessBreakingDTO.creator != ''">
            and rw.creator like concat('%', #{crossProcessBreakingDTO.creator}, '%')
        </if>
        <if test="crossProcessBreakingDTO.code != null and crossProcessBreakingDTO.code != ''">
            and ifnull(JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')),'') like concat('%', #{crossProcessBreakingDTO.code}, '%')
        </if>
        <if test="crossProcessBreakingDTO.reportingWorkId != null and crossProcessBreakingDTO.reportingWorkId != ''">
            and rw.reporting_work_id like concat('%', #{crossProcessBreakingDTO.reportingWorkId}, '%')
        </if>
        GROUP BY dd.id
        order by dd.id desc
        limit #{offset},#{pageSize}
    </select>
    <select id="getProcessBreakingTotal">
        select
            CEILING(count(dd.id)/#{pageSize}) as 'pageTotal',
            count(distinct dd.id) as 'total'
        from
            damage_details as dd
                left join reporting_work as rw
                          on rw.reporting_work_id=dd.reporting_work_id
                left join sd.order as o
                          on rw.order_id=o.order_id
                left join sd.order_glass_detail as ogd
                          on ogd.order_id=o.order_id and ogd.order_number=dd.order_number
                              and ogd.technology_number and dd.technology_number
        where date(rw.reporting_work_time)>=#{startDate} and date(rw.reporting_work_time) &lt;= #{endDate}
          and rw.this_worn_quantity>0 and dd.available=0
          and reviewed_state!=2
          and rw.this_process!=dd.responsible_process
        select CEILING(count(dd.id) / #{pageSize}) as 'pageTotal',
               count(distinct dd.id)               as 'total'
        from pp.damage_details as dd
                 left join pp.reporting_work as rw
                           on rw.reporting_work_id = dd.reporting_work_id
                 left join sd.order as o
                           on rw.order_id = o.order_id
                 left join sd.order_glass_detail as ogd
                           on ogd.order_id = o.order_id and ogd.order_number = dd.order_number
                               and ogd.technology_number and dd.technology_number
        left join sd.order_detail as od on o.order_id = od.order_id and od.order_number=ogd.order_number
        where (rw.reporting_work_time) >= #{startDate}
          and (rw.reporting_work_time) &lt;= #{endDate}
          and rw.this_worn_quantity > 0
          and dd.available = 0
          and rw.reviewed_state>=0
          and rw.this_process != dd.responsible_process
        <if test="crossProcessBreakingDTO.code != null and crossProcessBreakingDTO.code != ''">
            and JSON_UNQUOTE( JSON_EXTRACT( od.other_columns, '$.S01' )) like concat('%', #{crossProcessBreakingDTO.code}, '%')
        </if>
        <if test="crossProcessBreakingDTO.processId != null and crossProcessBreakingDTO.processId != ''">
            and rw.process_id  like concat('%', #{crossProcessBreakingDTO.processId}, '%')
        </if>
        <if test="crossProcessBreakingDTO.thisProcess != null and crossProcessBreakingDTO.thisProcess != ''">
            and rw.this_process  like concat('%', #{crossProcessBreakingDTO.thisProcess}, '%')
        </if>
        <if test="crossProcessBreakingDTO.responsibleProcess != null and crossProcessBreakingDTO.responsibleProcess != ''">
            and dd.responsible_process like concat('%', #{crossProcessBreakingDTO.responsibleProcess}, '%')
        </if>
        <if test="crossProcessBreakingDTO.responsibleTeam != null and crossProcessBreakingDTO.responsibleTeam != ''">
            and dd.responsible_team like concat('%', #{crossProcessBreakingDTO.responsibleTeam}, '%')
        </if>
        <if test="crossProcessBreakingDTO.glassChild != null and crossProcessBreakingDTO.glassChild != ''">
            and ogd.glass_child like concat('%', #{crossProcessBreakingDTO.glassChild}, '%')
        </if>
        <if test="crossProcessBreakingDTO.breakageType != null and crossProcessBreakingDTO.breakageType != ''">
            and dd.breakage_type like concat('%', #{crossProcessBreakingDTO.breakageType}, '%')
        </if>
        <if test="crossProcessBreakingDTO.project != null and crossProcessBreakingDTO.project != ''">
            and o.project like concat('%', #{crossProcessBreakingDTO.project}, '%')
        </if>
        <if test="crossProcessBreakingDTO.orderId != null and crossProcessBreakingDTO.orderId != ''">
            and o.order_id like concat('%', #{crossProcessBreakingDTO.orderId}, '%')
        </if>
        <if test="crossProcessBreakingDTO.responsiblePersonnel != null and crossProcessBreakingDTO.responsiblePersonnel != ''">
            and dd.responsible_personnel like concat('%', #{crossProcessBreakingDTO.responsiblePersonnel}, '%')
        </if>
        <if test="crossProcessBreakingDTO.creator != null and crossProcessBreakingDTO.creator != ''">
            and rw.creator like concat('%', #{crossProcessBreakingDTO.creator}, '%')
        </if>
        <if test="crossProcessBreakingDTO.code != null and crossProcessBreakingDTO.code != ''">
            and ifnull(JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')),'') like concat('%', #{crossProcessBreakingDTO.code}, '%')
        </if>
        <if test="crossProcessBreakingDTO.reportingWorkId != null and crossProcessBreakingDTO.reportingWorkId != ''">
            and rw.reporting_work_id like concat('%', #{crossProcessBreakingDTO.reportingWorkId}, '%')
        </if>
        order by dd.id desc
    </select>
    <select id="workInProgressMp">
        select #{selectProcesses} as thisProcess,
               fc.process_id,
               o.customer_name,
               o.project,
               o.order_id,
               o.batch,
               od.shape,
               ogd.order_number,
               ogd.technology_number,
               ogd.process,
               od.quantity,
               ogd.child_width,
               ogd.child_height,
               odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count -
               odpd.broken_num as stockNum,
               ROUND(ogd.child_width * ogd.child_height *
                     (odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count -
                      odpd.broken_num) / 1000000, 2) as stockArea,
               od.product_name,
               od.bend_radius
        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 flow_card AS fc
                           ON fc.order_id = ogd.order_id
                               and fc.production_id = ogd.production_id
                               AND fc.order_number = ogd.order_number
                               AND fc.technology_number = ogd.technology_number
                 left join sd.order_process_detail as odpd
                           ON odpd.order_id = fc.order_id
                               AND odpd.order_number = fc.order_number
                               AND odpd.technology_number = fc.technology_number
                               and odpd.process_id = fc.process_id
                 left join sd.order_process_detail as odpds
                           ON odpds.id = odpd.id - 1
                 left join
             (SELECT sum(rw.rework_num) as 'patchNumSum',
                     rw.process_id,
                     rw.order_sort,
                     rw.technology_number,
                     rwk.this_process
              from rework as rw
                       LEFT JOIN
                   reporting_work as rwk
                   on rw.reporting_work_id = rwk.reporting_work_id
              where rwk.this_process = #{selectProcesses}
                and rw.review_status = 1
              GROUP BY rw.process_id, rw.order_sort, rw.technology_number) as c
             on c.process_id = fc.process_id
                 and c.order_sort = fc.order_number
                 and c.technology_number = fc.technology_number
                 left join sd.`order` as o
                           on o.order_id = od.order_id
        where LENGTH(fc.process_id) = 14
          and odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count -
              odpd.broken_num != 0
          and odpd.process = #{selectProcesses} and o.create_time between #{selectTime1} and #{selectTime2}
          and position(#{orderId} in od.order_id) and position(#{inputProject} in o.project)
        group by fc.process_id, fc.order_number, fc.technology_number
        order by fc.process_id, fc.order_number, fc.technology_number
    <select id="getNotProcessBreakingTotal">
        select CEILING(count(dd.id) / #{pageSize}) as 'pageTotal',
        count(distinct dd.id)               as 'total'
        from pp.damage_details as dd
        left join pp.reporting_work as rw
        on rw.reporting_work_id = dd.reporting_work_id
        left join sd.order as o
        on rw.order_id = o.order_id
        left join sd.order_glass_detail as ogd
        on ogd.order_id = o.order_id and ogd.order_number = dd.order_number
        and ogd.technology_number and dd.technology_number
        left join sd.order_detail as od on o.order_id = od.order_id and od.order_number=ogd.order_number
        where (rw.reporting_work_time) >= #{startDate}
        and (rw.reporting_work_time) &lt;= #{endDate}
        and rw.this_worn_quantity > 0
        and dd.available = 0
        and reviewed_state != 2
        and rw.this_process = dd.responsible_process
        <if test="crossProcessBreakingDTO.code != null and crossProcessBreakingDTO.code != ''">
            and JSON_UNQUOTE( JSON_EXTRACT( od.other_columns, '$.S01' )) like concat('%', #{crossProcessBreakingDTO.code}, '%')
        </if>
        <if test="crossProcessBreakingDTO.processId != null and crossProcessBreakingDTO.processId != ''">
            and rw.process_id  like concat('%', #{crossProcessBreakingDTO.processId}, '%')
        </if>
        <if test="crossProcessBreakingDTO.thisProcess != null and crossProcessBreakingDTO.thisProcess != ''">
            and rw.this_process  like concat('%', #{crossProcessBreakingDTO.thisProcess}, '%')
        </if>
        <if test="crossProcessBreakingDTO.responsibleProcess != null and crossProcessBreakingDTO.responsibleProcess != ''">
            and dd.responsible_process like concat('%', #{crossProcessBreakingDTO.responsibleProcess}, '%')
        </if>
        <if test="crossProcessBreakingDTO.responsibleTeam != null and crossProcessBreakingDTO.responsibleTeam != ''">
            and dd.responsible_team like concat('%', #{crossProcessBreakingDTO.responsibleTeam}, '%')
        </if>
        <if test="crossProcessBreakingDTO.glassChild != null and crossProcessBreakingDTO.glassChild != ''">
            and ogd.glass_child like concat('%', #{crossProcessBreakingDTO.glassChild}, '%')
        </if>
        <if test="crossProcessBreakingDTO.breakageType != null and crossProcessBreakingDTO.breakageType != ''">
            and dd.breakage_type like concat('%', #{crossProcessBreakingDTO.breakageType}, '%')
        </if>
        <if test="crossProcessBreakingDTO.project != null and crossProcessBreakingDTO.project != ''">
            and o.project like concat('%', #{crossProcessBreakingDTO.project}, '%')
        </if>
        <if test="crossProcessBreakingDTO.orderId != null and crossProcessBreakingDTO.orderId != ''">
            and o.order_id like concat('%', #{crossProcessBreakingDTO.orderId}, '%')
        </if>
        <if test="crossProcessBreakingDTO.responsiblePersonnel != null and crossProcessBreakingDTO.responsiblePersonnel != ''">
            and dd.responsible_personnel like concat('%', #{crossProcessBreakingDTO.responsiblePersonnel}, '%')
        </if>
        <if test="crossProcessBreakingDTO.creator != null and crossProcessBreakingDTO.creator != ''">
            and rw.creator like concat('%', #{crossProcessBreakingDTO.creator}, '%')
        </if>
        <if test="crossProcessBreakingDTO.code != null and crossProcessBreakingDTO.code != ''">
            and ifnull(JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')),'') like concat('%', #{crossProcessBreakingDTO.code}, '%')
        </if>
        <if test="crossProcessBreakingDTO.reportingWorkId != null and crossProcessBreakingDTO.reportingWorkId != ''">
            and rw.reporting_work_id like concat('%', #{crossProcessBreakingDTO.reportingWorkId}, '%')
        </if>
        order by dd.id desc
    </select>
    <!--
    <if test="Report.processId != null and Report.processId != ''">
            and fc.process_id regexp #{Report.processId}
        </if>
        <if test="Report.customerName != null and Report.customerName != ''">
            and o.customer_name regexp #{Report.customerName}
        </if>
        <if test="Report.project != null and Report.project != ''">
            and o.project regexp #{Report.project}
        </if>
        <if test="Report.batch != null and Report.batch != ''">
            and o.batch regexp #{Report.batch}
        </if>
        <if test="Report.shape != null and Report.shape != ''">
            and od.shape regexp #{Report.shape}
        </if>
    -->
    <select id="workInProgressMp" resultMap="workInProgressMap">
        select #{selectProcesses} as thisProcess,
        fc.process_id,
        o.customer_name,
        o.project,
        o.order_id,
        o.batch,
        if(od.shape='' || ISNULL(od.shape),'普形',if(od.shape = 1, '普形', if(od.shape = 2, '异形', ''))) as shape,
        if(od.shape=2,JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S04')),od.bend_radius) as bend_radius,
        ogd.order_number,
        ogd.technology_number,
        ogd.process,
        od.quantity,
        ogd.child_width,
        ogd.child_height,
        odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count -
        odpd.broken_num as stockNum,
        ROUND(ogd.child_width * ogd.child_height *
        (odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count -
        odpd.broken_num) / 1000000, 2) as stockArea,
        od.product_name,
        od.bend_radius,
        ifnull(JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')),'') AS glassNumber,
        rws.teams_groups_name
<!--     <select id="getWorkInProgressTotal">-->
<!--        select CEILING(count(fc.id) / #{pageSize}) as 'pageTotal',-->
<!--               count(distinct fc.id)               as 'total'-->
        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 flow_card AS fc
        ON fc.order_id = ogd.order_id
        and fc.production_id = ogd.production_id
        AND fc.order_number = ogd.order_number
        AND fc.technology_number = ogd.technology_number
        left join sd.order_process_detail as odpd
        ON odpd.order_id = fc.order_id
        AND odpd.order_number = fc.order_number
        AND odpd.technology_number = fc.technology_number
        and odpd.process_id = fc.process_id
        left join sd.order_process_detail as odpds
        ON odpds.id = odpd.id - 1
        left join
        (SELECT sum(rw.rework_num) as 'patchNumSum',
        rw.process_id,
        rw.order_sort,
        rw.technology_number,
        rwk.this_process
        from rework as rw
        LEFT JOIN
        reporting_work as rwk
        on rw.reporting_work_id = rwk.reporting_work_id
        where rwk.this_process = #{selectProcesses}
        and rw.review_status >= 0
        GROUP BY rw.process_id, rw.order_sort, rw.technology_number) as c
        on c.process_id = fc.process_id
        and c.order_sort = fc.order_number
        and c.technology_number = fc.technology_number
        left join sd.`order` as o
        on o.order_id = od.order_id
        left join
        (
        select a.process_id,a.teams_groups_name,a.next_process,b.technology_number,b.order_number
        from reporting_work  as a
        left join reporting_work_detail as b on a.reporting_work_id=b.reporting_work_id
        GROUP BY a.process_id,a.teams_groups_name,a.next_process,b.order_number,b.technology_number
        ) as rws on rws.process_id=fc.process_id and rws.order_number=fc.order_number
                        and  rws.technology_number=fc.technology_number and rws.next_process=#{selectProcesses}
        where  o.create_order>0
        and odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count -
        odpd.broken_num != 0
        and odpd.process = #{selectProcesses}
        and position(#{orderId} in od.order_id)
        and position(#{inputProject} in o.project)
        <if test="workInProgressDTO.customerName != null and workInProgressDTO.customerName != ''">
            and o.customer_name regexp #{workInProgressDTO.customerName}
        </if>
        <if test="workInProgressDTO.project != null and workInProgressDTO.project != ''">
            and o.project regexp #{workInProgressDTO.project}
        </if>
        <if test="workInProgressDTO.orderId != null and workInProgressDTO.orderId != ''">
            and o.order_id regexp #{workInProgressDTO.orderId}
        </if>
        <if test="workInProgressDTO.batch != null and workInProgressDTO.batch != ''">
            and o.batch regexp #{workInProgressDTO.batch}
        </if>
        <if test="workInProgressDTO.processId != null and workInProgressDTO.processId != ''">
            and fc.process_id regexp #{workInProgressDTO.processId}
        </if>
        <if test="workInProgressDTO.orderNumber != null and workInProgressDTO.orderNumber != ''">
            and ogd.order_number regexp #{workInProgressDTO.orderNumber}
        </if>
        <if test="workInProgressDTO.technologyNumber != null and workInProgressDTO.technologyNumber != ''">
            and ogd.technology_number regexp #{workInProgressDTO.technologyNumber}
        </if>
        <if test="workInProgressDTO.glassNumber != null and workInProgressDTO.glassNumber != ''">
            and ifnull(JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')),'') regexp #{workInProgressDTO.glassNumber}
        </if>
        group by fc.process_id, fc.order_number, fc.technology_number
        order by fc.process_id, fc.order_number, fc.technology_number
        limit #{offset},#{pageSize};
    </select>
<!--        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 flow_card AS fc-->
<!--                           ON fc.order_id = ogd.order_id-->
<!--                               and fc.production_id = ogd.production_id-->
<!--                               AND fc.order_number = ogd.order_number-->
<!--                               AND fc.technology_number = ogd.technology_number-->
<!--                 left join sd.order_process_detail as odpd-->
<!--                           ON odpd.order_id = fc.order_id-->
<!--                               AND odpd.order_number = fc.order_number-->
<!--                               AND odpd.technology_number = fc.technology_number-->
<!--                               and odpd.process_id = fc.process_id-->
<!--                 left join sd.order_process_detail as odpds-->
<!--                           ON odpds.id = odpd.id - 1-->
<!--                 left join-->
<!--             (SELECT sum(rw.rework_num) as 'patchNumSum',-->
<!--                     rw.process_id,-->
<!--                     rw.order_sort,-->
<!--                     rw.technology_number,-->
<!--                     rwk.this_process-->
<!--              from rework as rw-->
<!--                       LEFT JOIN-->
<!--                   reporting_work as rwk-->
<!--                   on rw.reporting_work_id = rwk.reporting_work_id-->
<!--              where rwk.this_process = #{selectProcesses}-->
<!--                and rw.review_status = 1-->
<!--              GROUP BY rw.process_id, rw.order_sort, rw.technology_number) as c-->
<!--             on c.process_id = fc.process_id-->
<!--                 and c.order_sort = fc.order_number-->
<!--                 and c.technology_number = fc.technology_number-->
<!--                 left join sd.`order` as o-->
<!--                           on o.order_id = od.order_id-->
<!--        where LENGTH(fc.process_id) = 14-->
<!--          and odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count - -->
<!--              odpd.broken_num != 0-->
<!--          and odpd.process = #{selectProcesses}-->
<!--          and o.create_time between #{selectTime1} and #{selectTime2}-->
<!--          and position(#{orderId} in od.order_id)-->
<!--          and position(#{inputProject} in o.project)-->
<!--        group by fc.process_id, fc.order_number, fc.technology_number-->
<!--        order by fc.process_id, fc.order_number, fc.technology_number-->
<!--        limit #{offset},#{pageSize};-->
<!--    </select>-->
    <select id="workInProgressTotal">
        select CEILING(count(fc.id)/#{pageSize}) as 'pageTotal',
        count(distinct fc.id) as 'total'
        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 flow_card AS fc
        ON fc.order_id = ogd.order_id
        and fc.production_id = ogd.production_id
        AND fc.order_number = ogd.order_number
        AND fc.technology_number = ogd.technology_number
        left join sd.order_process_detail as odpd
        ON odpd.order_id = fc.order_id
        AND odpd.order_number = fc.order_number
        AND odpd.technology_number = fc.technology_number
        and odpd.process_id = fc.process_id
        left join sd.order_process_detail as odpds
        ON odpds.id = odpd.id - 1
        left join
        (SELECT sum(rw.rework_num) as 'patchNumSum',
        rw.process_id,
        rw.order_sort,
        rw.technology_number,
        rwk.this_process
        from rework as rw
        LEFT JOIN
        reporting_work as rwk
        on rw.reporting_work_id = rwk.reporting_work_id
        where rwk.this_process = #{selectProcesses}
        and rw.review_status >= 0
        GROUP BY rw.process_id, rw.order_sort, rw.technology_number) as c
        on c.process_id = fc.process_id
        and c.order_sort = fc.order_number
        and c.technology_number = fc.technology_number
        left join sd.`order` as o
        on o.order_id = od.order_id
        left join
        (
        select a.process_id,a.teams_groups_name,a.next_process,b.technology_number,b.order_number
        from reporting_work  as a
        left join reporting_work_detail as b on a.reporting_work_id=b.reporting_work_id
        GROUP BY a.process_id,a.teams_groups_name,a.next_process,b.order_number,b.technology_number
        ) as rws on rws.process_id=fc.process_id and rws.order_number=fc.order_number
        and  rws.technology_number=fc.technology_number and rws.next_process=#{selectProcesses}
        where  o.create_order>0
        and odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count -
        odpd.broken_num != 0
        and odpd.process = #{selectProcesses}
        and position(#{orderId} in od.order_id)
        and position(#{inputProject} in o.project)
        <if test="workInProgressDTO.customerName != null and workInProgressDTO.customerName != ''">
            and o.customer_name regexp #{workInProgressDTO.customerName}
        </if>
        <if test="workInProgressDTO.project != null and workInProgressDTO.project != ''">
            and o.project regexp #{workInProgressDTO.project}
        </if>
        <if test="workInProgressDTO.orderId != null and workInProgressDTO.orderId != ''">
            and o.order_id regexp #{workInProgressDTO.orderId}
        </if>
        <if test="workInProgressDTO.batch != null and workInProgressDTO.batch != ''">
            and o.batch regexp #{workInProgressDTO.batch}
        </if>
        <if test="workInProgressDTO.processId != null and workInProgressDTO.processId != ''">
            and fc.process_id regexp #{workInProgressDTO.processId}
        </if>
        <if test="workInProgressDTO.orderNumber != null and workInProgressDTO.orderNumber != ''">
            and ogd.order_number regexp #{workInProgressDTO.orderNumber}
        </if>
        <if test="workInProgressDTO.technologyNumber != null and workInProgressDTO.technologyNumber != ''">
            and ogd.technology_number regexp #{workInProgressDTO.technologyNumber}
        </if>
        limit #{offset},#{pageSize};
    </select>
    <select id="processToBeCompletedMp">
        select DATE(o.create_time) as create_time,
               DATE(o.delivery_date) as delivery_date,
        select DATE(o.create_time)                                                  as create_time,
               DATE(o.delivery_date)                                                as delivery_date,
               o.order_id,
               fc.process_id,
               o.customer_name,
@@ -348,16 +723,17 @@
               ogd.glass_child,
               ogd.child_width,
               ogd.child_height,
               od.quantity,
               ROUND(ogd.child_width * ogd.child_height / 1000000, 2)                 as childArea,
               ROUND(ogd.child_width * ogd.child_height * od.quantity / 1000000, 2)   as actualArea,
               odpd.reporting_work_num                                                as completeNum,
               fc.quantity - ifnull(fc.termination_quantity,0) as quantity,
               ROUND(ogd.child_width * ogd.child_height / 1000000, 2)               as childArea,
               ROUND(ogd.child_width * ogd.child_height * (fc.quantity- ifnull(fc.termination_quantity,0)) / 1000000, 2) as actualArea,
               odpd.reporting_work_num                                              as completeNum,
               ROUND(ogd.child_width * ogd.child_height * odpd.reporting_work_num / 1000000,
                     2)                                                               as completeArea,
               od.quantity - odpd.reporting_work_num                                  as incompleteNum,
               ROUND(ogd.child_width * ogd.child_height * (od.quantity - odpd.reporting_work_num) / 1000000,
                     2)                                                               as incompleteArea,
               od.product_name
                     2)                                                             as completeArea,
               fc.quantity - odpd.reporting_work_num - ifnull(fc.termination_quantity,0)      as incompleteNum,
               ROUND(ogd.child_width * ogd.child_height * (fc.quantity - odpd.reporting_work_num- ifnull(fc.termination_quantity,0)) / 1000000,
                     2)                                                             as incompleteArea,
               od.product_name,
               JSON_UNQUOTE(JSON_EXTRACT(pd.separation, '$.thickness')) AS thickness
        from sd.order_detail AS od
                 LEFT JOIN sd.order_glass_detail AS ogd
@@ -375,12 +751,15 @@
                               and odpd.process_id = fc.process_id
                 left join sd.`order` as o
                           on o.order_id = od.order_id
        where LENGTH(fc.process_id) = 14
                 left join sd.product_detail as pd on pd.prod_id=od.product_id
        where  o.create_order>0
          and odpd.process = #{selectProcesses}
          and o.create_time between #{selectTime1} and #{selectTime2}
          and  o.create_time >= #{selectTime1}
          AND o.create_time &lt;  #{selectTime2}
          and position(#{orderId} in od.order_id)
          and position(#{inputProject} in o.project)
          and od.quantity > odpd.reporting_work_num
          and GREATEST(fc.quantity - odpd.reporting_work_num, 0)>0
          and fc.quantity-ifnull(fc.termination_quantity,0)>0
        group by fc.process_id, fc.order_number, fc.technology_number
        order by fc.process_id, fc.order_number, fc.technology_number
@@ -388,64 +767,94 @@
    <select id="selectDamageReportMp" resultMap="damageReportMap">
        SELECT
            o.order_id,
            o.project,
            rw.process_id,
            dd.order_number,
            dd.technology_number,
            date(rw.reporting_work_time) as reporting_work_time,
            dd.responsible_process,
            dd.responsible_team,
            dd.responsible_equipment,
            dd.breakage_type,
            dd.breakage_reason,
            dd.breakage_quantity,
            round( ogd.child_width * ogd.child_height * dd.breakage_quantity / 1000000, 2 ) as area,
            IFNULL(dd.responsible_personnel,'') as personnel,
            ogd.glass_child
        o.order_id,
        o.project,
        o.batch,
        rw.process_id,
        dd.order_number,
        dd.technology_number,
        rw.reporting_work_time as reporting_work_time,
        dd.responsible_process,
        dd.responsible_team,
        dd.responsible_equipment,
        dd.breakage_type,
        dd.breakage_reason,
        dd.breakage_quantity,
        round( ogd.child_width * ogd.child_height * dd.breakage_quantity / 1000000, 2 ) as area,
        IFNULL(dd.responsible_personnel,'') as personnel,
        ogd.glass_child,
        ogd.child_width,
        ogd.child_height,
        ifnull(JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')),'') AS glassNumber,
        rw.this_process,
        rw.creator,
        rw.reporting_work_id
        FROM
            sd.ORDER AS o
                LEFT JOIN sd.order_glass_detail AS ogd ON ogd.order_id = o.order_id
                LEFT JOIN reporting_work AS rw ON rw.order_id = o.order_id
                LEFT JOIN damage_details AS dd ON dd.reporting_work_id = rw.reporting_work_id
                AND dd.order_number = ogd.order_number
                AND dd.technology_number = ogd.technology_number
        sd.ORDER AS o
        LEFT JOIN sd.order_glass_detail AS ogd ON ogd.order_id = o.order_id
        LEFT JOIN pp.reporting_work AS rw ON rw.order_id = o.order_id
        LEFT JOIN pp.damage_details AS dd ON dd.reporting_work_id = rw.reporting_work_id
        AND dd.order_number = ogd.order_number
        AND dd.technology_number = ogd.technology_number
        left join sd.order_detail as od on o.order_id = od.order_id and od.order_number=ogd.order_number
        WHERE
            rw.reporting_work_time between #{selectTime1} and #{selectTime2}
          AND dd.available = 0
          AND LENGTH( rw.process_id )= 14
        rw.reporting_work_time >= #{selectTime1}
        AND rw.reporting_work_time &lt;=  #{selectTime2}
        AND dd.available = 0 and rw.reviewed_state>=0
        <if test="damageReportDTO.orderId != null and damageReportDTO.orderId != ''">
            and o.order_id regexp #{damageReportDTO.orderId}
            and o.order_id like concat('%', #{damageReportDTO.orderId}, '%')
        </if>
        <if test="damageReportDTO.project != null and damageReportDTO.project != ''">
            and o.project regexp #{damageReportDTO.project}
            and o.project like concat('%', #{damageReportDTO.project}, '%')
        </if>
        <if test="damageReportDTO.processId != null and damageReportDTO.processId != ''">
            and rw.process_id regexp #{damageReportDTO.processId}
            and rw.process_id like concat('%', #{damageReportDTO.processId}, '%')
        </if>
        <if test="damageReportDTO.orderNumber != null and damageReportDTO.orderNumber != ''">
            and dd.order_number regexp #{damageReportDTO.orderNumber}
            and dd.order_number like concat('%', #{damageReportDTO.orderNumber}, '%')
        </if>
        <if test="damageReportDTO.technologyNumber != null and damageReportDTO.technologyNumber != ''">
            and dd.technology_number regexp #{damageReportDTO.technologyNumber}
            and dd.technology_number like concat('%', #{damageReportDTO.technologyNumber}, '%')
        </if>
        <if test="damageReportDTO.responsibleProcess != null and damageReportDTO.responsibleProcess != ''">
            and dd.responsible_process regexp #{damageReportDTO.responsibleProcess}
            and dd.responsible_process like concat('%', #{damageReportDTO.responsibleProcess}, '%')
        </if>
        <if test="damageReportDTO.responsibleTeam != null and damageReportDTO.responsibleTeam != ''">
            and dd.responsible_team regexp #{damageReportDTO.responsibleTeam}
            and dd.responsible_team like concat('%', #{damageReportDTO.responsibleTeam}, '%')
        </if>
        <if test="damageReportDTO.responsibleEquipment != null and damageReportDTO.responsibleEquipment != ''">
            and dd.responsible_equipment regexp #{damageReportDTO.responsibleEquipment}
            and dd.responsible_equipment like concat('%', #{damageReportDTO.responsibleEquipment}, '%')
        </if>
        <if test="damageReportDTO.breakageType != null and damageReportDTO.breakageType != ''">
            and dd.breakage_type regexp #{damageReportDTO.breakageType}
            and dd.breakage_type like concat('%', #{damageReportDTO.breakageType}, '%')
        </if>
        <if test="damageReportDTO.breakageReason != null and damageReportDTO.breakageReason != ''">
            and dd.breakage_reason regexp #{damageReportDTO.breakageReason}
            and dd.breakage_reason like concat('%', #{damageReportDTO.breakageReason}, '%')
        </if>
        <if test="damageReportDTO.glassChild != null and damageReportDTO.glassChild != ''">
            and ogd.glass_child like concat('%', #{damageReportDTO.glassChild}, '%')
        </if>
        <if test="damageReportDTO.glassNumber != null and damageReportDTO.glassNumber != ''">
            and ifnull(JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')),'') like concat('%', #{damageReportDTO.glassNumber}, '%')
        </if>
        <if test="damageReportDTO.thisProcess != null and damageReportDTO.thisProcess != ''">
            and rw.this_process like concat('%', #{damageReportDTO.thisProcess}, '%')
        </if>
        <if test="damageReportDTO.creator != null and damageReportDTO.creator != ''">
            and rw.creator like concat('%', #{damageReportDTO.creator}, '%')
        </if>
        <if test="damageReportDTO.reportingWorkId != null and damageReportDTO.reportingWorkId != ''">
            and rw.reporting_work_id like concat('%', #{damageReportDTO.reportingWorkId}, '%')
        </if>
        <if test="damageReportDTO.childWidth != null and damageReportDTO.childWidth != ''">
            and ogd.child_width regexp REGEXP_REPLACE(#{damageReportDTO.childWidth},'\\.0+$','')
        </if>
        <if test="damageReportDTO.childHeight != null and damageReportDTO.childHeight != ''">
            and ogd.child_height regexp REGEXP_REPLACE(#{damageReportDTO.childHeight},'\\.0+$','')
        </if>
        GROUP BY
            dd.id
        dd.id
        limit #{offset},#{pageSize};
    </select>
@@ -456,73 +865,94 @@
        FROM
        sd.ORDER AS o
        LEFT JOIN sd.order_glass_detail AS ogd ON ogd.order_id = o.order_id
        LEFT JOIN reporting_work AS rw ON rw.order_id = o.order_id
        LEFT JOIN damage_details AS dd ON dd.reporting_work_id = rw.reporting_work_id
        LEFT JOIN pp.reporting_work AS rw ON rw.order_id = o.order_id
        LEFT JOIN pp.damage_details AS dd ON dd.reporting_work_id = rw.reporting_work_id
        AND dd.order_number = ogd.order_number
        AND dd.technology_number = ogd.technology_number
        left join sd.order_detail as od on o.order_id = od.order_id and od.order_number=ogd.order_number
        WHERE
        rw.reporting_work_time between #{selectTime1} and #{selectTime2}
        AND dd.available = 0
        AND LENGTH( rw.process_id )= 14
        rw.reporting_work_time >= #{selectTime1}
        AND rw.reporting_work_time &lt;=  #{selectTime2}
        AND dd.available = 0 and rw.reviewed_state>=0
        <if test="damageReportDTO.orderId != null and damageReportDTO.orderId != ''">
            and o.order_id regexp #{damageReportDTO.orderId}
            and o.order_id like concat('%', #{damageReportDTO.orderId}, '%')
        </if>
        <if test="damageReportDTO.project != null and damageReportDTO.project != ''">
            and o.project regexp #{damageReportDTO.project}
            and o.project like concat('%', #{damageReportDTO.project}, '%')
        </if>
        <if test="damageReportDTO.processId != null and damageReportDTO.processId != ''">
            and rw.process_id regexp #{damageReportDTO.processId}
            and rw.process_id like concat('%', #{damageReportDTO.processId}, '%')
        </if>
        <if test="damageReportDTO.orderNumber != null and damageReportDTO.orderNumber != ''">
            and dd.order_number regexp #{damageReportDTO.orderNumber}
            and dd.order_number like concat('%', #{damageReportDTO.orderNumber}, '%')
        </if>
        <if test="damageReportDTO.technologyNumber != null and damageReportDTO.technologyNumber != ''">
            and dd.technology_number regexp #{damageReportDTO.technologyNumber}
            and dd.technology_number like concat('%', #{damageReportDTO.technologyNumber}, '%')
        </if>
        <if test="damageReportDTO.responsibleProcess != null and damageReportDTO.responsibleProcess != ''">
            and dd.responsible_process regexp #{damageReportDTO.responsibleProcess}
            and dd.responsible_process like concat('%', #{damageReportDTO.responsibleProcess}, '%')
        </if>
        <if test="damageReportDTO.responsibleTeam != null and damageReportDTO.responsibleTeam != ''">
            and dd.responsible_team regexp #{damageReportDTO.responsibleTeam}
            and dd.responsible_team like concat('%', #{damageReportDTO.responsibleTeam}, '%')
        </if>
        <if test="damageReportDTO.responsibleEquipment != null and damageReportDTO.responsibleEquipment != ''">
            and dd.responsible_equipment regexp #{damageReportDTO.responsibleEquipment}
            and dd.responsible_equipment like concat('%', #{damageReportDTO.responsibleEquipment}, '%')
        </if>
        <if test="damageReportDTO.breakageType != null and damageReportDTO.breakageType != ''">
            and dd.breakage_type regexp #{damageReportDTO.breakageType}
            and dd.breakage_type like concat('%', #{damageReportDTO.breakageType}, '%')
        </if>
        <if test="damageReportDTO.breakageReason != null and damageReportDTO.breakageReason != ''">
            and dd.breakage_reason regexp #{damageReportDTO.breakageReason}
            and dd.breakage_reason like concat('%', #{damageReportDTO.breakageReason}, '%')
        </if>
        <if test="damageReportDTO.glassChild != null and damageReportDTO.glassChild != ''">
            and ogd.glass_child like concat('%', #{damageReportDTO.glassChild}, '%')
        </if>
        <if test="damageReportDTO.glassNumber != null and damageReportDTO.glassNumber != ''">
            and ifnull(JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')),'') like concat('%', #{damageReportDTO.glassNumber}, '%')
        </if>
        <if test="damageReportDTO.thisProcess != null and damageReportDTO.thisProcess != ''">
            and rw.this_process like concat('%', #{damageReportDTO.thisProcess}, '%')
        </if>
        <if test="damageReportDTO.creator != null and damageReportDTO.creator != ''">
            and rw.creator like concat('%', #{damageReportDTO.creator}, '%')
        </if>
        <if test="damageReportDTO.reportingWorkId != null and damageReportDTO.reportingWorkId != ''">
            and rw.reporting_work_id like concat('%', #{damageReportDTO.reportingWorkId}, '%')
        </if>
        <if test="damageReportDTO.childWidth != null and damageReportDTO.childWidth != ''">
            and ogd.child_width regexp REGEXP_REPLACE(#{damageReportDTO.childWidth},'\\.0+$','')
        </if>
        <if test="damageReportDTO.childHeight != null and damageReportDTO.childHeight != ''">
            and ogd.child_height regexp REGEXP_REPLACE(#{damageReportDTO.childHeight},'\\.0+$','')
        </if>
        limit #{offset},#{pageSize};
    </select>
    <select id="splittingDetailsOutsideMp">
        SELECT
            fc.process_id processId,
            fc.order_number orderNumber,
            fc.technology_number as technologyNumber,
            o.project,
            o.batch,
            ogd.child_width as childWidth,
            ogd.child_height as childHeight,
            fc.quantity,
            round( ogd.child_width * ogd.child_height * fc.quantity / 1000000, 2 ) as area,
            od.shape,
            od.remarks
        SELECT fc.process_id                                                           processId,
               fc.order_number                                                         orderNumber,
               fc.technology_number                                                 as technologyNumber,
               o.project,
               o.batch,
               ogd.child_width                                                      as childWidth,
               ogd.child_height                                                     as childHeight,
               fc.quantity,
               round(ogd.child_width * ogd.child_height * fc.quantity / 1000000, 2) as area,
               if(od.shape='' || ISNULL(od.shape),'普形',if(od.shape = 1, '普形', if(od.shape = 2, '异形', ''))) as shape,
               od.remarks,
               ifnull(JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')),'') AS glassNumber,
               JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')) AS S01,
               JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S02')) AS S02,
               JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S03')) AS S03,
               JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S04')) AS S04,
               JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S05')) AS S05
        FROM
            sd.ORDER AS o
                LEFT JOIN sd.order_detail AS od ON od.order_id = od.order_id
                LEFT JOIN sd.order_glass_detail AS ogd ON o.order_id = ogd.order_id
                AND ogd.order_number = od.order_number
                LEFT JOIN flow_card AS fc ON fc.order_id = ogd.order_id
                AND fc.order_number
                AND fc.technology_number = ogd.technology_number
        WHERE
            fc.order_id = #{orderId}
        GROUP BY
            fc.id
            flow_card as fc left join sd.order_glass_detail as ogd on ogd.order_id=fc.order_id and ogd.order_number=ogd.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
        WHERE fc.order_id = #{orderId}
        GROUP BY fc.id
        order by fc.order_number,fc.technology_number
    </select>
    <select id="qualityReportMp">
@@ -533,10 +963,10 @@
               fc.technology_number,
               od.product_name,
               od.quantity,
               MAX(opd.reporting_work_num_count)                                                   as quantityMax,
               ifnull(MAX(opd.reporting_work_num_count), 0)                                        as quantityMax,
               IFNULL(SUM(distinct dd.breakage_quantity), 0)                                       as breakage_quantity,
               IFNULL(sum(distinct pl.patch_num), 0)                                               as patch_num,
               fc.received_quantity,
               ifnull(fc.received_quantity, 0)                                                     as received_quantity,
               CONCAT(ROUND(ROUND(od.quantity / MAX(opd.reporting_work_num_count), 2) * 100), '%') as finished
        FROM sd.`order` AS o
                 LEFT JOIN sd.order_detail AS od ON od.order_id = o.order_id
@@ -558,8 +988,8 @@
            AND opd.order_number = fc.order_number
            AND opd.technology_number = fc.technology_number
        WHERE o.create_time BETWEEN #{selectTime1} and #{selectTime2}
        WHERE  DATE_FORMAT((o.create_time), '%Y-%m-%d') BETWEEN #{selectTime1} and #{selectTime2}
          and o.create_order>0
        GROUP BY o.order_id,
                 fc.order_number,
                 fc.technology_number
@@ -567,96 +997,178 @@
    </select>
    <select id="yieldMp">
        SELECT opd.process,
               o.order_id,
               o.customer_name,
               o.project,
               od.product_name,
               ROUND(SUM(distinct opd.reporting_work_num) * od.area, 2)                               as finishedArea
                ,
               ROUND(SUM(distinct opd.broken_num) * od.area, 2)                                       as brokenArea,
               (ROUND(SUM(distinct opd.reporting_work_num) * od.area, 2) +
                ROUND(SUM(distinct opd.broken_num) * od.area, 2))                                     as area,
               CONCAT(ROUND(ROUND(ROUND(SUM(distinct opd.reporting_work_num) * od.area, 2) /
                                  (ROUND(SUM(distinct opd.reporting_work_num) * od.area, 2) +
                                   ROUND(SUM(distinct opd.broken_num) * od.area, 2)), 2) * 100), '%') as finished
        FROM sd.`order` AS o
                 LEFT JOIN sd.order_detail AS od ON od.order_id = o.order_id
                 LEFT JOIN flow_card AS fc ON fc.order_id = od.order_id
            AND fc.order_number = fc.order_number
                 LEFT JOIN sd.order_process_detail AS opd ON opd.order_id = fc.order_id
            AND opd.process_id = fc.process_id
            AND opd.order_number = fc.order_number
            AND opd.technology_number = fc.technology_number
        WHERE opd.reporting_work_num > 0
          and o.create_time BETWEEN #{selectTime1} and #{selectTime2}
          AND position(#{selectProcesses} IN opd.process)
        GROUP BY opd.process, o.order_id
        SELECT
        t.reporting_work_time,
        t.this_process as process,
        t.process_id,
        t.project,
        t.batch,
        SUM(t.completed_quantity) as completedQuantity,
        SUM(t.area) as completedArea,
        SUM(t.breakageQuantity) as breakageQuantity,
        SUM(t.breakageArea) as breakageArea,
        t.responsibleTeam,
        CONCAT(ROUND(TRUNCATE(SUM(t.area)/(SUM(t.area) + SUM(t.breakageArea)),2)*100), '%') as finished,
        t.product_name
        FROM
        (
        SELECT
        rw.reporting_work_time,
        rw.this_process,
        o.project,
        o.batch,
        rw.process_id,
        rwd.completed_quantity AS completed_quantity,
        ROUND(MAX(ogd.child_width) * MAX(ogd.child_height) * rwd.completed_quantity / 1000000, 2) AS area,
        IFNULL(dd.breakage_quantity,0) as breakageQuantity,
        IFNULL(ROUND(MAX(ogd.child_width) * MAX(ogd.child_height) * dd.breakage_quantity / 1000000, 2),0) AS breakageArea,
        IFNULL(dd.responsible_team,'') as responsibleTeam,
        od.product_name
        FROM
        reporting_work AS rw
        LEFT JOIN reporting_work_detail AS rwd
        ON rwd.reporting_work_id = rw.reporting_work_id
        LEFT JOIN damage_details as dd on dd.reporting_work_id = rw.reporting_work_id
        LEFT JOIN flow_card AS fc
        ON fc.order_id = rw.order_id
        AND fc.process_id = rw.process_id
        AND fc.order_number = rwd.order_number
        AND fc.technology_number = rwd.technology_number
        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 = ogd.order_id
        AND od.order_number = ogd.order_number
        LEFT JOIN sd.`order` AS o
        ON o.order_id = od.order_id
        WHERE
        o.create_order > 0
        AND rw.reviewed_state >= 0
        AND rwd.completed_quantity + IFNULL(dd.breakage_quantity,0)> 0
        AND rw.reporting_work_time &gt;= #{selectTime1}
        AND rw.reporting_work_time &lt; #{selectTime2}
        AND rw.this_process = #{selectProcesses}
        GROUP BY
        rw.reporting_work_id,
        rw.process_id,
        rw.this_process,
        rw.teams_groups_name,
        rwd.order_number,
        rwd.technology_number
        ) t
        GROUP BY
        t.reporting_work_time,
        t.this_process,
        t.process_id,
        t.responsibleTeam
        ORDER BY
        t.this_process,
        t.process_id,
        t.reporting_work_time
    </select>
    <select id="productionScheduleMp">
        select
            a.order_number,
            a.shape,
            a.product_name,
            b.child_width,
            b.child_height,
            c.quantity,
            c.technology_number,
            b.glass_child,
            ifnull(e.reportWorkQuantity,0) as reportWorkQuantity,
            ifnull(e.reportWorkQuantityCount,0) as reportWorkQuantityCount,
            ifnull(f.inventory,0) as inventoryNum,
            round(ifnull(f.inventory,0)*a.area,2) as  inventoryArea,
            ifnull(dd.quantity,0) as shippedQuantity,
            ifnull(dd.area,0) as area
        select a.product_name,
               b.glass_child,
               d.order_type,
               concat(c.process_id, '/', c.technology_number) as process_id,
               c.process_id as 'processId',
                c.order_id,
               c.order_number,
               c.technology_number,
               b.child_width,
               b.child_height,
               c.quantity,
        from
            flow_card as c
                left join
            sd.order_detail as a
            on  c.order_id = a.order_id
                and c.order_number = a.order_number
                left join sd.order_glass_detail as b
                          on c.order_id = b.order_id
                              and b.order_number = c.order_number
                              and c.technology_number = b.technology_number
                left join sd.`order` as d
                          on c.order_id = d.order_id
                left join mm.finished_goods_inventory as f
                          on c.order_id = f.order_id and f.order_number = c.order_number
                left join (
                SELECT process_id,
                       technology_number,
                       sum(a.broken_num) as broken_num,
                       concat('{',
                              GROUP_CONCAT(concat("\"",process,"\":\"",reporting_work_num,"\"")),
                              '}'
                           ) as reportWorkQuantity,
                       concat('{',
                              GROUP_CONCAT(concat("\"",process,"\":\"",reporting_work_num,"\"")),
                              '}'
                           ) as  reportWorkQuantityCount
                FROM sd.order_process_detail as a
                where a.order_id=#{orderId}
                GROUP BY process_id,a.technology_number
               c.quantity-ifnull(c.termination_quantity,0) as thisQuantity,/*用于判断是否改变颜色*/
               e.reportWorkQuantity,
               e.reportWorkQuantityShow,
               e.reportWorkQuantityCount,
               e.reportWorkTime,
               e.broken_num,
               c.quantity-ifnull(c.termination_quantity,0) as glassQuantity,
               c.quantity-ifnull(c.termination_quantity,0) as quantityShow,
               round( (c.quantity-ifnull(c.termination_quantity,0))*a.compute_area,2) as grossAreaShow,
               ifnull(c.received_quantity, 0) as inventoryNum,
               ifnull(dd.quantity, 0) as shippedQuantityShow, -- 发货数量
               round(ifnull(dd.quantity, 0)*a.compute_area,2) as shippedAreaShow, -- 发货面积
               round((ifnull(c.received_quantity, 0))*a.compute_area,2)  as inventoryArea,-- 入库面积
               round((c.quantity-ifnull(c.termination_quantity,0))*a.compute_area,2)as grossArea,
               ifnull(c.received_quantity, 0)                       as Storage,
               ifnull(dd.quantity, 0)                        as shippedQuantity,
               round(ifnull(dd.quantity, 0)*a.compute_area,2)        as shippedArea,
               round((ifnull(c.received_quantity, 0))*a.compute_area,2) as StorageArea,
               ifnull(JSON_UNQUOTE(JSON_EXTRACT(a.other_columns, '$.S01')),'') AS glassNumber,
               b.`group`
        from pp.flow_card as c
                 left join
             sd.order_detail as a
             on c.order_id = a.order_id
                 and c.order_number = a.order_number
                 left join sd.order_glass_detail as b
                           on c.order_id = b.order_id
                               and b.order_number = c.order_number
                               and c.technology_number = b.technology_number
                 left join sd.`order` as d
                           on c.order_id = d.order_id
            #                  left join mm.finished_goods_inventory as f
#                            on c.order_id = f.order_id and f.order_number = c.order_number
            left join sd.delivery_detail as dd on dd.order_id = a.order_id and dd.order_number = a.order_number
            left join (SELECT process_id,
            order_number,
            technology_number,
            sum(a.broken_num) as broken_num,
            concat('{',
            GROUP_CONCAT(concat("\"", process, "\":\"", if(technology_number!=1 and (bd.nickname='stepD' || bd.nickname='stepB' ) ,0,reporting_work_num), "\"")),
            '}'
            )             as reportWorkQuantity,
            concat('{',
            GROUP_CONCAT(concat("\"", process, "\":\"", reporting_work_num, "\"")),
            '}'
            )             as reportWorkQuantityShow,
            concat('{',
            GROUP_CONCAT(concat("\"", process, "\":\"", reporting_work_num_count, "\"")),
            '}'
            )             as reportWorkQuantityCount,
            concat('{',
            GROUP_CONCAT(concat("\"", process, "\":\"", IFNULL(date(update_time),''), "\"")),
            '}'
            )             as reportWorkTime
            FROM sd.order_process_detail as a
            left join (SELECT DISTINCT basic_name,nickname from sd.basic_data as bd where  bd.basic_category = 'process') as bd
            on a.process = bd.basic_name
            where a.order_id =#{orderId}
            GROUP BY process_id, a.order_number, a.technology_number
            ) as e
                          on e.process_id = c.process_id
                              and e.technology_number = c.technology_number
                left join sd.delivery_detail as dd on dd.order_id=a.order_id and dd.order_number=a.order_number
        where a.order_id = #{orderId}
        ORDER BY a.order_number
            on e.process_id = c.process_id
            and e.technology_number = c.technology_number
            and e.order_number = c.order_number
        where a.order_id = #{orderId} and d.create_order>0 and c.quantity-ifnull(c.termination_quantity,0)>0
        group by c.order_number,
            c.technology_number,
            c.process_id
        order by c.process_id, c.order_number, c.technology_number
    </select>
    <select id="taskCompletionStatusMp">
        select d.customer_name as customerName,
               d.project,
               d.batch,
               c.order_id as orderId,
               c.order_id      as orderId,
               d.quantity,
               d.area,
               dd.quantity as shippedQuantity,
               dd.area     as shippedArea,
               dd.quantity     as shippedQuantity,
               dd.area         as shippedArea,
               e.reportWorkQuantity,
               e.reportWorkQuantityCount
@@ -676,100 +1188,101 @@
                                   technology_number,
                                   sum(a.broken_num) as broken_num,
                                   concat('{',
                                          GROUP_CONCAT(concat("\"", process, "\":\"", ifnull(reporting_work_num,0), "\"")),
                                          GROUP_CONCAT(concat("\"", process, "\":\"", ifnull(reporting_work_num, 0), "\"")),
                                          '}'
                                       )             as reportWorkQuantity,
                                   concat('{',
                                          GROUP_CONCAT(concat("\"", process, "\":\"", ifnull(reporting_work_num,0), "\"")),
                                          GROUP_CONCAT(concat("\"", process, "\":\"", ifnull(reporting_work_num, 0), "\"")),
                                          '}'
                                       )             as reportWorkQuantityCount
                            FROM sd.order_process_detail as a
                                     left join sd.`order` as o on o.order_id = a.order_id
                            where o.create_time BETWEEN #{selectTime1} and #{selectTime2}
                            GROUP BY process_id,a.technology_number
                            ) as e
                            where    o.create_time >= #{selectTime1}
                              AND o.create_time &lt;  #{selectTime2}
                              and position(#{orderId} in o.order_id)
                            GROUP BY process_id, a.technology_number) as e
                           on e.process_id = c.process_id
                               and e.technology_number = c.technology_number
                 left join sd.delivery_detail as dd on dd.order_id = a.order_id and dd.order_number = a.order_number
        where d.create_time BETWEEN #{selectTime1} and #{selectTime2} and reportWorkQuantity is not null
        where   d.create_time >= #{selectTime1}
          AND d.create_time &lt;  #{selectTime2}
          and position(#{orderId} in a.order_id)
          and d.create_order>0
          and reportWorkQuantity is not null
        GROUP BY a.order_id
        ORDER BY a.order_id
    </select>
    <select id="orderPlanDecompositionMp">
        SELECT
            o.order_id,
            o.customer_name,
            o.project,
            o.batch,
            o.quantity,
            o.area,
            date(fc.create_time) as create_time,
            date(orw.startTime) as startTime,
            oopd.completionsNum,
            sum( DISTINCT fc.received_quantity ) AS received_quantity,
            sum( DISTINCT fc.quantity - fc.received_quantity ) AS receivedNo,
            IF(fc.quantity=fc.received_quantity,'已清单','') as accomplish,
            DATEDIFF(
                    MAX( rw.reporting_work_time ),
                    min( rw.reporting_work_time ))+1 AS daysDifference
        FROM
            sd.`order` AS o
                LEFT JOIN flow_card AS fc ON fc.order_id = o.order_id
                LEFT JOIN (
                SELECT
                    a.order_id,
                    MIN( b.reporting_work_time ) AS startTime
                FROM
                    sd.`order` AS a
                        LEFT JOIN reporting_work AS b ON a.order_id = b.order_id
                WHERE
                    b.this_process = '切割'
                  AND a.create_time BETWEEN #{selectTime1} and #{selectTime2}
                GROUP BY
                    a.order_id
            ) AS orw ON orw.order_id = o.order_id
                LEFT JOIN (
                SELECT
                    a.order_id,
                    SUM( b.reporting_work_num ) AS completionsNum
                FROM
                    sd.`order` AS a
                        LEFT JOIN sd.order_process_detail AS b ON a.order_id = b.order_id
                WHERE
                    b.process = '包装'
                  AND a.create_time BETWEEN #{selectTime1} and #{selectTime2}
                GROUP BY
                    a.order_id
            ) AS oopd ON oopd.order_id = o.order_id
                LEFT JOIN reporting_work AS rw ON rw.order_id = fc.order_id
                AND rw.process_id = fc.process_id
        WHERE
            o.create_time BETWEEN #{selectTime1} and #{selectTime2}
        SELECT o.order_id,
               o.customer_name,
               o.project,
               o.batch,
               o.quantity,
               o.area,
               date(fc.create_time)                                 as create_time,
               date(orw.startTime)                                  as startTime,
               ifnull(oopd.completionsNum, 0)                       as completionsNum,
               sum(DISTINCT fc.received_quantity)                   AS received_quantity,
               o.quantity - sum(DISTINCT fc.received_quantity)      AS receivedNo,
               IF(fc.quantity = fc.received_quantity, '已清单', '') as accomplish,
               DATEDIFF(
                       MAX(rw.reporting_work_time),
                       min(rw.reporting_work_time)) + 1             AS daysDifference
        FROM sd.`order` AS o
                 LEFT JOIN flow_card AS fc ON fc.order_id = o.order_id
                 LEFT JOIN (SELECT a.order_id,
                                   MIN(b.reporting_work_time) AS startTime
                            FROM sd.`order` AS a
                                     LEFT JOIN reporting_work AS b ON a.order_id = b.order_id
                            WHERE b.this_process = '切割'
            and  a.create_time >= #{selectTime1}
            AND a.create_time &lt;  #{selectTime2}
                            GROUP BY a.order_id) AS orw ON orw.order_id = o.order_id
                 LEFT JOIN (SELECT a.order_id,
                                   SUM(b.reporting_work_num) AS completionsNum
                            FROM sd.`order` AS a
                                     LEFT JOIN sd.order_process_detail AS b ON a.order_id = b.order_id
                            WHERE b.process = '包装'
            and  a.create_time >= #{selectTime1}
            AND a.create_time &lt;  #{selectTime2}
                            GROUP BY a.order_id) AS oopd ON oopd.order_id = o.order_id
                 LEFT JOIN reporting_work AS rw ON rw.order_id = fc.order_id
            AND rw.process_id = fc.process_id
        WHERE    o.create_time >= #{selectTime1}
          AND o.create_time &lt;  #{selectTime2}
          and o.create_order>0
          AND fc.create_time IS NOT NULL
        GROUP BY
            o.order_id
        GROUP BY o.order_id
    </select>
    <select id="orderReportingWorks">
        SELECT *
        from sd.order_process_detail opd left join sd.`order` o on o.order_id=opd.order_id
        where    o.create_time >= #{selectTime1}
          and o.create_time &lt;  #{selectTime2}
        and opd.reporting_work_num_count>0
        group by opd.order_id
        order by opd.order_id
    </select>
    <select id="rawMaterialRequisitionMp">
        SELECT
            fc.project_no,
            modl.material_name,
            modl.producer,
            ou.width,
            ou.height,
            modl.date_of_manufacture,
            SUM(distinct modl.outbound_quantity) as quantity,
            ROUND(SUM(modl.outbound_quantity)*SUM(modl.single_piece_area),2) as area,
            date(mo.material_requisition_date) as date
        FROM
            mm.material_outbound_detail AS modl
                left join mm.material_outbound as mo on mo.material_outbound_id=modl.material_outbound_id
                LEFT JOIN optimize_use AS ou ON modl.use_id = ou.id and ou.raw_stock_code=modl.inventory_id
                LEFT JOIN flow_card AS fc ON ou.project_no = fc.project_no
        where  modl.use_id IS NOT NULL and mo.material_requisition_date BETWEEN #{selectTime1} and #{selectTime2}
        GROUP BY
            ou.width,ou.height,material_code
        SELECT fc.project_no,
               modl.material_name,
               modl.producer,
               ou.width,
               ou.height,
               modl.date_of_manufacture,
               SUM(distinct modl.outbound_quantity)                                as quantity,
               ROUND(SUM(modl.outbound_quantity) * SUM(modl.single_piece_area), 2) as area,
               date(mo.material_requisition_date)                                  as date
        FROM mm.material_outbound_detail AS modl
                 left join mm.material_outbound as mo on mo.material_outbound_id = modl.material_outbound_id
                 LEFT JOIN optimize_use AS ou ON modl.use_id = ou.id and ou.raw_stock_code = modl.inventory_id
                 LEFT JOIN flow_card AS fc ON ou.project_no = fc.project_no
        where modl.use_id IS NOT NULL
          and  DATE_FORMAT((mo.material_requisition_date), '%Y-%m-%d') BETWEEN #{selectTime1} and #{selectTime2}
        GROUP BY ou.width, ou.height, material_code
    </select>
    <select id="exportCrossProcessBreakingMp">
@@ -784,7 +1297,12 @@
               rw.this_process,
               o.project,
               o.order_id,
               ogd.glass_child
               ogd.glass_child,
               rw.this_process,
               JSON_UNQUOTE( JSON_EXTRACT( od.other_columns, '$.S01' )) AS code,
               CONCAT(rw.process_id,'/',GROUP_CONCAT(distinct dd.technology_number SEPARATOR '')) as process_id,
               rw.creator,
               rw.reporting_work_id
        from damage_details as dd
                 left join reporting_work as rw
                           on rw.reporting_work_id = dd.reporting_work_id
@@ -793,6 +1311,7 @@
                 left join sd.order_glass_detail as ogd
                           on ogd.order_id = o.order_id and ogd.order_number = dd.order_number
                               and ogd.technology_number and dd.technology_number
                 left join sd.order_detail as od on o.order_id = od.order_id and od.order_number=ogd.order_number
        where date(rw.reporting_work_time) >= #{dates[0]}
          and date(rw.reporting_work_time) &lt;= #{dates[1]}
          and rw.this_worn_quantity > 0
@@ -803,9 +1322,47 @@
        order by dd.id desc
    </select>
    <select id="exportNotCrossProcessBreakingMp">
        select rw.reporting_work_id,
               rw.reporting_work_time,
               dd.responsible_process,
               dd.responsible_team,
               dd.breakage_type,
               dd.breakage_reason,
               ROUND((dd.breakage_quantity))                                                   as breakage_quantity,
               round(ogd.child_width * ogd.child_height * (dd.breakage_quantity) / 1000000, 2) as area,
               rw.this_process,
               o.project,
               o.order_id,
               ogd.glass_child,
               rw.this_process,
               JSON_UNQUOTE( JSON_EXTRACT( od.other_columns, '$.S01' )) AS code,
               CONCAT(rw.process_id,'/',GROUP_CONCAT(distinct dd.technology_number SEPARATOR '')) as process_id,
               rw.creator,
               rw.reporting_work_id
        from damage_details as dd
                 left join reporting_work as rw
                           on rw.reporting_work_id = dd.reporting_work_id
                 left join sd.order as o
                           on rw.order_id = o.order_id
                 left join sd.order_glass_detail as ogd
                           on ogd.order_id = o.order_id and ogd.order_number = dd.order_number
                               and ogd.technology_number and dd.technology_number
                 left join sd.order_detail as od on o.order_id = od.order_id and od.order_number=ogd.order_number
        where date(rw.reporting_work_time) >= #{dates[0]}
          and date(rw.reporting_work_time) &lt;= #{dates[1]}
          and rw.this_worn_quantity > 0
          and dd.available = 0
          and reviewed_state != 2
          and rw.this_process = dd.responsible_process
        GROUP BY dd.id
        order by dd.id desc
    </select>
    <select id="exportDamageReportMp">
        SELECT o.order_id,
               o.project,
               o.batch,
               rw.process_id,
               dd.order_number,
               dd.technology_number,
@@ -818,77 +1375,68 @@
               dd.breakage_quantity,
               round(ogd.child_width * ogd.child_height * dd.breakage_quantity / 1000000, 2) as area,
               IFNULL(dd.responsible_personnel, '')                                          as personnel,
               ogd.glass_child
               ogd.glass_child,
               ogd.child_width,
               ogd.child_height,
               ifnull(JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')),'') AS glassNumber,
               rw.this_process,
               rw.creator,
               rw.reporting_work_id
        FROM sd.ORDER AS o
                 LEFT JOIN sd.order_glass_detail AS ogd ON ogd.order_id = o.order_id
                 LEFT JOIN reporting_work AS rw ON rw.order_id = o.order_id
                 LEFT JOIN damage_details AS dd ON dd.reporting_work_id = rw.reporting_work_id
            AND dd.order_number = ogd.order_number
            AND dd.technology_number = ogd.technology_number
        WHERE date(rw.reporting_work_time) >= #{dates[0]}
          and date(rw.reporting_work_time) &lt;= #{dates[1]}
          AND dd.available = 0
          AND LENGTH(rw.process_id) = 14
            left join sd.order_detail as od on o.order_id = od.order_id and od.order_number=ogd.order_number
        WHERE rw.reporting_work_time >= #{dates[0]}
          and rw.reporting_work_time &lt;= #{dates[1]}
          AND dd.available = 0 and rw.reviewed_state>=0
        GROUP BY dd.id
    </select>
    <select id="exportOrderPlanDecompositionMp">
        SELECT
            o.order_id,
            o.customer_name,
            o.project,
            o.batch,
            o.quantity,
            o.area,
            date(fc.create_time) as create_time,
            date(orw.startTime) as startTime,
            oopd.completionsNum,
            sum( DISTINCT fc.received_quantity ) AS received_quantity,
            sum( DISTINCT fc.quantity - fc.received_quantity ) AS receivedNo,
            IF(fc.quantity=fc.received_quantity,'已清单','') as accomplish,
            DATEDIFF(
                    MAX( rw.reporting_work_time ),
                    min( rw.reporting_work_time ))+1 AS daysDifference
        FROM
            sd.`order` AS o
                LEFT JOIN flow_card AS fc ON fc.order_id = o.order_id
                LEFT JOIN (
                SELECT
                    a.order_id,
                    MIN( b.reporting_work_time ) AS startTime
                FROM
                    sd.`order` AS a
                        LEFT JOIN reporting_work AS b ON a.order_id = b.order_id
                WHERE
                    b.this_process = '切割'
                  AND date(a.create_time) >= #{dates[0]}
                  and date(a.create_time) &lt;= #{dates[1]}
        SELECT o.order_id,
               o.customer_name,
               o.project,
               o.batch,
               o.quantity,
               o.area,
               date(fc.create_time)                                 as create_time,
               date(orw.startTime)                                  as startTime,
               oopd.completionsNum,
               sum(DISTINCT fc.received_quantity)                   AS received_quantity,
               sum(DISTINCT fc.quantity - fc.received_quantity)     AS receivedNo,
               IF(fc.quantity = fc.received_quantity, '已清单', '') as accomplish,
               DATEDIFF(
                       MAX(rw.reporting_work_time),
                       min(rw.reporting_work_time)) + 1             AS daysDifference
        FROM sd.`order` AS o
                 LEFT JOIN flow_card AS fc ON fc.order_id = o.order_id
                 LEFT JOIN (SELECT a.order_id,
                                   MIN(b.reporting_work_time) AS startTime
                            FROM sd.`order` AS a
                                     LEFT JOIN reporting_work AS b ON a.order_id = b.order_id
                            WHERE b.this_process = '切割'
                              AND date(a.create_time) >= #{dates[0]}
                              and date(a.create_time) &lt;= #{dates[1]}
                GROUP BY
                    a.order_id
            ) AS orw ON orw.order_id = o.order_id
                LEFT JOIN (
                SELECT
                    a.order_id,
                    SUM( b.reporting_work_num ) AS completionsNum
                FROM
                    sd.`order` AS a
                        LEFT JOIN sd.order_process_detail AS b ON a.order_id = b.order_id
                WHERE
                    b.process = '包装'
                  AND  date(a.create_time) >= #{dates[0]}
                  and date(a.create_time) &lt;= #{dates[1]}
                GROUP BY
                    a.order_id
            ) AS oopd ON oopd.order_id = o.order_id
                LEFT JOIN reporting_work AS rw ON rw.order_id = fc.order_id
                AND rw.process_id = fc.process_id
        WHERE
            date(o.create_time) >= #{dates[0]}
                and date(o.create_time) &lt;= #{dates[1]}
                            GROUP BY a.order_id) AS orw ON orw.order_id = o.order_id
                 LEFT JOIN (SELECT a.order_id,
                                   SUM(b.reporting_work_num) AS completionsNum
                            FROM sd.`order` AS a
                                     LEFT JOIN sd.order_process_detail AS b ON a.order_id = b.order_id
                            WHERE b.process = '包装'
                              AND date(a.create_time) >= #{dates[0]}
                              and date(a.create_time) &lt;= #{dates[1]}
                            GROUP BY a.order_id) AS oopd ON oopd.order_id = o.order_id
                 LEFT JOIN reporting_work AS rw ON rw.order_id = fc.order_id
            AND rw.process_id = fc.process_id
        WHERE date(o.create_time) >= #{dates[0]}
          and date(o.create_time) &lt;= #{dates[1]}
          and o.create_order>0
          AND fc.create_time IS NOT NULL
        GROUP BY
            o.order_id
        GROUP BY o.order_id
    </select>
    <select id="exportProcessToBeCompletedMp">
@@ -931,12 +1479,12 @@
                               and odpd.process_id = fc.process_id
                 left join sd.`order` as o
                           on o.order_id = od.order_id
        where LENGTH(fc.process_id) = 14
        where  o.create_order>0
          and odpd.process = #{process}
          and date(o.create_time) >= #{date[0]}
          and date(o.create_time) &lt;= #{date[1]}
          and position(ifnull(#{inputVal},'') in od.order_id)
          and position(ifnull(#{project},'') in o.project)
          and position(ifnull(#{inputVal}, '') in od.order_id)
          and position(ifnull(#{project}, '') in o.project)
          and od.quantity > odpd.reporting_work_num
        group by fc.process_id, fc.order_number, fc.technology_number
@@ -944,13 +1492,13 @@
    </select>
    <select id="exportWorkInProgressMp">
        select #{process} as thisProcess,
        select if(#{process}='',odpd.process,#{process}) as thisProcess,
               fc.process_id,
               o.customer_name,
               o.project,
               o.order_id,
               o.batch,
               od.shape,
               if(od.shape='' || ISNULL(od.shape),'普形',if(od.shape = 1, '普形', if(od.shape = 2, '异形', ''))) as shape,
               ogd.order_number,
               ogd.technology_number,
               ogd.process,
@@ -963,7 +1511,8 @@
                     (odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count -
                      odpd.broken_num) / 1000000, 2) as stockArea,
               od.product_name,
               od.bend_radius
               od.bend_radius,
               ifnull(JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')),'') AS glassNumber
        from sd.order_detail AS od
                 LEFT JOIN sd.order_glass_detail AS ogd
@@ -983,7 +1532,7 @@
                           ON odpds.id = odpd.id - 1
                 left join
             (SELECT sum(rw.rework_num) as 'patchNumSum',
                     rw.process_id,
                      rw.process_id,
                     rw.order_sort,
                     rw.technology_number,
                     rwk.this_process
@@ -991,24 +1540,2395 @@
                       LEFT JOIN
                   reporting_work as rwk
                   on rw.reporting_work_id = rwk.reporting_work_id
              where rwk.this_process = #{process}
                and rw.review_status = 1
              where position(#{process} in rwk.this_process)
                and rw.review_status >= 0
              GROUP BY rw.process_id, rw.order_sort, rw.technology_number) as c
             on c.process_id = fc.process_id
                 and c.order_sort = fc.order_number
                 and c.technology_number = fc.technology_number
                 left join sd.`order` as o
                           on o.order_id = od.order_id
        where LENGTH(fc.process_id) = 14
        where  o.create_order>0
          and odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count -
              odpd.broken_num != 0
          and odpd.process = #{process} and  date(o.create_time) >= #{date[0]}
          and date(o.create_time) &lt;= #{date[1]}
          and position(ifnull(#{inputVal},'') in od.order_id)
          and position(ifnull(#{project},'') in o.project)
        group by fc.process_id, fc.order_number, fc.technology_number
              odpd.broken_num != 0 and odpd.process!=SUBSTRING_INDEX(ogd.process, '->', 1)
          and position(#{process} in odpd.process)
          and position(ifnull(#{inputVal}, '') in od.order_id)
          and position(ifnull(#{project}, '') in o.project)
        <if test="terminationVals != '1' and terminationVals != 1">
            and fc.termination_status !=1
        </if>
        group by fc.process_id, fc.order_number, fc.technology_number,odpd.process
        order by fc.process_id, fc.order_number, fc.technology_number
    </select>
    <select id="exportTaskCompletionStatusMp">
        select d.customer_name as customerName,
               d.project,
               d.batch,
               c.order_id      as orderId,
               d.quantity,
               d.area,
               dd.quantity     as shippedQuantity,
               dd.area         as shippedArea,
               e.reportWorkQuantity,
               e.reportWorkQuantityCount
        from sd.`order` as d
                 left join flow_card as c on c.order_id = d.order_id
                 left join
             sd.order_detail as a
             on c.order_id = a.order_id
                 and c.order_number = a.order_number
                 left join sd.order_glass_detail as b
                           on c.order_id = b.order_id
                               and b.order_number = c.order_number
                               and c.technology_number = b.technology_number
                 left join mm.finished_goods_inventory as f
                           on c.order_id = f.order_id and f.order_number = c.order_number
                 left join (SELECT process_id,
                                   technology_number,
                                   sum(a.broken_num) as broken_num,
                                   concat('{',
                                          GROUP_CONCAT(concat("\"", process, "\":\"", ifnull(reporting_work_num, 0), "\"")),
                                          '}'
                                       )             as reportWorkQuantity,
                                   concat('{',
                                          GROUP_CONCAT(concat("\"", process, "\":\"", ifnull(reporting_work_num, 0), "\"")),
                                          '}'
                                       )             as reportWorkQuantityCount
                            FROM sd.order_process_detail as a
                                     left join sd.`order` as o on o.order_id = a.order_id
                            where date(o.create_time) >= #{date[0]}
                              and date(o.create_time) &lt;= #{date[1]}
                            GROUP BY process_id, a.technology_number) as e
                           on e.process_id = c.process_id
                               and e.technology_number = c.technology_number
                 left join sd.delivery_detail as dd on dd.order_id = a.order_id and dd.order_number = a.order_number
        where d.create_time
          and date(o.create_time) >= #{dates[0]}
          and date(o.create_time) &lt;= #{dates[1]}
          and d.create_order>0
          and reportWorkQuantity is not null
        GROUP BY a.order_id
        ORDER BY a.order_id
    </select>
    <select id="exportRawMaterialRequisitionMp">
        SELECT fc.project_no,
               modl.material_name,
               modl.producer,
               ou.width,
               ou.height,
               modl.date_of_manufacture,
               SUM(distinct modl.outbound_quantity)                                as quantity,
               ROUND(SUM(modl.outbound_quantity) * SUM(modl.single_piece_area), 2) as area,
               date(mo.material_requisition_date)                                  as date
        FROM mm.material_outbound_detail AS modl
                 left join mm.material_outbound as mo on mo.material_outbound_id = modl.material_outbound_id
                 LEFT JOIN optimize_use AS ou ON modl.use_id = ou.id and ou.raw_stock_code = modl.inventory_id
                 LEFT JOIN flow_card AS fc ON ou.project_no = fc.project_no
        where modl.use_id IS NOT NULL
          and date(mo.material_requisition_date) >= #{dates[0]}
          and date(mo.material_requisition_date) &lt;= #{dates[1]}
        GROUP BY ou.width, ou.height, material_code
    </select>
    <select id="exportQualityReportSv">
        SELECT o.order_id,
               o.customer_name,
               o.project,
               fc.order_number,
               fc.technology_number,
               od.product_name,
               od.quantity,
               MAX(opd.reporting_work_num_count)                                                   as quantityMax,
               IFNULL(SUM(distinct dd.breakage_quantity), 0)                                       as breakage_quantity,
               IFNULL(sum(distinct pl.patch_num), 0)                                               as patch_num,
               fc.received_quantity,
               CONCAT(ROUND(ROUND(od.quantity / MAX(opd.reporting_work_num_count), 2) * 100), '%') as finished
        FROM sd.`order` AS o
                 LEFT JOIN sd.order_detail AS od ON od.order_id = o.order_id
                 LEFT JOIN flow_card AS fc ON o.order_id = fc.order_id
            AND fc.order_number = od.order_number
                 LEFT JOIN damage_details AS dd ON dd.process_id = fc.process_id
            AND dd.order_number = fc.order_number
            AND dd.technology_number = fc.technology_number
            and dd.available != 1
                 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
                 LEFT JOIN sd.order_process_detail AS opd ON opd.order_id = fc.order_id
            AND opd.order_number = fc.order_number
            AND opd.technology_number = fc.technology_number
        WHERE date(o.create_time) >= #{dates[0]}
          and date(o.create_time) &lt;= #{dates[1]}
          and o.create_order>0
        GROUP BY o.order_id,
                 fc.order_number,
                 fc.technology_number
        ORDER BY fc.order_number
    </select>
    <select id="exportYieldMp">
        SELECT opd.process,
               o.order_id,
               o.customer_name,
               o.project,
               od.product_name,
               ROUND(SUM(distinct opd.reporting_work_num) * od.area, 2)                               as finishedArea
                ,
               ROUND(SUM(distinct opd.broken_num) * od.area, 2)                                       as brokenArea,
               (ROUND(SUM(distinct opd.reporting_work_num) * od.area, 2) +
                ROUND(SUM(distinct opd.broken_num) * od.area, 2))                                     as area,
               CONCAT(ROUND(ROUND(ROUND(SUM(distinct opd.reporting_work_num) * od.area, 2) /
                                  (ROUND(SUM(distinct opd.reporting_work_num) * od.area, 2) +
                                   ROUND(SUM(distinct opd.broken_num) * od.area, 2)), 2) * 100), '%') as finished
        FROM sd.`order` AS o
                 LEFT JOIN sd.order_detail AS od ON od.order_id = o.order_id
                 LEFT JOIN flow_card AS fc ON fc.order_id = od.order_id
            AND fc.order_number = fc.order_number
                 LEFT JOIN sd.order_process_detail AS opd ON opd.order_id = fc.order_id
            AND opd.process_id = fc.process_id
            AND opd.order_number = fc.order_number
            AND opd.technology_number = fc.technology_number
        WHERE opd.reporting_work_num > 0
          and date(o.create_time) >= #{date[0]}
          and date(o.create_time) &lt;= #{date[1]}
          and o.create_order>0
          AND position(#{process} IN opd.process)
        GROUP BY opd.process, o.order_id
    </select>
    <select id="teamOutputMp" resultMap="teamOutputMap">
        SELECT
        t.*,
        -- 玻璃总厚度(mm)
        (
        SELECT SUM(CAST(REGEXP_SUBSTR(seg, '^[0-9]+') AS UNSIGNED))
        FROM JSON_TABLE(
        CONCAT('["', REPLACE(t.workProcessName, '+', '","'), '"]'),
        '$[*]' COLUMNS (seg VARCHAR(100) PATH '$')
        ) jt
        ) AS thicknessSum,
        ROUND(
        (
        SELECT SUM(CAST(REGEXP_SUBSTR(seg, '^[0-9]+') AS UNSIGNED))
        FROM JSON_TABLE(
        CONCAT('["', REPLACE(t.workProcessName, '+', '","'), '"]'),
        '$[*]' COLUMNS (seg VARCHAR(100) PATH '$')
        ) jt2
        ) * t.area,
        2
        ) AS thicknessArea
        FROM
        (
        SELECT
        rw.reporting_work_time,
        rw.this_process,
        rw.teams_groups_name,
        o.project,
        o.order_id,
        rw.process_id,
        fc.order_number,
        MAX(ogd.child_width)  AS width,
        MAX(ogd.child_height) AS height,
        od.edging_type,
        rwd.completed_quantity AS completed_quantity,
        ROUND(MAX(ogd.child_width) * MAX(ogd.child_height) * rwd.completed_quantity / 1000000, 2) AS area,
        od.product_name,
        JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')) AS code,
        rw.reviewed,
        rw.examine_time,
        rw.device_name,
        o.order_type,
        CASE
        WHEN LOCATE('step', #{laminating}) > 0 THEN GROUP_CONCAT(ogd.glass_child SEPARATOR '+')
        ELSE MAX(ogd.glass_child)
        END AS workProcessName,
        o.batch
        FROM
        pp.reporting_work AS rw
        LEFT JOIN pp.reporting_work_detail AS rwd
        ON rwd.reporting_work_id = rw.reporting_work_id
        LEFT JOIN pp.flow_card AS fc
        ON fc.order_id = rw.order_id
        AND fc.process_id = rw.process_id
        AND fc.order_number = rwd.order_number
        AND fc.technology_number = rwd.technology_number
        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 = ogd.order_id
        AND od.order_number = ogd.order_number
        LEFT JOIN sd.`order` AS o
        ON o.order_id = od.order_id
        WHERE
        o.create_order > 0
        AND rw.reviewed_state >= 0
        AND rwd.completed_quantity > 0
        AND rw.reporting_work_time &gt;= #{selectTime1}
        AND rw.reporting_work_time &lt;  #{selectTime2}
        <choose>
            <!-- 有传工序:精确匹配 -->
            <when test="selectProcesses != null and selectProcesses != ''">
                AND rw.this_process = #{selectProcesses}
            </when>
            <!-- 未传工序:不加限制,查所有) -->
            <otherwise>
            </otherwise>
        </choose>
        <if test="teamOutputDTO.thisProcess != null and teamOutputDTO.thisProcess != ''">
            AND rw.this_process REGEXP #{teamOutputDTO.thisProcess}
        </if>
        <if test="teamOutputDTO.teamsGroupsName != null and teamOutputDTO.teamsGroupsName != ''">
            and rw.teams_groups_name like concat('%', #{teamOutputDTO.teamsGroupsName}, '%')
        </if>
        <if test="teamOutputDTO.project != null and teamOutputDTO.project != ''">
            AND o.project REGEXP #{teamOutputDTO.project}
        </if>
        <if test="teamOutputDTO.processId != null and teamOutputDTO.processId != ''">
            AND rw.process_id REGEXP #{teamOutputDTO.processId}
        </if>
        <if test="teamOutputDTO.edgingType != null and teamOutputDTO.edgingType != ''">
            AND od.edging_type REGEXP #{teamOutputDTO.edgingType}
        </if>
        <if test="teamOutputDTO.deviceName != null and teamOutputDTO.deviceName != ''">
            AND rw.device_name REGEXP #{teamOutputDTO.deviceName}
        </if>
        <if test="teamOutputDTO.batch != null and teamOutputDTO.batch != ''">
            AND o.batch REGEXP #{teamOutputDTO.batch}
        </if>
        <if test="teamOutputDTO.width != null and teamOutputDTO.width != ''">
            and ogd.child_width regexp REGEXP_REPLACE(#{teamOutputDTO.width},'\\.0+$','')
        </if>
        <if test="teamOutputDTO.height != null and teamOutputDTO.height != ''">
            and ogd.child_height regexp REGEXP_REPLACE(#{teamOutputDTO.height},'\\.0+$','')
        </if>
        <choose>
            <when test="laminating == ''">
                GROUP BY
                rw.reporting_work_id,
                rw.process_id,
                rw.this_process,
                rw.teams_groups_name,
                rwd.order_number,
                rwd.technology_number
            </when>
            <otherwise>
                GROUP BY
                <if test="laminating == 'stepA' || laminating == 'stepC'">
                    ogd.`group`,
                </if>
                rw.reporting_work_id,
                rw.process_id,
                rw.this_process,
                rw.teams_groups_name,
                rwd.order_number
            </otherwise>
        </choose>
        ) t
        WHERE 1 = 1
        <if test="teamOutputDTO.workProcessName != null and teamOutputDTO.workProcessName != ''">
            AND t.workProcessName REGEXP #{teamOutputDTO.workProcessName}
        </if>
        HAVING 1 = 1
        <if test="teamOutputDTO.thicknessSum != null and teamOutputDTO.thicknessSum != ''">
            and thicknessSum regexp REGEXP_REPLACE(#{teamOutputDTO.thicknessSum},'\\.0+$','')
        </if>
        ORDER BY
        t.this_process,
        t.process_id,
        t.order_number,
        t.reporting_work_time,
        t.teams_groups_name
        LIMIT #{offset}, #{pageSize};
    </select>
    <select id="exportTeamOutputMp">
        SELECT
        t.*,
        -- 玻璃总厚度(mm)
        (
        SELECT SUM(CAST(REGEXP_SUBSTR(seg, '^[0-9]+') AS UNSIGNED))
        FROM JSON_TABLE(
        CONCAT('["', REPLACE(t.workProcessName, '+', '","'), '"]'),
        '$[*]' COLUMNS (seg VARCHAR(100) PATH '$')
        ) jt
        ) AS thicknessSum,
        ROUND(
        (
        SELECT SUM(CAST(REGEXP_SUBSTR(seg, '^[0-9]+') AS UNSIGNED))
        FROM JSON_TABLE(
        CONCAT('["', REPLACE(t.workProcessName, '+', '","'), '"]'),
        '$[*]' COLUMNS (seg VARCHAR(100) PATH '$')
        ) jt2
        ) * t.area,
        2
        ) AS thicknessArea
        FROM
        (
        SELECT
        rw.reporting_work_time,
        rw.this_process,
        rw.teams_groups_name,
        o.project,
        o.order_id,
        rw.process_id,
        fc.order_number,
        MAX(ogd.child_width)  AS width,
        MAX(ogd.child_height) AS height,
        od.edging_type,
        rwd.completed_quantity AS completed_quantity,
        ROUND(MAX(ogd.child_width) * MAX(ogd.child_height) * rwd.completed_quantity / 1000000, 2) AS area,
        od.product_name,
        JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')) AS code,
        rw.reviewed,
        rw.examine_time,
        rw.device_name,
        o.order_type,
        CASE
        WHEN LOCATE('step', #{laminating}) > 0 THEN GROUP_CONCAT(ogd.glass_child SEPARATOR '+')
        ELSE MAX(ogd.glass_child)
        END AS workProcessName,
        o.batch
        FROM
        pp.reporting_work AS rw
        LEFT JOIN pp.reporting_work_detail AS rwd
        ON rwd.reporting_work_id = rw.reporting_work_id
        LEFT JOIN pp.flow_card AS fc
        ON fc.order_id = rw.order_id
        AND fc.process_id = rw.process_id
        AND fc.order_number = rwd.order_number
        AND fc.technology_number = rwd.technology_number
        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 = ogd.order_id
        AND od.order_number = ogd.order_number
        LEFT JOIN sd.`order` AS o
        ON o.order_id = od.order_id
        WHERE
        o.create_order > 0
        AND rw.reviewed_state >= 0
        AND rwd.completed_quantity > 0
        AND rw.reporting_work_time &gt;= #{date[0]}
        AND rw.reporting_work_time &lt;  #{date[1]}
        <choose>
            <!-- 有传工序:精确匹配 -->
            <when test="process != null and process != ''">
                AND rw.this_process = #{process}
            </when>
            <!-- 未传工序:不加限制,查所有) -->
            <otherwise>
            </otherwise>
        </choose>
        <choose>
            <when test="laminating == ''">
                GROUP BY
                rw.reporting_work_id,
                rw.process_id,
                rw.this_process,
                rw.teams_groups_name,
                rwd.order_number,
                rwd.technology_number
            </when>
            <otherwise>
                GROUP BY
                <if test="laminating == 'stepA' || laminating == 'stepC'">
                    ogd.`group`,
                </if>
                rw.reporting_work_id,
                rw.process_id,
                rw.this_process,
                rw.teams_groups_name,
                rwd.order_number
            </otherwise>
        </choose>
        ) t
        ORDER BY
        t.this_process,
        t.process_id,
        t.order_number,
        t.reporting_work_time,
        t.teams_groups_name
    </select>
    <select id="teamOutputPageTotal">
        SELECT
        CEILING(COUNT(*) / #{pageSize}) AS pageTotal,
        COUNT(*) AS total
        FROM (
        SELECT
        t.*,
        CASE
        WHEN t.workProcessName IS NULL OR t.workProcessName = '' THEN 0
        ELSE (
        SELECT SUM(CAST(REGEXP_SUBSTR(seg, '^[0-9]+') AS UNSIGNED))
        FROM JSON_TABLE(
        CONCAT('["', REPLACE(t.workProcessName, '+', '","'), '"]'),
        '$[*]' COLUMNS (seg VARCHAR(100) PATH '$')
        ) jt
        )
        END AS thicknessSum,
        CASE
        WHEN t.workProcessName IS NULL OR t.workProcessName = '' THEN 0
        ELSE ROUND(
        (
        SELECT SUM(CAST(REGEXP_SUBSTR(seg2, '^[0-9]+') AS UNSIGNED))
        FROM JSON_TABLE(
        CONCAT('["', REPLACE(t.workProcessName, '+', '","'), '"]'),
        '$[*]' COLUMNS (seg2 VARCHAR(100) PATH '$')
        ) jt2
        ) * t.area,
        2
        )
        END AS thicknessArea
        FROM (
        SELECT
        rw.reporting_work_time,
        rw.this_process,
        rw.teams_groups_name,
        o.project,
        o.order_id,
        rw.process_id,
        fc.order_number,
        MAX(ogd.child_width)  AS width,
        MAX(ogd.child_height) AS height,
        od.edging_type,
        rwd.completed_quantity AS completed_quantity,
        ROUND(MAX(ogd.child_width) * MAX(ogd.child_height) * rwd.completed_quantity / 1000000, 2) AS area,
        od.product_name,
        JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')) AS code,
        rw.reviewed,
        rw.examine_time,
        rw.device_name,
        o.order_type,
        CASE
        WHEN LOCATE('step', #{laminating}) > 0 THEN GROUP_CONCAT(ogd.glass_child SEPARATOR '+')
        ELSE MAX(ogd.glass_child)
        END AS workProcessName,
        o.batch
        FROM
        pp.reporting_work AS rw
        LEFT JOIN pp.reporting_work_detail AS rwd
        ON rwd.reporting_work_id = rw.reporting_work_id
        LEFT JOIN pp.flow_card AS fc
        ON fc.order_id = rw.order_id
        AND fc.process_id = rw.process_id
        AND fc.order_number = rwd.order_number
        AND fc.technology_number = rwd.technology_number
        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 = ogd.order_id
        AND od.order_number = ogd.order_number
        LEFT JOIN sd.`order` AS o
        ON o.order_id = od.order_id
        WHERE
        o.create_order > 0
        AND rw.reviewed_state >= 0
        AND rwd.completed_quantity > 0
        AND rw.reporting_work_time &gt;= #{selectTime1}
        AND rw.reporting_work_time &lt;  #{selectTime2}
        <choose>
            <!-- 有传工序:精确匹配 -->
            <when test="selectProcesses != null and selectProcesses != ''">
                AND rw.this_process = #{selectProcesses}
            </when>
            <!-- 未传工序:不加限制 -->
            <otherwise>
            </otherwise>
        </choose>
        <if test="teamOutputDTO.thisProcess != null and teamOutputDTO.thisProcess != ''">
            AND rw.this_process REGEXP #{teamOutputDTO.thisProcess}
        </if>
        <if test="teamOutputDTO.teamsGroupsName != null and teamOutputDTO.teamsGroupsName != ''">
            AND rw.teams_groups_name LIKE CONCAT('%', #{teamOutputDTO.teamsGroupsName}, '%')
        </if>
        <if test="teamOutputDTO.project != null and teamOutputDTO.project != ''">
            AND o.project REGEXP #{teamOutputDTO.project}
        </if>
        <if test="teamOutputDTO.processId != null and teamOutputDTO.processId != ''">
            AND rw.process_id REGEXP #{teamOutputDTO.processId}
        </if>
        <if test="teamOutputDTO.edgingType != null and teamOutputDTO.edgingType != ''">
            AND od.edging_type REGEXP #{teamOutputDTO.edgingType}
        </if>
        <if test="teamOutputDTO.deviceName != null and teamOutputDTO.deviceName != ''">
            AND rw.device_name REGEXP #{teamOutputDTO.deviceName}
        </if>
        <if test="teamOutputDTO.batch != null and teamOutputDTO.batch != ''">
            AND o.batch REGEXP #{teamOutputDTO.batch}
        </if>
        <if test="teamOutputDTO.width != null and teamOutputDTO.width != ''">
            and ogd.child_width regexp REGEXP_REPLACE(#{teamOutputDTO.width},'\\.0+$','')
        </if>
        <if test="teamOutputDTO.height != null and teamOutputDTO.height != ''">
            and ogd.child_height regexp REGEXP_REPLACE(#{teamOutputDTO.height},'\\.0+$','')
        </if>
        <choose>
            <when test="laminating == ''">
                GROUP BY
                rw.reporting_work_id,
                rw.process_id,
                rw.this_process,
                rw.teams_groups_name,
                rwd.order_number,
                rwd.technology_number
            </when>
            <otherwise>
                GROUP BY
                rw.reporting_work_id,
                rw.process_id,
                rw.this_process,
                rw.teams_groups_name,
                rwd.order_number
            </otherwise>
        </choose>
        ) t
        WHERE 1 = 1
        <if test="teamOutputDTO.workProcessName != null and teamOutputDTO.workProcessName != ''">
            AND t.workProcessName REGEXP #{teamOutputDTO.workProcessName}
        </if>
        ) x
        WHERE 1 = 1
        <if test="teamOutputDTO.thicknessSum != null and teamOutputDTO.thicknessSum != ''">
            and thicknessSum regexp REGEXP_REPLACE(#{teamOutputDTO.thicknessSum},'\\.0+$','')
        </if>
        <if test="teamOutputDTO.thicknessArea != null and teamOutputDTO.thicknessArea != ''">
            AND x.thicknessArea REGEXP #{teamOutputDTO.thicknessArea}
        </if>
        limit #{offset},#{pageSize}
    </select>
    <select id="workInProgressOrderMp" resultMap="workInProgressMap">
        select #{selectProcesses} as thisProcess,
        o.customer_name,
        o.project,
        o.order_id,
        o.batch,
        if(od.shape='' || ISNULL(od.shape),'普形',if(od.shape = 1, '普形', if(od.shape = 2, '异形', ''))) as shape,
        sum(od.quantity) as quantity,
        sum(odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count -
        odpd.broken_num) as stockNum,
        sum(ROUND(ogd.child_width * ogd.child_height *
        (odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count -
        odpd.broken_num) / 1000000, 2)) as stockArea,
        od.product_name,
        rws.teams_groups_name
        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 flow_card AS fc
        ON fc.order_id = ogd.order_id
        and fc.production_id = ogd.production_id
        AND fc.order_number = ogd.order_number
        AND fc.technology_number = ogd.technology_number
        left join sd.order_process_detail as odpd
        ON odpd.order_id = fc.order_id
        AND odpd.order_number = fc.order_number
        AND odpd.technology_number = fc.technology_number
        and odpd.process_id = fc.process_id
        left join sd.order_process_detail as odpds
        ON odpds.id = odpd.id - 1
        left join
        (SELECT sum(rw.rework_num) as 'patchNumSum',
        rw.process_id,
        rw.order_sort,
        rw.technology_number,
        rwk.this_process
        from rework as rw
        LEFT JOIN
        reporting_work as rwk
        on rw.reporting_work_id = rwk.reporting_work_id
        where rwk.this_process = #{selectProcesses}
        and rw.review_status >= 0
        GROUP BY rw.process_id, rw.order_sort, rw.technology_number) as c
        on c.process_id = fc.process_id
        and c.order_sort = fc.order_number
        and c.technology_number = fc.technology_number
        left join sd.`order` as o
        on o.order_id = od.order_id
        left join
        (
        select a.process_id,a.teams_groups_name,a.next_process,b.technology_number,b.order_number
        from reporting_work  as a
        left join reporting_work_detail as b on a.reporting_work_id=b.reporting_work_id
        GROUP BY a.process_id,a.teams_groups_name,a.next_process,b.order_number,b.technology_number
        ) as rws on rws.process_id=fc.process_id and rws.order_number=fc.order_number
        and  rws.technology_number=fc.technology_number and rws.next_process=#{selectProcesses}
        where  o.create_order>0
        and odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count -
        odpd.broken_num != 0
        and odpd.process = #{selectProcesses}
        and position(#{orderId} in od.order_id)
        and position(#{inputProject} in o.project)
        <if test="workInProgressDTO.customerName != null and workInProgressDTO.customerName != ''">
            and o.customer_name regexp #{workInProgressDTO.customerName}
        </if>
        <if test="workInProgressDTO.project != null and workInProgressDTO.project != ''">
            and o.project regexp #{workInProgressDTO.project}
        </if>
        <if test="workInProgressDTO.orderId != null and workInProgressDTO.orderId != ''">
            and o.order_id regexp #{workInProgressDTO.orderId}
        </if>
        <if test="workInProgressDTO.batch != null and workInProgressDTO.batch != ''">
            and o.batch regexp #{workInProgressDTO.batch}
        </if>
        group by o.order_id
        order by o.order_id
        limit #{offset},#{pageSize};
    </select>
    <select id="workInProgressOrderTotal">
        select CEILING(count(o.order_id)/#{pageSize}) as 'pageTotal',
        count(distinct o.order_id) as 'total'
        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 flow_card AS fc
        ON fc.order_id = ogd.order_id
        and fc.production_id = ogd.production_id
        AND fc.order_number = ogd.order_number
        AND fc.technology_number = ogd.technology_number
        left join sd.order_process_detail as odpd
        ON odpd.order_id = fc.order_id
        AND odpd.order_number = fc.order_number
        AND odpd.technology_number = fc.technology_number
        and odpd.process_id = fc.process_id
        left join sd.order_process_detail as odpds
        ON odpds.id = odpd.id - 1
        left join
        (SELECT sum(rw.rework_num) as 'patchNumSum',
        rw.process_id,
        rw.order_sort,
        rw.technology_number,
        rwk.this_process
        from rework as rw
        LEFT JOIN
        reporting_work as rwk
        on rw.reporting_work_id = rwk.reporting_work_id
        where rwk.this_process = #{selectProcesses}
        and rw.review_status >= 0
        GROUP BY rw.process_id, rw.order_sort, rw.technology_number) as c
        on c.process_id = fc.process_id
        and c.order_sort = fc.order_number
        and c.technology_number = fc.technology_number
        left join sd.`order` as o
        on o.order_id = od.order_id
        left join
        (
        select a.process_id,a.teams_groups_name,a.next_process,b.technology_number,b.order_number
        from reporting_work  as a
        left join reporting_work_detail as b on a.reporting_work_id=b.reporting_work_id
        GROUP BY a.process_id,a.teams_groups_name,a.next_process,b.order_number,b.technology_number
        ) as rws on rws.process_id=fc.process_id and rws.order_number=fc.order_number
        and  rws.technology_number=fc.technology_number and rws.next_process=#{selectProcesses}
        where  o.create_order>0
        and odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count -
        odpd.broken_num != 0
        and odpd.process = #{selectProcesses}
        and position(#{orderId} in od.order_id)
        and position(#{inputProject} in o.project)
        <if test="workInProgressDTO.customerName != null and workInProgressDTO.customerName != ''">
            and o.customer_name regexp #{workInProgressDTO.customerName}
        </if>
        <if test="workInProgressDTO.project != null and workInProgressDTO.project != ''">
            and o.project regexp #{workInProgressDTO.project}
        </if>
        <if test="workInProgressDTO.orderId != null and workInProgressDTO.orderId != ''">
            and o.order_id regexp #{workInProgressDTO.orderId}
        </if>
        <if test="workInProgressDTO.batch != null and workInProgressDTO.batch != ''">
            and o.batch regexp #{workInProgressDTO.batch}
        </if>
        limit #{offset},#{pageSize};
    </select>
    <select id="workInProgressProcessMp" resultMap="workInProgressMap">
        select #{selectProcesses} as thisProcess,
        o.customer_name,
        o.project,
        o.order_id,
        fc.process_id,
        o.batch,
        if(od.shape='' || ISNULL(od.shape),'普形',if(od.shape = 1, '普形', if(od.shape = 2, '异形', ''))) as shape,
        sum(od.quantity) as quantity,
        sum(odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count -
        odpd.broken_num) as stockNum,
        sum(ROUND(ogd.child_width * ogd.child_height *
        (odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count -
        odpd.broken_num) / 1000000, 2)) as stockArea,
        od.product_name,
        rws.teams_groups_name
        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 flow_card AS fc
        ON fc.order_id = ogd.order_id
        and fc.production_id = ogd.production_id
        AND fc.order_number = ogd.order_number
        AND fc.technology_number = ogd.technology_number
        left join sd.order_process_detail as odpd
        ON odpd.order_id = fc.order_id
        AND odpd.order_number = fc.order_number
        AND odpd.technology_number = fc.technology_number
        and odpd.process_id = fc.process_id
        left join sd.order_process_detail as odpds
        ON odpds.id = odpd.id - 1
        left join
        (SELECT sum(rw.rework_num) as 'patchNumSum',
        rw.process_id,
        rw.order_sort,
        rw.technology_number,
        rwk.this_process
        from rework as rw
        LEFT JOIN
        reporting_work as rwk
        on rw.reporting_work_id = rwk.reporting_work_id
        where rwk.this_process = #{selectProcesses}
        and rw.review_status >= 0
        GROUP BY rw.process_id, rw.order_sort, rw.technology_number) as c
        on c.process_id = fc.process_id
        and c.order_sort = fc.order_number
        and c.technology_number = fc.technology_number
        left join sd.`order` as o
        on o.order_id = od.order_id
        left join
        (
        select a.process_id,a.teams_groups_name,a.next_process,b.technology_number,b.order_number
        from reporting_work  as a
        left join reporting_work_detail as b on a.reporting_work_id=b.reporting_work_id
        GROUP BY a.process_id,a.teams_groups_name,a.next_process,b.order_number,b.technology_number
        ) as rws on rws.process_id=fc.process_id and rws.order_number=fc.order_number
        and  rws.technology_number=fc.technology_number and rws.next_process=#{selectProcesses}
        where  o.create_order>0
        and odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count -
        odpd.broken_num != 0
        and odpd.process = #{selectProcesses}
        and position(#{orderId} in od.order_id)
        and position(#{inputProject} in o.project)
        <if test="workInProgressDTO.customerName != null and workInProgressDTO.customerName != ''">
            and o.customer_name regexp #{workInProgressDTO.customerName}
        </if>
        <if test="workInProgressDTO.project != null and workInProgressDTO.project != ''">
            and o.project regexp #{workInProgressDTO.project}
        </if>
        <if test="workInProgressDTO.orderId != null and workInProgressDTO.orderId != ''">
            and o.order_id regexp #{workInProgressDTO.orderId}
        </if>
        <if test="workInProgressDTO.batch != null and workInProgressDTO.batch != ''">
            and o.batch regexp #{workInProgressDTO.batch}
        </if>
        <if test="workInProgressDTO.processId != null and workInProgressDTO.processId != ''">
            and fc.process_id regexp #{workInProgressDTO.processId}
        </if>
        group by o.order_id, fc.process_id
        order by o.order_id, fc.process_id
        limit #{offset},#{pageSize};
    </select>
    <select id="workInProgressProcessTotal">
        select CEILING(count(fc.process_id)/#{pageSize}) as 'pageTotal',
        count(distinct fc.process_id) as 'total'
        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 flow_card AS fc
        ON fc.order_id = ogd.order_id
        and fc.production_id = ogd.production_id
        AND fc.order_number = ogd.order_number
        AND fc.technology_number = ogd.technology_number
        left join sd.order_process_detail as odpd
        ON odpd.order_id = fc.order_id
        AND odpd.order_number = fc.order_number
        AND odpd.technology_number = fc.technology_number
        and odpd.process_id = fc.process_id
        left join sd.order_process_detail as odpds
        ON odpds.id = odpd.id - 1
        left join
        (SELECT sum(rw.rework_num) as 'patchNumSum',
        rw.process_id,
        rw.order_sort,
        rw.technology_number,
        rwk.this_process
        from rework as rw
        LEFT JOIN
        reporting_work as rwk
        on rw.reporting_work_id = rwk.reporting_work_id
        where rwk.this_process = #{selectProcesses}
        and rw.review_status >= 0
        GROUP BY rw.process_id, rw.order_sort, rw.technology_number) as c
        on c.process_id = fc.process_id
        and c.order_sort = fc.order_number
        and c.technology_number = fc.technology_number
        left join sd.`order` as o
        on o.order_id = od.order_id
        left join
        (
        select a.process_id,a.teams_groups_name,a.next_process,b.technology_number,b.order_number
        from reporting_work  as a
        left join reporting_work_detail as b on a.reporting_work_id=b.reporting_work_id
        GROUP BY a.process_id,a.teams_groups_name,a.next_process,b.order_number,b.technology_number
        ) as rws on rws.process_id=fc.process_id and rws.order_number=fc.order_number
        and  rws.technology_number=fc.technology_number and rws.next_process=#{selectProcesses}
        where  o.create_order>0
        and odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count -
        odpd.broken_num != 0
        and odpd.process = #{selectProcesses}
        and position(#{orderId} in od.order_id)
        and position(#{inputProject} in o.project)
        <if test="workInProgressDTO.customerName != null and workInProgressDTO.customerName != ''">
            and o.customer_name regexp #{workInProgressDTO.customerName}
        </if>
        <if test="workInProgressDTO.project != null and workInProgressDTO.project != ''">
            and o.project regexp #{workInProgressDTO.project}
        </if>
        <if test="workInProgressDTO.orderId != null and workInProgressDTO.orderId != ''">
            and o.order_id regexp #{workInProgressDTO.orderId}
        </if>
        <if test="workInProgressDTO.batch != null and workInProgressDTO.batch != ''">
            and o.batch regexp #{workInProgressDTO.batch}
        </if>
        <if test="workInProgressDTO.processId != null and workInProgressDTO.processId != ''">
            and fc.process_id regexp #{workInProgressDTO.processId}
        </if>
        limit #{offset},#{pageSize};
    </select>
    <select id="scheduleProductionScheduleMp" resultMap="scheduleProductionScheduleMap">
        select ps.order_id,
        o.project,
        ps.processes,
        sum(ps.scheduling_quantity) as scheduling_quantity,
        notes,
        date(ps.scheduled_start_time) as scheduled_start_time,
        date(ps.plan_end_time) as plan_end_time
        from (select order_id, order_number, processes, scheduling_quantity, scheduled_start_time, plan_end_time, notes
        from production_scheduling
        where processes = #{processes}
        GROUP BY order_id, order_number) as ps
        left join sd.`order` as o on o.order_id = ps.order_id
        where ps.processes = #{processes} and o.create_order>0
        and  DATE_FORMAT((ps.scheduled_start_time), '%Y-%m-%d') between #{selectTime1} and #{selectTime2}
        <if test="scheduleProductionScheduleDTO.orderId != null and scheduleProductionScheduleDTO.orderId != ''">
            and ps.order_id regexp #{scheduleProductionScheduleDTO.orderId}
        </if>
        <if test="scheduleProductionScheduleDTO.project != null and scheduleProductionScheduleDTO.project != ''">
            and o.project regexp #{scheduleProductionScheduleDTO.project}
        </if>
        <if test="scheduleProductionScheduleDTO.processes != null and scheduleProductionScheduleDTO.processes != ''">
            and ps.processes regexp #{scheduleProductionScheduleDTO.processes}
        </if>
        <if test="scheduleProductionScheduleDTO.notes != null and scheduleProductionScheduleDTO.notes != ''">
            and ps.notes regexp #{scheduleProductionScheduleDTO.notes}
        </if>
        GROUP BY ps.order_id, ps.processes
        limit #{offset},#{pageSize};
    </select>
    <select id="getScheduleProductionScheduleTotal">
        select CEILING(count(ps.order_id)/#{pageSize}) as 'pageTotal',
        count(distinct ps.order_id) as 'total'
        from (select order_id, order_number, processes, scheduling_quantity, scheduled_start_time, plan_end_time, notes
        from production_scheduling
        where processes = #{processes}
        GROUP BY order_id, order_number) as ps
        left join sd.`order` as o on o.order_id = ps.order_id
        where ps.processes = #{processes} and o.create_order>0
        and  DATE_FORMAT((ps.scheduled_start_time), '%Y-%m-%d') between #{selectTime1} and #{selectTime2}
        <if test="scheduleProductionScheduleDTO.orderId != null and scheduleProductionScheduleDTO.orderId != ''">
            and ps.order_id regexp #{scheduleProductionScheduleDTO.orderId}
        </if>
        <if test="scheduleProductionScheduleDTO.project != null and scheduleProductionScheduleDTO.project != ''">
            and o.project regexp #{scheduleProductionScheduleDTO.project}
        </if>
        <if test="scheduleProductionScheduleDTO.processes != null and scheduleProductionScheduleDTO.processes != ''">
            and ps.processes regexp #{scheduleProductionScheduleDTO.processes}
        </if>
        <if test="scheduleProductionScheduleDTO.notes != null and scheduleProductionScheduleDTO.notes != ''">
            and ps.notes regexp #{scheduleProductionScheduleDTO.notes}
        </if>
        limit #{offset},#{pageSize};
    </select>
    <select id="exportScheduleReportMp">
        select ps.order_id,
               o.project,
               ps.processes,
               sum(ps.scheduling_quantity)   as scheduling_quantity,
               notes,
               date(ps.scheduled_start_time) as scheduled_start_time,
               date(ps.plan_end_time)        as plan_end_time
        from (select order_id, order_number, processes, scheduling_quantity, scheduled_start_time, plan_end_time, notes
              from production_scheduling
              where processes = #{process}
              GROUP BY order_id, order_number) as ps
                 left join sd.`order` as o on o.order_id = ps.order_id
        where ps.processes = #{process} and o.create_order>0
          and date(scheduled_start_time) >= #{date[0]}
          and date(scheduled_start_time) &lt;= #{date[1]}
        GROUP BY ps.order_id, ps.processes
    </select>
    <select id="workInProgressOrderFootSum">
        SELECT SUM(aa.quantity) AS quantity,
        sum(aa.stockNum) AS stockNum,
        SUM(aa.stockArea) AS stockArea,
        count(* ) AS 'total',
        CEILING( count(* )/#{pageSize} ) AS 'pageTotal'
        from
        (
        SELECT (od.quantity) AS quantity,
        d.numCounts + d.patchNumSum - d.numCount -d.broken_num as stockNum,
        ROUND(ogd.child_width * ogd.child_height *
        (d.numCounts + d.patchNumSum - d.numCount -
        d.broken_num) / 1000000, 2) as stockArea
        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 pp.flow_card AS fc
        ON fc.order_id = ogd.order_id
        and fc.production_id = ogd.production_id
        AND fc.order_number = ogd.order_number
        AND fc.technology_number = ogd.technology_number
        left join (
        SELECT
        odpd.process,
        odpd.process_id,
        odpd.order_number,
        odpd.technology_number,
        odpds.reporting_work_num_count as numCounts,
        ifnull( c.patchNumSum, 0 ) as patchNumSum,
        odpd.reporting_work_num_count as numCount,
        odpd.broken_num
        FROM
        sd.order_process_detail AS odpd
        LEFT JOIN sd.order_process_detail AS odpds ON odpds.id = odpd.id - 1
        LEFT JOIN (
        SELECT
        sum( rw.rework_num ) AS 'patchNumSum',
        rw.process_id,
        rw.order_sort,
        rw.technology_number,
        rwk.this_process
        FROM
        pp.rework AS rw
        LEFT JOIN pp.reporting_work AS rwk ON rw.reporting_work_id = rwk.reporting_work_id
        WHERE
        position( #{selectProcesses} IN rwk.this_process )
        AND rw.review_status >= 0
        GROUP BY
        rw.process_id,
        rw.order_sort,
        rw.technology_number
        ) AS c ON c.process_id = odpd.process_id
        AND c.order_sort = odpd.order_number
        AND c.technology_number = odpd.technology_number
        WHERE
        position(#{selectProcesses} IN odpd.process )  and odpds.reporting_work_num_count is not null
        GROUP BY
        odpd.process_id,
        odpd.order_number,
        odpd.technology_number,
        odpd.process
        ) as d
        on d.process_id=fc.process_id and d.order_number=fc.order_number and d.technology_number=fc.technology_number
        and position(#{selectProcesses} in d.process)
        left join sd.`order` as o on o.order_id=od.order_id
        where  o.create_order>0
        and d.numCounts +d.patchNumSum - d.numCount - d.broken_num != 0
        and d.process!=SUBSTRING_INDEX(ogd.process, '->', 1)
        and position(#{selectProcesses} in d.process)
        and position(#{orderId} in od.order_id)
        and position(#{inputProject} in o.project)
        <if test="terminationVals != '1' and terminationVals != 1">
            and fc.termination_status !=1
        </if>
        <if test="workInProgressDTO.thisProcess != null and workInProgressDTO.thisProcess != ''">
            and d.process like concat('%', #{workInProgressDTO.thisProcess}, '%')
        </if>
        <if test="workInProgressDTO.customerName != null and workInProgressDTO.customerName != ''">
            and o.customer_name like concat('%', #{workInProgressDTO.customerName}, '%')
        </if>
        <if test="workInProgressDTO.project != null and workInProgressDTO.project != ''">
            and o.project like concat('%', #{workInProgressDTO.project}, '%')
        </if>
        <if test="workInProgressDTO.orderId != null and workInProgressDTO.orderId != ''">
            and o.order_id like concat('%', #{workInProgressDTO.orderId}, '%')
        </if>
        <if test="workInProgressDTO.batch != null and workInProgressDTO.batch != ''">
            and o.batch like concat('%', #{workInProgressDTO.batch}, '%')
        </if>
        <if test="workInProgressDTO.processId != null and workInProgressDTO.processId != ''">
            and fc.process_id like concat('%', #{workInProgressDTO.processId}, '%')
        </if>
        <if test="workInProgressDTO.orderNumber != null and workInProgressDTO.orderNumber != ''">
            and ogd.order_number like concat('%', #{workInProgressDTO.orderNumber}, '%')
        </if>
        <if test="workInProgressDTO.technologyNumber != null and workInProgressDTO.technologyNumber != ''">
            and ogd.technology_number like concat('%', #{workInProgressDTO.technologyNumber}, '%')
        </if>
        <if test="workInProgressDTO.quantity != null and workInProgressDTO.quantity != ''">
            and od.quantity like concat('%', #{workInProgressDTO.quantity}, '%')
        </if>
        <if test="workInProgressDTO.childWidth != null and workInProgressDTO.childWidth != ''">
            and ogd.child_width regexp REGEXP_REPLACE(#{workInProgressDTO.childWidth},'\\.0+$','')
        </if>
        <if test="workInProgressDTO.childHeight != null and workInProgressDTO.childHeight != ''">
            and ogd.child_height regexp REGEXP_REPLACE(#{workInProgressDTO.childHeight},'\\.0+$','')
        </if>
        <if test="workInProgressDTO.stockNum != null and workInProgressDTO.stockNum != ''">
            and (d.numCounts + d.patchNumSum - d.numCount -d.broken_num) like concat('%', #{workInProgressDTO.stockNum}, '%')
        </if>
        <if test="workInProgressDTO.stockArea != null and workInProgressDTO.stockArea != ''">
            and ROUND(ogd.child_width * ogd.child_height * (d.numCounts + d.patchNumSum - d.numCount -
            d.broken_num) / 1000000, 2) regexp REGEXP_REPLACE(#{workInProgressDTO.stockArea},'\\.0+$','')
        </if>
        <if test="workInProgressDTO.glassNumber != null and workInProgressDTO.glassNumber != ''">
            and ifnull(JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')),'') like concat('%', #{workInProgressDTO.glassNumber}, '%')
        </if>
        group by fc.process_id, fc.order_number, fc.technology_number,d.process
        ) as aa
    </select>
    <select id="processToBeCompletedFootSum">
        SELECT
            SUM(fc.quantity) AS quantity,
            ROUND(SUM(ogd.child_width * ogd.child_height) / 1000000, 2) AS childArea,
            ROUND(SUM(ogd.child_width * ogd.child_height * fc.quantity) / 1000000, 2) AS actualArea,
            SUM(odpd.reporting_work_num) AS completeNum,
            ROUND(SUM(ogd.child_width * ogd.child_height * odpd.reporting_work_num) / 1000000, 2) AS completeArea,
            SUM(fc.quantity - odpd.reporting_work_num) AS incompleteNum,
            ROUND(SUM(ogd.child_width * ogd.child_height * (CAST(fc.quantity AS SIGNED) - CAST(odpd.reporting_work_num AS SIGNED))) / 1000000, 2) AS incompleteArea
        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 flow_card AS fc
                           ON fc.order_id = ogd.order_id
                               AND fc.production_id = ogd.production_id
                               AND fc.order_number = ogd.order_number
                               AND fc.technology_number = ogd.technology_number
                 LEFT JOIN sd.order_process_detail AS odpd
                           ON odpd.order_id = fc.order_id
                               AND odpd.order_number = fc.order_number
                               AND odpd.technology_number = fc.technology_number
                               AND odpd.process_id = fc.process_id
                 LEFT JOIN sd.`order` AS o
                           ON o.order_id = od.order_id
        WHERE o.create_order > 0
          and odpd.process = #{selectProcesses}
          and  o.create_time >= #{selectTime1}
          AND o.create_time &lt;  #{selectTime2}
          and position(#{orderId} in od.order_id)
          and position(#{inputProject} in o.project)
          AND CAST(fc.quantity AS SIGNED) - CAST(odpd.reporting_work_num AS SIGNED)>0;
    </select>
    <select id="damageReportFootSum">
        SELECT
            SUM(dd.breakage_quantity) AS breakageQuantity,
            ROUND(SUM(ogd.child_width * ogd.child_height * dd.breakage_quantity) / 1000000, 2) AS area
        FROM
            sd.ORDER AS o
                LEFT JOIN sd.order_glass_detail AS ogd ON ogd.order_id = o.order_id
                LEFT JOIN pp.reporting_work AS rw ON rw.order_id = o.order_id
                LEFT JOIN pp.damage_details AS dd ON dd.reporting_work_id = rw.reporting_work_id
                AND dd.order_number = ogd.order_number
                AND dd.technology_number = ogd.technology_number
                LEFT JOIN sd.order_detail AS od ON o.order_id = od.order_id
                AND od.order_number = ogd.order_number
        WHERE
            rw.reporting_work_time >= #{selectTime1}
          AND rw.reporting_work_time &lt;=  #{selectTime2}
          AND dd.available = 0 and rw.reviewed_state>=0
        <if test="damageReportDTO.orderId != null and damageReportDTO.orderId != ''">
            and o.order_id like concat('%', #{damageReportDTO.orderId}, '%')
        </if>
        <if test="damageReportDTO.project != null and damageReportDTO.project != ''">
            and o.project like concat('%', #{damageReportDTO.project}, '%')
        </if>
        <if test="damageReportDTO.processId != null and damageReportDTO.processId != ''">
            and rw.process_id like concat('%', #{damageReportDTO.processId}, '%')
        </if>
        <if test="damageReportDTO.orderNumber != null and damageReportDTO.orderNumber != ''">
            and dd.order_number like concat('%', #{damageReportDTO.orderNumber}, '%')
        </if>
        <if test="damageReportDTO.technologyNumber != null and damageReportDTO.technologyNumber != ''">
            and dd.technology_number like concat('%', #{damageReportDTO.technologyNumber}, '%')
        </if>
        <if test="damageReportDTO.responsibleProcess != null and damageReportDTO.responsibleProcess != ''">
            and dd.responsible_process like concat('%', #{damageReportDTO.responsibleProcess}, '%')
        </if>
        <if test="damageReportDTO.responsibleTeam != null and damageReportDTO.responsibleTeam != ''">
            and dd.responsible_team like concat('%', #{damageReportDTO.responsibleTeam}, '%')
        </if>
        <if test="damageReportDTO.responsibleEquipment != null and damageReportDTO.responsibleEquipment != ''">
            and dd.responsible_equipment like concat('%', #{damageReportDTO.responsibleEquipment}, '%')
        </if>
        <if test="damageReportDTO.breakageType != null and damageReportDTO.breakageType != ''">
            and dd.breakage_type like concat('%', #{damageReportDTO.breakageType}, '%')
        </if>
        <if test="damageReportDTO.breakageReason != null and damageReportDTO.breakageReason != ''">
            and dd.breakage_reason like concat('%', #{damageReportDTO.breakageReason}, '%')
        </if>
        <if test="damageReportDTO.glassChild != null and damageReportDTO.glassChild != ''">
            and ogd.glass_child like concat('%', #{damageReportDTO.glassChild}, '%')
        </if>
        <if test="damageReportDTO.glassNumber != null and damageReportDTO.glassNumber != ''">
            and ifnull(JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')),'') like concat('%', #{damageReportDTO.glassNumber}, '%')
        </if>
        <if test="damageReportDTO.thisProcess != null and damageReportDTO.thisProcess != ''">
            and rw.this_process like concat('%', #{damageReportDTO.thisProcess}, '%')
        </if>
        <if test="damageReportDTO.creator != null and damageReportDTO.creator != ''">
            and rw.creator like concat('%', #{damageReportDTO.creator}, '%')
        </if>
        <if test="damageReportDTO.reportingWorkId != null and damageReportDTO.reportingWorkId != ''">
            and rw.reporting_work_id like concat('%', #{damageReportDTO.reportingWorkId}, '%')
        </if>
        <if test="damageReportDTO.childWidth != null and damageReportDTO.childWidth != ''">
            and ogd.child_width regexp REGEXP_REPLACE(#{damageReportDTO.childWidth},'\\.0+$','')
        </if>
        <if test="damageReportDTO.childHeight != null and damageReportDTO.childHeight != ''">
            and ogd.child_height regexp REGEXP_REPLACE(#{damageReportDTO.childHeight},'\\.0+$','')
        </if>
    </select>
    <select id="teamOutputFootSum">
        SELECT
        -- 数量合计
        SUM(x.completed_quantity)              AS completedQuantity,
        -- 面积合计
        IFNULL(SUM(x.area), 0)                 AS area,
        -- 厚度×面积合计
        IFNULL(SUM(x.thicknessArea), 0)        AS thicknessArea
        FROM (
        /* 第 2 层:在这里根据 workProcessName 计算 thicknessSum / thicknessArea */
        SELECT
        t.*,
        /* 玻璃总厚度:只取每段前面的数字相加 */
        CASE
        WHEN t.workProcessName IS NULL OR t.workProcessName = '' THEN 0
        ELSE (
        SELECT SUM(CAST(REGEXP_SUBSTR(seg, '^[0-9]+') AS UNSIGNED))
        FROM JSON_TABLE(
        CAST(CONCAT('["', REPLACE(t.workProcessName, '+', '","'), '"]') AS JSON),
        '$[*]' COLUMNS (seg VARCHAR(100) PATH '$')
        ) jt
        )
        END AS thicknessSum,
        /* 厚度 × 面积 */
        CASE
        WHEN t.workProcessName IS NULL OR t.workProcessName = '' THEN 0
        ELSE ROUND(
        (
        SELECT SUM(CAST(REGEXP_SUBSTR(seg2, '^[0-9]+') AS UNSIGNED))
        FROM JSON_TABLE(
        CAST(CONCAT('["', REPLACE(t.workProcessName, '+', '","'), '"]') AS JSON),
        '$[*]' COLUMNS (seg2 VARCHAR(100) PATH '$')
        ) jt2
        ) * t.area,
        2
        )
        END AS thicknessArea
        FROM (
        /* 第 1 层:只负责算好 workProcessName、area 等基础字段 */
        SELECT
        rw.reporting_work_time,
        rw.this_process,
        rw.teams_groups_name,
        o.project,
        rw.process_id,
        fc.order_number,
        MAX(ogd.child_width)  AS width,
        MAX(ogd.child_height) AS height,
        od.edging_type,
        rwd.completed_quantity AS completed_quantity,
        ROUND(MAX(ogd.child_width) * MAX(ogd.child_height) * rwd.completed_quantity / 1000000, 2) AS area,
        od.product_name,
        JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')) AS code,
        rw.reviewed,
        rw.examine_time,
        rw.device_name,
        o.order_type,
        CASE
        WHEN LOCATE('step', #{laminating}) > 0 THEN GROUP_CONCAT(ogd.glass_child SEPARATOR '+')
        ELSE MAX(ogd.glass_child)
        END AS workProcessName,
        o.batch
        FROM
        pp.reporting_work AS rw
        LEFT JOIN pp.reporting_work_detail AS rwd
        ON rwd.reporting_work_id = rw.reporting_work_id
        LEFT JOIN pp.flow_card AS fc
        ON fc.order_id = rw.order_id
        AND fc.process_id = rw.process_id
        AND fc.order_number = rwd.order_number
        AND fc.technology_number = rwd.technology_number
        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 = ogd.order_id
        AND od.order_number = ogd.order_number
        LEFT JOIN sd.`order` AS o
        ON o.order_id = od.order_id
        WHERE
        o.create_order > 0
        AND rw.reviewed_state >= 0
        AND rwd.completed_quantity > 0
        AND rw.reporting_work_time &gt;= #{selectTime1}
        AND rw.reporting_work_time &lt;  #{selectTime2}
        <choose>
            <!-- 有传工序:精确匹配 -->
            <when test="selectProcesses != null and selectProcesses != ''">
                AND rw.this_process = #{selectProcesses}
            </when>
            <!-- 未传工序:不加限制,查所有) -->
            <otherwise>
            </otherwise>
        </choose>
        <if test="teamOutputDTO.thisProcess != null and teamOutputDTO.thisProcess != ''">
            AND rw.this_process REGEXP #{teamOutputDTO.thisProcess}
        </if>
        <if test="teamOutputDTO.teamsGroupsName != null and teamOutputDTO.teamsGroupsName != ''">
            AND rw.teams_groups_name LIKE CONCAT('%', #{teamOutputDTO.teamsGroupsName}, '%')
        </if>
        <if test="teamOutputDTO.project != null and teamOutputDTO.project != ''">
            AND o.project REGEXP #{teamOutputDTO.project}
        </if>
        <if test="teamOutputDTO.processId != null and teamOutputDTO.processId != ''">
            AND rw.process_id REGEXP #{teamOutputDTO.processId}
        </if>
        <if test="teamOutputDTO.edgingType != null and teamOutputDTO.edgingType != ''">
            AND od.edging_type REGEXP #{teamOutputDTO.edgingType}
        </if>
        <if test="teamOutputDTO.deviceName != null and teamOutputDTO.deviceName != ''">
            AND rw.device_name REGEXP #{teamOutputDTO.deviceName}
        </if>
        <if test="teamOutputDTO.batch != null and teamOutputDTO.batch != ''">
            AND o.batch REGEXP #{teamOutputDTO.batch}
        </if>
        <if test="teamOutputDTO.width != null and teamOutputDTO.width != ''">
            and ogd.child_width regexp REGEXP_REPLACE(#{teamOutputDTO.width},'\\.0+$','')
        </if>
        <if test="teamOutputDTO.height != null and teamOutputDTO.height != ''">
            and ogd.child_height regexp REGEXP_REPLACE(#{teamOutputDTO.height},'\\.0+$','')
        </if>
        <choose>
            <when test="laminating == ''">
                GROUP BY
                rw.reporting_work_id,
                rw.process_id,
                rw.this_process,
                rw.teams_groups_name,
                rwd.order_number,
                rwd.technology_number
            </when>
            <otherwise>
                GROUP BY
                <if test="laminating == 'stepA' || laminating == 'stepC'">
                    ogd.`group`,
                </if>
                rw.reporting_work_id,
                rw.process_id,
                rw.this_process,
                rw.teams_groups_name,
                rwd.order_number
            </otherwise>
        </choose>
        ) t
        WHERE 1 = 1
        <if test="teamOutputDTO.workProcessName != null and teamOutputDTO.workProcessName != ''">
            AND t.workProcessName REGEXP #{teamOutputDTO.workProcessName}
        </if>
        ) x
        WHERE 1 = 1
        <if test="teamOutputDTO.thicknessSum != null and teamOutputDTO.thicknessSum != ''">
            and thicknessSum regexp REGEXP_REPLACE(#{teamOutputDTO.thicknessSum},'\\.0+$','')
        </if>
        <if test="teamOutputDTO.thicknessArea != null and teamOutputDTO.thicknessArea != ''">
            AND x.thicknessArea REGEXP #{teamOutputDTO.thicknessArea}
        </if>
        ;
    </select>
    <select id="getLaminating">
        select IFNULL(nickname,'') from sd.basic_data where basic_category='process' and basic_name=#{selectProcesses}
    </select>
    <select id="workInProgressMpdataList1" resultMap="workInProgressMap">
        select d.process as thisProcess,
        fc.process_id,
        o.customer_name,
        o.project,
        o.order_id,
        o.batch,
        od.shape,
        if(od.shape=2,JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S04')),od.bend_radius) as bend_radius,
        ogd.order_number,
        ogd.technology_number,
        ogd.process,
        od.quantity,
        ogd.child_width,
        ogd.child_height,
        d.numCounts + d.patchNumSum - d.numCount -d.broken_num as stockNum,
        ROUND(ogd.child_width * ogd.child_height *
        (d.numCounts + d.patchNumSum - d.numCount -
        d.broken_num) / 1000000, 2) as stockArea,
        od.product_name,
        od.bend_radius,
        ifnull(JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')),'') AS glassNumber
        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 pp.flow_card AS fc
        ON fc.order_id = ogd.order_id
        and fc.production_id = ogd.production_id
        AND fc.order_number = ogd.order_number
        AND fc.technology_number = ogd.technology_number
        left join (
        SELECT
        odpd.process,
        odpd.process_id,
        odpd.order_number,
        odpd.technology_number,
        odpds.reporting_work_num_count as numCounts,
        ifnull( c.patchNumSum, 0 ) as patchNumSum,
        odpd.reporting_work_num_count as numCount,
        odpd.broken_num
        FROM
        sd.order_process_detail AS odpd
        LEFT JOIN sd.order_process_detail AS odpds ON odpds.id = odpd.id - 1
        LEFT JOIN (
        SELECT
        sum( rw.rework_num ) AS 'patchNumSum',
        rw.process_id,
        rw.order_sort,
        rw.technology_number,
        rwk.this_process
        FROM
        pp.rework AS rw
        LEFT JOIN pp.reporting_work AS rwk ON rw.reporting_work_id = rwk.reporting_work_id
        WHERE
        position( #{selectProcesses} IN rwk.this_process )
        AND rw.review_status >= 0
        GROUP BY
        rw.process_id,
        rw.order_sort,
        rw.technology_number
        ) AS c ON c.process_id = odpd.process_id
        AND c.order_sort = odpd.order_number
        AND c.technology_number = odpd.technology_number
        WHERE
        position(#{selectProcesses} IN odpd.process )  and odpds.reporting_work_num_count is not null
        GROUP BY
        odpd.process_id,
        odpd.order_number,
        odpd.technology_number,
        odpd.process
        ) as d
        on d.process_id=fc.process_id and d.order_number=fc.order_number and d.technology_number=fc.technology_number
        left join sd.`order` as o on o.order_id=od.order_id
        LEFT JOIN sd.basic_data AS bd ON bd.basic_name = d.process
        where  o.create_order>0
        and d.numCounts +d.patchNumSum - d.numCount - d.broken_num != 0
        and d.process!=SUBSTRING_INDEX(ogd.process, '->', 1)
        and position(#{orderId} in od.order_id)
        and position(#{inputProject} in o.project)
        <if test="terminationVals != '1' and terminationVals != 1">
            and fc.termination_status !=1
        </if>
        <if test="workInProgressDTO.thisProcess != null and workInProgressDTO.thisProcess != ''">
            and d.process like concat('%', #{workInProgressDTO.thisProcess}, '%')
        </if>
        <if test="workInProgressDTO.customerName != null and workInProgressDTO.customerName != ''">
            and o.customer_name like concat('%', #{workInProgressDTO.customerName}, '%')
        </if>
        <if test="workInProgressDTO.project != null and workInProgressDTO.project != ''">
            and o.project like concat('%', #{workInProgressDTO.project}, '%')
        </if>
        <if test="workInProgressDTO.orderId != null and workInProgressDTO.orderId != ''">
            and o.order_id like concat('%', #{workInProgressDTO.orderId}, '%')
        </if>
        <if test="workInProgressDTO.batch != null and workInProgressDTO.batch != ''">
            and o.batch like concat('%', #{workInProgressDTO.batch}, '%')
        </if>
        <if test="workInProgressDTO.processId != null and workInProgressDTO.processId != ''">
            and fc.process_id like concat('%', #{workInProgressDTO.processId}, '%')
        </if>
        <if test="workInProgressDTO.orderNumber != null and workInProgressDTO.orderNumber != ''">
            and ogd.order_number like concat('%', #{workInProgressDTO.orderNumber}, '%')
        </if>
        <if test="workInProgressDTO.technologyNumber != null and workInProgressDTO.technologyNumber != ''">
            and ogd.technology_number like concat('%', #{workInProgressDTO.technologyNumber}, '%')
        </if>
        <if test="workInProgressDTO.quantity != null and workInProgressDTO.quantity != ''">
            and od.quantity like concat('%', #{workInProgressDTO.quantity}, '%')
        </if>
        <if test="workInProgressDTO.childWidth != null and workInProgressDTO.childWidth != ''">
            and ogd.child_width regexp REGEXP_REPLACE(#{workInProgressDTO.childWidth},'\\.0+$','')
        </if>
        <if test="workInProgressDTO.childHeight != null and workInProgressDTO.childHeight != ''">
            and ogd.child_height regexp REGEXP_REPLACE(#{workInProgressDTO.childHeight},'\\.0+$','')
        </if>
        <if test="workInProgressDTO.stockNum != null and workInProgressDTO.stockNum != ''">
            and (d.numCounts + d.patchNumSum - d.numCount -d.broken_num) like concat('%', #{workInProgressDTO.stockNum}, '%')
        </if>
        <if test="workInProgressDTO.stockArea != null and workInProgressDTO.stockArea != ''">
            and ROUND(ogd.child_width * ogd.child_height * (d.numCounts + d.patchNumSum - d.numCount -
            d.broken_num) / 1000000, 2) regexp REGEXP_REPLACE(#{workInProgressDTO.stockArea},'\\.0+$','')
        </if>
        <if test="workInProgressDTO.glassNumber != null and workInProgressDTO.glassNumber != ''">
            and ifnull(JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')),'') like concat('%', #{workInProgressDTO.glassNumber}, '%')
        </if>
        <choose>
            <when test="laminating != null and laminating == 'stepC'">
                GROUP BY fc.process_id, fc.order_number, ogd.`group`, d.process
            </when>
            <when test="laminating != null and laminating == 'stepD'">
                GROUP BY fc.process_id, fc.order_number, d.process
            </when>
            <when test="laminating != null and laminating == 'stepB'">
                GROUP BY fc.process_id, fc.order_number, d.process
            </when>
            <otherwise>
                GROUP BY fc.process_id, fc.order_number, fc.technology_number, d.process
            </otherwise>
        </choose>
        order by d.process,fc.process_id, fc.order_number, fc.technology_number
        limit #{offset},#{pageSize};
    </select>
    <select id="workInProgressMpdataList2" resultMap="workInProgressMap">
        select
            a.process_id,a.teams_groups_name,a.next_process,b.technology_number,b.order_number
        from pp.reporting_work  as a
                 left join pp.reporting_work_detail as b on a.reporting_work_id=b.reporting_work_id
        where position(#{selectProcesses} in a.next_process) and a.next_process!='切割'
        GROUP BY a.reporting_work_id
    </select>
    <select id="workInProgressOrderMpList1" resultMap="workInProgressMap">
        select if(#{selectProcesses}='',odpd.process,#{selectProcesses}) as thisProcess,
        o.customer_name,
        o.project,
        o.order_id,
        o.batch,
        od.shape,
        sum(od.quantity) as quantity,
        sum(odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count -
        odpd.broken_num) as stockNum,
        sum(ROUND(ogd.child_width * ogd.child_height *
        (odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count -
        odpd.broken_num) / 1000000, 2)) as stockArea,
        od.product_name
        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 flow_card AS fc
        ON fc.order_id = ogd.order_id
        and fc.production_id = ogd.production_id
        AND fc.order_number = ogd.order_number
        AND fc.technology_number = ogd.technology_number
        left join sd.order_process_detail as odpd
        ON odpd.order_id = fc.order_id
        AND odpd.order_number = fc.order_number
        AND odpd.technology_number = fc.technology_number
        and odpd.process_id = fc.process_id
        left join sd.order_process_detail as odpds
        ON odpds.id = odpd.id - 1
        left join
        (SELECT sum(rw.rework_num) as 'patchNumSum',
        rw.process_id,
        rw.order_sort,
        rw.technology_number,
        rwk.this_process
        from rework as rw
        LEFT JOIN
        reporting_work as rwk
        on rw.reporting_work_id = rwk.reporting_work_id
        where position(#{selectProcesses} in rwk.this_process)
        and rw.review_status >= 0
        GROUP BY rw.process_id, rw.order_sort, rw.technology_number) as c
        on c.process_id = fc.process_id
        and c.order_sort = fc.order_number
        and c.technology_number = fc.technology_number
        left join sd.`order` as o
        on o.order_id = od.order_id
        where  o.create_order>0
        and odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count -
        odpd.broken_num != 0 and odpd.process!=SUBSTRING_INDEX(ogd.process, '->', 1)
        and position(#{selectProcesses} in odpd.process)
        and position(#{orderId} in od.order_id)
        and position(#{inputProject} in o.project)
        <if test="workInProgressDTO.customerName != null and workInProgressDTO.customerName != ''">
            and o.customer_name regexp #{workInProgressDTO.customerName}
        </if>
        <if test="workInProgressDTO.project != null and workInProgressDTO.project != ''">
            and o.project regexp #{workInProgressDTO.project}
        </if>
        <if test="workInProgressDTO.orderId != null and workInProgressDTO.orderId != ''">
            and o.order_id regexp #{workInProgressDTO.orderId}
        </if>
        <if test="workInProgressDTO.batch != null and workInProgressDTO.batch != ''">
            and o.batch regexp #{workInProgressDTO.batch}
        </if>
        group by o.order_id
        order by o.order_id
        limit #{offset},#{pageSize};
    </select>
    <select id="workInProgressProcessMpList1" resultMap="workInProgressMap">
        select if(#{selectProcesses}='',odpd.process,#{selectProcesses}) as thisProcess,
        o.customer_name,
        o.project,
        o.order_id,
        fc.process_id,
        o.batch,
        od.shape,
        sum(od.quantity) as quantity,
        sum(odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count -
        odpd.broken_num) as stockNum,
        sum(ROUND(ogd.child_width * ogd.child_height *
        (odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count -
        odpd.broken_num) / 1000000, 2)) as stockArea,
        od.product_name
        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 flow_card AS fc
        ON fc.order_id = ogd.order_id
        and fc.production_id = ogd.production_id
        AND fc.order_number = ogd.order_number
        AND fc.technology_number = ogd.technology_number
        left join sd.order_process_detail as odpd
        ON odpd.order_id = fc.order_id
        AND odpd.order_number = fc.order_number
        AND odpd.technology_number = fc.technology_number
        and odpd.process_id = fc.process_id
        left join sd.order_process_detail as odpds
        ON odpds.id = odpd.id - 1
        left join
        (SELECT sum(rw.rework_num) as 'patchNumSum',
        rw.process_id,
        rw.order_sort,
        rw.technology_number,
        rwk.this_process
        from rework as rw
        LEFT JOIN
        reporting_work as rwk
        on rw.reporting_work_id = rwk.reporting_work_id
        where position(#{selectProcesses} in rwk.this_process)
        and rw.review_status >= 0
        GROUP BY rw.process_id, rw.order_sort, rw.technology_number) as c
        on c.process_id = fc.process_id
        and c.order_sort = fc.order_number
        and c.technology_number = fc.technology_number
        left join sd.`order` as o
        on o.order_id = od.order_id
        where  o.create_order>0
        and odpds.reporting_work_num_count + ifnull(c.patchNumSum, 0) - odpd.reporting_work_num_count -
        odpd.broken_num != 0 and odpd.process!=SUBSTRING_INDEX(ogd.process, '->', 1)
        and position(#{selectProcesses} in odpd.process)
        and position(#{orderId} in od.order_id)
        and position(#{inputProject} in o.project)
        <if test="workInProgressDTO.customerName != null and workInProgressDTO.customerName != ''">
            and o.customer_name regexp #{workInProgressDTO.customerName}
        </if>
        <if test="workInProgressDTO.project != null and workInProgressDTO.project != ''">
            and o.project regexp #{workInProgressDTO.project}
        </if>
        <if test="workInProgressDTO.orderId != null and workInProgressDTO.orderId != ''">
            and o.order_id regexp #{workInProgressDTO.orderId}
        </if>
        <if test="workInProgressDTO.batch != null and workInProgressDTO.batch != ''">
            and o.batch regexp #{workInProgressDTO.batch}
        </if>
        <if test="workInProgressDTO.processId != null and workInProgressDTO.processId != ''">
            and fc.process_id regexp #{workInProgressDTO.processId}
        </if>
        group by o.order_id, fc.process_id
        order by o.order_id, fc.process_id
        limit #{offset},#{pageSize};
    </select>
    <select id="exportWorkInProgressMpdataList2">
        select
            a.process_id,a.teams_groups_name,a.next_process,b.technology_number,b.order_number
        from pp.reporting_work  as a
                 left join pp.reporting_work_detail as b on a.reporting_work_id=b.reporting_work_id
        where position(#{process} in a.next_process) and a.next_process!='切割'
        GROUP BY a.reporting_work_id
    </select>
    <select id="workInProgressCombinationMpdataList2">
        select
            a.process_id,a.teams_groups_name,a.next_process,b.technology_number,b.order_number
        from pp.reporting_work  as a
                 left join pp.reporting_work_detail as b on a.reporting_work_id=b.reporting_work_id
        where position(#{selectProcesses} in a.next_process) and a.next_process!='切割'
        GROUP BY a.reporting_work_id
    </select>
    <select id="workInProgressCombinationMpdataList1">
        select if(#{selectProcesses}='',d.process,#{selectProcesses}) as thisProcess,
        o.project,
        SUM(d.numCounts + d.patchNumSum - d.numCount -d.broken_num) as stockNum,
        SUM(ROUND(ogd.child_width * ogd.child_height *
        (d.numCounts + d.patchNumSum - d.numCount -
        d.broken_num) / 1000000, 2)) as stockArea
        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 pp.flow_card AS fc
        ON fc.order_id = ogd.order_id
        and fc.production_id = ogd.production_id
        AND fc.order_number = ogd.order_number
        AND fc.technology_number = ogd.technology_number
        left join (
        SELECT
        odpd.process,
        odpd.process_id,
        odpd.order_number,
        odpd.technology_number,
        odpds.reporting_work_num_count as numCounts,
        ifnull( c.patchNumSum, 0 ) as patchNumSum,
        odpd.reporting_work_num_count as numCount,
        odpd.broken_num
        FROM
        sd.order_process_detail AS odpd
        LEFT JOIN sd.order_process_detail AS odpds ON odpds.id = odpd.id - 1
        LEFT JOIN (
        SELECT
        sum( rw.rework_num ) AS 'patchNumSum',
        rw.process_id,
        rw.order_sort,
        rw.technology_number,
        rwk.this_process
        FROM
        pp.rework AS rw
        LEFT JOIN pp.reporting_work AS rwk ON rw.reporting_work_id = rwk.reporting_work_id
        WHERE
        position( #{selectProcesses} IN rwk.this_process )
        AND rw.review_status >= 0
        GROUP BY
        rw.process_id,
        rw.order_sort,
        rw.technology_number
        ) AS c ON c.process_id = odpd.process_id
        AND c.order_sort = odpd.order_number
        AND c.technology_number = odpd.technology_number
        WHERE
        position(#{selectProcesses} IN odpd.process )  and odpds.reporting_work_num_count is not null
        GROUP BY
        odpd.process_id,
        odpd.order_number,
        odpd.technology_number,
        odpd.process
        ) as d
        on d.process_id=fc.process_id and d.order_number=fc.order_number and d.technology_number=fc.technology_number
        and position(#{selectProcesses} in d.process)
        left join sd.`order` as o on o.order_id=od.order_id
        where  o.create_order>0
        and d.numCounts +d.patchNumSum - d.numCount - d.broken_num != 0
        and d.process!=SUBSTRING_INDEX(ogd.process, '->', 1)
        and position(#{selectProcesses} in d.process)
        <if test="workInProgressDTO.project != null and workInProgressDTO.project != ''">
            and o.project regexp #{workInProgressDTO.project}
        </if>
        group by d.process
        order by d.process
        limit #{offset},#{pageSize};
    </select>
    <select id="workInProgressCombinationOrderFootSum">
        SELECT SUM(aa.quantity) AS quantity,
        sum(aa.stockNum) AS stockNum,
        SUM(aa.stockArea) AS stockArea,
        count(* ) AS 'total',
        CEILING( count(* )/#{pageSize} ) AS 'pageTotal'
        from
        (
        SELECT (od.quantity) AS quantity,
        d.numCounts + d.patchNumSum - d.numCount -d.broken_num as stockNum,
        ROUND(ogd.child_width * ogd.child_height *
        (d.numCounts + d.patchNumSum - d.numCount -
        d.broken_num) / 1000000, 2) as stockArea
        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 pp.flow_card AS fc
        ON fc.order_id = ogd.order_id
        and fc.production_id = ogd.production_id
        AND fc.order_number = ogd.order_number
        AND fc.technology_number = ogd.technology_number
        left join (
        SELECT
        odpd.process,
        odpd.process_id,
        odpd.order_number,
        odpd.technology_number,
        odpds.reporting_work_num_count as numCounts,
        ifnull( c.patchNumSum, 0 ) as patchNumSum,
        odpd.reporting_work_num_count as numCount,
        odpd.broken_num
        FROM
        sd.order_process_detail AS odpd
        LEFT JOIN sd.order_process_detail AS odpds ON odpds.id = odpd.id - 1
        LEFT JOIN (
        SELECT
        sum( rw.rework_num ) AS 'patchNumSum',
        rw.process_id,
        rw.order_sort,
        rw.technology_number,
        rwk.this_process
        FROM
        pp.rework AS rw
        LEFT JOIN pp.reporting_work AS rwk ON rw.reporting_work_id = rwk.reporting_work_id
        WHERE
        position( #{selectProcesses} IN rwk.this_process )
        AND rw.review_status >= 0
        GROUP BY
        rw.process_id,
        rw.order_sort,
        rw.technology_number
        ) AS c ON c.process_id = odpd.process_id
        AND c.order_sort = odpd.order_number
        AND c.technology_number = odpd.technology_number
        WHERE
        position(#{selectProcesses} IN odpd.process )  and odpds.reporting_work_num_count is not null
        GROUP BY
        odpd.process_id,
        odpd.order_number,
        odpd.technology_number,
        odpd.process
        ) as d
        on d.process_id=fc.process_id and d.order_number=fc.order_number and d.technology_number=fc.technology_number
        and position(#{selectProcesses} in d.process)
        left join sd.`order` as o on o.order_id=od.order_id
        where  o.create_order>0
        and d.numCounts +d.patchNumSum - d.numCount - d.broken_num != 0
        and d.process!=SUBSTRING_INDEX(ogd.process, '->', 1)
        and position(#{selectProcesses} in d.process)
        <if test="workInProgressDTO.project != null and workInProgressDTO.project != ''">
            and o.project regexp #{workInProgressDTO.project}
        </if>
        group by d.process
        ) as aa
    </select>
    <select id="selectProcess">
        SELECT basic_name
        FROM sd.basic_data as bd
        where bd.basic_category = 'process'
          and bd.basic_type = 'product'
        and basic_name!='切割'
    </select>
    <select id="getWorkInProgressCombination">
        select
            #{process} as thisProcess,
            if(#{optionVal} = 1,'',h.project) as project,
            SUM(h.quantity) as stockNum,
            SUM(h.glassArea) as stockArea,
            if(#{optionVal} = 1,'',h.childName) as glassName
        from (
                 SELECT g.*
                      ,GROUP_CONCAT(g.glass_child SEPARATOR '+')  as childName
                 from( SELECT f.*,
        e.reporting_work_num_count+f.patchNumSum-f.reporting_work_num_count-f.broken_num as quantity,
        (e.reporting_work_num_count+f.patchNumSum-f.reporting_work_num_count-f.broken_num)*f.area as glassArea
                       from (SELECT a.order_id,
                                   if(a.batch!="",CONCAT(a.project,'(',a.batch,')'),a.project) as project,
                                    C.product_id,
                                    b.order_number,
                                    b.process_id,
                                    b.technology_number,
                                    b.reporting_work_num_count,
                                    d.`group` ,
                                    b.broken_num,
                                    b.id,
                                    c.area,
                                    d.glass_child,
                                    ifnull(cb.patchNumSum,0) as patchNumSum
                             FROM sd.`order` as a
                                      LEFT JOIN sd.order_process_detail as b
                                                on b.process = #{process} and a.order_id =b.order_id
                                      LEFT JOIN sd.order_detail as c
                                                on a.order_id = c.order_id and b.order_number =c.order_number
                                      left join sd.order_glass_detail as d
                                                on  d.order_id =a.order_id and d.order_number = b.order_number and d.technology_number = b.technology_number
                                      LEFT JOIN (
                                        SELECT
                                        IFNULL(sum( rw.rework_num ),0) AS 'patchNumSum',
                                        rw.process_id,
                                        rw.order_sort,
                                        rw.technology_number,
                                        rwk.this_process
                                        FROM
                                        pp.rework AS rw
                                        LEFT JOIN pp.reporting_work AS rwk ON rw.reporting_work_id = rwk.reporting_work_id
                                        WHERE
                                        position( #{process} IN rwk.this_process )
                                        AND rw.review_status >= 0
                                        GROUP BY
                                        rw.process_id,
                                        rw.order_sort,
                                        rw.technology_number
                                        ) AS cb ON cb.process_id = b.process_id
                                        AND cb.order_sort = b.order_number
                                        AND cb.technology_number = b.technology_number
                             left join pp.flow_card as fc on fc.order_id= d.order_id and fc.order_number = d.order_number
                                       and fc.technology_number = d.technology_number
                             where a.processing_card>0
                               and a.warehousing!=2
                          <if test=" terminationVal != '1' and terminationVal != 1">
                               and termination_status !=1
                            </if>
                             GROUP BY  b.process_id, b.order_number,
                                 b.technology_number) as f
                                LEFT JOIN sd.order_process_detail as e
                                          on e.id=(f.id-1) and e.process_id = f.process_id and e.order_number = f.order_number and e.technology_number =f.technology_number
                       where
                           e.id is not null
                         and (e.reporting_work_num_count+f.patchNumSum-f.reporting_work_num_count-f.broken_num)>0 group by f.process_id, f.order_number,
        f.technology_number ORDER BY f.process_id, f.order_number,
        f.technology_number) as g
                            <choose>
                                <when test="laminating == 'stepC' and process == '预压'">
                                    GROUP BY g.process_id, g.order_number, g.technology_number
                                </when>
                                <when test="laminating == 'stepC'">
                                    GROUP BY g.process_id, g.order_number, g.`group`
                                </when>
                                <when test="laminating == 'stepD'">
                                    GROUP BY g.process_id, g.order_number
                                </when>
                                <otherwise>
                                    GROUP BY g.process_id, g.order_number, g.technology_number
                                </otherwise>
                            </choose>
             ) as h
        <choose>
            <when test="optionVal == 1">
                GROUP BY thisProcess
            </when>
            <otherwise>
                GROUP BY h.project,h.childName
            </otherwise>
        </choose>
    </select>
    <select id="getWorkInProgressCombinationFootSum">
        select
        SUM(h.quantity) as stockNum,
        SUM(h.glassArea) as stockArea
        from (
        SELECT g.*
        ,GROUP_CONCAT(g.glass_child SEPARATOR '+')  as childName
        from( SELECT f.*,
        e.reporting_work_num_count+f.patchNumSum-f.reporting_work_num_count-f.broken_num as quantity,
        (e.reporting_work_num_count+f.patchNumSum-f.reporting_work_num_count-f.broken_num)*f.area as glassArea
        from (SELECT a.order_id,
        a.project,
        C.product_id,
        b.order_number,
        b.process_id,
        b.technology_number,
        b.reporting_work_num_count,
        d.`group` ,
        b.broken_num,
        b.id,
        c.area,
        d.glass_child,
        ifnull(cb.patchNumSum,0) as patchNumSum
        FROM sd.`order` as a
        LEFT JOIN sd.order_process_detail as b
        on b.process = #{process} and a.order_id =b.order_id
        LEFT JOIN sd.order_detail as c
        on a.order_id = c.order_id and b.order_number =c.order_number
        left join sd.order_glass_detail as d
        on  d.order_id =a.order_id and d.order_number = b.order_number and d.technology_number = b.technology_number
        LEFT JOIN (
        SELECT
        IFNULL(sum( rw.rework_num ),0) AS 'patchNumSum',
        rw.process_id,
        rw.order_sort,
        rw.technology_number,
        rwk.this_process
        FROM
        pp.rework AS rw
        LEFT JOIN pp.reporting_work AS rwk ON rw.reporting_work_id = rwk.reporting_work_id
        WHERE
        position( #{process} IN rwk.this_process )
        AND rw.review_status >= 0
        GROUP BY
        rw.process_id,
        rw.order_sort,
        rw.technology_number
        ) AS cb ON cb.process_id = b.process_id
        AND cb.order_sort = b.order_number
        AND cb.technology_number = b.technology_number
        left join pp.flow_card as fc on fc.order_id= d.order_id and fc.order_number = d.order_number
        and fc.technology_number = d.technology_number
        where a.processing_card>0
        and a.warehousing!=2
        <if test="terminationVal != '1' and terminationVal != 1">
            and termination_status !=1
        </if>
        GROUP BY  b.process_id, b.order_number,
        b.technology_number) as f
        LEFT JOIN sd.order_process_detail as e
        on e.id=(f.id-1) and e.process_id = f.process_id and e.order_number = f.order_number and e.technology_number =f.technology_number
        where
        e.id is not null
        and e.reporting_work_num_count-f.reporting_work_num_count>0 group by f.process_id, f.order_number,
        f.technology_number) as g
        <choose>
            <when test="laminating == 'stepC' and process == '预压'">
                GROUP BY g.process_id, g.order_number, g.technology_number
            </when>
            <when test="laminating == 'stepC'">
                GROUP BY g.process_id, g.order_number, g.`group`
            </when>
            <when test="laminating == 'stepD'">
                GROUP BY g.process_id, g.order_number
            </when>
            <otherwise>
                GROUP BY g.process_id, g.order_number, g.technology_number
            </otherwise>
        </choose>
        ) as h
    </select>
    <select id="exportWorkInProgressCombination">
        select
        #{process} as thisProcess,
        if(#{inputVal} = 1,'',h.project) as project,
        SUM(h.quantity) as stockNum,
        SUM(h.glassArea) as stockArea,
        if(#{inputVal} = 1,'',h.childName) as glassName
        from (
        SELECT g.*
        ,GROUP_CONCAT(g.glass_child SEPARATOR '+')  as childName
        from( SELECT f.*,
        e.reporting_work_num_count+f.patchNumSum-f.reporting_work_num_count-f.broken_num as quantity,
        (e.reporting_work_num_count+f.patchNumSum-f.reporting_work_num_count-f.broken_num)*f.area as glassArea
        from (SELECT a.order_id,
        a.project,
        C.product_id,
        b.order_number,
        b.process_id,
        b.technology_number,
        b.reporting_work_num_count,
        d.`group` ,
        b.broken_num,
        b.id,
        c.area,
        d.glass_child,
        ifnull(cb.patchNumSum,0) as patchNumSum
        FROM sd.`order` as a
        LEFT JOIN sd.order_process_detail as b
        on b.process = #{process} and a.order_id =b.order_id
        LEFT JOIN sd.order_detail as c
        on a.order_id = c.order_id and b.order_number =c.order_number
        left join sd.order_glass_detail as d
        on  d.order_id =a.order_id and d.order_number = b.order_number and d.technology_number = b.technology_number
        LEFT JOIN (
        SELECT
        IFNULL(sum( rw.rework_num ),0) AS 'patchNumSum',
        rw.process_id,
        rw.order_sort,
        rw.technology_number,
        rwk.this_process
        FROM
        pp.rework AS rw
        LEFT JOIN pp.reporting_work AS rwk ON rw.reporting_work_id = rwk.reporting_work_id
        WHERE
        position( #{process} IN rwk.this_process )
        AND rw.review_status >= 0
        GROUP BY
        rw.process_id,
        rw.order_sort,
        rw.technology_number
        ) AS cb ON cb.process_id = b.process_id
        AND cb.order_sort = b.order_number
        AND cb.technology_number = b.technology_number
        left join pp.flow_card as fc on fc.order_id= d.order_id and fc.order_number = d.order_number
        and fc.technology_number = d.technology_number
        where a.processing_card>0
        and a.warehousing!=2
        <if test="terminationVal != '1' and terminationVal != 1">
            and termination_status !=1
        </if>
        and (c.quantity-b.reporting_work_num_count)>0
        GROUP BY  b.process_id, b.order_number,
        b.technology_number) as f
        LEFT JOIN sd.order_process_detail as e
        on e.id=(f.id-1) and e.process_id = f.process_id and e.order_number = f.order_number and e.technology_number =f.technology_number
        where
        e.id is not null
        and (e.reporting_work_num_count+f.patchNumSum-f.reporting_work_num_count-f.broken_num)>0 ) as g
        <choose>
            <when test="laminating == 'stepC' and process == '预压'">
                GROUP BY g.process_id, g.order_number, g.technology_number
            </when>
            <when test="laminating == 'stepC'">
                GROUP BY g.process_id, g.order_number, g.`group`
            </when>
            <when test="laminating == 'stepD'">
                GROUP BY g.process_id, g.order_number
            </when>
            <otherwise>
                GROUP BY g.process_id, g.order_number, g.technology_number
            </otherwise>
        </choose>
        ) as h
        <choose>
            <when test="inputVal == 1">
                GROUP BY thisProcess
            </when>
            <otherwise>
                GROUP BY h.project,h.childName
            </otherwise>
        </choose>
    </select>
    <select id="processCardProgressCollectMp">
       select * from (select
              a.order_id,
              a.order_number,
              c.glass_group as 'group',
              a.technology_number,
            b.product_name,
            c.detail as glass_child,
            d.order_type,
            concat(a.process_id,'/',a.technology_number)  as processID,
            a.process_id,
            if(a.technology_number=1,sum(a.quantity-ifnull(a.termination_quantity,0)),0) as quantity,
            sum(a.quantity)-ifnull(a.termination_quantity,0) as thisQuantity,/*用于判断是否改变颜色*/
            if(a.technology_number=1, round(sum((a.quantity-ifnull(a.termination_quantity,0))*b.compute_area),2),0) as gross_area,
            if(a.technology_number=1, sum(a.received_quantity),0) as inventory,
            if(a.technology_number=1, round(sum(a.received_quantity*b.area),2),0) as inventoryArea,
            -- show
            sum(a.quantity-ifnull(a.termination_quantity,0)) as quantityShow ,
            round(sum((a.quantity-ifnull(a.termination_quantity,0)*b.compute_area)),2) as gross_areaShow,
            sum(a.received_quantity) as inventoryShow,
            round(sum(a.received_quantity*b.area),2) as inventoryAreaShow
            from pp.flow_card as a
            left join sd.order_detail as b
            on a.order_id = b.order_id and a.order_number = b.order_number
            left join sd.product_detail as c
            on c.prod_id = b.product_id and c.glass_sort = a.technology_number
            LEFT JOIN sd.`order` as d
            on a.order_id = d.order_id
            where a.order_id = #{orderId} group by processID
            ) as a
       left join (SELECT process_id,
                         technology_number,
                         sum(broken_num) as broken_num,
                         concat('{',GROUP_CONCAT(reporting_work_nums),'}') as reportWorkQuantity,
                         concat('{',GROUP_CONCAT(reporting_work_counts),'}') as reportWorkQuantityCount
                  from (select
                            opd.process_id,
                            opd.technology_number,
                            concat("\"", process, "\":\"", SUM(reporting_work_num), "\"") as  reporting_work_nums,
                            concat("\"", process, "\":\"", SUM(reporting_work_num_count), "\"") as  reporting_work_counts,
                            sum(broken_num) as broken_num
                        from sd.order_process_detail as opd
                        where opd.order_id = #{orderId}
                        group by opd.process_id,opd.technology_number,opd.process) as bb
                  GROUP BY bb.process_id,bb.technology_number) as b
       on a.process_id = b.process_id and a.technology_number = b.technology_number
       order by a.process_id,a.order_number,a.technology_number
    </select>
    <select id="processCardProgressReportMp">
        select a.product_name,
               b.glass_child,
               d.order_type,
               concat(c.process_id, '/', c.technology_number) as process_id,
               c.process_id as 'processId',
                c.order_id,
               c.order_number,
               c.technology_number,
               b.child_width,
               b.child_height,
               c.quantity,
               c.quantity-ifnull(c.termination_quantity,0) as thisQuantity,/*用于判断是否改变颜色*/
               e.reportWorkQuantity,
               e.reportWorkQuantityShow,
               e.reportWorkQuantityCount,
               e.reportWorkTime,
               e.broken_num,
               c.quantity-ifnull(c.termination_quantity,0) as glassQuantity,
               c.quantity-ifnull(c.termination_quantity,0) as quantityShow,
               round( (c.quantity-ifnull(c.termination_quantity,0))*a.compute_area,2) as grossAreaShow,
               ifnull(c.received_quantity, 0) as StorageShow,
               ifnull(dd.quantity, 0) as shippedQuantityShow, -- 发货数量
               round(ifnull(dd.quantity, 0)*a.compute_area,2) as shippedAreaShow, -- 发货面积
               round((ifnull(c.received_quantity, 0))*a.compute_area,2)  as StorageAreaShow,-- 入库面积
                round((c.quantity-ifnull(c.termination_quantity,0))*a.compute_area,2)as grossArea,
               ifnull(c.received_quantity, 0)                       as Storage,
               ifnull(dd.quantity, 0)                        as shippedQuantity,
               round(ifnull(dd.quantity, 0)*a.compute_area,2)        as shippedArea,
               round((ifnull(c.received_quantity, 0))*a.compute_area,2) as StorageArea,
               ifnull(JSON_UNQUOTE(JSON_EXTRACT(a.other_columns, '$.S01')),'') AS glassNumber,
               b.`group`
        from pp.flow_card as c
                 left join
             sd.order_detail as a
             on c.order_id = a.order_id
                 and c.order_number = a.order_number
                 left join sd.order_glass_detail as b
                           on c.order_id = b.order_id
                               and b.order_number = c.order_number
                               and c.technology_number = b.technology_number
                 left join sd.`order` as d
                           on c.order_id = d.order_id
            #                  left join mm.finished_goods_inventory as f
#                            on c.order_id = f.order_id and f.order_number = c.order_number
            left join sd.delivery_detail as dd on dd.order_id = a.order_id and dd.order_number = a.order_number
            left join (SELECT process_id,
            order_number,
            technology_number,
            sum(a.broken_num) as broken_num,
            concat('{',
            GROUP_CONCAT(concat("\"", process, "\":\"", if(technology_number!=1 and (bd.nickname='stepD' || bd.nickname='stepB' ) ,0,reporting_work_num), "\"")),
            '}'
            )             as reportWorkQuantity,
            concat('{',
            GROUP_CONCAT(concat("\"", process, "\":\"", reporting_work_num, "\"")),
            '}'
            )             as reportWorkQuantityShow,
            concat('{',
            GROUP_CONCAT(concat("\"", process, "\":\"", reporting_work_num_count, "\"")),
            '}'
            )             as reportWorkQuantityCount,
            concat('{',
            GROUP_CONCAT(concat("\"", process, "\":\"", IFNULL(date(update_time),''), "\"")),
            '}'
            )             as reportWorkTime
            FROM sd.order_process_detail as a
            left join (SELECT DISTINCT basic_name,nickname from sd.basic_data as bd where  bd.basic_category = 'process') as bd
            on a.process = bd.basic_name
            where a.order_id = #{orderId}
            GROUP BY process_id, a.order_number, a.technology_number
            ) as e
            on e.process_id = c.process_id
            and e.technology_number = c.technology_number
            and e.order_number = c.order_number
        where a.order_id = #{orderId} and d.create_order>0 and c.quantity-ifnull(c.termination_quantity,0)>0
        group by c.order_number,
            c.technology_number,
            c.process_id
        order by c.process_id, c.order_number, c.technology_number
    </select>
    <select id="selectProcessCompletedMp">
        SELECT
            #{selectProcesses} as process,
        hz.project,hz.batch,
        SUM(quantity) as quantity,
        SUM(childArea)as childArea,
        SUM(actualArea) as actualArea,
        SUM(completeNum) as completeNum,
        SUM(completeArea) as completeArea,
        SUM(incompleteNum) as incompleteNum,
        SUM(incompleteArea) as incompleteArea,
        hz.glass_child
        from (
        select DATE(o.create_time)                                                  as create_time,
        DATE(o.delivery_date)                                                as delivery_date,
        o.order_id,
        fc.process_id,
        o.customer_name,
        o.project,
        o.batch,
        od.order_number,
        ogd.technology_number,
        ogd.glass_child,
        ogd.child_width,
        ogd.child_height,
        fc.quantity - ifnull(fc.termination_quantity,0) as quantity,
        ROUND(ogd.child_width * ogd.child_height / 1000000, 2)               as childArea,
        ROUND(ogd.child_width * ogd.child_height * (fc.quantity- ifnull(fc.termination_quantity,0)) / 1000000, 2) as actualArea,
        odpd.reporting_work_num                                              as completeNum,
        ROUND(ogd.child_width * ogd.child_height * odpd.reporting_work_num / 1000000,
        2)                                                             as completeArea,
        fc.quantity - odpd.reporting_work_num - ifnull(fc.termination_quantity,0)      as incompleteNum,
        ROUND(ogd.child_width * ogd.child_height * (CAST(fc.quantity AS SIGNED) - CAST(odpd.reporting_work_num AS SIGNED)- ifnull(fc.termination_quantity,0)) / 1000000,
        2)                                                             as incompleteArea,
        od.product_name
        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 flow_card AS fc
        ON fc.order_id = ogd.order_id
        and fc.production_id = ogd.production_id
        AND fc.order_number = ogd.order_number
        AND fc.technology_number = ogd.technology_number
        left join sd.order_process_detail as odpd
        ON odpd.order_id = fc.order_id
        AND odpd.order_number = fc.order_number
        AND odpd.technology_number = fc.technology_number
        and odpd.process_id = fc.process_id
        left join sd.`order` as o
        on o.order_id = od.order_id
        where  o.create_order>0
          and odpd.process = #{selectProcesses}
          and  o.create_time >= #{selectTime1}
          AND o.create_time &lt;  #{selectTime2}
          and position(#{orderId} in od.order_id)
          and position(#{inputProject} in o.project)
        and CAST(fc.quantity AS SIGNED) - CAST(odpd.reporting_work_num AS SIGNED)>0
        and fc.quantity-ifnull(fc.termination_quantity,0)>0
        GROUP BY fc.process_id, fc.order_number, fc.technology_number
        order by fc.process_id, fc.order_number, fc.technology_number
        ) as hz
        GROUP BY hz.project,hz.batch,glass_child
    </select>
    <select id="yieldProcessMp">
        SELECT
            t.this_process as process,
            SUM(t.completed_quantity) as completedQuantity,
            SUM(t.area) as completedArea,
            SUM(t.breakageQuantity) as breakageQuantity,
            SUM(t.breakageArea) as breakageArea,
            CONCAT(ROUND(TRUNCATE(SUM(t.area)/(SUM(t.area) + SUM(t.breakageArea)),2)*100), '%') as finished
        FROM
            (
                SELECT
                    rw.reporting_work_time,
                    rw.this_process,
                    o.project,
                    o.batch,
                    rw.process_id,
                    rwd.completed_quantity AS completed_quantity,
                    ROUND(MAX(ogd.child_width) * MAX(ogd.child_height) * rwd.completed_quantity / 1000000, 2) AS area,
                    IFNULL(dd.breakage_quantity,0) as breakageQuantity,
                    IFNULL(ROUND(MAX(ogd.child_width) * MAX(ogd.child_height) * dd.breakage_quantity / 1000000, 2),0) AS breakageArea,
                    IFNULL(dd.responsible_team,'') as responsibleTeam,
                    od.product_name
                FROM
                    reporting_work AS rw
                        LEFT JOIN reporting_work_detail AS rwd
                                  ON rwd.reporting_work_id = rw.reporting_work_id
                        LEFT JOIN damage_details as dd on dd.reporting_work_id = rw.reporting_work_id
                        LEFT JOIN flow_card AS fc
                                  ON fc.order_id = rw.order_id
                                      AND fc.process_id = rw.process_id
                                      AND fc.order_number = rwd.order_number
                                      AND fc.technology_number = rwd.technology_number
                        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 = ogd.order_id
                                      AND od.order_number = ogd.order_number
                        LEFT JOIN sd.`order` AS o
                                  ON o.order_id = od.order_id
                WHERE
                    o.create_order > 0
                  AND rw.reviewed_state >= 0
                  AND rwd.completed_quantity + IFNULL(dd.breakage_quantity,0)> 0
                  AND rw.reporting_work_time &gt;= #{selectTime1}
                  AND rw.reporting_work_time &lt;= #{selectTime2}
                GROUP BY
                    rw.reporting_work_id,
                    rw.process_id,
                    rw.this_process,
                    rw.teams_groups_name,
                    rwd.order_number,
                    rwd.technology_number
            ) t
        GROUP BY
            t.this_process
    </select>
</mapper>