OwnerCarServiceDaoImplMapper.xml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  4. <mapper namespace="ownerCarServiceDaoImpl">
  5. <!-- 保存车辆管理信息 add by wuxw 2018-07-03 -->
  6. <insert id="saveBusinessOwnerCarInfo" parameterType="Map">
  7. insert into business_owner_car(car_color, car_brand, car_type, operate, car_num, ps_id, remark, owner_id, b_id,
  8. user_id, car_id, community_id, start_time,
  9. end_time, state, car_type_cd, member_id)
  10. values (#{carColor}, #{carBrand}, #{carType}, #{operate}, #{carNum}, #{psId}, #{remark}, #{ownerId}, #{bId},
  11. #{userId}, #{carId}, #{communityId},
  12. #{startTime}, #{endTime}, #{state}, #{carTypeCd}, #{memberId})
  13. </insert>
  14. <!-- 查询车辆管理信息(Business) add by wuxw 2018-07-03 -->
  15. <select id="getBusinessOwnerCarInfo" parameterType="Map" resultType="Map">
  16. select t.car_color,t.car_color carColor,t.car_brand,t.car_brand carBrand,t.car_type,t.car_type
  17. carType,t.operate,t.car_num,t.car_num carNum,t.ps_id,t.ps_id psId,t.remark,t.owner_id,t.owner_id
  18. ownerId,t.b_id,t.b_id bId,t.user_id,t.user_id userId,t.car_id,t.car_id carId,t.community_id,t.community_id
  19. communityId,t.start_time,t.end_time,t.state,t.start_time startTime,t.end_time endTime,t.car_type_cd,
  20. t.car_type_cd carTypeCd,t.member_id,t.member_id memberId,t.lease_type leaseType
  21. from business_owner_car t
  22. where 1 =1
  23. <if test="carColor !=null and carColor != ''">
  24. and t.car_color= #{carColor}
  25. </if>
  26. <if test="carBrand !=null and carBrand != ''">
  27. and t.car_brand= #{carBrand}
  28. </if>
  29. <if test="carType !=null and carType != ''">
  30. and t.car_type= #{carType}
  31. </if>
  32. <if test="carTypeCd !=null and carTypeCd != ''">
  33. and t.car_type_cd= #{carTypeCd}
  34. </if>
  35. <if test="operate !=null and operate != ''">
  36. and t.operate= #{operate}
  37. </if>
  38. <if test="carNum !=null and carNum != ''">
  39. and t.car_num= #{carNum}
  40. </if>
  41. <if test="psId !=null and psId != ''">
  42. and t.ps_id= #{psId}
  43. </if>
  44. <if test="remark !=null and remark != ''">
  45. and t.remark= #{remark}
  46. </if>
  47. <if test="ownerId !=null and ownerId != ''">
  48. and t.owner_id= #{ownerId}
  49. </if>
  50. <if test="leaseType !=null and leaseType != ''">
  51. and t.lease_type= #{leaseType}
  52. </if>
  53. <if test="bId !=null and bId != ''">
  54. and t.b_id= #{bId}
  55. </if>
  56. <if test="userId !=null and userId != ''">
  57. and t.user_id= #{userId}
  58. </if>
  59. <if test="carId !=null and carId != ''">
  60. and t.car_id= #{carId}
  61. </if>
  62. <if test="memberId !=null and memberId != ''">
  63. and t.member_id= #{memberId}
  64. </if>
  65. <if test="communityId !=null and communityId != ''">
  66. and t.community_id= #{communityId}
  67. </if>
  68. </select>
  69. <!-- 保存车辆管理信息至 instance表中 add by wuxw 2018-07-03 -->
  70. <insert id="saveOwnerCarInfoInstance" parameterType="Map">
  71. insert into owner_car(
  72. car_color,car_brand,car_type,car_num,ps_id,remark,status_cd,owner_id,b_id,user_id,car_id,community_id,
  73. start_time,end_time,state,car_type_cd,member_id
  74. ) select
  75. t.car_color,t.car_brand,t.car_type,t.car_num,t.ps_id,t.remark,'0',t.owner_id,t.b_id,t.user_id,t.car_id,t.community_id,
  76. t.start_time,t.end_time,t.state, t.car_type_cd,t.member_id
  77. from business_owner_car t where 1=1
  78. <if test="carColor !=null and carColor != ''">
  79. and t.car_color= #{carColor}
  80. </if>
  81. <if test="carBrand !=null and carBrand != ''">
  82. and t.car_brand= #{carBrand}
  83. </if>
  84. <if test="carType !=null and carType != ''">
  85. and t.car_type= #{carType}
  86. </if>
  87. <if test="carTypeCd !=null and carTypeCd != ''">
  88. and t.car_type_cd= #{carTypeCd}
  89. </if>
  90. and t.operate= 'ADD'
  91. <if test="carNum !=null and carNum != ''">
  92. and t.car_num= #{carNum}
  93. </if>
  94. <if test="psId !=null and psId != ''">
  95. and t.ps_id= #{psId}
  96. </if>
  97. <if test="remark !=null and remark != ''">
  98. and t.remark= #{remark}
  99. </if>
  100. <if test="ownerId !=null and ownerId != ''">
  101. and t.owner_id= #{ownerId}
  102. </if>
  103. <if test="bId !=null and bId != ''">
  104. and t.b_id= #{bId}
  105. </if>
  106. <if test="userId !=null and userId != ''">
  107. and t.user_id= #{userId}
  108. </if>
  109. <if test="carId !=null and carId != ''">
  110. and t.car_id= #{carId}
  111. </if>
  112. <if test="memberId !=null and memberId != ''">
  113. and t.member_id= #{memberId}
  114. </if>
  115. <if test="communityId !=null and communityId != ''">
  116. and t.community_id= #{communityId}
  117. </if>
  118. </insert>
  119. <!-- 查询车辆管理信息 add by wuxw 2018-07-03 -->
  120. <select id="getOwnerCarInfo" parameterType="Map" resultType="Map">
  121. select t.car_color,t.car_color carColor,t.car_brand,t.car_brand carBrand,t.car_type,t.car_type carType,t1.name
  122. carTypeName,
  123. t.car_num,t.car_num carNum,t.ps_id,t.ps_id psId,t.remark,t.status_cd,t.status_cd statusCd,t.owner_id,
  124. t.owner_id ownerId,t.b_id,t.b_id bId,t.user_id,t.user_id userId,t.car_id,t.car_id carId ,t.create_time
  125. createTime,t.community_id communityId,bow.name ownerName,bow.id_card idCard,bow.link,t2.name stateName,
  126. t.start_time,t.start_time startTime,t.end_time,t.end_time endTime,t.state,
  127. t.car_type_cd,t.car_type_cd carTypeCd,t.member_id,t.member_id memberId,ps.num,pa.num areaNum,pa.pa_id paId,t.lease_type
  128. leaseType,
  129. t3.name leaseTypeName,t4.name carTypeCdName
  130. <if test="carTypeCd != '1003'">
  131. ,count(moc.member_id) memberCarCount
  132. </if>
  133. from owner_car t
  134. left join t_dict t1 on t.car_type=t1.status_cd and t1.table_name='owner_car' and t1.table_columns = 'car_type'
  135. left join t_dict t2 on t.state=t2.status_cd and t2.table_name='owner_car' and t2.table_columns = 'state'
  136. left join t_dict t4 on t.car_type_cd=t4.status_cd and t4.table_name='owner_car' and t4.table_columns =
  137. 'car_type_cd'
  138. left join building_owner bow on t.owner_id = bow.member_id and bow.status_cd = '0' and bow.community_id =
  139. t.community_id
  140. left join parking_space ps on t.ps_id = ps.ps_id and ps.status_cd = '0'
  141. left join parking_area pa on ps.pa_id = pa.pa_id and pa.status_cd = '0'
  142. left join t_dict t3 on t.lease_type = t3.status_cd and t3.table_name = 'owner_car' and t3.table_columns =
  143. 'lease_type'
  144. <if test="carTypeCd != '1003'">
  145. left join owner_car moc on t.car_id = moc.car_id and moc.car_type_cd != t.car_type_cd and moc.car_type_cd =
  146. '1002' and moc.status_cd = '0'
  147. </if>
  148. where 1=1
  149. <if test="statusCd !=null and statusCd != ''">
  150. and t.status_cd = #{statusCd}
  151. </if>
  152. <if test="carColor !=null and carColor != ''">
  153. and t.car_color= #{carColor}
  154. </if>
  155. <if test="carBrand !=null and carBrand != ''">
  156. and t.car_brand= #{carBrand}
  157. </if>
  158. <if test="carType !=null and carType != ''">
  159. and t.car_type= #{carType}
  160. </if>
  161. <if test="carTypeCd !=null and carTypeCd != ''">
  162. and t.car_type_cd= #{carTypeCd}
  163. </if>
  164. <if test="carTypeCds !=null">
  165. and t.car_type_cd in
  166. <foreach collection="carTypeCds" item="item" index="index" open="(" close=")" separator=",">
  167. #{item}
  168. </foreach>
  169. </if>
  170. <if test="paIds !=null">
  171. and pa.pa_id in
  172. <foreach collection="paIds" item="item" index="index" open="(" close=")" separator=",">
  173. #{item}
  174. </foreach>
  175. </if>
  176. <if test="carNum !=null and carNum != ''">
  177. and t.car_num= #{carNum}
  178. </if>
  179. <if test="carNumLike !=null and carNumLike != ''">
  180. and t.car_num like concat('%',#{carNumLike},'%')
  181. </if>
  182. <if test="memberCarNum !=null and memberCarNum != '' and carTypeCd != '1003'">
  183. and moc.car_num= #{memberCarNum}
  184. </if>
  185. <if test="memberCarNumLike !=null and memberCarNumLike != '' and carTypeCd != '1003' ">
  186. and moc.car_num like concat('%',#{memberCarNumLike},'%')
  187. </if>
  188. <if test="carNums !=null">
  189. and t.car_num in
  190. <foreach collection="carNums" item="item" index="index" open="(" close=")" separator=",">
  191. #{item}
  192. </foreach>
  193. </if>
  194. <if test="psId !=null and psId != ''">
  195. and t.ps_id= #{psId}
  196. </if>
  197. <if test="psIds !=null">
  198. and t.ps_id in
  199. <foreach collection="psIds" item="item" index="index" open="(" close=")" separator=",">
  200. #{item}
  201. </foreach>
  202. </if>
  203. <if test="remark !=null and remark != ''">
  204. and t.remark= #{remark}
  205. </if>
  206. <if test="statusCd !=null and statusCd != ''">
  207. and t.status_cd= #{statusCd}
  208. </if>
  209. <if test="ownerId !=null and ownerId != ''">
  210. and t.owner_id= #{ownerId}
  211. </if>
  212. <if test="leaseType !=null and leaseType != ''">
  213. and t.lease_type= #{leaseType}
  214. </if>
  215. <if test="ownerName !=null and ownerName != ''">
  216. and bow.name like '%${ownerName}%'
  217. </if>
  218. <if test="link !=null and link != ''">
  219. and bow.link = #{link}
  220. </if>
  221. <if test="bId !=null and bId != ''">
  222. and t.b_id= #{bId}
  223. </if>
  224. <if test="carId !=null and carId != ''">
  225. and t.car_id= #{carId}
  226. </if>
  227. <if test="memberId !=null and memberId != ''">
  228. and t.member_id= #{memberId}
  229. </if>
  230. <if test="memberIds !=null">
  231. and t.member_id in
  232. <foreach collection="memberIds" item="item" index="index" open="(" close=")" separator=",">
  233. #{item}
  234. </foreach>
  235. </if>
  236. <if test="carIds !=null">
  237. and t.car_id in
  238. <foreach collection="carIds" item="item" index="index" open="(" close=")" separator=",">
  239. #{item}
  240. </foreach>
  241. </if>
  242. <if test="communityId !=null and communityId != ''">
  243. and t.community_id= #{communityId}
  244. </if>
  245. <if test="state !=null and state != ''">
  246. and t.state= #{state}
  247. </if>
  248. <if test="valid == 1">
  249. and t.end_time &gt; now()
  250. and t.state != '3003'
  251. </if>
  252. <if test="valid == 3">
  253. and (t.end_time &lt; now() or t.state = '3003')
  254. </if>
  255. <if test="valid == 2">
  256. and t.ps_id= '-1'
  257. </if>
  258. <if test="carTypeCd != '1003'">
  259. GROUP BY t.car_color,t.car_brand,t.car_type,t1.name,
  260. t.car_num,t.ps_id,t.remark,t.status_cd,t.owner_id,
  261. t.b_id,t.user_id,t.car_id,t.create_time
  262. ,t.community_id ,bow.name,bow.id_card ,bow.link,t2.name,t.start_time,t.end_time,t.state,
  263. t.car_type_cd,t.member_id,ps.num,t.lease_type ,
  264. t3.name ,t4.name
  265. </if>
  266. order by t.create_time desc
  267. <if test="page != -1 and page != null ">
  268. limit #{page}, #{row}
  269. </if>
  270. </select>
  271. <!-- 修改车辆管理信息 add by wuxw 2018-07-03 -->
  272. <update id="updateOwnerCarInfoInstance" parameterType="Map">
  273. update owner_car t set t.status_cd = #{statusCd}
  274. <if test="newBId != null and newBId != ''">
  275. ,t.b_id = #{newBId}
  276. </if>
  277. <if test="carColor !=null and carColor != ''">
  278. , t.car_color= #{carColor}
  279. </if>
  280. <if test="carBrand !=null and carBrand != ''">
  281. , t.car_brand= #{carBrand}
  282. </if>
  283. <if test="carType !=null and carType != ''">
  284. , t.car_type= #{carType}
  285. </if>
  286. <if test="carNum !=null and carNum != ''">
  287. , t.car_num= #{carNum}
  288. </if>
  289. <if test="psId !=null and psId != ''">
  290. , t.ps_id= #{psId}
  291. </if>
  292. <if test="remark !=null and remark != ''">
  293. , t.remark= #{remark}
  294. </if>
  295. <if test="ownerId !=null and ownerId != ''">
  296. , t.owner_id= #{ownerId}
  297. </if>
  298. <if test="leaseType !=null and leaseType != ''">
  299. , t.lease_type= #{leaseType}
  300. </if>
  301. <if test="userId !=null and userId != ''">
  302. , t.user_id= #{userId}
  303. </if>
  304. <if test="startTime !=null ">
  305. , t.start_time= #{startTime}
  306. </if>
  307. <if test="endTime !=null ">
  308. , t.end_time= #{endTime}
  309. </if>
  310. <if test="state !=null ">
  311. , t.state= #{state}
  312. </if>
  313. where 1=1
  314. <if test="bId !=null and bId != ''">
  315. and t.b_id= #{bId}
  316. </if>
  317. <if test="carId !=null and carId != ''">
  318. and t.car_id= #{carId}
  319. </if>
  320. <if test="memberId !=null and memberId != ''">
  321. and t.member_id= #{memberId}
  322. </if>
  323. <if test="communityId !=null and communityId != ''">
  324. and t.community_id= #{communityId}
  325. </if>
  326. <if test="carTypeCd !=null and carTypeCd != ''">
  327. and t.car_type_cd= #{carTypeCd}
  328. </if>
  329. </update>
  330. <!-- 查询车辆管理数量 add by wuxw 2018-07-03 -->
  331. <select id="queryOwnerCarsCount" parameterType="Map" resultType="Map">
  332. select count(1) count
  333. from owner_car t
  334. left join building_owner bow on t.owner_id = bow.member_id and bow.status_cd = '0' and bow.community_id =
  335. t.community_id
  336. left join parking_space ps on t.ps_id = ps.ps_id and ps.status_cd = '0'
  337. left join parking_area pa on ps.pa_id = pa.pa_id and pa.status_cd = '0'
  338. <if test="memberCarNumLike !=null and memberCarNumLike != ''">
  339. left join owner_car moc on t.car_id = moc.car_id and moc.car_type_cd != t.car_type_cd and moc.car_type_cd =
  340. '1002'
  341. </if>
  342. where 1=1
  343. <if test="statusCd !=null and statusCd != ''">
  344. and t.status_cd = #{statusCd}
  345. </if>
  346. <if test="carColor !=null and carColor != ''">
  347. and t.car_color= #{carColor}
  348. </if>
  349. <if test="carBrand !=null and carBrand != ''">
  350. and t.car_brand= #{carBrand}
  351. </if>
  352. <if test="carType !=null and carType != ''">
  353. and t.car_type= #{carType}
  354. </if>
  355. <if test="carTypeCd !=null and carTypeCd != ''">
  356. and t.car_type_cd= #{carTypeCd}
  357. </if>
  358. <if test="carTypeCds !=null">
  359. and t.car_type_cd in
  360. <foreach collection="carTypeCds" item="item" index="index" open="(" close=")" separator=",">
  361. #{item}
  362. </foreach>
  363. </if>
  364. <if test="carNum !=null and carNum != ''">
  365. and t.car_num= #{carNum}
  366. </if>
  367. <if test="carNumLike !=null and carNumLike != ''">
  368. and t.car_num like concat('%',#{carNumLike},'%')
  369. </if>
  370. <if test="memberCarNum !=null and memberCarNum != ''">
  371. and moc.car_num= #{memberCarNum}
  372. </if>
  373. <if test="memberCarNumLike !=null and memberCarNumLike != ''">
  374. and moc.car_num like concat('%',#{memberCarNumLike},'%')
  375. </if>
  376. <if test="carNums !=null">
  377. and t.car_num in
  378. <foreach collection="carNums" item="item" index="index" open="(" close=")" separator=",">
  379. #{item}
  380. </foreach>
  381. </if>
  382. <if test="psId !=null and psId != ''">
  383. and t.ps_id= #{psId}
  384. </if>
  385. <if test="remark !=null and remark != ''">
  386. and t.remark= #{remark}
  387. </if>
  388. <if test="statusCd !=null and statusCd != ''">
  389. and t.status_cd= #{statusCd}
  390. </if>
  391. <if test="ownerId !=null and ownerId != ''">
  392. and t.owner_id= #{ownerId}
  393. </if>
  394. <if test="leaseType !=null and leaseType != ''">
  395. and t.lease_type= #{leaseType}
  396. </if>
  397. <if test="ownerName !=null and ownerName != ''">
  398. and bow.name like '%${ownerName}%'
  399. </if>
  400. <if test="link !=null and link != ''">
  401. and bow.link = #{link}
  402. </if>
  403. <if test="bId !=null and bId != ''">
  404. and t.b_id= #{bId}
  405. </if>
  406. <if test="carId !=null and carId != ''">
  407. and t.car_id= #{carId}
  408. </if>
  409. <if test="memberId !=null and memberId != ''">
  410. and t.member_id= #{memberId}
  411. </if>
  412. <if test="memberIds !=null">
  413. and t.member_id in
  414. <foreach collection="memberIds" item="item" index="index" open="(" close=")" separator=",">
  415. #{item}
  416. </foreach>
  417. </if>
  418. <if test="carIds !=null">
  419. and t.car_id in
  420. <foreach collection="carIds" item="item" index="index" open="(" close=")" separator=",">
  421. #{item}
  422. </foreach>
  423. </if>
  424. <if test="paIds !=null">
  425. and pa.pa_id in
  426. <foreach collection="paIds" item="item" index="index" open="(" close=")" separator=",">
  427. #{item}
  428. </foreach>
  429. </if>
  430. <if test="communityId !=null and communityId != ''">
  431. and t.community_id= #{communityId}
  432. </if>
  433. <if test="state !=null and state != ''">
  434. and t.state= #{state}
  435. </if>
  436. <if test="valid == 1">
  437. and t.end_time &gt; now()
  438. and t.state != '3003'
  439. </if>
  440. <if test="valid == 3">
  441. and (t.end_time &lt; now() or t.state = '3003')
  442. </if>
  443. <if test="valid == 2">
  444. and t.ps_id= '-1'
  445. </if>
  446. </select>
  447. <select id="queryOwnerParkingSpaceCount" parameterType="Map" resultType="Map">
  448. select count(DISTINCT t.ps_id) count
  449. from owner_car t
  450. where
  451. t.ps_id != '-1'
  452. <if test="statusCd !=null and statusCd != ''">
  453. and t.status_cd= #{statusCd}
  454. </if>
  455. <if test="ownerId !=null and ownerId != ''">
  456. and t.owner_id= #{ownerId}
  457. </if>
  458. <if test="communityId !=null and communityId != ''">
  459. and t.community_id= #{communityId}
  460. </if>
  461. </select>
  462. </mapper>