RepairServiceDaoImplMapper.xml 21 KB

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