BaseDataStatisticsServiceDaoImplMapper.xml 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  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="baseDataStatisticsServiceDaoImpl">
  6. <!-- 查询房屋数 -->
  7. <select id="getRoomCount" parameterType="Map" resultType="Map">
  8. select count(1) count
  9. from building_room t
  10. inner join building_unit bu on t.unit_id = bu.unit_id and bu.status_cd = '0'
  11. inner join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  12. <if test="ownerId != null and ownerId != ''">
  13. inner join building_owner_room_rel borr on t.room_id = borr.room_id and borr.status_cd = '0'
  14. left join building_owner bo on borr.owner_id = bo.member_id and bo.status_cd = '0'
  15. </if>
  16. where 1=1
  17. and t.status_cd = '0'
  18. <if test="floorId != null and floorId != ''">
  19. and f.floor_id = #{floorId}
  20. </if>
  21. <if test="floorNum != null and floorNum != ''">
  22. and f.floor_num = #{floorNum}
  23. </if>
  24. <if test="unitNum != null and unitNum != ''">
  25. and bu.unit_num = #{unitNum}
  26. </if>
  27. <if test="roomNum != null and roomNum != ''">
  28. and t.room_num = #{roomNum}
  29. </if>
  30. <if test="roomNumLike !=null and roomNumLike != ''">
  31. and t.room_num like concat('%',#{roomNumLike},'%')
  32. </if>
  33. <if test="state !=null and state != ''">
  34. and t.state= #{state}
  35. </if>
  36. <if test="roomId != null and roomId != ''">
  37. and t.room_id = #{roomId}
  38. </if>
  39. <if test="communityId != null and communityId != ''">
  40. and t.community_id = #{communityId}
  41. </if>
  42. <if test="ownerId != null and ownerId != ''">
  43. and bo.owner_id = #{ownerId}
  44. </if>
  45. <if test="ownerName != null and ownerName != ''">
  46. and bo.`name` like concat('%',#{ownerName},'%')
  47. </if>
  48. <if test="link != null and link != ''">
  49. and bo.link = #{link}
  50. </if>
  51. </select>
  52. <!-- 查询单月欠费 -->
  53. <select id="getRoomInfo" parameterType="Map" resultType="Map">
  54. select t.fee_coefficient feeCoefficient,t.section,t.remark,t.user_id userId,
  55. t.room_id roomId,t.layer,t.built_up_area,t.built_up_area
  56. builtUpArea,t.room_num,t.room_num roomNum,t.unit_id,t.unit_id unitId,t.b_id,t.b_id
  57. bId,t.apartment,t.state,t.community_id,t.community_id communityId,t.room_type,t.room_type roomType,
  58. t.room_sub_type,t.room_rent,t.room_area,t.room_sub_type roomSubType,t.room_rent roomRent,t.room_area roomArea,
  59. f.floor_num floorNum,bu.unit_num unitNum,bo.name ownerName,bo.owner_id ownerId,bo.link
  60. from building_room t
  61. inner join building_unit bu on t.unit_id = bu.unit_id and bu.status_cd = '0'
  62. inner join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  63. inner join building_owner_room_rel borr on t.room_id = borr.room_id and borr.status_cd = '0'
  64. left join building_owner bo on borr.owner_id = bo.member_id and bo.status_cd = '0'
  65. where 1=1
  66. <if test="floorId != null and floorId != ''">
  67. and f.floor_id = #{floorId}
  68. </if>
  69. <if test="floorNum != null and floorNum != ''">
  70. and f.floor_num = #{floorNum}
  71. </if>
  72. <if test="unitNum != null and unitNum != ''">
  73. and bu.unit_num = #{unitNum}
  74. </if>
  75. <if test="roomNum != null and roomNum != ''">
  76. and t.room_num = #{roomNum}
  77. </if>
  78. <if test="roomNumLike !=null and roomNumLike != ''">
  79. and t.room_num like concat('%',#{roomNumLike},'%')
  80. </if>
  81. <if test="state !=null and state != ''">
  82. and t.state= #{state}
  83. </if>
  84. <if test="roomId != null and roomId != ''">
  85. and t.room_id = #{roomId}
  86. </if>
  87. <if test="communityId != null and communityId != ''">
  88. and t.community_id = #{communityId}
  89. </if>
  90. <if test="ownerId != null and ownerId != ''">
  91. and bo.owner_id = #{ownerId}
  92. </if>
  93. <if test="ownerName != null and ownerName != ''">
  94. and bo.`name` like concat('%',#{ownerName},'%')
  95. </if>
  96. <if test="link != null and link != ''">
  97. and bo.link = #{link}
  98. </if>
  99. order by t.create_time desc
  100. <if test="page != -1 and page != null">
  101. limit #{page},#{row}
  102. </if>
  103. </select>
  104. <select id="getReceivedRoomCount" parameterType="Map" resultType="Map">
  105. select count(1) count
  106. from
  107. (select t.room_id
  108. from building_room t
  109. inner join building_unit bu on t.unit_id = bu.unit_id and bu.status_cd = '0'
  110. inner join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  111. left join building_owner_room_rel borr on t.room_id = borr.room_id and borr.status_cd = '0'
  112. left join building_owner bo on borr.owner_id = bo.member_id and bo.status_cd = '0'
  113. inner join pay_fee pf on t.room_id = pf.payer_obj_id and pf.payer_obj_type = '3333' and pf.status_cd = '0'
  114. inner join pay_fee_detail pfd on pf.fee_id = pfd.fee_id and pfd.status_cd = '0'
  115. where 1=1
  116. <if test="startDate != null and startDate != ''">
  117. and pfd.create_time &gt;= #{startDate}
  118. and pfd.create_time &lt;= #{endDate}
  119. </if>
  120. and t.status_cd = '0'
  121. <if test="floorId != null and floorId != ''">
  122. and f.floor_id = #{floorId}
  123. </if>
  124. <if test="floorNum != null and floorNum != ''">
  125. and f.floor_num = #{floorNum}
  126. </if>
  127. <if test="unitNum != null and unitNum != ''">
  128. and bu.unit_num = #{unitNum}
  129. </if>
  130. <if test="roomNum != null and roomNum != ''">
  131. and t.room_num = #{roomNum}
  132. </if>
  133. <if test="roomNumLike !=null and roomNumLike != ''">
  134. and t.room_num like concat('%',#{roomNumLike},'%')
  135. </if>
  136. <if test="state !=null and state != ''">
  137. and t.state= #{state}
  138. </if>
  139. <if test="roomId != null and roomId != ''">
  140. and t.room_id = #{roomId}
  141. </if>
  142. <if test="communityId != null and communityId != ''">
  143. and t.community_id = #{communityId}
  144. </if>
  145. <if test="ownerId != null and ownerId != ''">
  146. and bo.owner_id = #{ownerId}
  147. </if>
  148. <if test="ownerName != null and ownerName != ''">
  149. and bo.`name` like concat('%',#{ownerName},'%')
  150. </if>
  151. <if test="link != null and link != ''">
  152. and bo.link = #{link}
  153. </if>
  154. group by t.room_id
  155. ) a
  156. </select>
  157. <!-- 查询单月欠费 -->
  158. <select id="getReceivedRoomInfo" parameterType="Map" resultType="Map">
  159. select a.* from (
  160. select t.fee_coefficient feeCoefficient,t.section,t.remark,t.user_id userId,
  161. t.room_id roomId,t.layer,t.built_up_area,t.built_up_area
  162. builtUpArea,t.room_num,t.room_num roomNum,t.unit_id,t.unit_id unitId,t.b_id,t.b_id
  163. bId,t.apartment,t.state,t.community_id,t.community_id communityId,t.room_type,t.room_type roomType,
  164. t.room_sub_type,t.room_rent,t.room_area,t.room_sub_type roomSubType,t.room_rent roomRent,t.room_area roomArea,
  165. f.floor_num floorNum,bu.unit_num unitNum,bo.name ownerName,bo.owner_id ownerId,bo.link
  166. from building_room t
  167. inner join building_unit bu on t.unit_id = bu.unit_id and bu.status_cd = '0'
  168. inner join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  169. inner join building_owner_room_rel borr on t.room_id = borr.room_id and borr.status_cd = '0'
  170. left join building_owner bo on borr.owner_id = bo.member_id and bo.status_cd = '0'
  171. inner join pay_fee pf on t.room_id = pf.payer_obj_id and pf.payer_obj_type = '3333' and pf.status_cd = '0'
  172. inner join pay_fee_detail pfd on pf.fee_id = pfd.fee_id and pfd.status_cd = '0'
  173. where 1=1
  174. <if test="startDate != null and startDate != ''">
  175. and pfd.create_time &gt;= #{startDate}
  176. and pfd.create_time &lt;= #{endDate}
  177. </if>
  178. <if test="floorId != null and floorId != ''">
  179. and f.floor_id = #{floorId}
  180. </if>
  181. <if test="floorNum != null and floorNum != ''">
  182. and f.floor_num = #{floorNum}
  183. </if>
  184. <if test="unitNum != null and unitNum != ''">
  185. and bu.unit_num = #{unitNum}
  186. </if>
  187. <if test="roomNum != null and roomNum != ''">
  188. and t.room_num = #{roomNum}
  189. </if>
  190. <if test="roomNumLike !=null and roomNumLike != ''">
  191. and t.room_num like concat('%',#{roomNumLike},'%')
  192. </if>
  193. <if test="state !=null and state != ''">
  194. and t.state= #{state}
  195. </if>
  196. <if test="roomId != null and roomId != ''">
  197. and t.room_id = #{roomId}
  198. </if>
  199. <if test="communityId != null and communityId != ''">
  200. and t.community_id = #{communityId}
  201. </if>
  202. <if test="ownerId != null and ownerId != ''">
  203. and bo.owner_id = #{ownerId}
  204. </if>
  205. <if test="ownerName != null and ownerName != ''">
  206. and bo.`name` like concat('%',#{ownerName},'%')
  207. </if>
  208. <if test="link != null and link != ''">
  209. and bo.link = #{link}
  210. </if>
  211. group by t.fee_coefficient ,t.section,t.remark,t.user_id ,
  212. t.room_id ,t.layer,t.built_up_area,t.room_num,t.unit_id,t.b_id,t.apartment,t.state,t.community_id,t.room_type,
  213. t.room_sub_type,t.room_rent,t.room_area,t.room_rent,t.room_area,
  214. f.floor_num ,bu.unit_num ,bo.name ,bo.owner_id ,bo.link
  215. order by t.create_time desc
  216. ) a
  217. <if test="page != -1 and page != null">
  218. limit #{page},#{row}
  219. </if>
  220. </select>
  221. <select id="getOweRoomCount" parameterType="Map" resultType="Map">
  222. select count(1) count
  223. from
  224. (select t.room_id
  225. from building_room t
  226. inner join building_unit bu on t.unit_id = bu.unit_id and bu.status_cd = '0'
  227. inner join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  228. left join building_owner_room_rel borr on t.room_id = borr.room_id and borr.status_cd = '0'
  229. left join building_owner bo on borr.owner_id = bo.member_id and bo.status_cd = '0'
  230. inner join report_owe_fee rof on t.room_id = rof.payer_obj_id and rof.payer_obj_type = '3333'
  231. where 1=1
  232. and rof.amount_owed > 0
  233. and t.status_cd = '0'
  234. <if test="floorId != null and floorId != ''">
  235. and f.floor_id = #{floorId}
  236. </if>
  237. <if test="floorNum != null and floorNum != ''">
  238. and f.floor_num = #{floorNum}
  239. </if>
  240. <if test="unitNum != null and unitNum != ''">
  241. and bu.unit_num = #{unitNum}
  242. </if>
  243. <if test="roomNum != null and roomNum != ''">
  244. and t.room_num = #{roomNum}
  245. </if>
  246. <if test="roomNumLike !=null and roomNumLike != ''">
  247. and t.room_num like concat('%',#{roomNumLike},'%')
  248. </if>
  249. <if test="state !=null and state != ''">
  250. and t.state= #{state}
  251. </if>
  252. <if test="roomId != null and roomId != ''">
  253. and t.room_id = #{roomId}
  254. </if>
  255. <if test="communityId != null and communityId != ''">
  256. and t.community_id = #{communityId}
  257. </if>
  258. <if test="ownerId != null and ownerId != ''">
  259. and bo.owner_id = #{ownerId}
  260. </if>
  261. <if test="ownerName != null and ownerName != ''">
  262. and bo.`name` like concat('%',#{ownerName},'%')
  263. </if>
  264. <if test="link != null and link != ''">
  265. and bo.link = #{link}
  266. </if>
  267. group by t.room_id
  268. ) a
  269. </select>
  270. <!-- 查询单月欠费 -->
  271. <select id="getOweRoomInfo" parameterType="Map" resultType="Map">
  272. select a.* from (
  273. select t.fee_coefficient feeCoefficient,t.section,t.remark,t.user_id userId,
  274. t.room_id roomId,t.layer,t.built_up_area,t.built_up_area
  275. builtUpArea,t.room_num,t.room_num roomNum,t.unit_id,t.unit_id unitId,t.b_id,t.b_id
  276. bId,t.apartment,t.state,t.community_id,t.community_id communityId,t.room_type,t.room_type roomType,
  277. t.room_sub_type,t.room_rent,t.room_area,t.room_sub_type roomSubType,t.room_rent roomRent,t.room_area roomArea,
  278. f.floor_num floorNum,bu.unit_num unitNum,bo.name ownerName,bo.owner_id ownerId,bo.link
  279. from building_room t
  280. inner join building_unit bu on t.unit_id = bu.unit_id and bu.status_cd = '0'
  281. inner join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
  282. left join building_owner_room_rel borr on t.room_id = borr.room_id and borr.status_cd = '0'
  283. left join building_owner bo on borr.owner_id = bo.member_id and bo.status_cd = '0'
  284. inner join report_owe_fee rof on t.room_id = rof.payer_obj_id and rof.payer_obj_type = '3333'
  285. where 1=1
  286. and rof.amount_owed > 0
  287. <if test="floorId != null and floorId != ''">
  288. and f.floor_id = #{floorId}
  289. </if>
  290. <if test="floorNum != null and floorNum != ''">
  291. and f.floor_num = #{floorNum}
  292. </if>
  293. <if test="unitNum != null and unitNum != ''">
  294. and bu.unit_num = #{unitNum}
  295. </if>
  296. <if test="roomNum != null and roomNum != ''">
  297. and t.room_num = #{roomNum}
  298. </if>
  299. <if test="roomNumLike !=null and roomNumLike != ''">
  300. and t.room_num like concat('%',#{roomNumLike},'%')
  301. </if>
  302. <if test="state !=null and state != ''">
  303. and t.state= #{state}
  304. </if>
  305. <if test="roomId != null and roomId != ''">
  306. and t.room_id = #{roomId}
  307. </if>
  308. <if test="communityId != null and communityId != ''">
  309. and t.community_id = #{communityId}
  310. </if>
  311. <if test="ownerId != null and ownerId != ''">
  312. and bo.owner_id = #{ownerId}
  313. </if>
  314. <if test="ownerName != null and ownerName != ''">
  315. and bo.`name` like concat('%',#{ownerName},'%')
  316. </if>
  317. <if test="link != null and link != ''">
  318. and bo.link = #{link}
  319. </if>
  320. group by t.fee_coefficient ,t.section,t.remark,t.user_id ,
  321. t.room_id ,t.layer,t.built_up_area,t.room_num,t.unit_id,t.b_id,t.apartment,t.state,t.community_id,t.room_type,
  322. t.room_sub_type,t.room_rent,t.room_area,t.room_rent,t.room_area,
  323. f.floor_num ,bu.unit_num ,bo.name ,bo.owner_id ,bo.link
  324. order by t.create_time desc
  325. ) a
  326. <if test="page != -1 and page != null">
  327. limit #{page},#{row}
  328. </if>
  329. </select>
  330. <select id="getCommunityFeeDetailCount" parameterType="Map" resultType="Map">
  331. select * from (
  332. select t.community_id communityId,count(1) count,SUM(t.received_amount) receivedAmount from pay_fee_detail t
  333. where t.status_cd = '0'
  334. and t.state in ('1000','1400','1200')
  335. <if test="communityIds !=null ">
  336. and t.community_id in
  337. <foreach collection="communityIds" item="item" open="(" close=")" separator=",">
  338. #{item}
  339. </foreach>
  340. </if>
  341. and t.create_time &gt;= #{startTime}
  342. and t.create_time &lt;= #{endTime}
  343. group by t.community_id
  344. ) a order by a.count desc limit 10
  345. </select>
  346. <select id="getCommunityRepairCount" parameterType="Map" resultType="Map">
  347. select * from (
  348. select t.community_id communityId,count(1) count from r_repair_pool t
  349. where t.status_cd = '0'
  350. <if test="communityIds !=null ">
  351. and t.community_id in
  352. <foreach collection="communityIds" item="item" open="(" close=")" separator=",">
  353. #{item}
  354. </foreach>
  355. </if>
  356. and t.create_time &gt;= #{startTime}
  357. and t.create_time &lt;= #{endTime}
  358. group by t.community_id
  359. ) a order by a.count desc limit 10
  360. </select>
  361. <select id="getCommunityFeeDetailCountAnalysis" parameterType="Map" resultType="Map">
  362. select DATE_FORMAT(t.create_time,'%Y-%m-%d') createTime,count(1) countValue
  363. from pay_fee_detail t
  364. where 1=1
  365. and t.state in ('1000','1400','1200')
  366. and t.create_time &gt; #{startTime}
  367. and t.create_time &lt; #{endTime}
  368. and t.community_id = #{communityId}
  369. group by DATE_FORMAT(t.create_time,'%Y-%m-%d')
  370. </select>
  371. <select id="getCommunityRepairCountAnalysis" parameterType="Map" resultType="Map">
  372. select DATE_FORMAT(t.create_time,'%Y-%m-%d') createTime,count(1) countValue
  373. from r_repair_pool t
  374. where 1=1
  375. and t.status_cd = '0'
  376. and t.create_time &gt; #{startTime}
  377. and t.create_time &lt; #{endTime}
  378. and t.community_id = #{communityId}
  379. group by DATE_FORMAT(t.create_time,'%Y-%m-%d')
  380. </select>
  381. <select id="getCommunityInspectionAnalysis" parameterType="Map" resultType="Map">
  382. select DATE_FORMAT(t.create_time,'%Y-%m-%d') createTime,count(1) countValue
  383. from inspection_task t
  384. where 1=1
  385. and t.status_cd = '0'
  386. and t.state in ('20200406','20200407')
  387. and t.create_time &gt; #{startTime}
  388. and t.create_time &lt; #{endTime}
  389. and t.community_id = #{communityId}
  390. group by DATE_FORMAT(t.create_time,'%Y-%m-%d')
  391. </select>
  392. <select id="getCommunityMaintainanceAnalysis" parameterType="Map" resultType="Map">
  393. select DATE_FORMAT(t.create_time,'%Y-%m-%d') createTime,count(1) countValue
  394. from maintainance_task t
  395. where 1=1
  396. and t.status_cd = '0'
  397. and t.state in ('20200406','20200407')
  398. and t.create_time &gt; #{startTime}
  399. and t.create_time &lt; #{endTime}
  400. and t.community_id = #{communityId}
  401. group by DATE_FORMAT(t.create_time,'%Y-%m-%d')
  402. </select>
  403. <select id="getCommunityItemInAnalysis" parameterType="Map" resultType="Map">
  404. select DATE_FORMAT(t.create_time,'%Y-%m-%d') createTime,count(1) countValue
  405. from purchase_apply t
  406. where 1=1
  407. and t.res_order_type = '10000'
  408. and t.status_cd = '0'
  409. and t.create_time &gt; #{startTime}
  410. and t.create_time &lt; #{endTime}
  411. and t.community_id = #{communityId}
  412. group by DATE_FORMAT(t.create_time,'%Y-%m-%d')
  413. </select>
  414. <select id="getCommunityItemOutAnalysis" parameterType="Map" resultType="Map">
  415. select DATE_FORMAT(t.create_time,'%Y-%m-%d') createTime,count(1) countValue
  416. from purchase_apply t
  417. where 1=1
  418. and t.res_order_type = '20000'
  419. and t.status_cd = '0'
  420. and t.create_time &gt; #{startTime}
  421. and t.create_time &lt; #{endTime}
  422. and t.community_id = #{communityId}
  423. group by DATE_FORMAT(t.create_time,'%Y-%m-%d')
  424. </select>
  425. <select id="getCommunityCarInAnalysis" parameterType="Map" resultType="Map">
  426. select DATE_FORMAT(t.create_time,'%Y-%m-%d') createTime,count(1) countValue
  427. from car_inout t
  428. where 1=1
  429. and t.status_cd = '0'
  430. and t.create_time &gt; #{startTime}
  431. and t.create_time &lt; #{endTime}
  432. and t.community_id = #{communityId}
  433. group by DATE_FORMAT(t.create_time,'%Y-%m-%d')
  434. </select>
  435. <select id="getCommunityPersonInAnalysis" parameterType="Map" resultType="Map">
  436. select DATE_FORMAT(t.create_time,'%Y-%m-%d') createTime,count(1) countValue
  437. from machine_record t
  438. where 1=1
  439. and t.status_cd = '0'
  440. and t.create_time &gt; #{startTime}
  441. and t.create_time &lt; #{endTime}
  442. and t.community_id = #{communityId}
  443. group by DATE_FORMAT(t.create_time,'%Y-%m-%d')
  444. </select>
  445. <select id="getCommunityContractAnalysis" parameterType="Map" resultType="Map">
  446. select DATE_FORMAT(t.create_time,'%Y-%m-%d') createTime,count(1) countValue
  447. from contract t
  448. where 1=1
  449. and t.status_cd = '0'
  450. and t.create_time &gt; #{startTime}
  451. and t.create_time &lt; #{endTime}
  452. and t.community_id = #{communityId}
  453. group by DATE_FORMAT(t.create_time,'%Y-%m-%d')
  454. </select>
  455. </mapper>