RepairRecordMapper.xml 68 KB

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