RepairRecordMapper.xml 82 KB

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