Browse Source

调整违章和到岗到位统计SQL

zx 5 tháng trước cách đây
mục cha
commit
88ceba8360

+ 1 - 1
ruoyi-powerdistribution/src/main/java/com/ruoyi/powerdistribution/controller/PdmStopTargeController.java

@@ -48,7 +48,7 @@ public class PdmStopTargeController extends BaseController
     @GetMapping("/list")
     public TableDataInfo list(PdmStopTarge pdmStopTarge)
     {
-        startPage();
+        //startPage();
         List<PdmStopTarge> list = pdmStopTargeService.selectPdmStopTargeList(pdmStopTarge);
         return getDataTable(list);
     }

+ 92 - 87
ruoyi-powerdistribution/src/main/resources/mapper/powerdistribution/PdmReportAppointmentDayMapper.xml

@@ -136,99 +136,104 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="selectAppointmentReport" parameterType="PdmReportAppointmentDay" resultMap="PdmReportAppointmentDayResult">
 
         select t1.organ_abbr company,
-        IFNULL(tt1.boss_sum,0) boss_sum,
-        IFNULL(tt1.manage_sum,0) manage_sum,
-        IFNULL(tt1.absent_sum,0) absent_sum,
-        IFNULL(tt2.absent_detail,'') absent_detail,
-        IFNULL(tt3.absent_bad_sum,0) absent_bad_sum,
-        IFNULL(tt3.absent_bad_detail,'') absent_bad_detail,
-        IFNULL(tt4.check_num3,'') check_num3,
-        IFNULL(tt4.check_num4,'') check_num4,
-        IFNULL(tt4.check_num5,'') check_num5,
-        IFNULL(tt4.problem_sum,'') problem_sum,
-        IFNULL(tt4.city_check_sum,'') city_check_sum
+               IFNULL(tt1.boss_sum,0) boss_sum,
+               IFNULL(tt1.manage_sum,0) manage_sum,
+               IFNULL(tt1.absent_sum,0) absent_sum,
+               IFNULL(tt2.absent_detail,'') absent_detail,
+               IFNULL(tt3.absent_bad_sum,0) absent_bad_sum,
+               IFNULL(tt3.absent_bad_detail,'') absent_bad_detail,
+               IFNULL(tt4.check_num3,0) check_num3,
+               IFNULL(tt4.check_num4,0) check_num4,
+               IFNULL(tt4.check_num5,0) check_num5,
+               IFNULL(tt4.problem_sum,0) problem_sum,
+               IFNULL(tt4.city_check_sum,0) city_check_sum
         from pdm_work_organ t1
