Browse Source

增加路牌接口

yangxiaokun 3 years ago
parent
commit
ee8486271f

+ 4 - 2
src/main/java/com/zy/bms/common/Constant.java

@@ -27,7 +27,7 @@ public class Constant {
         public static final String REGISTER = "10";
         //服务器响应设备注册请求
         public static final String HANDLE_REGISTER = "11";
-        //普适性 - 设备心跳协议
+        //普适性 - 设备心跳
         public static final String UBI_HEARTBEAT = "21";
         //普适性 - 远程控制设备报警
         public static final String UBI_CONTROL_ALARM = "23";
@@ -43,7 +43,9 @@ public class Constant {
         public static final String UBI_SET_INFO = "30";
         //普适性-服务器主动请求获取心跳包
         public static final String UBI_REQUEST_HEARTBEAT = "80";
-        //路牌-同步更新路牌本地设置
+        //路牌 - 设备心跳包
+        public static final String LP_HEARTBEAT = "70";
+        //路牌 - 同步更新路牌本地设置
         public static final String LP_SET_LOCAL_INFO = "71";
 
     }

+ 1 - 1
src/main/java/com/zy/bms/config/InterceptorCfg.java

@@ -27,7 +27,7 @@ public class InterceptorCfg implements WebMvcConfigurer {
     private UbiAppAuthInterceptor ubiAppAuthInterceptor;
     @Resource
     private OperateAuthInterceptor operateAuthInterceptor;
-
+    // 白名单
     private static List<String> whiteList = new ArrayList<>();
 
     static {

+ 5 - 0
src/main/java/com/zy/bms/entity/ubi/UbiInfoRecord.java

@@ -82,6 +82,11 @@ public class UbiInfoRecord implements Serializable {
      */
     private String version;
 
+    /**
+     * 板卡类型
+     */
+    private String oemType;
+
     /**
      * 上传时间
      */

+ 5 - 0
src/main/java/com/zy/bms/entity/ubi/UbiInfoState.java

@@ -76,6 +76,11 @@ public class UbiInfoState implements Serializable {
      */
     private String version;
 
+    /**
+     * 板卡类型
+     */
+    private String oemType;
+
     /**
      * 在线状态
      */

+ 10 - 5
src/main/java/com/zy/bms/handler/MqttCallbackHandler.java

@@ -32,6 +32,8 @@ public class MqttCallbackHandler {
     private IDeviceBaseService deviceStaticService;
     @Resource
     private UbiHandlers ubiHandlers;
+    @Resource
+    private LpHandlers lpHandlers;
 
     /**
      * 处理消息
@@ -62,6 +64,11 @@ public class MqttCallbackHandler {
                 ubiHandlers.deviceSetHandler(openNum, mqttDTO);
                 break;
             }
+            // 获取设备设置信息
+            case Constant.M.LP_HEARTBEAT: {
+                lpHandlers.deviceInfoHandler(openNum, mqttDTO);
+                break;
+            }
         }
         // 3. 转发消息至网页,忽略注册的报文
         webSocketHandler.massMessage(openNum, payload);
@@ -72,16 +79,14 @@ public class MqttCallbackHandler {
      */
     private void registerHandler(MqttDTO mqttDTO) {
         String openNum = mqttDTO.getString("regnum");
-        String group = mqttDTO.getString("group");
         // 查询数据库中是否有此设备
-        DeviceBase device = deviceStaticService
-                .getOne(new QueryWrapper<DeviceBase>()
-                        .eq("open_num", openNum));
+        DeviceBase device = deviceStaticService.getOne(new QueryWrapper<DeviceBase>().eq("open_num", openNum));
         // 没有该设备,保存至数据库
         if (device == null) {
             device = new DeviceBase();
             device.setOpenNum(openNum);
-            device.setGroupId(group);
+            device.setGroupId(mqttDTO.getString("group"));
+            device.setType(mqttDTO.getString("type"));
             device.setUsername("IMEI" + openNum);
             device.setPassword(MD5Util.encode(openNum));
             device.setSn("SN" + openNum);

+ 23 - 23
src/main/resources/mapper/UbiInfoStateMapper.xml

@@ -12,28 +12,29 @@
 
     <select id="listPage" resultType="com.zy.bms.pojo.vo.UbiDeviceListVo">
         SELECT
-        t1.open_num,
-        t1.username,
-        t1.password,
-        t1.sn,
-        t1.create_time,
-        t1.group_id,
-        t2.freq,
-        t2.power_volt,
-        t2.sat_num,
-        t2.signal4g,
-        t2.device_id,
-        t2.lat,
-        t2.lon,
-        t2.lat_gcj,
-        t2.lon_gcj,
-        t2.`version`,
-        t2.status,
-        t2.update_time
+            t1.open_num,
+            t1.username,
+            t1.password,
+            t1.sn,
+            t1.create_time,
+            t1.group_id,
+            t2.freq,
+            t2.power_volt,
+            t2.sat_num,
+            t2.signal4g,
+            t2.device_id,
+            t2.lat,
+            t2.lon,
+            t2.lat_gcj,
+            t2.lon_gcj,
+            t2.`version`,
+            t2.status,
+            t2.update_time
         FROM
-        device_base t1
+            device_base t1
         LEFT JOIN ubi_info_state t2 ON t1.open_num = t2.open_num
-        <where>
+        WHERE
+            t1.type = "gnss"
             <if test="io.openNum != null and io.openNum != ''">
                 AND t1.open_num LIKE CONCAT('%',#{io.openNum},'%')
             </if>
@@ -43,7 +44,6 @@
             <if test="io.status != null and io.status > -1">
                 AND t2.status = #{io.status}
             </if>
-        </where>
     </select>
 
     <select id="getDetail" resultType="com.zy.bms.pojo.vo.UbiDeviceDetailVo">
@@ -60,7 +60,7 @@
                t2.update_time
         FROM device_base t1
                  LEFT JOIN ubi_info_state t2 ON t1.open_num = t2.open_num
-        WHERE t1.open_num = #{openNum}
+        WHERE t1.type = "gnss" AND t1.open_num = #{openNum}
     </select>
 
     <select id="listWx" resultType="com.zy.bms.pojo.vo.UbiDeviceListVo">
@@ -69,7 +69,7 @@
                t2.status
         FROM device_base t1
                  LEFT JOIN ubi_info_state t2 ON t1.open_num = t2.open_num
-        WHERE t1.group_id = #{group}
+        WHERE t1.type = "gnss" t1.group_id = #{group}
     </select>
 
     <select id="checkOpenNum" resultType="java.lang.Integer">