|
@@ -10,6 +10,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<result property="reportDate" column="report_date" />
|
|
|
<result property="companyNo" column="company_no" />
|
|
|
<result property="companyName" column="company_name" />
|
|
|
+ <result property="teamType" column="team_type" />
|
|
|
+ <result property="teamId" column="team_id" />
|
|
|
+ <result property="teamName" column="team_name" />
|
|
|
<result property="workUserId" column="work_user_id" />
|
|
|
<result property="workUserName" column="work_user_name" />
|
|
|
<result property="score" column="score" />
|
|
@@ -20,7 +23,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</resultMap>
|
|
|
|
|
|
<sql id="selectPdmScoreRankWorkerVo">
|
|
|
- select id, report_year, report_date, company_no, SUBSTRING_INDEX(company_name, '国网湖南省电力有限公司', -1)company_name, work_user_id, work_user_name, score, create_by, create_time, update_by, update_time from pdm_score_rank_worker
|
|
|
+ select id, report_year, report_date, company_no, SUBSTRING_INDEX(company_name, '国网湖南省电力有限公司', -1)company_name,team_type,team_name,work_user_id, work_user_name, score, create_by, create_time, update_by, update_time from pdm_score_rank_worker
|
|
|
</sql>
|
|
|
|
|
|
<select id="selectPdmScoreRankWorkerList" parameterType="PdmScoreRankWorker" resultMap="PdmScoreRankWorkerResult">
|
|
@@ -33,6 +36,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<if test="workUserId != null and workUserId != ''"> and work_user_id = #{workUserId}</if>
|
|
|
<if test="workUserName != null and workUserName != ''"> and work_user_name like concat('%', #{workUserName}, '%')</if>
|
|
|
<if test="score != null "> and score = #{score}</if>
|
|
|
+ <if test="teamType != null and teamType != ''"> and team_type = #{teamType}</if>
|
|
|
</where>
|
|
|
<if test="isBlack == null or isBlack == '' ">
|
|
|
order by score desc
|
|
@@ -107,11 +111,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</delete>
|
|
|
|
|
|
<select id="getWorkerRankYearList" parameterType="PdmScoreRankWorker" resultMap="PdmScoreRankWorkerResult">
|
|
|
- select report_year, SUBSTRING_INDEX(company_name, '国网湖南省电力有限公司', -1)company_name, work_user_name,
|
|
|
+ select report_year, SUBSTRING_INDEX(company_name, '国网湖南省电力有限公司', -1)company_name,team_type,team_name, work_user_name,
|
|
|
sum(score) score
|
|
|
from pdm_score_rank_worker
|
|
|
where report_year = #{reportYear}
|
|
|
- group by report_year,company_name,work_user_name
|
|
|
+ group by report_year,company_name,team_type,team_name,work_user_name
|
|
|
<if test="isBlack == null or isBlack == '' ">
|
|
|
order by score desc
|
|
|
</if>
|
|
@@ -121,14 +125,108 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</select>
|
|
|
|
|
|
<insert id="saveWorker" parameterType="PdmScoreRankWorker">
|
|
|
- INSERT INTO pdm_score_rank_worker (report_year,report_date,company_name,work_user_id,work_user_name,score)
|
|
|
- SELECT DATE_FORMAT(create_tm,'%Y') report_year,
|
|
|
- DATE_FORMAT(create_tm,'%Y%m') report_date,
|
|
|
- std_county_org_nm company_name,
|
|
|
- person_id,person_nm,count(1) score
|
|
|
- from pdm_work_plan_worker
|
|
|
- where date_format(create_tm,'%Y%m%d') >= #{startDate}
|
|
|
- and date_format(create_tm,'%Y%m%d') <= #{endDate}
|
|
|
- GROUP BY std_county_org_nm,person_id,person_nm
|
|
|
+ INSERT INTO pdm_score_rank_worker (report_year,report_date,company_name,team_type,team_name,work_user_name,score)
|
|
|
+
|
|
|
+ select 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)-IFNULL(city_problem_2,0) 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
|
|
|
+ from pdm_work_plan t1,pdm_work_plan_worker 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') <= #{endDate}
|
|
|
+ and work_team_nm not like '%公司'
|
|
|
+ GROUP BY submit_org_nm,work_team_nm,person_nm,person_nm
|
|
|
+ )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
|
|
|
+ pdm_violation_records t1,pdm_inspection_records t2,pdm_work_plan t3,pdm_work_plan_worker 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
|
|
|
+ )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 = '2070001',1,0))*3*0.3 city_problem_1,
|
|
|
+ sum(if(t2.scene_rating_cd = '2018003' and audit_lvl_cd ='2025002' and t1.problem_level in('2070004','2070005','2070006','2070007'),1,0))*1*0.3 city_problem_2
|
|
|
+ from
|
|
|
+ pdm_inspection_problem_records t1,pdm_inspection_records t2,pdm_work_plan t3,pdm_work_plan_worker 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
|
|
|
+ )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,'' submit_org_nm,'2' 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)-IFNULL(city_problem_2,0) 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
|
|
|
+ from pdm_work_plan t1,pdm_work_plan_worker 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') <= #{endDate}
|
|
|
+ and work_team_nm like '%公司'
|
|
|
+ GROUP BY work_team_nm,person_nm,person_nm
|
|
|
+ )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
|
|
|
+ pdm_violation_records t1,pdm_inspection_records t2,pdm_work_plan t3,pdm_work_plan_worker 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 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
|
|
|
+ )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 = '2070001',1,0))*3*0.3 city_problem_1,
|
|
|
+ sum(if(t2.scene_rating_cd = '2018003' and audit_lvl_cd ='2025002' and t1.problem_level in('2070004','2070005','2070006','2070007'),1,0))*1*0.3 city_problem_2
|
|
|
+ from
|
|
|
+ pdm_inspection_problem_records t1,pdm_inspection_records t2,pdm_work_plan t3,pdm_work_plan_worker 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 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
|
|
|
+ )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>
|