-        LEFT JOIN (
-        select
-        sum(if((to_post_in_place_person_typ_cd in ('2035002','2035004') and is_in_place = '1'),1,0)) boss_sum,
-        sum(if((to_post_in_place_person_typ_cd in ('2035003','2035003') and is_in_place = '1'),1,0)) manage_sum,
-        sum(if(is_in_place = '0',1,0)) absent_sum,
-        op_org_nm
-        from pdm_work_plan_in_place
-        where data_dt &gt;= #{startDate} and data_dt &lt;= #{endDate}
-        GROUP BY op_org_nm
-        ) tt1 on t1.organ_name = tt1.op_org_nm
-
-        LEFT JOIN(
-        select op_org_nm,
-        GROUP_CONCAT(to_post_in_place_person_nm,';') AS absent_detail FROM
-        pdm_work_plan_in_place where is_in_place = '0'
-        and data_dt &gt;= #{startDate} and data_dt &lt;= #{endDate}
-        GROUP BY op_org_nm
-        ) tt2 on t1.organ_name = tt2.op_org_nm
-
-        LEFT JOIN(
-        select sum(1) absent_bad_sum,
-        GROUP_CONCAT(t1.to_post_in_place_person_nm,';') AS absent_bad_detail,
-        submit_org_nm
-        from  pdm_work_plan_in_place t1,pdm_work_plan t2 where
-        t2.uuid = t1.relation_id and t1.is_safe_resumption = '0'
-        and EXISTS(select 1 from pdm_inspection_records t3 where t3.day_op_info_id = t2.uuid and t3.scene_rating_cd!='2018002')
-        and t2.data_dt >= #{startDate} and t2.data_dt &lt;= #{endDate}
-        GROUP BY submit_org_nm
+           LEFT JOIN (
+            select
+                sum(if((to_post_in_place_person_typ_cd in ('2035002','2035004') and is_in_place = '1'),1,0)) boss_sum,
+                sum(if((to_post_in_place_person_typ_cd in ('2035003','2035003') and is_in_place = '1'),1,0)) manage_sum,
+                sum(if(is_in_place = '0',1,0)) absent_sum,
+                submit_org_nm
+            from pdm_work_plan_in_place t1,pdm_work_plan t2 where
+                t2.uuid = t1.relation_id
+                and date_format(plan_start_wk_tm,'%Y%m%d') &gt;= #{startDate} and date_format(plan_start_wk_tm,'%Y%m%d') &lt;= #{endDate}
+            GROUP BY submit_org_nm
+        ) tt1 on t1.organ_name = tt1.submit_org_nm
+
+                LEFT JOIN(
+            select submit_org_nm,
+            GROUP_CONCAT(to_post_in_place_person_nm,';') AS absent_detail FROM
+                pdm_work_plan_in_place t1,pdm_work_plan t2 where
+                t2.uuid = t1.relation_id and is_in_place = '0'
+                and date_format(plan_start_wk_tm,'%Y%m%d') &gt;= #{startDate} and date_format(plan_start_wk_tm,'%Y%m%d') &lt;= #{endDate}                                                                                                              and date_format(plan_start_wk_tm,'%Y%m%d') &gt;= #{startDate} and date_format(plan_start_wk_tm,'%Y%m%d') &lt;= #{endDate}
+            GROUP BY submit_org_nm
+        ) tt2 on t1.organ_name = tt2.submit_org_nm
+
+                 LEFT JOIN(
+            select sum(1) absent_bad_sum,
+                   GROUP_CONCAT(t1.to_post_in_place_person_nm,';') AS absent_bad_detail,
+                   submit_org_nm
+            from  pdm_work_plan_in_place t1,pdm_work_plan t2 where
+                t2.uuid = t1.relation_id and t1.is_safe_resumption = '0'
+                and EXISTS(select 1 from pdm_inspection_records t3 where t3.day_op_info_id = t2.uuid and t3.scene_rating_cd!='2018002')
+                and date_format(plan_start_wk_tm,'%Y%m%d') &gt;= #{startDate} and date_format(plan_start_wk_tm,'%Y%m%d') &lt;= #{endDate}
+            GROUP BY submit_org_nm
         )tt3 on t1.organ_name = tt3.submit_org_nm
-        LEFT JOIN(
-        select
-        sum(if(op_risk_cd ='2007003' ,1,0)) check_num3,
-        sum(if(op_risk_cd ='2007004' ,1,0)) check_num4,
-        sum(if(op_risk_cd ='2007005' ,1,0)) check_num5,
-        sum(if(scene_rating_cd !='2018002',1,0)) problem_sum,
-        sum(if(scene_rating_cd !='2018002' and audit_lvl_cd = '2025002',1,0)) city_check_sum,
-        op_org
-        from pdm_inspection_records
-        where
-        data_dt &gt;= #{startDate} and data_dt &lt;= #{endDate}
-        GROUP BY op_org
-        )tt4 on t1.organ_name = tt4.op_org
+                 LEFT JOIN(
+            select
+                sum(if(op_risk_cd ='2007003' ,1,0)) check_num3,
+                sum(if(op_risk_cd ='2007004' ,1,0)) check_num4,
+                sum(if(op_risk_cd ='2007005' ,1,0)) check_num5,
+                sum(if(scene_rating_cd !='2018002',1,0)) problem_sum,
+                sum(if(scene_rating_cd !='2018002' and audit_lvl_cd = '2025002',1,0)) city_check_sum,
+                submit_org_nm
+            from pdm_inspection_records t1,pdm_work_plan t2 where
+                t2.uuid = t1.day_op_info_id
+                and date_format(plan_start_wk_tm,'%Y%m%d') &gt;= #{startDate} and date_format(plan_start_wk_tm,'%Y%m%d') &lt;= #{endDate}
+            GROUP BY submit_org_nm
+        )tt4 on t1.organ_name = tt4.submit_org_nm
+
 
         UNION ALL
         select '总计' company,
-        IFNULL(ttt1.boss_sum,0) boss_sum,
-        IFNULL(ttt1.manage_sum,0) manage_sum,
-        IFNULL(ttt1.absent_sum,0) absent_sum,
-        '' absent_detail,
-        IFNULL(ttt2.absent_bad_sum,0) absent_bad_sum,
-        '' absent_bad_detail,
-        IFNULL(ttt3.check_num3,0) check_num3,
-        IFNULL(ttt3.check_num4,0) check_num4,
-        IFNULL(ttt3.check_num5,0) check_num5,
-        IFNULL(ttt3.problem_sum,0) problem_sum,
-        IFNULL(ttt3.city_check_sum,0) city_check_sum
+               IFNULL(ttt1.boss_sum,0) boss_sum,
+               IFNULL(ttt1.manage_sum,0) manage_sum,
+               IFNULL(ttt1.absent_sum,0) absent_sum,
+               '' absent_detail,
+               IFNULL(ttt2.absent_bad_sum,0) absent_bad_sum,
+               '' absent_bad_detail,
+               IFNULL(ttt3.check_num3,0) check_num3,
+               IFNULL(ttt3.check_num4,0) check_num4,
+               IFNULL(ttt3.check_num5,0) check_num5,
+               IFNULL(ttt3.problem_sum,0) problem_sum,
+               IFNULL(ttt3.city_check_sum,0) city_check_sum
         from (
-        (select
-        sum(if((to_post_in_place_person_typ_cd in ('2035002','2035004') and is_in_place = '1'),1,0)) boss_sum,
-        sum(if((to_post_in_place_person_typ_cd in ('2035003','2035003') and is_in_place = '1'),1,0)) manage_sum,
-        sum(if(is_in_place = '0',1,0)) absent_sum
-        from pdm_work_plan_in_place
-        where data_dt &gt;= #{startDate} and data_dt &lt;= #{endDate}
-        ) ttt1,
-        (select sum(1) absent_bad_sum,
-        GROUP_CONCAT(to1.to_post_in_place_person_nm,';') AS absent_bad_detail
-        from  pdm_work_plan_in_place to1,pdm_work_plan to2 where
-        to2.uuid = to1.relation_id and to1.is_safe_resumption = '0'
-        and EXISTS(select 1 from pdm_inspection_records to3 where to3.day_op_info_id = to2.uuid and to3.scene_rating_cd!='2018002')
-        and to2.data_dt &gt;= #{startDate} and to2.data_dt &lt;= #{endDate}
-        )ttt2,
-        (select
-        sum(if(op_risk_cd ='2007003' ,1,0)) check_num3,
-        sum(if(op_risk_cd ='2007004' ,1,0)) check_num4,
-        sum(if(op_risk_cd ='2007005' ,1,0)) check_num5,
-        sum(if(scene_rating_cd !='2018002',1,0)) problem_sum,
-        sum(if(scene_rating_cd !='2018002' and audit_lvl_cd = '2025002',1,0)) city_check_sum
-        from pdm_inspection_records
-        where data_dt &gt;= #{startDate} and data_dt &lt;= #{endDate}
-        ) ttt3
-        )
+             (select
+              sum(if((to_post_in_place_person_typ_cd in ('2035002','2035004') and is_in_place = '1'),1,0)) boss_sum,
+              sum(if((to_post_in_place_person_typ_cd in ('2035003','2035003') and is_in_place = '1'),1,0)) manage_sum,
+              sum(if(is_in_place = '0',1,0)) absent_sum
+              from pdm_work_plan_in_place t1,pdm_work_plan t2 where
+                  t2.uuid = t1.relation_id
+                 and date_format(plan_start_wk_tm,'%Y%m%d') &gt;= #{startDate} and date_format(plan_start_wk_tm,'%Y%m%d') &lt;= #{endDate}
+             ) ttt1,
+            (select sum(1) absent_bad_sum,
+            GROUP_CONCAT(to1.to_post_in_place_person_nm,';') AS absent_bad_detail
+            from  pdm_work_plan_in_place to1,pdm_work_plan to2 where
+            to2.uuid = to1.relation_id and to1.is_safe_resumption = '0'
+            and EXISTS(select 1 from pdm_inspection_records to3 where to3.day_op_info_id = to2.uuid and to3.scene_rating_cd!='2018002')
+            and date_format(plan_start_wk_tm,'%Y%m%d') &gt;= #{startDate} and date_format(plan_start_wk_tm,'%Y%m%d') &lt;= #{endDate}
+            )ttt2,
+             (select
+             sum(if(op_risk_cd ='2007003' ,1,0)) check_num3,
+             sum(if(op_risk_cd ='2007004' ,1,0)) check_num4,
+             sum(if(op_risk_cd ='2007005' ,1,0)) check_num5,
+             sum(if(scene_rating_cd !='2018002',1,0)) problem_sum,
+             sum(if(scene_rating_cd !='2018002' and audit_lvl_cd = '2025002',1,0)) city_check_sum
+             from pdm_inspection_records t1,pdm_work_plan t2 where
+             t2.uuid = t1.day_op_info_id
+             and date_format(plan_start_wk_tm,'%Y%m%d') &gt;= #{startDate} and date_format(plan_start_wk_tm,'%Y%m%d') &lt;= #{endDate}
+             ) ttt3
+                 )
 
     </select>
 

