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

<?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
6 years ago
where rec_status = 0
<if test="parentCode != null and parentCode != ''">
6 years ago
and parent_code = #{parentCode, jdbcType=VARCHAR}
</if>
6 years ago
<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>
6 years ago
<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 &lt;= #{time} and c.out_time &gt;= #{time}
</if>
where
s.rec_status = 0
<if test="siteName != null and siteName != ''">
6 years ago
and site_name like concat('%',#{siteName, jdbcType=VARCHAR},'%')
6 years ago
</if>
GROUP BY s.id
</select>
<select id="selectSiteMemberList" resultType="com.ccsens.health.bean.vo.ClockVo$SiteMemberList">
SELECT
c.id as id,
6 years ago
s.site_name as siteName,
6 years ago
m.name as name,
m.wkno as wkno,
m.department as department,
c.time as inTime,
c.out_time as outTime,
6 years ago
a.user_id as userId
6 years ago
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 != ''">
6 years ago
and s.site_name like concat('%',#{siteName},'%')
6 years ago
</if>
<if test="name != null and name != ''">
6 years ago
and m.`name` like concat('%',#{name},'%')
6 years ago
</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 &lt;= #{endTime}
</if>
<if test="startTime != null">
and c.out_time &gt;= #{startTime}
</if>
ORDER BY c.time DESC
</select>
<sql id="t1">
6 years ago
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
6 years ago
<if test="siteName != null and siteName != ''">
and s.site_name = #{siteName}
</if>
<if test="startTime != null">
and sc.time &gt;= #{startTime}
</if>
<if test="endTime != null">
and sc.time &lt;= #{endTime}
</if>
6 years ago
group by FROM_UNIXTIME(sc.time/1000,#{precision})
6 years ago
</sql>
<sql id="t2">
6 years ago
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
6 years ago
<if test="siteName != null and siteName != ''">
and s.site_name = #{siteName}
</if>
<if test="startTime != null">
and sc.out_time &gt;= #{startTime}
</if>
<if test="endTime != null">
and sc.out_time &lt;= #{endTime}
</if>
6 years ago
group by FROM_UNIXTIME(sc.out_time/1000,#{precision})
6 years ago
</sql>
6 years ago
<select id="getRealTimeStatistics" resultType="com.ccsens.health.bean.vo.ClockVo$StatisticsCount" parameterType="java.util.Map">
6 years ago
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
6 years ago
order by time DESC
6 years ago
</select>
</mapper>