|
@@ -1,22 +1,14 @@
|
|
package com.ozs.service.utils;
|
|
package com.ozs.service.utils;
|
|
|
|
|
|
-import com.alibaba.fastjson2.JSON;
|
|
|
|
import com.alibaba.fastjson2.JSONArray;
|
|
import com.alibaba.fastjson2.JSONArray;
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
-import com.ozs.service.entity.CameraUpdateLog;
|
|
|
|
-import com.ozs.service.service.CameraUpdateLogService;
|
|
|
|
-import com.ozs.service.service.impl.CameraUpdateLogServiceImpl;
|
|
|
|
import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
|
|
import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
|
|
import org.eclipse.paho.client.mqttv3.MqttCallback;
|
|
import org.eclipse.paho.client.mqttv3.MqttCallback;
|
|
import org.eclipse.paho.client.mqttv3.MqttMessage;
|
|
import org.eclipse.paho.client.mqttv3.MqttMessage;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
-import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
-import java.util.List;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* callback回调:
|
|
* callback回调:
|
|
@@ -54,6 +46,7 @@ public class PublishCallback implements MqttCallback {
|
|
String sign = null;
|
|
String sign = null;
|
|
String deviceSn = null;
|
|
String deviceSn = null;
|
|
Integer code = null;
|
|
Integer code = null;
|
|
|
|
+ String model = null;
|
|
// subscribe后得到的消息会执行到这里面
|
|
// subscribe后得到的消息会执行到这里面
|
|
logger.info("接收消息主题 : {}", topic);
|
|
logger.info("接收消息主题 : {}", topic);
|
|
logger.info("接收消息内容 : {}", new String(message.getPayload()));
|
|
logger.info("接收消息内容 : {}", new String(message.getPayload()));
|
|
@@ -66,8 +59,15 @@ public class PublishCallback implements MqttCallback {
|
|
JSONObject object = jsonArray.getJSONObject(i);
|
|
JSONObject object = jsonArray.getJSONObject(i);
|
|
sign = (String) object.get("sign");
|
|
sign = (String) object.get("sign");
|
|
deviceSn = (String) object.get("device_sn");
|
|
deviceSn = (String) object.get("device_sn");
|
|
|
|
+ JSONArray model1 = object.putArray("model");
|
|
|
|
+ // 检查数组是否为空
|
|
|
|
+ if (!model1.isEmpty()) {
|
|
|
|
+ // 取出数组的第一个值
|
|
|
|
+ model = model1.getString(0);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
// CallbackUtil.heart(deviceSn);
|
|
// CallbackUtil.heart(deviceSn);
|
|
|
|
+ CallbackUtil.updateVersionNum(model,deviceSn);
|
|
PublishClient.pull(sign, deviceSn);
|
|
PublishClient.pull(sign, deviceSn);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
logger.error(e.getMessage());
|
|
logger.error(e.getMessage());
|