WelcomeStudentMapper.xml 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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.WelcomeStudentMapper">
  4. <resultMap type="com.template.model.vo.StudentPageVo" id="studentPageMap">
  5. <result property="id" column="id"/>
  6. <result property="sex" column="sex"/>
  7. <result property="admissNum" column="admiss_num"/>
  8. <result property="name" column="name"/>
  9. <result property="cardId" column="card_id"/>
  10. <result property="college" column="college"/>
  11. <result property="major" column="major"/>
  12. <result property="classstr" column="classstr"/>
  13. <result property="trafficMethod" column="traffic_method"/>
  14. <result property="arrive" column="arrive"/>
  15. <result property="accompanyNum" column="accompanyNum"/>
  16. <result property="fillStatus" column="fill_status"/>
  17. <result property="amountPayable" column="amount_payable"/>
  18. <result property="payAmount" column="pay_amount"/>
  19. <result property="dormitory" column="dormitory"/>
  20. <result property="isRegistered" column="isRegistered"/>
  21. <result property="carNumber" column="carNumber"/>
  22. <result property="phone" column="phone"/>
  23. <result property="familyName" column="familyName"/>
  24. <result property="familyPhone" column="familyPhone"/>
  25. <result property="arrvieDate" column="arrvieDate"/>
  26. <result property="isPay" column="is_pay"/>
  27. <result property="collegeId" column="college_id"/>
  28. <result property="majorId" column="major_id"/>
  29. <result property="batchValue" column="batch_value"/>
  30. <result property="remark" column="remark"/>
  31. </resultMap>
  32. <select id="queryStudentPageList" resultType="com.template.model.vo.StudentPageVo" resultMap="studentPageMap">
  33. select (select count(id) from welcome_accompany where student_card = ws.card_id and deleted = 0) as accompanyNum,
  34. ws.id,ws.admiss_num,ws.name,ws.card_id,ws.college,ws.major,ws.classstr,
  35. ws.traffic_method,ws.arrive,ws.amount_payable,ws.pay_amount,ws.fill_status,
  36. CONCAT(wsd.build, '-', wsd.dormitory, '-', wsd.number) as dormitory,ws.sex,ws.is_registered as isRegistered,wv.car_number as carNumber,ws.phone,wf.`name` as familyName,
  37. wf.phone as familyPhone,ws.arrvie_date as arrvieDate,ws.is_pay,ws.college_id,ws.major_id,ws.batch_value,ws.remark
  38. from welcome_student ws
  39. left join welcome_bed wsd on wsd.deleted =0 and wsd.student_card = ws.card_id
  40. left join welcome_visitor wv on wv.deleted =0 and wv.student_card = ws.card_id
  41. left join (SELECT
  42. f.*
  43. FROM
  44. welcome_family f
  45. WHERE f.deleted=0
  46. GROUP BY
  47. f.student_card ) wf ON wf.deleted = 0
  48. AND wf.student_card = ws.card_id
  49. where ws.deleted = 0
  50. <if test="collegeIds != null and collegeIds.size() > 0">
  51. and ws.college_id in
  52. <foreach collection="collegeIds" item="collegeId" index="index" open="(" close=")" separator=",">
  53. ${collegeId}
  54. </foreach>
  55. </if>
  56. <if test="majorId != null and majorId != ''">
  57. and ws.major_id = #{majorId}
  58. </if>
  59. <if test="classstrId != null and classstrId != ''">
  60. and ws.classstr_id = #{classstrId}
  61. </if>
  62. <if test="trafficMethod != null and trafficMethod != ''">
  63. and ws.traffic_method = #{trafficMethod}
  64. </if>
  65. <if test="name != null and name != ''">
  66. and ws.name like '%' #{name} '%'
  67. </if>
  68. <if test="fillStatus != null and fillStatus != ''">
  69. and ws.fill_status = #{fillStatus}
  70. </if>
  71. <if test="isRegistered != null and isRegistered != ''">
  72. <if test="isRegistered == 1">
  73. and ws.is_registered = #{isRegistered}
  74. </if>
  75. <if test="isRegistered == 2">
  76. and (ws.is_registered =2 or ws.is_registered is NULL)
  77. </if>
  78. </if>
  79. <if test="isPay != null">
  80. and ws.is_pay = #{isPay}
  81. </if>
  82. <if test="isCheck != null">
  83. <if test="isCheck == 1">
  84. and wsd.is_check = #{isCheck}
  85. </if>
  86. <if test="isCheck == 0">
  87. and wsd.is_check is null
  88. </if>
  89. </if>
  90. <if test="school != null and school != ''">
  91. and ws.school = #{school}
  92. </if>
  93. <if test="batchValue != null and batchValue != ''">
  94. and ws.batch_value = #{batchValue}
  95. </if>
  96. <if test="carNumber != null">
  97. <if test="carNumber == 1">
  98. and wv.car_number is not null
  99. </if>
  100. <if test="carNumber == 0">
  101. and wv.car_number is null
  102. </if>
  103. </if>
  104. and ws.iden_type != 2
  105. AND ws.create_time between #{startTime} and #{endTime}
  106. order by ws.update_time desc
  107. </select>
  108. <select id="studentRegister" resultType="com.template.model.vo.StudentRegisterVo">
  109. SELECT
  110. SUM(1) AS totalCount,
  111. SUM(CASE WHEN ws.is_registered = 1 THEN 1 ELSE 0 END) AS count,
  112. ROUND(
  113. SUM(CASE WHEN ws.is_registered = 1 THEN 1 ELSE 0 END) * 100.0 / NULLIF(SUM(1), 0),
  114. 2
  115. ) AS rate,
  116. wo.`name`
  117. FROM
  118. `welcome_student` ws
  119. LEFT JOIN welcome_org wo
  120. ON ws.college_id = wo.id AND wo.deleted = 0
  121. WHERE
  122. ws.deleted = 0
  123. AND ws.iden_type=1
  124. AND ws.create_time between #{startTime} and #{endTime}
  125. GROUP BY
  126. college_id
  127. </select>
  128. <select id="studentTraffic" resultType="com.template.model.vo.StudentTrafficVo">
  129. SELECT count(ws.id) AS count,
  130. ws.traffic_method as trafficMethod
  131. FROM
  132. `welcome_student` ws
  133. WHERE
  134. ws.deleted = 0
  135. AND ws.iden_type=1
  136. AND ws.fill_status = '已填报'
  137. <if test="collegeId != null">
  138. and ws.college_id = #{collegeId}
  139. </if>
  140. AND ws.create_time between #{startTime} and #{endTime}
  141. GROUP BY
  142. traffic_method
  143. </select>
  144. <select id="studentSexRatio" resultType="com.template.model.vo.StudentSexRatioVo">
  145. SELECT
  146. wo.`name` AS collegeName,
  147. new.count AS manCount,
  148. new2.count AS girlCount
  149. FROM
  150. `welcome_student` w
  151. LEFT JOIN (
  152. SELECT
  153. ws.college_id AS collegeId,
  154. count( ws.id ) AS count
  155. FROM
  156. `welcome_student` ws
  157. WHERE
  158. ws.deleted = 0
  159. AND ws.sex = '男'
  160. AND ws.iden_type = 1
  161. AND ws.fill_status = "已填报"
  162. AND ws.create_time between #{startTime} and #{endTime}
  163. GROUP BY
  164. college_id
  165. ) new ON w.college_id = new.collegeId
  166. LEFT JOIN (
  167. SELECT
  168. ws.college_id AS collegeId,
  169. count( ws.id ) AS count
  170. FROM
  171. `welcome_student` ws
  172. WHERE
  173. ws.deleted = 0
  174. AND ws.sex = '女'
  175. AND ws.iden_type = 1
  176. AND ws.fill_status = "已填报"
  177. AND ws.create_time between #{startTime} and #{endTime}
  178. GROUP BY
  179. college_id
  180. ) new2 ON w.college_id = new2.collegeId
  181. LEFT JOIN welcome_org wo ON w.college_id = wo.id
  182. AND wo.deleted = 0
  183. WHERE
  184. w.deleted = 0
  185. AND w.iden_type = 1
  186. AND w.fill_status = "已填报"
  187. GROUP BY
  188. w.college_id
  189. </select>
  190. <resultMap type="com.template.model.vo.StudentTotalVo" id="queryStudentTotalMap">
  191. <result property="total" column="total"/>
  192. <result property="college" column="college"/>
  193. <result property="sex" column="sex"/>
  194. </resultMap>
  195. <select id="queryStudentTotal" resultType="com.template.model.vo.StudentTotalVo" resultMap="queryStudentTotalMap">
  196. select sum(1) as total,college,sex from welcome_student
  197. where deleted = 0 and iden_type = 1
  198. AND create_time between #{startTime} and #{endTime}
  199. group by college,sex
  200. </select>
  201. <select id="studentMajorRegister" resultType="com.template.model.vo.StudentRegisterVo">
  202. SELECT
  203. SUM(1) AS totalCount,
  204. SUM(CASE WHEN ws.is_registered = 1 THEN 1 ELSE 0 END) AS count,
  205. ROUND(
  206. SUM(CASE WHEN ws.is_registered = 1 THEN 1 ELSE 0 END) * 100.0 / NULLIF(SUM(1), 0),
  207. 2
  208. ) AS rate,
  209. wo.`name`
  210. FROM
  211. `welcome_student` ws
  212. LEFT JOIN welcome_org wo
  213. ON ws.major_id = wo.id AND wo.deleted = 0
  214. WHERE
  215. ws.deleted = 0
  216. AND ws.iden_type=1
  217. AND ws.college_id= #{collegeId}
  218. AND ws.create_time between #{startTime} and #{endTime}
  219. GROUP BY
  220. ws.major_id
  221. </select>
  222. <select id="levelRegister" resultType="com.template.model.vo.StudentRegisterVo">
  223. SELECT count(ws.id) AS count,
  224. ws.batch_value as name
  225. FROM
  226. `welcome_student` ws
  227. LEFT JOIN welcome_org wo
  228. ON ws.college_id = wo.id AND wo.deleted = 0
  229. WHERE
  230. ws.deleted = 0
  231. AND ws.iden_type=1
  232. AND ws.is_registered = 1
  233. <if test="collegeId != null">
  234. and ws.college_id = #{collegeId}
  235. </if>
  236. AND ws.create_time between #{startTime} and #{endTime}
  237. GROUP BY
  238. ws.batch_value
  239. </select>
  240. </mapper>