+ 40 - 17
ruoyi-powerdistribution/src/main/resources/mapper/powerdistribution/PdmReportIllegalDayMapper.xml

@@ -148,7 +148,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         IFNULL(t.province_num1,0) province_num1,IFNULL(t.province_num2,0) province_num2,
         IFNULL(t.city_num1,0) city_num1,IFNULL(t.city_num2,0) city_num2,
         IFNULL(t.county_num1,0) county_num1,IFNULL(t.county_num2,0) county_num2,
-        0 check_num
+        IFNULL(tt.check_num,0)  check_num
         from pdm_work_organ t1
         LEFT JOIN
         (
@@ -159,23 +159,46 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         sum(if((t3.audit_lvl_cd='2025002' and t2.break_rules_nature_cd = '2020001'),1,0)) city_num2,
         sum(if((t3.audit_lvl_cd='2025003' and t2.break_rules_nature_cd = '2020002'),1,0)) county_num1,
         sum(if((t3.audit_lvl_cd='2025003' and t2.break_rules_nature_cd = '2020001'),1,0)) county_num2,
-        t3.op_org from pdm_violation_records t2,pdm_inspection_records t3
-        where t2.audit_rec_id  = t3.audit_rec_id
-        and t2.data_dt  &gt;= #{startDate} and t2.data_dt &lt;= #{endDate}
-        GROUP BY t3.op_org
-        ) t on t1.organ_name = t.op_org
+        t4.submit_org_nm from pdm_violation_records t2,pdm_inspection_records t3,pdm_work_plan t4
+        where t2.audit_rec_id  = t3.audit_rec_id and t2.day_op_info_id = t4.uuid
+        and date_format(plan_start_wk_tm,'%Y%m%d') &gt;= #{startDate} and date_format(plan_start_wk_tm,'%Y%m%d') &lt;= #{endDate}
+        GROUP BY t4.submit_org_nm
+        ) t on t1.organ_name = t.submit_org_nm
+        LEFT JOIN
+        (
+        select count(1) check_num,t2.submit_org_nm from pdm_inspection_problem_records t1,pdm_work_plan t2
+        where t1.day_op_info_id = t2.uuid and t1.delete_mark  = '0'
+        and date_format(plan_start_wk_tm,'%Y%m%d') &gt;= #{startDate} and date_format(plan_start_wk_tm,'%Y%m%d') &lt;= #{endDate}
+        GROUP BY t2.submit_org_nm
+        )tt on t1.organ_name = tt.submit_org_nm
+
         UNION ALL
