Commit 491c2809 by YG8999

设备日志信息完善

parent 07e16f2d
...@@ -50,6 +50,13 @@ public class DeviceLog extends BaseEntity ...@@ -50,6 +50,13 @@ public class DeviceLog extends BaseEntity
@Excel(name = "消息主题") @Excel(name = "消息主题")
private String topic; private String topic;
@Excel(name = "消息回复结果")
@TableField(value = "`result`")
private String result;
@Excel(name = "描述")
private String description;
/** /**
* 房间名称 * 房间名称
*/ */
......
...@@ -644,12 +644,16 @@ public class MqttxServiceImpl implements MqttxService { ...@@ -644,12 +644,16 @@ public class MqttxServiceImpl implements MqttxService {
private boolean updateDeviceLog(String topic, String payload) { private boolean updateDeviceLog(String topic, String payload) {
JSONObject json = JSONUtil.parseObj(payload); JSONObject json = JSONUtil.parseObj(payload);
if (json.size() > 0) { if (json.size() > 0) {
JSONArray array = json.getJSONArray("params");
if (array != null && array.size() > 0) {
DeviceLog deviceLog = new DeviceLog(); DeviceLog deviceLog = new DeviceLog();
String seq = json.getStr("seq"); String seq = json.getStr("seq");
deviceLog.setSeq(seq); deviceLog.setSeq(seq);
deviceLog.setRemark(payload); deviceLog.setRemark(payload);
deviceLog.setResult(array.getStr(1));
return 0 < deviceLogMapper.updateBySeq(deviceLog); return 0 < deviceLogMapper.updateBySeq(deviceLog);
} }
}
return false; return false;
} }
......
...@@ -18,10 +18,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -18,10 +18,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateBy" column="update_by" /> <result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" /> <result property="updateTime" column="update_time" />
<result property="remark" column="remark" /> <result property="remark" column="remark" />
<result property="result" column="result" />
<result property="description" column="description" />
</resultMap> </resultMap>
<sql id="selectDeviceLogVo"> <sql id="selectDeviceLogVo">
select id, dev_mac, dev_id, seq, mqtt_type, mqtt_describe, payload, topic, create_by, create_time, update_by, update_time, remark from s_device_log select id, dev_mac, dev_id, seq, mqtt_type, mqtt_describe, payload, topic, create_by, create_time,
update_by, update_time, remark, `result`, description from s_device_log
</sql> </sql>
<select id="selectDeviceLogList" parameterType="DeviceLog" resultMap="DeviceLogResult"> <select id="selectDeviceLogList" parameterType="DeviceLog" resultMap="DeviceLogResult">
...@@ -44,7 +47,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -44,7 +47,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select> </select>
<select id="selectListByMaxId" resultMap="DeviceLogResult"> <select id="selectListByMaxId" resultMap="DeviceLogResult">
SELECT t1.id, t1.dev_mac, t1.dev_id, t1.seq, t1.mqtt_type, t1.mqtt_describe, t1.payload, t1.topic, SELECT t1.id, t1.dev_mac, t1.dev_id, t1.seq, t1.mqtt_type, t1.mqtt_describe, t1.payload, t1.topic,
t1.create_by, t1.create_time, t1.update_by, t1.update_time, t1.remark t1.create_by, t1.create_time, t1.update_by, t1.update_time, t1.remark,
t1.`result`, t1.description
FROM s_device_log t1 FROM s_device_log t1
JOIN ( JOIN (
SELECT MAX(id) AS max_id SELECT MAX(id) AS max_id
...@@ -74,6 +78,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -74,6 +78,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null">update_by,</if> <if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if> <if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if> <if test="remark != null">remark,</if>
<if test="result != null">`result`,</if>
<if test="description != null">description,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="devMac != null">#{devMac},</if> <if test="devMac != null">#{devMac},</if>
...@@ -88,6 +94,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -88,6 +94,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null">#{updateBy},</if> <if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if> <if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if> <if test="remark != null">#{remark},</if>
<if test="result != null">#{result},</if>
<if test="description != null">#{description},</if>
</trim> </trim>
</insert> </insert>
...@@ -106,11 +114,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -106,11 +114,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null">update_by = #{updateBy},</if> <if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if> <if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if> <if test="remark != null">remark = #{remark},</if>
<if test="result != null">`result` = #{result},</if>
<if test="description != null">description = #{description},</if>
</trim> </trim>
where id = #{id} where id = #{id}
</update> </update>
<update id="updateBySeq" parameterType="DeviceLog"> <update id="updateBySeq" parameterType="DeviceLog">
update s_device_log set remark = #{remark} where seq = #{seq} update s_device_log
set remark = #{remark},`result` = #{result}
where seq = #{seq}
</update> </update>
<delete id="deleteDeviceLogById" parameterType="Long"> <delete id="deleteDeviceLogById" parameterType="Long">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment