SmartVisitorMapper.xml 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.template.mapper.SmartVisitorMapper">
  4. <resultMap type="com.template.model.vo.VisitorPageVo" id="visitorPageMap">
  5. <result property="id" column="id"/>
  6. <result property="userId" column="user_id"/>
  7. <result property="userName" column="user_name"/>
  8. <result property="userPhone" column="user_phone"/>
  9. <result property="userNumber" column="user_number"/>
  10. <result property="peerNum" column="peer_num"/>
  11. <result property="carNum" column="car_num"/>
  12. <result property="visitReason" column="visit_reason"/>
  13. <result property="statu" column="statu"/>
  14. <result property="visitorTime" column="visitor_time"/>
  15. <result property="visitorDeadline" column="visitor_deadline"/>
  16. <result property="respondent" column="respondent"/>
  17. <result property="responcode" column="responcode"/>
  18. <result property="departmentId" column="department_id"/>
  19. <result property="respondentPhone" column="respondent_phone"/>
  20. <result property="respondentName" column="respondent_name"/>
  21. <result property="visitorType" column="visitor_type"/>
  22. <result property="createTime" column="create_time"/>
  23. </resultMap>
  24. <select id="queryVisitorPage" resultType="com.template.model.vo.VisitorPageVo" resultMap="visitorPageMap">
  25. select
  26. sv.id,sv.user_id,sv.user_name,sv.user_phone,sv.user_number,sv.peer_num,sv.car_num,sv.visit_reason,sv.statu,sv.visitor_time,sv.visitor_deadline,sv.respondent,
  27. sv.responcode,sv.department_id,sv.respondent_phone,sv.respondent_name,sv.visitor_type,sv.create_time,sv.image from
  28. smart_visitor sv
  29. inner join smart_user su on su.deleted = 0 and sv.user_id = su.id
  30. where sv.deleted = 0
  31. <if test="userId != null and userId != ''">
  32. and sv.user_id = #{userId}
  33. </if>
  34. <if test="createStartTime != null and createStartTime != '' and createEndTime != null and createEndTime != ''">
  35. and sv.create_time &gt;= #{createStartTime} and sv.create_time &lt;= #{createEndTime}
  36. </if>
  37. <if test="keyWord != null and keyWord != ''">
  38. and (sv.user_name like '%' #{keyWord} '%' or sv.user_phone like '%' #{keyWord} '%' or sv.respondent_name
  39. like '%' #{keyWord} '%'
  40. or sv.department_id in (select id from smart_department where deleted = 0 and name like '%' #{keyWord} '%')
  41. or sv.respondent_phone like '%' #{keyWord} '%' or sv.car_num like '%' #{keyWord} '%')
  42. </if>
  43. <if test="visitorStartTime != null and visitorStartTime != '' and visitorEndTime != null and visitorEndTime != ''">
  44. and sv.visitor_time &gt;= #{visitorStartTime} and sv.visitor_time &lt;= #{visitorEndTime}
  45. </if>
  46. <if test="statu != null and statu != ''">
  47. and sv.statu = #{statu}
  48. </if>
  49. order by sv.create_time desc
  50. </select>
  51. <select id="queryVisitorCount" resultType="java.lang.Integer">
  52. select Count(*) from smart_visitor
  53. where 1=1
  54. <if test="userId != null and userId != ''">
  55. and user_id = #{userId}
  56. </if>
  57. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  58. and (
  59. <if test="startTime != null and startTime != ''">
  60. (visitor_time &lt; #{startTime} and visitor_deadline &gt; #{startTime})
  61. </if>
  62. <if test="endTime != null and endTime != ''">
  63. or (visitor_time &lt; #{endTime} and visitor_deadline &gt; #{endTime})
  64. </if>
  65. )
  66. </if>
  67. and deleted = 0 and statu != 2 and statu != 9
  68. </select>
  69. <resultMap type="com.template.model.pojo.SmartVisitor" id="visitorDatasMap">
  70. <result property="id" column="id"/>
  71. <result property="userId" column="user_id"/>
  72. <result property="userName" column="user_name"/>
  73. <result property="userPhone" column="user_phone"/>
  74. <result property="userNumber" column="user_number"/>
  75. <result property="peerNum" column="peer_num"/>
  76. <result property="carNum" column="car_num"/>
  77. <result property="visitReason" column="visit_reason"/>
  78. <result property="statu" column="statu"/>
  79. <result property="visitorTime" column="visitor_time"/>
  80. <result property="visitorDeadline" column="visitor_deadline"/>
  81. <result property="respondent" column="respondent"/>
  82. <result property="responcode" column="responcode"/>
  83. <result property="departmentId" column="department_id"/>
  84. <result property="respondentPhone" column="respondent_phone"/>
  85. <result property="respondentName" column="respondent_name"/>
  86. <result property="visitorType" column="visitor_type"/>
  87. </resultMap>
  88. <select id="queryVisitorPageDatas" resultType="com.template.model.pojo.SmartVisitor" resultMap="visitorPageMap">
  89. select * from smart_visitor
  90. where deleted = 0
  91. <if test="type != null and type != ''">
  92. and statu = #{type}
  93. </if>
  94. and (
  95. <if test="studentIds != null and studentIds.size() > 0">
  96. (respondent in
  97. <foreach collection="studentIds" item="studentId" index="index" open="(" close=")" separator=",">
  98. ${studentId}
  99. </foreach>
  100. and visitor_type = 1)
  101. </if>
  102. <if test="isAdmin != null and isAdmin != ''">
  103. ${isAdmin}
  104. </if>
  105. )
  106. order by create_time desc
  107. </select>
  108. <select id="getPage" resultType="com.template.model.vo.SmartVisitorPageVo">
  109. SELECT
  110. sv.id,sv.user_id,sv.user_name,sv.user_phone,sv.user_number,sv.peer_num,sv.car_num,sv.visit_reason,sv.statu,sv.visitor_time,sv.visitor_deadline,sv.respondent,
  111. sv.responcode,sv.department_id,sv.respondent_phone,sv.respondent_name,sv.visitor_type,sv.create_time,sv.image,sv.source,
  112. sd.name as departmentName
  113. FROM
  114. `smart_visitor` sv
  115. left join smart_department sd on sv.department_id=sd.id
  116. WHERE sv.deleted=0 and sv.visitor_type=#{type}
  117. <if test="status != null and status != ''">
  118. and sv.statu = #{status}
  119. </if>
  120. <if test="keyWord != null and keyWord != ''">
  121. and (sv.user_name like '%' #{keyWord} '%' or sv.user_phone like '%' #{keyWord} '%' or sv.respondent_name
  122. like '%' #{keyWord} '%'
  123. or sv.department_id in (select id from smart_department where deleted = 0 and name like '%' #{keyWord} '%')
  124. or sv.respondent_phone like '%' #{keyWord} '%' or sv.car_num like '%' #{keyWord} '%')
  125. </if>
  126. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  127. and sv.create_time &gt;= #{startTime} and sv.create_time &lt;= #{endTime}
  128. </if>
  129. <if test="visitorStartTime != null and visitorStartTime != '' and visitorEndTime != null and visitorEndTime != ''">
  130. and sv.visitor_time &gt;= #{visitorStartTime} and sv.visitor_time &lt;= #{visitorEndTime}
  131. </if>
  132. order by sv.create_time desc
  133. </select>
  134. <select id="getScreenPage" resultType="com.template.model.vo.SmartVisitorScreenVo">
  135. SELECT
  136. sv.id,
  137. sv.visit_reason as visitReason,
  138. sv.image as image,
  139. sv.visitor_time as visitorTime,
  140. su.`name` as studentName,
  141. su.card_no as cardNo,
  142. sc.`name` as className,
  143. sv.statu as statu
  144. FROM
  145. `smart_visitor` sv
  146. LEFT JOIN smart_user su ON sv.respondent = su.id
  147. LEFT JOIN smart_class sc ON su.school_class = sc.id
  148. WHERE
  149. sv.deleted = 0
  150. AND sv.visitor_type =1
  151. <if test="status != null and status != ''">
  152. and sv.statu = #{status}
  153. </if>
  154. <if test="phone != null and phone != ''">
  155. and sv.user_phone = #{phone}
  156. </if>
  157. order by sv.visitor_time desc
  158. </select>
  159. <select id="parentsScreenPage" resultType="com.template.model.vo.SmartVisitorScreenVo">
  160. SELECT
  161. sv.id,
  162. sv.visit_reason as visitReason,
  163. sv.image as image,
  164. sv.visitor_time as visitorTime,
  165. su.`name` as studentName,
  166. su.card_no as cardNo,
  167. sc.`name` as className,
  168. sv.statu as statu
  169. FROM
  170. `smart_visitor` sv
  171. LEFT JOIN smart_user su ON sv.respondent = su.id
  172. LEFT JOIN smart_class sc ON su.school_class = sc.id
  173. WHERE
  174. sv.deleted = 0
  175. AND sv.visitor_type =1 and sv.user_id= #{userId}
  176. <if test="status != null and status != ''">
  177. and sv.statu = #{status}
  178. </if>
  179. order by sv.visitor_time desc
  180. </select>
  181. </mapper>