RepairRecordMapper.xml 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.repair.mapper.RepairRecordMapper">
  4. <resultMap type="com.repair.model.vo.RepairRecordCountVo" id="repairRecordCountMap">
  5. <result property="Incomplete" column="Incomplete"/>
  6. <result property="Confirmed" column="Confirmed"/>
  7. <result property="Finished" column="Finished"/>
  8. </resultMap>
  9. <select id="queryRepairRecordCount" resultType="com.repair.model.vo.RepairRecordCountVo"
  10. resultMap="repairRecordCountMap">
  11. SELECT COUNT(IF(maintenance_state &lt; 7,1, NULL)) Incomplete,COUNT(IF(maintenance_state=4,1, NULL))
  12. Confirmed,COUNT(IF(maintenance_state &gt;=7 ,1, NULL)) Finished FROM `repair_record`
  13. <where>
  14. and maintenance_state &lt;= 7 and deleted = 0
  15. <if test="userId != null and userId != ''">
  16. and user_id = #{userId}
  17. </if>
  18. </where>
  19. </select>
  20. <resultMap type="com.repair.model.vo.MyRepairRecordVo" id="repairRecordOwnMap">
  21. <result property="id" column="id"/>
  22. <result property="recordNo" column="record_no"/>
  23. <result property="reportTime" column="report_time"/>
  24. <result property="userName" column="user_name"/>
  25. <result property="userPhone" column="user_phone"/>
  26. <result property="areaName" column="area_name"/>
  27. <result property="address" column="address"/>
  28. <result property="articleName" column="article_name"/>
  29. <result property="descript" column="description"/>
  30. <result property="image" column="image"/>
  31. <result property="stateId" column="state_id"/>
  32. <result property="price" column="price"/>
  33. <result property="maintenancerName" column="maintenancer_name"/>
  34. <result property="maintenancerPhone" column="maintenancer_phone"/>
  35. <result property="timeoutDispStr" column="timeout_disp_str"/>
  36. <result property="timeoutReceStr" column="timeout_rece_str"/>
  37. </resultMap>
  38. <select id="queryMyRepairRecordList" resultType="com.repair.model.vo.MyRepairRecordVo"
  39. resultMap="repairRecordOwnMap">
  40. select
  41. case date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) &lt;= NOW() and rr.is_duty = 0 when true then '超时未接'
  42. else null end as timeout_disp_str,
  43. case date_add(rdv.receiving_time, interval rdv.maintenance_assess_time minute) &lt;= NOW() and rr.is_duty = 0 when true then '维修超时'
  44. else null end as timeout_rece_str,
  45. rr.id,rr.price,rr.maintenancer_name,rr.maintenancer_phone,rr.record_no,rr.report_time,rr.user_name,rr.user_phone,rr.area_id
  46. as area_name,rr.address,rr.description,rat.name as article_name,rr.image,rr.maintenance_state as state_id from
  47. repair_record rr
  48. left join repair_article_type rat on rat.id = rr.article_id
  49. left join repair_dispatch_record rdr on rdr.deleted = 0 and rdr.record_id = rr.id and rdr.is_lose_efficacy = 0
  50. left join repair_receiving rdv on rdv.deleted = 0 and rdv.record_id = rr.id and rdv.is_lose_efficacy = 0
  51. <where>
  52. and rr.deleted = 0
  53. <if test="stateStr != null and stateStr != ''">
  54. and rr.maintenance_state ${stateStr}
  55. </if>
  56. <if test="userId != null and userId != ''">
  57. and rr.user_id = #{userId}
  58. </if>
  59. </where>
  60. order by rr.report_time DESC
  61. </select>
  62. <resultMap type="com.repair.model.vo.MaintenanceTechnicianVo" id="repairRecordTechnicianMap">
  63. <result property="receivingCount" column="receiving_count"/>
  64. <result property="maintenanceCount" column="maintenance_count"/>
  65. <result property="timeoutCount" column="timeout_count"/>
  66. <result property="examineCount" column="examine_count"/>
  67. </resultMap>
  68. <select id="queryRepairTechnicianCount" resultType="com.repair.model.vo.MaintenanceTechnicianVo"
  69. resultMap="repairRecordTechnicianMap">
  70. select (select Count(*) from repair_record rr
  71. inner join repair_dispatch_record rdr on rdr.deleted = 0 and rdr.is_lose_efficacy = 0 and rdr.record_id = rr.id and rdr.users_id = #{userId}
  72. where rr.deleted = 0) as receiving_count ,(select Count(*) from repair_record rr2
  73. inner join repair_receiving rdv on rdv.deleted = 0 and rdv.user_id = #{userId} and rdv.record_id = rr2.id and
  74. rdv.is_lose_efficacy = 0
  75. where rr2.maintenance_state = 2 and rr2.deleted = 0) as maintenance_count,(select Count(*) as cs from (select rr3.*
  76. from repair_record rr3
  77. inner join repair_dispatch_record rdr on rdr.deleted = 0 and rdr.users_id = #{userId} and rdr.record_id = rr3.id and
  78. rdr.is_lose_efficacy = 0
  79. and date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) &lt;= #{dateNow}
  80. where rr3.maintenance_state = 1 and rr3.is_duty = 0 and rr3.deleted = 0
  81. UNION ALL
  82. select rr4.* from repair_record rr4
  83. inner join repair_receiving rdv on rdv.deleted = 0 and rdv.user_id = #{userId} and rdv.record_id = rr4.id and
  84. rdv.is_lose_efficacy = 0
  85. and date_add(rdv.receiving_time , interval rdv.maintenance_assess_time minute) &lt;= #{dateNow}
  86. where rr4.maintenance_state = 2 and rr4.is_duty = 0 and rr4.deleted = 0) c) as timeout_count,(select Count(*) as sh from (
  87. select rr5.* from repair_record rr5
  88. inner join repair_collaborate_record rcr on rcr.deleted = 0 and rcr.user_id = #{userId} and rcr.record_id = rr5.id and
  89. rcr.approval_statu = 2
  90. where rr5.maintenance_state = 6 and rr5.deleted = 0
  91. UNION ALL
  92. select rr.* from repair_record rr
  93. inner join repair_transfer_record rtr on rtr.deleted = 0 and rtr.user_id = #{userId} and rtr.record_id = rr.id and
  94. rtr.approval_statu = 2
  95. where rr.maintenance_state = 5 and rr.deleted = 0) a) as examine_count
  96. </select>
  97. <resultMap type="com.repair.model.vo.RepairTechnicianVo" id="repairRecordTechnicianDataMap">
  98. <result property="id" column="id"/>
  99. <result property="recordNo" column="record_no"/>
  100. <result property="reportTime" column="report_time"/>
  101. <result property="userName" column="user_name"/>
  102. <result property="userPhone" column="user_phone"/>
  103. <result property="areaName" column="area_name"/>
  104. <result property="address" column="address"/>
  105. <result property="articleName" column="article_name"/>
  106. <result property="description" column="description"/>
  107. <result property="image" column="image"/>
  108. <result property="state" column="state"/>
  109. <result property="timeoutStr" column="timeout_str"/>
  110. </resultMap>
  111. <!--待接单-->
  112. <select id="queryPendingOrderList" resultType="com.repair.model.vo.RepairTechnicianVo"
  113. resultMap="repairRecordTechnicianDataMap">
  114. select case date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) &lt;= #{dateNow} and rr.is_duty = 0 when true then '超时未接' else null end as timeout_str,rr.id,rr.record_no,rr.report_time,rr.user_name,rr.user_phone,rr.area_id as area_name,rr.address,rat.name as article_name,rr.description,rr.image,'待接单' as state
  115. from repair_record rr
  116. inner join repair_dispatch_record rdr on rdr.deleted = 0 and rdr.users_id = #{userId} and rdr.record_id = rr.id and rdr.is_lose_efficacy = 0 and rdr.receiving_time is null
  117. left join repair_article_type rat on rat.deleted = 0 and rat.id = rr.article_id
  118. where (rr.maintenance_state = 1 or rr.maintenance_state = 2) and rr.deleted = 0
  119. order by rr.report_time DESC
  120. </select>
  121. <!--维修中-->
  122. <select id="queryRepairOrderList" resultType="com.repair.model.vo.RepairTechnicianVo"
  123. resultMap="repairRecordTechnicianDataMap">
  124. select case date_add(rdv.receiving_time, interval rdv.maintenance_assess_time minute) &lt;= #{dateNow} and rr.is_duty = 0 when true then '维修超时' else null end as timeout_str,rr.id,rr.record_no,rr.report_time,rr.user_name,rr.user_phone,rr.area_id as area_name,rr.address,rat.name as article_name ,rr.description,rr.image,'维修中' as state
  125. from repair_record rr
  126. inner join repair_receiving rdv on rdv.deleted = 0 and rdv.user_id = #{userId} and rdv.record_id = rr.id and rdv.is_lose_efficacy = 0
  127. left join repair_article_type rat on rat.deleted = 0 and rat.id = rr.article_id
  128. where rr.maintenance_state = 2 and rr.deleted = 0
  129. order by rr.report_time DESC
  130. </select>
  131. <!--已超时-->
  132. <select id="queryTimeoutOrderList" resultType="com.repair.model.vo.RepairTechnicianVo"
  133. resultMap="repairRecordTechnicianDataMap">
  134. SELECT * FROM (
  135. select case date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) &lt;= #{dateNow} when true then '超时未接' else null end as timeout_str,rr.id,rr.record_no,rr.report_time,rr.user_name,rr.user_phone,rr.area_id as area_name,rr.address,rat.name as article_name ,rr.description,rr.image,'待接单' as state from repair_record rr
  136. inner join repair_dispatch_record rdr on rdr.deleted = 0 and rdr.users_id = #{userId} and rdr.record_id = rr.id and rdr.is_lose_efficacy = 0
  137. and date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) &lt;= #{dateNow}
  138. left join repair_article_type rat on rat.deleted = 0 and rat.id = rr.article_id
  139. where rr.maintenance_state = 1 and rr.is_duty = 0 and rr.deleted = 0
  140. UNION ALL
  141. select case date_add(rdv.receiving_time, interval rdv.maintenance_assess_time minute) &lt;= #{dateNow} when true then '维修超时' else null end as timeout_str,rr.id,rr.record_no,rr.report_time,rr.user_name,rr.user_phone,rr.area_id as area_name,rr.address,rat.name as article_name ,rr.description,rr.image,'维修中' as state from repair_record rr
  142. inner join repair_receiving rdv on rdv.deleted = 0 and rdv.user_id = #{userId} and rdv.record_id = rr.id and rdv.is_lose_efficacy = 0
  143. and date_add(rdv.receiving_time , interval rdv.maintenance_assess_time minute) &lt;= #{dateNow}
  144. left join repair_article_type rat on rat.deleted = 0 and rat.id = rr.article_id
  145. where rr.maintenance_state = 2 and rr.is_duty = 0 and rr.deleted = 0) t
  146. order by t.report_time desc
  147. </select>
  148. <!--待审核-->
  149. <select id="queryExamineOrderList" resultType="com.repair.model.vo.RepairTechnicianVo"
  150. resultMap="repairRecordTechnicianDataMap">
  151. select rr.id,rr.record_no,rr.report_time,rr.user_name,rr.user_phone,rr.area_id as area_name,rr.address,rat.name as article_name ,rr.description,rr.image,'协作审核' as state from repair_record rr
  152. inner join repair_collaborate_record rcr on rcr.deleted = 0 and rcr.user_id = #{userId} and rcr.record_id = rr.id and rcr.approval_statu = 2
  153. left join repair_article_type rat on rat.deleted = 0 and rat.id = rr.article_id
  154. where rr.maintenance_state = 6 and rr.deleted = 0
  155. UNION ALL
  156. select rr.id,rr.record_no,rr.report_time,rr.user_name,rr.user_phone,rr.area_id as area_name,rr.address,rat.name as article_name ,rr.description,rr.image,'转单审核' as state from repair_record rr
  157. inner join repair_transfer_record rtr on rtr.deleted = 0 and rtr.user_id = #{userId} and rtr.record_id = rr.id and rtr.approval_statu = 2
  158. left join repair_article_type rat on rat.deleted = 0 and rat.id = rr.article_id
  159. where rr.maintenance_state = 5 and rr.deleted = 0
  160. </select>
  161. <resultMap type="com.repair.model.vo.RepairManageCountVo" id="repairManageCountMap">
  162. <result property="allCount" column="all_count"/>
  163. <result property="dispatchCount" column="dispatch_count"/>
  164. <result property="maintenanceCount" column="maintenance_count"/>
  165. <result property="logisticsCount" column="logistics_count"/>
  166. <result property="examineCount" column="examine_count"/>
  167. <result property="finishedCount" column="finished_count"/>
  168. <result property="canceledCount" column="canceled_count"/>
  169. <result property="closedCount" column="closed_count"/>
  170. <result property="timeoutCount" column="timeout_count"/>
  171. </resultMap>
  172. <select id="queryManageCount" resultType="com.repair.model.vo.RepairManageCountVo" resultMap="repairManageCountMap">
  173. select
  174. (select Count(*) from repair_record where deleted = 0) as all_count,
  175. (select Count(*) from repair_record where deleted = 0 and maintenance_state = 1
  176. <if test="schoolId != null and schoolId != ''">
  177. and school_id = #{schoolId}
  178. </if>
  179. ) as dispatch_count,
  180. (select Count(*) from repair_record where deleted = 0 and maintenance_state = 2
  181. <if test="schoolId != null and schoolId != ''">
  182. and school_id = #{schoolId}
  183. </if>
  184. ) as maintenance_count,
  185. (select Count(*) from repair_record where deleted = 0 and maintenance_state = 3
  186. <if test="schoolId != null and schoolId != ''">
  187. and school_id = #{schoolId}
  188. </if>
  189. ) as logistics_count,
  190. (select Count(*) from repair_record where deleted = 0 and (maintenance_state = 5 or maintenance_state = 6)
  191. <if test="schoolId != null and schoolId != ''">
  192. and school_id = #{schoolId}
  193. </if>
  194. ) as examine_count,
  195. (select Count(*) from repair_record where deleted = 0 and maintenance_state = 7
  196. <if test="schoolId != null and schoolId != ''">
  197. and school_id = #{schoolId}
  198. </if>
  199. ) as finished_count,
  200. (select Count(*) from repair_record where deleted = 0 and maintenance_state = 8
  201. <if test="schoolId != null and schoolId != ''">
  202. and school_id = #{schoolId}
  203. </if>
  204. ) as canceled_count,
  205. (select Count(*) from repair_record where deleted = 0 and maintenance_state = 9
  206. <if test="schoolId != null and schoolId != ''">
  207. and school_id = #{schoolId}
  208. </if>
  209. ) as closed_count,
  210. (select Count(*) as cs from (select rr3.* from repair_record rr3
  211. inner join repair_dispatch_record rdr on rdr.deleted = 0 and rdr.record_id = rr3.id and
  212. rdr.is_lose_efficacy = 0 and date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) &lt;= NOW()
  213. where rr3.maintenance_state = 1 and rr3.is_duty = 0 and rr3.deleted = 0
  214. <if test="schoolId != null and schoolId != ''">
  215. and rr3.school_id = #{schoolId}
  216. </if>
  217. UNION ALL
  218. select rr4.* from repair_record rr4
  219. inner join repair_receiving rdv on rdv.deleted = 0 and rdv.record_id = rr4.id and
  220. rdv.is_lose_efficacy = 0 and date_add(rdv.receiving_time , interval rdv.maintenance_assess_time minute) &lt;= NOW()
  221. where rr4.maintenance_state = 2 and rr4.is_duty = 0 and rr4.deleted = 0
  222. <if test="schoolId != null and schoolId != ''">
  223. and school_id = #{schoolId}
  224. </if>
  225. ) c) as timeout_count
  226. </select>
  227. <resultMap type="com.repair.model.vo.RepairRecordPageVo" id="repairRecordPageMap">
  228. <result property="id" column="id"/>
  229. <result property="recordNo" column="record_no"/>
  230. <result property="userName" column="user_name"/>
  231. <result property="userPhone" column="user_phone"/>
  232. <result property="articleName" column="article_name"/>
  233. <result property="description" column="description"/>
  234. <result property="reportTime" column="report_time"/>
  235. <result property="maintenancerName" column="maintenancer_name"/>
  236. <result property="details" column="details"/>
  237. <result property="maintenanceState" column="maintenance_state"/>
  238. <result property="userId" column="user_id"/>
  239. </resultMap>
  240. <!--除已超时外的其他数据获取方式-->
  241. <select id="queryNotTimeout" resultType="com.repair.model.vo.RepairRecordPageVo" resultMap="repairRecordPageMap">
  242. select rr.user_id,1 as details,rr.id,rr.record_no,rr.area_id as area_name,rr.user_name,rr.user_phone,rat.name as
  243. article_name,
  244. rr.description,rr.report_time,rr.maintenancer_name,rr.maintenance_state
  245. from repair_record rr
  246. left join repair_article_type rat on rat.deleted = 0 and rat.id = rr.article_id
  247. <where>
  248. and rr.deleted = 0
  249. <if test="schoolId != null and schoolId != ''">
  250. and rr.school_id = #{schoolId}
  251. </if>
  252. <if test="stateStr != null and stateStr != ''">
  253. and (rr.maintenance_state ${stateStr}
  254. </if>
  255. <if test="keyWord != null and keyWord != ''">
  256. and (rr.area_id like '%' #{keyWord} '%' or rr.user_name like '%' #{keyWord} '%' or rr.user_phone like
  257. '%' #{keyWord} '%')
  258. </if>
  259. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  260. and rr.report_time between #{startTime} and #{endTime}
  261. </if>
  262. </where>
  263. order by rr.report_time desc
  264. </select>
  265. <!--#已超时获取方式-->
  266. <select id="queryTimeout" resultType="com.repair.model.vo.RepairRecordPageVo" resultMap="repairRecordPageMap">
  267. SELECT * FROM (
  268. select rr3.user_id,1 as details,rr3.id,rr3.record_no,rr3.area_id as
  269. area_name,rr3.user_name,rr3.user_phone,rat.name as article_name,
  270. rr3.description,rr3.report_time,rr3.maintenancer_name,rr3.maintenance_state
  271. from repair_record rr3
  272. left join repair_article_type rat on rat.deleted = 0 and rat.id = rr3.article_id
  273. inner join repair_dispatch_record rdr on rdr.deleted = 0 and rdr.record_id = rr3.id and
  274. rdr.is_lose_efficacy = 0
  275. and date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) &lt;= NOW()
  276. <where>
  277. and rr3.maintenance_state = 1 and rr3.deleted = 0 and rr3.is_duty = 0
  278. <if test="keyWord != null and keyWord != ''">
  279. and (rr3.area_id like '%' #{keyWord} '%' or rr3.user_name like '%' #{keyWord} '%' or rr3.user_phone like
  280. '%' #{keyWord} '%')
  281. </if>
  282. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  283. and rr3.report_time between #{startTime} and #{endTime}
  284. </if>
  285. <if test="schoolId != null and schoolId != ''">
  286. and rr3.school_id = #{schoolId}
  287. </if>
  288. </where>
  289. UNION ALL
  290. select rr4.user_id,1 as details,rr4.id,rr4.record_no,rr4.area_id as
  291. area_name,rr4.user_name,rr4.user_phone,rat.name as
  292. article_name,
  293. rr4.description,rr4.report_time,rr4.maintenancer_name,rr4.maintenance_state
  294. from repair_record rr4
  295. left join repair_article_type rat on rat.deleted = 0 and rat.id = rr4.article_id
  296. inner join repair_receiving rdv on rdv.deleted = 0 and rdv.record_id = rr4.id and
  297. rdv.is_lose_efficacy = 0
  298. and date_add(rdv.receiving_time , interval rdv.maintenance_assess_time minute) &lt;= NOW()
  299. <where>
  300. and rr4.maintenance_state = 2 and rr4.deleted = 0 and rr4.is_duty = 0
  301. <if test="keyWord != null and keyWord != ''">
  302. and (rr4.area_id like '%' #{keyWord} '%' or rr4.user_name like '%' #{keyWord} '%' or rr4.user_phone like
  303. '%' #{keyWord} '%')
  304. </if>
  305. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  306. and rr4.report_time between #{startTime} and #{endTime}
  307. </if>
  308. <if test="schoolId != null and schoolId != ''">
  309. and rr4.school_id = #{schoolId}
  310. </if>
  311. </where>
  312. ) t
  313. order by t.report_time desc
  314. </select>
  315. <!--#获取待处理池数据-->
  316. <resultMap type="com.repair.model.vo.pendingOrderVo" id="repairPendingOrderMap">
  317. <result property="id" column="id"/>
  318. <result property="recordNo" column="record_no"/>
  319. <result property="reportTime" column="report_time"/>
  320. <result property="userName" column="user_name"/>
  321. <result property="userPhone" column="user_phone"/>
  322. <result property="areaName" column="area_name"/>
  323. <result property="address" column="address"/>
  324. <result property="articleName" column="article_name"/>
  325. <result property="description" column="description"/>
  326. <result property="image" column="image"/>
  327. <result property="state" column="state"/>
  328. </resultMap>
  329. <select id="queryPendingOrder" resultType="com.repair.model.vo.pendingOrderVo" resultMap="repairPendingOrderMap">
  330. select * from (select (select Count(*) from repair_dispatch_record where is_lose_efficacy = 0 and record_id = rr.id and receiving_time is null and users_id = #{userId}) as disp_count,rr.id,rr.record_no,
  331. rr.report_time,rr.user_name,rr.user_phone,rr.area_id as area_name,rr.address,rat.name as article_name,rr.description,rr.image,'待接单' as state
  332. from repair_record rr
  333. left join repair_article_type rat on rat.id = rr.article_id
  334. where rr.maintenance_state = 1 and rr.deleted = 0) t where t.disp_count &lt;= 0
  335. order by t.report_time desc
  336. </select>
  337. <!--郭师傅维修 团队工单 头部数量-->
  338. <resultMap type="com.repair.model.vo.TeamWorkCountVo" id="teamWorkOrderMap">
  339. <result property="examineCount" column="examine_count"/>
  340. <result property="receivingCount" column="receiving_count"/>
  341. <result property="maintenanceCount" column="maintenance_count"/>
  342. <result property="finishedCount" column="finished_count"/>
  343. <result property="logisticsCount" column="logistics_count"/>
  344. <result property="timeoutCount" column="timeout_count"/>
  345. <result property="closedCount" column="closed_count"/>
  346. </resultMap>
  347. <select id="queryTeamWorkCount" resultType="com.repair.model.vo.TeamWorkCountVo" resultMap="teamWorkOrderMap">
  348. select
  349. (select Count(*) as sh from (
  350. select rr5.* from repair_record rr5
  351. inner join repair_collaborate_record rcr on rcr.deleted = 0 and rcr.record_id = rr5.id and
  352. rcr.approval_statu = 2
  353. where rr5.maintenance_state = 6 and rr5.school_id = #{schoolId} and rr5.deleted = 0
  354. UNION ALL
  355. select rr.* from repair_record rr
  356. inner join repair_transfer_record rtr on rtr.deleted = 0 and rtr.record_id = rr.id and
  357. rtr.approval_statu = 2
  358. where rr.maintenance_state = 5 and rr.school_id = #{schoolId} and rr.deleted = 0) a) as examine_count,
  359. (select Count(*) from repair_record rr1
  360. inner join repair_dispatch_record rdr on rdr.deleted = 0 and rdr.record_id = rr1.id and
  361. rdr.is_lose_efficacy = 0
  362. where rr1.maintenance_state = 1 and rr1.school_id = #{schoolId} and rr1.deleted = 0) as receiving_count,
  363. (select Count(*) from repair_record rr2
  364. inner join repair_receiving rdv on rdv.deleted = 0 and rdv.record_id = rr2.id and
  365. rdv.is_lose_efficacy = 0
  366. where rr2.maintenance_state = 2 and rr2.school_id = #{schoolId} and rr2.deleted = 0) as maintenance_count,
  367. (select Count(*) from repair_record rr7
  368. where rr7.deleted = 0 and rr7.school_id = #{schoolId} and rr7.maintenance_state = 7) as finished_count,
  369. (select Count(*) from repair_record rr9
  370. where rr9.deleted = 0 and rr9.school_id = #{schoolId} and rr9.maintenance_state = 3) as logistics_count,
  371. (select Count(*) as cs from (select rr3.*
  372. from repair_record rr3
  373. inner join repair_dispatch_record rdr on rdr.deleted = 0 and rdr.record_id = rr3.id and
  374. rdr.is_lose_efficacy = 0
  375. and date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) &lt;= #{dateNow}
  376. where rr3.maintenance_state = 1 and rr3.deleted = 0 and rr3.is_duty = 0 and rr3.school_id = #{schoolId}
  377. UNION ALL
  378. select rr4.* from repair_record rr4
  379. inner join repair_receiving rdv on rdv.deleted = 0 and rdv.record_id = rr4.id and
  380. rdv.is_lose_efficacy = 0
  381. and date_add(rdv.receiving_time , interval rdv.maintenance_assess_time minute) &lt;= #{dateNow}
  382. where rr4.maintenance_state = 2 and rr4.deleted = 0 and rr4.is_duty = 0 and rr4.school_id = #{schoolId}) c) as timeout_count,
  383. (select Count(*) from repair_record rr8
  384. where rr8.deleted = 0 and rr8.school_id = #{schoolId} and rr8.maintenance_state = 9) as closed_count
  385. </select>
  386. <!--待审核-->
  387. <select id="queryTeamWorkExamine" resultType="com.repair.model.vo.RepairTechnicianVo"
  388. resultMap="repairRecordTechnicianDataMap">
  389. select rr5.id,rr5.record_no,rr5.report_time,rr5.user_name,rr5.user_phone,rr5.area_id as area_name,rr5.address,rat.name as article_name ,rr5.description,rr5.image,'协作审核' as state from repair_record rr5
  390. inner join repair_collaborate_record rcr on rcr.deleted = 0 and rcr.record_id = rr5.id and rcr.approval_statu = 2
  391. left join repair_article_type rat on rat.deleted = 0 and rat.id = rr5.article_id
  392. where rr5.maintenance_state = 6 and rr5.school_id = #{schoolId} and rr5.deleted = 0
  393. UNION ALL
  394. select rr.id,rr.record_no,rr.report_time,rr.user_name,rr.user_phone,rr.area_id as area_name,rr.address,rat.name as article_name ,rr.description,rr.image,'转单审核' as state from repair_record rr
  395. inner join repair_transfer_record rtr on rtr.deleted = 0 and rtr.record_id = rr.id and rtr.approval_statu = 2
  396. left join repair_article_type rat on rat.deleted = 0 and rat.id = rr.article_id
  397. where rr.maintenance_state = 5 and rr.school_id = #{schoolId} and rr.deleted = 0
  398. </select>
  399. <!--待接单-->
  400. <select id="queryTeamWorkPending" resultType="com.repair.model.vo.RepairTechnicianVo"
  401. resultMap="repairRecordTechnicianDataMap">
  402. select case date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) &lt;= #{dateNow} when true then '超时未接' else null end as timeout_str,rr.id,rr.record_no,rr.report_time,rr.user_name,rr.user_phone,rr.area_id as area_name,rr.address,rat.name as article_name,rr.description,rr.image,'待接单' as state
  403. from repair_record rr
  404. inner join repair_dispatch_record rdr on rdr.deleted = 0 and rdr.record_id = rr.id and rdr.is_lose_efficacy = 0
  405. left join repair_article_type rat on rat.deleted = 0 and rat.id = rr.article_id
  406. where rr.maintenance_state = 1 and rr.school_id = #{schoolId} and rr.deleted = 0
  407. order by rr.report_time DESC
  408. </select>
  409. <!--维修中-->
  410. <select id="queryTeamWorkMaintenance" resultType="com.repair.model.vo.RepairTechnicianVo"
  411. resultMap="repairRecordTechnicianDataMap">
  412. select case date_add(rdv.receiving_time, interval rdv.maintenance_assess_time minute) &lt;= #{dateNow} when true then '维修超时' else null end as timeout_str,rr.id,rr.record_no,rr.report_time,rr.user_name,rr.user_phone,rr.area_id as area_name,rr.address,rat.name as article_name ,rr.description,rr.image,'维修中' as state
  413. from repair_record rr
  414. inner join repair_receiving rdv on rdv.deleted = 0 and rdv.record_id = rr.id and rdv.is_lose_efficacy = 0
  415. left join repair_article_type rat on rat.deleted = 0 and rat.id = rr.article_id
  416. where rr.maintenance_state = 2 and rr.school_id = #{schoolId} and rr.deleted = 0
  417. order by rr.report_time DESC
  418. </select>
  419. <!--已完成-->
  420. <select id="queryTeamWorkFinished" resultType="com.repair.model.vo.RepairTechnicianVo"
  421. resultMap="repairRecordTechnicianDataMap">
  422. select rr.id,rr.record_no,rr.report_time,rr.user_name,rr.user_phone,rr.area_id as area_name,rr.address,rat.name as article_name ,rr.description,rr.image,'已完成' as state from repair_record rr
  423. left join repair_article_type rat on rat.deleted = 0 and rat.id = rr.article_id
  424. where rr.deleted = 0 and rr.school_id = #{schoolId} and rr.maintenance_state = 7
  425. order by rr.report_time DESC
  426. </select>
  427. <!--待处理-->
  428. <select id="queryTeamWorkLogistics" resultType="com.repair.model.vo.RepairTechnicianVo"
  429. resultMap="repairRecordTechnicianDataMap">
  430. select rr.id,rr.record_no,rr.report_time,rr.user_name,rr.user_phone,rr.area_id as area_name,rr.address,rat.name as article_name ,rr.description,rr.image,'待处理' as state from repair_record rr
  431. left join repair_article_type rat on rat.deleted = 0 and rat.id = rr.article_id
  432. where rr.deleted = 0 and rr.school_id = #{schoolId} and rr.maintenance_state = 3
  433. order by rr.report_time DESC
  434. </select>
  435. <!--已超时-->
  436. <select id="queryTeamWorkTimeout" resultType="com.repair.model.vo.RepairTechnicianVo"
  437. resultMap="repairRecordTechnicianDataMap">
  438. SELECT * FROM (
  439. select case date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) &lt;= #{dateNow} when true then '超时未接' else null end as timeout_str,rr3.id,rr3.record_no,rr3.report_time,rr3.user_name,rr3.user_phone,rr3.area_id as area_name,rr3.address,rat.name as article_name ,rr3.description,rr3.image,'已超时' as state from repair_record rr3
  440. inner join repair_dispatch_record rdr on rdr.deleted = 0 and rdr.record_id = rr3.id and rdr.is_lose_efficacy = 0
  441. and date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) &lt;= #{dateNow}
  442. left join repair_article_type rat on rat.deleted = 0 and rat.id = rr3.article_id
  443. where rr3.maintenance_state = 1 and rr3.deleted = 0 and rr3.is_duty = 0 and rr3.school_id = #{schoolId}
  444. UNION ALL
  445. select case date_add(rdv.receiving_time, interval rdv.maintenance_assess_time minute) &lt;= #{dateNow} when true then '维修超时' else null end as timeout_str,rr4.id,rr4.record_no,rr4.report_time,rr4.user_name,rr4.user_phone,rr4.area_id as area_name,rr4.address,rat.name as article_name ,rr4.description,rr4.image,'已超时' as state from repair_record rr4
  446. inner join repair_receiving rdv on rdv.deleted = 0 and rdv.record_id = rr4.id and
  447. rdv.is_lose_efficacy = 0
  448. and date_add(rdv.receiving_time , interval rdv.maintenance_assess_time minute) &lt;= #{dateNow}
  449. left join repair_article_type rat on rat.deleted = 0 and rat.id = rr4.article_id
  450. where rr4.maintenance_state = 2 and rr4.deleted = 0 and rr4.is_duty = 0 and rr4.school_id = #{schoolId}) t
  451. order by t.report_time desc
  452. </select>
  453. <!--已关单-->
  454. <select id="queryTeamWorkClosed" resultType="com.repair.model.vo.RepairTechnicianVo"
  455. resultMap="repairRecordTechnicianDataMap">
  456. select rr.id,rr.record_no,rr.report_time,rr.user_name,rr.user_phone,rr.area_id as area_name,rr.address,rat.name as article_name ,rr.description,rr.image,'已关单' as state from repair_record rr
  457. left join repair_article_type rat on rat.deleted = 0 and rat.id = rr.article_id
  458. where rr.deleted = 0 and rr.school_id = #{schoolId} and rr.maintenance_state = 9
  459. order by rr.report_time DESC
  460. </select>
  461. <!-- 报表导出获取除已超时外的其他数据获取方式-->
  462. <select id="queryNotTimeoutReportExport" resultType="com.repair.model.vo.ReportExportVo">
  463. select rr.user_id,1 as details,rr.id,rr.record_no,rr.area_id as area_name,rr.user_name,rr.user_phone,rat.name as
  464. article_name,
  465. rr.description,rr.report_time,rr.maintenancer_name,rr.maintenance_state
  466. from repair_record rr
  467. left join repair_article_type rat on rat.deleted = 0 and rat.id = rr.article_id
  468. <where>
  469. and rr.deleted = 0
  470. <if test="schoolId != null and schoolId != ''">
  471. and rr.school_id = #{schoolId}
  472. </if>
  473. <if test="stateStr != null and stateStr != ''">
  474. and (rr.maintenance_state ${stateStr}
  475. </if>
  476. <if test="keyWord != null and keyWord != ''">
  477. and (rr.area_id like '%' #{keyWord} '%' or rr.user_name like '%' #{keyWord} '%' or rr.user_phone like
  478. '%' #{keyWord} '%')
  479. </if>
  480. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  481. and rr.report_time between #{startTime} and #{endTime}
  482. </if>
  483. </where>
  484. order by rr.report_time desc
  485. </select>
  486. <!-- 报表导出获取除已超时数据获取方式-->
  487. <select id="queryTimeoutReportExport" resultType="com.repair.model.vo.ReportExportVo">
  488. SELECT * FROM (
  489. select rr3.user_id,1 as details,rr3.id,rr3.record_no,rr3.area_id as
  490. area_name,rr3.user_name,rr3.user_phone,rat.name as article_name,
  491. rr3.description,rr3.report_time,rr3.maintenancer_name,rr3.maintenance_state
  492. from repair_record rr3
  493. left join repair_article_type rat on rat.deleted = 0 and rat.id = rr3.article_id
  494. inner join repair_dispatch_record rdr on rdr.deleted = 0 and rdr.record_id = rr3.id and
  495. rdr.is_lose_efficacy = 0
  496. and date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) &lt;= NOW()
  497. <where>
  498. and rr3.maintenance_state = 1 and rr3.deleted = 0 and rr3.is_duty = 0
  499. <if test="keyWord != null and keyWord != ''">
  500. and (rr3.area_id like '%' #{keyWord} '%' or rr3.user_name like '%' #{keyWord} '%' or rr3.user_phone like
  501. '%' #{keyWord} '%')
  502. </if>
  503. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  504. and rr3.report_time between #{startTime} and #{endTime}
  505. </if>
  506. <if test="schoolId != null and schoolId != ''">
  507. and rr3.school_id = #{schoolId}
  508. </if>
  509. </where>
  510. UNION ALL
  511. select rr4.user_id,1 as details,rr4.id,rr4.record_no,rr4.area_id as
  512. area_name,rr4.user_name,rr4.user_phone,rat.name as
  513. article_name,
  514. rr4.description,rr4.report_time,rr4.maintenancer_name,rr4.maintenance_state
  515. from repair_record rr4
  516. left join repair_article_type rat on rat.deleted = 0 and rat.id = rr4.article_id
  517. inner join repair_receiving rdv on rdv.deleted = 0 and rdv.record_id = rr4.id and
  518. rdv.is_lose_efficacy = 0
  519. and date_add(rdv.receiving_time , interval rdv.maintenance_assess_time minute) &lt;= NOW()
  520. <where>
  521. and rr4.maintenance_state = 2 and rr4.deleted = 0 and rr4.is_duty = 0
  522. <if test="keyWord != null and keyWord != ''">
  523. and (rr4.area_id like '%' #{keyWord} '%' or rr4.user_name like '%' #{keyWord} '%' or rr4.user_phone like
  524. '%' #{keyWord} '%')
  525. </if>
  526. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  527. and rr4.report_time between #{startTime} and #{endTime}
  528. </if>
  529. <if test="schoolId != null and schoolId != ''">
  530. and rr4.school_id = #{schoolId}
  531. </if>
  532. </where>
  533. ) t
  534. order by t.report_time desc
  535. </select>
  536. </mapper>