-        select '总计' company,
-        IFNULL(sum(if((t3.audit_lvl_cd='2025001' and t2.break_rules_nature_cd = '2020002'),1,0)),0) province_num1,
-        IFNULL(sum(if((t3.audit_lvl_cd='2025001' and t2.break_rules_nature_cd = '2020001'),1,0)),0) province_num2,
-        IFNULL(sum(if((t3.audit_lvl_cd='2025002' and t2.break_rules_nature_cd = '2020002'),1,0)),0) city_num1,
-        IFNULL(sum(if((t3.audit_lvl_cd='2025002' and t2.break_rules_nature_cd = '2020001'),1,0)),0) city_num2,
-        IFNULL(sum(if((t3.audit_lvl_cd='2025003' and t2.break_rules_nature_cd = '2020002'),1,0)),0) county_num1,
-        IFNULL(sum(if((t3.audit_lvl_cd='2025003' and t2.break_rules_nature_cd = '2020001'),1,0)),0) county_num2,
-        0 check_num
-        from pdm_violation_records t2,pdm_inspection_records t3
-        where t2.audit_rec_id  = t3.audit_rec_id
-        and t2.data_dt  &gt;= #{startDate} and t2.data_dt &lt;= #{endDate}
+
+        select
+        '总计' company,
+        IFNULL(total_1.province_num1,0) province_num1,
+        IFNULL(total_1.province_num2,0) province_num2,
+        IFNULL(total_1.city_num2,0) city_num1,
+        IFNULL(total_1.city_num2,0) city_num2,
+        IFNULL(total_1.county_num1,0) county_num1,
+        IFNULL(total_1.county_num2,0) county_num2,
+        IFNULL(total_2.check_num,0) check_num
+        from
+        (select
+        sum(if((t3.audit_lvl_cd='2025001' and t2.break_rules_nature_cd = '2020002'),1,0)) province_num1,
+        sum(if((t3.audit_lvl_cd='2025001' and t2.break_rules_nature_cd = '2020001'),1,0)) province_num2,
+        sum(if((t3.audit_lvl_cd='2025002' and t2.break_rules_nature_cd = '2020002'),1,0)) city_num1,
+        sum(if((t3.audit_lvl_cd='2025002' and t2.break_rules_nature_cd = '2020001'),1,0)) city_num2,
+        sum(if((t3.audit_lvl_cd='2025003' and t2.break_rules_nature_cd = '2020002'),1,0)) county_num1,
+        sum(if((t3.audit_lvl_cd='2025003' and t2.break_rules_nature_cd = '2020001'),1,0)) county_num2
+        from pdm_violation_records t2,pdm_inspection_records t3,pdm_work_plan t4
+        where t2.audit_rec_id  = t3.audit_rec_id and t2.day_op_info_id = t4.uuid
+        and date_format(plan_start_wk_tm,'%Y%m%d') &gt;= #{startDate} and date_format(plan_start_wk_tm,'%Y%m%d') &lt;= #{endDate}
+        )total_1,
+        (select count(1) check_num from pdm_inspection_problem_records t1,pdm_work_plan t2
+        where t1.day_op_info_id = t2.uuid and t1.delete_mark  = '0'
+        and date_format(plan_start_wk_tm,'%Y%m%d') &gt;= #{startDate} and date_format(plan_start_wk_tm,'%Y%m%d') &lt;= #{endDate}
+        )total_2
     </select>
 
 </mapper>

