wanglt 3 месяцев назад
Родитель
Сommit
c3d75fda3c
1 измененных файлов с 6 добавлено и 20 удалено
  1. 6 20
      ygtx-gxt/src/main/resources/mapper/gxt/GxtWorkOrderMapper.xml

+ 6 - 20
ygtx-gxt/src/main/resources/mapper/gxt/GxtWorkOrderMapper.xml

@@ -696,7 +696,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                 p.dept_name AS center,
                 '维保工单' AS orderType,
                 m.nick_name AS chargePerson,
-                <if test="repairPerson != null and repairPerson == 'true'">u.nick_name AS repairPerson,ROUND(wop.score,2) AS score,</if>
+                <if test="repairPerson != null and repairPerson == 'true'">wop.nick_name AS repairPerson,ROUND(wop.score,2) AS score,</if>
                 <if test="repairPerson == null or repairPerson == '' or repairPerson == 'false'">ROUND(wo.score,2) AS score,</if>
                 ROUND(TIMESTAMPDIFF( MINUTE, wo.create_time, wo.assign_time ) / 60,2) AS xfsc,
                 ROUND(TIMESTAMPDIFF( MINUTE, wo.assign_time, wo.accept_time ) / 60,2) AS xysc,
@@ -711,18 +711,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                 LEFT JOIN sys_dept p ON d.parent_id = p.dept_id
                 <if test="repairPerson != null and repairPerson == 'true'">
                     LEFT JOIN gxt_work_order_person wop ON wo.id = wop.order_id
-                    LEFT JOIN sys_user u ON wop.user_id = u.user_id
                 </if>
                 LEFT JOIN sys_user m ON wo.team_leader_id = m.user_id
                 LEFT JOIN ( SELECT order_id, COUNT(*) AS order_num FROM gxt_work_order_person GROUP BY order_id ) t ON t.order_id = wo.id
-                LEFT JOIN ( SELECT MIN( action_time ) AS assign_time, order_id FROM gxt_work_order_flow WHERE action_type = 'assign' AND order_id IS NOT NULL GROUP BY order_id ) assign ON assign.order_id = wo.id
-                LEFT JOIN ( SELECT MIN( action_time ) AS accept_time, order_id FROM gxt_work_order_flow WHERE action_type = 'accept' AND order_id IS NOT NULL GROUP BY order_id ) accept ON accept.order_id = wo.id
-                LEFT JOIN ( SELECT MIN( action_time ) AS process_time, order_id FROM gxt_work_order_flow WHERE action_type = 'process' AND order_id IS NOT NULL GROUP BY order_id ) process ON process.order_id = wo.id
-                LEFT JOIN ( SELECT MAX( action_time ) AS complete_time, order_id FROM gxt_work_order_flow WHERE action_type = 'complete' AND order_id IS NOT NULL GROUP BY order_id ) complete ON complete.order_id = wo.id
-                LEFT JOIN ( SELECT MAX( action_time ) AS restart_time, order_id FROM gxt_work_order_flow WHERE action_type = 'restart' AND order_id IS NOT NULL GROUP BY order_id ) restart ON restart.order_id = wo.id
-                LEFT JOIN ( SELECT MIN( action_time ) AS approved_time, order_id FROM gxt_work_order_flow WHERE action_type = 'approved' AND order_id IS NOT NULL GROUP BY order_id ) approved ON approved.order_id = wo.id
-                LEFT JOIN ( SELECT MAX( action_time ) AS resume_time, order_id FROM gxt_work_order_flow WHERE action_type = 'resume' AND order_id IS NOT NULL GROUP BY order_id ) resume ON resume.order_id = wo.id
                 LEFT JOIN gxt_work_order_flow_records_next gq ON gq.order_id = wo.id
+                LEFT JOIN (SELECT order_id,COUNT(*) AS wop_num FROM gxt_work_order_person GROUP BY order_id) wopp ON wopp.order_id=wo.id
             <where>
                 <if test="startTime != null "> AND wo.create_time > #{startTime}</if>
                 <if test="endTime != null "> AND wo.create_time <![CDATA[<]]> #{endTime}</if>
@@ -745,7 +738,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                     </foreach>
                 </if>
                 <if test="dataPermission != null and dataPermission != ''">${dataPermission}</if>
-                AND p.dept_name IS NOT NULL AND wo.work_order_status IS NOT NULL AND wo.work_order_status IN ('completed','archived')
+                AND p.dept_name IS NOT NULL AND wopp.wop_num>0 AND wo.work_order_status IS NOT NULL AND wo.work_order_status IN ('completed','archived')
             </where>
 
             UNION ALL
