123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420 |
- <?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">
- <!-- namespace必须指向DAO接口 -->
- <mapper namespace="com.jpsoft.smart.modules.base.dao.PersonDeviceLogDAO">
- <sql id="Base_Column_List">
- device_no,
- person_id,
- person_name,
- id_,
- identity_no,
- create_by,
- create_time,
- update_by,
- update_time,
- is_effective,
- del_flag,
- device_no,
- person_id,
- temperature_,
- match_status,
- match_msg,
- match_face_id,
- face_image,
- record_time
- </sql>
- <delete id="delete">
- delete from base_person_device_log where id_=#{0}
- </delete>
- <resultMap id="SimpleMap" type="com.jpsoft.smart.modules.base.entity.PersonDeviceLog">
- <id property="id" column="id_" />
- <result property="createBy" column="create_by" />
- <result property="createTime" column="create_time" />
- <result property="updateBy" column="update_by" />
- <result property="updateTime" column="update_time" />
- <result property="isEffective" column="is_effective" />
- <result property="delFlag" column="del_flag" />
- <result property="deviceNo" column="device_no" />
- <result property="personId" column="person_id" />
- <result property="personName" column="person_name"/>
- <result property="temperature" column="temperature_" />
- <result property="identityNo" column="identity_no"/>
- <result property="matchStatus" column="match_status" />
- <result property="matchMsg" column="match_msg" />
- <result property="matchFaceId" column="match_face_id" />
- <result property="faceImage" column="face_image" />
- <result property="recordTime" column="record_time" />
- </resultMap>
- <resultMap id="PersonDeviceLogMap" extends="SimpleMap" type="com.jpsoft.smart.modules.base.entity.PersonDeviceLog">
- <association property="device" column="device_no"
- select="com.jpsoft.smart.modules.base.dao.DeviceInfoDAO.getByDeviceNo"></association>
- <association property="person" column="person_id"
- select="com.jpsoft.smart.modules.base.dao.PersonInfoDAO.get"></association>
- </resultMap>
- <insert id="insert" parameterType="com.jpsoft.smart.modules.base.entity.PersonDeviceLog">
- <!--
- <selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
- select sys_guid() from dual
- </selectKey>
- -->
- <![CDATA[
- insert into base_person_device_log
- (id_,create_by,create_time,update_by,update_time,is_effective,del_flag,device_no,person_id,person_name,temperature_,identity_no,match_status,match_msg,match_face_id,face_image,record_time)
- values
- (
- #{id,jdbcType=VARCHAR}
- ,#{createBy,jdbcType=VARCHAR}
- ,#{createTime,jdbcType= TIMESTAMP }
- ,#{updateBy,jdbcType=VARCHAR}
- ,#{updateTime,jdbcType= TIMESTAMP }
- ,#{isEffective,jdbcType= NUMERIC }
- ,#{delFlag,jdbcType= NUMERIC }
- ,#{deviceNo,jdbcType=VARCHAR}
- ,#{personId,jdbcType=VARCHAR}
- ,#{personName,jdbcType=VARCHAR}
- ,#{temperature,jdbcType=NUMERIC}
- ,#{identityNo,jdbcType=VARCHAR}
- ,#{matchStatus,jdbcType=INTEGER}
- ,#{matchMsg,jdbcType=VARCHAR}
- ,#{matchFaceId,jdbcType= INTEGER}
- ,#{faceImage,jdbcType=VARCHAR}
- ,#{recordTime,jdbcType=TIMESTAMP}
- )
- ]]>
- </insert>
- <select id="simpleSearch" parameterType="hashmap" resultMap="SimpleMap">
- select * from base_person_device_log a
- <where>
- and a.del_flag = false
- <if test="searchParams.personId != null">
- and a.person_id = #{searchParams.personId}
- </if>
- <if test="searchParams.beginTime != null">
- <![CDATA[
- and a.record_time >= #{searchParams.beginTime}
- ]]>
- </if>
- <if test="searchParams.endTime != null">
- <![CDATA[
- and a.record_time <= #{searchParams.endTime}
- ]]>
- </if>
- </where>
- </select>
- <select id="findByPersonAndDate" resultMap="SimpleMap">
- select * from base_person_device_log where person_id = #{personId}
- and del_flag=false
- <![CDATA[
- and record_time >= #{startDate} and record_time <= #{endDate}
- ]]>
- order by record_time asc
- </select>
- <select id="search" parameterType="hashmap" resultMap="PersonDeviceLogMap">
- <![CDATA[
- select a.* from base_person_device_log a left join base_device_info b
- on a.device_no = b.device_no left join base_person_info c
- on a.person_id = c.id_
- ]]>
- <where>
- and a.del_flag = false
- <if test="searchParams.deviceIdList != null">
- and b.id_ in
- <foreach item="item" collection="searchParams.deviceIdList" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="searchParams.companyCode != null">
- and exists (
- select t1.id_ from base_person_info t1,base_company_info t2
- where t1.company_id =t2.id_
- and t2.code_ like #{searchParams.companyCode}
- and t1.del_flag=0 and t1.id_ = a.person_id
- )
- </if>
- <if test="searchParams.personId != null">
- and a.person_id = #{searchParams.personId}
- </if>
- <if test="searchParams.deviceNo != null">
- and a.device_no like #{searchParams.deviceNo}
- </if>
- <if test="searchParams.aliasName != null">
- and b.alias_name like #{searchParams.aliasName}
- </if>
- <if test="searchParams.personName != null">
- and c.name_ like #{searchParams.personName}
- </if>
- <if test="searchParams.matchStatus != null">
- and a.match_status = #{searchParams.matchStatus}
- </if>
- <if test="searchParams.beginTime != null">
- <![CDATA[
- and a.record_time >= #{searchParams.beginTime}
- ]]>
- </if>
- <if test="searchParams.endTime != null">
- <![CDATA[
- and a.record_time <= #{searchParams.endTime}
- ]]>
- </if>
- <if test="searchParams.minTemperature != null">
- <![CDATA[
- and a.temperature_ >= #{searchParams.minTemperature}
- ]]>
- </if>
- <if test="searchParams.maxTempedistinctrature != null">
- <![CDATA[
- and a.temperature_ <= #{searchParams.maxTemperature}
- ]]>
- </if>
- <if test="searchParams.matchMsg != null">
- and a.match_msg like #{searchParams.matchMsg}
- </if>
- <if test="searchParams.distinct">
- and a.rownum_ in (
- SELECT max(rownum_)
- from base_person_device_log
- <where>
- del_flag=0
- <if test="searchParams.beginTime != null">
- <![CDATA[
- and record_time >= #{searchParams.beginTime}
- ]]>
- </if>
- <if test="searchParams.endTime != null">
- <![CDATA[
- and record_time <= #{searchParams.endTime}
- ]]>
- </if>
- </where>
- GROUP BY person_id
- )
- </if>
- </where>
- <foreach item="sort" collection="sortList" open="order by" separator=",">
- ${sort.name} ${sort.order}
- </foreach>
- </select>
- <select id="get" resultMap="SimpleMap">
- select * from base_person_device_log where id_=#{0}
- </select>
- <select id="queryUnAttendanceList" resultMap="com.jpsoft.smart.modules.base.dao.PersonInfoDAO.PersonInfoMap">
- <![CDATA[
- select a.*,b.name_ as company_name
- from base_person_info a,base_company_info b
- where a.company_id=b.id_ and b.code_ like #{companyCode}
- and a.del_flag=0
- and a.id_ not in (
- select person_id from base_person_device_log
- where record_time>=#{startTime}
- and record_time <=#{endTime}
- )
- ]]>
- </select>
- <select id="queryAttendanceList" resultMap="com.jpsoft.smart.modules.base.dao.PersonInfoDAO.PersonInfoMap">
- <![CDATA[
- select a.*,b.name_ as company_name
- from base_person_info a,base_company_info b
- where a.company_id=b.id_
- and b.code_ like #{companyCode}
- and a.del_flag=0
- and a.id_ in (
- select c.person_id from base_person_device_log c
- where c.record_time>=#{startTime}
- and c.record_time<=#{endTime}
- and c.del_flag=0
- )
- ]]>
- </select>
- <select id="findLastPersonLog" resultMap="PersonDeviceLogMap">
- <![CDATA[
- select * from base_person_device_log
- where person_id=#{personId} and temperature_<=#{temperatureMax} and del_flag=0
- order by record_time desc
- limit 1
- ]]>
- </select>
- <select id="getDayCheckedVistorNumByDeviceNoList" resultType="Integer">
- <![CDATA[
- select count(*) from base_person_device_log where match_face_id = 0
- and record_time >=#{startTime}
- and record_time <= #{endTime}
- and temperature_ > 0
- ]]>
- <foreach collection="list" index="index" item="item" open="and device_no in(" separator="," close=")">
- #{item}
- </foreach>
- </select>
- <select id="findAllPersonLogByCompanyIdAndDeviceNo" resultMap="PersonDeviceLogMap">
- <![CDATA[
- select * from base_person_device_log
- where rownum_ in (
- SELECT max(m.rownum_)
- from base_person_device_log m inner join base_person_info n ON m.person_id = n.id_
- where m.record_time>=#{startTime}
- and m.record_time <=#{endTime}
- ]]>
- <foreach collection="companyList" index="index" item="item" open=" and n.company_id in (" separator="," close=")">
- #{item.id}
- </foreach>
- <![CDATA[
- and m.temperature_>0 GROUP BY m.person_id
- )
- ]]>
- union all
- <![CDATA[
- select * from base_person_device_log
- where person_id = 0
- and record_time >= #{startTime}
- and record_time <= #{endTime}
- and temperature_>0
- ]]>
- <foreach collection="deviceNoList" index="index" item="item" open="and device_no in(" separator="," close=")">
- #{item}
- </foreach>
- order by record_time desc
- </select>
- <select id="findLastPersonLogByCompanyList" resultMap="PersonDeviceLogMap">
- <![CDATA[
- select * from base_person_device_log
- where rownum_ in (
- SELECT max(m.rownum_)
- from base_person_device_log m inner join base_person_info n ON m.person_id = n.id_
- where m.record_time>=#{startTime}
- and m.record_time <=#{endTime}
- and n.guest_enabled is not true
- ]]>
- <foreach collection="companyList" index="index" item="item" open=" and n.company_id in (" separator="," close=")">
- #{item.id}
- </foreach>
- <![CDATA[
- and m.temperature_>0 GROUP BY m.person_id
- )
- ]]>
- order by record_time desc
- </select>
- <select id="findVisitorLogByDeviceNoList" resultMap="PersonDeviceLogMap">
- <![CDATA[
- select * from base_person_device_log
- where match_face_id = 0
- and record_time >= #{startTime}
- and record_time <= #{endTime}
- and temperature_>0
- ]]>
- <foreach collection="list" index="index" item="item" open="and device_no in(" separator="," close=")"> #{item}
- </foreach>
- ORDER BY record_time desc
- </select>
- <select id="findLastTeacherLogByCompanyList" resultMap="PersonDeviceLogMap">
- <![CDATA[
- select * from base_person_device_log
- where rownum_ in (
- SELECT max(m.rownum_)
- from base_person_device_log m inner join base_person_info n ON m.person_id = n.id_
- where m.record_time>=#{startTime}
- and m.record_time <=#{endTime}
- and n.popedom_ like '%2%'
- and n.guest_enabled is not true
- ]]>
- <foreach collection="list" index="index" item="item" open=" and n.company_id in (" separator="," close=")">
- #{item.id}
- </foreach>
- <![CDATA[
- and m.temperature_>0 GROUP BY m.person_id
- )
- ]]>
- order by record_time desc
- <!-- <!– <![CDATA[-->
- <!-- SELECT * from-->
- <!-- (-->
- <!-- SELECT m.*,n.company_id as company_id,n.popedom_ as popedom_-->
- <!-- from base_person_device_log m LEFT JOIN base_person_info n-->
- <!-- ON m.person_id = n.id_-->
- <!-- where m.record_time>=#{startTime}-->
- <!-- and m.record_time <= #{endTime}-->
- <!-- and popedom_ like '%2%'-->
- <!-- and m.temperature_>0-->
- <!-- ]]>-->
- <!-- <foreach collection="list" index="index" item="item" open="and company_id in(" separator="," close=")">-->
- <!-- #{item.id}-->
- <!-- </foreach>-->
- <!-- ) a-->
- <!-- <![CDATA[-->
- <!-- where person_id<>0 and temperature_>0 GROUP BY a.person_id ORDER BY record_time desc-->
- <!-- ]]>–>-->
- </select>
- <select id="findLastStudentLogByCompanyList" resultMap="PersonDeviceLogMap">
- <![CDATA[
- select * from base_person_device_log
- where rownum_ in (
- SELECT max(m.rownum_)
- from base_person_device_log m inner join base_person_info n ON m.person_id = n.id_
- where m.record_time>=#{startTime}
- and m.record_time <=#{endTime}
- and n.popedom_ = '1'
- and n.guest_enabled is not true
- ]]>
- <foreach collection="list" index="index" item="item" open=" and n.company_id in (" separator="," close=")">
- #{item.id}
- </foreach>
- <![CDATA[
- and m.temperature_>0 GROUP BY m.person_id
- )
- ]]>
- order by record_time desc
- <!--<![CDATA[
- SELECT * from
- (
- SELECT m.*,n.company_id as company_id,n.popedom_ as popedom_
- from base_person_device_log m LEFT JOIN base_person_info n
- ON m.person_id = n.id_
- where record_time>=#{startTime}
- and record_time <= #{endTime}
- and popedom_ = '1'
- ]]>
- <foreach collection="list" index="index" item="item" open="and company_id in(" separator="," close=")"> #{item.id}
- </foreach>
- <![CDATA[
- ) a
- where person_id <> 0 and temperature_>0 GROUP BY a.person_id ORDER BY record_time desc
- ]]>-->
- </select>
- <select id="getDayCheckedPersonNumByCompanyList" resultType="Integer">
- select count(*) from base_person_device_log a left join base_person_info b
- on a.person_id = b.id_
- where a.record_time >=#{startTime}
- and a.record_time <= #{endTime}
- and b.guest_enabled is not true
- <foreach collection="list" index="index" item="item" open=" and b.company_id in (" separator="," close=")"> #{item.id}
- </foreach>
- and a.del_flag = 0
- <if test="popedom!=null">
- and b.popedom_ like #{popedom}
- </if>
- </select>
- <select id="findExpiredVisitorRecord" resultMap="PersonDeviceLogMap">
- <![CDATA[
- select * from base_person_device_log
- where datediff(now(),record_time)>1
- and person_id=0
- order by record_time asc limit ${limit}
- ]]>
- </select>
- <select id="countByAttendance" resultType="long">
- <![CDATA[
- select count(distinct(c.person_id)) from base_person_info a,base_company_info b,base_person_device_log c
- where a.company_id=b.id_
- and a.id_=c.person_id
- and b.code_ like #{companyCode}
- and a.del_flag=0
- and c.record_time>=#{beginDate}
- and c.record_time<=#{endDate}
- and c.del_flag=0
- ]]>
- </select>
- </mapper>
|