CommunityServiceDaoImplMapper.xml 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  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="noAuditEnterCommunity == true">
  294. and ms.member_type_cd not in ('390001200003','390001200005','390001200000')
  295. </if>
  296. <if test="memberTypeCd != null and memberTypeCd != ''">
  297. and ms.member_type_cd = #{memberTypeCd}
  298. </if>
  299. <if test="auditStatusCd != null and auditStatusCd != ''">
  300. and ms.audit_status_cd = #{auditStatusCd}
  301. </if>
  302. <if test="communityId != null and communityId != ''">
  303. and ms.community_id = #{communityId}
  304. </if>
  305. <if test="page != -1 and page != null">
  306. limit #{page},#{row}
  307. </if>
  308. </select>
  309. <!-- 修改小区成员 add by wuxw 2018-07-03 -->
  310. <update id="updateCommunityMemberInstance" parameterType="Map">
  311. update s_community_member ms set ms.status_cd = #{statusCd}
  312. <if test="newBId != null and newBId != ''">
  313. ,ms.b_id = #{newBId}
  314. </if>
  315. <if test="auditStatusCd !=null and auditStatusCd !=''">
  316. ,ms.audit_status_cd = #{auditStatusCd}
  317. </if>
  318. where 1=1
  319. <if test="bId != null and bId !=''">
  320. and ms.b_id = #{bId}
  321. </if>
  322. <if test="communityMemberId != null and communityMemberId !=''">
  323. and ms.community_member_id = #{communityMemberId}
  324. </if>
  325. </update>
  326. <!-- 查询小区成员 add by wuxw 2018-07-03 -->
  327. <select id="getCommunityMemberCount" parameterType="Map" resultType="Map">
  328. select count(1) count
  329. from s_community_member ms
  330. <if test="needCommunityInfo == true">
  331. ,s_community sc,
  332. s_community_member msc
  333. </if>
  334. where 1=1
  335. <if test="needCommunityInfo == true">
  336. and sc.`community_id` = ms.`community_id`
  337. AND sc.`status_cd` = '0'
  338. and sc.state='1100'
  339. </if>
  340. <if test="statusCd != null and statusCd != ''">
  341. and ms.status_cd = #{statusCd}
  342. </if>
  343. <if test="bId != null and bId !=''">
  344. and ms.b_id = #{bId}
  345. </if>
  346. <if test="communityMemberId != null and communityMemberId !=''">
  347. and ms.community_member_id = #{communityMemberId}
  348. </if>
  349. <if test="memberId != null and memberId != '' and needCommunityInfo == true">
  350. AND ms.`community_id` = msc.`community_id`
  351. and msc.member_id = #{memberId}
  352. </if>
  353. <if test="memberId != null and memberId != '' and needCommunityInfo == false">
  354. and ms.member_id = #{memberId}
  355. </if>
  356. <if test="noAuditEnterCommunity == true">
  357. and ms.member_type_cd not in ('390001200003','390001200005','390001200000')
  358. </if>
  359. <if test="memberTypeCd != null and memberTypeCd != ''">
  360. and ms.member_type_cd = #{memberTypeCd}
  361. </if>
  362. <if test="auditStatusCd != null and auditStatusCd != ''">
  363. and ms.audit_status_cd = #{auditStatusCd}
  364. </if>
  365. <if test="communityId != null and communityId != ''">
  366. and ms.community_id = #{communityId}
  367. </if>
  368. </select>
  369. <!-- 查询小区信息 add by wuxw 2018-07-03 -->
  370. <select id="getCommunityInfoNew" parameterType="Map" resultType="Map">
  371. select t.address,t.nearby_landmarks,t.nearby_landmarks nearbyLandmarks,
  372. t.city_code,t.city_code cityCode,t.name,t.status_cd,t.status_cd statusCd,
  373. t.community_id,t.community_id communityId,t.b_id,t.b_id bId,t.map_y,t.map_y mapY,
  374. t.map_x,t.map_x mapX,t.state,(CASE
  375. WHEN t.state='1000'
  376. THEN '待审核'
  377. WHEN t.state = '1100'
  378. THEN '审核完成'
  379. ELSE
  380. '审核拒绝'
  381. END) stateName
  382. from s_community t
  383. <if test="memberId !=null and memberId !=''">
  384. ,s_community_member cm
  385. </if>
  386. where 1 =1
  387. <if test="address !=null and address != ''">
  388. and t.address= #{address}
  389. </if>
  390. <if test="nearbyLandmarks !=null and nearbyLandmarks != ''">
  391. and t.nearby_landmarks= #{nearbyLandmarks}
  392. </if>
  393. <if test="cityCode !=null and cityCode != ''">
  394. and t.city_code= #{cityCode}
  395. </if>
  396. <if test="name !=null and name != ''">
  397. and t.name= #{name}
  398. </if>
  399. <if test="statusCd !=null and statusCd != ''">
  400. and t.status_cd= #{statusCd}
  401. </if>
  402. <if test="communityId !=null and communityId != ''">
  403. and t.community_id= #{communityId}
  404. </if>
  405. <if test="bId !=null and bId != ''">
  406. and t.b_id= #{bId}
  407. </if>
  408. <if test="mapY !=null and mapY != ''">
  409. and t.map_y= #{mapY}
  410. </if>
  411. <if test="mapX !=null and mapX != ''">
  412. and t.map_x= #{mapX}
  413. </if>
  414. <if test="state !=null and state != ''">
  415. and t.state= #{state}
  416. </if>
  417. <if test="memberId !=null and memberId !=''">
  418. and cm.community_id = t.community_id
  419. and cm.member_id = #{memberId}
  420. and cm.status_cd = '0'
  421. </if>
  422. <if test="page != -1 and page != null ">
  423. limit #{page}, #{row}
  424. </if>
  425. </select>
  426. <!-- 查询小区数量 add by wuxw 2018-07-03 -->
  427. <select id="queryCommunitysCount" parameterType="Map" resultType="Map">
  428. select count(1) count
  429. from s_community t
  430. <if test="memberId !=null and memberId !=''">
  431. ,s_community_member cm
  432. </if>
  433. where 1 =1
  434. <if test="address !=null and address != ''">
  435. and t.address= #{address}
  436. </if>
  437. <if test="nearbyLandmarks !=null and nearbyLandmarks != ''">
  438. and t.nearby_landmarks= #{nearbyLandmarks}
  439. </if>
  440. <if test="cityCode !=null and cityCode != ''">
  441. and t.city_code= #{cityCode}
  442. </if>
  443. <if test="name !=null and name != ''">
  444. and t.name= #{name}
  445. </if>
  446. <if test="statusCd !=null and statusCd != ''">
  447. and t.status_cd= #{statusCd}
  448. </if>
  449. <if test="communityId !=null and communityId != ''">
  450. and t.community_id= #{communityId}
  451. </if>
  452. <if test="bId !=null and bId != ''">
  453. and t.b_id= #{bId}
  454. </if>
  455. <if test="mapY !=null and mapY != ''">
  456. and t.map_y= #{mapY}
  457. </if>
  458. <if test="mapX !=null and mapX != ''">
  459. and t.map_x= #{mapX}
  460. </if>
  461. <if test="state !=null and state != ''">
  462. and t.state= #{state}
  463. </if>
  464. <if test="memberId !=null and memberId !=''">
  465. and cm.community_id = t.community_id
  466. and cm.member_id = #{memberId}
  467. and cm.status_cd = '0'
  468. </if>
  469. </select>
  470. </mapper>