CommunityServiceDaoImplMapper.xml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505
  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="communityServiceDaoImpl">
  6. <!-- 保存小区信息 add by wuxw 2018-07-03 -->
  7. <insert id="saveBusinessCommunityInfo" parameterType="Map">
  8. insert into business_community(community_id,b_id,name,address,city_code,nearby_landmarks,map_x,map_y,month,state,operate)
  9. values(#{communityId},#{bId},#{name},#{address},#{cityCode},#{nearbyLandmarks},#{mapX},#{mapY},#{month},#{state},#{operate})
  10. </insert>
  11. <!-- 保存小区属性信息 add by wuxw 2018-07-03 -->
  12. <insert id="saveBusinessCommunityAttr" parameterType="Map">
  13. insert into business_community_attr(b_id,attr_id,community_id,spec_cd,value,month,operate)
  14. values(#{bId},#{attrId},#{communityId},#{specCd},#{value},#{month},#{operate})
  15. </insert>
  16. <!-- 保存小区照片信息 add by wuxw 2018-07-03 -->
  17. <insert id="saveBusinessCommunityPhoto" parameterType="Map">
  18. insert into business_community_photo(community_photo_id,b_id,community_id,community_photo_type_cd,photo,month,operate)
  19. values(#{communityPhotoId},#{bId},#{communityId},#{communityPhotoTypeCd},#{photo},#{month},#{operate})
  20. </insert>
  21. <!-- 查询小区信息(Business) add by wuxw 2018-07-03 -->
  22. <select id="getBusinessCommunityInfo" parameterType="Map" resultType="Map">
  23. select s.community_id,s.b_id,s.name,s.address,s.city_code,s.nearby_landmarks,s.map_x,s.map_y,s.operate,s.state
  24. from business_community s where 1 = 1
  25. <if test="operate != null and operate != ''">
  26. and s.operate = #{operate}
  27. </if>
  28. <if test="bId != null and bId !=''">
  29. and s.b_id = #{bId}
  30. </if>
  31. <if test="communityId != null and communityId != ''">
  32. and s.community_id = #{communityId}
  33. </if>
  34. </select>
  35. <!-- 查询小区属性信息(Business) add by wuxw 2018-07-03 -->
  36. <select id="getBusinessCommunityAttrs" parameterType="Map" resultType="Map">
  37. select sa.b_id,sa.attr_id,sa.community_id,sa.spec_cd,sa.value,sa.operate
  38. from business_community_attr sa where 1=1
  39. <if test="operate != null and operate != ''">
  40. and sa.operate = #{operate}
  41. </if>
  42. <if test="bId != null and bId !=''">
  43. and sa.b_id = #{bId}
  44. </if>
  45. <if test="communityId != null and communityId != ''">
  46. and sa.community_id = #{communityId}
  47. </if>
  48. <if test="attrId != null and attrId != ''">
  49. and sa.attr_id = #{attrId}
  50. </if>
  51. </select>
  52. <!-- 查询小区照片信息 add by wuxw 2018-07-03 -->
  53. <select id="getBusinessCommunityPhoto" parameterType="Map" resultType="Map">
  54. select sp.community_photo_id,sp.b_id,sp.community_id,sp.community_photo_type_cd,sp.photo,sp.operate
  55. from business_community_photo sp where 1=1
  56. <if test="bId != null and bId !=''">
  57. and sp.b_id = #{bId}
  58. </if>
  59. <if test="operate != null and operate != ''">
  60. and sp.operate = #{operate}
  61. </if>
  62. <if test="communityId != null and communityId != ''">
  63. and sp.community_id = #{communityId}
  64. </if>
  65. </select>
  66. <!-- 保存小区信息至 instance表中 add by wuxw 2018-07-03 -->
  67. <insert id="saveCommunityInfoInstance" parameterType="Map">
  68. insert into s_community(community_id,b_id,name,address,city_code,nearby_landmarks,map_x,map_y,status_cd,state)
  69. values(#{community_id},#{b_id},#{name},#{address},#{city_code},#{nearby_landmarks},#{map_x},#{map_y},'0',#{state})
  70. </insert>
  71. <!-- 保存小区属性信息到 instance add by wuxw 2018-07-03 -->
  72. <insert id="saveCommunityAttrsInstance" parameterType="Map">
  73. insert into s_community_attr(b_id,attr_id,community_id,spec_cd,value,status_cd)
  74. select sa.b_id,sa.attr_id,sa.community_id,sa.spec_cd,sa.value,'0'
  75. from business_community_attr sa
  76. where sa.operate = 'ADD' and sa.b_id=#{bId}
  77. <if test="communityId != null and communityId != ''">
  78. and sa.community_id = #{communityId}
  79. </if>
  80. </insert>
  81. <!-- 保存 小区照片信息 instance add by wuxw 2018-07-03 -->
  82. <insert id="saveCommunityPhotoInstance" parameterType="Map">
  83. insert into s_community_photo(community_photo_id,b_id,community_id,community_photo_type_cd,photo,status_cd)
  84. select sp.community_photo_id,sp.b_id,sp.community_id,sp.community_photo_type_cd,sp.photo,'0'
  85. from business_community_photo sp
  86. where sp.operate = 'ADD' and sp.b_id=#{bId}
  87. <if test="communityId != null and communityId != ''">
  88. and sp.community_id = #{communityId}
  89. </if>
  90. </insert>
  91. <!-- 查询小区信息 add by wuxw 2018-07-03 -->
  92. <select id="getCommunityInfo" parameterType="Map" resultType="Map">
  93. select s.community_id,s.b_id,s.name,s.address,s.city_code,s.nearby_landmarks,s.map_x,s.map_y,s.status_cd,s.state
  94. from s_community s
  95. where 1=1
  96. <if test="statusCd != null and statusCd != ''">
  97. and s.status_cd = #{statusCd}
  98. </if>
  99. <if test="bId != null and bId !=''">
  100. and s.b_id = #{bId}
  101. </if>
  102. <if test="communityId != null and communityId !=''">
  103. and s.community_id = #{communityId}
  104. </if>
  105. </select>
  106. <!-- 查询小区属性信息 add by wuxw 2018-07-03 -->
  107. <select id="getCommunityAttrs" parameterType="Map" resultType="Map">
  108. select sa.b_id,sa.attr_id,sa.community_id,sa.spec_cd,sa.value,sa.status_cd
  109. from s_community_attr sa
  110. where
  111. 1=1
  112. <if test="statusCd != null and statusCd != ''">
  113. and sa.status_cd = #{statusCd}
  114. </if>
  115. <if test="bId != null and bId !=''">
  116. and sa.b_id = #{bId}
  117. </if>
  118. <if test="communityId != null and communityId !=''">
  119. and sa.community_id = #{communityId}
  120. </if>
  121. <if test="attrId != null and attrId != ''">
  122. and sa.attr_id = #{attrId}
  123. </if>
  124. </select>
  125. <!-- 查询小区照片信息 add by wuxw 2018-07-03 -->
  126. <select id="getCommunityPhoto" parameterType="Map" resultType="Map">
  127. select sp.community_photo_id,sp.b_id,sp.community_id,sp.community_photo_type_cd,sp.photo,sp.status_cd
  128. from s_community_photo sp
  129. where 1=1
  130. <if test="statusCd != null and statusCd != ''">
  131. and sp.status_cd = #{statusCd}
  132. </if>
  133. <if test="bId != null and bId !=''">
  134. and sp.b_id = #{bId}
  135. </if>
  136. <if test="communityId != null and communityId !=''">
  137. and sp.community_id = #{communityId}
  138. </if>
  139. </select>
  140. <!-- 修改小区信息 add by wuxw 2018-07-03 -->
  141. <update id="updateCommunityInfoInstance" parameterType="Map">
  142. update s_community s set s.status_cd = #{statusCd}
  143. <if test="newBId != null and newBId != ''">
  144. ,s.b_id = #{newBId}
  145. </if>
  146. <if test="name != null and name != ''">
  147. ,s.name = #{name}
  148. </if>
  149. <if test="address != null and address != ''">
  150. ,s.address = #{address}
  151. </if>
  152. <if test="cityCode != null and cityCode != ''">
  153. ,s.city_code = #{cityCode}
  154. </if>
  155. <if test="nearbyLandmarks != null and nearbyLandmarks != ''">
  156. ,s.nearby_landmarks = #{nearbyLandmarks}
  157. </if>
  158. <if test="mapX != null and mapX != ''">
  159. ,s.map_x = #{mapX}
  160. </if>
  161. <if test="mapY != null and mapY != ''">
  162. ,s.map_y = #{mapY}
  163. </if>
  164. <if test="state != null and state != ''">
  165. ,s.state = #{state}
  166. </if>
  167. where 1=1
  168. <if test="bId != null and bId !=''">
  169. and s.b_id = #{bId}
  170. </if>
  171. <if test="communityId != null and communityId !=''">
  172. and s.community_id = #{communityId}
  173. </if>
  174. </update>
  175. <!-- 修改小区属性信息 add by wuxw 2018-07-03 -->
  176. <update id="updateCommunityAttrInstance" parameterType="Map">
  177. update s_community_attr sa set sa.status_cd = #{statusCd}
  178. <if test="newBId != null and newBId != ''">
  179. ,sa.b_id = #{newBId}
  180. </if>
  181. <if test="value != null and value != ''">
  182. ,sa.value = #{value}
  183. </if>
  184. where 1=1
  185. <if test="bId != null and bId !=''">
  186. and sa.b_id = #{bId}
  187. </if>
  188. <if test="communityId != null and communityId !=''">
  189. and sa.community_id = #{communityId}
  190. </if>
  191. <if test="specCd != null and specCd !=''">
  192. and sa.spec_cd = #{specCd}
  193. </if>
  194. <if test="attrId != null and attrId !=''">
  195. and sa.attr_id = #{attrId}
  196. </if>
  197. </update>
  198. <!-- 修改小区照片信息 add by wuxw 2018-07-03 -->
  199. <update id="updateCommunityPhotoInstance" parameterType="Map">
  200. update s_community_photo sp set sp.status_cd = #{statusCd}
  201. <if test="newBId != null and newBId != ''">
  202. ,sp.b_id = #{newBId}
  203. </if>
  204. <if test="communityPhotoTypeCd != null and communityPhotoTypeCd != ''">
  205. ,sp.community_photo_type_cd = #{communityPhotoTypeCd}
  206. </if>
  207. <if test="photo != null and photo != ''">
  208. ,sp.photo = #{photo}
  209. </if>
  210. where 1=1
  211. <if test="bId != null and bId !=''">
  212. and sp.b_id = #{bId}
  213. </if>
  214. <if test="communityId != null and communityId !=''">
  215. and sp.community_id = #{communityId}
  216. </if>
  217. <if test="communityPhotoId != null and communityPhotoId !=''">
  218. and sp.community_photo_id = #{communityPhotoId}
  219. </if>
  220. </update>
  221. <!--小区成员加入 add by wuxw 2018-10-27 saveBusinessCommunityMember-->
  222. <insert id="saveBusinessCommunityMember" parameterType="Map">
  223. insert into business_community_member(community_member_id,b_id,community_id,member_id,member_type_cd,month,operate,audit_status_cd)
  224. values(#{communityMemberId},#{bId},#{communityId},#{memberId},#{memberTypeCd},#{month},#{operate},#{auditStatusCd})
  225. </insert>
  226. <!-- 小区成员加入 instance表中 add by wuxw 2018-10-27 -->
  227. <insert id="saveCommunityMemberInstance" parameterType="Map">
  228. insert into s_community_member(community_member_id,b_id,community_id,member_id,member_type_cd,status_cd,audit_status_cd)
  229. select ms.community_member_id,ms.b_id,ms.community_id,ms.member_id,ms.member_type_cd,'0',ms.audit_status_cd
  230. from business_community_member ms where
  231. ms.operate = 'ADD' and ms.b_id=#{bId}
  232. <if test="communityId != null and communityId != ''">
  233. and ms.community_id = #{communityId}
  234. </if>
  235. </insert>
  236. <!-- 查询小区成员 add by wuxw 2018-10-27 getBusinessCommunityMember-->
  237. <select id="getBusinessCommunityMember" parameterType="Map" resultType="Map">
  238. select ms.community_member_id,ms.b_id,ms.community_id,ms.member_id,ms.member_type_cd,ms.operate,ms.audit_status_cd
  239. from business_community_member ms where 1 = 1
  240. <if test="operate != null and operate != ''">
  241. and ms.operate = #{operate}
  242. </if>
  243. <if test="bId != null and bId !=''">
  244. and ms.b_id = #{bId}
  245. </if>
  246. <if test="communityId != null and communityId != ''">
  247. and ms.community_id = #{communityId}
  248. </if>
  249. </select>
  250. <!-- 查询小区成员 add by wuxw 2018-07-03 -->
  251. <select id="getCommunityMember" parameterType="Map" resultType="Map">
  252. select ms.community_member_id , ms.b_id,ms.community_id,ms.member_id,ms.member_type_cd,ms.status_cd,ms.audit_status_cd,
  253. ms.community_member_id communityMemberId ,ms.b_id bId,ms.community_id communityId,ms.member_id memberId,ms.member_type_cd memberTypeCd,ms.status_cd statusCd,
  254. ms.audit_status_cd auditStatusCd,
  255. (CASE
  256. WHEN ms.audit_status_cd='1000'
  257. THEN '待审核'
  258. WHEN ms.audit_status_cd = '1100'
  259. THEN '审核完成'
  260. ELSE
  261. '审核拒绝'
  262. END) stateName
  263. <if test="needCommunityInfo == true">
  264. ,sc.name
  265. </if>
  266. from s_community_member ms
  267. <if test="needCommunityInfo == true">
  268. ,s_community sc,
  269. s_community_member msc
  270. </if>
  271. where 1=1
  272. <if test="needCommunityInfo == true">
  273. and sc.`community_id` = ms.`community_id`
  274. AND sc.`status_cd` = '0'
  275. and sc.state='1100'
  276. </if>
  277. <if test="statusCd != null and statusCd != ''">
  278. and ms.status_cd = #{statusCd}
  279. </if>
  280. <if test="bId != null and bId !=''">
  281. and ms.b_id = #{bId}
  282. </if>
  283. <if test="communityMemberId != null and communityMemberId !=''">
  284. and ms.community_member_id = #{communityMemberId}
  285. </if>
  286. <if test="memberId != null and memberId != '' and needCommunityInfo == true">
  287. AND ms.`community_id` = msc.`community_id`
  288. and msc.member_id = #{memberId}
  289. </if>
  290. <if test="memberId != null and memberId != '' and needCommunityInfo == false">
  291. and ms.member_id = #{memberId}
  292. </if>
  293. <if test="memberTypeCd != null and memberTypeCd != ''">
  294. and ms.member_type_cd = #{memberTypeCd}
  295. </if>
  296. <if test="auditStatusCd != null and auditStatusCd != ''">
  297. and ms.audit_status_cd = #{auditStatusCd}
  298. </if>
  299. <if test="communityId != null and communityId != ''">
  300. and ms.community_id = #{communityId}
  301. </if>
  302. <if test="page != -1 and page != null">
  303. limit #{page},#{row}
  304. </if>
  305. </select>
  306. <!-- 修改小区成员 add by wuxw 2018-07-03 -->
  307. <update id="updateCommunityMemberInstance" parameterType="Map">
  308. update s_community_member ms set ms.status_cd = #{statusCd}
  309. <if test="newBId != null and newBId != ''">
  310. ,ms.b_id = #{newBId}
  311. </if>
  312. <if test="auditStatusCd !=null and auditStatusCd !=''">
  313. ,ms.audit_status_cd = #{auditStatusCd}
  314. </if>
  315. where 1=1
  316. <if test="bId != null and bId !=''">
  317. and ms.b_id = #{bId}
  318. </if>
  319. <if test="communityMemberId != null and communityMemberId !=''">
  320. and ms.community_member_id = #{communityMemberId}
  321. </if>
  322. </update>
  323. <!-- 查询小区成员 add by wuxw 2018-07-03 -->
  324. <select id="getCommunityMemberCount" parameterType="Map" resultType="Map">
  325. select count(1) count
  326. from s_community_member ms
  327. <if test="needCommunityInfo == true">
  328. ,s_community sc,
  329. s_community_member msc
  330. </if>
  331. where 1=1
  332. <if test="needCommunityInfo == true">
  333. and sc.`community_id` = ms.`community_id`
  334. AND sc.`status_cd` = '0'
  335. and sc.state='1100'
  336. </if>
  337. <if test="statusCd != null and statusCd != ''">
  338. and ms.status_cd = #{statusCd}
  339. </if>
  340. <if test="bId != null and bId !=''">
  341. and ms.b_id = #{bId}
  342. </if>
  343. <if test="communityMemberId != null and communityMemberId !=''">
  344. and ms.community_member_id = #{communityMemberId}
  345. </if>
  346. <if test="memberId != null and memberId != '' and needCommunityInfo == true">
  347. AND ms.`community_id` = msc.`community_id`
  348. and msc.member_id = #{memberId}
  349. </if>
  350. <if test="memberId != null andull
  351. <if test="memberTypeCd != null and memberTypeCd != ''">
  352. and ms.member_type_cd = #{memberTypeCd}
  353. </if>
  354. <if test="auditStatusCd != null and auditStatusCd != ''">
  355. and ms.audit_status_cd = #{auditStatusCd}
  356. </if>
  357. <if test="communityId != null and communityId != ''">
  358. and ms.community_id = #{communityId}
  359. </if>
  360. </select>
  361. <!-- 查询小区信息 add by wuxw 2018-07-03 -->
  362. <select id="getCommunityInfoNew" parameterType="Map" resultType="Map">
  363. select t.address,t.nearby_landmarks,t.nearby_landmarks nearbyLandmarks,
  364. t.city_code,t.city_code cityCode,t.name,t.status_cd,t.status_cd statusCd,
  365. t.community_id,t.community_id communityId,t.b_id,t.b_id bId,t.map_y,t.map_y mapY,
  366. t.map_x,t.map_x mapX,t.state,(CASE
  367. WHEN t.state='1000'
  368. THEN '待审核'
  369. WHEN t.state = '1100'
  370. THEN '审核完成'
  371. ELSE
  372. '审核拒绝'
  373. END) stateName
  374. from s_community t
  375. <if test="memberId !=null and memberId !=''">
  376. ,s_community_member cm
  377. </if>
  378. where 1 =1
  379. <if test="address !=null and address != ''">
  380. and t.address= #{address}
  381. </if>
  382. <if test="nearbyLandmarks !=null and nearbyLandmarks != ''">
  383. and t.nearby_landmarks= #{nearbyLandmarks}
  384. </if>
  385. <if test="cityCode !=null and cityCode != ''">
  386. and t.city_code= #{cityCode}
  387. </if>
  388. <if test="name !=null and name != ''">
  389. and t.name= #{name}
  390. </if>
  391. <if test="statusCd !=null and statusCd != ''">
  392. and t.status_cd= #{statusCd}
  393. </if>
  394. <if test="communityId !=null and communityId != ''">
  395. and t.community_id= #{communityId}
  396. </if>
  397. <if test="bId !=null and bId != ''">
  398. and t.b_id= #{bId}
  399. </if>
  400. <if test="mapY !=null and mapY != ''">
  401. and t.map_y= #{mapY}
  402. </if>
  403. <if test="mapX !=null and mapX != ''">
  404. and t.map_x= #{mapX}
  405. </if>
  406. <if test="state !=null and state != ''">
  407. and t.state= #{state}
  408. </if>
  409. <if test="memberId !=null and memberId !=''">
  410. and cm.community_id = t.community_id
  411. and cm.member_id = #{memberId}
  412. and cm.status_cd = '0'
  413. </if>
  414. <if test="page != -1 and page != null ">
  415. limit #{page}, #{row}
  416. </if>
  417. </select>
  418. <!-- 查询小区数量 add by wuxw 2018-07-03 -->
  419. <select id="queryCommunitysCount" parameterType="Map" resultType="Map">
  420. select count(1) count
  421. from s_community t
  422. <if test="memberId !=null and memberId !=''">
  423. ,s_community_member cm
  424. </if>
  425. where 1 =1
  426. <if test="address !=null and address != ''">
  427. and t.address= #{address}
  428. </if>
  429. <if test="nearbyLandmarks !=null and nearbyLandmarks != ''">
  430. and t.nearby_landmarks= #{nearbyLandmarks}
  431. </if>
  432. <if test="cityCode !=null and cityCode != ''">
  433. and t.city_code= #{cityCode}
  434. </if>
  435. <if test="name !=null and name != ''">
  436. and t.name= #{name}
  437. </if>
  438. <if test="statusCd !=null and statusCd != ''">
  439. and t.status_cd= #{statusCd}
  440. </if>
  441. <if test="communityId !=null and communityId != ''">
  442. and t.community_id= #{communityId}
  443. </if>
  444. <if test="bId !=null and bId != ''">
  445. and t.b_id= #{bId}
  446. </if>
  447. <if test="mapY !=null and mapY != ''">
  448. and t.map_y= #{mapY}
  449. </if>
  450. <if test="mapX !=null and mapX != ''">
  451. and t.map_x= #{mapX}
  452. </if>
  453. <if test="state !=null and state != ''">
  454. and t.state= #{state}
  455. </if>
  456. <if test="memberId !=null and memberId !=''">
  457. and cm.community_id = t.community_id
  458. and cm.member_id = #{memberId}
  459. and cm.status_cd = '0'
  460. </if>
  461. </select>
  462. </mapper>