| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354 |
- <?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,1, NULL)) Incomplete,COUNT(IF(maintenance_state=4,1, NULL))
- Confirmed,COUNT(IF(maintenance_state >=7 ,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.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.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.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.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.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.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.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 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.maintenancer_name,rr.maintenancer_phone,rr.price
- 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
- order by rr.report_time DESC
- </select>
- <!--维修中-->
- <select id="queryRepairOrderList" resultType="com.repair.model.vo.RepairTechnicianVo"
- resultMap="repairRecordTechnicianDataMap">
- 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.maintenancer_name,rr.maintenancer_phone,rr.price
- 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
- order by rr.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 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.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 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.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 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
- 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 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
- </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"/>
- </resultMap>
- <select id="queryManageCount" resultType="com.repair.model.vo.RepairManageCountVo" resultMap="repairManageCountMap">
- select
- (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
- <if test="keyWord != null and keyWord != ''">
- and (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 dispatch_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
- <if test="keyWord != null and keyWord != ''">
- and (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 maintenance_count,
- (select Count(*) from repair_record where deleted = 0 and maintenance_state = 3
- <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>
- ) as logistics_count,
- (select Count(*) from repair_record where deleted = 0 and (maintenance_state = 5 or maintenance_state = 6)
- <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>
- ) as examine_count,
- (select Count(*) from repair_record where deleted = 0 and maintenance_state = 7
- <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>
- ) as finished_count,
- (select Count(*) from repair_record where deleted = 0 and maintenance_state = 8
- <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>
- ) as canceled_count,
- (select Count(*) from repair_record where deleted = 0 and maintenance_state = 9
- <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>
- ) 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.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.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) as timeout_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="userId" column="user_id"/>
- </resultMap>
- <!--除已超时外的其他数据获取方式-->
- <select id="queryNotTimeout" resultType="com.repair.model.vo.RepairRecordPageVo" resultMap="repairRecordPageMap">
- 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
- 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_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.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>
- <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 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.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.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
- order by t.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"/>
- </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) 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 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
- </select>
- <!--待接单-->
- <select id="queryTeamWorkPending" resultType="com.repair.model.vo.RepairTechnicianVo"
- resultMap="repairRecordTechnicianDataMap">
- 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,(select user_name from repair_user where deleted = 0 and id = rdr.users_id) as 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
- 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
- order by rr.report_time DESC
- </select>
- <!--维修中-->
- <select id="queryTeamWorkMaintenance" resultType="com.repair.model.vo.RepairTechnicianVo"
- resultMap="repairRecordTechnicianDataMap">
- 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,(select user_name from repair_user where deleted = 0 and id = rdv.user_id) as 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
- 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
- order by rr.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 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 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 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 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 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="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.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,rr3.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.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,rr4.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.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"/>
- </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
- where deleted = 0 and 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.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.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
- 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) 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.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.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.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_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>
- <select id="repairCampusTotal" resultType="com.repair.model.vo.RepairCampusVo">
- SELECT rs.id,
- count(rr.school_id) as orders_total,
- rs.`name` as school_name,
- (SELECT COUNT(school_id)
- FROM `repair_record`
- WHERE price > 0
- AND rs.id = school_id
- AND deleted = 0) AS orders_compensation,
- (SELECT COUNT(school_id)
- FROM `repair_record`
- WHERE (price IS NULL OR price = 0)
- AND rs.id = school_id
- AND deleted = 0) 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
- AND rr.deleted = 0
- GROUP BY rr.school_id
- </select>
- <select id="repairCampus" resultType="com.repair.model.vo.RepairCampusVo">
- SELECT
- rs.id,
- count( rr.school_id ) as orders_total,
- rs.`name` as school_name,
- (
- SELECT
- COUNT( school_id )
- FROM
- `repair_record`
- <where>
- and price > 0
- AND rs.id = school_id
- AND deleted = 0
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and report_time between #{startTime} and #{endTime}
- </if>
- </where>
- ) AS orders_compensation,
- (
- SELECT
- COUNT( school_id )
- FROM
- `repair_record`
- <where>
- and ( price IS NULL OR price = 0 )
- AND rs.id = school_id
- AND deleted = 0
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and report_time between #{startTime} and #{endTime}
- </if>
- </where>
- ) 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.school_id
- </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,
- (SELECT COUNT(area_id)
- FROM `repair_record`
- WHERE price > 0
- AND rr.area_id = area_id
- AND deleted = 0) AS orders_compensation,
- (SELECT COUNT(area_id)
- FROM `repair_record`
- WHERE (price IS NULL OR price = 0)
- AND rr.area_id = area_id
- AND deleted = 0) 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,
- (SELECT COUNT(area_id)
- FROM `repair_record`
- <where>
- AND price > 0
- AND rr.area_id = area_id
- AND deleted = 0
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and report_time between #{startTime} and #{endTime}
- </if>
- </where>
- ) AS orders_compensation,
- (SELECT COUNT(area_id)
- FROM `repair_record`
- <where>
- AND (price IS NULL OR price = 0)
- AND rr.area_id = area_id
- AND deleted = 0
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and report_time between #{startTime} and #{endTime}
- </if>
- </where>
- ) 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="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,
- count(rr.article_id) AS orders_total,
- (SELECT COUNT(article_id)
- FROM `repair_record`
- WHERE price > 0
- AND rr.article_id = article_id
- AND deleted = 0) AS orders_compensation,
- (SELECT COUNT(article_id)
- FROM `repair_record`
- WHERE (price IS NULL OR price = 0)
- AND rr.article_id = article_id
- AND deleted = 0) 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 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,
- count(rr.article_id) AS orders_total,
- (SELECT COUNT(article_id)
- FROM `repair_record`
- <where>
- and price > 0 AND rr.article_id = article_id AND deleted = 0
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and report_time between #{startTime} and #{endTime}
- </if>
- </where>
- ) AS orders_compensation,
- (SELECT COUNT(article_id)
- FROM `repair_record`
- <where>
- and (price IS NULL OR price = 0)
- AND rr.article_id = article_id
- AND deleted = 0
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and report_time between #{startTime} and #{endTime}
- </if>
- </where>
- ) 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>
- <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,
- (SELECT COUNT(area_id)
- FROM `repair_record`
- <where>
- AND price > 0
- AND rr.area_id = area_id
- AND deleted = 0
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and report_time between #{startTime} and #{endTime}
- </if>
- </where>
- ) AS orders_compensation,
- (SELECT COUNT(area_id)
- FROM `repair_record`
- <where>
- AND (price IS NULL OR price = 0)
- AND rr.area_id = area_id
- AND deleted = 0
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and report_time between #{startTime} and #{endTime}
- </if>
- </where>
- ) 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,
- count(rr.article_id) AS orders_total,
- (SELECT COUNT(article_id)
- FROM `repair_record`
- <where>
- and price > 0 AND rr.article_id = article_id AND deleted = 0
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and report_time between #{startTime} and #{endTime}
- </if>
- </where>
- ) AS orders_compensation,
- (SELECT COUNT(article_id)
- FROM `repair_record`
- <where>
- and (price IS NULL OR price = 0)
- AND rr.article_id = article_id
- AND deleted = 0
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and report_time between #{startTime} and #{endTime}
- </if>
- </where>
- ) 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="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.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
- COUNT(*) AS total_count,
- (SELECT COUNT(*) FROM repair_record
- <where>
- AND deleted = 0
- and (maintenance_state in (5,6))
- <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
- <where>
- AND deleted = 0
- and maintenance_state = 1
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and report_time between #{startTime} and #{endTime}
- </if>
- </where>
- ) as receiving_count ,
- (SELECT COUNT(*) FROM repair_record
- <where>
- AND deleted = 0
- and maintenance_state = 2
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and 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
- FROM
- repair_record rr
- <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="queryTimeOut" resultType="java.lang.Integer">
- SELECT COUNT(*) FROM (
- select rr3.school_id,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,concat((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="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and rr3.report_time between #{startTime} and #{endTime}
- </if>
- </where>
- UNION ALL
- select rr4.school_id,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,concat((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="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and rr4.report_time between #{startTime} and #{endTime}
- </if>
- </where>
- ) t
- </select>
- <select id="repairSummarizing" resultType="com.repair.model.vo.RepairSummarizingVo">
- SELECT
- COUNT(*) AS total_count,
- (SELECT COUNT(*) FROM repair_record
- <where>
- AND deleted = 0
- and (maintenance_state in (5,6))
- <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
- <where>
- AND deleted = 0
- and maintenance_state = 1
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and report_time between #{startTime} and #{endTime}
- </if>
- </where>
- ) as receiving_count ,
- (SELECT COUNT(*) FROM repair_record
- <where>
- AND deleted = 0
- and maintenance_state = 2
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and 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
- FROM
- repair_record rr
- <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="repairTotalData" resultType="com.repair.model.vo.RepairTotalDataVo">
- select *, sum(t.accomplish_count + t.cancel_count + t.shut_count) as accomplish_total_count
- from (SELECT COUNT(*) AS total_count,
- (SELECT COUNT(*)
- FROM repair_record
- where deleted = 0
- and (maintenance_state in (5, 6))) as check_count,
- (SELECT COUNT(*)
- FROM repair_record
- where deleted = 0
- and maintenance_state = 1) as receiving_count,
- (SELECT COUNT(*)
- FROM repair_record
- where deleted = 0
- and 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
- FROM repair_record rr
- where rr.deleted = 0) t
- </select>
- </mapper>
|