Browse Source

驾驶舱

wanglt 3 months ago
parent
commit
fd586a839d

+ 87 - 19
ygtx-gxt/src/main/resources/mapper/gxt/GxtWorkOrderMapper.xml

@@ -690,13 +690,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                 wo.team_leader_name AS chargePerson,
                 <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,
-                ROUND((TIMESTAMPDIFF( MINUTE, wo.accept_time, wo.real_start_time ) / 60) - (IFNULL(gq.total_before_start_suspend_seconds, 0) / 3600),2) AS zbsc,
-                ROUND(TIMESTAMPDIFF( MINUTE, COALESCE ( wo.pause_time, wo.real_start_time ), wo.restart_time ) / 60,2) AS tjsc,
-                ROUND(TIMESTAMPDIFF( MINUTE, wo.real_end_time, wo.restart_time ) / 60,2) AS qjbwsc,
-                ROUND(( TIMESTAMPDIFF( MINUTE, wo.real_start_time, wo.real_end_time ) / 60 ) - (IFNULL(gq.total_in_work_suspend_seconds, 0) / 3600),2) AS clsc,
-                ROUND(CASE WHEN gq.order_id IS NOT NULL THEN (gq.total_in_work_suspend_seconds)/3600 ELSE 0 END,2) AS gqsc
+                ROUND(TIMESTAMPDIFF( SECOND, wo.create_time, wo.assign_time ) / 3600,2) AS xfsc,
+                ROUND(TIMESTAMPDIFF( SECOND, wo.assign_time, wo.accept_time ) / 3600,2) AS xysc,
+                ROUND((TIMESTAMPDIFF( SECOND, wo.accept_time, wo.real_start_time ) - IFNULL(gq.total_before_start_suspend_seconds, 0)) / 3600,2) AS zbsc,
+                ROUND(TIMESTAMPDIFF( SECOND, COALESCE ( wo.pause_time, wo.real_start_time ), wo.restart_time ) / 3600,2) AS tjsc,
+                ROUND(TIMESTAMPDIFF( SECOND, wo.real_end_time, wo.restart_time ) / 3600,2) AS qjbwsc,
+                ROUND(( TIMESTAMPDIFF( SECOND, wo.real_start_time, wo.real_end_time ) - IFNULL(gq.total_in_work_suspend_seconds, 0)) / 3600,2) AS clsc,
+                ROUND(CASE WHEN gq.order_id IS NOT NULL THEN (gq.total_before_start_suspend_seconds + gq.total_in_work_suspend_seconds + gq.total_night_auto_suspend_seconds)/3600 ELSE 0 END,2) AS gqsc
             FROM
                 gxt_work_order wo
                 <if test="repairPerson != null and repairPerson == 'true'">
@@ -704,9 +704,35 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                 </if>
                 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
+                LEFT JOIN (SELECT order_id,MAX(action_time) AS finish_time FROM gxt_work_order_flow WHERE action_type IN ('complete','auto_finalize') GROUP BY order_id) gsflow ON gsflow.order_id=wo.id
+                LEFT JOIN (SELECT order_id,MAX(action_time) AS score_time FROM gxt_work_order_flow WHERE action_type IN ('reviewRating','finalRating') GROUP BY order_id) gfflow ON gfflow.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>
+                <if test="startTime != null ">
+                    <choose>
+                        <when test="(xfsc != null and xfsc == 'true') or (xysc != null and xysc == 'true') or (zbsc != null and zbsc == 'true') or (tjsc != null and tjsc == 'true') or (qjbwsc != null and qjbwsc == 'true') or (clsc != null and clsc == 'true') or (gqsc != null and gqsc == 'true')">
+                            AND gsflow.finish_time > #{startTime}
+                        </when>
+                        <when test="score != null and score == 1">
+                            AND gfflow.score_time > #{startTime}
+                        </when>
+                        <otherwise>
+                            AND wo.create_time > #{startTime}
+                        </otherwise>
+                    </choose>
+                </if>
+                <if test="endTime != null ">
+                    <choose>
+                        <when test="(xfsc != null and xfsc == 'true') or (xysc != null and xysc == 'true') or (zbsc != null and zbsc == 'true') or (tjsc != null and tjsc == 'true') or (qjbwsc != null and qjbwsc == 'true') or (clsc != null and clsc == 'true') or (gqsc != null and gqsc == 'true')">
+                            AND gsflow.finish_time <![CDATA[<]]> #{endTime}
+                        </when>
+                        <when test="score != null and score == 1">
+                            AND gfflow.score_time <![CDATA[<]]> #{endTime}
+                        </when>
+                        <otherwise>
+                            AND wo.create_time <![CDATA[<]]> #{endTime}
+                        </otherwise>
+                    </choose>
+                </if>
                 <if test="pcsId != null "> AND wo.pcs_station_pid = #{pcsId}</if>
                 <if test="centerId != null "> AND wo.gxt_center_id = #{centerId}</if>
                 <if test="remark != null and remark != '' ">
