|
@@ -56,17 +56,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
56
|
56
|
</select>
|
57
|
57
|
|
58
|
58
|
<select id="selectCmcStudyStatistic" parameterType="CmcStudy" resultMap="CmcStudyResult">
|
59
|
|
- select * from
|
60
|
|
- (select u.user_id, u.dept_id, u.nick_name, d.dept_name, sum(s.get_hours) as get_hours, u.status, s.last_time from sys_user as u
|
|
59
|
+ select t.user_id, t.dept_id, t.nick_name, t.dept_name, sum(t.get_hours) as get_hours, t.status, t.last_time from
|
|
60
|
+ (select t1.* from (select u.user_id, u.dept_id, u.nick_name, d.dept_name, sum(s.get_hours) as get_hours, u.status, s.last_time as last_time from sys_user as u
|
61
|
61
|
left join cmc_study as s on u.user_id = s.user_id
|
62
|
62
|
left join sys_dept as d on d.dept_id = u.dept_id
|
63
|
|
- group by u.user_id) as t
|
64
|
63
|
<where>
|
65
|
|
- t.status = '0' and t.user_id != 1
|
66
|
|
- <if test="deptId != null "> and t.dept_id = #{deptId}</if>
|
67
|
|
- <if test="lastTime != null "> and YEAR(t.last_time) = YEAR(#{lastTime})</if>
|
|
64
|
+ u.status = '0' and u.user_id != 1
|
|
65
|
+ <if test="deptId != null "> and u.dept_id = #{deptId}</if>
|
|
66
|
+ <if test="lastTime != null "> and YEAR(s.last_time) = YEAR(#{lastTime})</if>
|
|
67
|
+ </where>
|
|
68
|
+ group by u.user_id) as t1
|
|
69
|
+ union
|
|
70
|
+ select t2.* from (select u.user_id, u.dept_id, u.nick_name, d.dept_name, sum(ta.hours) as get_hours, u.status, ta.dept_time as last_time from sys_user as u
|
|
71
|
+ left join cmc_train_approval as ta on ta.user_id = u.user_id
|
|
72
|
+ left join sys_dept as d on d.dept_id = u.dept_id
|
|
73
|
+ <where>
|
|
74
|
+ u.status = '0' and u.user_id != 1 and ta.dept_time is not null
|
|
75
|
+ <if test="deptId != null "> and u.dept_id = #{deptId}</if>
|
|
76
|
+ <if test="lastTime != null "> and YEAR(ta.dept_time) = YEAR(#{lastTime})</if>
|
68
|
77
|
</where>
|
69
|
|
- order by t.get_hours desc, user_id
|
|
78
|
+ group by u.user_id) as t2) as t
|
|
79
|
+ group by t.user_id
|
|
80
|
+ order by get_hours desc, user_id
|
70
|
81
|
</select>
|
71
|
82
|
|
72
|
83
|
<select id="selectCmcStudyByStudyId" parameterType="Integer" resultMap="CmcStudyResult">
|