OwnerServiceDaoImplMapper.xml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  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="ownerServiceDaoImpl">
  6. <!-- 保存业主信息 add by wuxw 2018-07-03 -->
  7. <insert id="saveBusinessOwnerInfo" parameterType="Map">
  8. insert into business_building_owner(
  9. operate,sex,name,link,remark,owner_id,b_id,user_id,age,member_id,owner_type_cd,community_id,id_card
  10. ) values (
  11. #{operate},#{sex},#{name},#{link},#{remark},#{ownerId},#{bId},#{userId},#{age},#{memberId},#{ownerTypeCd},#{communityId},#{idCard}
  12. )
  13. </insert>
  14. <!-- 查询业主信息(Business) add by wuxw 2018-07-03 -->
  15. <select id="getBusinessOwnerInfo" parameterType="Map" resultType="Map">
  16. select t.operate,t.sex,t.name,t.link,t.remark,t.owner_id,t.owner_id ownerId,t.b_id,t.b_id bId,
  17. t.user_id,t.user_id userId,t.age,t.member_id,t.member_id memberId,t.owner_type_cd,
  18. t.owner_type_cd ownerTypeCd,t.community_id,t.community_id communityId,
  19. t.id_card, t.id_card idCard
  20. from business_building_owner t
  21. where 1 =1
  22. <if test="operate !=null and operate != ''">
  23. and t.operate= #{operate}
  24. </if>
  25. <if test="sex !=null ">
  26. and t.sex= #{sex}
  27. </if>
  28. <if test="name !=null and name != ''">
  29. and t.name = #{name}
  30. </if>
  31. <if test="link !=null and link != ''">
  32. and t.link= #{link}
  33. </if>
  34. <if test="remark !=null and remark != ''">
  35. and t.remark= #{remark}
  36. </if>
  37. <if test="ownerId !=null and ownerId != ''">
  38. and t.owner_id= #{ownerId}
  39. </if>
  40. <if test="communityId !=null and communityId != ''">
  41. and t.community_id= #{communityId}
  42. </if>
  43. <if test="idCard !=null and idCard != ''">
  44. and t.id_card = #{idCard}
  45. </if>
  46. <if test="bId !=null and bId != ''">
  47. and t.b_id= #{bId}
  48. </if>
  49. <if test="userId !=null and userId != ''">
  50. and t.user_id= #{userId}
  51. </if>
  52. <if test="age !=null and age != ''">
  53. and t.age= #{age}
  54. </if>
  55. <if test="memberId !=null and memberId != ''">
  56. and t.member_id= #{memberId}
  57. </if>
  58. <if test="ownerTypeCd !=null and ownerTypeCd != ''">
  59. and t.owner_type_cd= #{ownerTypeCd}
  60. </if>
  61. </select>
  62. <!-- 保存业主信息至 instance表中 add by wuxw 2018-07-03 -->
  63. <insert id="saveOwnerInfoInstance" parameterType="Map">
  64. insert into building_owner(
  65. sex,name,link,status_cd,remark,owner_id,b_id,user_id,age,member_id,owner_type_cd,community_id,id_card
  66. ) select t.sex,t.name,t.link,'0',t.remark,t.owner_id,t.b_id,t.user_id,t.age,t.member_id,t.owner_type_cd,
  67. t.community_id communityId,t.id_card
  68. from business_building_owner t where 1=1
  69. and t.operate= 'ADD'
  70. <if test="sex !=null">
  71. and t.sex= #{sex}
  72. </if>
  73. <if test="name !=null and name != ''">
  74. and t.name= #{name}
  75. </if>
  76. <if test="link !=null and link != ''">
  77. and t.link= #{link}
  78. </if>
  79. <if test="remark !=null and remark != ''">
  80. and t.remark= #{remark}
  81. </if>
  82. <if test="ownerId !=null and ownerId != ''">
  83. and t.owner_id= #{ownerId}
  84. </if>
  85. <if test="communityId !=null and communityId != ''">
  86. and t.community_id= #{communityId}
  87. </if>
  88. <if test="idCard !=null and idCard != ''">
  89. and t.id_card = #{idCard}
  90. </if>
  91. <if test="bId !=null and bId != ''">
  92. and t.b_id= #{bId}
  93. </if>
  94. <if test="userId !=null and userId != ''">
  95. and t.user_id= #{userId}
  96. </if>
  97. <if test="age !=null and age != ''">
  98. and t.age= #{age}
  99. </if>
  100. <if test="memberId !=null and memberId != ''">
  101. and t.member_id= #{memberId}
  102. </if>
  103. <if test="ownerTypeCd !=null and ownerTypeCd != ''">
  104. and t.owner_type_cd= #{ownerTypeCd}
  105. </if>
  106. </insert>
  107. <!-- 查询业主信息 add by wuxw 2018-07-03 -->
  108. <select id="getOwnerInfo" parameterType="Map" resultType="Map">
  109. select t.sex,t.name,t.link,t.status_cd,t.status_cd statusCd,t.remark,
  110. t.owner_id,t.owner_id ownerId,t.b_id,t.b_id bId,
  111. t.user_id,t.user_id userId,t.age,t.member_id,t.member_id memberId,t.owner_type_cd,
  112. t.owner_type_cd ownerTypeCd,t.create_time createTime,t.community_id,
  113. t.community_id communityId,t.id_card, t.id_card idCard
  114. from building_owner t
  115. where 1 =1
  116. <if test="sex !=null">
  117. and t.sex= #{sex}
  118. </if>
  119. <if test="name !=null and name != ''">
  120. and t.name like concat('%',#{name},'%')
  121. </if>
  122. <if test="link !=null and link != ''">
  123. and t.link= #{link}
  124. </if>
  125. <if test="statusCd !=null and statusCd != ''">
  126. and t.status_cd= #{statusCd}
  127. </if>
  128. <if test="remark !=null and remark != ''">
  129. and t.remark= #{remark}
  130. </if>
  131. <if test="ownerId !=null and ownerId != ''">
  132. and t.owner_id= #{ownerId}
  133. </if>
  134. <if test="communityId !=null and communityId != ''">
  135. and t.community_id= #{communityId}
  136. </if>
  137. <if test="idCard !=null and idCard != ''">
  138. and t.id_card = #{idCard}
  139. </if>
  140. <if test="bId !=null and bId != ''">
  141. and t.b_id= #{bId}
  142. </if>
  143. <if test="userId !=null and userId != ''">
  144. and t.user_id= #{userId}
  145. </if>
  146. <if test="age !=null and age != ''">
  147. and t.age= #{age}
  148. </if>
  149. <if test="memberId !=null and memberId != ''">
  150. and t.member_id= #{memberId}
  151. </if>
  152. <if test="ownerIds != null and ownerIds != ''">
  153. and t.owner_id in
  154. <foreach collection="ownerIds" item="item" open="(" close=")" separator=",">
  155. #{item}
  156. </foreach>
  157. </if>
  158. <if test="ownerTypeCd !=null and ownerTypeCd != ''">
  159. and t.owner_type_cd= #{ownerTypeCd}
  160. </if>
  161. <if test="page != -1 and page != null ">
  162. limit #{page}, #{row}
  163. </if>
  164. </select>
  165. <!-- 查询业主信息 add by wuxw 2018-07-03 -->
  166. <select id="getOwnerInfoCount" parameterType="Map" resultType="Map">
  167. select count(1) count
  168. from building_owner t
  169. where 1 =1
  170. <if test="sex !=null">
  171. and t.sex= #{sex}
  172. </if>
  173. <if test="name !=null and name != ''">
  174. and t.name like concat('%',#{name},'%')
  175. </if>
  176. <if test="link !=null and link != ''">
  177. and t.link= #{link}
  178. </if>
  179. <if test="statusCd !=null and statusCd != ''">
  180. and t.status_cd= #{statusCd}
  181. </if>
  182. <if test="remark !=null and remark != ''">
  183. and t.remark= #{remark}
  184. </if>
  185. <if test="ownerId !=null and ownerId != ''">
  186. and t.owner_id= #{ownerId}
  187. </if>
  188. <if test="communityId !=null and communityId != ''">
  189. and t.community_id= #{communityId}
  190. </if>
  191. <if test="idCard !=null and idCard != ''">
  192. and t.id_card = #{idCard}
  193. </if>
  194. <if test="bId !=null and bId != ''">
  195. and t.b_id= #{bId}
  196. </if>
  197. <if test="userId !=null and userId != ''">
  198. and t.user_id= #{userId}
  199. </if>
  200. <if test="age !=null and age != ''">
  201. and t.age= #{age}
  202. </if>
  203. <if test="memberId !=null and memberId != ''">
  204. and t.member_id= #{memberId}
  205. </if>
  206. <if test="ownerIds != null and ownerIds != ''">
  207. and t.owner_id in
  208. <foreach collection="ownerIds" item="item" open="(" close=")" separator=",">
  209. #{item}
  210. </foreach>
  211. </if>
  212. <if test="ownerTypeCd !=null and ownerTypeCd != ''">
  213. and t.owner_type_cd= #{ownerTypeCd}
  214. </if>
  215. </select>
  216. <!-- 修改业主信息 add by wuxw 2018-07-03 -->
  217. <update id="updateOwnerInfoInstance" parameterType="Map">
  218. update building_owner t set t.status_cd = #{statusCd}
  219. <if test="newBId != null and newBId != ''">
  220. ,t.b_id = #{newBId}
  221. </if>
  222. <if test="sex !=null ">
  223. , t.sex= #{sex}
  224. </if>
  225. <if test="name !=null and name != ''">
  226. , t.name= #{name}
  227. </if>
  228. <if test="link !=null and link != ''">
  229. , t.link= #{link}
  230. </if>
  231. <if test="remark !=null and remark != ''">
  232. , t.remark= #{remark}
  233. </if>
  234. <if test="ownerId !=null and ownerId != ''">
  235. , t.owner_id= #{ownerId}
  236. </if>
  237. <if test="userId !=null and userId != ''">
  238. , t.user_id= #{userId}
  239. </if>
  240. <if test="age !=null and age != ''">
  241. , t.age= #{age}
  242. </if>
  243. <if test="idCard !=null and idCard != ''">
  244. , t.id_card = #{idCard}
  245. </if>
  246. where 1=1
  247. <if test="bId !=null and bId != ''">
  248. and t.b_id= #{bId}
  249. </if>
  250. <if test="communityId !=null and communityId != ''">
  251. and t.community_id= #{communityId}
  252. </if>
  253. <if test="memberId !=null and memberId != ''">
  254. and t.member_id= #{memberId}
  255. </if>
  256. </update>
  257. <!-- 查询业主数量 add by wuxw 2018-07-03 -->
  258. <select id="queryOwnersCount" parameterType="Map" resultType="Map">
  259. select count(1) count
  260. FROM building_owner t
  261. where 1=1
  262. <if test="sex !=null ">
  263. and t.sex= #{sex}
  264. </if>
  265. <if test="name !=null and name != ''">
  266. and t.name like concat('%',#{name},'%')
  267. </if>
  268. <if test="link !=null and link != ''">
  269. and t.link= #{link}
  270. </if>
  271. <if test="statusCd !=null and statusCd != ''">
  272. and t.status_cd= #{statusCd}
  273. </if>
  274. <if test="remark !=null and remark != ''">
  275. and t.remark= #{remark}
  276. </if>
  277. <if test="ownerId !=null and ownerId != ''">
  278. and t.owner_id= #{ownerId}
  279. </if>
  280. <if test="communityId !=null and communityId != ''">
  281. and t.community_id= #{communityId}
  282. </if>
  283. <if test="idCard !=null and idCard != ''">
  284. and t.id_card = #{idCard}
  285. </if>
  286. <if test="bId !=null and bId != ''">
  287. and t.b_id= #{bId}
  288. </if>
  289. <if test="userId !=null and userId != ''">
  290. and t.user_id= #{userId}
  291. </if>
  292. <if test="age !=null and age != ''">
  293. and t.age= #{age}
  294. </if>
  295. <if test="memberId !=null and memberId != ''">
  296. and t.member_id= #{memberId}
  297. </if>
  298. <if test="ownerTypeCd !=null and ownerTypeCd != ''">
  299. and t.owner_type_cd= #{ownerTypeCd}
  300. </if>
  301. </select>
  302. <!-- 查询业主数量 add by wuxw 2018-07-03 -->
  303. <select id="queryOwnersCountByCondition" parameterType="Map" resultType="Map">
  304. select count(1) count
  305. FROM building_owner t , s_community_member cm
  306. WHERE t.`member_id` = cm.`member_id`
  307. AND cm.`community_id` = #{communityId}
  308. AND cm.`status_cd` = '0'
  309. AND t.`status_cd` = '0'
  310. <if test="sex !=null ">
  311. and t.sex= #{sex}
  312. </if>
  313. <if test="name !=null and name != ''">
  314. and t.name like concat('%',#{name},'%')
  315. </if>
  316. <if test="link !=null and link != ''">
  317. and t.link= #{link}
  318. </if>
  319. <if test="statusCd !=null and statusCd != ''">
  320. and t.status_cd= #{statusCd}
  321. </if>
  322. <if test="remark !=null and remark != ''">
  323. and t.remark= #{remark}
  324. </if>
  325. <if test="ownerId !=null and ownerId != ''">
  326. and t.owner_id= #{ownerId}
  327. </if>
  328. <if test="communityId !=null and communityId != ''">
  329. and t.community_id= #{communityId}
  330. </if>
  331. <if test="idCard !=null and idCard != ''">
  332. and t.id_card = #{idCard}
  333. </if>
  334. <if test="bId !=null and bId != ''">
  335. and t.b_id= #{bId}
  336. </if>
  337. <if test="userId !=null and userId != ''">
  338. and t.user_id= #{userId}
  339. </if>
  340. <if test="age !=null and age != ''">
  341. and t.age= #{age}
  342. </if>
  343. <if test="memberId !=null and memberId != ''">
  344. and t.member_id= #{memberId}
  345. </if>
  346. <if test="ownerTypeCd !=null and ownerTypeCd != ''">
  347. and t.owner_type_cd= #{ownerTypeCd}
  348. </if>
  349. </select>
  350. <!-- 查询业主信息 add by wuxw 2018-07-03 -->
  351. <select id="getOwnerInfoByCondition" parameterType="Map" resultType="Map">
  352. select t.sex,t.name,t.link,t.status_cd,t.status_cd statusCd,t.remark,t.owner_id,t.owner_id ownerId,t.b_id,t.b_id
  353. bId,
  354. t.user_id,t.user_id userId,t.age,t.member_id,t.member_id memberId,
  355. t.owner_type_cd,t.owner_type_cd ownerTypeCd,t.community_id,
  356. t.community_id communityId,t.id_card, t.id_card idCard
  357. FROM building_owner t , s_community_member cm
  358. WHERE t.`member_id` = cm.`member_id`
  359. AND cm.`community_id` = #{communityId}
  360. AND cm.`status_cd` = '0'
  361. AND t.`status_cd` = '0'
  362. <if test="sex !=null ">
  363. and t.sex= #{sex}
  364. </if>
  365. <if test="name !=null and name != ''">
  366. and t.name like concat('%',#{name},'%')
  367. </if>
  368. <if test="link !=null and link != ''">
  369. and t.link= #{link}
  370. </if>
  371. <if test="statusCd !=null and statusCd != ''">
  372. and t.status_cd= #{statusCd}
  373. </if>
  374. <if test="remark !=null and remark != ''">
  375. and t.remark= #{remark}
  376. </if>
  377. <if test="ownerId !=null and ownerId != ''">
  378. and t.owner_id= #{ownerId}
  379. </if>
  380. <if test="communityId !=null and communityId != ''">
  381. and t.community_id= #{communityId}
  382. </if>
  383. <if test="idCard !=null and idCard != ''">
  384. and t.id_card = #{idCard}
  385. </if>
  386. <if test="bId !=null and bId != ''">
  387. and t.b_id= #{bId}
  388. </if>
  389. <if test="userId !=null and userId != ''">
  390. and t.user_id= #{userId}
  391. </if>
  392. <if test="age !=null and age != ''">
  393. and t.age= #{age}
  394. </if>
  395. <if test="memberId !=null and memberId != ''">
  396. and t.member_id= #{memberId}
  397. </if>
  398. <if test="ownerIds != null and ownerIds != ''">
  399. and t.owner_id in
  400. <foreach collection="ownerIds" item="item" open="(" close=")" separator=",">
  401. #{item}
  402. </foreach>
  403. </if>
  404. <if test="ownerTypeCd !=null and ownerTypeCd != ''">
  405. and t.owner_type_cd= #{ownerTypeCd}
  406. </if>
  407. <if test="page != -1 and page != null ">
  408. limit #{page}, #{row}
  409. </if>
  410. </select>
  411. <!-- 查询未入驻业主 总数 -->
  412. <select id="queryNoEnterRoomOwnerCount" parameterType="Map" resultType="Map">
  413. SELECT
  414. COUNT(1) count
  415. FROM
  416. building_owner_room_rel a,
  417. building_owner o,
  418. s_community_member m
  419. WHERE a.`state` IN ('2001', '2003')
  420. AND a.`owner_id` = o.`owner_id`
  421. AND o.`owner_id` = m.`member_id`
  422. AND m.`member_type_cd` = '390001200005'
  423. AND m.`community_id` = #{communityId}
  424. AND a.`status_cd` = '0'
  425. AND o.`status_cd` = '0'
  426. AND m.`status_cd` = '0'
  427. </select>
  428. <!-- queryOwnersByRoom -->
  429. <!-- 根据房屋查询业主信息 -->
  430. <select id="queryOwnersByRoom" parameterType="Map" resultType="Map">
  431. SELECT t.sex,t.name,t.link,t.status_cd,t.status_cd statusCd,t.remark,t.owner_id,t.owner_id ownerId,t.b_id,t.b_id
  432. bId,
  433. t.user_id,t.user_id userId,t.age,t.member_id,t.member_id memberId,t.owner_type_cd,t.owner_type_cd ownerTypeCd,
  434. r.`room_id` roomId,r.`room_num` roomNum,t.community_id,t.community_id communityId,t.id_card, t.id_card idCard
  435. FROM building_room r,building_owner_room_rel orr,building_owner t
  436. WHERE r.`room_id` = orr.`room_id`
  437. AND orr.`owner_id` = t.`owner_id`
  438. <if test="roomId !=null and roomId != ''">
  439. AND r.`room_id` = #{roomId}
  440. </if>
  441. <if test="roomIds != null ">
  442. and r.room_id in
  443. <foreach collection="roomIds" item="item" open="(" close=")" separator=",">
  444. #{item}
  445. </foreach>
  446. </if>
  447. <if test="communityId !=null and communityId != ''">
  448. and t.community_id= #{communityId}
  449. </if>
  450. AND r.`status_cd` = '0'
  451. AND orr.`status_cd` = '0'
  452. AND t.`status_cd` = '0'
  453. </select>
  454. <!-- 根据停车位查询 -->
  455. <select id="queryOwnersByParkingSpace" parameterType="Map" resultType="Map">
  456. select ps.num,ps.ps_id psId,t.sex,t.name,t.link,t.status_cd,t.status_cd statusCd,t.remark,t.owner_id,t.owner_id
  457. ownerId,t.b_id,t.b_id bId,
  458. t.user_id,t.user_id userId,t.age,t.member_id,t.member_id memberId,
  459. t.owner_type_cd,t.owner_type_cd ownerTypeCd,t.id_card, t.id_card idCard
  460. from p_parking_space ps , owner_car oc,building_owner t
  461. where ps.ps_id = oc.ps_id
  462. and oc.owner_id = t.owner_id
  463. AND oc.`status_cd` = '0'
  464. AND ps.`status_cd` = '0'
  465. AND t.`status_cd` = '0'
  466. <if test="psIds != null ">
  467. and ps.ps_id in
  468. <foreach collection="psIds" item="item" open="(" close=")" separator=",">
  469. #{item}
  470. </foreach>
  471. </if>
  472. <if test="psId !=null and psId != ''">
  473. AND ps.`ps_id` = #{psId}
  474. </if>
  475. </select>
  476. </mapper>