2024-09-10 17:37:44 +08:00
|
|
|
<?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.bonus.base.mapper.TbDeviceMapper">
|
|
|
|
|
<resultMap id="BaseResultMap" type="com.bonus.base.domain.TbDevice">
|
|
|
|
|
<!--@mbg.generated-->
|
|
|
|
|
<!--@Table tb_device-->
|
|
|
|
|
<id column="id" jdbcType="BIGINT" property="id" />
|
|
|
|
|
<result column="dev_type" jdbcType="VARCHAR" property="devType" />
|
|
|
|
|
<result column="dev_code" jdbcType="VARCHAR" property="devCode" />
|
|
|
|
|
<result column="dev_name" jdbcType="VARCHAR" property="devName" />
|
|
|
|
|
<result column="bd_id" jdbcType="BIGINT" property="bdId" />
|
|
|
|
|
<result column="config_id" jdbcType="BIGINT" property="configId" />
|
|
|
|
|
<result column="dev_status" jdbcType="INTEGER" property="devStatus" />
|
|
|
|
|
<result column="dev_warn" jdbcType="INTEGER" property="devWarn" />
|
|
|
|
|
<result column="del_flag" jdbcType="INTEGER" property="delFlag" />
|
|
|
|
|
<result column="logo_url" jdbcType="VARCHAR" property="logoUrl" />
|
|
|
|
|
</resultMap>
|
2024-09-19 11:04:18 +08:00
|
|
|
|
2024-09-10 17:37:44 +08:00
|
|
|
<sql id="Base_Column_List">
|
|
|
|
|
<!--@mbg.generated-->
|
2024-09-23 15:25:09 +08:00
|
|
|
id, dev_type, dev_code, dev_name, bd_id, config_id, dev_status, dev_warn, del_flag,
|
2024-09-10 17:37:44 +08:00
|
|
|
logo_url
|
|
|
|
|
</sql>
|
2024-09-19 11:04:18 +08:00
|
|
|
|
2024-09-10 17:37:44 +08:00
|
|
|
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
|
|
|
|
|
<!--@mbg.generated-->
|
2024-09-23 15:25:09 +08:00
|
|
|
select
|
2024-09-10 17:37:44 +08:00
|
|
|
<include refid="Base_Column_List" />
|
|
|
|
|
from tb_device
|
|
|
|
|
where id = #{id,jdbcType=BIGINT}
|
|
|
|
|
</select>
|
2024-09-19 11:04:18 +08:00
|
|
|
|
2024-09-10 17:37:44 +08:00
|
|
|
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
|
|
|
|
|
update tb_device set del_flag = 1
|
|
|
|
|
where id = #{id,jdbcType=BIGINT}
|
|
|
|
|
</delete>
|
2024-09-19 11:04:18 +08:00
|
|
|
|
2024-09-10 17:37:44 +08:00
|
|
|
<insert id="insert" parameterType="com.bonus.base.domain.TbDevice">
|
|
|
|
|
<!--@mbg.generated-->
|
2024-09-23 15:25:09 +08:00
|
|
|
insert into tb_device (id, dev_type, dev_code,
|
|
|
|
|
dev_name, bd_id, config_id,
|
|
|
|
|
dev_status, dev_warn, del_flag,
|
2024-09-10 17:37:44 +08:00
|
|
|
logo_url)
|
2024-09-23 15:25:09 +08:00
|
|
|
values (#{id,jdbcType=BIGINT}, #{devType,jdbcType=VARCHAR}, #{devCode,jdbcType=VARCHAR},
|
|
|
|
|
#{devName,jdbcType=VARCHAR}, #{bdId,jdbcType=BIGINT}, #{configId,jdbcType=BIGINT},
|
|
|
|
|
#{devStatus,jdbcType=INTEGER}, #{devWarn,jdbcType=INTEGER}, #{delFlag,jdbcType=INTEGER},
|
2024-09-10 17:37:44 +08:00
|
|
|
#{logoUrl,jdbcType=VARCHAR})
|
|
|
|
|
</insert>
|
|
|
|
|
<insert id="insertSelective" parameterType="com.bonus.base.domain.TbDevice">
|
|
|
|
|
<!--@mbg.generated-->
|
|
|
|
|
insert into tb_device
|
|
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
2024-09-20 11:16:05 +08:00
|
|
|
<if test="id != null">
|
|
|
|
|
id,
|
|
|
|
|
</if>
|
2024-09-10 17:37:44 +08:00
|
|
|
<if test="devType != null and devType != ''">
|
|
|
|
|
dev_type,
|
|
|
|
|
</if>
|
|
|
|
|
<if test="devCode != null and devCode != ''">
|
|
|
|
|
dev_code,
|
|
|
|
|
</if>
|
|
|
|
|
<if test="devName != null and devName != ''">
|
|
|
|
|
dev_name,
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bdId != null">
|
|
|
|
|
bd_id,
|
|
|
|
|
</if>
|
|
|
|
|
<if test="configId != null">
|
|
|
|
|
config_id,
|
|
|
|
|
</if>
|
2024-09-20 10:51:00 +08:00
|
|
|
<if test="devStatus != null">
|
2024-09-10 17:37:44 +08:00
|
|
|
dev_status,
|
2024-09-20 10:51:00 +08:00
|
|
|
</if>
|
2024-09-10 17:37:44 +08:00
|
|
|
<if test="devWarn != null">
|
|
|
|
|
dev_warn,
|
|
|
|
|
</if>
|
|
|
|
|
del_flag,
|
|
|
|
|
<if test="logoUrl != null and logoUrl != ''">
|
|
|
|
|
logo_url,
|
|
|
|
|
</if>
|
|
|
|
|
</trim>
|
|
|
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
2024-09-20 10:51:00 +08:00
|
|
|
<if test="id != null">
|
|
|
|
|
#{id,jdbcType=BIGINT},
|
|
|
|
|
</if>
|
2024-09-10 17:37:44 +08:00
|
|
|
<if test="devType != null and devType != ''">
|
|
|
|
|
#{devType,jdbcType=VARCHAR},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="devCode != null and devCode != ''">
|
|
|
|
|
#{devCode,jdbcType=VARCHAR},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="devName != null and devName != ''">
|
|
|
|
|
#{devName,jdbcType=VARCHAR},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bdId != null">
|
|
|
|
|
#{bdId,jdbcType=BIGINT},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="configId != null">
|
|
|
|
|
#{configId,jdbcType=BIGINT},
|
|
|
|
|
</if>
|
2024-09-20 11:16:05 +08:00
|
|
|
<if test="devStatus != null">
|
|
|
|
|
#{devStatus,jdbcType=INTEGER},
|
|
|
|
|
</if>
|
2024-09-10 17:37:44 +08:00
|
|
|
<if test="devWarn != null">
|
|
|
|
|
#{devWarn,jdbcType=INTEGER},
|
|
|
|
|
</if>
|
2024-09-14 18:23:56 +08:00
|
|
|
0,
|
2024-09-10 17:37:44 +08:00
|
|
|
<if test="logoUrl != null and logoUrl != ''">
|
|
|
|
|
#{logoUrl,jdbcType=VARCHAR},
|
|
|
|
|
</if>
|
|
|
|
|
</trim>
|
|
|
|
|
</insert>
|
2024-09-19 11:04:18 +08:00
|
|
|
|
2024-09-10 17:37:44 +08:00
|
|
|
<update id="updateByPrimaryKeySelective" parameterType="com.bonus.base.domain.TbDevice">
|
|
|
|
|
<!--@mbg.generated-->
|
|
|
|
|
update tb_device
|
|
|
|
|
<set>
|
|
|
|
|
<if test="devType != null and devType != ''">
|
|
|
|
|
dev_type = #{devType,jdbcType=VARCHAR},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="devCode != null and devCode != ''">
|
|
|
|
|
dev_code = #{devCode,jdbcType=VARCHAR},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="devName != null and devName != ''">
|
|
|
|
|
dev_name = #{devName,jdbcType=VARCHAR},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bdId != null">
|
|
|
|
|
bd_id = #{bdId,jdbcType=BIGINT},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="configId != null">
|
|
|
|
|
config_id = #{configId,jdbcType=BIGINT},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="devStatus != null">
|
|
|
|
|
dev_status = #{devStatus,jdbcType=INTEGER},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="devWarn != null">
|
|
|
|
|
dev_warn = #{devWarn,jdbcType=INTEGER},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="delFlag != null">
|
|
|
|
|
del_flag = #{delFlag,jdbcType=INTEGER},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="logoUrl != null and logoUrl != ''">
|
|
|
|
|
logo_url = #{logoUrl,jdbcType=VARCHAR},
|
|
|
|
|
</if>
|
|
|
|
|
</set>
|
|
|
|
|
where id = #{id,jdbcType=BIGINT}
|
|
|
|
|
</update>
|
2024-09-19 11:04:18 +08:00
|
|
|
|
2024-09-10 17:37:44 +08:00
|
|
|
<update id="updateByPrimaryKey" parameterType="com.bonus.base.domain.TbDevice">
|
|
|
|
|
<!--@mbg.generated-->
|
|
|
|
|
update tb_device
|
|
|
|
|
set dev_type = #{devType,jdbcType=VARCHAR},
|
|
|
|
|
dev_code = #{devCode,jdbcType=VARCHAR},
|
|
|
|
|
dev_name = #{devName,jdbcType=VARCHAR},
|
|
|
|
|
bd_id = #{bdId,jdbcType=BIGINT},
|
|
|
|
|
config_id = #{configId,jdbcType=BIGINT},
|
|
|
|
|
dev_status = #{devStatus,jdbcType=INTEGER},
|
|
|
|
|
dev_warn = #{devWarn,jdbcType=INTEGER},
|
|
|
|
|
del_flag = #{delFlag,jdbcType=INTEGER},
|
|
|
|
|
logo_url = #{logoUrl,jdbcType=VARCHAR}
|
|
|
|
|
where id = #{id,jdbcType=BIGINT}
|
|
|
|
|
</update>
|
2024-09-19 11:04:18 +08:00
|
|
|
|
2024-09-10 17:37:44 +08:00
|
|
|
<update id="updateBatch" parameterType="java.util.List">
|
|
|
|
|
<!--@mbg.generated-->
|
|
|
|
|
update tb_device
|
|
|
|
|
<trim prefix="set" suffixOverrides=",">
|
|
|
|
|
<trim prefix="dev_type = case" suffix="end,">
|
|
|
|
|
<foreach collection="list" index="index" item="item">
|
|
|
|
|
when id = #{item.id,jdbcType=BIGINT} then #{item.devType,jdbcType=VARCHAR}
|
|
|
|
|
</foreach>
|
|
|
|
|
</trim>
|
|
|
|
|
<trim prefix="dev_code = case" suffix="end,">
|
|
|
|
|
<foreach collection="list" index="index" item="item">
|
|
|
|
|
when id = #{item.id,jdbcType=BIGINT} then #{item.devCode,jdbcType=VARCHAR}
|
|
|
|
|
</foreach>
|
|
|
|
|
</trim>
|
|
|
|
|
<trim prefix="dev_name = case" suffix="end,">
|
|
|
|
|
<foreach collection="list" index="index" item="item">
|
|
|
|
|
when id = #{item.id,jdbcType=BIGINT} then #{item.devName,jdbcType=VARCHAR}
|
|
|
|
|
</foreach>
|
|
|
|
|
</trim>
|
|
|
|
|
<trim prefix="bd_id = case" suffix="end,">
|
|
|
|
|
<foreach collection="list" index="index" item="item">
|
|
|
|
|
when id = #{item.id,jdbcType=BIGINT} then #{item.bdId,jdbcType=BIGINT}
|
|
|
|
|
</foreach>
|
|
|
|
|
</trim>
|
|
|
|
|
<trim prefix="config_id = case" suffix="end,">
|
|
|
|
|
<foreach collection="list" index="index" item="item">
|
|
|
|
|
when id = #{item.id,jdbcType=BIGINT} then #{item.configId,jdbcType=BIGINT}
|
|
|
|
|
</foreach>
|
|
|
|
|
</trim>
|
|
|
|
|
<trim prefix="dev_status = case" suffix="end,">
|
|
|
|
|
<foreach collection="list" index="index" item="item">
|
|
|
|
|
when id = #{item.id,jdbcType=BIGINT} then #{item.devStatus,jdbcType=INTEGER}
|
|
|
|
|
</foreach>
|
|
|
|
|
</trim>
|
|
|
|
|
<trim prefix="dev_warn = case" suffix="end,">
|
|
|
|
|
<foreach collection="list" index="index" item="item">
|
|
|
|
|
when id = #{item.id,jdbcType=BIGINT} then #{item.devWarn,jdbcType=INTEGER}
|
|
|
|
|
</foreach>
|
|
|
|
|
</trim>
|
|
|
|
|
<trim prefix="del_flag = case" suffix="end,">
|
|
|
|
|
<foreach collection="list" index="index" item="item">
|
|
|
|
|
when id = #{item.id,jdbcType=BIGINT} then #{item.delFlag,jdbcType=INTEGER}
|
|
|
|
|
</foreach>
|
|
|
|
|
</trim>
|
|
|
|
|
<trim prefix="logo_url = case" suffix="end,">
|
|
|
|
|
<foreach collection="list" index="index" item="item">
|
|
|
|
|
when id = #{item.id,jdbcType=BIGINT} then #{item.logoUrl,jdbcType=VARCHAR}
|
|
|
|
|
</foreach>
|
|
|
|
|
</trim>
|
|
|
|
|
</trim>
|
|
|
|
|
where id in
|
|
|
|
|
<foreach close=")" collection="list" item="item" open="(" separator=", ">
|
|
|
|
|
#{item.id,jdbcType=BIGINT}
|
|
|
|
|
</foreach>
|
|
|
|
|
</update>
|
2024-09-18 18:19:12 +08:00
|
|
|
|
2024-09-10 17:37:44 +08:00
|
|
|
<delete id="deleteByPrimaryKeyIn">
|
2024-09-18 18:19:12 +08:00
|
|
|
update tb_device set del_flag = 1 where id in
|
2024-09-10 17:37:44 +08:00
|
|
|
<foreach close=")" collection="list" item="id" open="(" separator=", ">
|
|
|
|
|
#{id,jdbcType=BIGINT}
|
|
|
|
|
</foreach>
|
|
|
|
|
</delete>
|
2024-09-18 18:19:12 +08:00
|
|
|
|
|
|
|
|
<select id="getDeviceView" resultType="com.bonus.screen.vo.DeviceViewVo">
|
|
|
|
|
select count(1) as deviceTotal,
|
|
|
|
|
count(dev_status = 1) as deviceOnlineTotal
|
|
|
|
|
from tb_device
|
|
|
|
|
where del_flag = 0
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="getSensingDevice" resultType="com.bonus.screen.vo.DeviceViewVo">
|
|
|
|
|
select count(1) as deviceTotal,
|
2024-09-20 18:47:08 +08:00
|
|
|
count(CASE WHEN dev_type = #{param1.code} THEN 1 END) as baseSafetyHat,
|
|
|
|
|
count(CASE WHEN dev_type = #{param2.code} THEN 1 END) as baseEnvironmentMonitor,
|
|
|
|
|
count(CASE WHEN dev_type = #{param3.code} THEN 1 END) as basePitMonitor,
|
|
|
|
|
count(CASE WHEN dev_type = #{param4.code} THEN 1 END) as towerRakeMonitor,
|
|
|
|
|
count(CASE WHEN dev_type = #{param5.code} THEN 1 END) as towerWaterMonitor,
|
|
|
|
|
count(CASE WHEN dev_type = #{param6.code} THEN 1 END) as leadStrainMonitor
|
2024-09-18 18:19:12 +08:00
|
|
|
from tb_device
|
|
|
|
|
where del_flag = 0
|
|
|
|
|
</select>
|
2024-09-19 11:04:18 +08:00
|
|
|
|
|
|
|
|
<select id="getAll" resultType="com.bonus.base.domain.TbDevice">
|
|
|
|
|
SELECT
|
|
|
|
|
td.id as id,
|
|
|
|
|
td.dev_type as devType,
|
|
|
|
|
sda.dict_label as devTypeName,
|
|
|
|
|
td.dev_code as devCode,
|
|
|
|
|
td.dev_name as devName,
|
|
|
|
|
td.bd_id as bdId,
|
|
|
|
|
t1.dev_name as bdName,
|
|
|
|
|
td.config_id as configId,
|
|
|
|
|
t2.config_name as configName,
|
|
|
|
|
td.dev_status as devStatus,
|
|
|
|
|
CASE
|
|
|
|
|
WHEN td.dev_status = 0 THEN
|
|
|
|
|
'离线'
|
|
|
|
|
WHEN td.dev_status = 1 THEN
|
|
|
|
|
'在线'
|
|
|
|
|
ELSE
|
|
|
|
|
'未知状态'
|
|
|
|
|
END devStatusName,
|
|
|
|
|
td.dev_warn as devWarn,
|
|
|
|
|
td.del_flag as delFlag,
|
|
|
|
|
td.logo_url as logoUrl
|
|
|
|
|
FROM
|
|
|
|
|
tb_device td
|
|
|
|
|
LEFT JOIN sys_dict_data sda ON td.dev_type = sda.dict_code
|
|
|
|
|
LEFT JOIN tb_bd_device_record t1 on td.bd_id = t1.id
|
|
|
|
|
LEFT JOIN tb_warn_config t2 on t2.id = td.config_id and t2.del_flag = 0
|
|
|
|
|
WHERE
|
|
|
|
|
td.del_flag = 0
|
|
|
|
|
<if test="devType != null and devType != ''">
|
|
|
|
|
and td.dev_type = #{devType}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="devName != null and devName != ''">
|
|
|
|
|
and td.dev_name like concat('%',#{devName},'%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="devCode != null and devCode != ''">
|
|
|
|
|
and td.dev_code like concat('%',#{devCode},'%')
|
|
|
|
|
</if>
|
2024-09-23 15:25:09 +08:00
|
|
|
<if test="devStatus != null">
|
2024-09-19 11:04:18 +08:00
|
|
|
and td.dev_status = #{devStatus}
|
|
|
|
|
</if>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="selectByDevCode" resultType="com.bonus.base.domain.TbDevice">
|
|
|
|
|
select
|
|
|
|
|
<include refid="Base_Column_List" />
|
|
|
|
|
from tb_device
|
2024-09-20 09:29:53 +08:00
|
|
|
where del_flag = 0
|
2024-09-19 11:04:18 +08:00
|
|
|
<if test="devName != null and devName != ''">
|
|
|
|
|
<if test="devCode != null and devCode != ''">
|
|
|
|
|
and (dev_name = #{devName} or dev_code = #{devCode})
|
|
|
|
|
</if>
|
|
|
|
|
<if test="devCode == null or devCode == ''">
|
|
|
|
|
and dev_name = #{devName}
|
|
|
|
|
</if>
|
|
|
|
|
</if>
|
|
|
|
|
<if test="devName == null or devName == ''">
|
|
|
|
|
<if test="devCode != null and devCode != ''">
|
|
|
|
|
and dev_code = #{devCode}
|
|
|
|
|
</if>
|
|
|
|
|
</if>
|
|
|
|
|
<if test="devType != null and devType != ''">
|
|
|
|
|
and dev_type = #{devType}
|
|
|
|
|
</if>
|
|
|
|
|
</select>
|
2024-09-20 10:51:00 +08:00
|
|
|
|
|
|
|
|
<select id="getDeviceModelDetailsPage" resultType="com.bonus.screen.vo.DeviceWarnRecordVo">
|
|
|
|
|
SELECT
|
2024-09-23 17:09:36 +08:00
|
|
|
td.dev_name as devName,
|
|
|
|
|
td.dev_code AS devCode,
|
|
|
|
|
td.dev_type AS devTypeName,
|
2024-09-20 10:51:00 +08:00
|
|
|
CASE WHEN td.dev_status = 0 THEN '离线'
|
|
|
|
|
WHEN td.dev_status = 1 THEN '在线'
|
2024-09-23 17:09:36 +08:00
|
|
|
ELSE '未知状态' END devStatusName,
|
|
|
|
|
tp.pro_name AS proName,
|
2024-09-20 10:51:00 +08:00
|
|
|
tbdr.dev_name AS bdDeviceName,
|
|
|
|
|
tbdr.dev_user AS devUserName
|
|
|
|
|
FROM tb_device td
|
|
|
|
|
LEFT JOIN tb_bd_device_record tbdr ON tbdr.id = td.bd_id
|
|
|
|
|
LEFT JOIN tb_project tp ON tbdr.pro_id = tp.id
|
|
|
|
|
WHERE td.del_flag = 0
|
2024-09-23 17:09:36 +08:00
|
|
|
<if test="devTypeCode != null">
|
|
|
|
|
and td.dev_type = #{devTypeCode}
|
2024-09-20 10:51:00 +08:00
|
|
|
</if>
|
|
|
|
|
</select>
|
2024-09-23 15:25:09 +08:00
|
|
|
</mapper>
|