chenlu
2025-03-07 3ab330b8aefb3cd781c9b8730b4ab7ac65e7e9d7
north-glass-erp/src/main/resources/mapper/pp/ReportingWork.xml
@@ -91,6 +91,7 @@
        where fc.process_id = #{processIdStr}
          and POSITION(fc.technology_number in #{technologyStr})
          and if(#{reportType}=1,o.order_type!='样品订单',o.order_id!='')
        and o.create_order>0
        GROUP BY fc.process_id
    </select>
@@ -179,6 +180,7 @@
          AND  POSITION(fc.technology_number in #{technologyStr})
          AND odpd.process = #{process}
          and if(#{reportType}=1,o.order_type!='样品订单',o.order_id!='')
        and o.create_order>0
        group by fc.order_number,
                 ogd.technology_number
        order by fc.order_number
@@ -213,7 +215,7 @@
        LEFT JOIN sd.order_glass_detail AS ogd
                ON od.order_id = ogd.order_id
                AND od.order_number = ogd.order_number
        <if test="process == '夹胶' or (process == '打胶和粘框' and previousProcess=='夹胶')">
        <if test="process == '夹胶' or (process == '打胶和粘框')">
            AND ogd.`group` = (select `group`
                               from sd.order_glass_detail
                               where order_id = ogd.order_id
@@ -343,11 +345,11 @@
    </select>
    <select id="selectGlassProcessNum" resultType="java.lang.Integer">
        select
        if((d.reporting_work_num_count+ifnull(c.reworkNumSum,0)-b.reporting_work_num_count-b.broken_num)&lt; 0,
        ifnull(if((d.reporting_work_num_count+ifnull(c.reworkNumSum,0)-b.reporting_work_num_count-b.broken_num)&lt; 0,
           0,
           (d.reporting_work_num_count+ifnull(c.reworkNumSum,0)-b.reporting_work_num_count-b.broken_num)
            )
        from flow_card as a
            ),0)
        from pp.flow_card as a
        left join sd.order_process_detail as b
        on
            b.order_number = a.order_number
@@ -362,9 +364,9 @@
                       rw.process_id,rw.order_sort,rw.technology_number,
                       rwk.this_process
                   from
                       rework as rw
                       pp.rework as rw
                           LEFT JOIN
                       reporting_work as rwk
                       pp.reporting_work as rwk
                       on rw.reporting_work_id =rwk.reporting_work_id
                   where rwk.this_process=#{thisProcess}
                     and rw.review_status=1
@@ -533,7 +535,8 @@
                           on rwd.reporting_work_id = rw.reporting_work_id and rwd.order_number = ogd.order_number and
                              rwd.technology_number = ogd.technology_number
        where rw.reviewed_state != 2
          and DATE_FORMAT((rw.reporting_work_time), '%Y-%m-%d') between #{selectTime1} and #{selectTime2}
          and rw.reporting_work_time >= #{selectTime1}
    AND rw.reporting_work_time &lt;  #{selectTime2}
          and position(#{orderId} in rw.order_id)
          and rw.reviewed_state!=-1
          and o.create_order>0
@@ -576,7 +579,8 @@
                           on rwd.reporting_work_id = rw.reporting_work_id and rwd.order_number = ogd.order_number and
                              rwd.technology_number = ogd.technology_number
        where rw.reviewed_state != 2
          and DATE_FORMAT((rw.reporting_work_time), '%Y-%m-%d') between #{selectTime1} and #{selectTime2} and position(#{orderId} in rw.order_id)
          and rw.reporting_work_time >= #{selectTime1}
        AND rw.reporting_work_time &lt;  #{selectTime2} and position(#{orderId} in rw.order_id)
          and rw.reviewed_state!=-1
          and o.create_order>0
        <if test="reportingWork.reportingWorkId != null and reportingWork.reportingWorkId != ''">
@@ -943,7 +947,7 @@
        LEFT JOIN sd.order_glass_detail AS ogd
        ON od.order_id = ogd.order_id
        AND od.order_number = ogd.order_number
        <if test="process == '夹胶' or (process == '打胶和粘框' and previousProcess=='夹胶')">
        <if test="process == '夹胶' or (process == '打胶和粘框')">
            AND ogd.`group` = (select `group`
            from sd.order_glass_detail
            where order_id = ogd.order_id
@@ -1004,4 +1008,64 @@
    <select id="getProcessLaminating">
        select IFNULL(nickname,'') from sd.basic_data where basic_category='process' and basic_name=#{process}
    </select>
    <select id="selectOrderid">
        select order_id from  pp.flow_card where process_id=#{processIdStr} group by order_id
    </select>
    <select id="getFootSum">
        SELECT
            ifnull(SUM(this_completed_quantity),0) AS thisCompletedQuantity,
            ifnull(SUM(ROUND(child_width * child_height * this_completed_quantity / 1000000, 2)),0) AS completedArea,
            ifnull(SUM(this_worn_quantity),0) AS thisWornQuantity,
            ifnull(SUM(ROUND(child_width * child_height * this_worn_quantity / 1000000, 2)),0) AS wornArea
        FROM (
                 -- 先对 reporting_work_id 进行去重
                 SELECT
                     rw.reporting_work_id,
                     MAX(rw.this_completed_quantity) AS this_completed_quantity,
                     MAX(rw.this_worn_quantity) AS this_worn_quantity,
                     MAX(ogd.child_width) AS child_width,
                     MAX(ogd.child_height) AS child_height
                 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 = ogd.order_id
                                        AND rw.production_id = ogd.production_id
                 WHERE rw.reviewed_state != 2
      and rw.reporting_work_time >= #{selectTime1}
                   AND rw.reporting_work_time &lt;  #{selectTime2}
                   and position(#{orderId} in rw.order_id)
                   AND rw.reviewed_state != -1
                   AND o.create_order > 0
        <if test="reportingWork.reportingWorkId != null and reportingWork.reportingWorkId != ''">
            and rw.reporting_work_id regexp #{reportingWork.reportingWorkId}
        </if>
        <if test="reportingWork.orderId != null and reportingWork.orderId != ''">
            and o.order_id regexp #{reportingWork.orderId}
        </if>
        <if test="reportingWork.processId != null and reportingWork.processId != ''">
            and rw.process_id regexp #{reportingWork.processId}
        </if>
        <if test="reportingWork.order.project != null and reportingWork.order.project != ''">
            and o.project regexp #{reportingWork.order.project}
        </if>
        <if test="reportingWork.order.batch != null and reportingWork.order.batch != ''">
            and o.batch regexp #{reportingWork.order.batch}
        </if>
        <if test="reportingWork.thisProcess != null and reportingWork.thisProcess != ''">
            and rw.this_process regexp #{reportingWork.thisProcess}
        </if>
        <if test="reportingWork.deviceName != null and reportingWork.deviceName != ''">
            and rw.device_name regexp #{reportingWork.deviceName}
        </if>
        <if test="reportingWork.teamsGroupsName != null and reportingWork.teamsGroupsName != ''">
            and rw.teams_groups_name regexp #{reportingWork.teamsGroupsName}
        </if>
                 GROUP BY rw.reporting_work_id  -- 按 reporting_work_id 进行分组,确保唯一
             ) AS subquery;
    </select>
</mapper>