RepairServiceDaoImplMapper.xml 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  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="repairServiceDaoImpl">
  6. <!-- 保存报修信息信息 add by wuxw 2018-07-03 -->
  7. <insert id="saveBusinessRepairInfo" parameterType="Map">
  8. insert into business_repair_pool(
  9. operate,repair_name,appointment_time,repair_type,context,repair_id,tel,state,community_id,b_id,repair_obj_type,repair_obj_id,repair_obj_name
  10. ) values (
  11. #{operate},#{repairName},#{appointmentTime},#{repairType},#{context},#{repairId},#{tel},#{state},#{communityId},#{bId},
  12. #{repairObjType},#{repairObjId},#{repairObjName}
  13. )
  14. </insert>
  15. <!-- 查询报修信息信息(Business) add by wuxw 2018-07-03 -->
  16. <select id="getBusinessRepairInfo" parameterType="Map" resultType="Map">
  17. select t.operate,t.repair_name,t.repair_name repairName,t.appointment_time,t.appointment_time
  18. appointmentTime,t.repair_type,t.repair_type repairType,t.context,t.repair_id,t.repair_id
  19. repairId,t.tel,t.state,t.community_id,t.community_id communityId,t.b_id,t.b_id bId,
  20. t.repair_obj_type,t.repair_obj_id,t.repair_obj_name,t.repair_obj_type repairObjType,t.repair_obj_id
  21. repairObjId,t.repair_obj_name repairObjName
  22. from business_repair_pool t
  23. where 1 =1
  24. <if test="operate !=null and operate != ''">
  25. and t.operate= #{operate}
  26. </if>
  27. <if test="repairName !=null and repairName != ''">
  28. and t.repair_name= #{repairName}
  29. </if>
  30. <if test="appointmentTime !=null">
  31. and t.appointment_time= #{appointmentTime}
  32. </if>
  33. <if test="repairType !=null and repairType != ''">
  34. and t.repair_type= #{repairType}
  35. </if>
  36. <if test="context !=null and context != ''">
  37. and t.context= #{context}
  38. </if>
  39. <if test="repairId !=null and repairId != ''">
  40. and t.repair_id= #{repairId}
  41. </if>
  42. <if test="tel !=null and tel != ''">
  43. and t.tel= #{tel}
  44. </if>
  45. <if test="state !=null and state != ''">
  46. and t.state= #{state}
  47. </if>
  48. <if test="communityId !=null and communityId != ''">
  49. and t.community_id= #{communityId}
  50. </if>
  51. <if test="bId !=null and bId != ''">
  52. and t.b_id= #{bId}
  53. </if>
  54. </select>
  55. <!-- 保存报修信息信息至 instance表中 add by wuxw 2018-07-03 -->
  56. <insert id="saveRepairInfoInstance" parameterType="Map">
  57. insert into r_repair_pool(
  58. repair_name,appointment_time,repair_type,context,repair_id,tel,status_cd,state,community_id,b_id,
  59. repair_obj_type,repair_obj_id,repair_obj_name
  60. ) select
  61. t.repair_name,t.appointment_time,t.repair_type,t.context,t.repair_id,t.tel,'0',t.state,t.community_id,t.b_id,
  62. t.repair_obj_type,t.repair_obj_id,t.repair_obj_name
  63. from business_repair_pool t where 1=1
  64. and t.operate= 'ADD'
  65. <if test="repairName !=null and repairName != ''">
  66. and t.repair_name= #{repairName}
  67. </if>
  68. <if test="appointmentTime !=null ">
  69. and t.appointment_time= #{appointmentTime}
  70. </if>
  71. <if test="repairType !=null and repairType != ''">
  72. and t.repair_type= #{repairType}
  73. </if>
  74. <if test="context !=null and context != ''">
  75. and t.context= #{context}
  76. </if>
  77. <if test="repairId !=null and repairId != ''">
  78. and t.repair_id= #{repairId}
  79. </if>
  80. <if test="tel !=null and tel != ''">
  81. and t.tel= #{tel}
  82. </if>
  83. <if test="state !=null and state != ''">
  84. and t.state= #{state}
  85. </if>
  86. <if test="communityId !=null and communityId != ''">
  87. and t.community_id= #{communityId}
  88. </if>
  89. <if test="bId !=null and bId != ''">
  90. and t.b_id= #{bId}
  91. </if>
  92. </insert>
  93. <!-- 查询报修信息信息 add by wuxw 2018-07-03 -->
  94. <select id="getRepairInfo" parameterType="Map" resultType="Map">
  95. select t.repair_name,t.repair_name repairName,t.appointment_time,t.appointment_time
  96. appointmentTime,t.repair_type,t.repair_type repairType,t.context,t.repair_id,t.repair_id
  97. repairId,t.tel,t.status_cd,t.status_cd statusCd,t.state,t.community_id,t.community_id communityId,t.b_id,t.b_id
  98. bId,
  99. d.name stateName,
  100. rs.repair_type_name repairTypeName,rs.repair_way repairWay,rs.return_visit_flag returnVisitFlag,
  101. t.repair_obj_type,t.repair_obj_id,t.repair_obj_name,t.repair_obj_type repairObjType,t.repair_obj_id repairObjId,
  102. t.repair_obj_name repairObjName
  103. <if test="staffId != null and staffId != ''">
  104. ,rru.state repairDispatchState,rru.context repairDispatchContext,td.name repairDispatchStateName
  105. </if>
  106. from r_repair_pool t
  107. left join t_dict d on t.state = d.status_cd and d.table_name = 'r_repair_pool' and d.table_columns = 'state'
  108. left join r_repair_setting rs on rs.repair_type = t.repair_type and rs.status_cd = '0'
  109. <if test="staffId != null and staffId != ''">
  110. ,r_repair_user rru
  111. ,t_dict td
  112. </if>
  113. where 1 =1
  114. <if test="staffId != null and staffId != ''">
  115. and t.repair_id = rru.repair_id
  116. and rru.user_id = #{staffId}
  117. and rru.status_cd = '0'
  118. and td.`table_name` = 'r_repair_user'
  119. AND td.`table_columns` = 'state'
  120. AND td.`status_cd` = rru.state
  121. </if>
  122. <if test="repairWay !=null and repairWay != ''">
  123. and rs.repair_way= #{repairWay}
  124. </if>
  125. <if test="returnVisitFlag !=null and returnVisitFlag != ''">
  126. and rs.return_visit_flag in ('001','002')
  127. </if>
  128. <if test="repairName !=null and repairName != ''">
  129. and t.repair_name like '%${repairName}%'
  130. </if>
  131. <if test="appointmentTime !=null ">
  132. and t.appointment_time= #{appointmentTime}
  133. </if>
  134. <if test="repairType !=null and repairType != ''">
  135. and t.repair_type= #{repairType}
  136. </if>
  137. <if test="context !=null and context != ''">
  138. and t.context= #{context}
  139. </if>
  140. <if test="repairId !=null and repairId != ''">
  141. and t.repair_id= #{repairId}
  142. </if>
  143. <if test="tel !=null and tel != ''">
  144. and t.tel= #{tel}
  145. </if>
  146. <if test="statusCd !=null and statusCd != ''">
  147. and t.status_cd= #{statusCd}
  148. </if>
  149. <if test="state !=null and state != ''">
  150. and t.state= #{state}
  151. </if>
  152. <if test="statess !=null">
  153. and t.state in
  154. <foreach collection="statess" item="item" open="(" close=")" separator=",">
  155. #{item}
  156. </foreach>
  157. </if>
  158. <if test="communityId !=null and communityId != ''">
  159. and t.community_id= #{communityId}
  160. </if>
  161. <if test="bId !=null and bId != ''">
  162. and t.b_id= #{bId}
  163. </if>
  164. <if test="repairObjType !=null and repairObjType != ''">
  165. and t.repair_obj_type= #{repairObjType}
  166. </if>
  167. <if test="repairObjId !=null and repairObjId != ''">
  168. and t.repair_obj_id= #{repairObjId}
  169. </if>
  170. order by t.create_time desc
  171. <if test="page != -1 and page != null ">
  172. limit #{page}, #{row}
  173. </if>
  174. </select>
  175. <!-- 修改报修信息信息 add by wuxw 2018-07-03 -->
  176. <update id="updateRepairInfoInstance" parameterType="Map">
  177. update r_repair_pool t set t.status_cd = #{statusCd}
  178. <if test="newBId != null and newBId != ''">
  179. ,t.b_id = #{newBId}
  180. </if>
  181. <if test="repairName !=null and repairName != ''">
  182. , t.repair_name= #{repairName}
  183. </if>
  184. <if test="appointmentTime !=null">
  185. , t.appointment_time= #{appointmentTime}
  186. </if>
  187. <if test="repairType !=null and repairType != ''">
  188. , t.repair_type= #{repairType}
  189. </if>
  190. <if test="context !=null and context != ''">
  191. , t.context= #{context}
  192. </if>
  193. <if test="tel !=null and tel != ''">
  194. , t.tel= #{tel}
  195. </if>
  196. <if test="state !=null and state != ''">
  197. , t.state= #{state}
  198. </if>
  199. <if test="communityId !=null and communityId != ''">
  200. , t.community_id= #{communityId}
  201. </if>
  202. <if test="repairObjType !=null and repairObjType != ''">
  203. , t.repair_obj_type= #{repairObjType}
  204. </if>
  205. <if test="repairObjId !=null and repairObjId != ''">
  206. , t.repair_obj_id= #{repairObjId}
  207. </if>
  208. <if test="repairObjName !=null and repairObjName != ''">
  209. , t.repair_obj_name= #{repairObjName}
  210. </if>
  211. where 1=1
  212. <if test="repairId !=null and repairId != ''">
  213. and t.repair_id= #{repairId}
  214. </if>
  215. <if test="bId !=null and bId != ''">
  216. and t.b_id= #{bId}
  217. </if>
  218. </update>
  219. <!-- 查询报修信息数量 add by wuxw 2018-07-03 -->
  220. <select id="queryRepairsCount" parameterType="Map" resultType="Map">
  221. select count(1) count
  222. from r_repair_pool t
  223. <if test="staffId != null and staffId != ''">
  224. ,r_repair_user rru
  225. ,t_dict td
  226. </if>
  227. where 1 =1
  228. <if test="staffId != null and staffId != ''">
  229. and t.repair_id = rru.repair_id
  230. and rru.user_id = #{staffId}
  231. and rru.status_cd = '0'
  232. and td.`table_name` = 'r_repair_user'
  233. AND td.`table_columns` = 'state'
  234. AND td.`status_cd` = rru.state
  235. </if>
  236. <if test="repairName !=null and repairName != ''">
  237. and t.repair_name like '%${repairName}%'
  238. </if>
  239. <if test="appointmentTime !=null ">
  240. and t.appointment_time= #{appointmentTime}
  241. </if>
  242. <if test="repairType !=null and repairType != ''">
  243. and t.repair_type= #{repairType}
  244. </if>
  245. <if test="context !=null and context != ''">
  246. and t.context= #{context}
  247. </if>
  248. <if test="repairId !=null and repairId != ''">
  249. and t.repair_id= #{repairId}
  250. </if>
  251. <if test="tel !=null and tel != ''">
  252. and t.tel= #{tel}
  253. </if>
  254. <if test="statusCd !=null and statusCd != ''">
  255. and t.status_cd= #{statusCd}
  256. </if>
  257. <if test="state !=null and state != ''">
  258. and t.state= #{state}
  259. </if>
  260. <if test="statess !=null">
  261. and t.state in
  262. <foreach collection="statess" item="item" open="(" close=")" separator=",">
  263. #{item}
  264. </foreach>
  265. </if>
  266. <if test="communityId !=null and communityId != ''">
  267. and t.community_id= #{communityId}
  268. </if>
  269. <if test="bId !=null and bId != ''">
  270. and t.b_id= #{bId}
  271. </if>
  272. <if test="repairObjType !=null and repairObjType != ''">
  273. and t.repair_obj_type= #{repairObjType}
  274. </if>
  275. <if test="repairWay !=null and repairWay != ''">
  276. and rs.repair_way= #{repairWay}
  277. </if>
  278. <if test="repairObjId !=null and repairObjId != ''">
  279. and t.repair_obj_id= #{repairObjId}
  280. </if>
  281. </select>
  282. <!-- 查询报修信息信息 add by wuxw 2018-07-03 -->
  283. <select id="getStaffRepairInfo" parameterType="Map" resultType="Map">
  284. select distinct t.repair_name,t.repair_name repairName,t.appointment_time,t.appointment_time
  285. appointmentTime,t.repair_type,t.repair_type repairType,t.context,t.repair_id,t.repair_id
  286. repairId,t.tel,t.status_cd,t.status_cd statusCd,t.state,t.community_id,t.community_id communityId,t.b_id,t.b_id
  287. bId,ru.pre_staff_id preStaffId,ru.pre_staff_name preStaffName,
  288. d.name stateName,
  289. rs.repair_type_name repairTypeName,rs.repair_way repairWay,
  290. t.repair_obj_type,t.repair_obj_id,t.repair_obj_name,t.repair_obj_type repairObjType,t.repair_obj_id repairObjId,t.repair_obj_name repairObjName,
  291. sru.ru_id startRuId,ru.ru_id ruId
  292. from r_repair_pool t
  293. left join t_dict d on t.state = d.status_cd and d.table_name = 'r_repair_pool' and d.table_columns = 'state'
  294. left join r_repair_setting rs on rs.repair_type = t.repair_type and rs.status_cd = '0'
  295. left join r_repair_user ru on t.repair_id = ru.repair_id and ru.status_cd = 0
  296. left join r_repair_user sru on sru.repair_id = ru.repair_id and sru.status_cd = 0 and sru.state = '10005'
  297. where 1 =1
  298. and ru.end_time is null
  299. and ru.state = '10001'
  300. and ru.staff_id = #{staffId}
  301. <if test="repairName !=null and repairName != ''">
  302. and t.repair_name= #{repairName}
  303. </if>
  304. <if test="appointmentTime !=null ">
  305. and t.appointment_time= #{appointmentTime}
  306. </if>
  307. <if test="repairType !=null and repairType != ''">
  308. and t.repair_type= #{repairType}
  309. </if>
  310. <if test="context !=null and context != ''">
  311. and t.context= #{context}
  312. </if>
  313. <if test="repairId !=null and repairId != ''">
  314. and t.repair_id= #{repairId}
  315. </if>
  316. <if test="tel !=null and tel != ''">
  317. and t.tel= #{tel}
  318. </if>
  319. <if test="statusCd !=null and statusCd != ''">
  320. and t.status_cd= #{statusCd}
  321. </if>
  322. <if test="state !=null and state != ''">
  323. and t.state= #{state}
  324. </if>
  325. <if test="communityId !=null and communityId != ''">
  326. and t.community_id= #{communityId}
  327. </if>
  328. <if test="bId !=null and bId != ''">
  329. and t.b_id= #{bId}
  330. </if>
  331. <if test="repairObjType !=null and repairObjType != ''">
  332. and t.repair_obj_type= #{repairObjType}
  333. </if>
  334. <if test="repairObjId !=null and repairObjId != ''">
  335. and t.repair_obj_id= #{repairObjId}
  336. </if>
  337. order by t.create_time desc
  338. <if test="page != -1 and page != null ">
  339. limit #{page}, #{row}
  340. </if>
  341. </select>
  342. <!-- 查询报修信息数量 add by wuxw 2018-07-03 -->
  343. <select id="queryStaffRepairsCount" parameterType="Map" resultType="Map">
  344. select count(1) count
  345. from r_repair_pool t
  346. left join t_dict d on t.state = d.status_cd and d.table_name = 'r_repair_pool' and d.table_columns = 'state'
  347. left join r_repair_setting rs on rs.repair_type = t.repair_type and rs.status_cd = '0'
  348. left join r_repair_user ru on t.repair_id = ru.repair_id and t.status_cd = 0
  349. where 1 =1
  350. and ru.end_time is null
  351. and ru.state = '10001'
  352. and ru.staff_id = #{staffId}
  353. <if test="repairName !=null and repairName != ''">
  354. and t.repair_name= #{repairName}
  355. </if>
  356. <if test="appointmentTime !=null ">
  357. and t.appointment_time= #{appointmentTime}
  358. </if>
  359. <if test="repairType !=null and repairType != ''">
  360. and t.repair_type= #{repairType}
  361. </if>
  362. <if test="context !=null and context != ''">
  363. and t.context= #{context}
  364. </if>
  365. <if test="repairId !=null and repairId != ''">
  366. and t.repair_id= #{repairId}
  367. </if>
  368. <if test="tel !=null and tel != ''">
  369. and t.tel= #{tel}
  370. </if>
  371. <if test="statusCd !=null and statusCd != ''">
  372. and t.status_cd= #{statusCd}
  373. </if>
  374. <if test="state !=null and state != ''">
  375. and t.state= #{state}
  376. </if>
  377. <if test="communityId !=null and communityId != ''">
  378. and t.community_id= #{communityId}
  379. </if>
  380. <if test="bId !=null and bId != ''">
  381. and t.b_id= #{bId}
  382. </if>
  383. <if test="repairObjType !=null and repairObjType != ''">
  384. and t.repair_obj_type= #{repairObjType}
  385. </if>
  386. <if test="repairObjId !=null and repairObjId != ''">
  387. and t.repair_obj_id= #{repairObjId}
  388. </if>
  389. </select>
  390. <!-- 查询报修信息信息 add by wuxw 2018-07-03 -->
  391. <select id="getStaffFinishRepairInfo" parameterType="Map" resultType="Map">
  392. select distinct t.repair_name,t.repair_name repairName,t.appointment_time,t.appointment_time
  393. appointmentTime,t.repair_type,t.repair_type repairType,t.context,t.repair_id,t.repair_id
  394. repairId,t.tel,t.status_cd,t.status_cd statusCd,t.state,t.community_id,t.community_id communityId,t.b_id,t.b_id
  395. bId,
  396. d.name stateName,
  397. rs.repair_type_name repairTypeName,rs.repair_way repairWay,
  398. t.repair_obj_type,t.repair_obj_id,t.repair_obj_name,t.repair_obj_type repairObjType,t.repair_obj_id
  399. repairObjId,t.repair_obj_name repairObjName
  400. from r_repair_pool t
  401. left join t_dict d on t.state = d.status_cd and d.table_name = 'r_repair_pool' and d.table_columns = 'state'
  402. left join r_repair_setting rs on rs.repair_type = t.repair_type and rs.status_cd = '0'
  403. left join r_repair_user ru on t.repair_id = ru.repair_id and t.status_cd = 0
  404. where 1 =1
  405. and ru.state in ('10002','10003','10004','10005')
  406. and ru.staff_id = #{staffId}
  407. <if test="repairName !=null and repairName != ''">
  408. and t.repair_name= #{repairName}
  409. </if>
  410. <if test="appointmentTime !=null ">
  411. and t.appointment_time= #{appointmentTime}
  412. </if>
  413. <if test="repairType !=null and repairType != ''">
  414. and t.repair_type= #{repairType}
  415. </if>
  416. <if test="context !=null and context != ''">
  417. and t.context= #{context}
  418. </if>
  419. <if test="repairId !=null and repairId != ''">
  420. and t.repair_id= #{repairId}
  421. </if>
  422. <if test="tel !=null and tel != ''">
  423. and t.tel= #{tel}
  424. </if>
  425. <if test="statusCd !=null and statusCd != ''">
  426. and t.status_cd= #{statusCd}
  427. </if>
  428. <if test="state !=null and state != ''">
  429. and t.state= #{state}
  430. </if>
  431. <if test="states !=null">
  432. and t.state in
  433. <foreach collection="states" item="item" open="(" close=")" separator=",">
  434. #{item}
  435. </foreach>
  436. </if>
  437. <if test="communityId !=null and communityId != ''">
  438. and t.community_id= #{communityId}
  439. </if>
  440. <if test="bId !=null and bId != ''">
  441. and t.b_id= #{bId}
  442. </if>
  443. <if test="repairObjType !=null and repairObjType != ''">
  444. and t.repair_obj_type= #{repairObjType}
  445. </if>
  446. <if test="repairObjId !=null and repairObjId != ''">
  447. and t.repair_obj_id= #{repairObjId}
  448. </if>
  449. order by t.create_time desc
  450. <if test="page != -1 and page != null ">
  451. limit #{page}, #{row}
  452. </if>
  453. </select>
  454. <!-- 查询报修信息数量 add by wuxw 2018-07-03 -->
  455. <select id="queryStaffFinishRepairsCount" parameterType="Map" resultType="Map">
  456. select count(1) count
  457. from r_repair_pool t
  458. left join t_dict d on t.state = d.status_cd and d.table_name = 'r_repair_pool' and d.table_columns = 'state'
  459. left join r_repair_setting rs on rs.repair_type = t.repair_type and rs.status_cd = '0'
  460. left join r_repair_user ru on t.repair_id = ru.repair_id and t.status_cd = 0
  461. where 1 =1
  462. and ru.state in ('10002','10003','10004','10005')
  463. and ru.staff_id = #{staffId}
  464. <if test="repairName !=null and repairName != ''">
  465. and t.repair_name= #{repairName}
  466. </if>
  467. <if test="appointmentTime !=null ">
  468. and t.appointment_time= #{appointmentTime}
  469. </if>
  470. <if test="repairType !=null and repairType != ''">
  471. and t.repair_type= #{repairType}
  472. </if>
  473. <if test="context !=null and context != ''">
  474. and t.context= #{context}
  475. </if>
  476. <if test="repairId !=null and repairId != ''">
  477. and t.repair_id= #{repairId}
  478. </if>
  479. <if test="tel !=null and tel != ''">
  480. and t.tel= #{tel}
  481. </if>
  482. <if test="statusCd !=null and statusCd != ''">
  483. and t.status_cd= #{statusCd}
  484. </if>
  485. <if test="state !=null and state != ''">
  486. and t.state= #{state}
  487. </if>
  488. <if test="states !=null">
  489. and t.state in
  490. <foreach collection="states" item="item" open="(" close=")" separator=",">
  491. #{item}
  492. </foreach>
  493. </if>
  494. <if test="communityId !=null and communityId != ''">
  495. and t.community_id= #{communityId}
  496. </if>
  497. <if test="bId !=null and bId != ''">
  498. and t.b_id= #{bId}
  499. </if>
  500. <if test="repairObjType !=null and repairObjType != ''">
  501. and t.repair_obj_type= #{repairObjType}
  502. </if>
  503. <if test="repairObjId !=null and repairObjId != ''">
  504. and t.repair_obj_id= #{repairObjId}
  505. </if>
  506. group by ru.staff_id
  507. </select>
  508. </mapper>