You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
133 lines
4.7 KiB
133 lines
4.7 KiB
<?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.ccsens.health.persist.dao.SiteDao">
|
|
|
|
|
|
<select id="queryAll" resultType="com.ccsens.health.bean.vo.ClockVo$SiteList">
|
|
select t.id, t.site_name as siteName, t.site_code as siteCode, t.longitude, t.latitude, t1.qrcode_path as inUrl, t2.qrcode_path as outUrl
|
|
from
|
|
(select * from t_site
|
|
where rec_status = 0
|
|
<if test="parentCode != null and parentCode != ''">
|
|
and parent_code = #{parentCode, jdbcType=VARCHAR}
|
|
</if>
|
|
<if test="siteName != null and siteName != ''">
|
|
and site_name like concat('%',#{siteName, jdbcType=VARCHAR},'%')
|
|
</if>
|
|
) t
|
|
left join
|
|
(select * from t_site_qrcode where out_or_in = 0 ) t1
|
|
on t.id = t1.site_id
|
|
left join
|
|
(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 site_name like concat('%',#{siteName, jdbcType=VARCHAR},'%')
|
|
</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 siteName,
|
|
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
|
|
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
|
|
where
|
|
s. rec_status = 0
|
|
<if test="siteName != null and siteName != ''">
|
|
and s.site_name like concat('%',#{siteName},'%')
|
|
</if>
|
|
<if test="name != null and name != ''">
|
|
and m.`name` like concat('%',#{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,#{precision}) 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,#{precision})
|
|
</sql>
|
|
<sql id="t2">
|
|
select FROM_UNIXTIME(sc.out_time/1000,#{precision}) 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,#{precision})
|
|
</sql>
|
|
|
|
<select id="getRealTimeStatistics" resultType="com.ccsens.health.bean.vo.ClockVo$StatisticsCount" parameterType="java.util.Map">
|
|
|
|
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 DESC
|
|
</select>
|
|
</mapper>
|