| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313 |
- <?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 maintenance_state <= 7 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="dispatchTime" column="dispatch_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"/>
- </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() when true then '超时未接'
- else null end as timeout_disp_str,
- case date_add(rdv.receiving_time, interval rdv.maintenance_assess_time minute) <= NOW() when true then '维修超时'
- else null end as timeout_rece_str,
- rr.id,rr.price,rr.maintenancer_name,rr.maintenancer_phone,rr.record_no,rr.report_time,rr.dispatch_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>
- 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 rr1
- inner join repair_dispatch_record rdr on rdr.deleted = 0 and rdr.users_id = #{userId} and rdr.record_id = rr1.id and
- rdr.is_lose_efficacy = 0
- where rr1.maintenance_state = 1 and rr1.deleted = 0) 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}
- where rr3.maintenance_state = 1 and rr3.deleted = 0
- UNION ALL
- 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}
- where rr4.maintenance_state = 2 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="timeoutStr" column="timeout_str"/>
- </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} when true then '超时未接' else null end as timeout_str,rr.id,rr.record_no,rr.report_time,rr.user_name,rr.user_phone,rr.area_id as area_name,rr.address,rat.name as article_name,rr.description,rr.image,'待接单' as state
- 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
- 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} when true then '维修超时' else null end as timeout_str,rr.id,rr.record_no,rr.report_time,rr.user_name,rr.user_phone,rr.area_id as area_name,rr.address,rat.name as article_name ,rr.description,rr.image,'维修中' as state
- 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 * FROM (
- select case date_add(rdr.assigned_time , interval rdr.acceptance_assess_time minute) <= #{dateNow} when true then '超时未接' else null end as timeout_str,rr.id,rr.record_no,rr.report_time,rr.user_name,rr.user_phone,rr.area_id as area_name,rr.address,rat.name as article_name ,rr.description,rr.image,'待接单' as state 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) <= #{dateNow}
- 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
- UNION ALL
- select case date_add(rdv.receiving_time, interval rdv.maintenance_assess_time minute) <= #{dateNow} when true then '维修超时' else null end as timeout_str,rr.id,rr.record_no,rr.report_time,rr.user_name,rr.user_phone,rr.area_id as area_name,rr.address,rat.name as article_name ,rr.description,rr.image,'维修中' as state 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) <= #{dateNow}
- 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) t
- order by t.report_time desc
- </select>
- <!--待审核-->
- <select id="queryExamineOrderList" resultType="com.repair.model.vo.RepairTechnicianVo"
- resultMap="repairRecordTechnicianDataMap">
- 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 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.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 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="allCount" column="all_count"/>
- <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 where deleted = 0) as all_count,
- (select Count(*) from repair_record where deleted = 0 and maintenance_state = 1) as dispatch_count,
- (select Count(*) from repair_record where deleted = 0 and maintenance_state = 2) as maintenance_count,
- (select Count(*) from repair_record where deleted = 0 and maintenance_state = 3) as logistics_count,
- (select Count(*) from repair_record where deleted = 0 and (maintenance_state = 5 or maintenance_state = 6)) as examine_count,
- (select Count(*) from repair_record where deleted = 0 and maintenance_state = 7) as finished_count,
- (select Count(*) from repair_record where deleted = 0 and maintenance_state = 8) as canceled_count,
- (select Count(*) from repair_record where deleted = 0 and maintenance_state = 9) as closed_count,
- (select Count(*) as cs from (select rr3.* from repair_record rr3
- 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()
- where rr3.maintenance_state = 1 and rr3.deleted = 0
- UNION ALL
- select rr4.* from repair_record rr4
- 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()
- where rr4.maintenance_state = 2 and rr4.deleted = 0) c) 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="userName" column="user_name"/>
- <result property="userPhone" column="user_phone"/>
- <result property="articleName" column="article_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="userId" column="user_id"/>
- </resultMap>
- <!--除已超时外的其他数据获取方式-->
- <select id="queryNotTimeout" resultType="com.repair.model.vo.RepairRecordPageVo" resultMap="repairRecordPageMap">
- 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="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="queryTimeout" resultType="com.repair.model.vo.RepairRecordPageVo" resultMap="repairRecordPageMap">
- 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()
- <where>
- and rr3.maintenance_state = 1 and rr3.deleted = 0
- <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>
- </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()
- <where>
- and rr4.maintenance_state = 2 and rr4.deleted = 0
- <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>
- </where>
- ) t
- 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"/>
- </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 users_id = #{userId}) as disp_count,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
- 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) t where t.disp_count <= 0
- order by t.report_time desc
- </select>
- </mapper>
|