chenyi406 3 years ago
parent
commit
6dc3ecf839

+ 58 - 0
src/main/java/com/zy/bms/handler/MqttCallbackHandler.java

@@ -10,6 +10,7 @@ import com.zy.bms.entity.ubi.UbiInfoState;
 import com.zy.bms.entity.ubi.UbiTcp;
 import com.zy.bms.pojo.dto.MqttDTO;
 import com.zy.bms.service.*;
+import com.zy.bms.service.lp.ILpInfoStateService;
 import com.zy.bms.service.ubi.IUbiInfoRecordService;
 import com.zy.bms.service.ubi.IUbiInfoStateService;
 import com.zy.bms.service.ubi.IUbiNtripService;
@@ -51,6 +52,8 @@ public class MqttCallbackHandler {
     private IUbiNtripService ntripSetService;
     @Resource
     private IUbiTcpService tcpSetService;
+    @Resource
+    private ILpInfoStateService lpInfoStateService;
 
     /**
      * 处理消息
@@ -159,4 +162,59 @@ public class MqttCallbackHandler {
         tcpSetService.saveOrUpdateTcpSet(link2, openNum, IUbiTcpService.LINK_2);
         tcpSetService.saveOrUpdateTcpSet(link3, openNum, IUbiTcpService.LINK_3);
     }
+
+//    /**
+//     * 路牌-基本信息上传
+//     */
+//    private void LP_deviceInfoHandler(String topic, MqttDTO mqttDTO) {
+//        try {
+//            String openNum = Constant.splitOpenNum(topic);
+//            LpInfoState dbDevice = lpInfoStateService.getByOpenNum(openNum);
+//            if (dbDevice == null) {
+//                log.error("设备需要手动添加至数据库:" + openNum);
+//                return;
+//            }
+//            LpInfoState deviceLp = new LpInfoState();
+//            Double wakeInt = mqttDTO.getDouble("sleept");
+//            Integer thresh = mqttDTO.getInt("thresh");
+//            //若数据库中没有设置唤醒时间和阈值则直接同步设备数据
+//            if (dbDevice.getThresh() == null || dbDevice.getWakeInt() == null) {
+//                deviceLp.setWakeInt(BigDecimal.valueOf(wakeInt));
+//                deviceLp.setThresh(thresh);
+//            } else {
+//                //如果远程设备的(唤醒时间,阈值)与数据库的数据不一致,则发送消息更新设备的设置数据与数据库保持一致
+//                if (!dbDevice.getWakeInt().equals(wakeInt) || !dbDevice.getThresh().equals(thresh)) {
+//                    setService.updateDevice_LP(num, dbDevice.getWakeInt(), dbDevice.getThresh());
+//                }
+//            }
+//            deviceLp.setDataType(msg.getString("datetype"));
+//            deviceLp.setBattery(msg.getString("batterynum"));
+//            deviceLp.setS4g(msg.getString("s4g"));
+//            deviceLp.setX(msg.getString("x"));
+//            deviceLp.setY(msg.getString("y"));
+//            deviceLp.setZ(msg.getString("z"));
+//            deviceLp.setAnglex(msg.getString("anglex"));
+//            deviceLp.setAngley(msg.getString("angley"));
+//            deviceLp.setAnglez(msg.getString("anglez"));
+//            deviceLp.setTemp(msg.getString("temp"));
+//            deviceLp.setUpdateTime(LocalDateTime.now());
+//            //临时解决方案
+//            if (msg.getString("lon") != null) {
+//                deviceLp.setMode(msg.getInt("mode"));
+//                deviceLp.setLon(msg.getString("lon"));
+//                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) {
+//            log.error("路牌上传基本信息异常", e);
+//        }
+//    }
+
 }

+ 6 - 0
src/main/java/com/zy/bms/service/lp/ILpInfoStateService.java

@@ -12,5 +12,11 @@ import com.zy.bms.entity.lp.LpInfoState;
  * @since 2021-06-22
  */
 public interface ILpInfoStateService extends IService<LpInfoState> {
+    /**
+     * 通过设备ID获取设备信息
+     *
+     * @param openNum 设备ID
+     */
+    LpInfoState getByOpenNum(String openNum);
 
 }

+ 5 - 0
src/main/java/com/zy/bms/service/lp/impl/LpInfoStateServiceImpl.java

@@ -1,5 +1,6 @@
 package com.zy.bms.service.lp.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.zy.bms.entity.lp.LpInfoState;
 import com.zy.bms.mapper.lp.LpInfoStateMapper;
 import com.zy.bms.service.lp.ILpInfoStateService;
@@ -17,4 +18,8 @@ import org.springframework.stereotype.Service;
 @Service
 public class LpInfoStateServiceImpl extends ServiceImpl<LpInfoStateMapper, LpInfoState> implements ILpInfoStateService {
 
+    @Override
+    public LpInfoState getByOpenNum(String openNum) {
+        return baseMapper.selectOne(new QueryWrapper<LpInfoState>().eq("open_num", openNum));
+    }
 }

+ 1 - 1
src/main/resources/application.yml

@@ -1,3 +1,3 @@
 spring:
   profiles:
-    active: ailishi
+    active: dev