|
@@ -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="managerId" column="manager_id" />
|
|
|
<result property="managerName" column="manager_name" />
|
|
|
<result property="score" column="score" />
|
|
@@ -17,10 +20,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<result property="createTime" column="create_time" />
|
|
|
<result property="updateBy" column="update_by" />
|
|
|
<result property="updateTime" column="update_time" />
|
|
|
+ <result property="teamType" column="team_type" />
|
|
|
</resultMap>
|
|
|
|
|
|
<sql id="selectPdmScoreRankManagerVo">
|
|
|
- select id, report_year, report_date, company_no, company_name, manager_id, manager_name, score, create_by, create_time, update_by, update_time from pdm_score_rank_manager
|
|
|
+ select id, report_year, report_date, company_no, company_name,team_type,team_name, manager_id, manager_name, score, create_by, create_time, update_by, update_time,team_type from pdm_score_rank_manager
|
|
|
</sql>
|
|
|
|
|
|
<select id="selectPdmScoreRankManagerList" parameterType="PdmScoreRankManager" resultMap="PdmScoreRankManagerResult">
|
|
@@ -33,6 +37,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<if test="managerId != null and managerId != ''"> and manager_id = #{managerId}</if>
|
|
|
<if test="managerName != null and managerName != ''"> and manager_name like concat('%', #{managerName}, '%')</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,21 +112,112 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</delete>
|
|
|
|
|
|
<insert id="saveRank" parameterType="PdmScoreRankManager">
|
|
|
- insert into pdm_score_rank_manager(report_year,report_date,company_name,manager_name,score)
|
|
|
- select
|
|
|
- DATE_FORMAT(t2.op_plan_start_tm,'%Y') report_year,
|
|
|
- DATE_FORMAT(t2.op_plan_start_tm,'%Y%m') report_date,
|
|
|
- op_org company_name,work_princip manager_name,count(1) score
|
|
|
- from pdm_violation_records t1,pdm_inspection_records t2
|
|
|
- where t1.audit_rec_id = t2.audit_rec_id
|
|
|
- and date_format(t2.op_plan_start_tm,'%Y%m%d') >= #{startDate}
|
|
|
- and date_format(t2.op_plan_start_tm,'%Y%m%d') <= #{endDate}
|
|
|
- GROUP BY op_org,work_princip,work_princip_id
|
|
|
+ insert into pdm_score_rank_manager(report_year,report_date,company_name,team_type,team_name,manager_name,score)
|
|
|
+
|
|
|
+ select report_year,report_date,t1.submit_org_nm,'1' team_type,t1.work_team_nm,t1.work_princip_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,work_princip_nm,work_princip_id,
|
|
|
+ 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 pdm_work_plan
|
|
|
+ where 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,work_princip_nm,work_princip_id
|
|
|
+ )t1
|
|
|
+ LEFT JOIN
|
|
|
+ (
|
|
|
+ SELECT t3.submit_org_nm,t3.work_team_nm,work_princip_nm,t3.work_princip_id,
|
|
|
+ sum(if(t2.scene_rating_cd = '2018004' and audit_lvl_cd ='2025001' and break_rules_nature_cd = '2020001',1,0))*12 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 province_violation_2,
|
|
|
+ sum(if(t2.scene_rating_cd = '2018004' and audit_lvl_cd ='2025002' and break_rules_nature_cd = '2020001',1,0))*6 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 city_violation_2
|
|
|
+ from
|
|
|
+ pdm_violation_records t1,pdm_inspection_records t2,pdm_work_plan t3
|
|
|
+ where t1.audit_rec_id = t2.audit_rec_id and t1.day_op_info_id = t3.uuid
|
|
|
+ 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,work_team_nm,work_princip_nm,t3.work_princip_id
|
|
|
+ )t2 on t1.submit_org_nm = t2.submit_org_nm and t1.work_team_nm = t2.work_team_nm and t1.work_princip_nm = t2.work_princip_nm and t1.work_princip_id = t2.work_princip_id
|
|
|
+ LEFT JOIN
|
|
|
+ (
|
|
|
+ SELECT t3.submit_org_nm,work_team_nm,t3.work_princip_nm,t3.work_princip_id,
|
|
|
+ sum(if(t2.scene_rating_cd = '2018003' and audit_lvl_cd ='2025002' and t1.problem_level = '2070001',1,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 city_problem_2
|
|
|
+ from
|
|
|
+ pdm_inspection_problem_records t1,pdm_inspection_records t2,pdm_work_plan t3
|
|
|
+ where t1.day_op_info_id = t2.day_op_info_id and t2.day_op_info_id = t3.uuid
|
|
|
+ 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,work_team_nm,work_princip_nm,t3.work_princip_id
|
|
|
+ )t3 on t1.work_team_nm = t3.work_team_nm and t1.work_princip_nm = t3.work_princip_nm and t1.work_princip_id = t3.work_princip_id
|
|
|
+
|
|
|
+ union all
|
|
|
+
|
|
|
+ select report_year,report_date,'' submit_org_nm,'2' team_type,t1.work_team_nm,t1.work_princip_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,work_princip_nm,work_princip_id,
|
|
|
+ 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 pdm_work_plan
|
|
|
+ where 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,work_princip_nm,work_princip_id
|
|
|
+ )t1
|
|
|
+ LEFT JOIN
|
|
|
+ (
|
|
|
+ SELECT t3.work_team_nm,work_princip_nm,t3.work_princip_id,
|
|
|
+ sum(if(t2.scene_rating_cd = '2018004' and audit_lvl_cd ='2025001' and break_rules_nature_cd = '2020001',1,0))*12 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 province_violation_2,
|
|
|
+ sum(if(t2.scene_rating_cd = '2018004' and audit_lvl_cd ='2025002' and break_rules_nature_cd = '2020001',1,0))*6 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 city_violation_2
|
|
|
+ from
|
|
|
+ pdm_violation_records t1,pdm_inspection_records t2,pdm_work_plan t3
|
|
|
+ where t1.audit_rec_id = t2.audit_rec_id and t1.day_op_info_id = t3.uuid
|
|
|
+ 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 work_team_nm,work_princip_nm,t3.work_princip_id
|
|
|
+ )t2 on t1.work_team_nm = t2.work_team_nm and t1.work_princip_nm = t2.work_princip_nm and t1.work_princip_id = t2.work_princip_id
|
|
|
+ LEFT JOIN
|
|
|
+ (
|
|
|
+ SELECT work_team_nm,t3.work_princip_nm,t3.work_princip_id,
|
|
|
+ sum(if(t2.scene_rating_cd = '2018003' and audit_lvl_cd ='2025002' and t1.problem_level = '2070001',1,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 city_problem_2
|
|
|
+ from
|
|
|
+ pdm_inspection_problem_records t1,pdm_inspection_records t2,pdm_work_plan t3
|
|
|
+ where t1.day_op_info_id = t2.day_op_info_id and t2.day_op_info_id = t3.uuid
|
|
|
+ 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 work_team_nm,work_princip_nm,t3.work_princip_id
|
|
|
+ )t3 on t1.work_team_nm = t3.work_team_nm and t1.work_princip_nm = t3.work_princip_nm and t1.work_princip_id = t3.work_princip_id;
|
|
|
|
|
|
</insert>
|
|
|
|
|
|
<select id="getManagerRankYearList" parameterType="PdmScoreRankManager" resultMap="PdmScoreRankManagerResult">
|
|
|
- select report_year, company_name,manager_name,
|
|
|
+ select report_year, company_name,manager_name,team_type,
|
|
|
sum(score) score
|
|
|
from pdm_score_rank_manager
|
|
|
where report_year = #{reportYear}
|