@@ -726,7 +752,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                     </foreach>
                 </if>
                 <if test="dataPermission != null and dataPermission != ''">${dataPermission}</if>
-                AND wopp.wop_num>0 AND wo.work_order_status IS NOT NULL AND wo.work_order_status IN ('completed','archived')
+                <choose>
+                    <when test="score != null and score == 1">
+                        AND wo.work_order_status IN ('archived')
+                    </when>
+                    <otherwise>
+                        AND wo.work_order_status IN ('completed','archived')
+                    </otherwise>
+                </choose>
+                AND wopp.wop_num>0 AND wo.work_order_status IS NOT NULL
             </where>
 
             UNION ALL
@@ -745,12 +779,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                 wo.team_leader_name AS chargePerson,
                 <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,
-                ROUND((TIMESTAMPDIFF( MINUTE, wo.accept_time, wo.real_start_time ) / 60)-(IFNULL(gq.total_before_start_suspend_seconds, 0) / 3600),2) AS zbsc,
-                ROUND(TIMESTAMPDIFF( MINUTE, wo.occur_time, wo.restart_time ) / 60,2) AS tjsc,
-                ROUND(TIMESTAMPDIFF( MINUTE, wo.real_end_time, wo.restart_time ) / 60,2) AS qjbwsc,
-                ROUND((TIMESTAMPDIFF( MINUTE, wo.real_start_time, wo.real_end_time ) / 60 ) - (IFNULL(gq.total_before_start_suspend_seconds, 0) / 3600) - (IFNULL(gq.total_in_work_suspend_seconds, 0) / 3600),2) AS clsc,
+                ROUND(TIMESTAMPDIFF( SECOND, wo.occur_time, wo.assign_time ) / 3600,2) AS xfsc,
+                ROUND(( TIMESTAMPDIFF( SECOND, wo.assign_time, wo.accept_time ) - IFNULL(gq.total_night_auto_suspend_seconds, 0))/ 3600,2) AS xysc,
+                ROUND((TIMESTAMPDIFF( SECOND, wo.accept_time, wo.real_start_time ) - IFNULL(gq.total_before_start_suspend_seconds, 0)) / 3600,2) AS zbsc,
+                ROUND(TIMESTAMPDIFF( SECOND, wo.occur_time, wo.restart_time ) / 3600,2) AS tjsc,
+                ROUND(TIMESTAMPDIFF( SECOND, wo.real_end_time, wo.restart_time ) / 3600,2) AS qjbwsc,
+                ROUND((TIMESTAMPDIFF( SECOND, wo.real_start_time, wo.real_end_time ) - IFNULL(gq.total_in_work_suspend_seconds, 0)) / 3600,2) AS clsc,
                 ROUND(CASE WHEN gq.order_id IS NOT NULL THEN (gq.total_before_start_suspend_seconds + gq.total_in_work_suspend_seconds + gq.total_night_auto_suspend_seconds)/3600 ELSE 0 END,2) AS gqsc
             FROM
                 gxt_repair_order wo
@@ -759,9 +793,35 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                 </if>
                 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
