WelcomeBedMapper.xml 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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.WelcomeBedMapper">
  4. <update id="updateData">
  5. UPDATE `welcome_bed`
  6. SET is_check = 0,
  7. student_card = NULL,
  8. card_num = NULL,
  9. `name` = NULL
  10. WHERE
  11. id = #{bedId}
  12. </update>
  13. <update id="updateBuild">
  14. UPDATE `welcome_bed`
  15. SET
  16. build= #{build},
  17. school_id= #{schoolId},
  18. school= #{school}
  19. WHERE
  20. deleted=0
  21. AND build_id= #{buildId}
  22. </update>
  23. <select id="queryBedList" resultType="com.template.model.vo.BedInfosVo">
  24. select id,student_card,is_check,number,build,build_id,dormitory_id,dormitory from welcome_bed
  25. where dormitory_id in (
  26. SELECT dormitory_id FROM `welcome_bed`
  27. where student_card = #{studentCard} and deleted = 0)
  28. and deleted = 0
  29. order by number
  30. </select>
  31. <select id="getBedList" resultType="com.template.model.vo.BedDetailsVo">
  32. SELECT
  33. number,
  34. is_check as isCheck
  35. FROM
  36. welcome_bed
  37. WHERE
  38. deleted = 0
  39. AND school_id = #{schoolId}
  40. AND build_id = #{buildId}
  41. AND dormitory_id = #{dormitoryId}
  42. AND (student_card != #{studentCard} or student_card is NULL)
  43. </select>
  44. <select id="getBedDetailsVo" resultType="com.template.model.vo.BedDetailsVo">
  45. SELECT
  46. ws.picture,
  47. wb.card_num ascardNum,
  48. ws.`name`,
  49. ws.sex,
  50. ws.nationality,
  51. wo.`name` as college,
  52. wo2.`name` as major,
  53. wo3.`name` as classstr,
  54. ws.batch_value as batchValue,
  55. w.build,
  56. ws.exam_num as examNum,
  57. wd.dormitory,
  58. wb.student_card as studentCard,
  59. ws.address,
  60. ws.phone,
  61. wb.number,
  62. wb.is_check as isCheck
  63. FROM
  64. welcome_bed wb
  65. LEFT JOIN welcome_org wo ON wb.college_id = wo.id
  66. AND wo.deleted = 0
  67. LEFT JOIN welcome_org wo2 ON wb.major_id = wo2.id
  68. AND wo2.deleted = 0
  69. LEFT JOIN welcome_org wo3 ON wb.classstr_id = wo3.id
  70. AND wo3.deleted = 0
  71. LEFT JOIN welcome_build w ON wb.build_id = w.id
  72. AND w.deleted = 0
  73. LEFT JOIN welcome_dormitory wd ON wb.dormitory_id = wd.id
  74. AND wd.deleted = 0
  75. LEFT JOIN welcome_student ws ON wb.student_card = ws.card_id
  76. AND ws.deleted = 0
  77. WHERE
  78. wb.deleted = 0
  79. AND wb.school_id = #{schoolId}
  80. AND wb.build_id = #{buildId}
  81. AND wb.dormitory_id = #{dormitoryId}
  82. AND wb.student_card = #{studentCard}
  83. </select>
  84. <select id="isCheck" resultType="com.template.model.vo.WelcomeBedCheckVo">
  85. SELECT
  86. wb.is_check as isCheck,
  87. wb.school_id as schoolId,
  88. wb.build_id as buildId,
  89. wb.dormitory_id as dormitoryId,
  90. ws.school,
  91. w.build,
  92. wd.dormitory
  93. FROM
  94. `welcome_bed` wb
  95. LEFT JOIN welcome_school ws ON ws.id = wb.school_id
  96. AND ws.deleted = 0
  97. LEFT JOIN welcome_build w ON w.id = wb.build_id
  98. AND w.deleted = 0
  99. LEFT JOIN welcome_dormitory wd ON wd.id = wb.dormitory_id
  100. AND wd.deleted = 0
  101. WHERE
  102. wb.deleted =0
  103. AND wb.student_card= #{studentCard}
  104. </select>
  105. <resultMap type="com.template.model.vo.BedSqlTotalVo" id="queryBedSqlMap">
  106. <result property="totalData" column="totalData"/>
  107. <result property="totalBed" column="totalBed"/>
  108. <result property="college" column="college"/>
  109. <result property="sex" column="sex"/>
  110. <result property="build" column="build"/>
  111. <result property="dormitory" column="dormitory"/>
  112. </resultMap>
  113. <select id="queryBedSqlList" resultType="com.template.model.vo.BedSqlTotalVo" resultMap="queryBedSqlMap">
  114. -- select (select sum(1) as total from welcome_student where deleted = 0 and college = wb.college and iden_type = 1 and sex = wb.sex) as totalData,
  115. select 0 as totalData,
  116. SUM(1) as totalBed,college,sex,build,dormitory
  117. from welcome_bed wb
  118. where wb.deleted = 0 and wb.college is not null and wb.college != ''
  119. <if test="collegeId != null and collegeId != ''">
  120. and wb.college_id = #{collegeId}
  121. </if>
  122. <if test="sex != null and sex != ''">
  123. and wb.sex = #{sex}
  124. </if>
  125. group by wb.college,wb.sex,wb.build,wb.dormitory
  126. </select>
  127. <resultMap type="com.template.model.vo.SleepSqlTotalVo" id="queryTotalSqlMap">
  128. <result property="totalBed" column="totalBed"/>
  129. <result property="sleeper" column="sleeper"/>
  130. <result property="totalData" column="totalData"/>
  131. <result property="college" column="college"/>
  132. <result property="sex" column="sex"/>
  133. </resultMap>
  134. <select id="queryTotalSqlList" resultType="com.template.model.vo.SleepSqlTotalVo" resultMap="queryTotalSqlMap">
  135. select SUM(1) as totalBed,
  136. (select SUM(1) as total from welcome_bed where deleted = 0 and `name` is not null and name != '' and college = wb.college and sex = wb.sex) as sleeper,
  137. -- (select sum(1) as total from welcome_student where deleted = 0 and college = wb.college and iden_type = 1 and sex = wb.sex) as totalData,wb.college,wb.sex from welcome_bed wb
  138. 0 as totalData,wb.college,wb.sex from welcome_bed wb
  139. where wb.deleted = 0 and wb.college is not null
  140. <if test="collegeId != null and collegeId != ''">
  141. and wb.college_id = #{collegeId}
  142. </if>
  143. <if test="sex != null and sex != ''">
  144. and wb.sex = #{sex}
  145. </if>
  146. group by wb.college,wb.sex
  147. </select>
  148. <select id="queryPageWelcomeBedsC" resultType="com.template.model.pojo.WelcomeBed">
  149. SELECT
  150. wb.*
  151. FROM
  152. `welcome_bed` wb
  153. WHERE
  154. wb.deleted =0
  155. <if test="schoolId != null and schoolId != ''">
  156. and wb.school_id = #{schoolId}
  157. </if>
  158. <if test="buildId != null and buildId != ''">
  159. and wb.build_id = #{buildId}
  160. </if>
  161. <if test="dormitoryId != null and dormitoryId != ''">
  162. and wb.dormitory_id = #{dormitoryId}
  163. </if>
  164. <if test="sex != null and sex != ''">
  165. and wb.sex = #{sex}
  166. </if>
  167. <if test="isCheck != null">
  168. and wb.is_check = #{isCheck}
  169. </if>
  170. <if test="majorId != null and majorId != ''">
  171. and wb.major_id = #{majorId}
  172. </if>
  173. <if test="classstrId != null and classstrId != ''">
  174. and wb.classstr_id = #{classstrId}
  175. </if>
  176. <if test="retentionState != null and retentionState != ''">
  177. and wb.retention_state = #{retentionState}
  178. </if>
  179. AND FIND_IN_SET(wb.college_id,#{collegeIds})
  180. order by LPAD(wb.build, 20, '0'),wb.dormitory,wb.number asc
  181. </select>
  182. <select id="queryPageWelcomeBeds" resultType="com.template.model.pojo.WelcomeBed">
  183. SELECT
  184. wb.*
  185. FROM
  186. `welcome_bed` wb
  187. WHERE
  188. wb.deleted =0
  189. <if test="schoolId != null and schoolId != ''">
  190. and wb.school_id = #{schoolId}
  191. </if>
  192. <if test="buildId != null and buildId != ''">
  193. and wb.build_id = #{buildId}
  194. </if>
  195. <if test="dormitoryId != null and dormitoryId != ''">
  196. and wb.dormitory_id = #{dormitoryId}
  197. </if>
  198. <if test="sex != null and sex != ''">
  199. and wb.sex = #{sex}
  200. </if>
  201. <if test="isCheck != null ">
  202. and wb.is_check = #{isCheck}
  203. </if>
  204. <if test="collegeId != null and collegeId != ''">
  205. and wb.college_id = #{collegeId}
  206. </if>
  207. <if test="majorId != null and majorId != ''">
  208. and wb.major_id = #{majorId}
  209. </if>
  210. <if test="classstrId != null and classstrId != ''">
  211. and wb.classstr_id = #{classstrId}
  212. </if>
  213. <if test="retentionState != null and retentionState != ''">
  214. and wb.retention_state = #{retentionState}
  215. </if>
  216. order by LPAD(wb.build, 20, '0'),wb.dormitory,wb.number asc
  217. </select>
  218. </mapper>