2026-02-12 21:07:41 +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.xzzn.ems.mapper.EmsPointConfigMapper">
|
|
|
|
|
|
|
|
|
|
<resultMap type="EmsPointConfig" id="EmsPointConfigResult">
|
|
|
|
|
<result property="id" column="id"/>
|
2026-02-13 21:41:23 +08:00
|
|
|
<result property="pointId" column="point_id"/>
|
2026-02-12 21:07:41 +08:00
|
|
|
<result property="siteId" column="site_id"/>
|
|
|
|
|
<result property="deviceCategory" column="device_category"/>
|
|
|
|
|
<result property="deviceId" column="device_id"/>
|
|
|
|
|
<result property="pointName" column="point_name"/>
|
|
|
|
|
<result property="dataKey" column="data_key"/>
|
|
|
|
|
<result property="pointDesc" column="point_desc"/>
|
|
|
|
|
<result property="registerAddress" column="register_address"/>
|
|
|
|
|
<result property="dataUnit" column="data_unit"/>
|
|
|
|
|
<result property="dataA" column="data_a"/>
|
|
|
|
|
<result property="dataK" column="data_k"/>
|
|
|
|
|
<result property="dataB" column="data_b"/>
|
|
|
|
|
<result property="dataBit" column="data_bit"/>
|
|
|
|
|
<result property="isAlarm" column="is_alarm"/>
|
|
|
|
|
<result property="pointType" column="point_type"/>
|
|
|
|
|
<result property="calcExpression" column="calc_expression"/>
|
|
|
|
|
<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="remark" column="remark"/>
|
|
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
|
|
<sql id="selectEmsPointConfigVo">
|
2026-02-13 21:41:23 +08:00
|
|
|
select id, point_id, site_id, device_category, device_id, point_name, data_key, point_desc, register_address,
|
2026-02-12 21:07:41 +08:00
|
|
|
data_unit, data_a, data_k, data_b, data_bit, is_alarm, point_type, calc_expression,
|
|
|
|
|
create_by, create_time, update_by, update_time, remark
|
|
|
|
|
from ems_point_config
|
|
|
|
|
</sql>
|
|
|
|
|
|
|
|
|
|
<select id="selectEmsPointConfigById" parameterType="Long" resultMap="EmsPointConfigResult">
|
|
|
|
|
<include refid="selectEmsPointConfigVo"/>
|
|
|
|
|
where id = #{id}
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="selectEmsPointConfigList" parameterType="EmsPointConfig" resultMap="EmsPointConfigResult">
|
|
|
|
|
<include refid="selectEmsPointConfigVo"/>
|
|
|
|
|
<where>
|
|
|
|
|
<if test="siteId != null and siteId != ''">and site_id = #{siteId}</if>
|
2026-02-13 21:41:23 +08:00
|
|
|
<if test="pointId != null and pointId != ''">and point_id = #{pointId}</if>
|
2026-02-12 21:07:41 +08:00
|
|
|
<if test="deviceCategory != null and deviceCategory != ''">and device_category = #{deviceCategory}</if>
|
|
|
|
|
<if test="deviceId != null and deviceId != ''">and device_id = #{deviceId}</if>
|
|
|
|
|
<if test="dataKey != null and dataKey != ''">and data_key like concat('%', #{dataKey}, '%')</if>
|
|
|
|
|
<if test="pointDesc != null and pointDesc != ''">and point_desc like concat('%', #{pointDesc}, '%')</if>
|
|
|
|
|
<if test="pointType != null and pointType != ''">and point_type = #{pointType}</if>
|
|
|
|
|
<if test="registerAddress != null and registerAddress != ''">and register_address = #{registerAddress}</if>
|
|
|
|
|
</where>
|
|
|
|
|
order by update_time desc, id desc
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<insert id="insertEmsPointConfig" parameterType="EmsPointConfig" useGeneratedKeys="true" keyProperty="id">
|
|
|
|
|
insert into ems_point_config
|
|
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
2026-02-13 21:41:23 +08:00
|
|
|
<if test="pointId != null">point_id,</if>
|
2026-02-12 21:07:41 +08:00
|
|
|
<if test="siteId != null">site_id,</if>
|
|
|
|
|
<if test="deviceCategory != null">device_category,</if>
|
|
|
|
|
<if test="deviceId != null">device_id,</if>
|
|
|
|
|
<if test="pointName != null">point_name,</if>
|
|
|
|
|
<if test="dataKey != null">data_key,</if>
|
|
|
|
|
<if test="pointDesc != null">point_desc,</if>
|
|
|
|
|
<if test="registerAddress != null">register_address,</if>
|
|
|
|
|
<if test="dataUnit != null">data_unit,</if>
|
|
|
|
|
<if test="dataA != null">data_a,</if>
|
|
|
|
|
<if test="dataK != null">data_k,</if>
|
|
|
|
|
<if test="dataB != null">data_b,</if>
|
|
|
|
|
<if test="dataBit != null">data_bit,</if>
|
|
|
|
|
<if test="isAlarm != null">is_alarm,</if>
|
|
|
|
|
<if test="pointType != null">point_type,</if>
|
|
|
|
|
<if test="calcExpression != null">calc_expression,</if>
|
|
|
|
|
<if test="createBy != null">create_by,</if>
|
|
|
|
|
<if test="createTime != null">create_time,</if>
|
|
|
|
|
<if test="updateBy != null">update_by,</if>
|
|
|
|
|
<if test="updateTime != null">update_time,</if>
|
|
|
|
|
<if test="remark != null">remark,</if>
|
|
|
|
|
</trim>
|
|
|
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
2026-02-13 21:41:23 +08:00
|
|
|
<if test="pointId != null">#{pointId},</if>
|
2026-02-12 21:07:41 +08:00
|
|
|
<if test="siteId != null">#{siteId},</if>
|
|
|
|
|
<if test="deviceCategory != null">#{deviceCategory},</if>
|
|
|
|
|
<if test="deviceId != null">#{deviceId},</if>
|
|
|
|
|
<if test="pointName != null">#{pointName},</if>
|
|
|
|
|
<if test="dataKey != null">#{dataKey},</if>
|
|
|
|
|
<if test="pointDesc != null">#{pointDesc},</if>
|
|
|
|
|
<if test="registerAddress != null">#{registerAddress},</if>
|
|
|
|
|
<if test="dataUnit != null">#{dataUnit},</if>
|
|
|
|
|
<if test="dataA != null">#{dataA},</if>
|
|
|
|
|
<if test="dataK != null">#{dataK},</if>
|
|
|
|
|
<if test="dataB != null">#{dataB},</if>
|
|
|
|
|
<if test="dataBit != null">#{dataBit},</if>
|
|
|
|
|
<if test="isAlarm != null">#{isAlarm},</if>
|
|
|
|
|
<if test="pointType != null">#{pointType},</if>
|
|
|
|
|
<if test="calcExpression != null">#{calcExpression},</if>
|
|
|
|
|
<if test="createBy != null">#{createBy},</if>
|
|
|
|
|
<if test="createTime != null">#{createTime},</if>
|
|
|
|
|
<if test="updateBy != null">#{updateBy},</if>
|
|
|
|
|
<if test="updateTime != null">#{updateTime},</if>
|
|
|
|
|
<if test="remark != null">#{remark},</if>
|
|
|
|
|
</trim>
|
|
|
|
|
</insert>
|
|
|
|
|
|
2026-02-13 21:41:23 +08:00
|
|
|
<insert id="insertBatchEmsPointConfig">
|
|
|
|
|
insert into ems_point_config (
|
|
|
|
|
point_id, site_id, device_category, device_id, point_name, data_key, point_desc, register_address,
|
|
|
|
|
data_unit, data_a, data_k, data_b, data_bit, is_alarm, point_type, calc_expression,
|
|
|
|
|
create_by, create_time, update_by, update_time, remark
|
|
|
|
|
)
|
|
|
|
|
values
|
|
|
|
|
<foreach collection="list" item="item" separator=",">
|
|
|
|
|
(
|
|
|
|
|
#{item.pointId},
|
|
|
|
|
#{item.siteId},
|
|
|
|
|
#{item.deviceCategory},
|
|
|
|
|
#{item.deviceId},
|
|
|
|
|
#{item.pointName},
|
|
|
|
|
#{item.dataKey},
|
|
|
|
|
#{item.pointDesc},
|
|
|
|
|
#{item.registerAddress},
|
|
|
|
|
#{item.dataUnit},
|
|
|
|
|
#{item.dataA},
|
|
|
|
|
#{item.dataK},
|
|
|
|
|
#{item.dataB},
|
|
|
|
|
#{item.dataBit},
|
|
|
|
|
#{item.isAlarm},
|
|
|
|
|
#{item.pointType},
|
|
|
|
|
#{item.calcExpression},
|
|
|
|
|
#{item.createBy},
|
|
|
|
|
now(),
|
|
|
|
|
#{item.updateBy},
|
|
|
|
|
now(),
|
|
|
|
|
#{item.remark}
|
|
|
|
|
)
|
|
|
|
|
</foreach>
|
|
|
|
|
</insert>
|
|
|
|
|
|
2026-02-12 21:07:41 +08:00
|
|
|
<update id="updateEmsPointConfig" parameterType="EmsPointConfig">
|
|
|
|
|
update ems_point_config
|
|
|
|
|
<trim prefix="SET" suffixOverrides=",">
|
2026-02-13 21:41:23 +08:00
|
|
|
<if test="pointId != null">point_id = #{pointId},</if>
|
2026-02-12 21:07:41 +08:00
|
|
|
<if test="siteId != null">site_id = #{siteId},</if>
|
|
|
|
|
<if test="deviceCategory != null">device_category = #{deviceCategory},</if>
|
|
|
|
|
<if test="deviceId != null">device_id = #{deviceId},</if>
|
|
|
|
|
<if test="pointName != null">point_name = #{pointName},</if>
|
|
|
|
|
<if test="dataKey != null">data_key = #{dataKey},</if>
|
|
|
|
|
<if test="pointDesc != null">point_desc = #{pointDesc},</if>
|
|
|
|
|
<if test="registerAddress != null">register_address = #{registerAddress},</if>
|
|
|
|
|
<if test="dataUnit != null">data_unit = #{dataUnit},</if>
|
|
|
|
|
<if test="dataA != null">data_a = #{dataA},</if>
|
|
|
|
|
<if test="dataK != null">data_k = #{dataK},</if>
|
|
|
|
|
<if test="dataB != null">data_b = #{dataB},</if>
|
|
|
|
|
<if test="dataBit != null">data_bit = #{dataBit},</if>
|
|
|
|
|
<if test="isAlarm != null">is_alarm = #{isAlarm},</if>
|
|
|
|
|
<if test="pointType != null">point_type = #{pointType},</if>
|
|
|
|
|
<if test="calcExpression != null">calc_expression = #{calcExpression},</if>
|
|
|
|
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
|
|
|
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
|
|
|
|
<if test="remark != null">remark = #{remark},</if>
|
|
|
|
|
</trim>
|
|
|
|
|
where id = #{id}
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
<delete id="deleteEmsPointConfigById" parameterType="Long">
|
|
|
|
|
delete from ems_point_config where id = #{id}
|
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
|
|
<delete id="deleteEmsPointConfigByIds" parameterType="String">
|
|
|
|
|
delete from ems_point_config where id in
|
|
|
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
|
|
|
#{id}
|
|
|
|
|
</foreach>
|
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
|
|
<select id="countBySiteId" resultType="int">
|
|
|
|
|
select count(1)
|
|
|
|
|
from ems_point_config
|
|
|
|
|
where site_id = #{siteId}
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<delete id="deleteBySiteId">
|
|
|
|
|
delete from ems_point_config
|
|
|
|
|
where site_id = #{siteId}
|
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
|
|
<insert id="copyTemplateToSite">
|
|
|
|
|
insert into ems_point_config (
|
2026-02-13 21:41:23 +08:00
|
|
|
point_id, site_id, device_category, device_id, point_name, data_key, point_desc, register_address,
|
2026-02-12 21:07:41 +08:00
|
|
|
data_unit, data_a, data_k, data_b, data_bit, is_alarm, point_type, calc_expression,
|
|
|
|
|
create_by, create_time, update_by, update_time, remark
|
|
|
|
|
)
|
|
|
|
|
select
|
2026-02-13 21:41:23 +08:00
|
|
|
concat('PT_', replace(uuid(), '-', '')), #{targetSiteId}, device_category, device_id, point_name, data_key, point_desc, register_address,
|
2026-02-12 21:07:41 +08:00
|
|
|
data_unit, data_a, data_k, data_b, data_bit, is_alarm, point_type, calc_expression,
|
|
|
|
|
#{operName}, now(), #{operName}, now(), remark
|
|
|
|
|
from ems_point_config
|
|
|
|
|
where site_id = #{templateSiteId}
|
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
|
|
<select id="getRegisterAddress" resultType="java.lang.String">
|
|
|
|
|
select register_address
|
|
|
|
|
from ems_point_config
|
|
|
|
|
where site_id = #{siteId}
|
|
|
|
|
and device_category = #{deviceCategory}
|
|
|
|
|
and device_id = #{deviceId}
|
|
|
|
|
and data_key = #{dataKey}
|
|
|
|
|
limit 1
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="getPointNameList" resultType="com.xzzn.ems.domain.vo.GeneralQueryPointOptionVo">
|
|
|
|
|
select point_name as pointName,
|
|
|
|
|
data_key as dataKey,
|
|
|
|
|
point_desc as pointDesc
|
|
|
|
|
from ems_point_config
|
|
|
|
|
where 1 = 1
|
|
|
|
|
<if test="siteIds != null and siteIds.size() > 0">
|
|
|
|
|
and site_id in
|
|
|
|
|
<foreach collection="siteIds" item="siteId" open="(" separator="," close=")">
|
|
|
|
|
#{siteId}
|
|
|
|
|
</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
<if test="deviceCategory != null and deviceCategory != ''">
|
|
|
|
|
and device_category = #{deviceCategory}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="deviceId != null and deviceId != ''">
|
|
|
|
|
and device_id = #{deviceId}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="pointName != null and pointName != ''">
|
|
|
|
|
and (
|
|
|
|
|
point_name like concat('%', #{pointName}, '%')
|
|
|
|
|
or data_key like concat('%', #{pointName}, '%')
|
|
|
|
|
or point_desc like concat('%', #{pointName}, '%')
|
|
|
|
|
)
|
|
|
|
|
</if>
|
|
|
|
|
group by point_name, data_key, point_desc
|
|
|
|
|
order by point_name asc, data_key asc
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="getConfigListForGeneralQuery" resultMap="EmsPointConfigResult">
|
|
|
|
|
<include refid="selectEmsPointConfigVo"/>
|
|
|
|
|
where 1 = 1
|
|
|
|
|
<if test="siteIds != null and siteIds.size() > 0">
|
|
|
|
|
and site_id in
|
|
|
|
|
<foreach collection="siteIds" item="siteId" open="(" separator="," close=")">
|
|
|
|
|
#{siteId}
|
|
|
|
|
</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
<if test="deviceCategory != null and deviceCategory != ''">
|
|
|
|
|
and device_category = #{deviceCategory}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="pointNames != null and pointNames.size() > 0">
|
|
|
|
|
and point_name in
|
|
|
|
|
<foreach collection="pointNames" item="pointName" open="(" separator="," close=")">
|
|
|
|
|
#{pointName}
|
|
|
|
|
</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
<if test="deviceIds != null and deviceIds.size() > 0">
|
|
|
|
|
and device_id in
|
|
|
|
|
<foreach collection="deviceIds" item="deviceId" open="(" separator="," close=")">
|
|
|
|
|
#{deviceId}
|
|
|
|
|
</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
</select>
|
|
|
|
|
|
2026-02-13 21:41:23 +08:00
|
|
|
<select id="selectBySiteIdAndPointIds" resultMap="EmsPointConfigResult">
|
|
|
|
|
<include refid="selectEmsPointConfigVo"/>
|
|
|
|
|
where site_id = #{siteId}
|
|
|
|
|
and point_id in
|
|
|
|
|
<foreach collection="pointIds" item="pointId" open="(" separator="," close=")">
|
|
|
|
|
#{pointId}
|
|
|
|
|
</foreach>
|
|
|
|
|
</select>
|
|
|
|
|
|
2026-02-12 21:07:41 +08:00
|
|
|
</mapper>
|