2025-09-05 13:45:39 +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.EmsPointMatchMapper">
|
|
|
|
|
|
|
|
|
|
<resultMap type="EmsPointMatch" id="EmsPointMatchResult">
|
|
|
|
|
<result property="id" column="id" />
|
|
|
|
|
<result property="pointName" column="point_name" />
|
|
|
|
|
<result property="matchTable" column="match_table" />
|
|
|
|
|
<result property="matchField" column="match_field" />
|
|
|
|
|
<result property="siteId" column="site_id" />
|
|
|
|
|
<result property="deviceCategory" column="device_category" />
|
2025-09-13 21:49:33 +08:00
|
|
|
<result property="dataPoint" column="data_point" />
|
|
|
|
|
<result property="dataPointName" column="data_point_name" />
|
|
|
|
|
<result property="dataDevice" column="data_device" />
|
2025-10-14 16:50:53 +08:00
|
|
|
<result property="dataUnit" column="data_unit" />
|
2025-11-05 14:58:05 +08:00
|
|
|
<result property="ipAddress" column="ip_address" />
|
|
|
|
|
<result property="ipPort" column="ip_port" />
|
2025-10-14 16:50:53 +08:00
|
|
|
<result property="dataType" column="data_type" />
|
|
|
|
|
<result property="needDiffDeviceId" column="need_diff_device_id" />
|
2025-09-05 13:45:39 +08:00
|
|
|
<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" />
|
2025-11-28 11:58:45 +08:00
|
|
|
<result property="deviceId" column="device_id" />
|
2025-09-05 13:45:39 +08:00
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
|
|
<sql id="selectEmsPointMatchVo">
|
2025-11-28 11:58:45 +08:00
|
|
|
select id, point_name, match_table, match_field, site_id, device_category, data_point, data_point_name, data_device, data_unit, ip_address, ip_port, data_type, need_diff_device_id, create_by, create_time, update_by, update_time, remark, device_id from ems_point_match
|
2025-09-05 13:45:39 +08:00
|
|
|
</sql>
|
|
|
|
|
|
|
|
|
|
<select id="selectEmsPointMatchList" parameterType="EmsPointMatch" resultMap="EmsPointMatchResult">
|
|
|
|
|
<include refid="selectEmsPointMatchVo"/>
|
|
|
|
|
<where>
|
|
|
|
|
<if test="pointName != null and pointName != ''"> and point_name like concat('%', #{pointName}, '%')</if>
|
|
|
|
|
<if test="matchTable != null and matchTable != ''"> and match_table = #{matchTable}</if>
|
|
|
|
|
<if test="matchField != null and matchField != ''"> and match_field = #{matchField}</if>
|
|
|
|
|
<if test="siteId != null and siteId != ''"> and site_id = #{siteId}</if>
|
|
|
|
|
<if test="deviceCategory != null and deviceCategory != ''"> and device_category = #{deviceCategory}</if>
|
2025-09-13 21:49:33 +08:00
|
|
|
<if test="dataPoint != null and dataPoint != ''"> and data_point = #{dataPoint}</if>
|
|
|
|
|
<if test="dataPointName != null and dataPointName != ''"> and data_point_name like concat('%', #{dataPointName}, '%')</if>
|
|
|
|
|
<if test="dataDevice != null and dataDevice != ''"> and data_device = #{dataDevice}</if>
|
2025-10-14 16:50:53 +08:00
|
|
|
<if test="dataUnit != null and dataUnit != ''"> and data_unit = #{dataUnit}</if>
|
2025-11-05 14:58:05 +08:00
|
|
|
<if test="ipAddress != null and ipAddress != ''"> and ip_address = #{ipAddress}</if>
|
|
|
|
|
<if test="ipPort != null "> and ip_port = #{ipPort}</if>
|
2025-10-14 16:50:53 +08:00
|
|
|
<if test="dataType != null "> and data_type = #{dataType}</if>
|
|
|
|
|
<if test="needDiffDeviceId != null "> and need_diff_device_id = #{needDiffDeviceId}</if>
|
2025-09-05 13:45:39 +08:00
|
|
|
</where>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="selectEmsPointMatchById" parameterType="Long" resultMap="EmsPointMatchResult">
|
|
|
|
|
<include refid="selectEmsPointMatchVo"/>
|
|
|
|
|
where id = #{id}
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<insert id="insertEmsPointMatch" parameterType="EmsPointMatch" useGeneratedKeys="true" keyProperty="id">
|
|
|
|
|
insert into ems_point_match
|
|
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
|
|
<if test="pointName != null">point_name,</if>
|
|
|
|
|
<if test="matchTable != null">match_table,</if>
|
|
|
|
|
<if test="matchField != null">match_field,</if>
|
|
|
|
|
<if test="siteId != null">site_id,</if>
|
|
|
|
|
<if test="deviceCategory != null">device_category,</if>
|
2025-09-13 21:49:33 +08:00
|
|
|
<if test="dataPoint != null">data_point,</if>
|
|
|
|
|
<if test="dataPointName != null">data_point_name,</if>
|
|
|
|
|
<if test="dataDevice != null">data_device,</if>
|
2025-10-14 16:50:53 +08:00
|
|
|
<if test="dataUnit != null">data_unit,</if>
|
2025-11-05 14:58:05 +08:00
|
|
|
<if test="ipAddress != null">ip_address,</if>
|
|
|
|
|
<if test="ipPort != null">ip_port,</if>
|
2025-10-14 16:50:53 +08:00
|
|
|
<if test="dataType != null">data_type,</if>
|
|
|
|
|
<if test="needDiffDeviceId != null">need_diff_device_id,</if>
|
2025-09-05 13:45:39 +08:00
|
|
|
<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>
|
2025-11-28 11:58:45 +08:00
|
|
|
<if test="deviceId != null">device_id,</if>
|
2025-09-05 13:45:39 +08:00
|
|
|
</trim>
|
|
|
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
|
|
<if test="pointName != null">#{pointName},</if>
|
|
|
|
|
<if test="matchTable != null">#{matchTable},</if>
|
|
|
|
|
<if test="matchField != null">#{matchField},</if>
|
|
|
|
|
<if test="siteId != null">#{siteId},</if>
|
|
|
|
|
<if test="deviceCategory != null">#{deviceCategory},</if>
|
2025-09-13 21:49:33 +08:00
|
|
|
<if test="dataPoint != null">#{dataPoint},</if>
|
|
|
|
|
<if test="dataPointName != null">#{dataPointName},</if>
|
|
|
|
|
<if test="dataDevice != null">#{dataDevice},</if>
|
2025-10-14 16:50:53 +08:00
|
|
|
<if test="dataUnit != null">#{dataUnit},</if>
|
2025-11-05 14:58:05 +08:00
|
|
|
<if test="ipAddress != null">#{ipAddress},</if>
|
|
|
|
|
<if test="ipPort != null">#{ipPort},</if>
|
2025-10-14 16:50:53 +08:00
|
|
|
<if test="dataType != null">#{dataType},</if>
|
|
|
|
|
<if test="needDiffDeviceId != null">#{needDiffDeviceId},</if>
|
2025-09-05 13:45:39 +08:00
|
|
|
<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>
|
2025-11-28 11:58:45 +08:00
|
|
|
<if test="deviceId != null">#{deviceId},</if>
|
2025-09-05 13:45:39 +08:00
|
|
|
</trim>
|
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
|
|
<update id="updateEmsPointMatch" parameterType="EmsPointMatch">
|
|
|
|
|
update ems_point_match
|
|
|
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
|
|
|
<if test="pointName != null">point_name = #{pointName},</if>
|
|
|
|
|
<if test="matchTable != null">match_table = #{matchTable},</if>
|
|
|
|
|
<if test="matchField != null">match_field = #{matchField},</if>
|
|
|
|
|
<if test="siteId != null">site_id = #{siteId},</if>
|
|
|
|
|
<if test="deviceCategory != null">device_category = #{deviceCategory},</if>
|
2025-09-13 21:49:33 +08:00
|
|
|
<if test="dataPoint != null">data_point = #{dataPoint},</if>
|
|
|
|
|
<if test="dataPointName != null">data_point_name = #{dataPointName},</if>
|
|
|
|
|
<if test="dataDevice != null">data_device = #{dataDevice},</if>
|
2025-10-14 16:50:53 +08:00
|
|
|
<if test="dataUnit != null">data_unit = #{dataUnit},</if>
|
2025-11-05 14:58:05 +08:00
|
|
|
<if test="ipAddress != null">ip_address = #{ipAddress},</if>
|
|
|
|
|
<if test="ipPort != null">ip_port = #{ipPort},</if>
|
2025-10-14 16:50:53 +08:00
|
|
|
<if test="dataType != null">data_type = #{dataType},</if>
|
|
|
|
|
<if test="needDiffDeviceId != null">need_diff_device_id = #{needDiffDeviceId},</if>
|
2025-09-05 13:45:39 +08:00
|
|
|
<if test="createBy != null">create_by = #{createBy},</if>
|
|
|
|
|
<if test="createTime != null">create_time = #{createTime},</if>
|
|
|
|
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
|
|
|
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
|
|
|
|
<if test="remark != null">remark = #{remark},</if>
|
2025-11-28 11:58:45 +08:00
|
|
|
<if test="deviceId != null">device_id = #{deviceId},</if>
|
2025-09-05 13:45:39 +08:00
|
|
|
</trim>
|
|
|
|
|
where id = #{id}
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
<delete id="deleteEmsPointMatchById" parameterType="Long">
|
|
|
|
|
delete from ems_point_match where id = #{id}
|
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
|
|
<delete id="deleteEmsPointMatchByIds" parameterType="String">
|
|
|
|
|
delete from ems_point_match where id in
|
|
|
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
|
|
|
#{id}
|
|
|
|
|
</foreach>
|
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
|
|
<select id="getPointNameList" resultType="String">
|
|
|
|
|
select distinct t.point_name
|
|
|
|
|
from ems_point_match t
|
|
|
|
|
where 1=1
|
|
|
|
|
<if test="siteIds != null and siteIds.size() > 0">
|
|
|
|
|
AND t.site_id IN
|
|
|
|
|
<foreach collection="siteIds" item="siteId" open="(" separator="," close=")">
|
|
|
|
|
#{siteId}
|
|
|
|
|
</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
<if test="deviceCategory != null and deviceCategory != ''">
|
|
|
|
|
and t.device_category = #{deviceCategory}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="pointName != null and pointName != ''">
|
|
|
|
|
and t.point_name like CONCAT('%', #{pointName}, '%')
|
|
|
|
|
</if>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="getMatchInfo" resultType="com.xzzn.ems.domain.EmsPointMatch">
|
|
|
|
|
select distinct t.site_id as siteId,
|
|
|
|
|
t.match_table as matchTable,
|
|
|
|
|
t.match_field as matchField,
|
|
|
|
|
t.device_category as deviceCategory,
|
2025-10-16 17:01:35 +08:00
|
|
|
t.point_name as pointName,
|
|
|
|
|
t.data_type as dataType
|
2025-09-05 13:45:39 +08:00
|
|
|
from ems_point_match t
|
|
|
|
|
where 1=1
|
|
|
|
|
<if test="siteIds != null and siteIds.size() > 0">
|
|
|
|
|
AND t.site_id IN
|
|
|
|
|
<foreach collection="siteIds" item="siteId" open="(" separator="," close=")">
|
|
|
|
|
#{siteId}
|
|
|
|
|
</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
<if test="deviceCategory != null and deviceCategory != ''">
|
|
|
|
|
and t.device_category = #{deviceCategory}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="pointName != null and pointName != ''">
|
|
|
|
|
and t.point_name = #{pointName}
|
|
|
|
|
</if>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<sql id="commonFilter">
|
2025-10-14 17:07:00 +08:00
|
|
|
<if test="clusterDeviceId != null and clusterDeviceId != ''">
|
|
|
|
|
and cluster_device_id = #{clusterDeviceId}
|
|
|
|
|
</if>
|
2025-09-05 13:45:39 +08:00
|
|
|
<choose>
|
|
|
|
|
<when test="params != null and !params.isEmpty()">
|
|
|
|
|
AND ( <trim prefixOverrides="OR">
|
|
|
|
|
<foreach collection="params.entrySet()" item="devices" index="siteId" separator="OR">
|
|
|
|
|
( site_id = #{siteId}
|
|
|
|
|
AND device_id IN
|
|
|
|
|
<foreach collection="devices" item="deviceId" open="(" close=")" separator=",">
|
|
|
|
|
#{deviceId}
|
|
|
|
|
</foreach>
|
|
|
|
|
)
|
|
|
|
|
</foreach>
|
|
|
|
|
</trim>
|
|
|
|
|
)
|
|
|
|
|
</when>
|
|
|
|
|
<otherwise>
|
|
|
|
|
AND site_id IN
|
|
|
|
|
<foreach collection="siteIds" item="siteId" open="(" close=")" separator=",">
|
|
|
|
|
#{siteId}
|
|
|
|
|
</foreach>
|
|
|
|
|
</otherwise>
|
|
|
|
|
</choose>
|
|
|
|
|
</sql>
|
|
|
|
|
|
2025-09-05 20:31:30 +08:00
|
|
|
<select id="getBatteryPointDataByMinutes" resultType="com.xzzn.ems.domain.vo.GeneralQueryDataVo">
|
2025-09-05 13:45:39 +08:00
|
|
|
SELECT DATE_FORMAT(create_time, '%Y-%m-%d %H:%i:00') AS valueDate,
|
|
|
|
|
site_id as siteId,
|
|
|
|
|
device_id as deviceId,
|
2025-09-05 20:31:30 +08:00
|
|
|
cluster_device_id as parentDeviceId,
|
2025-09-05 13:45:39 +08:00
|
|
|
${tableField} as pointValue
|
|
|
|
|
FROM ${tableName}
|
|
|
|
|
WHERE create_time >= #{startDate}
|
|
|
|
|
AND create_time <= #{endDate}
|
|
|
|
|
AND ${tableField} is not null
|
|
|
|
|
<include refid="commonFilter"/>
|
2025-09-05 20:31:30 +08:00
|
|
|
GROUP BY valueDate, site_id, device_id,cluster_device_id,pointValue
|
|
|
|
|
ORDER BY site_id,device_id,cluster_device_id, valueDate ASC
|
2025-09-05 13:45:39 +08:00
|
|
|
</select>
|
|
|
|
|
|
2025-09-05 20:31:30 +08:00
|
|
|
<select id="getBatteryPointDataByHours" resultType="com.xzzn.ems.domain.vo.GeneralQueryDataVo">
|
2025-09-05 13:45:39 +08:00
|
|
|
SELECT DATE_FORMAT(t.create_time, '%Y-%m-%d %H:00') AS valueDate,
|
|
|
|
|
t.site_id as siteId,
|
|
|
|
|
t.device_id as deviceId,
|
|
|
|
|
t.${tableField} as pointValue,
|
2025-09-05 20:31:30 +08:00
|
|
|
t.cluster_device_id as parentDeviceId,
|
2025-09-05 13:45:39 +08:00
|
|
|
t.create_time AS last_update_time
|
|
|
|
|
FROM ${tableName} t
|
2025-09-05 20:31:30 +08:00
|
|
|
INNER JOIN ( SELECT site_id, device_id, cluster_device_id,
|
|
|
|
|
DATE_FORMAT(create_time, '%Y-%m-%d %H:00') AS hour_group,
|
2025-09-05 13:45:39 +08:00
|
|
|
MAX(create_time) AS max_time
|
|
|
|
|
FROM ${tableName}
|
|
|
|
|
WHERE create_time >= #{startDate}
|
2025-09-05 20:31:30 +08:00
|
|
|
AND create_time <= #{endDate}
|
|
|
|
|
AND ${tableField} is not null
|
2025-09-05 13:45:39 +08:00
|
|
|
<include refid="commonFilter"/>
|
2025-09-05 20:31:30 +08:00
|
|
|
GROUP BY site_id, device_id,cluster_device_id, hour_group
|
2025-09-05 13:45:39 +08:00
|
|
|
) tmp ON t.site_id = tmp.site_id
|
|
|
|
|
AND t.device_id = tmp.device_id
|
2025-09-05 20:31:30 +08:00
|
|
|
AND t.cluster_device_id = tmp.cluster_device_id
|
2025-09-05 13:45:39 +08:00
|
|
|
AND DATE_FORMAT(t.create_time, '%Y-%m-%d %H:00') = tmp.hour_group
|
|
|
|
|
AND t.create_time = tmp.max_time
|
|
|
|
|
where ${tableField} is not null
|
2025-09-05 20:31:30 +08:00
|
|
|
ORDER BY t.site_id, t.device_id, t.cluster_device_id, valueDate ASC
|
2025-09-05 13:45:39 +08:00
|
|
|
</select>
|
|
|
|
|
|
2025-09-05 20:31:30 +08:00
|
|
|
<select id="getBatteryPointDataByDays" resultType="com.xzzn.ems.domain.vo.GeneralQueryDataVo">
|
2025-09-05 13:45:39 +08:00
|
|
|
SELECT DATE_FORMAT(t.create_time, '%Y-%m-%d') AS valueDate,
|
|
|
|
|
t.site_id as siteId,
|
|
|
|
|
t.device_id as deviceId,
|
2025-09-05 20:31:30 +08:00
|
|
|
t.cluster_device_id as parentDeviceId,
|
2025-09-05 13:45:39 +08:00
|
|
|
t.${tableField} as pointValue,
|
|
|
|
|
t.create_time AS last_update_time
|
|
|
|
|
FROM ${tableName} t
|
2025-09-05 20:31:30 +08:00
|
|
|
INNER JOIN ( SELECT site_id, device_id, cluster_device_id,
|
|
|
|
|
DATE_FORMAT(create_time, '%Y-%m-%d') AS day_group,
|
|
|
|
|
MAX(create_time) AS max_time
|
|
|
|
|
FROM ${tableName}
|
|
|
|
|
WHERE create_time >= #{startDate}
|
|
|
|
|
AND create_time <= #{endDate}
|
|
|
|
|
AND ${tableField} is not null
|
|
|
|
|
<include refid="commonFilter"/>
|
|
|
|
|
GROUP BY site_id, device_id, cluster_device_id, day_group
|
|
|
|
|
) tmp ON t.site_id = tmp.site_id
|
|
|
|
|
AND t.device_id = tmp.device_id
|
|
|
|
|
AND t.cluster_device_id = tmp.cluster_device_id
|
|
|
|
|
AND DATE_FORMAT(t.create_time, '%Y-%m-%d') = tmp.day_group
|
|
|
|
|
AND t.create_time = tmp.max_time
|
|
|
|
|
WHERE t.${tableField} is not null
|
|
|
|
|
ORDER BY t.site_id, t.device_id, t.cluster_device_id, valueDate ASC
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="getCommonPointDataByMinutes" resultType="com.xzzn.ems.domain.vo.GeneralQueryDataVo">
|
|
|
|
|
SELECT DATE_FORMAT(create_time, '%Y-%m-%d %H:%i:00') AS valueDate,
|
|
|
|
|
site_id as siteId,
|
|
|
|
|
device_id as deviceId,
|
|
|
|
|
${tableField} as pointValue
|
|
|
|
|
FROM ${tableName}
|
|
|
|
|
WHERE create_time >= #{startDate}
|
|
|
|
|
AND create_time <= #{endDate}
|
|
|
|
|
AND ${tableField} is not null
|
|
|
|
|
AND site_id IN
|
|
|
|
|
<foreach collection="siteIds" item="siteId" open="(" close=")" separator=",">
|
|
|
|
|
#{siteId}
|
|
|
|
|
</foreach>
|
2025-09-13 19:25:58 +08:00
|
|
|
<if test="deviceId != null and deviceId != ''">
|
|
|
|
|
and device_id = #{deviceId}
|
|
|
|
|
</if>
|
2025-09-05 20:31:30 +08:00
|
|
|
GROUP BY valueDate, site_id, device_id,pointValue
|
|
|
|
|
ORDER BY site_id,device_id, valueDate ASC
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="getCommonPointDataByHours" resultType="com.xzzn.ems.domain.vo.GeneralQueryDataVo">
|
|
|
|
|
SELECT DATE_FORMAT(t.create_time, '%Y-%m-%d %H:00') AS valueDate,
|
|
|
|
|
t.site_id as siteId,
|
|
|
|
|
t.device_id as deviceId,
|
|
|
|
|
t.${tableField} as pointValue,
|
|
|
|
|
t.create_time AS last_update_time
|
|
|
|
|
FROM ${tableName} t
|
|
|
|
|
INNER JOIN ( SELECT site_id, device_id, DATE_FORMAT(create_time, '%Y-%m-%d %H:00') AS hour_group,
|
|
|
|
|
MAX(create_time) AS max_time
|
|
|
|
|
FROM ${tableName}
|
2025-09-05 13:45:39 +08:00
|
|
|
WHERE create_time >= #{startDate}
|
|
|
|
|
AND create_time <= #{endDate}
|
|
|
|
|
AND ${tableField} is not null
|
2025-09-05 20:31:30 +08:00
|
|
|
AND site_id IN
|
|
|
|
|
<foreach collection="siteIds" item="siteId" open="(" close=")" separator=",">
|
|
|
|
|
#{siteId}
|
|
|
|
|
</foreach>
|
2025-09-13 19:25:58 +08:00
|
|
|
<if test="deviceId != null and deviceId != ''">
|
|
|
|
|
and device_id = #{deviceId}
|
|
|
|
|
</if>
|
2025-09-05 20:31:30 +08:00
|
|
|
GROUP BY site_id, device_id, hour_group
|
|
|
|
|
) tmp ON t.site_id = tmp.site_id
|
|
|
|
|
AND t.device_id = tmp.device_id
|
|
|
|
|
AND DATE_FORMAT(t.create_time, '%Y-%m-%d %H:00') = tmp.hour_group
|
|
|
|
|
AND t.create_time = tmp.max_time
|
|
|
|
|
where ${tableField} is not null
|
|
|
|
|
ORDER BY t.site_id, t.device_id, valueDate ASC
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="getCommonPointDataByDays" resultType="com.xzzn.ems.domain.vo.GeneralQueryDataVo">
|
|
|
|
|
SELECT DATE_FORMAT(t.create_time, '%Y-%m-%d') AS valueDate,
|
|
|
|
|
t.site_id as siteId,
|
|
|
|
|
t.device_id as deviceId,
|
|
|
|
|
t.${tableField} as pointValue,
|
|
|
|
|
t.create_time AS last_update_time
|
|
|
|
|
FROM ${tableName} t
|
|
|
|
|
INNER JOIN ( SELECT site_id, device_id, DATE_FORMAT(create_time, '%Y-%m-%d') AS day_group,
|
|
|
|
|
MAX(create_time) AS max_time
|
|
|
|
|
FROM ${tableName}
|
|
|
|
|
WHERE create_time >= #{startDate}
|
|
|
|
|
AND create_time <= #{endDate}
|
|
|
|
|
AND ${tableField} is not null
|
|
|
|
|
AND site_id IN
|
|
|
|
|
<foreach collection="siteIds" item="siteId" open="(" close=")" separator=",">
|
|
|
|
|
#{siteId}
|
|
|
|
|
</foreach>
|
2025-09-13 19:25:58 +08:00
|
|
|
<if test="deviceId != null and deviceId != ''">
|
|
|
|
|
and device_id = #{deviceId}
|
|
|
|
|
</if>
|
2025-09-05 13:45:39 +08:00
|
|
|
GROUP BY site_id, device_id, day_group
|
|
|
|
|
) tmp ON t.site_id = tmp.site_id
|
|
|
|
|
AND t.device_id = tmp.device_id
|
|
|
|
|
AND DATE_FORMAT(t.create_time, '%Y-%m-%d') = tmp.day_group
|
|
|
|
|
AND t.create_time = tmp.max_time
|
|
|
|
|
WHERE t.${tableField} is not null
|
|
|
|
|
ORDER BY t.site_id, t.device_id, valueDate ASC
|
|
|
|
|
</select>
|
2025-09-13 21:49:33 +08:00
|
|
|
|
2025-09-18 05:17:57 +08:00
|
|
|
<select id="getSingleSiteDevicePoints" resultType="com.xzzn.ems.domain.vo.PointQueryResponse">
|
|
|
|
|
select t.point_name as pointName,
|
|
|
|
|
t.data_point as dataPoint,
|
|
|
|
|
t.data_point_name as dataPointName,
|
|
|
|
|
t.data_device as dataDevice,
|
2025-10-14 16:50:53 +08:00
|
|
|
t.need_diff_device_id as isNeedDeviceId,
|
2025-11-05 14:58:05 +08:00
|
|
|
t.data_unit as dataUnit,
|
|
|
|
|
t.ip_address as ipAddress,
|
|
|
|
|
t.ip_port as ipPort
|
2025-09-18 05:17:57 +08:00
|
|
|
from ems_point_match t
|
2025-09-13 21:49:33 +08:00
|
|
|
where 1=1
|
|
|
|
|
<if test="siteId != null and siteId != ''">
|
2025-09-18 18:04:59 +08:00
|
|
|
and t.site_id = #{siteId}
|
2025-09-13 21:49:33 +08:00
|
|
|
</if>
|
|
|
|
|
<if test="deviceCategory != null and deviceCategory != ''">
|
2025-09-18 18:04:59 +08:00
|
|
|
and t.device_category = #{deviceCategory}
|
|
|
|
|
</if>
|
2025-09-28 14:44:02 +08:00
|
|
|
<if test="pointName != null and pointName != ''">
|
|
|
|
|
and t.point_name like CONCAT('%', #{pointName}, '%')
|
2025-09-13 21:49:33 +08:00
|
|
|
</if>
|
2025-09-23 14:01:24 +08:00
|
|
|
<if test="dataPoint != null and dataPoint != ''">
|
|
|
|
|
and t.data_point like CONCAT('%', #{dataPoint}, '%')
|
|
|
|
|
</if>
|
2025-11-05 14:58:05 +08:00
|
|
|
<if test="ipAddress != null and ipAddress != ''">
|
|
|
|
|
and t.ip_address = #{ipAddress}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="ipPort != null">
|
|
|
|
|
and t.ip_port = #{ipPort}
|
|
|
|
|
</if>
|
2025-09-13 21:49:33 +08:00
|
|
|
</select>
|
2025-09-26 16:37:46 +08:00
|
|
|
|
|
|
|
|
<select id="getClusterDevicePoints" resultType="com.xzzn.ems.domain.vo.PointQueryResponse">
|
|
|
|
|
SELECT tmp.pointName,
|
|
|
|
|
tmp.dataPoint,
|
|
|
|
|
tmp.dataDevice,
|
2025-10-14 16:50:53 +08:00
|
|
|
tmp.dataPointName,
|
2025-11-05 14:58:05 +08:00
|
|
|
tmp.dataUnit,
|
|
|
|
|
tmp.ipAddress,
|
|
|
|
|
tmp.ipPort
|
2025-09-26 16:37:46 +08:00
|
|
|
FROM ( select t.point_name as pointName,
|
|
|
|
|
case
|
|
|
|
|
when t.need_diff_device_id = 1 and t.data_device = 'PCS' then concat(#{deviceId}, t.data_point)
|
|
|
|
|
when t.need_diff_device_id = 1 and t.data_device = 'BMSD' then concat(#{parentDeviceId}, t.data_point)
|
|
|
|
|
else t.data_point end as dataPoint,
|
|
|
|
|
t.data_point_name as dataPointName,
|
2025-10-14 16:50:53 +08:00
|
|
|
t.data_device as dataDevice,
|
2025-11-05 14:58:05 +08:00
|
|
|
t.data_unit as dataUnit,
|
|
|
|
|
t.ip_address as ipAddress,
|
|
|
|
|
t.ip_port as ipPort
|
2025-09-26 16:37:46 +08:00
|
|
|
from ems_point_match t
|
|
|
|
|
where 1=1
|
|
|
|
|
<if test="siteId != null and siteId != ''">
|
|
|
|
|
and t.site_id = #{siteId}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="deviceCategory != null and deviceCategory != ''">
|
|
|
|
|
and t.device_category = #{deviceCategory}
|
|
|
|
|
</if>
|
|
|
|
|
) as tmp
|
|
|
|
|
where 1=1
|
2025-09-28 14:44:02 +08:00
|
|
|
<if test="pointName != null and pointName != ''">
|
2025-11-05 14:58:05 +08:00
|
|
|
and tmp.dataPointName like CONCAT('%', #{pointName}, '%')
|
2025-09-26 16:37:46 +08:00
|
|
|
</if>
|
|
|
|
|
<if test="dataPoint != null and dataPoint != ''">
|
|
|
|
|
and tmp.dataPoint like CONCAT('%', #{dataPoint}, '%')
|
|
|
|
|
</if>
|
2025-11-05 14:58:05 +08:00
|
|
|
<if test="ipAddress != null and ipAddress != ''">
|
|
|
|
|
and tmp.ipAddress = #{ipAddress}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="ipPort != null">
|
|
|
|
|
and tmp.ipPort = #{ipPort}
|
|
|
|
|
</if>
|
2025-09-26 16:37:46 +08:00
|
|
|
</select>
|
2025-11-06 15:32:33 +08:00
|
|
|
|
|
|
|
|
<select id="getUniquePoint" resultMap="EmsPointMatchResult">
|
|
|
|
|
<include refid="selectEmsPointMatchVo"/>
|
|
|
|
|
where site_id = #{siteId}
|
|
|
|
|
and device_category = #{deviceCategory}
|
|
|
|
|
and data_point = #{dataPoint}
|
|
|
|
|
</select>
|
2025-11-28 11:58:45 +08:00
|
|
|
<select id="getOnePointMatch" resultMap="EmsPointMatchResult">
|
|
|
|
|
<include refid="selectEmsPointMatchVo"/>
|
|
|
|
|
where site_id = #{siteId}
|
|
|
|
|
and device_category = #{deviceCategory}
|
|
|
|
|
and device_id = #{deviceId}
|
|
|
|
|
and data_point = #{dataPoint}
|
|
|
|
|
order by update_time desc
|
|
|
|
|
limit 1
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="getDevicePointMatchList" resultMap="EmsPointMatchResult">
|
|
|
|
|
<include refid="selectEmsPointMatchVo"/>
|
|
|
|
|
where site_id = #{siteId}
|
|
|
|
|
and device_category = #{deviceCategory}
|
|
|
|
|
and device_id = #{deviceId}
|
|
|
|
|
</select>
|
2025-09-05 13:45:39 +08:00
|
|
|
</mapper>
|