RepairServiceDaoImplMapper.xml 27 KB

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