ChargerAssessScoreDetailSMapper.xml
10.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zteits.park.mapper.smapper.ChargerAssessScoreDetailSMapper">
<resultMap id="BaseResultMap" type="com.zteits.park.domain.ChargerAssessScoreDetail">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="static_date" jdbcType="DATE" property="staticDate" />
<result column="evidence_no" jdbcType="VARCHAR" property="evidenceNo" />
<result column="charger_code" jdbcType="VARCHAR" property="chargerCode" />
<result column="charger_name" jdbcType="VARCHAR" property="chargerName" />
<result column="person_type" jdbcType="INTEGER" property="personType" />
<result column="target_no" jdbcType="VARCHAR" property="targetNo" />
<result column="score_type" jdbcType="INTEGER" property="scoreType" />
<result column="temp_score" jdbcType="INTEGER" property="tempScore" />
<result column="org_id" jdbcType="BIGINT" property="orgId" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
<result column="data_state" jdbcType="INTEGER" property="dataState" />
<result column="exam_state" jdbcType="INTEGER" property="examState" />
<result column="create_emp_id" jdbcType="VARCHAR" property="createEmpId" />
<result column="create_emp_name" jdbcType="VARCHAR" property="createEmpName" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="modify_emp_id" jdbcType="VARCHAR" property="modifyEmpId" />
<result column="modify_emp_name" jdbcType="VARCHAR" property="modifyEmpName" />
<result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime" />
</resultMap>
<sql id="Base_Column_List">
id, static_date, evidence_no, charger_code, charger_name, person_type, target_no,
score_type, temp_score, org_id, remark, data_state, create_emp_id, create_emp_name,
create_time, modify_emp_id, modify_emp_name, modify_time
</sql>
<!-- 条件分页查询人员考核结果 -->
<select id="queryChargerAssessResultForPage"
parameterType="com.zteits.clouds.api.dto.assess.param.ChargerAssessRequest"
resultType="com.zteits.clouds.api.dto.assess.dto.ChargerAssessResultDTO">
select
aa.*,
<foreach collection="chargerAssessTemplateRelDTOs" item="rel">
<choose>
<when test="rel.targetNo != null and rel.targetNo != '' and rel.targetNo == 'Z1001'">
aa.baseScoreZ1001 + aa.tempScoreZ1001 AS actScoreZ1001,
</when>
<when test="rel.targetNo != null and rel.targetNo != '' and rel.targetNo == 'Z1002'">
aa.baseScoreZ1002 + aa.tempScoreZ1002 AS actScoreZ1002,
</when>
<otherwise>
</otherwise>
</choose>
</foreach>
0
<foreach collection="chargerAssessTemplateRelDTOs" item="rel">
<choose>
<when test="rel.targetNo != null and rel.targetNo != '' and rel.targetNo == 'Z1001'">
+ (aa.baseScoreZ1001 + aa.tempScoreZ1001) * aa.weightRateZ1001
</when>
<when test="rel.targetNo != null and rel.targetNo != '' and rel.targetNo == 'Z1002'">
+ (aa.baseScoreZ1002 + aa.tempScoreZ1002) * aa.weightRateZ1002
</when>
<otherwise>
</otherwise>
</choose>
</foreach>
AS actScore
from
( select
<foreach collection="chargerAssessTemplateRelDTOs" item="rel">
<choose>
<when test="rel.targetNo != null and rel.targetNo != '' and rel.targetNo == 'Z1001'">
#{rel.baseScore} AS baseScoreZ1001,
#{rel.minScore} AS minScoreZ1001,
#{rel.maxScore} AS maxScoreZ1001,
#{rel.weightRate} AS weightRateZ1001,
CASE
<foreach collection="chargerAssessRuleDTOs" item="rule">
<choose>
<when test="rule.targetNo != null and rule.targetNo != '' and rule.targetNo == 'Z1001' and rule.rangeEnd < 1 ">
WHEN (a.normalSignRateZ1001 >= #{rule.rangeBegin} and a.normalSignRateZ1001 < #{rule.rangeEnd}) THEN #{rule.tempScore}
</when>
<when test="rule.targetNo != null and rule.targetNo != '' and rule.targetNo == 'Z1001' and rule.rangeEnd >= 1 ">
WHEN (a.normalSignRateZ1001 >= #{rule.rangeBegin} and a.normalSignRateZ1001 <= #{rule.rangeEnd}) THEN #{rule.tempScore}
</when>
</choose>
</foreach>
ELSE 0
END tempScoreZ1001,
</when>
</choose>
<choose>
<when test="rel.targetNo != null and rel.targetNo != '' and rel.targetNo == 'Z1002'">
#{rel.baseScore} AS baseScoreZ1002,
#{rel.minScore} AS minScoreZ1002,
#{rel.maxScore} AS maxScoreZ1002,
#{rel.weightRate} AS weightRateZ1002,
SUM(a.tempScore1002) tempScoreZ1002,
</when>
</choose>
</foreach>
a.*
from
(SELECT
<foreach collection="chargerAssessTemplateRelDTOs" item="rel">
<if test="rel.targetNo != null and rel.targetNo != '' and rel.targetNo == 'Z1001'">
COUNT(score_type) totalSignNum,
SUM(CASE WHEN (target_no = 'Z1001' AND score_type = 0) THEN 1 ELSE 0 END ) AS normalSignNum,
SUM(CASE WHEN (target_no = 'Z1001' AND score_type = 1) THEN 1 ELSE 0 END ) AS abnormalSignNum,
SUM(CASE WHEN (target_no = 'Z1001' AND score_type = 0) THEN 1 ELSE 0 END ) / COUNT(score_type) AS normalSignRateZ1001,
</if>
<if test="rel.targetNo != null and rel.targetNo != '' and rel.targetNo == 'Z1002'">
SUM(CASE WHEN (target_no = 'Z1002' ) THEN temp_score ELSE 0 END ) AS tempScore1002,
</if>
</foreach>
charger_code AS chargerCode,
charger_name AS chargerName,
person_type AS personType,
MAX(static_date) AS staticDate,
org_id AS orgId
FROM
`charger_assess_score_detail`
where data_state = 1
AND exam_state = 1
AND static_date BETWEEN #{beginTime} AND #{endTime}
AND org_id = #{orgId}
<if test="chargerCodes != null and chargerCodes.size() >0">
AND charger_code in
<foreach collection="chargerCodes" item="chargerCode" separator="," open="(" close=")" index="index">
#{chargerCode}
</foreach>
</if>
<if test="personType != null ">
AND person_type = #{personType}
</if>
GROUP BY charger_code,charger_name,org_id)a
GROUP BY a.chargerCode,a.chargerName,a.orgId)aa
<choose>
<when test="baseRequest != null and baseRequest.sortName != null and baseRequest.sortOrder != null
and baseRequest.sortName != '' and baseRequest.sortOrder != ''">
ORDER BY ${baseRequest.sortName} ${baseRequest.sortOrder}
</when>
<otherwise>
ORDER BY actScore DESC
</otherwise>
</choose>
</select>
<!--公共查询条件-->
<sql id="selective_where_condition">
data_state = 1
AND exam_state = 1
AND static_date BETWEEN #{beginTime} AND #{endTime}
AND org_id = #{orgId}
<if test="chargerCodes != null and chargerCodes.size() >0">
AND charger_code in
<foreach collection="chargerCodes" item="chargerCode" separator="," open="(" close=")" index="index">
#{chargerCode}
</foreach>
</if>
<if test="personType != null ">
AND person_type = #{personType}
</if>
</sql>
<!-- 查询人员签到情况 -->
<select id="queryChargerAssessResultForSign"
parameterType="com.zteits.clouds.api.dto.assess.param.ChargerAssessRequest"
resultType="com.zteits.clouds.api.dto.assess.dto.ChargerAssessResultDTO">
select
COUNT(score_type) totalSignNum,
SUM(CASE WHEN (score_type = 0) THEN 1 ELSE 0 END ) AS normalSignNum,
SUM(CASE WHEN (score_type = 1) THEN 1 ELSE 0 END ) AS abnormalSignNum,
SUM(CASE WHEN (score_type = 0) THEN 1 ELSE 0 END ) / COUNT(score_type) AS normalSignRateZ1001,
charger_code AS chargerCode,
charger_name AS chargerName,
person_type AS personType,
MAX(static_date) AS staticDate,
org_id AS orgId
FROM
`charger_assess_score_detail`
<where>
<include refid="selective_where_condition"/>
</where>
AND target_no = 'Z1001'
GROUP BY charger_code,org_id
</select>
<!-- 查询人员服务态度得分 -->
<select id="queryChargerAssessResultForService"
parameterType="com.zteits.clouds.api.dto.assess.param.ChargerAssessRequest"
resultType="com.zteits.clouds.api.dto.assess.dto.ChargerAssessResultDTO">
select
SUM(temp_score) AS tempScoreZ1002,
charger_code AS chargerCode,
charger_name AS chargerName,
person_type AS personType,
MAX(static_date) AS staticDate,
org_id AS orgId
FROM
`charger_assess_score_detail`
<where>
<include refid="selective_where_condition"/>
</where>
AND target_no = 'Z1002'
GROUP BY charger_code,org_id
</select>
</mapper>