319 lines
19 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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.RepairMapper">
<resultMap type="com.ics.admin.domain.Repair" id="RepairResult">
<result property="id" column="id" />
<result property="sn" column="sn" />
<result property="repairName" column="repair_name" />
<result property="repairLevel" column="repair_level" />
<result property="repairTime" column="repair_time" />
<result property="typeId" column="type_id" />
<result property="typeName" column="type_name" />
<result property="deviceId" column="device_id" />
<result property="deviceName" column="device_name" />
<result property="name" column="name" />
<result property="phone" column="phone" />
<result property="addressId" column="address_id" />
<result property="address" column="address" />
<result property="floorId" column="floor_id" />
<result property="floor" column="floor" />
<result property="room" column="room" />
<result property="explain" column="explain" />
<result property="perUserId" column="per_userid" />
<result property="preDate" column="predate" />
<result property="cause" column="cause" />
<result property="solution" column="solution" />
<result property="failureTypeId" column="failure_type_id" />
<result property="failureTypeName" column="failure_type_name" />
<result property="resolve" column="resolve" />
<result property="repairUserId" column="repair_user_id" />
<result property="endDate" column="end_date" />
<result property="evalService" column="eval_service" />
<result property="feedback" column="feedback" />
<result property="evalTime" column="eval_time" />
<result property="evalUserId" column="eval_user_id" />
<result property="timeout" column="timeout" />
<result property="warn" column="warn" />
<result property="status" column="status" />
<result property="logId" column="log_id" />
<result property="remark" column="remark" />
<result property="ext1" column="ext1" />
<result property="ext2" column="ext2" />
<result property="ext3" column="ext3" />
<result property="deleteFlag" column="delete_flag" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="tenantId" column="tenant_id" />
<result property="parkId" column="park_id" />
</resultMap>
<sql id="selectRepairVo">
SELECT id, sn, repair_name, repair_level, repair_time, type_id, type_name, device_id, device_name, name, phone, address_id, address, floor_id, floor, room, `explain`, per_userid, predate, cause, solution, failure_type_id, failure_type_name, resolve, repair_user_id, end_date, eval_service, feedback, eval_time, eval_user_id, timeout, warn, status, log_id, remark, ext1, ext2, ext3, delete_flag, create_by, create_time, update_by, update_time, tenant_id, park_id FROM ics_repair
</sql>
<select id="selectRepairById" parameterType="Long" resultMap="RepairResult">
<include refid="selectRepairVo"/>
WHERE id = #{id} and delete_flag = 0
</select>
<insert id="insertRepair" parameterType="Repair" useGeneratedKeys="true" keyProperty="id">
INSERT INTO ics_repair
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="sn != null and sn != ''">sn,</if>
<if test="repairName != null and repairName != ''">repair_name,</if>
<if test="repairLevel != null and repairLevel != ''">repair_level,</if>
<if test="repairTime != null ">repair_time,</if>
<if test="typeId != null ">type_id,</if>
<if test="typeName != null and typeName != ''">type_name,</if>
<if test="deviceId != null ">device_id,</if>
<if test="deviceName != null and deviceName != ''">device_name,</if>
<if test="name != null and name != ''">name,</if>
<if test="phone != null and phone != ''">phone,</if>
<if test="addressId != null ">address_id,</if>
<if test="address != null and address != ''">address,</if>
<if test="floorId != null ">floor_id,</if>
<if test="floor != null and floor != ''">floor,</if>
<if test="room != null and room != ''">room,</if>
<if test="explain != null and explain != ''">`explain`,</if>
<if test="perUserId != null ">per_userid,</if>
<if test="preDate != null ">preDate,</if>
<if test="cause != null and cause != ''">cause,</if>
<if test="solution != null and solution != ''">solution,</if>
<if test="failureTypeId != null ">failure_type_id,</if>
<if test="failureTypeName != null and failureTypeName != ''">failure_type_name,</if>
<if test="resolve != null ">resolve,</if>
<if test="repairUserId != null ">repair_user_id,</if>
<if test="endDate != null ">end_date,</if>
<if test="evalService != null ">eval_service,</if>
<if test="feedback != null and feedback != ''">feedback,</if>
<if test="evalTime != null ">eval_time,</if>
<if test="evalUserId != null ">eval_user_id,</if>
<if test="timeout != null ">timeout,</if>
<if test="warn != null ">warn,</if>
<if test="status != null ">status,</if>
<if test="logId != null ">log_id,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="ext1 != null and ext1 != ''">ext1,</if>
<if test="ext2 != null and ext2 != ''">ext2,</if>
<if test="ext3 != null and ext3 != ''">ext3,</if>
<if test="deleteFlag != null ">delete_flag,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="createTime != null ">create_time,</if>
<if test="tenantId != null ">tenant_id,</if>
<if test="parkId != null ">park_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sn != null and sn != ''">#{sn},</if>
<if test="repairName != null and repairName != ''">#{repairName},</if>
<if test="repairLevel != null and repairLevel != ''">#{repairLevel},</if>
<if test="repairTime != null ">#{repairTime},</if>
<if test="typeId != null ">#{typeId},</if>
<if test="typeName != null and typeName != ''">#{typeName},</if>
<if test="deviceId != null ">#{deviceId},</if>
<if test="deviceName != null and deviceName != ''">#{deviceName},</if>
<if test="name != null and name != ''">#{name},</if>
<if test="phone != null and phone != ''">#{phone},</if>
<if test="addressId != null ">#{addressId},</if>
<if test="address != null and address != ''">#{address},</if>
<if test="floorId != null ">#{floorId},</if>
<if test="floor != null and floor != ''">#{floor},</if>
<if test="room != null and room != ''">#{room},</if>
<if test="explain != null and explain != ''">#{explain},</if>
<if test="perUserId != null ">#{perUserId},</if>
<if test="preDate != null ">#{preDate},</if>
<if test="cause != null and cause != ''">#{cause},</if>
<if test="solution != null and solution != ''">#{solution},</if>
<if test="failureTypeId != null ">#{failureTypeId},</if>
<if test="failureTypeName != null and failureTypeName != ''">#{failureTypeName},</if>
<if test="resolve != null ">#{resolve},</if>
<if test="repairUserId != null ">#{repairUserId},</if>
<if test="endDate != null ">#{endDate},</if>
<if test="evalService != null ">#{evalService},</if>
<if test="feedback != null and feedback != ''">#{feedback},</if>
<if test="evalTime != null ">#{evalTime},</if>
<if test="evalUserId != null ">#{evalUserId},</if>
<if test="timeout != null ">#{timeout},</if>
<if test="warn != null ">#{warn},</if>
<if test="status != null ">#{status},</if>
<if test="logId != null ">#{logId},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="ext1 != null and ext1 != ''">#{ext1},</if>
<if test="ext2 != null and ext2 != ''">#{ext2},</if>
<if test="ext3 != null and ext3 != ''">#{ext3},</if>
<if test="deleteFlag != null ">#{deleteFlag},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="createTime != null ">#{createTime},</if>
<if test="tenantId != null ">#{tenantId},</if>
<if test="parkId != null ">#{parkId},</if>
</trim>
</insert>
<update id="updateRepair" parameterType="Repair">
UPDATE ics_repair
<trim prefix="SET" suffixOverrides=",">
<if test="sn != null and sn != ''">sn = #{sn},</if>
<if test="repairName != null and repairName != ''">repair_name = #{repairName},</if>
<if test="repairLevel != null and repairLevel != ''">repair_level = #{repairLevel},</if>
<if test="repairTime != null ">repair_time = #{repairTime},</if>
<if test="typeId != null ">type_id = #{typeId},</if>
<if test="typeName != null and typeName != ''">type_name = #{typeName},</if>
<if test="deviceId != null ">device_id = #{deviceId},</if>
<if test="deviceName != null and deviceName != ''">device_name = #{deviceName},</if>
<if test="name != null and name != ''">name = #{name},</if>
<if test="phone != null and phone != ''">phone = #{phone},</if>
<if test="addressId != null ">address_id = #{addressId},</if>
<if test="address != null and address != ''">address = #{address},</if>
<if test="floorId != null ">floor_id = #{floorId},</if>
<if test="floor != null and floor != ''">floor = #{floor},</if>
<if test="room != null and room != ''">room = #{room},</if>
<if test="explain != null and explain != ''">`explain` = #{explain},</if>
<if test="perUserId != null ">per_userid = #{perUserId},</if>
<if test="preDate != null ">predate = #{preDate},</if>
<if test="cause != null and cause != ''">cause = #{cause},</if>
<if test="solution != null and solution != ''">solution = #{solution},</if>
<if test="failureTypeId != null ">failure_type_id = #{failureTypeId},</if>
<if test="failureTypeName != null and failureTypeName != ''">failure_type_name = #{failureTypeName},</if>
<if test="resolve != null ">resolve = #{resolve},</if>
<if test="repairUserId != null ">repair_user_id = #{repairUserId},</if>
<if test="endDate != null ">end_date = #{endDate},</if>
<if test="evalService != null ">eval_service = #{evalService},</if>
<if test="feedback != null and feedback != ''">feedback = #{feedback},</if>
<if test="evalTime != null ">eval_time = #{evalTime},</if>
<if test="evalUserId != null ">eval_user_id = #{evalUserId},</if>
<if test="timeout != null ">timeout = #{timeout},</if>
<if test="warn != null ">warn = #{warn},</if>
<if test="status != null ">status = #{status},</if>
<if test="logId != null ">log_id = #{logId},</if>
<if test="remark != null and remark != ''">remark = #{remark},</if>
<if test="ext1 != null and ext1 != ''">ext1 = #{ext1},</if>
<if test="ext2 != null and ext2 != ''">ext2 = #{ext2},</if>
<if test="ext3 != null and ext3 != ''">ext3 = #{ext3},</if>
<if test="deleteFlag != null ">delete_flag = #{deleteFlag},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="updateTime != null ">update_time = #{updateTime},</if>
<if test="tenantId != null ">tenant_id = #{tenantId},</if>
<if test="parkId != null ">park_id = #{parkId},</if>
</trim>
WHERE id = #{id}
</update>
<!--普通用户 工单列表-->
<select id="repairList" parameterType="Repair" resultMap="RepairResult">
<!--1.普通用户3派单员5维修人, 7管理员 ,9楼层管理员-->
<if test="params.role == 1 or params.role == 3 or params.role == 5 or params.role == 7">
SELECT * FROM ics_repair rep where delete_flag = 0
</if>
<if test="params.role == 9">
select rep.* from ics_repair rep,ics_repair_address_floor floor where
rep.delete_flag=0 and floor.delete_flag=0 and floor.id=rep.floor_id and floor.admin_id= #{params.userId}
</if>
<if test="params.role == 1"> and create_by = #{params.userId}</if>
<if test="params.role == 3"> and per_userid = #{params.userId}</if>
<if test="params.role == 5"> and repair_user_id = #{params.userId}</if>
<!--普通用户、楼层管理员、管理员 都会用到以下分类-->
<if test="params.type == 'all'"></if>
<if test="params.type == 'process'"> and rep.status &lt;=7 </if>
<if test="params.type == 'evaling'"> and rep.status = 9</if>
<if test="params.type == 'evaled'"> and rep.status = 13</if>
<if test="params.type == 'invalid'"> and rep.status = 11</if>
<!--派单员-->
<if test="params.role == 3">
<if test="params.type == 'wait'"> and status = 1</if>
<if test="params.type == 'already'"><![CDATA[ and (status>=5 and status<=13 and status<> 11)]]></if>
</if>
<!--维修人员-->
<if test="params.role == 5">
<if test="params.type == 'wait'"> and status = 5</if>
<if test="params.type == 'process'"> and status = 7</if>
<if test="params.type == 'end'"> and (status = 9 or status = 13)</if>
</if>
<!--管理员-->
<if test="params.role == 7">
<if test="params.type == 'wait'"> and status = 1</if>
<if test="params.type == 'anew'"> and status = 3</if>
<if test="params.type == 'already'"><![CDATA[ and (status>=5 and status<=13 and status<> 11)]]></if>
</if>
<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>
order by create_time desc
</select>
<select id="workerRepairNumber" resultType="Integer">
select count(id) from ics_repair where delete_flag=0 and repair_user_id = #{userId}
<if test="type == 'wait'">and status = 5</if>
<if test="type == 'working'">and status = 7</if>
<if test="type == 'close'">and (status = 9 or status = 13)</if>
</select>
<delete id="deleteRepairById" parameterType="Long">
DELETE FROM ics_repair WHERE id = #{id}
</delete>
<delete id="deleteRepairByIds" parameterType="String">
DELETE FROM ics_repair where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<!-- 预警 -->
<update id="repairForewarnRed" parameterType="Integer">
update ics_repair set warn=5 where delete_flag=0 and status <![CDATA[ < ]]> 9 and preDate is not null and warn <![CDATA[ <> ]]> 5 and TIMESTAMPDIFF(DAY,NOW(),preDate) <![CDATA[ <= ]]> #{day}
</update>
<update id="repairForewarnOrange" parameterType="Integer">
update ics_repair set warn=3 where delete_flag=0 and status <![CDATA[ < ]]> 9 and preDate is not null and warn <![CDATA[ <= ]]> 1 and TIMESTAMPDIFF(DAY,NOW(),preDate) <![CDATA[ <= ]]> #{day}
</update>
<update id="removeWarn">
update ics_repair set warn=0 where delete_flag=0 and status <![CDATA[ >= ]]> 9 and warn <![CDATA[ > ]]> 0
</update>
<!-- 自动好评 -->
<update id="repairGoodEval">
update ics_repair set eval_service=5,eval_time=NOW(),eval_user_id=-1,status=13
where delete_flag=0 and status=9 and end_date is not null and TIMESTAMPDIFF(DAY,end_date,NOW()) <![CDATA[ >= ]]> 7
</update>
<!-- 防止刷单 -->
<select id="submitCheck" parameterType="String" resultType="Integer">
select count(id) from ics_repair where delete_flag=0 and create_by= #{userId} and TIMESTAMPDIFF(MINUTE,create_time,NOW()) <![CDATA[ <= ]]> 3
</select>
<!-- 超时告警,按顺序执行 -->
<select id="getRepairTimeoutRed" resultMap="RepairResult">
<![CDATA[
select * from ics_repair where delete_flag=0 and (status=5 or status=7) and timeout <> 5 and TIMESTAMPDIFF(DAY,preDate,now()) >= #{day}
]]>
</select>
<update id="repairTimeoutRed" parameterType="Integer">
<![CDATA[
update ics_repair set timeout=5 where delete_flag=0 and (status=5 or status=7) and timeout <> 5 and TIMESTAMPDIFF(DAY,preDate,now()) >= #{day}
]]>
</update>
<select id="getRepairTimeoutOrange" resultMap="RepairResult">
<![CDATA[
SELECT * from ics_repair where delete_flag=0 and (status=5 or status=7) and timeout <= 1 and TIMESTAMPDIFF(DAY,preDate,now()) >= #{day}
]]>
</select>
<update id="repairTimeoutOrange" parameterType="Integer">
<![CDATA[
update ics_repair set timeout=3 where delete_flag=0 and (status=5 or status=7) and timeout <= 1 and TIMESTAMPDIFF(DAY,preDate,now()) >= #{day}
]]>
</update>
</mapper>