|
@@ -132,71 +132,82 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
INSERT INTO pdm_score_rank_worker (report_year,report_date,company_name,team_type,team_name,work_user_name,score)
|
|
|
|
|
|
select DISTINCT report_year,report_date,t1.submit_org_nm,'1' team_type,t1.work_team_nm,t1.person_nm,
|
|
|
- work_level_1+work_level_2+work_level_3+work_level_4+work_level_5
|
|
|
- -IFNULL(province_violation_1,0)-IFNULL(province_violation_2,0)-IFNULL(city_violation_1,0)-IFNULL(city_violation_2,0)
|
|
|
- -IFNULL(city_problem_1,0) score
|
|
|
+ (work_level_1+work_level_2+work_level_3+work_level_4+work_level_5
|
|
|
+ -IFNULL(violation,0)-IFNULL(problem,0))*0.3 score
|
|
|
from
|
|
|
(
|
|
|
SELECT
|
|
|
DATE_FORMAT(plan_start_wk_tm,'%Y') report_year,
|
|
|
DATE_FORMAT(plan_start_wk_tm,'%Y%m') report_date,submit_org_nm,work_team_nm,person_nm,person_id,
|
|
|
- sum(if(op_risk_lvl_cd = '2007001',1,0))*6*0.3 work_level_1,
|
|
|
- sum(if(op_risk_lvl_cd = '2007002',1,0))*4*0.3 work_level_2,
|
|
|
- sum(if(op_risk_lvl_cd = '2007003',1,0))*2*0.3 work_level_3,
|
|
|
- sum(if(op_risk_lvl_cd = '2007004',1,0))*1*0.3 work_level_4,
|
|
|
- sum(if(op_risk_lvl_cd = '2007005',1,0))*0.5*0.3 work_level_5
|
|
|
+ sum(if(op_risk_lvl_cd = '2007001',1,0))*6 work_level_1,
|
|
|
+ sum(if(op_risk_lvl_cd = '2007002',1,0))*4 work_level_2,
|
|
|
+ sum(if(op_risk_lvl_cd = '2007003',1,0))*2 work_level_3,
|
|
|
+ sum(if(op_risk_lvl_cd = '2007004',1,0))*1 work_level_4,
|
|
|
+ sum(if(op_risk_lvl_cd = '2007005',1,0))*0.5 work_level_5
|
|
|
from ads_cst_hygszdbb_pdmworkplan_df t1,ads_cst_hygszdbb_pdmworkplanworker_df t2
|
|
|
where t1.uuid =t2.op_plan_id
|
|
|
- AND date_format(plan_start_wk_tm,'%Y%m%d') >= #{startDate}
|
|
|
+ and date_format(plan_start_wk_tm,'%Y%m%d') >= #{startDate}
|
|
|
and date_format(plan_start_wk_tm,'%Y%m%d') <= #{endDate}
|
|
|
+ and plan_exec_st_cd !='2029005'
|
|
|
and work_team_nm not like '%公司'
|
|
|
GROUP BY submit_org_nm,work_team_nm,person_nm,person_id
|
|
|
)t1
|
|
|
LEFT JOIN
|
|
|
(
|
|
|
- SELECT t3.submit_org_nm,t3.work_team_nm,person_nm,person_id,
|
|
|
- sum(if(t2.scene_rating_cd = '2018004' and audit_lvl_cd ='2025001' and break_rules_nature_cd = '2020001',1,0))*12*0.3 province_violation_1,
|
|
|
- sum(if(t2.scene_rating_cd = '2018004' and audit_lvl_cd ='2025001' and break_rules_nature_cd in ('2020002','2020003','2020004','2020005','2020006'),1,0))*4*0.3 province_violation_2,
|
|
|
- sum(if(t2.scene_rating_cd = '2018004' and audit_lvl_cd ='2025002' and break_rules_nature_cd = '2020001',1,0))*6*0.3 city_violation_1,
|
|
|
- sum(if(t2.scene_rating_cd = '2018004' and audit_lvl_cd ='2025002' and break_rules_nature_cd in ('2020002','2020003','2020004','2020005','2020006'),1,0))*2*0.3 city_violation_2
|
|
|
- from
|
|
|
- ads_cst_hygszdbb_pdmviolationrecords_df t1,ads_cst_hygszdbb_pdminspectionrecords_df t2,ads_cst_hygszdbb_pdmworkplan_df t3,ads_cst_hygszdbb_pdmworkplanworker_df t4
|
|
|
+ select submit_org_nm,work_team_nm,person_nm,person_id,sum(violation) violation from (
|
|
|
+ select uuid,submit_org_nm,work_team_nm,person_nm,person_id,max(violation) violation from (
|
|
|
+ select uuid,submit_org_nm,t3.work_team_nm,person_nm,person_id,
|
|
|
+ case when t2.scene_rating_cd = '2018004' and audit_lvl_cd ='2025001' and break_rules_nature_cd = '2020001' then 4
|
|
|
+ when t2.scene_rating_cd = '2018004' and audit_lvl_cd ='2025001' and break_rules_nature_cd in ('2020002','2020003','2020004','2020005','2020006') then 12
|
|
|
+ when t2.scene_rating_cd = '2018004' and audit_lvl_cd ='2025002' and break_rules_nature_cd = '2020001' then 2
|
|
|
+ when t2.scene_rating_cd = '2018004' and audit_lvl_cd ='2025002' and break_rules_nature_cd in ('2020002','2020003','2020004','2020005','2020006') then 6
|
|
|
+ when t2.scene_rating_cd = '2018004' and audit_lvl_cd ='2025003' and break_rules_nature_cd = '2020001' then 1
|
|
|
+ when t2.scene_rating_cd = '2018004' and audit_lvl_cd ='2025003' and break_rules_nature_cd in ('2020002','2020003','2020004','2020005','2020006') then 3
|
|
|
+ else 0
|
|
|
+ end as violation
|
|
|
+ from ads_cst_hygszdbb_pdmviolationrecords_df t1,ads_cst_hygszdbb_pdminspectionrecords_df t2,ads_cst_hygszdbb_pdmworkplan_df t3,ads_cst_hygszdbb_pdmworkplanworker_df t4
|
|
|
where t1.audit_rec_id = t2.audit_rec_id and t1.day_op_info_id = t3.uuid and t3.uuid =t4.op_plan_id
|
|
|
and work_team_nm not like '%公司'
|
|
|
and date_format(plan_start_wk_tm,'%Y%m%d') >= #{startDate}
|
|
|
and date_format(plan_start_wk_tm,'%Y%m%d') <= #{endDate}
|
|
|
- GROUP BY t3.submit_org_nm,t3.work_team_nm,person_nm,person_id
|
|
|
+ and plan_exec_st_cd !='2029005'
|
|
|
+ ) a GROUP BY uuid,submit_org_nm,work_team_nm,person_nm,person_id
|
|
|
+ ) aa GROUP BY submit_org_nm,work_team_nm,person_nm,person_id
|
|
|
+
|
|
|
)t2 on t1.submit_org_nm = t2.submit_org_nm and t1.work_team_nm = t2.work_team_nm and t1.person_nm = t2.person_nm and t1.person_id = t2.person_id
|
|
|
LEFT JOIN
|
|
|
(
|
|
|
- SELECT t3.submit_org_nm,work_team_nm,person_nm,person_id,
|
|
|
- sum(if(t2.scene_rating_cd = '2018003' and audit_lvl_cd ='2025002' and t1.problem_level in('2070004','2070005','2070006','2070007'),1,0))*3*0.3 city_problem_1,
|
|
|
- sum(if(t2.scene_rating_cd = '2018003' and audit_lvl_cd ='2025002' and t1.problem_level = '2070001',1,0))*1*0.3 city_problem_2
|
|
|
- from
|
|
|
- ads_cst_hygszdbb_pdminspectionproblemrecords_df t1,ads_cst_hygszdbb_pdminspectionrecords_df t2,ads_cst_hygszdbb_pdmworkplan_df t3,ads_cst_hygszdbb_pdmworkplanworker_df t4
|
|
|
+ select submit_org_nm,work_team_nm,person_nm,person_id,sum(problem) problem from (
|
|
|
+ select uuid,submit_org_nm,work_team_nm,person_nm,person_id,max(problem) problem from (
|
|
|
+ SELECT uuid,t3.submit_org_nm,work_team_nm,person_nm,person_id,
|
|
|
+ case when t2.scene_rating_cd = '2018003' and audit_lvl_cd ='2025002' and t1.problem_level in('2070004','2070005','2070006','2070007') then 3
|
|
|
+ else 0 end as problem
|
|
|
+ from ads_cst_hygszdbb_pdminspectionproblemrecords_df t1,ads_cst_hygszdbb_pdminspectionrecords_df t2,ads_cst_hygszdbb_pdmworkplan_df t3,ads_cst_hygszdbb_pdmworkplanworker_df t4
|
|
|
where t1.day_op_info_id = t2.day_op_info_id and t2.day_op_info_id = t3.uuid and t3.uuid =t4.op_plan_id
|
|
|
and work_team_nm not like '%公司'
|
|
|
and date_format(plan_start_wk_tm,'%Y%m%d') >= #{startDate}
|
|
|
and date_format(plan_start_wk_tm,'%Y%m%d') <= #{endDate}
|
|
|
- GROUP BY t3.submit_org_nm,t3.work_team_nm,person_nm,person_id
|
|
|
+ and plan_exec_st_cd !='2029005'
|
|
|
+ ) a GROUP BY uuid,submit_org_nm,work_team_nm,person_nm,person_id
|
|
|
+ ) aa GROUP BY submit_org_nm,work_team_nm,person_nm,person_id
|
|
|
+
|
|
|
)t3 on t1.submit_org_nm = t3.submit_org_nm and t1.work_team_nm = t3.work_team_nm and t1.person_nm = t2.person_nm and t1.person_id = t2.person_id
|
|
|
|
|
|
union all
|
|
|
|
|
|
select report_year,report_date,t1.work_team_nm submit_org_nm,'2' team_type,'' work_team_nm,t1.person_nm,
|
|
|
- work_level_1+work_level_2+work_level_3+work_level_4+work_level_5
|
|
|
- -IFNULL(province_violation_1,0)-IFNULL(province_violation_2,0)-IFNULL(city_violation_1,0)-IFNULL(city_violation_2,0)
|
|
|
- -IFNULL(city_problem_1,0)-IFNULL(city_problem_2,0) score
|
|
|
+ (work_level_1+work_level_2+work_level_3+work_level_4+work_level_5
|
|
|
+ -IFNULL(violation,0)-IFNULL(problem,0))*0.3 score
|
|
|
from
|
|
|
(
|
|
|
SELECT
|
|
|
DATE_FORMAT(plan_start_wk_tm,'%Y') report_year,
|
|
|
DATE_FORMAT(plan_start_wk_tm,'%Y%m') report_date,work_team_nm,person_nm,person_id,
|
|
|
- sum(if(op_risk_lvl_cd = '2007001',1,0))*6*0.3 work_level_1,
|
|
|
- sum(if(op_risk_lvl_cd = '2007002',1,0))*4*0.3 work_level_2,
|
|
|
- sum(if(op_risk_lvl_cd = '2007003',1,0))*2*0.3 work_level_3,
|
|
|
- sum(if(op_risk_lvl_cd = '2007004',1,0))*1*0.3 work_level_4,
|
|
|
- sum(if(op_risk_lvl_cd = '2007005',1,0))*0.5*0.3 work_level_5
|
|
|
+ sum(if(op_risk_lvl_cd = '2007001',1,0))*6 work_level_1,
|
|
|
+ sum(if(op_risk_lvl_cd = '2007002',1,0))*4 work_level_2,
|
|
|
+ sum(if(op_risk_lvl_cd = '2007003',1,0))*2 work_level_3,
|
|
|
+ sum(if(op_risk_lvl_cd = '2007004',1,0))*1 work_level_4,
|
|
|
+ sum(if(op_risk_lvl_cd = '2007005',1,0))*0.5 work_level_5
|
|
|
from ads_cst_hygszdbb_pdmworkplan_df t1,ads_cst_hygszdbb_pdmworkplanworker_df t2
|
|
|
where t1.uuid =t2.op_plan_id
|
|
|
and date_format(plan_start_wk_tm,'%Y%m%d') >= #{startDate}
|
|
@@ -206,31 +217,42 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
)t1
|
|
|
LEFT JOIN
|
|
|
(
|
|
|
- SELECT t3.work_team_nm,person_nm,person_id,
|
|
|
- sum(if(t2.scene_rating_cd = '2018004' and audit_lvl_cd ='2025001' and break_rules_nature_cd = '2020001',1,0))*12*0.3 province_violation_1,
|
|
|
- sum(if(t2.scene_rating_cd = '2018004' and audit_lvl_cd ='2025001' and break_rules_nature_cd in ('2020002','2020003','2020004','2020005','2020006'),1,0))*4*0.3 province_violation_2,
|
|
|
- sum(if(t2.scene_rating_cd = '2018004' and audit_lvl_cd ='2025002' and break_rules_nature_cd = '2020001',1,0))*6*0.3 city_violation_1,
|
|
|
- sum(if(t2.scene_rating_cd = '2018004' and audit_lvl_cd ='2025002' and break_rules_nature_cd in ('2020002','2020003','2020004','2020005','2020006'),1,0))*2*0.3 city_violation_2
|
|
|
- from
|
|
|
- ads_cst_hygszdbb_pdmviolationrecords_df t1,ads_cst_hygszdbb_pdminspectionrecords_df t2,ads_cst_hygszdbb_pdmworkplan_df t3,ads_cst_hygszdbb_pdmworkplanworker_df t4
|
|
|
+ select work_team_nm,person_nm,person_id,sum(violation) violation from (
|
|
|
+ select uuid,work_team_nm,person_nm,person_id,max(violation) violation from (
|
|
|
+ select uuid,t3.work_team_nm,person_nm,person_id,
|
|
|
+ case when t2.scene_rating_cd = '2018004' and audit_lvl_cd ='2025001' and break_rules_nature_cd = '2020001' then 4
|
|
|
+ when t2.scene_rating_cd = '2018004' and audit_lvl_cd ='2025001' and break_rules_nature_cd in ('2020002','2020003','2020004','2020005','2020006') then 12
|
|
|
+ when t2.scene_rating_cd = '2018004' and audit_lvl_cd ='2025002' and break_rules_nature_cd = '2020001' then 2
|
|
|
+ when t2.scene_rating_cd = '2018004' and audit_lvl_cd ='2025002' and break_rules_nature_cd in ('2020002','2020003','2020004','2020005','2020006') then 6
|
|
|
+ when t2.scene_rating_cd = '2018004' and audit_lvl_cd ='2025003' and break_rules_nature_cd = '2020001' then 1
|
|
|
+ when t2.scene_rating_cd = '2018004' and audit_lvl_cd ='2025003' and break_rules_nature_cd in ('2020002','2020003','2020004','2020005','2020006') then 3
|
|
|
+ else 0
|
|
|
+ end as violation
|
|
|
+ from ads_cst_hygszdbb_pdmviolationrecords_df t1,ads_cst_hygszdbb_pdminspectionrecords_df t2,ads_cst_hygszdbb_pdmworkplan_df t3,ads_cst_hygszdbb_pdmworkplanworker_df t4
|
|
|
where t1.audit_rec_id = t2.audit_rec_id and t1.day_op_info_id = t3.uuid and t3.uuid =t4.op_plan_id
|
|
|
and work_team_nm like '%公司' and work_team_nm not like '%雁能%'
|
|
|
and date_format(plan_start_wk_tm,'%Y%m%d') >= #{startDate}
|
|
|
and date_format(plan_start_wk_tm,'%Y%m%d') <= #{endDate}
|
|
|
- GROUP BY t3.work_team_nm,person_nm,person_id
|
|
|
+ and plan_exec_st_cd !='2029005'
|
|
|
+ ) a GROUP BY uuid,work_team_nm,person_nm,person_id
|
|
|
+ ) aa GROUP BY work_team_nm,person_nm,person_id
|
|
|
)t2 on t1.work_team_nm = t2.work_team_nm and t1.person_nm = t2.person_nm and t1.person_id = t2.person_id
|
|
|
LEFT JOIN
|
|
|
(
|
|
|
- SELECT work_team_nm,person_nm,person_id,
|
|
|
- sum(if(t2.scene_rating_cd = '2018003' and audit_lvl_cd ='2025002' and t1.problem_level in('2070004','2070005','2070006','2070007'),1,0))*3*0.3 city_problem_1,
|
|
|
- sum(if(t2.scene_rating_cd = '2018003' and audit_lvl_cd ='2025002' and t1.problem_level = '2070001',1,0))*1*0.3 city_problem_2
|
|
|
- from
|
|
|
- ads_cst_hygszdbb_pdminspectionproblemrecords_df t1,ads_cst_hygszdbb_pdminspectionrecords_df t2,ads_cst_hygszdbb_pdmworkplan_df t3,ads_cst_hygszdbb_pdmworkplanworker_df t4
|
|
|
+ select work_team_nm,person_nm,person_id,sum(problem) problem from (
|
|
|
+ select uuid,work_team_nm,person_nm,person_id,max(problem) problem from (
|
|
|
+ SELECT uuid,work_team_nm,person_nm,person_id,
|
|
|
+ case when t2.scene_rating_cd = '2018003' and audit_lvl_cd ='2025002' and t1.problem_level in('2070004','2070005','2070006','2070007') then 3
|
|
|
+ else 0 end as problem
|
|
|
+ from ads_cst_hygszdbb_pdminspectionproblemrecords_df t1,ads_cst_hygszdbb_pdminspectionrecords_df t2,ads_cst_hygszdbb_pdmworkplan_df t3,ads_cst_hygszdbb_pdmworkplanworker_df t4
|
|
|
where t1.day_op_info_id = t2.day_op_info_id and t2.day_op_info_id = t3.uuid and t3.uuid =t4.op_plan_id
|
|
|
and work_team_nm like '%公司' and work_team_nm not like '%雁能%'
|
|
|
and date_format(plan_start_wk_tm,'%Y%m%d') >= #{startDate}
|
|
|
and date_format(plan_start_wk_tm,'%Y%m%d') <= #{endDate}
|
|
|
- GROUP BY t3.work_team_nm,person_nm,person_id
|
|
|
+ and plan_exec_st_cd !='2029005'
|
|
|
+ ) a GROUP BY uuid,work_team_nm,person_nm,person_id
|
|
|
+ ) aa GROUP BY work_team_nm,person_nm,person_id
|
|
|
)t3 on t1.work_team_nm = t3.work_team_nm and t1.person_nm = t2.person_nm and t1.person_id = t2.person_id
|
|
|
+
|
|
|
</insert>
|
|
|
</mapper>
|