RepairRecordMapper.xml 75 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299
  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 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
  42. rdr.receiving_time is null) or date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) &lt;=
  43. rdr.receiving_time) and rr.maintenance_state &lt;= 7 and rr.is_duty = 0 when true then '超时未接'
  44. else null end as timeout_disp_str,
  45. case ((date_add(rdv.receiving_time, interval rdv.maintenance_assess_time minute) &lt;= NOW() and
  46. rdv.maintenance_assess_time is null) or date_add(rdv.receiving_time , interval rdv.maintenance_assess_time
  47. minute) &lt;= rdv.finish_time) and rr.maintenance_state &lt;= 7 and rr.is_duty = 0 when true then '维修超时'
  48. else null end as timeout_rece_str,
  49. 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
  50. as area_name,rr.address,rr.description,rat.name as article_name,rr.image,rr.maintenance_state as state_id from
  51. repair_record rr
  52. left join repair_article_type rat on rat.id = rr.article_id
  53. left join repair_dispatch_record rdr on rdr.deleted = 0 and rdr.record_id = rr.id and rdr.is_lose_efficacy = 0
  54. left join repair_receiving rdv on rdv.deleted = 0 and rdv.record_id = rr.id and rdv.is_lose_efficacy = 0
  55. <where>
  56. and rr.deleted = 0
  57. <if test="stateStr != null and stateStr != ''">
  58. and rr.maintenance_state ${stateStr}
  59. </if>
  60. <if test="userId != null and userId != ''">
  61. and rr.user_id = #{userId}
  62. </if>
  63. </where>
  64. GROUP BY rr.id
  65. order by rr.report_time DESC
  66. </select>
  67. <resultMap type="com.repair.model.vo.MaintenanceTechnicianVo" id="repairRecordTechnicianMap">
  68. <result property="receivingCount" column="receiving_count"/>
  69. <result property="maintenanceCount" column="maintenance_count"/>
  70. <result property="timeoutCount" column="timeout_count"/>
  71. <result property="examineCount" column="examine_count"/>
  72. </resultMap>
  73. <select id="queryRepairTechnicianCount" resultType="com.repair.model.vo.MaintenanceTechnicianVo"
  74. resultMap="repairRecordTechnicianMap">
  75. select (select Count(*) from repair_record rr
  76. inner join repair_dispatch_record rdr on rdr.deleted = 0 and rdr.is_lose_efficacy = 0 and rdr.record_id = rr.id and rdr.receiving_time is null and rdr.users_id = #{userId}
  77. where rr.deleted = 0 and rr.maintenance_state = 1) as receiving_count ,(select Count(*) from repair_record rr2
  78. inner join repair_receiving rdv on rdv.deleted = 0 and rdv.user_id = #{userId} and rdv.record_id = rr2.id and
  79. rdv.is_lose_efficacy = 0
  80. where rr2.maintenance_state = 2 and rr2.deleted = 0) as maintenance_count,(select Count(*) as cs from (select rr3.*
  81. from repair_record rr3
  82. inner join repair_dispatch_record rdr on rdr.deleted = 0 and rdr.users_id = #{userId} and rdr.record_id = rr3.id and
  83. rdr.is_lose_efficacy = 0
  84. and ((date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) &lt;= #{dateNow} and rdr.receiving_time is null) or date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) &lt;= rdr.receiving_time)
  85. where rr3.is_duty = 0 and rr3.maintenance_state &lt;= 7 and rr3.deleted = 0
  86. UNION
  87. select rr4.* from repair_record rr4
  88. inner join repair_receiving rdv on rdv.deleted = 0 and rdv.user_id = #{userId} and rdv.record_id = rr4.id and
  89. rdv.is_lose_efficacy = 0
  90. and ((date_add(rdv.receiving_time , interval rdv.maintenance_assess_time minute) &lt;= #{dateNow} and rdv.maintenance_assess_time is null) or date_add(rdv.receiving_time , interval rdv.maintenance_assess_time minute) &lt;= rdv.finish_time)
  91. where rr4.is_duty = 0 and rr4.maintenance_state &lt;= 7 and rr4.deleted = 0) c) as timeout_count,(select Count(*) as sh from (
  92. select rr5.* from repair_record rr5
  93. inner join repair_collaborate_record rcr on rcr.deleted = 0 and rcr.user_id = #{userId} and rcr.record_id = rr5.id and
  94. rcr.approval_statu = 2
  95. where rr5.maintenance_state = 6 and rr5.deleted = 0
  96. UNION ALL
  97. select rr.* from repair_record rr
  98. inner join repair_transfer_record rtr on rtr.deleted = 0 and rtr.user_id = #{userId} and rtr.record_id = rr.id and
  99. rtr.approval_statu = 2
  100. where rr.maintenance_state = 5 and rr.deleted = 0) a) as examine_count
  101. </select>
  102. <resultMap type="com.repair.model.vo.RepairTechnicianVo" id="repairRecordTechnicianDataMap">
  103. <result property="id" column="id"/>
  104. <result property="recordNo" column="record_no"/>
  105. <result property="reportTime" column="report_time"/>
  106. <result property="userName" column="user_name"/>
  107. <result property="userPhone" column="user_phone"/>
  108. <result property="areaName" column="area_name"/>
  109. <result property="address" column="address"/>
  110. <result property="articleName" column="article_name"/>
  111. <result property="description" column="description"/>
  112. <result property="image" column="image"/>
  113. <result property="state" column="state"/>
  114. <result property="maintenanceState" column="maintenance_state"/>
  115. <result property="timeoutStr" column="timeout_str"/>
  116. <result property="maintenanceTimeout" column="maintenance_timeout"/>
  117. <result property="maintenancerName" column="maintenancer_name"/>
  118. <result property="maintenancerPhone" column="maintenancer_phone"/>
  119. <result property="price" column="price"/>
  120. </resultMap>
  121. <!--待接单-->
  122. <select id="queryPendingOrderList" resultType="com.repair.model.vo.RepairTechnicianVo"
  123. resultMap="repairRecordTechnicianDataMap">
  124. select case ((date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) &lt;= #{dateNow} and rdr.receiving_time is null) or date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) &lt;= rdr.receiving_time) 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,rr.maintenancer_name,rr.maintenancer_phone,rr.price
  125. from repair_record rr
  126. 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
  127. left join repair_article_type rat on rat.deleted = 0 and rat.id = rr.article_id
  128. where rr.maintenance_state = 1 and rr.deleted = 0
  129. order by rr.report_time DESC
  130. </select>
  131. <!--维修中-->
  132. <select id="queryRepairOrderList" resultType="com.repair.model.vo.RepairTechnicianVo"
  133. resultMap="repairRecordTechnicianDataMap">
  134. select case ((date_add(rdv.receiving_time, interval rdv.maintenance_assess_time minute) &lt;= #{dateNow} and rdv.maintenance_assess_time is null) or date_add(rdv.receiving_time , interval rdv.maintenance_assess_time minute) &lt;= rdv.finish_time) 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,rr.maintenancer_name,rr.maintenancer_phone,rr.price
  135. from repair_record rr
  136. 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
  137. left join repair_article_type rat on rat.deleted = 0 and rat.id = rr.article_id
  138. where rr.maintenance_state = 2 and rr.deleted = 0
  139. order by rr.report_time DESC
  140. </select>
  141. <!--已超时-->
  142. <select id="queryTimeoutOrderList" resultType="com.repair.model.vo.RepairTechnicianVo"
  143. resultMap="repairRecordTechnicianDataMap">
  144. SELECT case ((date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) &lt;= NOW() and rdr.receiving_time is null) or date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) &lt;= rdr.receiving_time) when true then '超时未接' else null end as timeout_str,case ((date_add(rdv.receiving_time, interval rdv.maintenance_assess_time minute) &lt;= NOW() and rdv.maintenance_assess_time is null) or date_add(rdv.receiving_time , interval rdv.maintenance_assess_time minute) &lt;= rdv.finish_time) when true then '维修超时' else null end as maintenance_timeout,rat.name as article_name,t.* FROM (
  145. select rr.maintenance_state,rr.article_id,rr.id,rr.record_no,rr.report_time,rr.user_name,rr.user_phone,rr.area_id as area_name,rr.address,rr.description,rr.image,rr.maintenancer_name,rr.maintenancer_phone,rr.price from repair_record rr
  146. 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
  147. and ((date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) &lt;= NOW() and rdr.receiving_time is null) or date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) &lt;= rdr.receiving_time)
  148. where rr.is_duty = 0 and rr.maintenance_state &lt;= 7 and rr.deleted = 0
  149. UNION
  150. select rr.maintenance_state,rr.article_id,rr.id,rr.record_no,rr.report_time,rr.user_name,rr.user_phone,rr.area_id as area_name,rr.address,rr.description,rr.image,rr.maintenancer_name,rr.maintenancer_phone,rr.price from repair_record rr
  151. 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
  152. and ((date_add(rdv.receiving_time , interval rdv.maintenance_assess_time minute) &lt;= NOW() and rdv.maintenance_assess_time is null) or date_add(rdv.receiving_time , interval rdv.maintenance_assess_time minute) &lt;= rdv.finish_time)
  153. where rr.is_duty = 0 and rr.maintenance_state &lt;= 7 and rr.deleted = 0) t
  154. left join repair_dispatch_record rdr on rdr.deleted = 0 and rdr.users_id = #{userId} and rdr.record_id = t.id and rdr.is_lose_efficacy = 0
  155. left join repair_receiving rdv on rdv.deleted = 0 and rdv.user_id = #{userId} and rdv.record_id = t.id and rdv.is_lose_efficacy = 0
  156. left join repair_article_type rat on rat.deleted = 0 and rat.id = t.article_id
  157. order by t.report_time desc
  158. </select>
  159. <!--待审核-->
  160. <select id="queryExamineOrderList" resultType="com.repair.model.vo.RepairTechnicianVo"
  161. resultMap="repairRecordTechnicianDataMap">
  162. 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,rr.maintenancer_name,rr.maintenancer_phone,rr.price from repair_record rr
  163. 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
  164. left join repair_article_type rat on rat.deleted = 0 and rat.id = rr.article_id
  165. where rr.maintenance_state = 6 and rr.deleted = 0
  166. UNION ALL
  167. 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,rr.maintenancer_name,rr.maintenancer_phone,rr.price from repair_record rr
  168. 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
  169. left join repair_article_type rat on rat.deleted = 0 and rat.id = rr.article_id
  170. where rr.maintenance_state = 5 and rr.deleted = 0
  171. </select>
  172. <resultMap type="com.repair.model.vo.RepairManageCountVo" id="repairManageCountMap">
  173. <result property="allCount" column="all_count"/>
  174. <result property="dispatchCount" column="dispatch_count"/>
  175. <result property="maintenanceCount" column="maintenance_count"/>
  176. <result property="logisticsCount" column="logistics_count"/>
  177. <result property="examineCount" column="examine_count"/>
  178. <result property="finishedCount" column="finished_count"/>
  179. <result property="canceledCount" column="canceled_count"/>
  180. <result property="closedCount" column="closed_count"/>
  181. <result property="timeoutCount" column="timeout_count"/>
  182. </resultMap>
  183. <select id="queryManageCount" resultType="com.repair.model.vo.RepairManageCountVo" resultMap="repairManageCountMap">
  184. select
  185. (select Count(*) from repair_record where deleted = 0
  186. <if test="keyWord != null and keyWord != ''">
  187. and (area_id like '%' #{keyWord} '%' or user_name like '%' #{keyWord} '%' or user_phone like '%' #{keyWord} '%')
  188. </if>
  189. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  190. and report_time between #{startTime} and #{endTime}
  191. </if>
  192. <if test="schoolId != null and schoolId != ''">
  193. and school_id = #{schoolId}
  194. </if>
  195. and maintenance_state != 4
  196. ) as all_count,
  197. (select Count(*) from repair_record where deleted = 0 and maintenance_state = 1
  198. <if test="keyWord != null and keyWord != ''">
  199. and (area_id like '%' #{keyWord} '%' or user_name like '%' #{keyWord} '%' or user_phone like '%' #{keyWord} '%')
  200. </if>
  201. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  202. and report_time between #{startTime} and #{endTime}
  203. </if>
  204. <if test="schoolId != null and schoolId != ''">
  205. and school_id = #{schoolId}
  206. </if>
  207. ) as dispatch_count,
  208. (select Count(*) from repair_record where deleted = 0 and maintenance_state = 2
  209. <if test="keyWord != null and keyWord != ''">
  210. and (area_id like '%' #{keyWord} '%' or user_name like '%' #{keyWord} '%' or user_phone like '%' #{keyWord} '%')
  211. </if>
  212. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  213. and report_time between #{startTime} and #{endTime}
  214. </if>
  215. <if test="schoolId != null and schoolId != ''">
  216. and school_id = #{schoolId}
  217. </if>
  218. ) as maintenance_count,
  219. (select Count(*) from repair_record where deleted = 0 and maintenance_state = 3
  220. <if test="keyWord != null and keyWord != ''">
  221. and (area_id like '%' #{keyWord} '%' or user_name like '%' #{keyWord} '%' or user_phone like '%' #{keyWord} '%')
  222. </if>
  223. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  224. and report_time between #{startTime} and #{endTime}
  225. </if>
  226. <if test="schoolId != null and schoolId != ''">
  227. and school_id = #{schoolId}
  228. </if>
  229. ) as logistics_count,
  230. (select Count(*) from repair_record where deleted = 0 and (maintenance_state = 5 or maintenance_state = 6)
  231. <if test="keyWord != null and keyWord != ''">
  232. and (area_id like '%' #{keyWord} '%' or user_name like '%' #{keyWord} '%' or user_phone like '%' #{keyWord} '%')
  233. </if>
  234. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  235. and report_time between #{startTime} and #{endTime}
  236. </if>
  237. <if test="schoolId != null and schoolId != ''">
  238. and school_id = #{schoolId}
  239. </if>
  240. ) as examine_count,
  241. (select Count(*) from repair_record where deleted = 0 and maintenance_state = 7
  242. <if test="keyWord != null and keyWord != ''">
  243. and (area_id like '%' #{keyWord} '%' or user_name like '%' #{keyWord} '%' or user_phone like '%' #{keyWord} '%')
  244. </if>
  245. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  246. and report_time between #{startTime} and #{endTime}
  247. </if>
  248. <if test="schoolId != null and schoolId != ''">
  249. and school_id = #{schoolId}
  250. </if>
  251. ) as finished_count,
  252. (select Count(*) from repair_record where deleted = 0 and maintenance_state = 8
  253. <if test="keyWord != null and keyWord != ''">
  254. and (area_id like '%' #{keyWord} '%' or user_name like '%' #{keyWord} '%' or user_phone like '%' #{keyWord} '%')
  255. </if>
  256. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  257. and report_time between #{startTime} and #{endTime}
  258. </if>
  259. <if test="schoolId != null and schoolId != ''">
  260. and school_id = #{schoolId}
  261. </if>
  262. ) as canceled_count,
  263. (select Count(*) from repair_record where deleted = 0 and maintenance_state = 9
  264. <if test="keyWord != null and keyWord != ''">
  265. and (area_id like '%' #{keyWord} '%' or user_name like '%' #{keyWord} '%' or user_phone like '%' #{keyWord} '%')
  266. </if>
  267. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  268. and report_time between #{startTime} and #{endTime}
  269. </if>
  270. <if test="schoolId != null and schoolId != ''">
  271. and school_id = #{schoolId}
  272. </if>
  273. ) as closed_count,
  274. (SELECT count(*) as cs FROM (
  275. select rdr.users_id as
  276. user_id,rr.maintenance_state,rr.article_id,rr.id,rr.record_no,rr.report_time,rr.user_name,rr.user_phone,rr.area_id
  277. as area_name,rr.address,rr.description,rr.image,rr.maintenancer_name,rr.maintenancer_phone,rr.price from
  278. repair_record rr
  279. inner join repair_dispatch_record rdr on rdr.deleted = 0 and rdr.record_id = rr.id and rdr.is_lose_efficacy = 0
  280. and ((date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) &lt;= NOW() and
  281. rdr.receiving_time is null) or date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) &lt;=
  282. rdr.receiving_time)
  283. where rr.is_duty = 0 and rr.maintenance_state &lt;= 7 and rr.deleted = 0
  284. <if test="keyWord != null and keyWord != ''">
  285. and (rr.area_id like '%' #{keyWord} '%' or rr.user_name like '%' #{keyWord} '%' or rr.user_phone like '%' #{keyWord} '%')
  286. </if>
  287. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  288. and rr.report_time between #{startTime} and #{endTime}
  289. </if>
  290. <if test="schoolId != null and schoolId != ''">
  291. and rr.school_id = #{schoolId}
  292. </if>
  293. UNION
  294. select
  295. rdv.user_id,rr.maintenance_state,rr.article_id,rr.id,rr.record_no,rr.report_time,rr.user_name,rr.user_phone,rr.area_id
  296. as area_name,rr.address,rr.description,rr.image,rr.maintenancer_name,rr.maintenancer_phone,rr.price from
  297. repair_record rr
  298. inner join repair_receiving rdv on rdv.deleted = 0 and rdv.record_id = rr.id and rdv.is_lose_efficacy = 0
  299. and ((date_add(rdv.receiving_time , interval rdv.maintenance_assess_time minute) &lt;= NOW() and
  300. rdv.maintenance_assess_time is null) or date_add(rdv.receiving_time , interval rdv.maintenance_assess_time
  301. minute) &lt;= rdv.finish_time)
  302. where rr.is_duty = 0 and rr.maintenance_state &lt;= 7 and rr.deleted = 0
  303. <if test="keyWord != null and keyWord != ''">
  304. and (rr.area_id like '%' #{keyWord} '%' or rr.user_name like '%' #{keyWord} '%' or rr.user_phone like '%' #{keyWord} '%')
  305. </if>
  306. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  307. and rr.report_time between #{startTime} and #{endTime}
  308. </if>
  309. <if test="schoolId != null and schoolId != ''">
  310. and rr.school_id = #{schoolId}
  311. </if>
  312. ) t) as timeout_count
  313. </select>
  314. <!--管理端工单分页数据-->
  315. <resultMap type="com.repair.model.vo.RepairRecordPageVo" id="repairRecordPageMap">
  316. <result property="id" column="id"/>
  317. <result property="recordNo" column="record_no"/>
  318. <result property="schoolId" column="school_id"/>
  319. <result property="userName" column="user_name"/>
  320. <result property="userPhone" column="user_phone"/>
  321. <result property="articleName" column="article_name"/>
  322. <result property="areaName" column="area_name"/>
  323. <result property="description" column="description"/>
  324. <result property="reportTime" column="report_time"/>
  325. <result property="maintenancerName" column="maintenancer_name"/>
  326. <result property="details" column="details"/>
  327. <result property="maintenanceState" column="maintenance_state"/>
  328. <result property="userId" column="user_id"/>
  329. </resultMap>
  330. <!--除已超时外的其他数据获取方式-->
  331. <select id="queryNotTimeout" resultType="com.repair.model.vo.RepairRecordPageVo" resultMap="repairRecordPageMap">
  332. select rr.school_id,rr.user_id,1 as details,rr.id,rr.record_no,rr.area_id as
  333. area_name,rr.user_name,rr.user_phone,rat.name as
  334. article_name,
  335. rr.description,rr.report_time,rr.maintenancer_name,rr.maintenance_state
  336. from repair_record rr
  337. left join repair_article_type rat on rat.deleted = 0 and rat.id = rr.article_id
  338. <where>
  339. and rr.deleted = 0
  340. <if test="schoolId != null and schoolId != ''">
  341. and rr.school_id = #{schoolId}
  342. </if>
  343. <if test="stateStr != null and stateStr != ''">
  344. and (rr.maintenance_state ${stateStr}
  345. </if>
  346. <if test="stateStr == null or stateStr == ''">
  347. and rr.maintenance_state != 4
  348. </if>
  349. <if test="keyWord != null and keyWord != ''">
  350. and (rr.area_id like '%' #{keyWord} '%' or rr.user_name like '%' #{keyWord} '%' or rr.user_phone like
  351. '%' #{keyWord} '%')
  352. </if>
  353. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  354. and rr.report_time between #{startTime} and #{endTime}
  355. </if>
  356. </where>
  357. order by rr.report_time desc
  358. </select>
  359. <resultMap type="com.repair.model.vo.RepairRecordTimeoutPageVo" id="repairRecordTimeoutPageMap">
  360. <result property="id" column="id"/>
  361. <result property="recordNo" column="record_no"/>
  362. <result property="schoolId" column="school_id"/>
  363. <result property="userName" column="user_name"/>
  364. <result property="userPhone" column="user_phone"/>
  365. <result property="articleName" column="article_name"/>
  366. <result property="areaName" column="area_name"/>
  367. <result property="description" column="description"/>
  368. <result property="reportTime" column="report_time"/>
  369. <result property="maintenancerName" column="maintenancer_name"/>
  370. <result property="details" column="details"/>
  371. <result property="maintenanceState" column="maintenance_state"/>
  372. <result property="timeoutStr" column="timeout_str"/>
  373. <result property="maintenanceTimeout" column="maintenance_timeout"/>
  374. <result property="userId" column="user_id"/>
  375. </resultMap>
  376. <!--#已超时获取方式-->
  377. <select id="queryTimeout" resultType="com.repair.model.vo.RepairRecordTimeoutPageVo"
  378. resultMap="repairRecordTimeoutPageMap">
  379. select t.school_id,t.user_id,t.details,t.id,t.record_no,t.area_name,t.user_name,t.user_phone,rat.name as
  380. article_name,t.description,t.report_time,t.maintenance_state,ru.user_name as maintenancer_name,ru.user_phone as
  381. maintenancer_phone,
  382. case ((date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) &lt;= NOW() and
  383. rdr.receiving_time is null) or date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) &lt;=
  384. rdr.receiving_time) when true then '超时未接' else null end as timeout_str,
  385. case ((date_add(rdv.receiving_time, interval rdv.maintenance_assess_time minute) &lt;= NOW() and
  386. rdv.maintenance_assess_time is null) or date_add(rdv.receiving_time , interval rdv.maintenance_assess_time
  387. minute) &lt;= rdv.finish_time) when true then '维修超时' else null end as maintenance_timeout
  388. FROM (
  389. select rr.school_id,rdr.users_id as user_id,1 as details,rr.id,rr.record_no,rr.area_id as
  390. area_name,rr.user_name,rr.user_phone,rr.price,rr.maintenance_state,rr.article_id,rr.report_time,rr.description
  391. from repair_record rr
  392. inner join repair_dispatch_record rdr on rdr.deleted = 0 and rdr.record_id = rr.id and rdr.is_lose_efficacy = 0
  393. and ((date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) &lt;= NOW() and
  394. rdr.receiving_time is null) or date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) &lt;=
  395. rdr.receiving_time)
  396. <where>
  397. and rr.deleted = 0 and rr.is_duty = 0 and rr.maintenance_state &lt;= 7
  398. <if test="keyWord != null and keyWord != ''">
  399. and (rr.area_id like '%' #{keyWord} '%' or rr.user_name like '%' #{keyWord} '%' or rr.user_phone like '%' #{keyWord} '%')
  400. </if>
  401. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  402. and rr.report_time between #{startTime} and #{endTime}
  403. </if>
  404. <if test="schoolId != null and schoolId != ''">
  405. and rr.school_id = #{schoolId}
  406. </if>
  407. </where>
  408. UNION
  409. select rr.school_id,rdv.user_id,1 as details,rr.id,rr.record_no,rr.area_id as
  410. area_name,rr.user_name,rr.user_phone,rr.price,rr.maintenance_state,rr.article_id,rr.report_time,rr.description
  411. from repair_record rr
  412. inner join repair_receiving rdv on rdv.deleted = 0 and rdv.record_id = rr.id and rdv.is_lose_efficacy = 0
  413. and ((date_add(rdv.receiving_time , interval rdv.maintenance_assess_time minute) &lt;= NOW() and
  414. rdv.maintenance_assess_time is null) or date_add(rdv.receiving_time , interval rdv.maintenance_assess_time
  415. minute) &lt;= rdv.finish_time)
  416. <where>
  417. and rr.deleted = 0 and rr.is_duty = 0 and rr.maintenance_state &lt;= 7
  418. <if test="keyWord != null and keyWord != ''">
  419. and (rr.area_id like '%' #{keyWord} '%' or rr.user_name like '%' #{keyWord} '%' or rr.user_phone like '%' #{keyWord} '%')
  420. </if>
  421. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  422. and rr.report_time between #{startTime} and #{endTime}
  423. </if>
  424. <if test="schoolId != null and schoolId != ''">
  425. and rr.school_id = #{schoolId}
  426. </if>
  427. </where>
  428. ) t
  429. left join repair_dispatch_record rdr on rdr.users_id =t.user_id and rdr.deleted = 0 and rdr.record_id = t.id and
  430. rdr.is_lose_efficacy = 0
  431. left join repair_receiving rdv on rdv.user_id =t.user_id and rdv.deleted = 0 and rdv.record_id = t.id and
  432. rdv.is_lose_efficacy = 0
  433. left join repair_article_type rat on rat.deleted = 0 and rat.id = t.article_id
  434. left join repair_user ru on ru.deleted = 0 and ru.id = t.user_id
  435. order by t.report_time desc
  436. </select>
  437. <!--#获取待处理池数据-->
  438. <resultMap type="com.repair.model.vo.pendingOrderVo" id="repairPendingOrderMap">
  439. <result property="id" column="id"/>
  440. <result property="recordNo" column="record_no"/>
  441. <result property="reportTime" column="report_time"/>
  442. <result property="userName" column="user_name"/>
  443. <result property="userPhone" column="user_phone"/>
  444. <result property="areaName" column="area_name"/>
  445. <result property="address" column="address"/>
  446. <result property="articleName" column="article_name"/>
  447. <result property="description" column="description"/>
  448. <result property="image" column="image"/>
  449. <result property="state" column="state"/>
  450. </resultMap>
  451. <select id="queryPendingOrder" resultType="com.repair.model.vo.pendingOrderVo" resultMap="repairPendingOrderMap">
  452. select * from (select (select Count(*) from repair_dispatch_record where is_lose_efficacy = 0 and record_id = rr.id and receiving_time is null) as disp_count,rr.id,rr.record_no,
  453. 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
  454. from repair_record rr
  455. left join repair_article_type rat on rat.id = rr.article_id
  456. where rr.maintenance_state = 1 and rr.deleted = 0) t where t.disp_count &lt;= 0
  457. order by t.report_time desc
  458. </select>
  459. <!--郭师傅维修 团队工单 头部数量-->
  460. <resultMap type="com.repair.model.vo.TeamWorkCountVo" id="teamWorkOrderMap">
  461. <result property="examineCount" column="examine_count"/>
  462. <result property="receivingCount" column="receiving_count"/>
  463. <result property="maintenanceCount" column="maintenance_count"/>
  464. <result property="finishedCount" column="finished_count"/>
  465. <result property="logisticsCount" column="logistics_count"/>
  466. <result property="timeoutCount" column="timeout_count"/>
  467. <result property="closedCount" column="closed_count"/>
  468. </resultMap>
  469. <select id="queryTeamWorkCount" resultType="com.repair.model.vo.TeamWorkCountVo" resultMap="teamWorkOrderMap">
  470. select
  471. (select Count(*) as sh from (
  472. select rr5.* from repair_record rr5
  473. inner join repair_collaborate_record rcr on rcr.deleted = 0 and rcr.record_id = rr5.id and
  474. rcr.approval_statu = 2
  475. where rr5.maintenance_state = 6 and rr5.school_id = #{schoolId} and rr5.deleted = 0
  476. UNION ALL
  477. select rr.* from repair_record rr
  478. inner join repair_transfer_record rtr on rtr.deleted = 0 and rtr.record_id = rr.id and
  479. rtr.approval_statu = 2
  480. where rr.maintenance_state = 5 and rr.school_id = #{schoolId} and rr.deleted = 0) a) as examine_count,
  481. (select Count(*) from repair_record rr1
  482. inner join repair_dispatch_record rdr on rdr.deleted = 0 and rdr.record_id = rr1.id and
  483. rdr.is_lose_efficacy = 0 and rdr.receiving_time is null
  484. where rr1.maintenance_state = 1 and rr1.school_id = #{schoolId} and rr1.deleted = 0) as receiving_count,
  485. (select Count(*) from repair_record rr2
  486. inner join repair_receiving rdv on rdv.deleted = 0 and rdv.record_id = rr2.id and
  487. rdv.is_lose_efficacy = 0
  488. where rr2.maintenance_state = 2 and rr2.school_id = #{schoolId} and rr2.deleted = 0) as maintenance_count,
  489. (select Count(*) from repair_record rr7
  490. where rr7.deleted = 0 and rr7.school_id = #{schoolId} and rr7.maintenance_state = 7) as finished_count,
  491. (select Count(*) from repair_record rr9
  492. where rr9.deleted = 0 and rr9.school_id = #{schoolId} and rr9.maintenance_state = 3) as logistics_count,
  493. (SELECT count(*) as cs FROM (
  494. select rdr.users_id as user_id,rr.maintenance_state,rr.article_id,rr.id,rr.record_no,rr.report_time,rr.user_name,rr.user_phone,rr.area_id as area_name,rr.address,rr.description,rr.image,rr.maintenancer_name,rr.maintenancer_phone,rr.price from repair_record rr
  495. inner join repair_dispatch_record rdr on rdr.deleted = 0 and rdr.record_id = rr.id and rdr.is_lose_efficacy = 0
  496. and ((date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) &lt;= NOW() and rdr.receiving_time is null) or date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) &lt;= rdr.receiving_time)
  497. where rr.is_duty = 0 and rr.maintenance_state &lt;= 7 and rr.deleted = 0 and rr.school_id = #{schoolId}
  498. UNION
  499. select rdv.user_id,rr.maintenance_state,rr.article_id,rr.id,rr.record_no,rr.report_time,rr.user_name,rr.user_phone,rr.area_id as area_name,rr.address,rr.description,rr.image,rr.maintenancer_name,rr.maintenancer_phone,rr.price from repair_record rr
  500. inner join repair_receiving rdv on rdv.deleted = 0 and rdv.record_id = rr.id and rdv.is_lose_efficacy = 0
  501. and ((date_add(rdv.receiving_time , interval rdv.maintenance_assess_time minute) &lt;= NOW() and rdv.maintenance_assess_time is null) or date_add(rdv.receiving_time , interval rdv.maintenance_assess_time minute) &lt;= rdv.finish_time)
  502. where rr.is_duty = 0 and rr.maintenance_state &lt;= 7 and rr.deleted = 0 and rr.school_id = #{schoolId}) t) as timeout_count,
  503. (select Count(*) from repair_record rr8
  504. where rr8.deleted = 0 and rr8.school_id = #{schoolId} and rr8.maintenance_state = 9) as closed_count
  505. </select>
  506. <!--待审核-->
  507. <select id="queryTeamWorkExamine" resultType="com.repair.model.vo.RepairTechnicianVo"
  508. resultMap="repairRecordTechnicianDataMap">
  509. 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,rr5.maintenancer_name,rr5.maintenancer_phone,rr5.price from repair_record rr5
  510. inner join repair_collaborate_record rcr on rcr.deleted = 0 and rcr.record_id = rr5.id and rcr.approval_statu = 2
  511. left join repair_article_type rat on rat.deleted = 0 and rat.id = rr5.article_id
  512. where rr5.maintenance_state = 6 and rr5.school_id = #{schoolId} and rr5.deleted = 0
  513. UNION ALL
  514. 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,rr.maintenancer_name,rr.maintenancer_phone,rr.price from repair_record rr
  515. inner join repair_transfer_record rtr on rtr.deleted = 0 and rtr.record_id = rr.id and rtr.approval_statu = 2
  516. left join repair_article_type rat on rat.deleted = 0 and rat.id = rr.article_id
  517. where rr.maintenance_state = 5 and rr.school_id = #{schoolId} and rr.deleted = 0
  518. </select>
  519. <!--待接单-->
  520. <select id="queryTeamWorkPending" resultType="com.repair.model.vo.RepairTechnicianVo"
  521. resultMap="repairRecordTechnicianDataMap">
  522. select case ((date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) &lt;= #{dateNow} and rdr.receiving_time is null) or date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) &lt;= rdr.receiving_time) 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,rr.maintenancer_name,rr.maintenancer_phone,rr.price
  523. from repair_record rr
  524. inner join repair_dispatch_record rdr on rdr.deleted = 0 and rdr.record_id = rr.id and rdr.is_lose_efficacy = 0
  525. left join repair_article_type rat on rat.deleted = 0 and rat.id = rr.article_id
  526. where rr.maintenance_state = 1 and rr.school_id = #{schoolId} and rr.deleted = 0
  527. order by rr.report_time DESC
  528. </select>
  529. <!--维修中-->
  530. <select id="queryTeamWorkMaintenance" resultType="com.repair.model.vo.RepairTechnicianVo"
  531. resultMap="repairRecordTechnicianDataMap">
  532. select case ((date_add(rdv.receiving_time, interval rdv.maintenance_assess_time minute) &lt;= #{dateNow} and rdv.maintenance_assess_time is null) or date_add(rdv.receiving_time , interval rdv.maintenance_assess_time minute) &lt;= rdv.finish_time) 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,rr.maintenancer_name,rr.maintenancer_phone,rr.price
  533. from repair_record rr
  534. inner join repair_receiving rdv on rdv.deleted = 0 and rdv.record_id = rr.id and rdv.is_lose_efficacy = 0
  535. left join repair_article_type rat on rat.deleted = 0 and rat.id = rr.article_id
  536. where rr.maintenance_state = 2 and rr.school_id = #{schoolId} and rr.deleted = 0
  537. order by rr.report_time DESC
  538. </select>
  539. <!--已完成-->
  540. <select id="queryTeamWorkFinished" resultType="com.repair.model.vo.RepairTechnicianVo"
  541. resultMap="repairRecordTechnicianDataMap">
  542. 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,rr.maintenancer_name,rr.maintenancer_phone,rr.price from repair_record rr
  543. left join repair_article_type rat on rat.deleted = 0 and rat.id = rr.article_id
  544. where rr.deleted = 0 and rr.school_id = #{schoolId} and rr.maintenance_state = 7
  545. order by rr.report_time DESC
  546. </select>
  547. <!--待处理-->
  548. <select id="queryTeamWorkLogistics" resultType="com.repair.model.vo.RepairTechnicianVo"
  549. resultMap="repairRecordTechnicianDataMap">
  550. 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,rr.maintenancer_name,rr.maintenancer_phone,rr.price from repair_record rr
  551. left join repair_article_type rat on rat.deleted = 0 and rat.id = rr.article_id
  552. where rr.deleted = 0 and rr.school_id = #{schoolId} and rr.maintenance_state = 3
  553. order by rr.report_time DESC
  554. </select>
  555. <!--已超时-->
  556. <select id="queryTeamWorkTimeout" resultType="com.repair.model.vo.RepairTechnicianVo"
  557. resultMap="repairRecordTechnicianDataMap">
  558. SELECT ru.user_name as maintenancer_name,ru.user_phone as maintenancer_phone,case ((date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) &lt;= NOW() and rdr.receiving_time is null) or date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) &lt;= rdr.receiving_time) when true then '超时未接' else null end as timeout_str,case ((date_add(rdv.receiving_time, interval rdv.maintenance_assess_time minute) &lt;= NOW() and rdv.maintenance_assess_time is null) or date_add(rdv.receiving_time , interval rdv.maintenance_assess_time minute) &lt;= rdv.finish_time) when true then '维修超时' else null end as maintenance_timeout,rat.name as article_name,t.id,t.maintenance_state,t.record_no,t.report_time,t.user_name,t.user_phone,t.area_name,t.address,t.description,t.image,t.price FROM (
  559. select rdr.users_id as user_id,rr.maintenance_state,rr.article_id,rr.id,rr.record_no,rr.report_time,rr.user_name,rr.user_phone,rr.area_id as area_name,rr.address,rr.description,rr.image,rr.maintenancer_name,rr.maintenancer_phone,rr.price from repair_record rr
  560. inner join repair_dispatch_record rdr on rdr.deleted = 0 and rdr.record_id = rr.id and rdr.is_lose_efficacy = 0
  561. and ((date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) &lt;= NOW() and rdr.receiving_time is null) or date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) &lt;= rdr.receiving_time)
  562. where rr.is_duty = 0 and rr.maintenance_state &lt;= 7 and rr.deleted = 0 and rr.school_id = #{schoolId}
  563. UNION
  564. select rdv.user_id,rr.maintenance_state,rr.article_id,rr.id,rr.record_no,rr.report_time,rr.user_name,rr.user_phone,rr.area_id as area_name,rr.address,rr.description,rr.image,rr.maintenancer_name,rr.maintenancer_phone,rr.price from repair_record rr
  565. inner join repair_receiving rdv on rdv.deleted = 0 and rdv.record_id = rr.id and rdv.is_lose_efficacy = 0
  566. and ((date_add(rdv.receiving_time , interval rdv.maintenance_assess_time minute) &lt;= NOW() and rdv.maintenance_assess_time is null) or date_add(rdv.receiving_time , interval rdv.maintenance_assess_time minute) &lt;= rdv.finish_time)
  567. where rr.is_duty = 0 and rr.maintenance_state &lt;= 7 and rr.deleted = 0 and rr.school_id = #{schoolId}) t
  568. left join repair_dispatch_record rdr on rdr.users_id =t.user_id and rdr.deleted = 0 and rdr.record_id = t.id and rdr.is_lose_efficacy = 0
  569. left join repair_receiving rdv on rdv.user_id =t.user_id and rdv.deleted = 0 and rdv.record_id = t.id and rdv.is_lose_efficacy = 0
  570. left join repair_article_type rat on rat.deleted = 0 and rat.id = t.article_id
  571. left join repair_user ru on ru.deleted = 0 and ru.id = t.user_id
  572. order by t.report_time desc
  573. </select>
  574. <!--已关单-->
  575. <select id="queryTeamWorkClosed" resultType="com.repair.model.vo.RepairTechnicianVo"
  576. resultMap="repairRecordTechnicianDataMap">
  577. 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,rr.maintenancer_name,rr.maintenancer_phone,rr.price from repair_record rr
  578. left join repair_article_type rat on rat.deleted = 0 and rat.id = rr.article_id
  579. where rr.deleted = 0 and rr.school_id = #{schoolId} and rr.maintenance_state = 9
  580. order by rr.report_time DESC
  581. </select>
  582. <!-- 报表导出获取除已超时外的其他数据获取方式-->
  583. <select id="queryNotTimeoutReportExport" resultType="com.repair.model.vo.ReportExportVo">
  584. 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
  585. article_name,
  586. rr.description,rr.report_time,rr.maintenancer_name,rr.maintenance_state
  587. from repair_record rr
  588. left join repair_article_type rat on rat.deleted = 0 and rat.id = rr.article_id
  589. <where>
  590. and rr.deleted = 0
  591. <if test="schoolId != null and schoolId != ''">
  592. and rr.school_id = #{schoolId}
  593. </if>
  594. <if test="stateStr != null and stateStr != ''">
  595. and (rr.maintenance_state ${stateStr}
  596. </if>
  597. <if test="keyWord != null and keyWord != ''">
  598. and (rr.area_id like '%' #{keyWord} '%' or rr.user_name like '%' #{keyWord} '%' or rr.user_phone like
  599. '%' #{keyWord} '%')
  600. </if>
  601. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  602. and rr.report_time between #{startTime} and #{endTime}
  603. </if>
  604. </where>
  605. order by rr.report_time desc
  606. </select>
  607. <!-- 报表导出获取除已超时数据获取方式-->
  608. <select id="queryTimeoutReportExport" resultType="com.repair.model.vo.ReportExportVo">
  609. SELECT * FROM (
  610. select rr3.user_id,1 as details,rr3.id,rr3.record_no,rr3.area_id as
  611. area_name,rr3.user_name,rr3.user_phone,rat.name as article_name,
  612. rr3.description,rr3.report_time,rr3.maintenancer_name,rr3.maintenance_state
  613. from repair_record rr3
  614. left join repair_article_type rat on rat.deleted = 0 and rat.id = rr3.article_id
  615. inner join repair_dispatch_record rdr on rdr.deleted = 0 and rdr.record_id = rr3.id and
  616. rdr.is_lose_efficacy = 0
  617. and ((date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) &lt;= NOW() and
  618. rdr.receiving_time is null) or date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) &lt;=
  619. rdr.receiving_time)
  620. <where>
  621. and rr3.deleted = 0 and rr3.is_duty = 0 and rr3.maintenance_state &lt;= 7
  622. <if test="keyWord != null and keyWord != ''">
  623. and (rr3.area_id like '%' #{keyWord} '%' or rr3.user_name like '%' #{keyWord} '%' or rr3.user_phone like
  624. '%' #{keyWord} '%')
  625. </if>
  626. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  627. and rr3.report_time between #{startTime} and #{endTime}
  628. </if>
  629. <if test="schoolId != null and schoolId != ''">
  630. and rr3.school_id = #{schoolId}
  631. </if>
  632. </where>
  633. UNION ALL
  634. select rr4.user_id,1 as details,rr4.id,rr4.record_no,rr4.area_id as
  635. area_name,rr4.user_name,rr4.user_phone,rat.name as
  636. article_name,
  637. rr4.description,rr4.report_time,rr4.maintenancer_name,rr4.maintenance_state
  638. from repair_record rr4
  639. left join repair_article_type rat on rat.deleted = 0 and rat.id = rr4.article_id
  640. inner join repair_receiving rdv on rdv.deleted = 0 and rdv.record_id = rr4.id and
  641. rdv.is_lose_efficacy = 0
  642. and ((date_add(rdv.receiving_time , interval rdv.maintenance_assess_time minute) &lt;= NOW() and
  643. rdv.maintenance_assess_time is null) or date_add(rdv.receiving_time , interval rdv.maintenance_assess_time
  644. minute) &lt;= rdv.finish_time)
  645. <where>
  646. and rr4.deleted = 0 and rr4.is_duty = 0 and rr4.maintenance_state &lt;= 7
  647. <if test="keyWord != null and keyWord != ''">
  648. and (rr4.area_id like '%' #{keyWord} '%' or rr4.user_name like '%' #{keyWord} '%' or rr4.user_phone like
  649. '%' #{keyWord} '%')
  650. </if>
  651. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  652. and rr4.report_time between #{startTime} and #{endTime}
  653. </if>
  654. <if test="schoolId != null and schoolId != ''">
  655. and rr4.school_id = #{schoolId}
  656. </if>
  657. </where>
  658. ) t
  659. order by t.report_time desc
  660. </select>
  661. <!--维修师傅首页头部数量-->
  662. <resultMap type="com.repair.model.vo.MasterHomepageVo" id="masterHomepageMap">
  663. <result property="workCount" column="work_count"/>
  664. <result property="processCount" column="process_count"/>
  665. <result property="finishCount" column="finish_count"/>
  666. <result property="timeoutCount" column="timeout_count"/>
  667. </resultMap>
  668. <!--说明:-->
  669. <!--#work_count 工单数:维修师傅的工单总数,只计算维修师傅的接单数,待接单不用计算进去-->
  670. <!--#process_count 处理中:维修中没有完成的工单,包含维修中,待接单,待审核-->
  671. <!--#finish_count 已完成:已取消 已完成 已关单-->
  672. <!--#timeout_count 已超时:包含接单超时 维修超时-->
  673. <select id="queryMasterHomeCount" resultType="com.repair.model.vo.MasterHomepageVo" resultMap="masterHomepageMap">
  674. select
  675. (select count(*) from repair_receiving
  676. where deleted = 0 and user_id = #{userId}) as work_count,
  677. (select
  678. (select Count(*) as rc from repair_record rr
  679. 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}
  680. where rr.deleted = 0 and rr.maintenance_state = 1) +
  681. (select Count(*) as wx from repair_record rr2
  682. inner join repair_receiving rdv on rdv.deleted = 0 and rdv.user_id = #{userId} and rdv.record_id = rr2.id and
  683. rdv.is_lose_efficacy = 0
  684. where rr2.maintenance_state = 2 and rr2.deleted = 0) +
  685. (select Count(*) as sh from (
  686. select rr5.* from repair_record rr5
  687. inner join repair_collaborate_record rcr on rcr.deleted = 0 and rcr.user_id = #{userId} and rcr.record_id = rr5.id and
  688. rcr.approval_statu = 2
  689. where rr5.maintenance_state = 6 and rr5.deleted = 0
  690. UNION ALL
  691. select rr.* from repair_record rr
  692. inner join repair_transfer_record rtr on rtr.deleted = 0 and rtr.user_id = #{userId} and rtr.record_id = rr.id and
  693. rtr.approval_statu = 2
  694. where rr.maintenance_state = 5 and rr.deleted = 0) a) as process_count) as process_count,
  695. (select Count(*) from repair_record rr
  696. 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}
  697. where rr.deleted = 0 and rr.maintenance_state >= 7) as finish_count,
  698. (select Count(*) as cs from (select rr3.*
  699. from repair_record rr3
  700. inner join repair_dispatch_record rdr on rdr.deleted = 0 and rdr.users_id = #{userId} and rdr.record_id = rr3.id and
  701. rdr.is_lose_efficacy = 0
  702. and ((date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) &lt;= NOW() and rdr.receiving_time is null) or date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) &lt;= rdr.receiving_time)
  703. where rr3.maintenance_state &lt;= 7 and rr3.is_duty = 0 and rr3.deleted = 0
  704. UNION
  705. select rr4.* from repair_record rr4
  706. inner join repair_receiving rdv on rdv.deleted = 0 and rdv.user_id = #{userId} and rdv.record_id = rr4.id and
  707. rdv.is_lose_efficacy = 0
  708. and ((date_add(rdv.receiving_time , interval rdv.maintenance_assess_time minute) &lt;= NOW() and rdv.maintenance_assess_time is null) or date_add(rdv.receiving_time , interval rdv.maintenance_assess_time minute) &lt;= rdv.finish_time)
  709. where rr4.maintenance_state &lt;= 7 and rr4.is_duty = 0 and rr4.deleted = 0) c) as timeout_count
  710. </select>
  711. <!--后勤人员和郭师傅首页头部数量-->
  712. <!--说明:-->
  713. <!--#work_count 工单数:对应校区的工单总数,只计算对应人员校区的接单数,待接单不用计算进去-->
  714. <!--#process_count 处理中:维修中没有完成的工单,包含维修中,待接单,待审核-->
  715. <!--#finish_count 已完成:已取消 已完成 已关单-->
  716. <!--#timeout_count 已超时:包含接单超时 维修超时-->
  717. <select id="queryLogisticHomeCount" resultType="com.repair.model.vo.MasterHomepageVo" resultMap="masterHomepageMap">
  718. select
  719. (select Count(*) from repair_receiving rc
  720. inner join repair_record rr on rr.deleted = 0 and rr.school_id = #{schoolId} and rr.id = rc.record_id
  721. where rc.deleted = 0) as work_count,
  722. (select
  723. (select Count(*) as rc from repair_record rr
  724. inner join repair_dispatch_record rdr on rdr.deleted = 0 and rdr.is_lose_efficacy = 0 and rdr.record_id = rr.id
  725. where rr.deleted = 0 and rr.maintenance_state = 1 and rr.school_id = #{schoolId}) +
  726. (select Count(*) as wx from repair_record rr2
  727. inner join repair_receiving rdv on rdv.deleted = 0 and rdv.record_id = rr2.id and
  728. rdv.is_lose_efficacy = 0
  729. where rr2.maintenance_state = 2 and rr2.deleted = 0 and rr2.school_id = #{schoolId}) +
  730. (select Count(*) as sh from (
  731. select rr5.* from repair_record rr5
  732. inner join repair_collaborate_record rcr on rcr.deleted = 0 and rcr.record_id = rr5.id and
  733. rcr.approval_statu = 2
  734. where rr5.maintenance_state = 6 and rr5.deleted = 0 and rr5.school_id = #{schoolId}
  735. UNION
  736. select rr.* from repair_record rr
  737. inner join repair_transfer_record rtr on rtr.deleted = 0 and rtr.record_id = rr.id and
  738. rtr.approval_statu = 2
  739. where rr.maintenance_state = 5 and rr.deleted = 0 and rr.school_id = #{schoolId}) a) as process_count) as process_count,
  740. (select Count(*) from repair_record rr
  741. inner join repair_dispatch_record rdr on rdr.deleted = 0 and rdr.is_lose_efficacy = 0 and rdr.record_id = rr.id
  742. where rr.deleted = 0 and rr.maintenance_state >= 7 and rr.school_id = #{schoolId}) as finish_count,
  743. (SELECT count(*) as cs FROM (
  744. select rdr.users_id as user_id,rr.maintenance_state,rr.article_id,rr.id,rr.record_no,rr.report_time,rr.user_name,rr.user_phone,rr.area_id as area_name,rr.address,rr.description,rr.image,rr.maintenancer_name,rr.maintenancer_phone,rr.price from repair_record rr
  745. inner join repair_dispatch_record rdr on rdr.deleted = 0 and rdr.record_id = rr.id and rdr.is_lose_efficacy = 0
  746. and ((date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) &lt;= NOW() and rdr.receiving_time is null) or date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) &lt;= rdr.receiving_time)
  747. where rr.is_duty = 0 and rr.maintenance_state &lt;= 7 and rr.deleted = 0 and rr.school_id = #{schoolId}
  748. UNION
  749. select rdv.user_id,rr.maintenance_state,rr.article_id,rr.id,rr.record_no,rr.report_time,rr.user_name,rr.user_phone,rr.area_id as area_name,rr.address,rr.description,rr.image,rr.maintenancer_name,rr.maintenancer_phone,rr.price from repair_record rr
  750. inner join repair_receiving rdv on rdv.deleted = 0 and rdv.record_id = rr.id and rdv.is_lose_efficacy = 0
  751. and ((date_add(rdv.receiving_time , interval rdv.maintenance_assess_time minute) &lt;= NOW() and rdv.maintenance_assess_time is null) or date_add(rdv.receiving_time , interval rdv.maintenance_assess_time minute) &lt;= rdv.finish_time)
  752. where rr.is_duty = 0 and rr.maintenance_state &lt;= 7 and rr.deleted = 0 and rr.school_id = #{schoolId}) t) as timeout_count
  753. </select>
  754. <select id="repairCampusTotal" resultType="com.repair.model.vo.RepairCampusVo">
  755. SELECT rs.id,
  756. count(rr.school_id) as orders_total,
  757. rs.`name` as school_name,
  758. (SELECT COUNT(school_id)
  759. FROM `repair_record`
  760. WHERE price > 0
  761. AND rs.id = school_id
  762. AND deleted = 0) AS orders_compensation,
  763. (SELECT COUNT(school_id)
  764. FROM `repair_record`
  765. WHERE (price IS NULL OR price = 0)
  766. AND rs.id = school_id
  767. AND deleted = 0) AS orders_gratis,
  768. SUM(rr.price) AS total_price
  769. FROM `repair_record` rr
  770. LEFT JOIN repair_school rs ON rs.deleted = 0
  771. AND rr.school_id = rs.id
  772. AND rr.deleted = 0
  773. GROUP BY rr.school_id
  774. </select>
  775. <select id="repairCampus" resultType="com.repair.model.vo.RepairCampusVo">
  776. SELECT
  777. rs.id,
  778. count( rr.school_id ) as orders_total,
  779. rs.`name` as school_name,
  780. (
  781. SELECT
  782. COUNT( school_id )
  783. FROM
  784. `repair_record`
  785. <where>
  786. and price > 0
  787. AND rs.id = school_id
  788. AND deleted = 0
  789. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  790. and report_time between #{startTime} and #{endTime}
  791. </if>
  792. </where>
  793. ) AS orders_compensation,
  794. (
  795. SELECT
  796. COUNT( school_id )
  797. FROM
  798. `repair_record`
  799. <where>
  800. and ( price IS NULL OR price = 0 )
  801. AND rs.id = school_id
  802. AND deleted = 0
  803. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  804. and report_time between #{startTime} and #{endTime}
  805. </if>
  806. </where>
  807. ) AS orders_gratis,
  808. SUM( rr.price ) AS total_price
  809. FROM
  810. `repair_record` rr
  811. LEFT JOIN repair_school rs ON rs.deleted = 0
  812. AND rr.school_id = rs.id
  813. <where>
  814. AND rr.deleted = 0
  815. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  816. and report_time between #{startTime} and #{endTime}
  817. </if>
  818. </where>
  819. GROUP BY
  820. rr.school_id
  821. </select>
  822. <select id="repairAreaTotal" resultType="com.repair.model.vo.RepairAreaVo">
  823. SELECT row_number() over ( ORDER BY ra.area_name ) AS id, ra.*
  824. FROM (SELECT count(rr.area_id) AS orders_total,
  825. rs.`name` AS school_name,
  826. rr.area_id AS area_name,
  827. (SELECT COUNT(area_id)
  828. FROM `repair_record`
  829. WHERE price > 0
  830. AND rr.area_id = area_id
  831. AND deleted = 0) AS orders_compensation,
  832. (SELECT COUNT(area_id)
  833. FROM `repair_record`
  834. WHERE (price IS NULL OR price = 0)
  835. AND rr.area_id = area_id
  836. AND deleted = 0) AS orders_gratis,
  837. SUM(rr.price) AS total_price
  838. FROM `repair_record` rr
  839. LEFT JOIN repair_school rs ON rs.deleted = 0
  840. AND rr.school_id = rs.id
  841. where rr.deleted = 0
  842. GROUP BY rr.area_id) ra
  843. </select>
  844. <select id="repairArea" resultType="com.repair.model.vo.RepairAreaVo">
  845. SELECT row_number() over ( ORDER BY ra.area_name ) AS id, ra.*
  846. FROM (SELECT count(rr.area_id) AS orders_total,
  847. rs.`name` AS school_name,
  848. rr.area_id AS area_name,
  849. (SELECT COUNT(area_id)
  850. FROM `repair_record`
  851. <where>
  852. AND price > 0
  853. AND rr.area_id = area_id
  854. AND deleted = 0
  855. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  856. and report_time between #{startTime} and #{endTime}
  857. </if>
  858. </where>
  859. ) AS orders_compensation,
  860. (SELECT COUNT(area_id)
  861. FROM `repair_record`
  862. <where>
  863. AND (price IS NULL OR price = 0)
  864. AND rr.area_id = area_id
  865. AND deleted = 0
  866. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  867. and report_time between #{startTime} and #{endTime}
  868. </if>
  869. </where>
  870. ) AS orders_gratis,
  871. SUM(rr.price) AS total_price
  872. FROM `repair_record` rr
  873. LEFT JOIN repair_school rs ON rs.deleted = 0
  874. AND rr.school_id = rs.id
  875. <where>
  876. AND rr.deleted=0
  877. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  878. and report_time between #{startTime} and #{endTime}
  879. </if>
  880. </where>
  881. GROUP BY rr.area_id) ra
  882. </select>
  883. <select id="maintenanceGoodsTotal" resultType="com.repair.model.vo.MaintenanceGoodsVo">
  884. SELECT row_number() over ( ORDER BY wx.article_name ) AS id, wx.*
  885. FROM (SELECT rat.`name` AS article_name,
  886. count(rr.article_id) AS orders_total,
  887. (SELECT COUNT(article_id)
  888. FROM `repair_record`
  889. WHERE price > 0
  890. AND rr.article_id = article_id
  891. AND deleted = 0) AS orders_compensation,
  892. (SELECT COUNT(article_id)
  893. FROM `repair_record`
  894. WHERE (price IS NULL OR price = 0)
  895. AND rr.article_id = article_id
  896. AND deleted = 0) AS orders_gratis,
  897. SUM(rr.price) AS total_price
  898. FROM `repair_record` rr
  899. LEFT JOIN repair_article_type rat ON rat.deleted = 0
  900. AND rr.article_id = rat.id
  901. WHERE rr.deleted = 0
  902. GROUP BY rr.article_id) wx
  903. </select>
  904. <select id="maintenanceGoods" resultType="com.repair.model.vo.MaintenanceGoodsVo">
  905. SELECT row_number() over ( ORDER BY wx.article_name ) AS id, wx.*
  906. FROM (SELECT rat.`name` AS article_name,
  907. count(rr.article_id) AS orders_total,
  908. (SELECT COUNT(article_id)
  909. FROM `repair_record`
  910. <where>
  911. and price > 0 AND rr.article_id = article_id AND deleted = 0
  912. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  913. and report_time between #{startTime} and #{endTime}
  914. </if>
  915. </where>
  916. ) AS orders_compensation,
  917. (SELECT COUNT(article_id)
  918. FROM `repair_record`
  919. <where>
  920. and (price IS NULL OR price = 0)
  921. AND rr.article_id = article_id
  922. AND deleted = 0
  923. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  924. and report_time between #{startTime} and #{endTime}
  925. </if>
  926. </where>
  927. ) AS orders_gratis,
  928. SUM(rr.price) AS total_price
  929. FROM `repair_record` rr
  930. LEFT JOIN repair_article_type rat ON rat.deleted = 0
  931. AND rr.article_id = rat.id
  932. <where>
  933. and rr.deleted = 0
  934. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  935. and report_time between #{startTime} and #{endTime}
  936. </if>
  937. </where>
  938. GROUP BY rr.article_id) wx
  939. </select>
  940. <select id="repairAreaExport" resultType="com.repair.model.vo.RepairAreaVo">
  941. SELECT row_number() over ( ORDER BY ra.area_name ) AS id, ra.*
  942. FROM (SELECT count(rr.area_id) AS orders_total,
  943. rs.`name` AS school_name,
  944. rr.area_id AS area_name,
  945. (SELECT COUNT(area_id)
  946. FROM `repair_record`
  947. <where>
  948. AND price > 0
  949. AND rr.area_id = area_id
  950. AND deleted = 0
  951. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  952. and report_time between #{startTime} and #{endTime}
  953. </if>
  954. </where>
  955. ) AS orders_compensation,
  956. (SELECT COUNT(area_id)
  957. FROM `repair_record`
  958. <where>
  959. AND (price IS NULL OR price = 0)
  960. AND rr.area_id = area_id
  961. AND deleted = 0
  962. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  963. and report_time between #{startTime} and #{endTime}
  964. </if>
  965. </where>
  966. ) AS orders_gratis,
  967. SUM(rr.price) AS total_price
  968. FROM `repair_record` rr
  969. LEFT JOIN repair_school rs ON rs.deleted = 0
  970. AND rr.school_id = rs.id
  971. <where>
  972. AND rr.deleted=0
  973. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  974. and report_time between #{startTime} and #{endTime}
  975. </if>
  976. </where>
  977. GROUP BY rr.area_id) ra
  978. </select>
  979. <select id="maintenanceGoodsExport" resultType="com.repair.model.vo.MaintenanceGoodsVo">
  980. SELECT row_number() over ( ORDER BY wx.article_name ) AS id, wx.*
  981. FROM (SELECT rat.`name` AS article_name,
  982. count(rr.article_id) AS orders_total,
  983. (SELECT COUNT(article_id)
  984. FROM `repair_record`
  985. <where>
  986. and price > 0 AND rr.article_id = article_id AND deleted = 0
  987. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  988. and report_time between #{startTime} and #{endTime}
  989. </if>
  990. </where>
  991. ) AS orders_compensation,
  992. (SELECT COUNT(article_id)
  993. FROM `repair_record`
  994. <where>
  995. and (price IS NULL OR price = 0)
  996. AND rr.article_id = article_id
  997. AND deleted = 0
  998. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  999. and report_time between #{startTime} and #{endTime}
  1000. </if>
  1001. </where>
  1002. ) AS orders_gratis,
  1003. SUM(rr.price) AS total_price
  1004. FROM `repair_record` rr
  1005. LEFT JOIN repair_article_type rat ON rat.deleted = 0
  1006. AND rr.article_id = rat.id
  1007. <where>
  1008. and rr.deleted = 0
  1009. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  1010. and report_time between #{startTime} and #{endTime}
  1011. </if>
  1012. </where>
  1013. GROUP BY rr.article_id) wx
  1014. </select>
  1015. <!--报修详情-->
  1016. <resultMap type="com.repair.model.vo.DetailsVo" id="detailDatasMap">
  1017. <result property="id" column="id"/>
  1018. <result property="maintenanceState" column="maintenance_state"/>
  1019. <result property="recordNo" column="record_no"/>
  1020. <result property="reportTime" column="report_time"/>
  1021. <result property="userName" column="user_name"/>
  1022. <result property="userPhone" column="user_phone"/>
  1023. <result property="areaName" column="area_name"/>
  1024. <result property="address" column="address"/>
  1025. <result property="articleName" column="article_name"/>
  1026. <result property="description" column="description"/>
  1027. <result property="voice" column="voice"/>
  1028. <result property="voiceLength" column="voice_length"/>
  1029. <result property="image" column="image"/>
  1030. <result property="maintenancerName" column="maintenancer_name"/>
  1031. <result property="maintenancerPhone" column="maintenancer_phone"/>
  1032. <result property="price" column="price"/>
  1033. </resultMap>
  1034. <select id="queryDetailData" resultType="com.repair.model.vo.DetailsVo" resultMap="detailDatasMap">
  1035. select rr.id,rr.maintenance_state,rr.record_no,rr.report_time,rr.user_name,rr.user_phone,rr.area_id as
  1036. area_name,rr.address,rat.name as article_name,
  1037. rr.description,rr.voice,rr.voice_length,rr.image,rr.maintenancer_name,rr.maintenancer_phone,rr.price
  1038. from repair_record rr
  1039. left join repair_article_type rat on rat.deleted = 0 and rat.id = rr.article_id
  1040. where rr.deleted = 0
  1041. <if test="recordId != null and recordId != ''">
  1042. and rr.id = #{recordId}
  1043. </if>
  1044. </select>
  1045. <select id="repairAnalysis" resultType="com.repair.model.vo.RepairAnalysisVo">
  1046. SELECT
  1047. COUNT(*) AS total_count,
  1048. (SELECT COUNT(*) FROM repair_record
  1049. <where>
  1050. AND deleted = 0
  1051. and (maintenance_state in (5,6))
  1052. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  1053. and report_time between #{startTime} and #{endTime}
  1054. </if>
  1055. </where>
  1056. ) as check_count ,
  1057. (SELECT COUNT(*) FROM repair_record
  1058. <where>
  1059. AND deleted = 0
  1060. and maintenance_state = 1
  1061. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  1062. and report_time between #{startTime} and #{endTime}
  1063. </if>
  1064. </where>
  1065. ) as receiving_count ,
  1066. (SELECT COUNT(*) FROM repair_record
  1067. <where>
  1068. AND deleted = 0
  1069. and maintenance_state = 2
  1070. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  1071. and report_time between #{startTime} and #{endTime}
  1072. </if>
  1073. </where>
  1074. ) as maintain_count ,
  1075. (SELECT COUNT(*) FROM repair_record
  1076. <where>
  1077. AND deleted = 0
  1078. and maintenance_state = 7
  1079. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  1080. and report_time between #{startTime} and #{endTime}
  1081. </if>
  1082. </where>
  1083. ) as accomplish_count ,
  1084. (SELECT COUNT(*) FROM repair_record
  1085. <where>
  1086. AND deleted = 0
  1087. and maintenance_state = 9
  1088. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  1089. and report_time between #{startTime} and #{endTime}
  1090. </if>
  1091. </where>
  1092. ) as shut_count ,
  1093. (SELECT COUNT(*) FROM repair_record
  1094. <where>
  1095. AND deleted = 0
  1096. and maintenance_state = 8
  1097. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  1098. and report_time between #{startTime} and #{endTime}
  1099. </if>
  1100. </where>
  1101. ) as cancel_count ,
  1102. (SELECT COUNT(*) FROM repair_record
  1103. <where>
  1104. AND deleted = 0
  1105. and maintenance_state = 3
  1106. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  1107. and report_time between #{startTime} and #{endTime}
  1108. </if>
  1109. </where>
  1110. ) as dispose_count ,
  1111. (SELECT COUNT(*) FROM repair_record
  1112. <where>
  1113. AND deleted = 0
  1114. and maintenance_state = 4
  1115. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  1116. and report_time between #{startTime} and #{endTime}
  1117. </if>
  1118. </where>
  1119. )
  1120. as affirm_count
  1121. FROM
  1122. repair_record rr
  1123. <where>
  1124. AND rr.deleted = 0
  1125. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  1126. and rr.report_time between #{startTime} and #{endTime}
  1127. </if>
  1128. </where>
  1129. </select>
  1130. <select id="queryTimeOut" resultType="java.lang.Integer">
  1131. SELECT COUNT(*) FROM (
  1132. select rr3.school_id,rr3.user_id,1 as details,rr3.id,rr3.record_no,rr3.area_id as
  1133. area_name,rr3.user_name,rr3.user_phone,rat.name as article_name,
  1134. rr3.description,rr3.report_time,concat((select user_name from repair_user where id = rdr.users_id),'-','接单超时')
  1135. as maintenancer_name,rr3.maintenance_state
  1136. from repair_record rr3
  1137. left join repair_article_type rat on rat.deleted = 0 and rat.id = rr3.article_id
  1138. inner join repair_dispatch_record rdr on rdr.deleted = 0 and rdr.record_id = rr3.id and
  1139. rdr.is_lose_efficacy = 0
  1140. and ((date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) &lt;= NOW() and
  1141. rdr.receiving_time is null) or date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) &lt;=
  1142. rdr.receiving_time)
  1143. <where>
  1144. and rr3.deleted = 0 and rr3.is_duty = 0 and rr3.maintenance_state &lt;= 7
  1145. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  1146. and rr3.report_time between #{startTime} and #{endTime}
  1147. </if>
  1148. </where>
  1149. UNION ALL
  1150. select rr4.school_id,rr4.user_id,1 as details,rr4.id,rr4.record_no,rr4.area_id as
  1151. area_name,rr4.user_name,rr4.user_phone,rat.name as
  1152. article_name,
  1153. rr4.description,rr4.report_time,concat((select user_name from repair_user where id = rdv.user_id),'-','维修超时')
  1154. as maintenancer_name,rr4.maintenance_state
  1155. from repair_record rr4
  1156. left join repair_article_type rat on rat.deleted = 0 and rat.id = rr4.article_id
  1157. inner join repair_receiving rdv on rdv.deleted = 0 and rdv.record_id = rr4.id and
  1158. rdv.is_lose_efficacy = 0
  1159. and ((date_add(rdv.receiving_time , interval rdv.maintenance_assess_time minute) &lt;= NOW() and
  1160. rdv.maintenance_assess_time is null) or date_add(rdv.receiving_time , interval rdv.maintenance_assess_time
  1161. minute) &lt;= rdv.finish_time)
  1162. <where>
  1163. and rr4.deleted = 0 and rr4.is_duty = 0 and rr4.maintenance_state &lt;= 7
  1164. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  1165. and rr4.report_time between #{startTime} and #{endTime}
  1166. </if>
  1167. </where>
  1168. ) t
  1169. </select>
  1170. <select id="repairSummarizing" resultType="com.repair.model.vo.RepairSummarizingVo">
  1171. SELECT
  1172. COUNT(*) AS total_count,
  1173. (SELECT COUNT(*) FROM repair_record
  1174. <where>
  1175. AND deleted = 0
  1176. and (maintenance_state in (5,6))
  1177. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  1178. and report_time between #{startTime} and #{endTime}
  1179. </if>
  1180. </where>
  1181. ) as check_count ,
  1182. (SELECT COUNT(*) FROM repair_record
  1183. <where>
  1184. AND deleted = 0
  1185. and maintenance_state = 1
  1186. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  1187. and report_time between #{startTime} and #{endTime}
  1188. </if>
  1189. </where>
  1190. ) as receiving_count ,
  1191. (SELECT COUNT(*) FROM repair_record
  1192. <where>
  1193. AND deleted = 0
  1194. and maintenance_state = 2
  1195. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  1196. and report_time between #{startTime} and #{endTime}
  1197. </if>
  1198. </where>
  1199. ) as maintain_count ,
  1200. (SELECT COUNT(*) FROM repair_record
  1201. <where>
  1202. AND deleted = 0
  1203. and maintenance_state = 7
  1204. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  1205. and report_time between #{startTime} and #{endTime}
  1206. </if>
  1207. </where>
  1208. ) as accomplish_count ,
  1209. (SELECT COUNT(*) FROM repair_record
  1210. <where>
  1211. AND deleted = 0
  1212. and maintenance_state = 9
  1213. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  1214. and report_time between #{startTime} and #{endTime}
  1215. </if>
  1216. </where>
  1217. ) as shut_count ,
  1218. (SELECT COUNT(*) FROM repair_record
  1219. <where>
  1220. AND deleted = 0
  1221. and maintenance_state = 8
  1222. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  1223. and report_time between #{startTime} and #{endTime}
  1224. </if>
  1225. </where>
  1226. ) as cancel_count ,
  1227. (SELECT COUNT(*) FROM repair_record
  1228. <where>
  1229. AND deleted = 0
  1230. and maintenance_state = 3
  1231. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  1232. and report_time between #{startTime} and #{endTime}
  1233. </if>
  1234. </where>
  1235. ) as dispose_count ,
  1236. (SELECT COUNT(*) FROM repair_record
  1237. <where>
  1238. AND deleted = 0
  1239. and maintenance_state = 4
  1240. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  1241. and report_time between #{startTime} and #{endTime}
  1242. </if>
  1243. </where>
  1244. )
  1245. as affirm_count
  1246. FROM
  1247. repair_record rr
  1248. <where>
  1249. AND rr.deleted = 0
  1250. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  1251. and rr.report_time between #{startTime} and #{endTime}
  1252. </if>
  1253. </where>
  1254. </select>
  1255. </mapper>