Newer
Older
smartwell_demos / src / main / resources / mapper / DeviceDataMapper.xml
chaizhuang on 29 Aug 2023 2 KB 中石化thingsboard,联调bug
<?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.casic.dao.DeviceDataMapper">

    <select id="getDeviceRecentData" resultType="java.util.Map">
        SELECT ${fields}
        FROM ${tableName}
        WHERE 1=1
        <if test="devcode != null and devcode !='' ">
            and devcode = #{devcode}
        </if>
        ORDER BY uptime DESC
        limit ${recentNum}
    </select>

    <select id="getDeviceDataTotal" resultType="java.lang.Integer">
        SELECT count(*)
        FROM ${tableName}
        WHERE 1=1
        <if test="devcode != null and devcode !='' ">
            and devcode = #{devcode}
        </if>
    </select>

    <select id="getDeviceDataListPage" resultType="java.util.Map">
        SELECT ${fields}
        FROM ${tableName}
        WHERE 1=1
        <if test="devcode != null and devcode !='' ">
            and devcode = #{devcode}
        </if>
        ORDER BY uptime DESC
        LIMIT #{currentIndex},#{pageSize}
    </select>

    <select id="getLevelByType" resultType="java.lang.String">
        SELECT high_value AS "highValue"
        FROM alarm_level
        WHERE level=1
        AND  device_type=#{deviceType}
    </select>

    <select id="getDevcodeByType" resultType="java.lang.String">
        SELECT DEVCODE
        FROM BUS_DEVICE
        WHERE VALID=1 AND DEVICE_TYPE=#{devciceType}
        AND ONLINE_STATE=1
    </select>

    <select id="getRecentData" resultType="java.lang.String">
        SELECT DISTINCT DEVCODE
        FROM DATA_H2S
        WHERE SYSDATE-LOGTIME  <![CDATA[< ]]> #{dataDay}
    </select>

    <update id="updateOnlineByDevs">
        UPDATE  BUS_DEVICE
        SET ONLINE_STATE=0
        WHERE  VALID=1
        AND DEVCODE IN
        <foreach collection="dataSortList" index="index" item="item" open="(" separator="," close=")">
                      #{item}
        </foreach>
    </update>


</mapper>