UnitServiceDaoImplMapper.xml 10 KB

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