+                LEFT JOIN (SELECT order_id,MAX(action_time) AS finish_time FROM gxt_repair_order_flow WHERE action_type IN ('complete','auto_finalize') GROUP BY order_id) gsflow ON gsflow.order_id=wo.id
+                LEFT JOIN (SELECT order_id,MAX(action_time) AS score_time FROM gxt_repair_order_flow WHERE action_type IN ('reviewRating','finalRating') GROUP BY order_id) gfflow ON gfflow.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>
+                <if test="startTime != null ">
+                    <choose>
+                        <when test="(xfsc != null and xfsc == 'true') or (xysc != null and xysc == 'true') or (zbsc != null and zbsc == 'true') or (tjsc != null and tjsc == 'true') or (qjbwsc != null and qjbwsc == 'true') or (clsc != null and clsc == 'true') or (gqsc != null and gqsc == 'true')">
+                            AND gsflow.finish_time > #{startTime}
+                        </when>
+                        <when test="score != null and score == 1">
+                            AND gfflow.score_time > #{startTime}
+                        </when>
+                        <otherwise>
+                            AND wo.occur_time > #{startTime}
+                        </otherwise>
+                    </choose>
+                </if>
+                <if test="endTime != null ">
+                    <choose>
+                        <when test="(xfsc != null and xfsc == 'true') or (xysc != null and xysc == 'true') or (zbsc != null and zbsc == 'true') or (tjsc != null and tjsc == 'true') or (qjbwsc != null and qjbwsc == 'true') or (clsc != null and clsc == 'true') or (gqsc != null and gqsc == 'true')">
+                            AND gsflow.finish_time <![CDATA[<]]> #{endTime}
+                        </when>
+                        <when test="score != null and score == 1">
+                            AND gfflow.score_time <![CDATA[<]]> #{endTime}
+                        </when>
+                        <otherwise>
+                            AND wo.occur_time <![CDATA[<]]> #{endTime}
+                        </otherwise>
+                    </choose>
+                </if>
                 <if test="pcsId != null "> AND wo.pcs_station_pid = #{pcsId}</if>
                 <if test="centerId != null "> AND wo.gxt_center_id = #{centerId}</if>
                 <if test="remark != null and remark != '' ">
@@ -781,7 +841,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                     </foreach>
                 </if>
                 <if test="dataPermission != null and dataPermission != ''">${dataPermission}</if>
-                AND wopp.wop_num>0 AND wo.work_order_status IS NOT NULL AND wo.work_order_status IN ('completed','archived')
+                <choose>
+                    <when test="score != null and score == 1">
+                        AND wo.work_order_status IN ('archived')
+                    </when>
+                    <otherwise>
+                        AND wo.work_order_status IN ('completed','archived')
+                    </otherwise>
+                </choose>
+                AND wopp.wop_num>0 AND wo.work_order_status IS NOT NULL
             </where>
             ) o
         <where>

+ 48 - 11
ygtx-gxt/src/main/resources/mapper/gxt/gxtOrderPersonMapper.xml

@@ -270,12 +270,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             (SELECT COUNT(*)
              FROM gxt_work_order_flow f2
              WHERE f2.order_id = f.order_id
-               AND f2.action_type IN ('approved', 'resume')
+               AND f2.action_type IN ('approved', 'resume', 'auto_suspend', 'auto_resume')
                AND f.action_time >= f2.action_time) AS order_seq
         FROM gxt_work_order_flow f
                  LEFT JOIN gxt_work_order ro
                            ON ro.id = f.order_id
-        WHERE f.action_type IN ('approved', 'resume')) t
+        WHERE f.action_type IN ('approved', 'resume', 'auto_suspend', 'auto_resume')) t
     </select>
 
     <insert id="addWorkOrderFlowRecords">
@@ -294,12 +294,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             (SELECT COUNT(*)
              FROM gxt_work_order_flow f2
              WHERE f2.order_id = f.order_id
-               AND f2.action_type IN ('approved', 'resume')
+               AND f2.action_type IN ('approved', 'resume', 'auto_suspend', 'auto_resume')
                AND f.action_time >= f2.action_time) AS order_seq
         FROM gxt_work_order_flow f
                  LEFT JOIN gxt_work_order ro
                            ON ro.id = f.order_id
