|
|
@ -22,4 +22,121 @@ |
|
|
|
(select * from t_site_qrcode where out_or_in = 1) t2 |
|
|
|
on t.id = t2.site_id |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="selectSiteOverview" resultType="com.ccsens.health.bean.vo.ClockVo$SiteOverview" parameterType="java.util.Map"> |
|
|
|
SELECT |
|
|
|
s.id as id, |
|
|
|
s.site_name as siteName, |
|
|
|
COUNT(c.id) as number |
|
|
|
FROM |
|
|
|
t_site s left join t_site_clock_in c on c.site_id = s.id |
|
|
|
|
|
|
|
<if test="time != null"> |
|
|
|
and |
|
|
|
c.time <= #{time} and c.out_time >= #{time} |
|
|
|
</if> |
|
|
|
where |
|
|
|
s.rec_status = 0 |
|
|
|
<if test="siteName != null and siteName != ''"> |
|
|
|
and s.site_name = #{siteName} |
|
|
|
</if> |
|
|
|
GROUP BY s.id |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="selectSiteMemberList" resultType="com.ccsens.health.bean.vo.ClockVo$SiteMemberList"> |
|
|
|
SELECT |
|
|
|
c.id as id, |
|
|
|
s.site_name as sitrName, |
|
|
|
m.name as name, |
|
|
|
m.wkno as wkno, |
|
|
|
m.department as department, |
|
|
|
c.time as inTime, |
|
|
|
c.out_time as outTime, |
|
|
|
a.user_id as userId, |
|
|
|
h.health_type_id as healthType |
|
|
|
FROM |
|
|
|
t_site_clock_in c left join t_site s on c.site_id = s.id |
|
|
|
left join t_real_name_auth a on c.user_id = a.user_id |
|
|
|
left join t_member m on a.`no` = m.wkno |
|
|
|
left join ( |
|
|
|
SELECT * |
|
|
|
FROM |
|
|
|
t_health_records |
|
|
|
ORDER BY time DESC |
|
|
|
limit 1 |
|
|
|
) h on h.user_id = a.user_id |
|
|
|
where |
|
|
|
s. rec_status = 0 |
|
|
|
<if test="siteName != null and siteName != ''"> |
|
|
|
and s.site_name = #{siteName} |
|
|
|
</if> |
|
|
|
<if test="name != null and name != ''"> |
|
|
|
and m.name = #{name} |
|
|
|
</if> |
|
|
|
<if test="wkno != null and wkno != ''"> |
|
|
|
and m.wkno = #{wkno} |
|
|
|
</if> |
|
|
|
<if test="department != null and department != ''"> |
|
|
|
and m.department = #{department} |
|
|
|
</if> |
|
|
|
<if test="endTime != null"> |
|
|
|
and c.time <= #{endTime} |
|
|
|
</if> |
|
|
|
<if test="startTime != null"> |
|
|
|
and c.out_time >= #{startTime} |
|
|
|
</if> |
|
|
|
ORDER BY c.time DESC |
|
|
|
</select> |
|
|
|
|
|
|
|
<sql id="t1"> |
|
|
|
select FROM_UNIXTIME(sc.time/1000,'%Y-%m-%d %H') as time, count(*) as inCount from t_site s, t_site_clock_in sc where s.id = sc.site_id |
|
|
|
<if test="siteName != null and siteName != ''"> |
|
|
|
and s.site_name = #{siteName} |
|
|
|
</if> |
|
|
|
<if test="startTime != null"> |
|
|
|
and sc.time >= #{startTime} |
|
|
|
</if> |
|
|
|
<if test="endTime != null"> |
|
|
|
and sc.time <= #{endTime} |
|
|
|
</if> |
|
|
|
group by FROM_UNIXTIME(sc.time/1000,'%Y-%m-%d %H') |
|
|
|
</sql> |
|
|
|
<sql id="t2"> |
|
|
|
select FROM_UNIXTIME(sc.out_time/1000,'%Y-%m-%d %H') as time, count(*) as outCount from t_site s, t_site_clock_in sc where s.id = sc.site_id |
|
|
|
<if test="siteName != null and siteName != ''"> |
|
|
|
and s.site_name = #{siteName} |
|
|
|
</if> |
|
|
|
<if test="startTime != null"> |
|
|
|
and sc.out_time >= #{startTime} |
|
|
|
</if> |
|
|
|
<if test="endTime != null"> |
|
|
|
and sc.out_time <= #{endTime} |
|
|
|
</if> |
|
|
|
group by FROM_UNIXTIME(sc.out_time/1000,'%Y-%m-%d %H') |
|
|
|
</sql> |
|
|
|
|
|
|
|
<select id="getRealTimeStatistics" resultType="com.ccsens.health.bean.vo.ClockVo$RealTimeStatistics"> |
|
|
|
|
|
|
|
select t1.time as time, t1.inCount as inCount, t2.outCount as outCount from |
|
|
|
( |
|
|
|
<include refid="t1" /> |
|
|
|
) t1 |
|
|
|
left join |
|
|
|
( |
|
|
|
<include refid="t2" /> |
|
|
|
) t2 |
|
|
|
on t1.time = t2.time |
|
|
|
union |
|
|
|
select t2.time, t1.inCount, t2.outCount from |
|
|
|
( |
|
|
|
<include refid="t1" /> |
|
|
|
) t1 |
|
|
|
right join |
|
|
|
( |
|
|
|
<include refid="t2" /> |
|
|
|
) t2 |
|
|
|
on t1.time = t2.time |
|
|
|
|
|
|
|
order by time |
|
|
|
</select> |
|
|
|
</mapper> |