feat(): 用户考核统计数据接口分安全类环保类
parent
98fdc48095
commit
38711db39a
|
|
@ -29,6 +29,8 @@ public class UserEvalStatisticsCO implements Serializable {
|
|||
private String departmentName;
|
||||
@ApiModelProperty(value = "岗位")
|
||||
private String postName;
|
||||
@ApiModelProperty(value = "考评类型,1:安全类,2:环保类")
|
||||
private String evaluationType;
|
||||
@ApiModelProperty(value = "奖励总得分")
|
||||
private Integer totalScore;
|
||||
@ApiModelProperty(value = "已兑换分数")
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ public class UserEvalStatisticsDO implements Serializable {
|
|||
private String departmentName;
|
||||
@ApiModelProperty(value = "岗位")
|
||||
private String postName;
|
||||
@ApiModelProperty(value = "考评类型,1:安全类,2:环保类")
|
||||
private String evaluationType;
|
||||
@ApiModelProperty(value = "奖励总得分")
|
||||
private Integer totalScore;
|
||||
@ApiModelProperty(value = "已兑换分数")
|
||||
|
|
|
|||
|
|
@ -84,6 +84,8 @@ public class HiddenEvaluationRecordRepositoryImpl extends BaseRepositoryImpl<Hid
|
|||
if (!org.springframework.util.ObjectUtils.isEmpty(params.get("menuPath"))){
|
||||
menuPerms = MenuEnum.getMenuKeyByPath(params.get("menuPath").toString());
|
||||
}
|
||||
// 关闭 count SQL 优化,因为该查询包含派生表子查询 + CROSS JOIN 等复杂结构,JSQLParser 无法解析
|
||||
((com.baomidou.mybatisplus.extension.plugins.pagination.Page<?>) iPage).setOptimizeCountSql(false);
|
||||
IPage<UserEvalStatisticsDO> result = hiddenEvaluationRecordMapper.userEvalStatisticsPage(iPage, params,menuPerms);
|
||||
return PageHelper.pageToResponse(result, result.getRecords());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,39 @@
|
|||
|
||||
<mapper namespace="com.zcloud.hidden.evaluation.persistence.mapper.HiddenEvaluationRecordMapper">
|
||||
|
||||
<sql id="baseUserQuery">
|
||||
SELECT DISTINCT
|
||||
u_inner.id AS userId,
|
||||
u_inner.username AS userName,
|
||||
u_inner.name,
|
||||
u_inner.department_id AS departmentId,
|
||||
u_inner.corpinfo_id AS corpinfoId,
|
||||
d_inner.name AS departmentName,
|
||||
p_inner.post_name AS postName
|
||||
FROM hidden h_inner
|
||||
INNER JOIN user u_inner ON h_inner.creator_id = u_inner.id
|
||||
LEFT JOIN department d_inner ON u_inner.department_id = d_inner.id
|
||||
LEFT JOIN post p_inner ON u_inner.post_id = p_inner.id
|
||||
WHERE h_inner.delete_enum = 'FALSE'
|
||||
AND h_inner.state = 301
|
||||
AND ((h_inner.source IN (4,5) AND h_inner.final_check = 1) OR h_inner.source NOT IN (4,5))
|
||||
<if test="params.corpinfoId != null">
|
||||
AND u_inner.corpinfo_id = #{params.corpinfoId}
|
||||
</if>
|
||||
<if test="params.departmentId != null">
|
||||
AND d_inner.id = #{params.departmentId}
|
||||
</if>
|
||||
<if test="params.userName != null and params.userName != ''">
|
||||
AND u_inner.name LIKE CONCAT('%', #{params.userName}, '%')
|
||||
</if>
|
||||
<if test="params.userIdList != null and params.userIdList.size() > 0">
|
||||
AND u_inner.id IN
|
||||
<foreach collection="params.userIdList" item="item" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="corpHidddenPage" resultType="com.zcloud.hidden.evaluation.persistence.dataobject.CorpHiddenStatisticsDO" >
|
||||
SELECT ec.corpinfo_id as corpinfoId,
|
||||
ci.corp_name AS corpinfoName,
|
||||
|
|
@ -28,7 +61,8 @@
|
|||
COUNT(DISTINCT CASE WHEN h.source = 6 THEN h.hidden_id END) as fireCheckTotalCount,
|
||||
COUNT(DISTINCT CASE WHEN h.source = 7 AND her.evaluation_result != 1 THEN h.hidden_id END) as videoPatrolEvalCount,
|
||||
COUNT(DISTINCT CASE WHEN h.source = 7 THEN h.hidden_id END) as videoPatrolTotalCount,
|
||||
IFNULL(ec_all.evaluationMembers, '') AS evaluationMembers
|
||||
IFNULL(ec_all.evaluationMembers, '') AS evaluationMembers,
|
||||
(SELECT e.evaluation_closed FROM evaluation_corp e WHERE e.delete_enum = 'FALSE' LIMIT 1) AS evaluationClosed
|
||||
FROM evaluation_config ec
|
||||
left join evaluation_corp ecorp ON ecorp.corpinfo_id = ec.corpinfo_id AND ecorp.delete_enum = 'FALSE'
|
||||
LEFT JOIN corp_info ci ON ci.id = ec.corpinfo_id AND ci.delete_enum = 'FALSE'
|
||||
|
|
@ -268,7 +302,8 @@
|
|||
LEFT JOIN user usr ON ec.user_id = usr.id
|
||||
WHERE ec.corpinfo_id = ci.id
|
||||
AND ec.delete_enum = 'FALSE'
|
||||
AND ec.evaluation_type = 2) AS envEvaluationMember
|
||||
AND ec.evaluation_type = 2) AS envEvaluationMember,
|
||||
(SELECT e.evaluation_closed FROM evaluation_corp e WHERE e.delete_enum = 'FALSE' LIMIT 1) AS evaluationClosed
|
||||
FROM corp_info ci
|
||||
LEFT JOIN user hu ON hu.corpinfo_id = ci.id
|
||||
LEFT JOIN hidden h ON hu.id = h.creator_id AND h.delete_enum = 'FALSE' AND h.state = 301 AND
|
||||
|
|
@ -300,30 +335,39 @@
|
|||
|
||||
<select id="userEvalStatisticsPage" resultType="com.zcloud.hidden.evaluation.persistence.dataobject.UserEvalStatisticsDO">
|
||||
SELECT
|
||||
ci.corp_name as corpinfoName,
|
||||
h.creator_id as userId,
|
||||
ci.corp_name AS corpinfoName,
|
||||
u.id AS userId,
|
||||
u.username AS userName,
|
||||
u.name AS name,
|
||||
u.department_id as departmentId,
|
||||
u.name,
|
||||
u.department_id AS departmentId,
|
||||
d.name AS departmentName,
|
||||
p.post_name AS postName,
|
||||
COUNT(DISTINCT CASE WHEN her.evaluation_result =2 THEN h.id END) AS totalScore,
|
||||
1 AS evaluationType,
|
||||
COUNT(DISTINCT CASE WHEN her.evaluation_result = 2 THEN h.id END) AS totalScore,
|
||||
COUNT(DISTINCT CASE WHEN her.exchange_flag = 1 THEN h.id END) AS exchangedScore,
|
||||
COUNT(DISTINCT CASE WHEN her.exchange_flag = 0 and her.evaluation_result=2 THEN h.id END) AS notExchangedScore
|
||||
FROM hidden h left join evaluation_corp ecorp on ecorp.corpinfo_id = h.corp_id
|
||||
inner JOIN user u ON h.creator_id = u.id
|
||||
COUNT(DISTINCT CASE WHEN her.exchange_flag = 0 AND her.evaluation_result = 2 THEN h.id END) AS notExchangedScore
|
||||
FROM user u
|
||||
LEFT JOIN department d ON u.department_id = d.id
|
||||
left join post p ON u.post_id = p.id
|
||||
left join corp_info ci ON h.corp_id = ci.id AND ci.delete_enum = 'FALSE'
|
||||
LEFT JOIN hidden_evaluation_record her ON h.hidden_id = her.hidden_id AND her.delete_enum = 'FALSE'
|
||||
WHERE h.delete_enum = 'FALSE'
|
||||
LEFT JOIN post p ON u.post_id = p.id
|
||||
LEFT JOIN corp_info ci ON u.corpinfo_id = ci.id AND ci.delete_enum = 'FALSE'
|
||||
LEFT JOIN hidden h ON h.creator_id = u.id
|
||||
AND h.delete_enum = 'FALSE'
|
||||
AND h.state = 301
|
||||
AND (
|
||||
(h.source IN (4,5) AND h.final_check = 1)
|
||||
OR h.source NOT IN (4,5)
|
||||
AND ((h.source IN (4,5) AND h.final_check = 1) OR h.source NOT IN (4,5))
|
||||
AND h.hidden_type IN ('aqyh','rdbaqys','wzcz','wzzh','grfhyp','wdbaqzt','jxsb','hcl','dqsb','gsj','aqbhzz','ss','xf','tzsb','hjdbaqys','zmjdgyxbj','aqbzbs','gkkd','zykjxzzl','eltq','gldqx','wzdhzdlsbdw','wfacs','jypx','aqyh-qt')
|
||||
LEFT JOIN hidden_evaluation_record her ON h.hidden_id = her.hidden_id
|
||||
AND her.evaluation_type = 1
|
||||
AND her.delete_enum = 'FALSE'
|
||||
WHERE u.delete_enum = 'FALSE'
|
||||
AND EXISTS (
|
||||
SELECT 1 FROM hidden h_exist
|
||||
WHERE h_exist.creator_id = u.id
|
||||
AND h_exist.delete_enum = 'FALSE'
|
||||
AND h_exist.state = 301
|
||||
AND ((h_exist.source IN (4,5) AND h_exist.final_check = 1) OR h_exist.source NOT IN (4,5))
|
||||
)
|
||||
<if test="params.corpinfoId != null">
|
||||
AND u.corpinfo_id= #{params.corpinfoId}
|
||||
AND u.corpinfo_id = #{params.corpinfoId}
|
||||
</if>
|
||||
<if test="params.departmentId != null ">
|
||||
AND d.id = #{params.departmentId}
|
||||
|
|
@ -331,15 +375,66 @@
|
|||
<if test="params.userName != null and params.userName != ''">
|
||||
AND u.name LIKE CONCAT('%', #{params.userName}, '%')
|
||||
</if>
|
||||
|
||||
<if test="params.userIdList != null and params.userIdList.size() > 0">
|
||||
and h.creator_id in
|
||||
AND u.id IN
|
||||
<foreach collection="params.userIdList" item="item" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
GROUP BY h.creator_id
|
||||
ORDER BY u.sort ,u.create_time desc
|
||||
GROUP BY u.id, u.username, u.name, u.department_id, d.name, p.post_name, ci.corp_name
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
ci.corp_name AS corpinfoName,
|
||||
u.id AS userId,
|
||||
u.username AS userName,
|
||||
u.name,
|
||||
u.department_id AS departmentId,
|
||||
d.name AS departmentName,
|
||||
p.post_name AS postName,
|
||||
2 AS evaluationType,
|
||||
COUNT(DISTINCT CASE WHEN her.evaluation_result = 2 THEN h.id END) AS totalScore,
|
||||
COUNT(DISTINCT CASE WHEN her.exchange_flag = 1 THEN h.id END) AS exchangedScore,
|
||||
COUNT(DISTINCT CASE WHEN her.exchange_flag = 0 AND her.evaluation_result = 2 THEN h.id END) AS notExchangedScore
|
||||
FROM user u
|
||||
LEFT JOIN department d ON u.department_id = d.id
|
||||
LEFT JOIN post p ON u.post_id = p.id
|
||||
LEFT JOIN corp_info ci ON u.corpinfo_id = ci.id AND ci.delete_enum = 'FALSE'
|
||||
LEFT JOIN hidden h ON h.creator_id = u.id
|
||||
AND h.delete_enum = 'FALSE'
|
||||
AND h.state = 301
|
||||
AND ((h.source IN (4,5) AND h.final_check = 1) OR h.source NOT IN (4,5))
|
||||
AND h.hidden_type IN ('wshb','hjwr','ws','dq','zs','gf','hjwsjlh','yqfk','wshb-qt')
|
||||
LEFT JOIN hidden_evaluation_record her ON h.hidden_id = her.hidden_id
|
||||
AND her.evaluation_type = 2
|
||||
AND her.delete_enum = 'FALSE'
|
||||
WHERE u.delete_enum = 'FALSE'
|
||||
AND EXISTS (
|
||||
SELECT 1 FROM hidden h_exist
|
||||
WHERE h_exist.creator_id = u.id
|
||||
AND h_exist.delete_enum = 'FALSE'
|
||||
AND h_exist.state = 301
|
||||
AND ((h_exist.source IN (4,5) AND h_exist.final_check = 1) OR h_exist.source NOT IN (4,5))
|
||||
)
|
||||
<if test="params.corpinfoId != null">
|
||||
AND u.corpinfo_id = #{params.corpinfoId}
|
||||
</if>
|
||||
<if test="params.departmentId != null ">
|
||||
AND d.id = #{params.departmentId}
|
||||
</if>
|
||||
<if test="params.userName != null and params.userName != ''">
|
||||
AND u.name LIKE CONCAT('%', #{params.userName}, '%')
|
||||
</if>
|
||||
<if test="params.userIdList != null and params.userIdList.size() > 0">
|
||||
AND u.id IN
|
||||
<foreach collection="params.userIdList" item="item" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
GROUP BY u.id, u.username, u.name, u.department_id, d.name, p.post_name, ci.corp_name
|
||||
|
||||
ORDER BY userId ASC
|
||||
</select>
|
||||
|
||||
<select id="hiddenEvalPage" resultType="com.zcloud.hidden.evaluation.persistence.dataobject.HiddenEvalDO">
|
||||
|
|
@ -438,7 +533,8 @@
|
|||
THEN h.id END) AS exchangeScoreCount,
|
||||
COUNT(DISTINCT CASE
|
||||
WHEN her.evaluation_result = 2 AND her.exchange_flag = 0 AND u.corpinfo_id = ecorp.corpinfo_id
|
||||
THEN h.id END) AS unExchangeScoreCount
|
||||
THEN h.id END) AS unExchangeScoreCount,
|
||||
(SELECT e.evaluation_closed FROM evaluation_corp e WHERE e.delete_enum = 'FALSE' LIMIT 1) AS evaluationClosed
|
||||
FROM evaluation_corp ecorp
|
||||
LEFT JOIN evaluation_config ec on ecorp.corpinfo_id = ec.corpinfo_id AND ecorp.delete_enum = 'FALSE'
|
||||
LEFT JOIN corp_info ci
|
||||
|
|
|
|||
Loading…
Reference in New Issue