-        WHERE f.action_type IN ('approved', 'resume')
+        WHERE f.action_type IN ('approved', 'resume', 'auto_suspend', 'auto_resume')
         ORDER BY f.order_id, f.action_time
     </insert>
 
@@ -308,11 +308,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             order_id,
             total_before_start_suspend_seconds,
             total_in_work_suspend_seconds,
+            total_night_auto_suspend_seconds,
             before_start_suspend_format,
-            in_work_suspend_format
+            in_work_suspend_format,
+            night_auto_suspend_format
         )
         SELECT
-            t1.order_id,
+            t0.order_id,
             COALESCE(SUM(CASE
                              WHEN t1.action_time <![CDATA[<]]> t1.real_start_time
                                  THEN TIMESTAMPDIFF(SECOND, t1.action_time, t2.action_time)
@@ -325,6 +327,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                              ELSE 0
                 END), 0) AS total_in_work_suspend_seconds,
 
+            COALESCE(SUM(CASE
+                             WHEN t4.action_time IS NOT NULL
+                                 THEN TIMESTAMPDIFF(SECOND, t3.action_time, t4.action_time)
+                             ELSE 0
+                END), 0) AS total_night_auto_suspend_seconds,
+
             CONCAT(
                     FLOOR(COALESCE(SUM(CASE
                                            WHEN t1.action_time <![CDATA[<]]> t1.real_start_time
@@ -359,15 +367,44 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                                              THEN TIMESTAMPDIFF(SECOND, t1.action_time, t2.action_time)
                                          ELSE 0
                         END), 0), 60), '秒'
-                ) AS in_work_suspend_format
-        FROM gxt_work_order_flow_records t1
+                ) AS in_work_suspend_format,
+
+            CONCAT(
+                    FLOOR(COALESCE(SUM(CASE
+                                           WHEN t4.action_time IS NOT NULL
+                                               THEN TIMESTAMPDIFF(SECOND, t3.action_time, t4.action_time)
+                                           ELSE 0
+                        END), 0) / 3600), '小时',
+                    FLOOR(MOD(COALESCE(SUM(CASE
+                                               WHEN t4.action_time IS NOT NULL
+                                                   THEN TIMESTAMPDIFF(SECOND, t3.action_time, t4.action_time)
+                                               ELSE 0
+                        END), 0), 3600) / 60), '分钟',
+                    MOD(COALESCE(SUM(CASE
+                                         WHEN t4.action_time IS NOT NULL
+                                             THEN TIMESTAMPDIFF(SECOND, t3.action_time, t4.action_time)
+                                         ELSE 0
+                        END), 0), 60), '秒'
+                ) AS night_auto_suspend_format
+        FROM (SELECT order_id FROM gxt_work_order_flow_records GROUP BY order_id) t0
+                 LEFT JOIN gxt_work_order_flow_records t1
+                           ON t0.order_id = t1.order_id
+                               AND t1.action_type = 'approved'
                  LEFT JOIN gxt_work_order_flow_records t2
                            ON t1.order_id = t2.order_id
                                AND t2.order_seq = t1.order_seq + 1
                                AND t1.action_type = 'approved'
-                               AND t2.action_type = 'resume'
-        GROUP BY t1.order_id
-        ORDER BY t1.order_id
+                               AND t2.action_type IN ('resume','auto_resume')
+                 LEFT JOIN gxt_work_order_flow_records t3
+                           ON t0.order_id = t3.order_id
+                               AND t3.action_type = 'auto_suspend'
+                 LEFT JOIN gxt_work_order_flow_records t4
+                           ON t3.order_id = t4.order_id
+                               AND t4.order_seq = t3.order_seq + 1
+                               AND t3.action_type = 'auto_suspend'
+                               AND t4.action_type IN ('resume','auto_resume')
+        GROUP BY t0.order_id
+        ORDER BY t0.order_id
     </insert>
     
 </mapper>