2024-10-15 20:21:37 +08:00

84 lines
5.0 KiB
XML

<?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.ics.admin.mapper.RepairCheckMapper">
<select id="checkDeviceType" resultType="com.ics.admin.vo.RepairCheckVo">
SELECT
a.id pid, a.name pname, b.id sid, b.name sname
FROM ics_repair_device_type a,
ics_repair_device b
where a.delete_flag = 0
and b.delete_flag = 0
and a.id = b.type_id
and a.name = #{typeName}
and b.name = #{deviceName}
</select>
<select id="checkAddress" resultType="com.ics.admin.vo.RepairCheckVo">
SELECT
a.id pid, a.name pname, b.id sid, b.name sname
FROM ics_repair_address a,
ics_repair_address_floor b
where a.delete_flag = 0
and b.delete_flag = 0
and a.id = b.address_id
and a.name = #{addressName}
and b.name = #{floorName}
</select>
<!--工单导出-->
<select id="exportList" parameterType="com.ics.admin.domain.Repair" resultType="com.ics.admin.vo.RepairExportVo">
<![CDATA[
select
rep.id,DATE_FORMAT(rep.create_time,'%Y-%m-%d') create_time,rep.`name`,
case when rep.remark ='5110' then '5110' else '微信小程序' end AS source,
rep.`explain`,floor.bm,staff.username,
case when rep.`status`>=5 and rep.`status`<>11 then '是' else '否' end as wx,
rep.repair_level,
case when rep.end_date is not null then TIMESTAMPDIFF(DAY,rep.create_time,rep.end_date) ELSE '' END as duration,
case when rep.timeout=1 then '正常' when rep.timeout=3 then '超时' when rep.timeout=5 then '严重超时' else '' end as timeout,
case when rep.`status`=11 then '无效申请' when rep.`status`=9 or rep.`status`=13 then '已完成' else '处理中' end as `status`,
case when rep.resolve=1 then '已解决' when rep.resolve=0 then '未解决' else '' end as resolve,
CONCAT_WS('/',rep.address,rep.floor,rep.room) address,
rep.type_name typeName
from
ics_repair rep,ics_repair_address_floor floor,ics_customer_staff staff
where
rep.delete_flag=0 and floor.delete_flag=0 and staff.delete_flag =0 and rep.floor_id=floor.id and floor.admin_Id=staff.id
]]>
<if test="params.beginTime != null and params.endTime != null"> and rep.create_time between #{params.beginTime} and #{params.endTime}</if>
<if test="sn != null and sn != ''"> AND rep.sn LIKE CONCAT('%', #{sn}, '%')</if>
<if test="repairLevel != null and repairLevel != ''"> AND rep.repair_level LIKE CONCAT('%', #{repairLevel}, '%')</if>
<if test="typeId != null"> AND rep.type_id = #{typeId}</if>
<if test="deviceId != null"> AND rep.device_id = #{deviceId}</if>
<if test="name != null and name != ''"> AND rep.name LIKE CONCAT('%', #{name}, '%')</if>
<if test="phone != null and phone != ''"> AND rep.phone LIKE CONCAT('%', #{phone}, '%')</if>
<if test="addressId != null"> AND rep.address_id = #{addressId}</if>
<if test="floorId != null"> AND rep.floor_id = #{floorId}</if>
<if test="room != null and room != ''"> AND rep.room LIKE CONCAT('%', #{room}, '%')</if>
<if test="explain != null and explain != ''"> AND rep.`explain` LIKE CONCAT('%', #{explain}, '%')</if>
<if test="failureTypeId != null"> AND rep.failure_type_id = #{failureTypeId}</if>
<if test="remark != null and remark=='yes'"> AND rep.remark = '5110'</if>
<if test="remark != null and remark=='no'"> AND rep.remark is null</if>
<if test="evalService != null and evalService==1"> AND rep.eval_service &gt;= 4</if>
<if test="evalService != null and evalService==2"> AND rep.eval_service = 3</if>
<if test="evalService != null and evalService==3"> AND rep.eval_service &lt;= 2</if>
<if test="timeout != null and timeout==9"> and predate is not null and predate &lt; now() and status &lt; 9</if>
order by rep.create_time
</select>
<!-- 故障类型分类统计 -->
<select id="categoryExport" parameterType="com.ics.admin.domain.Repair" resultType="com.ics.admin.vo.RepairTypeExportVo">
select dt.name, count(rep.id) zs,
sum(case when `status` = 5 then 1 else 0 end) sh,
sum(case when `status` = 1 then 1 else 0 end) `wait`,
sum(case when `status` = 7 then 1 else 0 end) process,
sum(case when `status` = 9 or `status` = 13 then 1 else 0 end) `end`,
sum(case when `status`= 13 then 1 else 0 end) evaled
from ics_repair_device_type dt left join ics_repair rep on dt.id=rep.type_id and rep.delete_flag=0 and dt.delete_flag=0
<if test="params.beginTime != null and params.endTime != null"> and rep.create_time between #{params.beginTime} and #{params.endTime}</if>
group by dt.name order by dt.id
</select>
</mapper>