You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
2.1 KiB

<?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.techsor.datacenter.business.dao.ex.RiliPersonnasLatestMapperExt">
<select id="getListPage" resultType="com.techsor.datacenter.business.model.RiliPersonnasLatest">
select
personnas_space_id as personnasSpaceId,
name,
latest_ts as latestTs,
latest_value as latestValue
from
rili_personnas_latest
<where>
<if test="param.riliPersonnasSpaceId != null and param.riliPersonnasSpaceId != ''">
and personnas_space_id = #{param.riliPersonnasSpaceId}
</if>
<if test="param.name != null and param.name != ''">
and name = #{param.name}
</if>
</where>
</select>
<select id="getHistoryListPage" resultType="com.techsor.datacenter.business.model.RiliPersonnasHistory">
select
personnas_space_id as personnasSpaceId,
name,
record_ts as recordTs,
value as value,
check_ts as checkTs
from
rili_personnas_history
<where>
<if test="param.riliPersonnasSpaceId != null and param.riliPersonnasSpaceId != ''">
and personnas_space_id = #{param.riliPersonnasSpaceId}
</if>
<if test="param.startTs != null">
and check_ts > #{param.startTs}
</if>
<if test="param.endTs != null">
and check_ts <![CDATA[<=]]> #{param.endTs}
</if>
</where>
</select>
<insert id="batchUpsertPersonnas" parameterType="java.util.List">
INSERT INTO rili_personnas_latest (personnas_space_id, name, latest_ts, latest_value)
VALUES
<foreach collection="list" item="item" separator=",">
(#{item.personnasSpaceId}, #{item.name}, #{item.latestTs}, #{item.latestValue})
</foreach>
ON DUPLICATE KEY UPDATE
name = VALUES(name),
latest_ts = VALUES(latest_ts),
latest_value = VALUES(latest_value)
</insert>
</mapper>