@@ -763,7 +756,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                 p.dept_name AS center,
                 '维修工单' AS orderType,
                 m.nick_name AS chargePerson,
-                <if test="repairPerson != null and repairPerson == 'true'">u.nick_name AS repairPerson,ROUND(wop.score,2) AS score,</if>
+                <if test="repairPerson != null and repairPerson == 'true'">wop.nick_name AS repairPerson,ROUND(wop.score,2) AS score,</if>
                 <if test="repairPerson == null or repairPerson == '' or repairPerson == 'false'">ROUND(wo.score,2) AS score,</if>
                 ROUND(TIMESTAMPDIFF( MINUTE, wo.occur_time, wo.assign_time ) / 60,2) AS xfsc,
                 ROUND((TIMESTAMPDIFF( MINUTE, wo.assign_time, wo.accept_time ) / 60)-(IFNULL(gq.total_night_auto_suspend_seconds, 0) / 3600),2) AS xysc,
@@ -778,18 +771,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                 LEFT JOIN sys_dept p ON d.parent_id = p.dept_id
                 <if test="repairPerson != null and repairPerson == 'true'">
                     LEFT JOIN gxt_repair_order_person wop ON wo.id = wop.order_id
-                    LEFT JOIN sys_user u ON wop.user_id = u.user_id
                 </if>
                 LEFT JOIN sys_user m ON wo.team_leader_id = m.user_id
                 LEFT JOIN ( SELECT order_id, COUNT(*) AS order_num FROM gxt_repair_order_person GROUP BY order_id ) t ON t.order_id = wo.id
-                LEFT JOIN ( SELECT MIN( action_time ) AS assign_time, order_id FROM gxt_repair_order_flow WHERE action_type = 'assign' AND order_id IS NOT NULL GROUP BY order_id ) assign ON assign.order_id = wo.id
-                LEFT JOIN ( SELECT MIN( action_time ) AS accept_time, order_id FROM gxt_repair_order_flow WHERE action_type = 'accept' AND order_id IS NOT NULL GROUP BY order_id ) accept ON accept.order_id = wo.id
-                LEFT JOIN ( SELECT MIN( action_time ) AS process_time, order_id FROM gxt_repair_order_flow WHERE action_type = 'process' AND order_id IS NOT NULL GROUP BY order_id ) process ON process.order_id = wo.id
-                LEFT JOIN ( SELECT MAX( action_time ) AS complete_time, order_id FROM gxt_repair_order_flow WHERE action_type = 'complete' AND order_id IS NOT NULL GROUP BY order_id ) complete ON complete.order_id = wo.id
-                LEFT JOIN ( SELECT MAX( action_time ) AS restart_time, order_id FROM gxt_repair_order_flow WHERE action_type = 'restart' AND order_id IS NOT NULL GROUP BY order_id ) restart ON restart.order_id = wo.id
-                LEFT JOIN ( SELECT MIN( action_time ) AS approved_time, order_id FROM gxt_repair_order_flow WHERE action_type = 'approved' AND order_id IS NOT NULL GROUP BY order_id ) approved ON approved.order_id = wo.id
-                LEFT JOIN ( SELECT MAX( action_time ) AS resume_time, order_id FROM gxt_repair_order_flow WHERE action_type = 'resume' AND order_id IS NOT NULL GROUP BY order_id ) resume ON resume.order_id = wo.id
                 LEFT JOIN gxt_repair_order_flow_records_next gq ON gq.order_id = wo.id
+                LEFT JOIN (SELECT order_id,COUNT(*) AS wop_num FROM gxt_repair_order_person GROUP BY order_id) wopp ON wopp.order_id=wo.id
             <where>
                 <if test="startTime != null "> AND wo.occur_time > #{startTime}</if>
                 <if test="endTime != null "> AND wo.occur_time <![CDATA[<]]> #{endTime}</if>
@@ -812,7 +798,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                     </foreach>
                 </if>
                 <if test="dataPermission != null and dataPermission != ''">${dataPermission}</if>
-                AND p.dept_name IS NOT NULL AND wo.work_order_status IS NOT NULL AND wo.work_order_status IN ('completed','archived')
+                AND p.dept_name IS NOT NULL AND wopp.wop_num>0 AND wo.work_order_status IS NOT NULL AND wo.work_order_status IN ('completed','archived')
             </where>
             ) o
         <where>