RepairRecordMapper.xml 79 KB

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