+ 9 - 7
ruoyi-powerdistribution/src/main/resources/mapper/powerdistribution/PdmReportPlanNextDayMapper.xml

@@ -212,13 +212,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             GROUP BY submit_org_nm
         )  tt1 on t1.organ_name = tt1.submit_org_nm
                  LEFT JOIN(
-            select CONCAT(subs_or_line_nm,'(',count(1),'个作业面)') check_detail,
-                   submit_org_nm from
-                pdm_work_plan where volt_lvl_cd=  '2001008' and op_typ_cd != '2002001'
-             and date_format(plan_start_wk_tm,'%Y%m%d') &gt;= #{startDate}
-             and date_format(plan_start_wk_tm,'%Y%m%d') &lt;= #{endDate}
-            GROUP BY submit_org_nm,subs_or_line_nm
-            HAVING count(1) >1
+                 select GROUP_CONCAT(check_detail) check_detail,submit_org_nm from(
+                        select CONCAT(subs_or_line_nm,'(',count(1),'个作业面)') check_detail,
+                               submit_org_nm from
+                            pdm_work_plan where volt_lvl_cd=  '2001008' and op_typ_cd != '2002001'
+                         and date_format(plan_start_wk_tm,'%Y%m%d') &gt;= #{startDate}
+                         and date_format(plan_start_wk_tm,'%Y%m%d') &lt;= #{endDate}
+                        GROUP BY submit_org_nm,subs_or_line_nm
+                        HAVING count(1) >1
+                   ) line GROUP BY submit_org_nm
         ) tt2 on t1.organ_name = tt2.submit_org_nm
 
         UNION ALL