ah_jjzhgd_service/securitycontrol-model/securitycontrol-background/src/main/resources/mapper/DeviceBdMapper.xml

110 lines
5.1 KiB
XML
Raw Normal View History

2024-03-20 13:53:57 +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.securitycontrol.background.mapper.IDeviceOfBdMapper">
2024-03-20 17:54:12 +08:00
<!--新增/修改边带设备-->
<insert id="addOrUpdateDeviceBd">
<if test="type == 1">
INSERT INTO tb_pro_bd
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null and id != ''">id,</if>
<if test="bdName != null and bdName!=''">bd_name,</if>
<if test="bdCode != null and bdCode!=''">bd_code,</if>
<if test="bdIp != null and bdIp!=''">bd_ip,</if>
<if test="bdType != null and bdType!=''">bd_type,</if>
<if test="typeCode != null and typeCode!=''">type_code,</if>
<if test="gtId != null and gtId!=''">gt_id,</if>
<if test="bidCode != null and bidCode!=''">bid_code,</if>
del_flag,
<if test="updateTime != null and updateTime!=''">update_time,</if>
<if test="createTime != null and createTime!=''">create_time,</if>
<if test="bindTime != null and bindTime!=''">bind_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null and id != ''">#{id},</if>
<if test="bdName != null and bdName!=''">#{bdName},</if>
<if test="bdCode != null and bdCode!=''">#{bdCode},</if>
<if test="bdIp != null and bdIp!=''">#{bdIp},</if>
<if test="bdType != null and bdType != ''">#{bdType},</if>
<if test="typeCode != null and typeCode!=''">#{typeCode},</if>
<if test="gtId != null and gtId!=''">#{gtId},</if>
<if test="bidCode != null and bidCode!=''">#{bidCode},</if>
0,
<if test="updateTime != null and updateTime!=''">#{updateTime},</if>
<if test="createTime != null and createTime!=''">#{createTime},</if>
<if test="bindTime != null and bindTime!=''">#{bindTime},</if>
</trim>
</if>
<if test="type == 2">
UPDATE tb_pro_bd
<set>
<if test="bdName != null and bdName != ''">bd_name = #{bdName},</if>
<if test="bdCode != null and bdCode != ''">bd_code = #{bdCode},</if>
<if test="bdIp != null and bdIp != ''">bd_ip = #{bdIp},</if>
<if test="bdType != null and bdType != ''">bd_type = #{bdType},</if>
<if test="typeCode != null and typeCode != ''">type_code = #{typeCode},</if>
<if test="gtId != null and gtId != ''">gt_id = #{gtId},</if>
<if test="bidCode != null and bidCode != ''">bid_code = #{bidCode},</if>
</set>
WHERE id = #{id}
</if>
</insert>
<!--删除边带设备-->
<delete id="delDeviceBdById">
DELETE FROM tb_pro_bd WHERE id = #{id}
</delete>
2024-03-20 13:53:57 +08:00
2024-03-20 17:54:12 +08:00
<!--获取边带设备列表-->
<select id="getDeviceBdList" resultType="com.securitycontrol.entity.background.vo.DeviceBdVo">
SELECT tpb.id,
tpb.bd_name AS bdName,
tpb.bd_code AS bdCode,
tpb.bd_ip AS bdIp,
sd.dict_name AS bdTypeName,
sd2.dict_name AS typeCodeName,
tp.pro_name AS proName,
tpg.gt_name AS gtName,
tpb.bind_time AS bindTime,
tpb.bid_code AS bidCode
FROM tb_pro_bd tpb
LEFT JOIN sys_dict sd ON sd.dict_code = tpb.bd_type
LEFT JOIN sys_dict sd2 ON sd2.dict_code = tpb.type_code
LEFT JOIN tb_project tp ON tp.bid_code = tpb.bid_code
LEFT JOIN t_pro_gt tpg ON tpg.gt_id = tpb.gt_id
<where>
<if test="keyWord!=null and keyWord!=''">
AND (
INSTR(tpb.bd_name,#{keyWord}) > 0 OR
INSTR(tpb.bd_code,#{keyWord}) > 0 OR
INSTR(tp.pro_name,#{keyWord}) > 0 OR
INSTR(tpg.gt_name,#{keyWord}) > 0
)
</if>
</where>
</select>
<!--边带编码是否重复-->
<select id="isBdCodeExist" resultType="java.lang.Integer">
<if test="id == null or id == ''">
SELECT COUNT(*) FROM tb_pro_bd tpb WHERE bd_code = #{bdCode}
</if>
<if test="id != null and id != ''">
SELECT COUNT(*) FROM tb_pro_bd tpb WHERE bd_code = #{bdCode} AND id != #{id}
</if>
</select>
<!--边带设备详情-->
<select id="getDeviceBdById" resultType="com.securitycontrol.entity.background.vo.DeviceBdVo">
SELECT tpb.id,
tpb.bd_name AS bdName,
tpb.bd_code AS bdCode,
tpb.bd_ip AS bdIp,
tpb.bid_code AS bidCode,
tpb.type_code AS typeCode,
tpb.bd_type AS bdType,
tpb.gt_id AS gtId
FROM tb_pro_bd tpb
WHERE id = #{id}
</select>
<!--边带设备是否包含子设备-->
<select id="isHasChildDeviceBd" resultType="java.lang.Integer">
SELECT COUNT(*) FROM tb_bd_device WHERE bd_id = #{id}
</select>
2024-03-20 13:53:57 +08:00
</mapper>