<?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.ruoyi.system.mapper.VehicleAlertConfigMapper">
|
|
<resultMap type="VehicleAlertConfig" id="VehicleAlertConfigResult">
|
<result property="configId" column="config_id" />
|
<result property="configType" column="config_type" />
|
<result property="deptId" column="dept_id" />
|
<result property="vehicleId" column="vehicle_id" />
|
<result property="mileageThreshold" column="mileage_threshold" />
|
<result property="dailyAlertLimit" column="daily_alert_limit" />
|
<result property="alertInterval" column="alert_interval" />
|
<result property="notifyUserIds" column="notify_user_ids" />
|
<result property="status" column="status" />
|
<result property="remark" column="remark" />
|
<result property="createBy" column="create_by" />
|
<result property="createTime" column="create_time" />
|
<result property="updateBy" column="update_by" />
|
<result property="updateTime" column="update_time" />
|
</resultMap>
|
|
<sql id="selectVehicleAlertConfigVo">
|
select c.config_id, c.config_type, c.dept_id, c.vehicle_id, c.mileage_threshold,
|
c.daily_alert_limit, c.alert_interval, c.notify_user_ids, c.status, c.remark,
|
c.create_by, c.create_time, c.update_by, c.update_time,
|
CASE
|
WHEN c.config_type = 'DEPT' THEN d.dept_name
|
WHEN c.config_type = 'VEHICLE' THEN v.vehicle_no
|
ELSE NULL
|
END as target_name
|
from tb_vehicle_alert_config c
|
left join sys_dept d on c.dept_id = d.dept_id
|
left join tb_vehicle_info v on c.vehicle_id = v.vehicle_id
|
</sql>
|
|
<select id="selectVehicleAlertConfigList" parameterType="VehicleAlertConfig" resultMap="VehicleAlertConfigResult">
|
<include refid="selectVehicleAlertConfigVo"/>
|
<where>
|
<if test="configType != null and configType != ''"> and c.config_type = #{configType}</if>
|
<if test="deptId != null "> and c.dept_id = #{deptId}</if>
|
<if test="vehicleId != null "> and c.vehicle_id = #{vehicleId}</if>
|
<if test="status != null and status != ''"> and c.status = #{status}</if>
|
</where>
|
order by
|
CASE c.config_type
|
WHEN 'GLOBAL' THEN 3
|
WHEN 'DEPT' THEN 2
|
WHEN 'VEHICLE' THEN 1
|
END,
|
c.create_time desc
|
</select>
|
|
<select id="selectVehicleAlertConfigByConfigId" parameterType="Long" resultMap="VehicleAlertConfigResult">
|
<include refid="selectVehicleAlertConfigVo"/>
|
where c.config_id = #{configId}
|
</select>
|
|
<select id="selectConfigByVehicle" resultMap="VehicleAlertConfigResult">
|
<include refid="selectVehicleAlertConfigVo"/>
|
where c.status = '0'
|
and (
|
(c.config_type = 'VEHICLE' and c.vehicle_id = #{vehicleId})
|
or (c.config_type = 'DEPT' and c.dept_id = #{deptId})
|
or c.config_type = 'GLOBAL'
|
)
|
order by
|
CASE c.config_type
|
WHEN 'VEHICLE' THEN 1
|
WHEN 'DEPT' THEN 2
|
WHEN 'GLOBAL' THEN 3
|
END
|
limit 1
|
</select>
|
|
<insert id="insertVehicleAlertConfig" parameterType="VehicleAlertConfig" useGeneratedKeys="true" keyProperty="configId">
|
insert into tb_vehicle_alert_config
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="configType != null and configType != ''">config_type,</if>
|
<if test="deptId != null">dept_id,</if>
|
<if test="vehicleId != null">vehicle_id,</if>
|
<if test="mileageThreshold != null">mileage_threshold,</if>
|
<if test="dailyAlertLimit != null">daily_alert_limit,</if>
|
<if test="alertInterval != null">alert_interval,</if>
|
<if test="notifyUserIds != null">notify_user_ids,</if>
|
<if test="status != null">status,</if>
|
<if test="remark != null">remark,</if>
|
<if test="createBy != null">create_by,</if>
|
create_time
|
</trim>
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<if test="configType != null and configType != ''">#{configType},</if>
|
<if test="deptId != null">#{deptId},</if>
|
<if test="vehicleId != null">#{vehicleId},</if>
|
<if test="mileageThreshold != null">#{mileageThreshold},</if>
|
<if test="dailyAlertLimit != null">#{dailyAlertLimit},</if>
|
<if test="alertInterval != null">#{alertInterval},</if>
|
<if test="notifyUserIds != null">#{notifyUserIds},</if>
|
<if test="status != null">#{status},</if>
|
<if test="remark != null">#{remark},</if>
|
<if test="createBy != null">#{createBy},</if>
|
now()
|
</trim>
|
</insert>
|
|
<update id="updateVehicleAlertConfig" parameterType="VehicleAlertConfig">
|
update tb_vehicle_alert_config
|
<trim prefix="SET" suffixOverrides=",">
|
<if test="configType != null and configType != ''">config_type = #{configType},</if>
|
<if test="deptId != null">dept_id = #{deptId},</if>
|
<if test="vehicleId != null">vehicle_id = #{vehicleId},</if>
|
<if test="mileageThreshold != null">mileage_threshold = #{mileageThreshold},</if>
|
<if test="dailyAlertLimit != null">daily_alert_limit = #{dailyAlertLimit},</if>
|
<if test="alertInterval != null">alert_interval = #{alertInterval},</if>
|
<if test="notifyUserIds != null">notify_user_ids = #{notifyUserIds},</if>
|
<if test="status != null">status = #{status},</if>
|
<if test="remark != null">remark = #{remark},</if>
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
update_time = now()
|
</trim>
|
where config_id = #{configId}
|
</update>
|
|
<delete id="deleteVehicleAlertConfigByConfigId" parameterType="Long">
|
delete from tb_vehicle_alert_config where config_id = #{configId}
|
</delete>
|
|
<delete id="deleteVehicleAlertConfigByConfigIds" parameterType="String">
|
delete from tb_vehicle_alert_config where config_id in
|
<foreach item="configId" collection="array" open="(" separator="," close=")">
|
#{configId}
|
</foreach>
|
</delete>
|
</mapper>
|