UnitServiceDaoImplMapper.xml 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="unitServiceDaoImpl">
  6. <!-- 保存小区单元信息 add by wuxw 2018-07-03 -->
  7. <insert id="saveBusinessUnitInfo" parameterType="Map">
  8. insert into business_building_unit(
  9. floor_id,operate,layer_count,unit_id,unit_num,lift,remark,b_id,user_id
  10. ) values (
  11. #{floorId},#{operate},#{layerCount},#{unitId},#{unitNum},#{lift},#{remark},#{bId},#{userId}
  12. )
  13. </insert>
  14. <!-- 查询小区单元信息(Business) add by wuxw 2018-07-03 -->
  15. <select id="getBusinessUnitInfo" parameterType="Map" resultType="Map">
  16. select t.floor_id,t.floor_id floorId,t.operate,t.layer_count,t.layer_count layerCount,t.unit_id,t.unit_id
  17. unitId,t.unit_num,t.unit_num unitNum,t.lift,t.remark,t.b_id,t.b_id bId,t.user_id,t.user_id userId
  18. from business_building_unit t
  19. where 1 =1
  20. <if test="floorId !=null and floorId != ''">
  21. and t.floor_id= #{floorId}
  22. </if>
  23. <if test="operate !=null and operate != ''">
  24. and t.operate= #{operate}
  25. </if>
  26. <if test="layerCount !=null and layerCount != ''">
  27. and t.layer_count= #{layerCount}
  28. </if>
  29. <if test="unitId !=null and unitId != ''">
  30. and t.unit_id= #{unitId}
  31. </if>
  32. <if test="unitNum !=null and unitNum != ''">
  33. and t.unit_num= #{unitNum}
  34. </if>
  35. <if test="lift !=null and lift != ''">
  36. and t.lift= #{lift}
  37. </if>
  38. <if test="remark !=null and remark != ''">
  39. and t.remark= #{remark}
  40. </if>
  41. <if test="bId !=null and bId != ''">
  42. and t.b_id= #{bId}
  43. </if>
  44. <if test="userId !=null and userId != ''">
  45. and t.user_id= #{userId}
  46. </if>
  47. </select>
  48. <!-- 保存小区单元信息至 instance表中 add by wuxw 2018-07-03 -->
  49. <insert id="saveUnitInfoInstance" parameterType="Map">
  50. insert into building_unit(
  51. floor_id,layer_count,unit_id,unit_num,lift,status_cd,remark,b_id,user_id
  52. ) select t.floor_id,t.layer_count,t.unit_id,t.unit_num,t.lift,'0',t.remark,t.b_id,t.user_id from
  53. business_building_unit t where 1=1
  54. <if test="floorId !=null and floorId != ''">
  55. and t.floor_id= #{floorId}
  56. </if>
  57. and t.operate= 'ADD'
  58. <if test="layerCount !=null and layerCount != ''">
  59. and t.layer_count= #{layerCount}
  60. </if>
  61. <if test="unitId !=null and unitId != ''">
  62. and t.unit_id= #{unitId}
  63. </if>
  64. <if test="unitNum !=null and unitNum != ''">
  65. and t.unit_num= #{unitNum}
  66. </if>
  67. <if test="lift !=null and lift != ''">
  68. and t.lift= #{lift}
  69. </if>
  70. <if test="remark !=null and remark != ''">
  71. and t.remark= #{remark}
  72. </if>
  73. <if test="bId !=null and bId != ''">
  74. and t.b_id= #{bId}
  75. </if>
  76. <if test="userId !=null and userId != ''">
  77. and t.user_id= #{userId}
  78. </if>
  79. </insert>
  80. <!-- 查询小区单元信息 add by wuxw 2018-07-03 -->
  81. <select id="getUnitInfo" parameterType="Map" resultType="Map">
  82. select t.floor_id,t.floor_id floorId,t.layer_count,t.layer_count layerCount,t.unit_id,t.unit_id
  83. unitId,t.unit_num,t.unit_num unitNum,t.lift,t.status_cd,t.status_cd statusCd,t.remark,t.b_id,t.b_id
  84. bId,t.user_id,t.user_id userId
  85. from building_unit t
  86. <if test="communityId!=null and communityId != ''">
  87. ,f_floor ff
  88. </if>
  89. where 1 =1
  90. <if test="communityId!=null and communityId != ''">
  91. and t.`floor_id` = ff.`floor_id`
  92. AND ff.community_id = #{communityId}
  93. and ff.status_cd = '0'
  94. </if>
  95. <if test="floorId !=null and floorId != ''">
  96. and t.floor_id= #{floorId}
  97. </if>
  98. <if test="layerCount !=null and layerCount != ''">
  99. and t.layer_count= #{layerCount}
  100. </if>
  101. <if test="unitId !=null and unitId != ''">
  102. and t.unit_id= #{unitId}
  103. </if>
  104. <if test="unitNum !=null and unitNum != ''">
  105. and t.unit_num= #{unitNum}
  106. </if>
  107. <if test="lift !=null and lift != ''">
  108. and t.lift= #{lift}
  109. </if>
  110. <if test="statusCd !=null and statusCd != ''">
  111. and t.status_cd= #{statusCd}
  112. </if>
  113. <if test="remark !=null and remark != ''">
  114. and t.remark= #{remark}
  115. </if>
  116. <if test="bId !=null and bId != ''">
  117. and t.b_id= #{bId}
  118. </if>
  119. <if test="userId !=null and userId != ''">
  120. and t.user_id= #{userId}
  121. </if>
  122. <!-- <if test="page != -1 and page != null ">
  123. limit #{page}, #{row}
  124. </if>limit 10;-->
  125. </select>
  126. <!-- 修改小区单元信息 add by wuxw 2018-07-03 -->
  127. <update id="updateUnitInfoInstance" parameterType="Map">
  128. update building_unit t set t.status_cd = #{statusCd}
  129. <if test="newBId != null and newBId != ''">
  130. ,t.b_id = #{newBId}
  131. </if>
  132. <if test="floorId !=null and floorId != ''">
  133. , t.floor_id= #{floorId}
  134. </if>
  135. <if test="layerCount !=null and layerCount != ''">
  136. , t.layer_count= #{layerCount}
  137. </if>
  138. <if test="unitNum !=null and unitNum != ''">
  139. , t.unit_num= #{unitNum}
  140. </if>
  141. <if test="lift !=null and lift != ''">
  142. , t.lift= #{lift}
  143. </if>
  144. <if test="remark !=null and remark != ''">
  145. , t.remark= #{remark}
  146. </if>
  147. <if test="userId !=null and userId != ''">
  148. , t.user_id= #{userId}
  149. </if>
  150. where 1=1
  151. <if test="unitId !=null and unitId != ''">
  152. and t.unit_id= #{unitId}
  153. </if>
  154. <if test="bId !=null and bId != ''">
  155. and t.b_id= #{bId}
  156. </if>
  157. </update>
  158. <!-- 查询小区单元数量 add by wuxw 2018-07-03 -->
  159. <select id="queryUnitsCount" parameterType="Map" resultType="Map">
  160. select count(1) count
  161. from building_unit t
  162. where 1 =1
  163. <if test="floorId !=null and floorId != ''">
  164. and t.floor_id= #{floorId}
  165. </if>
  166. <if test="layerCount !=null and layerCount != ''">
  167. and t.layer_count= #{layerCount}
  168. </if>
  169. <if test="unitId !=null and unitId != ''">
  170. and t.unit_id= #{unitId}
  171. </if>
  172. <if test="unitNum !=null and unitNum != ''">
  173. and t.unit_num= #{unitNum}
  174. </if>
  175. <if test="lift !=null and lift != ''">
  176. and t.lift= #{lift}
  177. </if>
  178. <if test="statusCd !=null and statusCd != ''">
  179. and t.status_cd= #{statusCd}
  180. </if>
  181. <if test="remark !=null and remark != ''">
  182. and t.remark= #{remark}
  183. </if>
  184. <if test="bId !=null and bId != ''">
  185. and t.b_id= #{bId}
  186. </if>
  187. <if test="userId !=null and userId != ''">
  188. and t.user_id= #{userId}
  189. </if>
  190. </select>
  191. <select id="queryUnitsByCommunityId" parameterType="Map" resultType="Map">
  192. select t.floor_id,t.floor_id floorId,t.layer_count,t.layer_count layerCount,t.unit_id,t.unit_id
  193. unitId,t.unit_num,t.unit_num unitNum,t.lift,t.status_cd,t.status_cd statusCd,t.remark,t.b_id,t.b_id
  194. bId,t.user_id,t.user_id userId
  195. from building_unit t,f_floor f
  196. where 1 =1
  197. and t.floor_id = f.floor_id
  198. and f.community_id = #{communityId}
  199. and f.status_cd = '0'
  200. <if test="floorId !=null and floorId != ''">
  201. and t.floor_id= #{floorId}
  202. </if>
  203. <if test="layerCount !=null and layerCount != ''">
  204. and t.layer_count= #{layerCount}
  205. </if>
  206. <if test="unitId !=null and unitId != ''">
  207. and t.unit_id= #{unitId}
  208. </if>
  209. <if test="unitNum !=null and unitNum != ''">
  210. and t.unit_num= #{unitNum}
  211. </if>
  212. <if test="lift !=null and lift != ''">
  213. and t.lift= #{lift}
  214. </if>
  215. <if test="statusCd !=null and statusCd != ''">
  216. and t.status_cd= #{statusCd}
  217. </if>
  218. <if test="remark !=null and remark != ''">
  219. and t.remark= #{remark}
  220. </if>
  221. <if test="bId !=null and bId != ''">
  222. and t.b_id= #{bId}
  223. </if>
  224. <if test="userId !=null and userId != ''">
  225. and t.user_id= #{userId}
  226. </if>
  227. <if test="page != -1 and page != null">
  228. limit #{page}, #{row}
  229. </if>
  230. </select>
  231. <select id="getFloorAndUnitInfo" parameterType="Map" resultType="Map">
  232. SELECT
  233. bu.`unit_id` unitId,
  234. bu.`unit_num` unitNum,
  235. f.`floor_id` floorId,
  236. f.`floor_num` floorNum
  237. FROM
  238. f_floor f,
  239. building_unit bu
  240. WHERE f.`floor_id` = bu.`floor_id`
  241. AND f.`status_cd` = '0'
  242. AND bu.`status_cd` = '0'
  243. <if test="floorId != null and floorId !=''">
  244. and bu.floor_id = #{floorId}
  245. </if>
  246. <if test="floorNum != null and floorNum !=''">
  247. and f.floor_num = #{floorNum}
  248. </if>
  249. <if test="unitId != null and unitId !=''">
  250. and bu.unit_id = #{unitId}
  251. </if>
  252. <if test="unitIds != null">
  253. and bu.unit_id in
  254. <foreach collection="unitIds" item="item" open="(" close=")" separator=",">
  255. #{item}
  256. </foreach>
  257. </if>
  258. <if test="unitNum != null and unitNum !=''">
  259. and bu.unit_num = #{unitNum}
  260. </if>
  261. </select>
  262. </mapper>