|
@@ -27,19 +27,19 @@ public class MqttLogService extends ServiceImpl<MqttLogMapper, MqttLog> {
|
|
|
* @param tag 0收 1发
|
|
|
*/
|
|
|
public void saveLog(String topic, String payload, Integer tag) {
|
|
|
- MqttLog mqttLog = new MqttLog();
|
|
|
- mqttLog.setTopic(topic);
|
|
|
+ MqttLog entity = new MqttLog();
|
|
|
+ entity.setTopic(topic);
|
|
|
//mqtt 日志类型
|
|
|
- mqttLog.setTag(tag);
|
|
|
+ entity.setTag(tag);
|
|
|
//获取消息解析对象
|
|
|
MqttMsgDto mqttMsgDto = MqttMsgDto.parse(payload);
|
|
|
String regTopic = tag == 0 ? Constant.TOPIC_REGISTER_SERVER : Constant.TOPIC_REGISTER_CLIENT;
|
|
|
//区分注册报文和普通报文,注册报文取设备随机码
|
|
|
- mqttLog.setDeviceId(topic.equals(regTopic) ? mqttMsgDto.getString("regnum") : mqttMsgDto.getDeviceId());
|
|
|
+ entity.setDeviceId(topic.equals(regTopic) ? mqttMsgDto.getString("regnum") : mqttMsgDto.getDeviceId());
|
|
|
//mqtt 指令
|
|
|
- mqttLog.setInstruction(mqttMsgDto.getM());
|
|
|
- mqttLog.setContent(payload);
|
|
|
- baseMapper.insert(mqttLog);
|
|
|
+ entity.setInstruction(mqttMsgDto.getM());
|
|
|
+ entity.setContent(payload);
|
|
|
+ baseMapper.insert(entity);
|
|
|
}
|
|
|
|
|
|
/**
|