WelcomeBedMapper.xml 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. <select id="queryBedList" resultType="com.template.model.vo.BedInfosVo">
  14. select id,student_card,is_check,number,build,build_id,dormitory_id,dormitory from welcome_bed
  15. where dormitory_id in (
  16. SELECT dormitory_id FROM `welcome_bed`
  17. where student_card = #{studentCard} and deleted = 0)
  18. and deleted = 0
  19. order by number
  20. </select>
  21. <select id="getBedList" resultType="com.template.model.vo.BedDetailsVo">
  22. SELECT
  23. number,
  24. is_check as isCheck
  25. FROM
  26. welcome_bed
  27. WHERE
  28. deleted = 0
  29. AND school_id = #{schoolId}
  30. AND build_id = #{buildId}
  31. AND dormitory_id = #{dormitoryId}
  32. AND (student_card != #{studentCard} or student_card is NULL)
  33. </select>
  34. <select id="getBedDetailsVo" resultType="com.template.model.vo.BedDetailsVo">
  35. SELECT
  36. ws.picture,
  37. wb.card_num ascardNum,
  38. ws.`name`,
  39. ws.sex,
  40. ws.nationality,
  41. wo.`name` as college,
  42. wo2.`name` as major,
  43. wo3.`name` as classstr,
  44. ws.batch_value as batchValue,
  45. w.build,
  46. ws.exam_num as examNum,
  47. wd.dormitory,
  48. wb.student_card as studentCard,
  49. ws.address,
  50. ws.phone,
  51. wb.number,
  52. wb.is_check as isCheck
  53. FROM
  54. welcome_bed wb
  55. LEFT JOIN welcome_org wo ON wb.college_id = wo.id
  56. AND wo.deleted = 0
  57. LEFT JOIN welcome_org wo2 ON wb.major_id = wo2.id
  58. AND wo2.deleted = 0
  59. LEFT JOIN welcome_org wo3 ON wb.classstr_id = wo3.id
  60. AND wo3.deleted = 0
  61. LEFT JOIN welcome_build w ON wb.build_id = w.id
  62. AND w.deleted = 0
  63. LEFT JOIN welcome_dormitory wd ON wb.dormitory_id = wd.id
  64. AND wd.deleted = 0
  65. LEFT JOIN welcome_student ws ON wb.student_card = ws.card_id
  66. AND ws.deleted = 0
  67. WHERE
  68. wb.deleted = 0
  69. AND wb.school_id = #{schoolId}
  70. AND wb.build_id = #{buildId}
  71. AND wb.dormitory_id = #{dormitoryId}
  72. AND wb.student_card = #{studentCard}
  73. </select>
  74. <select id="isCheck" resultType="com.template.model.vo.WelcomeBedCheckVo">
  75. SELECT
  76. wb.is_check as isCheck,
  77. wb.school_id as schoolId,
  78. wb.build_id as buildId,
  79. wb.dormitory_id as dormitoryId,
  80. ws.school,
  81. w.build,
  82. wd.dormitory
  83. FROM
  84. `welcome_bed` wb
  85. LEFT JOIN welcome_school ws ON ws.id = wb.school_id
  86. AND ws.deleted = 0
  87. LEFT JOIN welcome_build w ON w.id = wb.build_id
  88. AND w.deleted = 0
  89. LEFT JOIN welcome_dormitory wd ON wd.id = wb.dormitory_id
  90. AND wd.deleted = 0
  91. WHERE
  92. wb.deleted =0
  93. AND wb.student_card= #{studentCard}
  94. </select>
  95. <resultMap type="com.template.model.vo.BedSqlTotalVo" id="queryBedSqlMap">
  96. <result property="totalData" column="totalData"/>
  97. <result property="totalBed" column="totalBed"/>
  98. <result property="college" column="college"/>
  99. <result property="sex" column="sex"/>
  100. <result property="build" column="build"/>
  101. <result property="dormitory" column="dormitory"/>
  102. </resultMap>
  103. <select id="queryBedSqlList" resultType="com.template.model.vo.BedSqlTotalVo" resultMap="queryBedSqlMap">
  104. -- 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,
  105. select 0 as totalData,
  106. SUM(1) as totalBed,college,sex,build,dormitory
  107. from welcome_bed wb
  108. where wb.deleted = 0 and wb.college is not null and wb.college != ''
  109. <if test="collegeId != null and collegeId != ''">
  110. and wb.college_id = #{collegeId}
  111. </if>
  112. <if test="sex != null and sex != ''">
  113. and wb.sex = #{sex}
  114. </if>
  115. group by wb.college,wb.sex,wb.build,wb.dormitory
  116. </select>
  117. <resultMap type="com.template.model.vo.SleepSqlTotalVo" id="queryTotalSqlMap">
  118. <result property="totalBed" column="totalBed"/>
  119. <result property="sleeper" column="sleeper"/>
  120. <result property="totalData" column="totalData"/>
  121. <result property="college" column="college"/>
  122. <result property="sex" column="sex"/>
  123. </resultMap>
  124. <select id="queryTotalSqlList" resultType="com.template.model.vo.SleepSqlTotalVo" resultMap="queryTotalSqlMap">
  125. select SUM(1) as totalBed,
  126. (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,
  127. -- (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
  128. 0 as totalData,wb.college,wb.sex from welcome_bed wb
  129. where wb.deleted = 0 and wb.college is not null
  130. <if test="collegeId != null and collegeId != ''">
  131. and wb.college_id = #{collegeId}
  132. </if>
  133. <if test="sex != null and sex != ''">
  134. and wb.sex = #{sex}
  135. </if>
  136. group by wb.college,wb.sex
  137. </select>
  138. </mapper>