Browse Source

临时修改上传位置为旧方案

yangxiaokun 3 năm trước cách đây
mục cha
commit
e7bdefdbda

+ 13 - 1
src/main/java/com/zy/omp/config/mqtt/MqttCallbackHandler.java

@@ -208,7 +208,7 @@ public class MqttCallbackHandler {
     private void uploadDeviceInfoLPHandler(String topic, MqttMsgDto msg) {
         try {
             String num = topic.split("IMEI")[1];
-            setService.getDeviceLocation_LP(num);
+            //setService.getDeviceLocation_LP(num);
             DeviceLp dbDevice = deviceLpService.getByNum(num);
             if (dbDevice == null) {
                 log.warn("设备需要手动添加至数据库:" + num);
@@ -238,6 +238,18 @@ public class MqttCallbackHandler {
             deviceLp.setAnglez(msg.getString("anglez"));
             deviceLp.setTemp(msg.getString("temp"));
             deviceLp.setUpdateTime(LocalDateTime.now());
+            //临时解决方案
+            if (msg.getString("lng")!=null){
+                deviceLp.setMode(msg.getInt("mode"));
+                deviceLp.setLon(msg.getString("lng"));
+                deviceLp.setLat(msg.getString("lat"));
+                //转换后的坐标
+                String[] gcj = CoordTransformUtil.wgs84toGcj02(deviceLp.getLon(), deviceLp.getLat());
+                deviceLp.setLonGcj(gcj[0]);
+                deviceLp.setLatGcj(gcj[1]);
+                // 逆地理位置解析
+                deviceLp.setSite(GaoDeApiUtil.regeo(deviceLp.getLonGcj(), deviceLp.getLatGcj()));
+            }
             // 保存基本信息
             deviceLpService.updateByNum(deviceLp, num);
         } catch (Exception e) {

+ 2 - 2
src/main/java/com/zy/omp/service/MqttLogService.java

@@ -26,9 +26,9 @@ public class MqttLogService extends ServiceImpl<MqttLogMapper, MqttLog> {
 
     static {
         registerSet.add(Constant.TOPIC_REGISTER_CLIENT);
-        registerSet.add(Constant.TOPIC_DEVICE_CLIENT_LP);
+        registerSet.add(Constant.TOPIC_REGISTER_CLIENT_LP);
         registerSet.add(Constant.TOPIC_REGISTER_SERVER);
-        registerSet.add(Constant.TOPIC_DEVICE_SERVER_LP);
+        registerSet.add(Constant.TOPIC_REGISTER_SERVER_LP);
     }
 
     /**

+ 1 - 1
src/main/java/com/zy/omp/service/SetService.java

@@ -186,6 +186,6 @@ public class SetService {
         msgDto.setData(data);
         mqttGateway.sendMsgToMqtt(msgDto.toJson(), Constant.TOPIC_DEVICE_CLIENT_LP + num);
         // 3. 存储消息日志
-        mqttLogService.saveSendLog(Constant.M_CODE_UPDATE_DEVICE_INFO_LP, msgDto.toJson());
+        mqttLogService.saveSendLog(Constant.TOPIC_DEVICE_CLIENT_LP + num, msgDto.toJson());
     }
 }