|
@@ -49,6 +49,8 @@ public class MqttCallbackHandler {
|
|
|
* @param payload 消息内容
|
|
|
*/
|
|
|
void handle(String topic, String payload) {
|
|
|
+ System.out.println(payload);
|
|
|
+ System.out.println("-------------------------------------------------------------------------");
|
|
|
if (topic.contains("/")) {
|
|
|
webSocketServer.massMessage(topic.split("/")[1], payload);
|
|
|
}
|
|
@@ -72,7 +74,7 @@ public class MqttCallbackHandler {
|
|
|
* 注册设备
|
|
|
*/
|
|
|
private void registerDevice(MqttMsgDto obj) {
|
|
|
- String num = obj.getData().get("num").toString();
|
|
|
+ String num = obj.getData().get("regnum").toString();
|
|
|
//查询数据库中是否有此设备
|
|
|
Device device = deviceService.getByNum(num);
|
|
|
//没有该设备,保存至数据库
|
|
@@ -118,7 +120,7 @@ public class MqttCallbackHandler {
|
|
|
private Device createDevice(String num) {
|
|
|
Device device = new Device();
|
|
|
device.setNum(num);
|
|
|
- device.setClientId(CodeGenerator.generateClientId());
|
|
|
+ device.setClientId(CodeGenerator.generateUUID());
|
|
|
device.setPassword(CodeGenerator.generateShortUuid());
|
|
|
device.setGroupId(1);
|
|
|
deviceService.save(device);
|
|
@@ -137,9 +139,9 @@ public class MqttCallbackHandler {
|
|
|
location.setBatteryNum((int) dataMap.get("batterynum"));
|
|
|
location.setSignalNum((int) dataMap.get("signalnum"));
|
|
|
location.setMode((int) dataMap.get("mode"));
|
|
|
- location.setLon((String) dataMap.get("lon"));
|
|
|
- location.setLon((String) dataMap.get("lat"));
|
|
|
- location.setSpeed((String) dataMap.get("speed"));
|
|
|
+ location.setLon(dataMap.get("lon").toString());
|
|
|
+ location.setLat(dataMap.get("lat").toString());
|
|
|
+ location.setSpeed(dataMap.get("speed").toString());
|
|
|
location.setNum((int) dataMap.get("num"));
|
|
|
location.setUploadTime(DateTimeUtil.strToTime((String) dataMap.get("createtime")));
|
|
|
Object cellInfo = dataMap.get("cellInfo");
|
|
@@ -152,6 +154,7 @@ public class MqttCallbackHandler {
|
|
|
location.setLatGcj(gcj[1]);
|
|
|
return location;
|
|
|
} catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
throw new ApiRuntimeException("处理设备上传位置定位信息出错");
|
|
|
}
|
|
|
}
|