PersonDeviceLog.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  4. <!-- namespace必须指向DAO接口 -->
  5. <mapper namespace="com.jpsoft.smart.modules.base.dao.PersonDeviceLogDAO">
  6. <sql id="Base_Column_List">
  7. device_no,
  8. person_id,
  9. person_name,
  10. id_,
  11. identity_no,
  12. create_by,
  13. create_time,
  14. update_by,
  15. update_time,
  16. is_effective,
  17. del_flag,
  18. device_no,
  19. person_id,
  20. temperature_,
  21. match_status,
  22. match_msg,
  23. match_face_id,
  24. face_image,
  25. record_time
  26. </sql>
  27. <delete id="delete">
  28. delete from base_person_device_log where id_=#{0}
  29. </delete>
  30. <resultMap id="SimpleMap" type="com.jpsoft.smart.modules.base.entity.PersonDeviceLog">
  31. <id property="id" column="id_" />
  32. <result property="createBy" column="create_by" />
  33. <result property="createTime" column="create_time" />
  34. <result property="updateBy" column="update_by" />
  35. <result property="updateTime" column="update_time" />
  36. <result property="isEffective" column="is_effective" />
  37. <result property="delFlag" column="del_flag" />
  38. <result property="deviceNo" column="device_no" />
  39. <result property="personId" column="person_id" />
  40. <result property="personName" column="person_name"/>
  41. <result property="temperature" column="temperature_" />
  42. <result property="identityNo" column="identity_no"/>
  43. <result property="matchStatus" column="match_status" />
  44. <result property="matchMsg" column="match_msg" />
  45. <result property="matchFaceId" column="match_face_id" />
  46. <result property="faceImage" column="face_image" />
  47. <result property="recordTime" column="record_time" />
  48. </resultMap>
  49. <resultMap id="PersonDeviceLogMap" extends="SimpleMap" type="com.jpsoft.smart.modules.base.entity.PersonDeviceLog">
  50. <association property="device" column="device_no"
  51. select="com.jpsoft.smart.modules.base.dao.DeviceInfoDAO.getByDeviceNo"></association>
  52. <association property="person" column="person_id"
  53. select="com.jpsoft.smart.modules.base.dao.PersonInfoDAO.get"></association>
  54. </resultMap>
  55. <insert id="insert" parameterType="com.jpsoft.smart.modules.base.entity.PersonDeviceLog">
  56. <!--
  57. <selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
  58. select sys_guid() from dual
  59. </selectKey>
  60. -->
  61. <![CDATA[
  62. insert into base_person_device_log
  63. (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)
  64. values
  65. (
  66. #{id,jdbcType=VARCHAR}
  67. ,#{createBy,jdbcType=VARCHAR}
  68. ,#{createTime,jdbcType= TIMESTAMP }
  69. ,#{updateBy,jdbcType=VARCHAR}
  70. ,#{updateTime,jdbcType= TIMESTAMP }
  71. ,#{isEffective,jdbcType= NUMERIC }
  72. ,#{delFlag,jdbcType= NUMERIC }
  73. ,#{deviceNo,jdbcType=VARCHAR}
  74. ,#{personId,jdbcType=VARCHAR}
  75. ,#{personName,jdbcType=VARCHAR}
  76. ,#{temperature,jdbcType=NUMERIC}
  77. ,#{identityNo,jdbcType=VARCHAR}
  78. ,#{matchStatus,jdbcType=INTEGER}
  79. ,#{matchMsg,jdbcType=VARCHAR}
  80. ,#{matchFaceId,jdbcType= INTEGER}
  81. ,#{faceImage,jdbcType=VARCHAR}
  82. ,#{recordTime,jdbcType=TIMESTAMP}
  83. )
  84. ]]>
  85. </insert>
  86. <select id="simpleSearch" parameterType="hashmap" resultMap="SimpleMap">
  87. select * from base_person_device_log a
  88. <where>
  89. and a.del_flag = false
  90. <if test="searchParams.personId != null">
  91. and a.person_id = #{searchParams.personId}
  92. </if>
  93. <if test="searchParams.beginTime != null">
  94. <![CDATA[
  95. and a.record_time >= #{searchParams.beginTime}
  96. ]]>
  97. </if>
  98. <if test="searchParams.endTime != null">
  99. <![CDATA[
  100. and a.record_time <= #{searchParams.endTime}
  101. ]]>
  102. </if>
  103. </where>
  104. </select>
  105. <select id="findByPersonAndDate" resultMap="SimpleMap">
  106. select * from base_person_device_log where person_id = #{personId}
  107. and del_flag=false
  108. <![CDATA[
  109. and record_time >= #{startDate} and record_time <= #{endDate}
  110. ]]>
  111. order by record_time asc
  112. </select>
  113. <select id="search" parameterType="hashmap" resultMap="PersonDeviceLogMap">
  114. <![CDATA[
  115. select a.* from base_person_device_log a left join base_device_info b
  116. on a.device_no = b.device_no left join base_person_info c
  117. on a.person_id = c.id_
  118. ]]>
  119. <where>
  120. and a.del_flag = false
  121. <if test="searchParams.deviceIdList != null">
  122. and b.id_ in
  123. <foreach item="item" collection="searchParams.deviceIdList" open="(" separator="," close=")">
  124. #{item}
  125. </foreach>
  126. </if>
  127. <if test="searchParams.companyCode != null">
  128. and exists (
  129. select t1.id_ from base_person_info t1,base_company_info t2
  130. where t1.company_id =t2.id_
  131. and t2.code_ like #{searchParams.companyCode}
  132. and t1.del_flag=0 and t1.id_ = a.person_id
  133. )
  134. </if>
  135. <if test="searchParams.personId != null">
  136. and a.person_id = #{searchParams.personId}
  137. </if>
  138. <if test="searchParams.deviceNo != null">
  139. and a.device_no like #{searchParams.deviceNo}
  140. </if>
  141. <if test="searchParams.aliasName != null">
  142. and b.alias_name like #{searchParams.aliasName}
  143. </if>
  144. <if test="searchParams.personName != null">
  145. and c.name_ like #{searchParams.personName}
  146. </if>
  147. <if test="searchParams.matchStatus != null">
  148. and a.match_status = #{searchParams.matchStatus}
  149. </if>
  150. <if test="searchParams.beginTime != null">
  151. <![CDATA[
  152. and a.record_time >= #{searchParams.beginTime}
  153. ]]>
  154. </if>
  155. <if test="searchParams.endTime != null">
  156. <![CDATA[
  157. and a.record_time <= #{searchParams.endTime}
  158. ]]>
  159. </if>
  160. <if test="searchParams.minTemperature != null">
  161. <![CDATA[
  162. and a.temperature_ >= #{searchParams.minTemperature}
  163. ]]>
  164. </if>
  165. <if test="searchParams.maxTempedistinctrature != null">
  166. <![CDATA[
  167. and a.temperature_ <= #{searchParams.maxTemperature}
  168. ]]>
  169. </if>
  170. <if test="searchParams.matchMsg != null">
  171. and a.match_msg like #{searchParams.matchMsg}
  172. </if>
  173. <if test="searchParams.distinct">
  174. and a.rownum_ in (
  175. SELECT max(rownum_)
  176. from base_person_device_log
  177. <where>
  178. del_flag=0
  179. <if test="searchParams.beginTime != null">
  180. <![CDATA[
  181. and record_time >= #{searchParams.beginTime}
  182. ]]>
  183. </if>
  184. <if test="searchParams.endTime != null">
  185. <![CDATA[
  186. and record_time <= #{searchParams.endTime}
  187. ]]>
  188. </if>
  189. </where>
  190. GROUP BY person_id
  191. )
  192. </if>
  193. </where>
  194. <foreach item="sort" collection="sortList" open="order by" separator=",">
  195. ${sort.name} ${sort.order}
  196. </foreach>
  197. </select>
  198. <select id="get" resultMap="SimpleMap">
  199. select * from base_person_device_log where id_=#{0}
  200. </select>
  201. <select id="queryUnAttendanceList" resultMap="com.jpsoft.smart.modules.base.dao.PersonInfoDAO.PersonInfoMap">
  202. <![CDATA[
  203. select a.*,b.name_ as company_name
  204. from base_person_info a,base_company_info b
  205. where a.company_id=b.id_ and b.code_ like #{companyCode}
  206. and a.del_flag=0
  207. and a.id_ not in (
  208. select person_id from base_person_device_log
  209. where record_time>=#{startTime}
  210. and record_time <=#{endTime}
  211. )
  212. ]]>
  213. </select>
  214. <select id="queryAttendanceList" resultMap="com.jpsoft.smart.modules.base.dao.PersonInfoDAO.PersonInfoMap">
  215. <![CDATA[
  216. select a.*,b.name_ as company_name
  217. from base_person_info a,base_company_info b
  218. where a.company_id=b.id_
  219. and b.code_ like #{companyCode}
  220. and a.del_flag=0
  221. and a.id_ in (
  222. select c.person_id from base_person_device_log c
  223. where c.record_time>=#{startTime}
  224. and c.record_time<=#{endTime}
  225. and c.del_flag=0
  226. )
  227. ]]>
  228. </select>
  229. <select id="findLastPersonLog" resultMap="PersonDeviceLogMap">
  230. <![CDATA[
  231. select * from base_person_device_log
  232. where person_id=#{personId} and temperature_<=#{temperatureMax} and del_flag=0
  233. order by record_time desc
  234. limit 1
  235. ]]>
  236. </select>
  237. <select id="getDayCheckedVistorNumByDeviceNoList" resultType="Integer">
  238. <![CDATA[
  239. select count(*) from base_person_device_log where match_face_id = 0
  240. and record_time >=#{startTime}
  241. and record_time <= #{endTime}
  242. and temperature_ > 0
  243. ]]>
  244. <foreach collection="list" index="index" item="item" open="and device_no in(" separator="," close=")">
  245. #{item}
  246. </foreach>
  247. </select>
  248. <select id="findAllPersonLogByCompanyIdAndDeviceNo" resultMap="PersonDeviceLogMap">
  249. <![CDATA[
  250. select * from base_person_device_log
  251. where rownum_ in (
  252. SELECT max(m.rownum_)
  253. from base_person_device_log m inner join base_person_info n ON m.person_id = n.id_
  254. where m.record_time>=#{startTime}
  255. and m.record_time <=#{endTime}
  256. ]]>
  257. <foreach collection="companyList" index="index" item="item" open=" and n.company_id in (" separator="," close=")">
  258. #{item.id}
  259. </foreach>
  260. <![CDATA[
  261. and m.temperature_>0 GROUP BY m.person_id
  262. )
  263. ]]>
  264. union all
  265. <![CDATA[
  266. select * from base_person_device_log
  267. where person_id = 0
  268. and record_time >= #{startTime}
  269. and record_time <= #{endTime}
  270. and temperature_>0
  271. ]]>
  272. <foreach collection="deviceNoList" index="index" item="item" open="and device_no in(" separator="," close=")">
  273. #{item}
  274. </foreach>
  275. order by record_time desc
  276. </select>
  277. <select id="findLastPersonLogByCompanyList" resultMap="PersonDeviceLogMap">
  278. <![CDATA[
  279. select * from base_person_device_log
  280. where rownum_ in (
  281. SELECT max(m.rownum_)
  282. from base_person_device_log m inner join base_person_info n ON m.person_id = n.id_
  283. where m.record_time>=#{startTime}
  284. and m.record_time <=#{endTime}
  285. and n.guest_enabled is not true
  286. ]]>
  287. <foreach collection="companyList" index="index" item="item" open=" and n.company_id in (" separator="," close=")">
  288. #{item.id}
  289. </foreach>
  290. <![CDATA[
  291. and m.temperature_>0 GROUP BY m.person_id
  292. )
  293. ]]>
  294. order by record_time desc
  295. </select>
  296. <select id="findVisitorLogByDeviceNoList" resultMap="PersonDeviceLogMap">
  297. <![CDATA[
  298. select * from base_person_device_log
  299. where match_face_id = 0
  300. and record_time >= #{startTime}
  301. and record_time <= #{endTime}
  302. and temperature_>0
  303. ]]>
  304. <foreach collection="list" index="index" item="item" open="and device_no in(" separator="," close=")"> #{item}
  305. </foreach>
  306. ORDER BY record_time desc
  307. </select>
  308. <select id="findLastTeacherLogByCompanyList" resultMap="PersonDeviceLogMap">
  309. <![CDATA[
  310. select * from base_person_device_log
  311. where rownum_ in (
  312. SELECT max(m.rownum_)
  313. from base_person_device_log m inner join base_person_info n ON m.person_id = n.id_
  314. where m.record_time>=#{startTime}
  315. and m.record_time <=#{endTime}
  316. and n.popedom_ like '%2%'
  317. and n.guest_enabled is not true
  318. ]]>
  319. <foreach collection="list" index="index" item="item" open=" and n.company_id in (" separator="," close=")">
  320. #{item.id}
  321. </foreach>
  322. <![CDATA[
  323. and m.temperature_>0 GROUP BY m.person_id
  324. )
  325. ]]>
  326. order by record_time desc
  327. <!-- &lt;!&ndash; <![CDATA[-->
  328. <!-- SELECT * from-->
  329. <!-- (-->
  330. <!-- SELECT m.*,n.company_id as company_id,n.popedom_ as popedom_-->
  331. <!-- from base_person_device_log m LEFT JOIN base_person_info n-->
  332. <!-- ON m.person_id = n.id_-->
  333. <!-- where m.record_time>=#{startTime}-->
  334. <!-- and m.record_time <= #{endTime}-->
  335. <!-- and popedom_ like '%2%'-->
  336. <!-- and m.temperature_>0-->
  337. <!-- ]]>-->
  338. <!-- <foreach collection="list" index="index" item="item" open="and company_id in(" separator="," close=")">-->
  339. <!-- #{item.id}-->
  340. <!-- </foreach>-->
  341. <!-- ) a-->
  342. <!-- <![CDATA[-->
  343. <!-- where person_id<>0 and temperature_>0 GROUP BY a.person_id ORDER BY record_time desc-->
  344. <!-- ]]>&ndash;&gt;-->
  345. </select>
  346. <select id="findLastStudentLogByCompanyList" resultMap="PersonDeviceLogMap">
  347. <![CDATA[
  348. select * from base_person_device_log
  349. where rownum_ in (
  350. SELECT max(m.rownum_)
  351. from base_person_device_log m inner join base_person_info n ON m.person_id = n.id_
  352. where m.record_time>=#{startTime}
  353. and m.record_time <=#{endTime}
  354. and n.popedom_ = '1'
  355. and n.guest_enabled is not true
  356. ]]>
  357. <foreach collection="list" index="index" item="item" open=" and n.company_id in (" separator="," close=")">
  358. #{item.id}
  359. </foreach>
  360. <![CDATA[
  361. and m.temperature_>0 GROUP BY m.person_id
  362. )
  363. ]]>
  364. order by record_time desc
  365. <!--<![CDATA[
  366. SELECT * from
  367. (
  368. SELECT m.*,n.company_id as company_id,n.popedom_ as popedom_
  369. from base_person_device_log m LEFT JOIN base_person_info n
  370. ON m.person_id = n.id_
  371. where record_time>=#{startTime}
  372. and record_time <= #{endTime}
  373. and popedom_ = '1'
  374. ]]>
  375. <foreach collection="list" index="index" item="item" open="and company_id in(" separator="," close=")"> #{item.id}
  376. </foreach>
  377. <![CDATA[
  378. ) a
  379. where person_id <> 0 and temperature_>0 GROUP BY a.person_id ORDER BY record_time desc
  380. ]]>-->
  381. </select>
  382. <select id="getDayCheckedPersonNumByCompanyList" resultType="Integer">
  383. select count(*) from base_person_device_log a left join base_person_info b
  384. on a.person_id = b.id_
  385. where a.record_time >=#{startTime}
  386. and a.record_time &lt;= #{endTime}
  387. and b.guest_enabled is not true
  388. <foreach collection="list" index="index" item="item" open=" and b.company_id in (" separator="," close=")"> #{item.id}
  389. </foreach>
  390. and a.del_flag = 0
  391. <if test="popedom!=null">
  392. and b.popedom_ like #{popedom}
  393. </if>
  394. </select>
  395. <select id="findExpiredVisitorRecord" resultMap="PersonDeviceLogMap">
  396. <![CDATA[
  397. select * from base_person_device_log
  398. where datediff(now(),record_time)>1
  399. and person_id=0
  400. order by record_time asc limit ${limit}
  401. ]]>
  402. </select>
  403. <select id="countByAttendance" resultType="long">
  404. <![CDATA[
  405. select count(distinct(c.person_id)) from base_person_info a,base_company_info b,base_person_device_log c
  406. where a.company_id=b.id_
  407. and a.id_=c.person_id
  408. and b.code_ like #{companyCode}
  409. and a.del_flag=0
  410. and c.record_time>=#{beginDate}
  411. and c.record_time<=#{endDate}
  412. and c.del_flag=0
  413. ]]>
  414. </select>
  415. </mapper>