| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.repair.mapper.RepairRecordMapper">
- <resultMap type="com.repair.model.vo.RepairRecordCountVo" id="repairRecordCountMap">
- <result property="Incomplete" column="Incomplete"/>
- <result property="Confirmed" column="Confirmed"/>
- <result property="Finished" column="Finished"/>
- </resultMap>
- <select id="queryRepairRecordCount" resultType="com.repair.model.vo.RepairRecordCountVo"
- resultMap="repairRecordCountMap">
- SELECT COUNT(IF(maintenance_state < 7 or maintenance_state = 11,1, NULL))
- Incomplete,COUNT(IF(maintenance_state=4,1, NULL))
- Confirmed,COUNT(IF(maintenance_state >=7 and maintenance_state <= 10 ,1, NULL)) Finished FROM
- `repair_record`
- <where>
- and deleted = 0
- <if test="userId != null and userId != ''">
- and user_id = #{userId}
- </if>
- </where>
- </select>
- <resultMap type="com.repair.model.vo.MyRepairRecordVo" id="repairRecordOwnMap">
- <result property="id" column="id"/>
- <result property="recordNo" column="record_no"/>
- <result property="reportTime" column="report_time"/>
- <result property="userName" column="user_name"/>
- <result property="userPhone" column="user_phone"/>
- <result property="areaName" column="area_name"/>
- <result property="address" column="address"/>
- <result property="articleName" column="article_name"/>
- <result property="descript" column="description"/>
- <result property="image" column="image"/>
- <result property="stateId" column="state_id"/>
- <result property="price" column="price"/>
- <result property="maintenancerName" column="maintenancer_name"/>
- <result property="maintenancerPhone" column="maintenancer_phone"/>
- <result property="timeoutDispStr" column="timeout_disp_str"/>
- <result property="timeoutReceStr" column="timeout_rece_str"/>
- <result property="voice" column="voice"/>
- <result property="voiceLength" column="voice_length"/>
- <result property="finishVoice" column="finish_voice"/>
- <result property="finishVoiceLength" column="finish_voice_length"/>
- </resultMap>
- <select id="queryMyRepairRecordList" resultType="com.repair.model.vo.MyRepairRecordVo"
- resultMap="repairRecordOwnMap">
- select
- case ((date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) <= NOW() and
- rdr.receiving_time is null) or date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) <=
- rdr.receiving_time) and rr.maintenance_state <= 7 and rr.is_duty = 0 when true then '超时未接'
- else null end as timeout_disp_str,
- case ((date_add(rdv.receiving_time, interval rdv.maintenance_assess_time minute) <= NOW() and
- rdv.maintenance_assess_time is null) or date_add(rdv.receiving_time , interval rdv.maintenance_assess_time
- minute) <= rdv.finish_time) and rr.maintenance_state <= 7 and rr.is_duty = 0 when true then '维修超时'
- else null end as timeout_rece_str,rr.user_class,
- rr.voice,rr.voice_length,rr.finish_voice,rr.finish_voice_length,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
- as area_name,rr.address,rr.description,rat.name as article_name,rr.image,rr.maintenance_state as state_id from
- repair_record rr
- left join repair_article_type rat on rat.id = rr.article_id
- left join repair_dispatch_record rdr on rdr.deleted = 0 and rdr.record_id = rr.id and rdr.is_lose_efficacy = 0
- left join repair_receiving rdv on rdv.deleted = 0 and rdv.record_id = rr.id and rdv.is_lose_efficacy = 0
- <where>
- and rr.deleted = 0
- <if test="stateStr != null and stateStr != ''">
- and (rr.maintenance_state ${stateStr}
- </if>
- <if test="userId != null and userId != ''">
- and rr.user_id = #{userId}
- </if>
- </where>
- GROUP BY rr.id
- order by rr.report_time DESC
- </select>
- <resultMap type="com.repair.model.vo.MaintenanceTechnicianVo" id="repairRecordTechnicianMap">
- <result property="receivingCount" column="receiving_count"/>
- <result property="maintenanceCount" column="maintenance_count"/>
- <result property="timeoutCount" column="timeout_count"/>
- <result property="examineCount" column="examine_count"/>
- </resultMap>
- <select id="queryRepairTechnicianCount" resultType="com.repair.model.vo.MaintenanceTechnicianVo"
- resultMap="repairRecordTechnicianMap">
- select (select Count(*) from repair_record rr
- 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}
- where rr.deleted = 0 and rr.school_id = #{schoolId} and rr.maintenance_state = 1) as receiving_count ,
- (select Count(*) from repair_record rr2
- 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
- where rr2.maintenance_state = 2 and rr2.school_id = #{schoolId} and rr2.deleted = 0) as maintenance_count,
- (select Count(*) as cs from (select rr3.*
- from repair_record rr3
- inner join repair_dispatch_record rdr on rdr.deleted = 0 and rdr.users_id = #{userId} and rdr.record_id = rr3.id and
- rdr.is_lose_efficacy = 0
- and ((date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) <= #{dateNow} and rdr.receiving_time is null) or date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) <= rdr.receiving_time)
- where rr3.is_duty = 0 and rr3.school_id = #{schoolId} and rr3.maintenance_state <= 7 and rr3.deleted = 0
- UNION
- select rr4.* from repair_record rr4
- inner join repair_receiving rdv on rdv.deleted = 0 and rdv.user_id = #{userId} and rdv.record_id = rr4.id and
- rdv.is_lose_efficacy = 0
- and ((date_add(rdv.receiving_time , interval rdv.maintenance_assess_time minute) <= #{dateNow} and rdv.maintenance_assess_time is null) or date_add(rdv.receiving_time , interval rdv.maintenance_assess_time minute) <= rdv.finish_time)
- where rr4.is_duty = 0 and rr4.school_id = #{schoolId} and rr4.maintenance_state <= 7 and rr4.deleted = 0) c) as timeout_count,
- (select Count(*) as sh from (
- select rr5.* from repair_record rr5
- inner join repair_collaborate_record rcr on rcr.deleted = 0 and rcr.user_id = #{userId} and rcr.record_id = rr5.id and
- rcr.approval_statu = 2
- where rr5.maintenance_state = 6 and rr5.school_id = #{schoolId} and rr5.deleted = 0
- UNION ALL
- select rr.* from repair_record rr
- 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
- where rr.maintenance_state = 5 and rr.school_id = #{schoolId} and rr.deleted = 0
- UNION ALL
- select rr.* from repair_record rr
- inner join repair_offline_record ror on ror.deleted = 0 and ror.user_id = #{userId} and ror.record_id = rr.id and
- ror.approval_statu = 2
- where rr.maintenance_state = 11 and rr.school_id = #{schoolId} and rr.deleted = 0
- ) a) as examine_count
- </select>
- <resultMap type="com.repair.model.vo.RepairTechnicianVo" id="repairRecordTechnicianDataMap">
- <result property="id" column="id"/>
- <result property="recordNo" column="record_no"/>
- <result property="reportTime" column="report_time"/>
- <result property="userName" column="user_name"/>
- <result property="userPhone" column="user_phone"/>
- <result property="areaName" column="area_name"/>
- <result property="address" column="address"/>
- <result property="articleName" column="article_name"/>
- <result property="description" column="description"/>
- <result property="image" column="image"/>
- <result property="state" column="state"/>
- <result property="maintenanceState" column="maintenance_state"/>
- <result property="timeoutStr" column="timeout_str"/>
- <result property="maintenanceTimeout" column="maintenance_timeout"/>
- <result property="maintenancerName" column="maintenancer_name"/>
- <result property="maintenancerPhone" column="maintenancer_phone"/>
- <result property="voice" column="voice"/>
- <result property="voiceLength" column="voice_length"/>
- <result property="finishVoice" column="finish_voice"/>
- <result property="finishVoiceLength" column="finish_voice_length"/>
- <result property="price" column="price"/>
- </resultMap>
- <!--待接单-->
- <select id="queryPendingOrderList" resultType="com.repair.model.vo.RepairTechnicianVo"
- resultMap="repairRecordTechnicianDataMap">
- select t.*,ru.user_name as maintenancer_name,ru.user_phone as maintenancer_phone from (
- select case ((date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) <= #{dateNow} and rdr.receiving_time is null) or date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) <= rdr.receiving_time) and rr.is_duty = 0 when true then '超时未接' else null end as timeout_str,
- 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.price,
- rr.user_class
- from repair_record rr
- 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
- left join repair_article_type rat on rat.deleted = 0 and rat.id = rr.article_id
- where rr.maintenance_state = 1 and rr.deleted = 0 and rr.school_id = #{schoolId}
- ) t
- left join repair_user ru on ru.id = #{userId}
- order by t.report_time DESC
- </select>
- <!--维修中-->
- <select id="queryRepairOrderList" resultType="com.repair.model.vo.RepairTechnicianVo"
- resultMap="repairRecordTechnicianDataMap">
- select t.*,ru.user_name as maintenancer_name,ru.user_phone as maintenancer_phone from (
- select case ((date_add(rdv.receiving_time, interval rdv.maintenance_assess_time minute) <= #{dateNow} and rdv.maintenance_assess_time is null) or date_add(rdv.receiving_time , interval rdv.maintenance_assess_time minute) <= rdv.finish_time) and rr.is_duty = 0 when true then '维修超时' else null end as timeout_str,
- 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.price,
- rr.user_class
- from repair_record rr
- 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
- left join repair_article_type rat on rat.deleted = 0 and rat.id = rr.article_id
- where rr.maintenance_state = 2 and rr.deleted = 0 and rr.school_id = #{schoolId}
- ) t
- left join repair_user ru on ru.id = #{userId}
- order by t.report_time DESC
- </select>
- <!--已超时-->
- <select id="queryTimeoutOrderList" resultType="com.repair.model.vo.RepairTechnicianVo"
- resultMap="repairRecordTechnicianDataMap">
- SELECT case ((date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) <= NOW() and rdr.receiving_time is null) or date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) <= rdr.receiving_time) when true then '超时未接' else null end as timeout_str,case ((date_add(rdv.receiving_time, interval rdv.maintenance_assess_time minute) <= NOW() and rdv.maintenance_assess_time is null) or date_add(rdv.receiving_time , interval rdv.maintenance_assess_time minute) <= rdv.finish_time) when true then '维修超时' else null end as maintenance_timeout,rat.name as article_name,t.* FROM (
- 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,rr.user_class
- from repair_record rr
- 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 ((date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) <= NOW() and rdr.receiving_time is null) or date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) <= rdr.receiving_time)
- where rr.is_duty = 0 and rr.maintenance_state <= 7 and rr.school_id = #{schoolId} and rr.deleted = 0
- UNION
- 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,rr.user_class
- from repair_record rr
- 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
- and ((date_add(rdv.receiving_time , interval rdv.maintenance_assess_time minute) <= NOW() and rdv.maintenance_assess_time is null) or date_add(rdv.receiving_time , interval rdv.maintenance_assess_time minute) <= rdv.finish_time)
- where rr.is_duty = 0 and rr.maintenance_state <= 7 and rr.school_id = #{schoolId} and rr.deleted = 0) t
- 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
- 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
- left join repair_article_type rat on rat.deleted = 0 and rat.id = t.article_id
- order by t.report_time desc
- </select>
- <!--待审核-->
- <select id="queryExamineOrderList" resultType="com.repair.model.vo.RepairTechnicianVo"
- resultMap="repairRecordTechnicianDataMap">
- 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,rr.user_class
- from repair_record rr
- 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
- left join repair_article_type rat on rat.deleted = 0 and rat.id = rr.article_id
- where rr.maintenance_state = 6 and rr.deleted = 0 and rr.school_id = #{schoolId}
- UNION ALL
- 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,rr.user_class
- from repair_record rr
- 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
- left join repair_article_type rat on rat.deleted = 0 and rat.id = rr.article_id
- where rr.maintenance_state = 5 and rr.deleted = 0 and rr.school_id = #{schoolId}
- UNION ALL
- 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,rr.user_class
- from repair_record rr
- inner join repair_offline_record ror on ror.deleted = 0 and ror.user_id = #{userId} and ror.record_id = rr.id and ror.approval_statu = 2
- left join repair_article_type rat on rat.deleted = 0 and rat.id = rr.article_id
- where rr.maintenance_state = 11 and rr.deleted = 0 and rr.school_id = #{schoolId}
- </select>
- <resultMap type="com.repair.model.vo.RepairManageCountVo" id="repairManageCountMap">
- <result property="dispatchCount" column="dispatch_count"/>
- <result property="maintenanceCount" column="maintenance_count"/>
- <result property="logisticsCount" column="logistics_count"/>
- <result property="examineCount" column="examine_count"/>
- <result property="finishedCount" column="finished_count"/>
- <result property="canceledCount" column="canceled_count"/>
- <result property="closedCount" column="closed_count"/>
- <result property="timeoutCount" column="timeout_count"/>
- <result property="offlineCount" column="offline_count"/>
- </resultMap>
- <select id="queryManageCount" resultType="com.repair.model.vo.RepairManageCountVo" resultMap="repairManageCountMap">
- select
- (select Count(*) from (select rdr.users_id from repair_record rr
- 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
- where rr.deleted = 0 and rr.maintenance_state = 1
- <if test="keyWord != null and keyWord != ''">
- and (rr.record_no like '%' #{keyWord} '%' or rr.area_id like '%' #{keyWord} '%' or rr.user_name like '%'
- #{keyWord} '%' or rr.user_phone like '%'
- #{keyWord} '%')
- </if>
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and rr.report_time between #{startTime} and #{endTime}
- </if>
- <if test="schoolId != null and schoolId != ''">
- and rr.school_id = #{schoolId}
- </if>
- ) t
- <if test="maintenanceName != null and maintenanceName != ''">
- where t.users_id in (select id from repair_user where user_name like '%' #{maintenanceName} '%' and deleted
- = 0)
- </if>) as dispatch_count,
- (select Count(*) from (select rdv.user_id from repair_record rr
- 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
- where rr.deleted = 0 and rr.maintenance_state = 2
- <if test="keyWord != null and keyWord != ''">
- and (rr.record_no like '%' #{keyWord} '%' or rr.area_id like '%' #{keyWord} '%' or rr.user_name like '%'
- #{keyWord} '%' or rr.user_phone like '%'
- #{keyWord} '%')
- </if>
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and rr.report_time between #{startTime} and #{endTime}
- </if>
- <if test="schoolId != null and schoolId != ''">
- and rr.school_id = #{schoolId}
- </if>
- ) t
- <if test="maintenanceName != null and maintenanceName != ''">
- where t.user_id in (select id from repair_user where user_name like '%' #{maintenanceName} '%' and deleted =
- 0)
- </if>) as maintenance_count,
- (select Count(*) from repair_record rr
- inner join repair_dispatch_record rdr on rdr.deleted = 0 and rdr.is_lose_efficacy = 0 and rdr.record_id = rr.id
- <if test="maintenanceName != null and maintenanceName != ''">
- and rdr.users_id in (select id from repair_user where user_name like '%' #{maintenanceName} '%' and deleted
- = 0)
- </if>
- where rr.deleted = 0 and rr.maintenance_state = 3
- <if test="keyWord != null and keyWord != ''">
- and (rr.record_no like '%' #{keyWord} '%' or rr.area_id like '%' #{keyWord} '%' or rr.user_name like '%'
- #{keyWord} '%' or rr.user_phone like '%' #{keyWord}
- '%')
- </if>
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and rr.report_time between #{startTime} and #{endTime}
- </if>
- <if test="schoolId != null and schoolId != ''">
- and rr.school_id = #{schoolId}
- </if>
- ) as logistics_count,
- (select Count(*) from repair_record where deleted = 0 and (maintenance_state = 5 or maintenance_state = 6 or
- maintenance_state = 11)
- <if test="keyWord != null and keyWord != ''">
- and (area_id like '%' #{keyWord} '%' or user_name like '%' #{keyWord} '%' or user_phone like '%' #{keyWord}
- '%')
- </if>
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and report_time between #{startTime} and #{endTime}
- </if>
- <if test="schoolId != null and schoolId != ''">
- and school_id = #{schoolId}
- </if>
- <if test="maintenanceName != null and maintenanceName != ''">
- and maintenancer_name like '%' #{maintenanceName} '%'
- </if>) as examine_count,
- (select Count(*) from repair_record rr
- where rr.deleted = 0 and rr.maintenance_state = 7
- <if test="keyWord != null and keyWord != ''">
- and (rr.record_no like '%' #{keyWord} '%' or rr.area_id like '%' #{keyWord} '%' or rr.user_name like '%'
- #{keyWord} '%' or rr.user_phone like '%' #{keyWord}
- '%')
- </if>
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and rr.report_time between #{startTime} and #{endTime}
- </if>
- <if test="schoolId != null and schoolId != ''">
- and rr.school_id = #{schoolId}
- </if>
- <if test="maintenanceName != null and maintenanceName != ''">
- and rr.maintenancer_name like '%' #{maintenanceName} '%'
- </if>
- ) as finished_count,
- (select Count(*) from repair_record rr
- where rr.deleted = 0 and rr.maintenance_state = 8
- <if test="keyWord != null and keyWord != ''">
- and (rr.record_no like '%' #{keyWord} '%' or rr.area_id like '%' #{keyWord} '%' or rr.user_name like '%'
- #{keyWord} '%' or rr.user_phone like '%' #{keyWord}
- '%')
- </if>
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and rr.report_time between #{startTime} and #{endTime}
- </if>
- <if test="schoolId != null and schoolId != ''">
- and rr.school_id = #{schoolId}
- </if>
- <if test="maintenanceName != null and maintenanceName != ''">
- and rr.maintenancer_name like '%' #{maintenanceName} '%'
- </if>
- ) as canceled_count,
- (select Count(*) from repair_record rr
- where rr.deleted = 0 and rr.maintenance_state = 9
- <if test="keyWord != null and keyWord != ''">
- and (rr.record_no like '%' #{keyWord} '%' or rr.area_id like '%' #{keyWord} '%' or rr.user_name like '%'
- #{keyWord} '%' or rr.user_phone like '%' #{keyWord}
- '%')
- </if>
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and rr.report_time between #{startTime} and #{endTime}
- </if>
- <if test="schoolId != null and schoolId != ''">
- and rr.school_id = #{schoolId}
- </if>
- <if test="maintenanceName != null and maintenanceName != ''">
- and rr.maintenancer_name like '%' #{maintenanceName} '%'
- </if>) as closed_count,
- (SELECT count(*) as cs FROM (
- 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
- inner join repair_dispatch_record rdr on rdr.deleted = 0 and rdr.record_id = rr.id and rdr.is_lose_efficacy = 0
- and ((date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) <= NOW() and
- rdr.receiving_time is null) or date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) <=
- rdr.receiving_time)
- where rr.is_duty = 0 and rr.maintenance_state <= 7 and rr.deleted = 0
- <if test="keyWord != null and keyWord != ''">
- and (rr.record_no like '%' #{keyWord} '%' or rr.area_id like '%' #{keyWord} '%' or rr.user_name like '%'
- #{keyWord} '%' or rr.user_phone like '%'
- #{keyWord} '%')
- </if>
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and rr.report_time between #{startTime} and #{endTime}
- </if>
- <if test="schoolId != null and schoolId != ''">
- and rr.school_id = #{schoolId}
- </if>
- UNION
- 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
- inner join repair_receiving rdv on rdv.deleted = 0 and rdv.record_id = rr.id and rdv.is_lose_efficacy = 0
- and ((date_add(rdv.receiving_time , interval rdv.maintenance_assess_time minute) <= NOW() and
- rdv.maintenance_assess_time is null) or date_add(rdv.receiving_time , interval rdv.maintenance_assess_time
- minute) <= rdv.finish_time)
- where rr.is_duty = 0 and rr.maintenance_state <= 7 and rr.deleted = 0
- <if test="keyWord != null and keyWord != ''">
- and (rr.record_no like '%' #{keyWord} '%' or rr.area_id like '%' #{keyWord} '%' or rr.user_name like '%'
- #{keyWord} '%' or rr.user_phone like '%'
- #{keyWord} '%')
- </if>
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and rr.report_time between #{startTime} and #{endTime}
- </if>
- <if test="schoolId != null and schoolId != ''">
- and rr.school_id = #{schoolId}
- </if>
- ) t
- <if test="maintenanceName != null and maintenanceName != ''">
- where t.user_id in (select id from repair_user where user_name like '%' #{maintenanceName} '%' and deleted =
- 0)
- </if>
- ) as timeout_count,
- (select Count(*) from repair_record rr
- where rr.deleted = 0 and rr.maintenance_state = 10
- <if test="keyWord != null and keyWord != ''">
- and (rr.record_no like '%' #{keyWord} '%' or rr.area_id like '%' #{keyWord} '%' or rr.user_name like '%'
- #{keyWord} '%' or rr.user_phone like '%' #{keyWord}
- '%')
- </if>
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and rr.report_time between #{startTime} and #{endTime}
- </if>
- <if test="schoolId != null and schoolId != ''">
- and rr.school_id = #{schoolId}
- </if>
- <if test="maintenanceName != null and maintenanceName != ''">
- and rr.maintenancer_name like '%' #{maintenanceName} '%'
- </if>
- ) as offline_count
- </select>
- <!--管理端工单分页数据-->
- <resultMap type="com.repair.model.vo.RepairRecordPageVo" id="repairRecordPageMap">
- <result property="id" column="id"/>
- <result property="recordNo" column="record_no"/>
- <result property="schoolId" column="school_id"/>
- <result property="userName" column="user_name"/>
- <result property="userPhone" column="user_phone"/>
- <result property="articleName" column="article_name"/>
- <result property="areaName" column="area_name"/>
- <result property="description" column="description"/>
- <result property="reportTime" column="report_time"/>
- <result property="maintenancerName" column="maintenancer_name"/>
- <result property="details" column="details"/>
- <result property="rdvName" column="rdvName"/>
- <result property="rdrName" column="rdrName"/>
- <result property="rorName" column="rorName"/>
- <result property="userId" column="user_id"/>
- </resultMap>
- <!--除已超时外的其他数据获取方式-->
- <select id="queryNotTimeout" resultType="com.repair.model.vo.RepairRecordPageVo" resultMap="repairRecordPageMap">
- select * from (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
- article_name,
- rr.description,rr.report_time,rr.maintenancer_name,rr.maintenance_state,(select user_name from repair_user where
- id = rdv.user_id and deleted = 0) as rdvName,(select user_name from repair_user where id = rdr.users_id and
- deleted = 0) as rdrName,(select user_name from repair_user where id = ror.user_id and
- deleted = 0) as rorName
- from repair_record rr
- left join repair_receiving rdv on rdv.deleted = 0 and rdv.record_id = rr.id and rdv.is_lose_efficacy = 0 and
- rdv.finish_time is null and rr.maintenance_state = 2
- left 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 rr.maintenance_state = 1
- left join repair_offline_record ror on ror.deleted = 0 and ror.record_id = rr.id and ror.approval_statu != 0
- <if test="stateStr != null and stateStr != ''">
- and (rr.maintenance_state ${stateStr}
- </if>
- left join repair_article_type rat on rat.deleted = 0 and rat.id = rr.article_id
- <where>
- and rr.deleted = 0
- <if test="schoolId != null and schoolId != ''">
- and rr.school_id = #{schoolId}
- </if>
- <if test="stateStr != null and stateStr != ''">
- and (rr.maintenance_state ${stateStr}
- </if>
- <if test="stateStr == null or stateStr == ''">
- and rr.maintenance_state != 4
- </if>
- <if test="keyWord != null and keyWord != ''">
- and (rr.record_no like '%' #{keyWord} '%' or rr.area_id like '%' #{keyWord} '%' or rr.user_name like '%'
- #{keyWord} '%' or rr.user_phone like
- '%' #{keyWord} '%')
- </if>
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and rr.report_time between #{startTime} and #{endTime}
- </if>
- </where>
- ) t
- <if test="maintenanceName != null and maintenanceName != ''">
- where t.maintenancer_name like '%' #{maintenanceName} '%' or t.rdvName like '%' #{maintenanceName} '%' or
- t.rdrName like '%' #{maintenanceName} '%'
- </if>
- order by t.report_time desc
- </select>
- <resultMap type="com.repair.model.vo.RepairRecordTimeoutPageVo" id="repairRecordTimeoutPageMap">
- <result property="id" column="id"/>
- <result property="recordNo" column="record_no"/>
- <result property="schoolId" column="school_id"/>
- <result property="userName" column="user_name"/>
- <result property="userPhone" column="user_phone"/>
- <result property="articleName" column="article_name"/>
- <result property="areaName" column="area_name"/>
- <result property="description" column="description"/>
- <result property="reportTime" column="report_time"/>
- <result property="maintenancerName" column="maintenancer_name"/>
- <result property="details" column="details"/>
- <result property="maintenanceState" column="maintenance_state"/>
- <result property="timeoutStr" column="timeout_str"/>
- <result property="maintenanceTimeout" column="maintenance_timeout"/>
- <result property="userId" column="user_id"/>
- </resultMap>
- <!--#已超时获取方式-->
- <select id="queryTimeout" resultType="com.repair.model.vo.RepairRecordTimeoutPageVo"
- resultMap="repairRecordTimeoutPageMap">
- 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
- article_name,t.description,t.report_time,t.maintenance_state,ru.user_name as maintenancer_name,ru.user_phone as
- maintenancer_phone,
- case ((date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) <= NOW() and
- rdr.receiving_time is null) or date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) <=
- rdr.receiving_time) when true then '超时未接' else null end as timeout_str,
- case ((date_add(rdv.receiving_time, interval rdv.maintenance_assess_time minute) <= NOW() and
- rdv.maintenance_assess_time is null) or date_add(rdv.receiving_time , interval rdv.maintenance_assess_time
- minute) <= rdv.finish_time) when true then '维修超时' else null end as maintenance_timeout
- FROM (
- select rr.school_id,rdr.users_id as user_id,1 as details,rr.id,rr.record_no,rr.area_id as
- area_name,rr.user_name,rr.user_phone,rr.price,rr.maintenance_state,rr.article_id,rr.report_time,rr.description
- from repair_record rr
- inner join repair_dispatch_record rdr on rdr.deleted = 0 and rdr.record_id = rr.id and rdr.is_lose_efficacy = 0
- and ((date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) <= NOW() and
- rdr.receiving_time is null) or date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) <=
- rdr.receiving_time)
- <where>
- and rr.deleted = 0 and rr.is_duty = 0 and rr.maintenance_state <= 7
- <if test="keyWord != null and keyWord != ''">
- and (rr.record_no like '%' #{keyWord} '%' or rr.area_id like '%' #{keyWord} '%' or rr.user_name like '%'
- #{keyWord} '%' or rr.user_phone like
- '%' #{keyWord} '%')
- </if>
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and rr.report_time between #{startTime} and #{endTime}
- </if>
- <if test="schoolId != null and schoolId != ''">
- and rr.school_id = #{schoolId}
- </if>
- </where>
- UNION
- select rr.school_id,rdv.user_id,1 as details,rr.id,rr.record_no,rr.area_id as
- area_name,rr.user_name,rr.user_phone,rr.price,rr.maintenance_state,rr.article_id,rr.report_time,rr.description
- from repair_record rr
- inner join repair_receiving rdv on rdv.deleted = 0 and rdv.record_id = rr.id and rdv.is_lose_efficacy = 0
- and ((date_add(rdv.receiving_time , interval rdv.maintenance_assess_time minute) <= NOW() and
- rdv.maintenance_assess_time is null) or date_add(rdv.receiving_time , interval rdv.maintenance_assess_time
- minute) <= rdv.finish_time)
- <where>
- and rr.deleted = 0 and rr.is_duty = 0 and rr.maintenance_state <= 7
- <if test="keyWord != null and keyWord != ''">
- and (rr.record_no like '%' #{keyWord} '%' or rr.area_id like '%' #{keyWord} '%' or rr.user_name like '%'
- #{keyWord} '%' or rr.user_phone like
- '%' #{keyWord} '%')
- </if>
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and rr.report_time between #{startTime} and #{endTime}
- </if>
- <if test="schoolId != null and schoolId != ''">
- and rr.school_id = #{schoolId}
- </if>
- </where>
- ) t
- 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
- 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
- left join repair_article_type rat on rat.deleted = 0 and rat.id = t.article_id
- left join repair_user ru on ru.deleted = 0 and ru.id = t.user_id) d
- <if test="maintenanceName != null and maintenanceName != ''">
- where d.maintenancer_name like '%' #{maintenanceName} '%'
- </if>
- order by d.report_time desc
- </select>
- <!--#获取待处理池数据-->
- <resultMap type="com.repair.model.vo.pendingOrderVo" id="repairPendingOrderMap">
- <result property="id" column="id"/>
- <result property="recordNo" column="record_no"/>
- <result property="reportTime" column="report_time"/>
- <result property="userName" column="user_name"/>
- <result property="userPhone" column="user_phone"/>
- <result property="areaName" column="area_name"/>
- <result property="address" column="address"/>
- <result property="articleName" column="article_name"/>
- <result property="description" column="description"/>
- <result property="image" column="image"/>
- <result property="state" column="state"/>
- <result property="voice" column="voice"/>
- <result property="voiceLength" column="voice_length"/>
- <result property="finishVoice" column="finish_voice"/>
- <result property="finishVoiceLength" column="finish_voice_length"/>
- </resultMap>
- <select id="queryPendingOrder" resultType="com.repair.model.vo.pendingOrderVo" resultMap="repairPendingOrderMap">
- 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,
- 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
- from repair_record rr
- left join repair_article_type rat on rat.id = rr.article_id
- where rr.maintenance_state = 1 and rr.deleted = 0 and rr.school_id = #{schoolId}) t where t.disp_count <= 0
- order by t.report_time desc
- </select>
- <!--郭师傅维修 团队工单 头部数量-->
- <resultMap type="com.repair.model.vo.TeamWorkCountVo" id="teamWorkOrderMap">
- <result property="examineCount" column="examine_count"/>
- <result property="receivingCount" column="receiving_count"/>
- <result property="maintenanceCount" column="maintenance_count"/>
- <result property="finishedCount" column="finished_count"/>
- <result property="logisticsCount" column="logistics_count"/>
- <result property="timeoutCount" column="timeout_count"/>
- <result property="closedCount" column="closed_count"/>
- <result property="offlineCount" column="offline_count"/>
- </resultMap>
- <select id="queryTeamWorkCount" resultType="com.repair.model.vo.TeamWorkCountVo" resultMap="teamWorkOrderMap">
- select
- (select Count(*) as sh from (
- select rr5.* from repair_record rr5
- inner join repair_collaborate_record rcr on rcr.deleted = 0 and rcr.record_id = rr5.id and
- rcr.approval_statu = 2
- where rr5.maintenance_state = 6 and rr5.school_id = #{schoolId} and rr5.deleted = 0
- UNION ALL
- select rr.* from repair_record rr
- inner join repair_transfer_record rtr on rtr.deleted = 0 and rtr.record_id = rr.id and
- rtr.approval_statu = 2
- where rr.maintenance_state = 5 and rr.school_id = #{schoolId} and rr.deleted = 0
- UNION ALL
- select rr.* from repair_record rr
- inner join repair_offline_record ror on ror.deleted = 0 and ror.record_id = rr.id and ror.approval_statu = 2
- where rr.maintenance_state = 11 and rr.school_id = #{schoolId} and rr.deleted = 0
- ) a) as examine_count,
- (select Count(*) from repair_record rr1
- inner join repair_dispatch_record rdr on rdr.deleted = 0 and rdr.record_id = rr1.id and
- rdr.is_lose_efficacy = 0 and rdr.receiving_time is null
- where rr1.maintenance_state = 1 and rr1.school_id = #{schoolId} and rr1.deleted = 0) as receiving_count,
- (select Count(*) from repair_record rr
- where rr.deleted = 0 and rr.school_id = #{schoolId} and rr.maintenance_state = 10) as offline_count,
- (select Count(*) from repair_record rr2
- inner join repair_receiving rdv on rdv.deleted = 0 and rdv.record_id = rr2.id and
- rdv.is_lose_efficacy = 0
- where rr2.maintenance_state = 2 and rr2.school_id = #{schoolId} and rr2.deleted = 0) as maintenance_count,
- (select Count(*) from repair_record rr7
- where rr7.deleted = 0 and rr7.school_id = #{schoolId} and rr7.maintenance_state = 7) as finished_count,
- (select Count(*) from repair_record rr9
- where rr9.deleted = 0 and rr9.school_id = #{schoolId} and rr9.maintenance_state = 3) as logistics_count,
- (SELECT count(*) as cs FROM (
- 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
- inner join repair_dispatch_record rdr on rdr.deleted = 0 and rdr.record_id = rr.id and rdr.is_lose_efficacy = 0
- and ((date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) <= NOW() and rdr.receiving_time is null) or date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) <= rdr.receiving_time)
- where rr.is_duty = 0 and rr.maintenance_state <= 7 and rr.deleted = 0 and rr.school_id = #{schoolId}
- UNION
- 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
- inner join repair_receiving rdv on rdv.deleted = 0 and rdv.record_id = rr.id and rdv.is_lose_efficacy = 0
- and ((date_add(rdv.receiving_time , interval rdv.maintenance_assess_time minute) <= NOW() and rdv.maintenance_assess_time is null) or date_add(rdv.receiving_time , interval rdv.maintenance_assess_time minute) <= rdv.finish_time)
- where rr.is_duty = 0 and rr.maintenance_state <= 7 and rr.deleted = 0 and rr.school_id = #{schoolId}) t) as timeout_count,
- (select Count(*) from repair_record rr8
- where rr8.deleted = 0 and rr8.school_id = #{schoolId} and rr8.maintenance_state = 9) as closed_count
- </select>
- <!--待审核-->
- <select id="queryTeamWorkExamine" resultType="com.repair.model.vo.RepairTechnicianVo"
- resultMap="repairRecordTechnicianDataMap">
- 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
- inner join repair_collaborate_record rcr on rcr.deleted = 0 and rcr.record_id = rr5.id and rcr.approval_statu = 2
- left join repair_article_type rat on rat.deleted = 0 and rat.id = rr5.article_id
- where rr5.maintenance_state = 6 and rr5.school_id = #{schoolId} and rr5.deleted = 0
- UNION ALL
- 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
- inner join repair_transfer_record rtr on rtr.deleted = 0 and rtr.record_id = rr.id and rtr.approval_statu = 2
- left join repair_article_type rat on rat.deleted = 0 and rat.id = rr.article_id
- where rr.maintenance_state = 5 and rr.school_id = #{schoolId} and rr.deleted = 0
- UNION ALL
- 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
- inner join repair_offline_record ror on ror.deleted = 0 and ror.record_id = rr.id and ror.approval_statu = 2
- left join repair_article_type rat on rat.deleted = 0 and rat.id = rr.article_id
- where rr.maintenance_state = 11 and rr.school_id = #{schoolId} and rr.deleted = 0
- </select>
- <!--待接单-->
- <select id="queryTeamWorkPending" resultType="com.repair.model.vo.RepairTechnicianVo"
- resultMap="repairRecordTechnicianDataMap">
- select t.*,ru.user_name as maintenancer_name,ru.user_phone as maintenancer_phone from
- (select case ((date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) <= #{dateNow} and rdr.receiving_time is null) or date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) <= rdr.receiving_time) when true then '超时未接' else null end as timeout_str,
- 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,rdr.users_id as rdrUId,rr.price,rr.user_class
- from repair_record rr
- inner join repair_dispatch_record rdr on rdr.deleted = 0 and rdr.record_id = rr.id and rdr.is_lose_efficacy = 0
- left join repair_article_type rat on rat.deleted = 0 and rat.id = rr.article_id
- where rr.maintenance_state = 1 and rr.school_id = #{schoolId} and rr.deleted = 0
- ) t
- left join repair_user ru on ru.id = t.rdrUId
- order by t.report_time DESC
- </select>
- <!--维修中-->
- <select id="queryTeamWorkMaintenance" resultType="com.repair.model.vo.RepairTechnicianVo"
- resultMap="repairRecordTechnicianDataMap">
- select t.*,ru.user_name as maintenancer_name,ru.user_phone as maintenancer_phone from
- (select case ((date_add(rdv.receiving_time, interval rdv.maintenance_assess_time minute) <= #{dateNow} and rdv.maintenance_assess_time is null) or date_add(rdv.receiving_time , interval rdv.maintenance_assess_time minute) <= rdv.finish_time) when true then '维修超时' else null end as timeout_str,
- 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,rdv.user_id as rdrUId,rr.price,rr.user_class
- from repair_record rr
- inner join repair_receiving rdv on rdv.deleted = 0 and rdv.record_id = rr.id and rdv.is_lose_efficacy = 0
- left join repair_article_type rat on rat.deleted = 0 and rat.id = rr.article_id
- where rr.maintenance_state = 2 and rr.school_id = #{schoolId} and rr.deleted = 0
- ) t
- left join repair_user ru on ru.id = t.rdrUId
- order by t.report_time DESC
- </select>
- <!--已完成-->
- <select id="queryTeamWorkFinished" resultType="com.repair.model.vo.RepairTechnicianVo"
- resultMap="repairRecordTechnicianDataMap">
- 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,rr.user_class
- from repair_record rr
- left join repair_article_type rat on rat.deleted = 0 and rat.id = rr.article_id
- where rr.deleted = 0 and rr.school_id = #{schoolId} and rr.maintenance_state = 7
- order by rr.report_time DESC
- </select>
- <!--待处理-->
- <select id="queryTeamWorkLogistics" resultType="com.repair.model.vo.RepairTechnicianVo"
- resultMap="repairRecordTechnicianDataMap">
- 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,rr.user_class
- from repair_record rr
- left join repair_article_type rat on rat.deleted = 0 and rat.id = rr.article_id
- where rr.deleted = 0 and rr.school_id = #{schoolId} and rr.maintenance_state = 3
- order by rr.report_time DESC
- </select>
- <!--已超时-->
- <select id="queryTeamWorkTimeout" resultType="com.repair.model.vo.RepairTechnicianVo"
- resultMap="repairRecordTechnicianDataMap">
- 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) <= NOW() and rdr.receiving_time is null) or date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) <= rdr.receiving_time) when true then '超时未接' else null end as timeout_str,case ((date_add(rdv.receiving_time, interval rdv.maintenance_assess_time minute) <= NOW() and rdv.maintenance_assess_time is null) or date_add(rdv.receiving_time , interval rdv.maintenance_assess_time minute) <= 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 (
- 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,rr.user_class
- from repair_record rr
- inner join repair_dispatch_record rdr on rdr.deleted = 0 and rdr.record_id = rr.id and rdr.is_lose_efficacy = 0
- and ((date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) <= NOW() and rdr.receiving_time is null) or date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) <= rdr.receiving_time)
- where rr.is_duty = 0 and rr.maintenance_state <= 7 and rr.deleted = 0 and rr.school_id = #{schoolId}
- UNION
- 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,rr.user_class
- from repair_record rr
- inner join repair_receiving rdv on rdv.deleted = 0 and rdv.record_id = rr.id and rdv.is_lose_efficacy = 0
- and ((date_add(rdv.receiving_time , interval rdv.maintenance_assess_time minute) <= NOW() and rdv.maintenance_assess_time is null) or date_add(rdv.receiving_time , interval rdv.maintenance_assess_time minute) <= rdv.finish_time)
- where rr.is_duty = 0 and rr.maintenance_state <= 7 and rr.deleted = 0 and rr.school_id = #{schoolId}) t
- 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
- 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
- left join repair_article_type rat on rat.deleted = 0 and rat.id = t.article_id
- left join repair_user ru on ru.deleted = 0 and ru.id = t.user_id
- order by t.report_time desc
- </select>
- <!--已关单-->
- <select id="queryTeamWorkClosed" resultType="com.repair.model.vo.RepairTechnicianVo"
- resultMap="repairRecordTechnicianDataMap">
- 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,rr.user_class
- from repair_record rr
- left join repair_article_type rat on rat.deleted = 0 and rat.id = rr.article_id
- where rr.deleted = 0 and rr.school_id = #{schoolId} and rr.maintenance_state = 9
- order by rr.report_time DESC
- </select>
- <!--转线下-->
- <select id="queryTeamWorkOffline" resultType="com.repair.model.vo.RepairTechnicianVo"
- resultMap="repairRecordTechnicianDataMap">
- 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,rr.user_class
- from repair_record rr
- left join repair_article_type rat on rat.deleted = 0 and rat.id = rr.article_id
- where rr.deleted = 0 and rr.school_id = #{schoolId} and rr.maintenance_state = 10
- order by rr.report_time DESC
- </select>
- <!-- 报表导出获取除已超时外的其他数据获取方式-->
- <select id="queryNotTimeoutReportExport" resultType="com.repair.model.vo.ReportExportVo">
- 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
- article_name,
- rr.description,rr.report_time,rr.maintenancer_name,rr.maintenance_state
- from repair_record rr
- left join repair_article_type rat on rat.deleted = 0 and rat.id = rr.article_id
- <where>
- and rr.deleted = 0
- <if test="schoolId != null and schoolId != ''">
- and rr.school_id = #{schoolId}
- </if>
- <if test="stateStr != null and stateStr != ''">
- and (rr.maintenance_state ${stateStr}
- </if>
- <if test="keyWord != null and keyWord != ''">
- and (rr.record_no like '%' #{keyWord} '%' or rr.area_id like '%' #{keyWord} '%' or rr.user_name like '%'
- #{keyWord} '%' or rr.user_phone like
- '%' #{keyWord} '%')
- </if>
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and rr.report_time between #{startTime} and #{endTime}
- </if>
- </where>
- order by rr.report_time desc
- </select>
- <!-- 报表导出获取除已超时数据获取方式-->
- <select id="queryTimeoutReportExport" resultType="com.repair.model.vo.ReportExportVo">
- SELECT * FROM (
- select rr3.user_id,1 as details,rr3.id,rr3.record_no,rr3.area_id as
- area_name,rr3.user_name,rr3.user_phone,rat.name as article_name,
- rr3.description,rr3.report_time,(select user_name from repair_user where id = rdr.users_id) as
- maintenancer_name,rr3.maintenance_state
- from repair_record rr3
- left join repair_article_type rat on rat.deleted = 0 and rat.id = rr3.article_id
- inner join repair_dispatch_record rdr on rdr.deleted = 0 and rdr.record_id = rr3.id and
- rdr.is_lose_efficacy = 0
- and ((date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) <= NOW() and
- rdr.receiving_time is null) or date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) <=
- rdr.receiving_time)
- <where>
- and rr3.deleted = 0 and rr3.is_duty = 0 and rr3.maintenance_state <= 7
- <if test="keyWord != null and keyWord != ''">
- and (rr3.record_no like '%' #{keyWord} '%' or rr3.area_id like '%' #{keyWord} '%' or rr3.user_name like
- '%' #{keyWord} '%' or rr3.user_phone like
- '%' #{keyWord} '%')
- </if>
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and rr3.report_time between #{startTime} and #{endTime}
- </if>
- <if test="schoolId != null and schoolId != ''">
- and rr3.school_id = #{schoolId}
- </if>
- </where>
- UNION ALL
- select rr4.user_id,1 as details,rr4.id,rr4.record_no,rr4.area_id as
- area_name,rr4.user_name,rr4.user_phone,rat.name as
- article_name,
- rr4.description,rr4.report_time,(select user_name from repair_user where id = rdv.user_id) as
- maintenancer_name,rr4.maintenance_state
- from repair_record rr4
- left join repair_article_type rat on rat.deleted = 0 and rat.id = rr4.article_id
- inner join repair_receiving rdv on rdv.deleted = 0 and rdv.record_id = rr4.id and
- rdv.is_lose_efficacy = 0
- and ((date_add(rdv.receiving_time , interval rdv.maintenance_assess_time minute) <= NOW() and
- rdv.maintenance_assess_time is null) or date_add(rdv.receiving_time , interval rdv.maintenance_assess_time
- minute) <= rdv.finish_time)
- <where>
- and rr4.deleted = 0 and rr4.is_duty = 0 and rr4.maintenance_state <= 7
- <if test="keyWord != null and keyWord != ''">
- and (rr4.record_no like '%' #{keyWord} '%' or rr4.area_id like '%' #{keyWord} '%' or rr4.user_name like
- '%' #{keyWord} '%' or rr4.user_phone like
- '%' #{keyWord} '%')
- </if>
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and rr4.report_time between #{startTime} and #{endTime}
- </if>
- <if test="schoolId != null and schoolId != ''">
- and rr4.school_id = #{schoolId}
- </if>
- </where>
- ) t
- order by t.report_time desc
- </select>
- <!--维修师傅首页头部数量-->
- <resultMap type="com.repair.model.vo.MasterHomepageVo" id="masterHomepageMap">
- <result property="workCount" column="work_count"/>
- <result property="processCount" column="process_count"/>
- <result property="finishCount" column="finish_count"/>
- <result property="timeoutCount" column="timeout_count"/>
- <result property="offlineCount" column="offline_count"/>
- </resultMap>
- <!--说明:-->
- <!--#work_count 工单数:维修师傅的工单总数,只计算维修师傅的接单数,待接单不用计算进去-->
- <!--#process_count 处理中:维修中没有完成的工单,包含维修中,待接单,待审核-->
- <!--#finish_count 已完成:已取消 已完成 已关单-->
- <!--#timeout_count 已超时:包含接单超时 维修超时-->
- <select id="queryMasterHomeCount" resultType="com.repair.model.vo.MasterHomepageVo" resultMap="masterHomepageMap">
- select
- (select count(*) from repair_receiving rc
- inner join repair_record rr on rr.deleted = 0 and rr.school_id = #{schoolId} and rr.id = rc.record_id
- where rc.deleted = 0 and rc.user_id = #{userId}) as work_count,
- (select
- (select Count(*) as rc from repair_record rr
- 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}
- where rr.deleted = 0 and rr.school_id = #{schoolId} and rr.maintenance_state = 1) +
- (select Count(*) as wx from repair_record rr2
- 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
- where rr2.maintenance_state = 2 and rr2.school_id = #{schoolId} and rr2.deleted = 0) +
- (select Count(*) as sh from (
- select rr5.* from repair_record rr5
- inner join repair_collaborate_record rcr on rcr.deleted = 0 and rcr.user_id = #{userId} and rcr.record_id = rr5.id and
- rcr.approval_statu = 2
- where rr5.maintenance_state = 6 and rr5.deleted = 0 and rr5.school_id = #{schoolId}
- UNION ALL
- select rr.* from repair_record rr
- 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
- where rr.maintenance_state = 5 and rr.deleted = 0 and rr.school_id = #{schoolId}) a) as process_count) as process_count,
- (select Count(*) from repair_record rr
- 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}
- where rr.deleted = 0 and rr.school_id = #{schoolId} and rr.maintenance_state >= 7) as finish_count,
- (select Count(*) as cs from (select rr3.*
- from repair_record rr3
- inner join repair_dispatch_record rdr on rdr.deleted = 0 and rdr.users_id = #{userId} and rdr.record_id = rr3.id and
- rdr.is_lose_efficacy = 0
- and ((date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) <= NOW() and rdr.receiving_time is null) or date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) <= rdr.receiving_time)
- where rr3.maintenance_state <= 7 and rr3.is_duty = 0 and rr3.school_id = #{schoolId} and rr3.deleted = 0
- UNION
- select rr4.* from repair_record rr4
- inner join repair_receiving rdv on rdv.deleted = 0 and rdv.user_id = #{userId} and rdv.record_id = rr4.id and
- rdv.is_lose_efficacy = 0
- and ((date_add(rdv.receiving_time , interval rdv.maintenance_assess_time minute) <= NOW() and rdv.maintenance_assess_time is null) or date_add(rdv.receiving_time , interval rdv.maintenance_assess_time minute) <= rdv.finish_time)
- where rr4.maintenance_state <= 7 and rr4.is_duty = 0 and rr4.school_id = #{schoolId} and rr4.deleted = 0) c) as timeout_count
- </select>
- <!--后勤人员和郭师傅首页头部数量-->
- <!--说明:-->
- <!--#work_count 工单数:对应校区的工单总数,只计算对应人员校区的接单数,待接单不用计算进去-->
- <!--#process_count 处理中:维修中没有完成的工单,包含维修中,待接单,待审核-->
- <!--#finish_count 已完成:已取消 已完成 已关单-->
- <!--#timeout_count 已超时:包含接单超时 维修超时-->
- <select id="queryLogisticHomeCount" resultType="com.repair.model.vo.MasterHomepageVo" resultMap="masterHomepageMap">
- select
- (select Count(*) from repair_record rr
- where rr.deleted = 0 and rr.maintenance_state = 10) as offline_count,
- (select Count(*) from repair_receiving rc
- inner join repair_record rr on rr.deleted = 0 and rr.school_id = #{schoolId} and rr.id = rc.record_id
- where rc.deleted = 0) as work_count,
- (select
- (select Count(*) as rc from repair_record rr
- inner join repair_dispatch_record rdr on rdr.deleted = 0 and rdr.is_lose_efficacy = 0 and rdr.record_id = rr.id
- where rr.deleted = 0 and rr.maintenance_state = 1 and rr.school_id = #{schoolId}) +
- (select Count(*) as wx from repair_record rr2
- inner join repair_receiving rdv on rdv.deleted = 0 and rdv.record_id = rr2.id and
- rdv.is_lose_efficacy = 0
- where rr2.maintenance_state = 2 and rr2.deleted = 0 and rr2.school_id = #{schoolId}) +
- (select Count(*) as sh from (
- select rr5.* from repair_record rr5
- inner join repair_collaborate_record rcr on rcr.deleted = 0 and rcr.record_id = rr5.id and
- rcr.approval_statu = 2
- where rr5.maintenance_state = 6 and rr5.deleted = 0 and rr5.school_id = #{schoolId}
- UNION
- select rr.* from repair_record rr
- inner join repair_transfer_record rtr on rtr.deleted = 0 and rtr.record_id = rr.id and
- rtr.approval_statu = 2
- where rr.maintenance_state = 5 and rr.deleted = 0 and rr.school_id = #{schoolId}) a) as process_count) as process_count,
- (select Count(*) from repair_record rr
- inner join repair_dispatch_record rdr on rdr.deleted = 0 and rdr.is_lose_efficacy = 0 and rdr.record_id = rr.id
- where rr.deleted = 0 and rr.maintenance_state >= 7 and rr.school_id = #{schoolId}) as finish_count,
- (SELECT count(*) as cs FROM (
- 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
- inner join repair_dispatch_record rdr on rdr.deleted = 0 and rdr.record_id = rr.id and rdr.is_lose_efficacy = 0
- and ((date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) <= NOW() and rdr.receiving_time is null) or date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) <= rdr.receiving_time)
- where rr.is_duty = 0 and rr.maintenance_state <= 7 and rr.deleted = 0 and rr.school_id = #{schoolId}
- UNION
- 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
- inner join repair_receiving rdv on rdv.deleted = 0 and rdv.record_id = rr.id and rdv.is_lose_efficacy = 0
- and ((date_add(rdv.receiving_time , interval rdv.maintenance_assess_time minute) <= NOW() and rdv.maintenance_assess_time is null) or date_add(rdv.receiving_time , interval rdv.maintenance_assess_time minute) <= rdv.finish_time)
- where rr.is_duty = 0 and rr.maintenance_state <= 7 and rr.deleted = 0 and rr.school_id = #{schoolId}) t) as timeout_count
- </select>
- <resultMap type="com.repair.model.vo.RepairCampusRecordVo" id="repairCampusMap">
- <result property="id" column="id"/>
- <result property="price" column="price"/>
- <result property="schoolId" column="school_id"/>
- <result property="maintenanceState" column="maintenance_state"/>
- </resultMap>
- <select id="repairCampusTotal" resultType="com.repair.model.vo.RepairCampusRecordVo" resultMap="repairCampusMap">
- SELECT rr.id,rr.price,rr.school_id,rr.maintenance_state
- FROM `repair_record` rr
- 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
- 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
- where rr.deleted = 0
- </select>
- <select id="repairCampus" resultType="com.repair.model.vo.RepairCampusRecordVo" resultMap="repairCampusMap">
- SELECT rr.id,rr.price,rr.school_id,rr.maintenance_state
- FROM `repair_record` rr
- 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
- 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
- <where>
- and rr.deleted = 0
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and rr.report_time between #{startTime} and #{endTime}
- </if>
- </where>
- </select>
- <select id="repairAreaTotal" resultType="com.repair.model.vo.RepairAreaVo">
- SELECT row_number() over ( ORDER BY ra.area_name ) AS id, ra.*
- FROM (SELECT count(rr.area_id) AS orders_total,
- rs.`name` AS school_name,
- rr.area_id AS area_name,
- SUM(case when rr.price > 0 then 1 else 0 end) AS orders_compensation,
- SUM(case when rr.price IS NULL OR rr.price = 0 then 1 else 0 end) AS orders_gratis,
- SUM(rr.price) AS total_price
- FROM `repair_record` rr
- LEFT JOIN repair_school rs ON rs.deleted = 0
- AND rr.school_id = rs.id
- where rr.deleted = 0
- GROUP BY rr.area_id) ra
- </select>
- <select id="repairArea" resultType="com.repair.model.vo.RepairAreaVo">
- SELECT row_number() over ( ORDER BY ra.area_name ) AS id, ra.*
- FROM (SELECT count(rr.area_id) AS orders_total,
- rs.`name` AS school_name,
- rr.area_id AS area_name,
- SUM(case when rr.price > 0 then 1 else 0 end) AS orders_compensation,
- SUM(case when rr.price IS NULL OR rr.price = 0 then 1 else 0 end) AS orders_gratis,
- SUM(rr.price) AS total_price
- FROM `repair_record` rr
- LEFT JOIN repair_school rs ON rs.deleted = 0
- AND rr.school_id = rs.id
- <where>
- AND rr.deleted=0
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and rr.report_time between #{startTime} and #{endTime}
- </if>
- </where>
- GROUP BY rr.area_id) ra
- </select>
- <select id="maintenanceGoodsTotal" resultType="com.repair.model.vo.MaintenanceGoodsVo">
- SELECT row_number() over ( ORDER BY wx.article_name ) AS id, wx.*
- FROM (SELECT rat.`name` AS article_name,
- rat.school_id as school_id,
- count(rr.article_id) AS orders_total,
- SUM(case when rr.price > 0 then 1 else 0 end) AS orders_compensation,
- SUM(case when rr.price IS NULL OR rr.price = 0 then 1 else 0 end) AS orders_gratis,
- SUM(rr.price) AS total_price
- FROM `repair_record` rr
- LEFT JOIN repair_article_type rat ON rr.article_id = rat.id
- WHERE rr.deleted = 0
- GROUP BY rr.article_id) wx
- </select>
- <select id="maintenanceGoods" resultType="com.repair.model.vo.MaintenanceGoodsVo">
- SELECT row_number() over ( ORDER BY wx.article_name ) AS id, wx.*
- FROM (SELECT rat.`name` AS article_name,
- rat.school_id as school_id,
- count(rr.article_id) AS orders_total,
- SUM(case when rr.price > 0 then 1 else 0 end) AS orders_compensation,
- SUM(case when rr.price IS NULL OR rr.price = 0 then 1 else 0 end) AS orders_gratis,
- SUM(rr.price) AS total_price
- FROM `repair_record` rr
- LEFT JOIN repair_article_type rat ON rr.article_id = rat.id
- <where>
- and rr.deleted = 0
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and report_time between #{startTime} and #{endTime}
- </if>
- </where>
- GROUP BY rr.article_id) wx
- </select>
- <select id="repairAreaExport" resultType="com.repair.model.vo.RepairAreaVo">
- SELECT row_number() over ( ORDER BY ra.area_name ) AS id, ra.*
- FROM (SELECT count(rr.area_id) AS orders_total,
- rs.`name` AS school_name,
- rr.area_id AS area_name,
- SUM(case when rr.price > 0 then 1 else 0 end) AS orders_compensation,
- SUM(case when rr.price IS NULL OR rr.price = 0 then 1 else 0 end) AS orders_gratis,
- SUM(rr.price) AS total_price
- FROM `repair_record` rr
- LEFT JOIN repair_school rs ON rs.deleted = 0
- AND rr.school_id = rs.id
- <where>
- AND rr.deleted=0
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and report_time between #{startTime} and #{endTime}
- </if>
- </where>
- GROUP BY rr.area_id) ra
- </select>
- <select id="maintenanceGoodsExport" resultType="com.repair.model.vo.MaintenanceGoodsVo">
- SELECT row_number() over ( ORDER BY wx.article_name ) AS id, wx.*
- FROM (SELECT rat.`name` AS article_name,
- rat.school_id as school_id,
- count(rr.article_id) AS orders_total,
- SUM(case when rr.price > 0 then 1 else 0 end) AS orders_compensation,
- SUM(case when rr.price IS NULL OR rr.price = 0 then 1 else 0 end) AS orders_gratis,
- SUM(rr.price) AS total_price
- FROM `repair_record` rr
- LEFT JOIN repair_article_type rat ON rat.deleted = 0
- AND rr.article_id = rat.id
- <where>
- and rr.deleted = 0
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and report_time between #{startTime} and #{endTime}
- </if>
- </where>
- GROUP BY rr.article_id) wx
- </select>
- <!--报修详情-->
- <resultMap type="com.repair.model.vo.DetailsVo" id="detailDatasMap">
- <result property="id" column="id"/>
- <result property="maintenanceState" column="maintenance_state"/>
- <result property="recordNo" column="record_no"/>
- <result property="reportTime" column="report_time"/>
- <result property="userName" column="user_name"/>
- <result property="userPhone" column="user_phone"/>
- <result property="userClass" column="user_class"/>
- <result property="areaName" column="area_name"/>
- <result property="address" column="address"/>
- <result property="articleName" column="article_name"/>
- <result property="description" column="description"/>
- <result property="voice" column="voice"/>
- <result property="voiceLength" column="voice_length"/>
- <result property="finishVoice" column="finish_voice"/>
- <result property="finishVoiceLength" column="finish_voice_length"/>
- <result property="image" column="image"/>
- <result property="maintenancerName" column="maintenancer_name"/>
- <result property="maintenancerPhone" column="maintenancer_phone"/>
- <result property="price" column="price"/>
- </resultMap>
- <select id="queryDetailData" resultType="com.repair.model.vo.DetailsVo" resultMap="detailDatasMap">
- select
- rr.id,rr.maintenance_state,rr.record_no,rr.report_time,rr.user_name,rr.user_phone,rr.user_class,rr.area_id as
- area_name,rr.address,rat.name as article_name,rr.description,rr.voice,rr.voice_length,
- rr.finish_voice,finish_voice_length,rr.image,rr.maintenancer_name,rr.maintenancer_phone,rr.price
- from repair_record rr
- left join repair_article_type rat on rat.deleted = 0 and rat.id = rr.article_id
- where rr.deleted = 0
- <if test="recordId != null and recordId != ''">
- and rr.id = #{recordId}
- </if>
- </select>
- <select id="repairAnalysis" resultType="com.repair.model.vo.RepairAnalysisVo">
- SELECT
- (SELECT COUNT(*) FROM repair_record
- <where>
- AND deleted = 0
- and (maintenance_state in (5,6,11))
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and report_time between #{startTime} and #{endTime}
- </if>
- </where>
- ) as check_count ,
- (SELECT COUNT(*) FROM repair_record rr
- 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
- <where>
- AND rr.deleted = 0
- and rr.maintenance_state = 1
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and rr.report_time between #{startTime} and #{endTime}
- </if>
- </where>
- ) as receiving_count ,
- (SELECT COUNT(*) FROM repair_record rr
- 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
- <where>
- AND rr.deleted = 0
- and rr.maintenance_state = 2
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and rr.report_time between #{startTime} and #{endTime}
- </if>
- </where>
- ) as maintain_count ,
- (SELECT COUNT(*) FROM repair_record
- <where>
- AND deleted = 0
- and maintenance_state = 7
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and report_time between #{startTime} and #{endTime}
- </if>
- </where>
- ) as accomplish_count ,
- (SELECT COUNT(*) FROM repair_record
- <where>
- AND deleted = 0
- and maintenance_state = 9
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and report_time between #{startTime} and #{endTime}
- </if>
- </where>
- ) as shut_count ,
- (SELECT COUNT(*) FROM repair_record
- <where>
- AND deleted = 0
- and maintenance_state = 8
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and report_time between #{startTime} and #{endTime}
- </if>
- </where>
- ) as cancel_count ,
- (SELECT COUNT(*) FROM repair_record
- <where>
- AND deleted = 0
- and maintenance_state = 3
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and report_time between #{startTime} and #{endTime}
- </if>
- </where>
- ) as dispose_count ,
- (SELECT COUNT(*) FROM repair_record
- <where>
- AND deleted = 0
- and maintenance_state = 4
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and report_time between #{startTime} and #{endTime}
- </if>
- </where>
- )
- as affirm_count
- </select>
- <select id="queryTimeOut" resultType="java.lang.Integer">
- SELECT count(*) FROM (
- 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
- inner join repair_dispatch_record rdr on rdr.deleted = 0 and rdr.record_id = rr.id and rdr.is_lose_efficacy = 0
- and ((date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) <= NOW() and
- rdr.receiving_time is null) or date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) <=
- rdr.receiving_time)
- where rr.is_duty = 0 and rr.maintenance_state <= 7 and rr.deleted = 0
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and rr.report_time between #{startTime} and #{endTime}
- </if>
- UNION
- 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
- inner join repair_receiving rdv on rdv.deleted = 0 and rdv.record_id = rr.id and rdv.is_lose_efficacy = 0
- and ((date_add(rdv.receiving_time , interval rdv.maintenance_assess_time minute) <= NOW() and
- rdv.maintenance_assess_time is null) or date_add(rdv.receiving_time , interval rdv.maintenance_assess_time
- minute) <= rdv.finish_time)
- where rr.is_duty = 0 and rr.maintenance_state <= 7 and rr.deleted = 0
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and rr.report_time between #{startTime} and #{endTime}
- </if>
- ) t
- </select>
- <select id="repairSummarizing" resultType="com.repair.model.vo.RepairSummarizingVo">
- SELECT
- (SELECT COUNT(*) FROM repair_record
- <where>
- AND deleted = 0
- and (maintenance_state in (5,6,11))
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and report_time between #{startTime} and #{endTime}
- </if>
- </where>
- ) as check_count ,
- (SELECT COUNT(*) FROM repair_record rr
- 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
- <where>
- AND rr.deleted = 0
- and rr.maintenance_state = 1
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and rr.report_time between #{startTime} and #{endTime}
- </if>
- </where>
- ) as receiving_count ,
- (SELECT COUNT(*) FROM repair_record rr
- 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
- <where>
- AND rr.deleted = 0
- and rr.maintenance_state = 2
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and rr.report_time between #{startTime} and #{endTime}
- </if>
- </where>
- ) as maintain_count ,
- (SELECT COUNT(*) FROM repair_record
- <where>
- AND deleted = 0
- and maintenance_state = 7
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and report_time between #{startTime} and #{endTime}
- </if>
- </where>
- ) as accomplish_count ,
- (SELECT COUNT(*) FROM repair_record
- <where>
- AND deleted = 0
- and maintenance_state = 9
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and report_time between #{startTime} and #{endTime}
- </if>
- </where>
- ) as shut_count ,
- (SELECT COUNT(*) FROM repair_record
- <where>
- AND deleted = 0
- and maintenance_state = 8
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and report_time between #{startTime} and #{endTime}
- </if>
- </where>
- ) as cancel_count ,
- (SELECT COUNT(*) FROM repair_record
- <where>
- AND deleted = 0
- and maintenance_state = 3
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and report_time between #{startTime} and #{endTime}
- </if>
- </where>
- ) as dispose_count ,
- (SELECT COUNT(*) FROM repair_record
- <where>
- AND deleted = 0
- and maintenance_state = 4
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and report_time between #{startTime} and #{endTime}
- </if>
- </where>
- )
- as affirm_count
- </select>
- <select id="repairTotalData" resultType="com.repair.model.vo.RepairTotalDataVo">
- select (SELECT COUNT(*)
- FROM repair_record
- where deleted = 0
- and (maintenance_state in (5, 6,11))) as check_count,
- (SELECT COUNT(*)
- FROM repair_record rr
- 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
- where rr.deleted = 0
- and rr.maintenance_state = 1) as receiving_count,
- (SELECT COUNT(*)
- FROM repair_record rr
- 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
- where rr.deleted = 0
- and rr.maintenance_state = 2) as maintain_count,
- (SELECT COUNT(*)
- FROM repair_record
- where deleted = 0
- and maintenance_state = 7) as accomplish_count,
- (SELECT COUNT(*)
- FROM repair_record
- where deleted = 0
- and maintenance_state = 9) as shut_count,
- (SELECT COUNT(*)
- FROM repair_record
- where deleted = 0
- and maintenance_state = 8) as cancel_count,
- (SELECT COUNT(*)
- FROM repair_record
- where deleted = 0
- and maintenance_state = 3) as dispose_count,
- (SELECT COUNT(*)
- FROM repair_record
- where deleted = 0
- and maintenance_state = 4)
- as affirm_count
- </select>
- <!--打印-->
- <resultMap type="com.repair.model.vo.PrintVo" id="PrintDataMap">
- <result property="recordNo" column="record_no"/>
- <result property="userName" column="user_name"/>
- <result property="userClass" column="user_class"/>
- <result property="userPhone" column="user_phone"/>
- <result property="areaId" column="area_id"/>
- <result property="articleName" column="article_name"/>
- <result property="reportTime" column="report_time"/>
- <result property="description" column="description"/>
- <result property="maintenancerName" column="maintenancer_name"/>
- <result property="maintenancerPhone" column="maintenancer_phone"/>
- <result property="maintenanceState" column="maintenance_state"/>
- <result property="schoolId" column="school_id"/>
- <result property="price" column="price"/>
- <result property="refund" column="refund"/>
- </resultMap>
- <select id="queryPrintData" resultType="com.repair.model.vo.PrintVo" resultMap="PrintDataMap">
- select rr.record_no,rr.user_name,rr.user_class,rr.user_phone,CONCAT(rr.area_id,rr.address) as area_id,rat.name
- as
- article_name,rr.report_time,rr.description,rr.maintenancer_name,rr.maintenancer_phone,rr.maintenance_state,rr.price,rr.school_id,
- (select IFNULL(sum(refund_price),0) from repair_refund_record where deleted = 0 and record_id = rr.id and
- approve = 2) as refund
- from repair_record rr
- left join repair_article_type rat on rat.deleted = 0 and rat.id = rr.article_id
- where rr.deleted = 0
- <if test="recordId != null and recordId != ''">
- and rr.id = #{recordId}
- </if>
- </select>
- </mapper>
|