mqtt模块初始化
This commit is contained in:
106
src/main/resources/mybatis/worn/MqttSensorCommandMapper.xml
Normal file
106
src/main/resources/mybatis/worn/MqttSensorCommandMapper.xml
Normal file
@@ -0,0 +1,106 @@
|
||||
<?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.shzg.project.worn.mapper.MqttSensorCommandMapper">
|
||||
|
||||
<resultMap type="MqttSensorCommand" id="MqttSensorCommandResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="deviceId" column="device_id" />
|
||||
<result property="topic" column="topic" />
|
||||
<result property="command" column="command" />
|
||||
<result property="payload" column="payload" />
|
||||
<result property="status" column="status" />
|
||||
<result property="sendTime" column="send_time" />
|
||||
<result property="remark" column="remark" />
|
||||
<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="isDelete" column="is_delete" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectMqttSensorCommandVo">
|
||||
select id, device_id, topic, command, payload, status, send_time, remark, create_by, create_time, update_by, update_time, is_delete from mqtt_sensor_command
|
||||
</sql>
|
||||
|
||||
<select id="selectMqttSensorCommandList" parameterType="MqttSensorCommand" resultMap="MqttSensorCommandResult">
|
||||
<include refid="selectMqttSensorCommandVo"/>
|
||||
<where>
|
||||
<if test="deviceId != null "> and device_id = #{deviceId}</if>
|
||||
<if test="topic != null and topic != ''"> and topic = #{topic}</if>
|
||||
<if test="command != null and command != ''"> and command = #{command}</if>
|
||||
<if test="payload != null and payload != ''"> and payload = #{payload}</if>
|
||||
<if test="status != null and status != ''"> and status = #{status}</if>
|
||||
<if test="sendTime != null "> and send_time = #{sendTime}</if>
|
||||
<if test="isDelete != null and isDelete != ''"> and is_delete = #{isDelete}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectMqttSensorCommandById" parameterType="Long" resultMap="MqttSensorCommandResult">
|
||||
<include refid="selectMqttSensorCommandVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertMqttSensorCommand" parameterType="MqttSensorCommand" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into mqtt_sensor_command
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="deviceId != null">device_id,</if>
|
||||
<if test="topic != null">topic,</if>
|
||||
<if test="command != null">command,</if>
|
||||
<if test="payload != null">payload,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="sendTime != null">send_time,</if>
|
||||
<if test="remark != null">remark,</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="isDelete != null">is_delete,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="deviceId != null">#{deviceId},</if>
|
||||
<if test="topic != null">#{topic},</if>
|
||||
<if test="command != null">#{command},</if>
|
||||
<if test="payload != null">#{payload},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="sendTime != null">#{sendTime},</if>
|
||||
<if test="remark != null">#{remark},</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="isDelete != null">#{isDelete},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateMqttSensorCommand" parameterType="MqttSensorCommand">
|
||||
update mqtt_sensor_command
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="deviceId != null">device_id = #{deviceId},</if>
|
||||
<if test="topic != null">topic = #{topic},</if>
|
||||
<if test="command != null">command = #{command},</if>
|
||||
<if test="payload != null">payload = #{payload},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="sendTime != null">send_time = #{sendTime},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<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="isDelete != null">is_delete = #{isDelete},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteMqttSensorCommandById" parameterType="Long">
|
||||
delete from mqtt_sensor_command where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteMqttSensorCommandByIds" parameterType="String">
|
||||
delete from mqtt_sensor_command where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
155
src/main/resources/mybatis/worn/MqttSensorDataMapper.xml
Normal file
155
src/main/resources/mybatis/worn/MqttSensorDataMapper.xml
Normal file
@@ -0,0 +1,155 @@
|
||||
<?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.shzg.project.worn.mapper.MqttSensorDataMapper">
|
||||
|
||||
<resultMap type="MqttSensorData" id="MqttSensorDataResult">
|
||||
<result property="id" column="id"/>
|
||||
<result property="deviceId" column="device_id"/>
|
||||
<result property="topic" column="topic"/>
|
||||
<result property="project" column="project"/>
|
||||
<result property="warehouse" column="warehouse"/>
|
||||
<result property="payload" column="payload"/>
|
||||
<result property="dataJson" column="data_json"/>
|
||||
<result property="battery" column="battery"/>
|
||||
<result property="temperature" column="temperature"/>
|
||||
<result property="humidity" column="humidity"/>
|
||||
<result property="nh3" column="nh3"/>
|
||||
<result property="h2s" column="h2s"/>
|
||||
<result property="concentration" column="concentration"/>
|
||||
|
||||
<result property="waterStatus" column="water_status"/>
|
||||
|
||||
<result property="remark" column="remark"/>
|
||||
<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="isDelete" column="is_delete"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectMqttSensorDataVo">
|
||||
select
|
||||
id, device_id, topic, project, warehouse, payload, data_json,
|
||||
battery, temperature, humidity, nh3, h2s, concentration,
|
||||
water_status,
|
||||
remark, create_by, create_time, update_by, update_time, is_delete
|
||||
from mqtt_sensor_data
|
||||
</sql>
|
||||
|
||||
<select id="selectMqttSensorDataList" parameterType="MqttSensorData" resultMap="MqttSensorDataResult">
|
||||
<include refid="selectMqttSensorDataVo"/>
|
||||
<where>
|
||||
<if test="deviceId != null "> and device_id = #{deviceId}</if>
|
||||
<if test="topic != null and topic != ''"> and topic = #{topic}</if>
|
||||
<if test="project != null and project != ''"> and project = #{project}</if>
|
||||
<if test="warehouse != null and warehouse != ''"> and warehouse = #{warehouse}</if>
|
||||
<if test="payload != null and payload != ''"> and payload = #{payload}</if>
|
||||
<if test="dataJson != null and dataJson != ''"> and data_json = #{dataJson}</if>
|
||||
<if test="battery != null "> and battery = #{battery}</if>
|
||||
<if test="temperature != null "> and temperature = #{temperature}</if>
|
||||
<if test="humidity != null "> and humidity = #{humidity}</if>
|
||||
<if test="nh3 != null "> and nh3 = #{nh3}</if>
|
||||
<if test="h2s != null "> and h2s = #{h2s}</if>
|
||||
<if test="concentration != null "> and concentration = #{concentration}</if>
|
||||
|
||||
<if test="waterStatus != null "> and water_status = #{waterStatus}</if>
|
||||
|
||||
<if test="isDelete != null and isDelete != ''"> and is_delete = #{isDelete}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectMqttSensorDataById" parameterType="Long" resultMap="MqttSensorDataResult">
|
||||
<include refid="selectMqttSensorDataVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertMqttSensorData" parameterType="MqttSensorData" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into mqtt_sensor_data
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="deviceId != null">device_id,</if>
|
||||
<if test="topic != null">topic,</if>
|
||||
<if test="project != null">project,</if>
|
||||
<if test="warehouse != null">warehouse,</if>
|
||||
<if test="payload != null">payload,</if>
|
||||
<if test="dataJson != null">data_json,</if>
|
||||
<if test="battery != null">battery,</if>
|
||||
<if test="temperature != null">temperature,</if>
|
||||
<if test="humidity != null">humidity,</if>
|
||||
<if test="nh3 != null">nh3,</if>
|
||||
<if test="h2s != null">h2s,</if>
|
||||
<if test="concentration != null">concentration,</if>
|
||||
|
||||
<if test="waterStatus != null">water_status,</if>
|
||||
|
||||
<if test="remark != null">remark,</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="isDelete != null">is_delete,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="deviceId != null">#{deviceId},</if>
|
||||
<if test="topic != null">#{topic},</if>
|
||||
<if test="project != null">#{project},</if>
|
||||
<if test="warehouse != null">#{warehouse},</if>
|
||||
<if test="payload != null">#{payload},</if>
|
||||
<if test="dataJson != null">#{dataJson},</if>
|
||||
<if test="battery != null">#{battery},</if>
|
||||
<if test="temperature != null">#{temperature},</if>
|
||||
<if test="humidity != null">#{humidity},</if>
|
||||
<if test="nh3 != null">#{nh3},</if>
|
||||
<if test="h2s != null">#{h2s},</if>
|
||||
<if test="concentration != null">#{concentration},</if>
|
||||
<if test="waterStatus != null">#{waterStatus},</if>
|
||||
<if test="remark != null">#{remark},</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="isDelete != null">#{isDelete},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateMqttSensorData" parameterType="MqttSensorData">
|
||||
update mqtt_sensor_data
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="deviceId != null">device_id = #{deviceId},</if>
|
||||
<if test="topic != null">topic = #{topic},</if>
|
||||
<if test="project != null">project = #{project},</if>
|
||||
<if test="warehouse != null">warehouse = #{warehouse},</if>
|
||||
<if test="payload != null">payload = #{payload},</if>
|
||||
<if test="dataJson != null">data_json = #{dataJson},</if>
|
||||
<if test="battery != null">battery = #{battery},</if>
|
||||
<if test="temperature != null">temperature = #{temperature},</if>
|
||||
<if test="humidity != null">humidity = #{humidity},</if>
|
||||
<if test="nh3 != null">nh3 = #{nh3},</if>
|
||||
<if test="h2s != null">h2s = #{h2s},</if>
|
||||
<if test="concentration != null">concentration = #{concentration},</if>
|
||||
|
||||
<!-- ✅ 新增 -->
|
||||
<if test="waterStatus != null">water_status = #{waterStatus},</if>
|
||||
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<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="isDelete != null">is_delete = #{isDelete},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteMqttSensorDataById" parameterType="Long">
|
||||
delete from mqtt_sensor_data where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteMqttSensorDataByIds" parameterType="String">
|
||||
delete from mqtt_sensor_data where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
108
src/main/resources/mybatis/worn/MqttSensorDeviceMapper.xml
Normal file
108
src/main/resources/mybatis/worn/MqttSensorDeviceMapper.xml
Normal file
@@ -0,0 +1,108 @@
|
||||
<?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.shzg.project.worn.mapper.MqttSensorDeviceMapper">
|
||||
|
||||
<resultMap type="MqttSensorDevice" id="MqttSensorDeviceResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="devEui" column="dev_eui" />
|
||||
<result property="deviceName" column="device_name" />
|
||||
<result property="deviceType" column="device_type" />
|
||||
<result property="deptId" column="dept_id" />
|
||||
<result property="status" column="status" />
|
||||
<result property="remark" column="remark" />
|
||||
<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="isDelete" column="is_delete" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectMqttSensorDeviceVo">
|
||||
select id, dev_eui, device_name, device_type, dept_id, status, remark, create_by, create_time, update_by, update_time, is_delete from mqtt_sensor_device
|
||||
</sql>
|
||||
|
||||
<select id="selectMqttSensorDeviceList" parameterType="MqttSensorDevice" resultMap="MqttSensorDeviceResult">
|
||||
<include refid="selectMqttSensorDeviceVo"/>
|
||||
<where>
|
||||
<if test="devEui != null and devEui != ''"> and dev_eui = #{devEui}</if>
|
||||
<if test="deviceName != null and deviceName != ''"> and device_name like concat('%', #{deviceName}, '%')</if>
|
||||
<if test="deviceType != null and deviceType != ''"> and device_type = #{deviceType}</if>
|
||||
<if test="deptId != null "> and dept_id = #{deptId}</if>
|
||||
<if test="status != null and status != ''"> and status = #{status}</if>
|
||||
<if test="isDelete != null and isDelete != ''"> and is_delete = #{isDelete}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectMqttSensorDeviceById" parameterType="Long" resultMap="MqttSensorDeviceResult">
|
||||
<include refid="selectMqttSensorDeviceVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertMqttSensorDevice" parameterType="MqttSensorDevice" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into mqtt_sensor_device
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="devEui != null and devEui != ''">dev_eui,</if>
|
||||
<if test="deviceName != null">device_name,</if>
|
||||
<if test="deviceType != null">device_type,</if>
|
||||
<if test="deptId != null">dept_id,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="remark != null">remark,</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="isDelete != null">is_delete,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="devEui != null and devEui != ''">#{devEui},</if>
|
||||
<if test="deviceName != null">#{deviceName},</if>
|
||||
<if test="deviceType != null">#{deviceType},</if>
|
||||
<if test="deptId != null">#{deptId},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="remark != null">#{remark},</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="isDelete != null">#{isDelete},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateMqttSensorDevice" parameterType="MqttSensorDevice">
|
||||
update mqtt_sensor_device
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="devEui != null and devEui != ''">dev_eui = #{devEui},</if>
|
||||
<if test="deviceName != null">device_name = #{deviceName},</if>
|
||||
<if test="deviceType != null">device_type = #{deviceType},</if>
|
||||
<if test="deptId != null">dept_id = #{deptId},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<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="isDelete != null">is_delete = #{isDelete},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteMqttSensorDeviceById" parameterType="Long">
|
||||
delete from mqtt_sensor_device where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteMqttSensorDeviceByIds" parameterType="String">
|
||||
delete from mqtt_sensor_device where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="selectByDevEui" parameterType="String" resultMap="MqttSensorDeviceResult">
|
||||
<include refid="selectMqttSensorDeviceVo"/>
|
||||
WHERE dev_eui = #{devEui}
|
||||
AND is_delete = '0'
|
||||
LIMIT 1
|
||||
</select>
|
||||
</mapper>
|
||||
101
src/main/resources/mybatis/worn/MqttSensorEventMapper.xml
Normal file
101
src/main/resources/mybatis/worn/MqttSensorEventMapper.xml
Normal file
@@ -0,0 +1,101 @@
|
||||
<?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.shzg.project.worn.mapper.MqttSensorEventMapper">
|
||||
|
||||
<resultMap type="MqttSensorEvent" id="MqttSensorEventResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="deviceId" column="device_id" />
|
||||
<result property="eventType" column="event_type" />
|
||||
<result property="eventDesc" column="event_desc" />
|
||||
<result property="level" column="level" />
|
||||
<result property="status" column="status" />
|
||||
<result property="remark" column="remark" />
|
||||
<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="isDelete" column="is_delete" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectMqttSensorEventVo">
|
||||
select id, device_id, event_type, event_desc, level, status, remark, create_by, create_time, update_by, update_time, is_delete from mqtt_sensor_event
|
||||
</sql>
|
||||
|
||||
<select id="selectMqttSensorEventList" parameterType="MqttSensorEvent" resultMap="MqttSensorEventResult">
|
||||
<include refid="selectMqttSensorEventVo"/>
|
||||
<where>
|
||||
<if test="deviceId != null "> and device_id = #{deviceId}</if>
|
||||
<if test="eventType != null and eventType != ''"> and event_type = #{eventType}</if>
|
||||
<if test="eventDesc != null and eventDesc != ''"> and event_desc = #{eventDesc}</if>
|
||||
<if test="level != null and level != ''"> and level = #{level}</if>
|
||||
<if test="status != null and status != ''"> and status = #{status}</if>
|
||||
<if test="isDelete != null and isDelete != ''"> and is_delete = #{isDelete}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectMqttSensorEventById" parameterType="Long" resultMap="MqttSensorEventResult">
|
||||
<include refid="selectMqttSensorEventVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertMqttSensorEvent" parameterType="MqttSensorEvent" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into mqtt_sensor_event
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="deviceId != null">device_id,</if>
|
||||
<if test="eventType != null and eventType != ''">event_type,</if>
|
||||
<if test="eventDesc != null">event_desc,</if>
|
||||
<if test="level != null">level,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="remark != null">remark,</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="isDelete != null">is_delete,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="deviceId != null">#{deviceId},</if>
|
||||
<if test="eventType != null and eventType != ''">#{eventType},</if>
|
||||
<if test="eventDesc != null">#{eventDesc},</if>
|
||||
<if test="level != null">#{level},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="remark != null">#{remark},</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="isDelete != null">#{isDelete},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateMqttSensorEvent" parameterType="MqttSensorEvent">
|
||||
update mqtt_sensor_event
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="deviceId != null">device_id = #{deviceId},</if>
|
||||
<if test="eventType != null and eventType != ''">event_type = #{eventType},</if>
|
||||
<if test="eventDesc != null">event_desc = #{eventDesc},</if>
|
||||
<if test="level != null">level = #{level},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<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="isDelete != null">is_delete = #{isDelete},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteMqttSensorEventById" parameterType="Long">
|
||||
delete from mqtt_sensor_event where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteMqttSensorEventByIds" parameterType="String">
|
||||
delete from mqtt_sensor_event where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
126
src/main/resources/mybatis/worn/MqttSensorThresholdMapper.xml
Normal file
126
src/main/resources/mybatis/worn/MqttSensorThresholdMapper.xml
Normal file
@@ -0,0 +1,126 @@
|
||||
<?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.shzg.project.worn.mapper.MqttSensorThresholdMapper">
|
||||
|
||||
<resultMap type="MqttSensorThreshold" id="MqttSensorThresholdResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="deviceId" column="device_id" />
|
||||
<result property="metricType" column="metric_type" />
|
||||
<result property="warnMin" column="warn_min" />
|
||||
<result property="warnMax" column="warn_max" />
|
||||
<result property="alarmMin" column="alarm_min" />
|
||||
<result property="alarmMax" column="alarm_max" />
|
||||
<result property="unit" column="unit" />
|
||||
<result property="status" column="status" />
|
||||
<result property="remark" column="remark" />
|
||||
<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="isDelete" column="is_delete" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectMqttSensorThresholdVo">
|
||||
select id, device_id, metric_type, warn_min, warn_max, alarm_min, alarm_max, unit, status, remark, create_by, create_time, update_by, update_time, is_delete from mqtt_sensor_threshold
|
||||
</sql>
|
||||
|
||||
<select id="selectMqttSensorThresholdList" parameterType="MqttSensorThreshold" resultMap="MqttSensorThresholdResult">
|
||||
<include refid="selectMqttSensorThresholdVo"/>
|
||||
<where>
|
||||
<if test="deviceId != null "> and device_id = #{deviceId}</if>
|
||||
<if test="metricType != null and metricType != ''"> and metric_type = #{metricType}</if>
|
||||
<if test="warnMin != null "> and warn_min = #{warnMin}</if>
|
||||
<if test="warnMax != null "> and warn_max = #{warnMax}</if>
|
||||
<if test="alarmMin != null "> and alarm_min = #{alarmMin}</if>
|
||||
<if test="alarmMax != null "> and alarm_max = #{alarmMax}</if>
|
||||
<if test="unit != null and unit != ''"> and unit = #{unit}</if>
|
||||
<if test="status != null and status != ''"> and status = #{status}</if>
|
||||
<if test="isDelete != null and isDelete != ''"> and is_delete = #{isDelete}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectMqttSensorThresholdById" parameterType="Long" resultMap="MqttSensorThresholdResult">
|
||||
<include refid="selectMqttSensorThresholdVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertMqttSensorThreshold" parameterType="MqttSensorThreshold" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into mqtt_sensor_threshold
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="deviceId != null">device_id,</if>
|
||||
<if test="metricType != null and metricType != ''">metric_type,</if>
|
||||
<if test="warnMin != null">warn_min,</if>
|
||||
<if test="warnMax != null">warn_max,</if>
|
||||
<if test="alarmMin != null">alarm_min,</if>
|
||||
<if test="alarmMax != null">alarm_max,</if>
|
||||
<if test="unit != null">unit,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="remark != null">remark,</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="isDelete != null">is_delete,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="deviceId != null">#{deviceId},</if>
|
||||
<if test="metricType != null and metricType != ''">#{metricType},</if>
|
||||
<if test="warnMin != null">#{warnMin},</if>
|
||||
<if test="warnMax != null">#{warnMax},</if>
|
||||
<if test="alarmMin != null">#{alarmMin},</if>
|
||||
<if test="alarmMax != null">#{alarmMax},</if>
|
||||
<if test="unit != null">#{unit},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="remark != null">#{remark},</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="isDelete != null">#{isDelete},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateMqttSensorThreshold" parameterType="MqttSensorThreshold">
|
||||
update mqtt_sensor_threshold
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="deviceId != null">device_id = #{deviceId},</if>
|
||||
<if test="metricType != null and metricType != ''">metric_type = #{metricType},</if>
|
||||
<if test="warnMin != null">warn_min = #{warnMin},</if>
|
||||
<if test="warnMax != null">warn_max = #{warnMax},</if>
|
||||
<if test="alarmMin != null">alarm_min = #{alarmMin},</if>
|
||||
<if test="alarmMax != null">alarm_max = #{alarmMax},</if>
|
||||
<if test="unit != null">unit = #{unit},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<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="isDelete != null">is_delete = #{isDelete},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteMqttSensorThresholdById" parameterType="Long">
|
||||
delete from mqtt_sensor_threshold where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteMqttSensorThresholdByIds" parameterType="String">
|
||||
delete from mqtt_sensor_threshold where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="selectByDeviceAndMetric" resultMap="MqttSensorThresholdResult">
|
||||
select *
|
||||
from mqtt_sensor_threshold
|
||||
where device_id = #{deviceId}
|
||||
and metric_type = #{metricType}
|
||||
and status = '1'
|
||||
and is_delete = '0'
|
||||
limit 1
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user