浏览代码

更换接口

yangxiaokun 2 年之前
父节点
当前提交
d9a88dc702

+ 2 - 3
src/main/java/com/zy/omp/common/Constant.java

@@ -13,8 +13,7 @@ public class Constant {
     /**
      * redis key前缀
      */
-    public static final String REDIS_LOCATION = "omp:device:location";//数据上传位置信息前缀
-    public static final String REDIS_TOKEN_PREFIX = "omp:user:token:";//PC管理员登录token 前缀
+    public static final String REDIS_TOKEN_PREFIX = "bms:user:token:";//PC管理员登录token 前缀
 
     /**
      * MQTT 协议报文 中 M值
@@ -41,6 +40,6 @@ public class Constant {
     public static final String TOPIC_DEVICE_CLIENT = "$drx/OMP";
 
     public static String getTopic(String openNum) {
-        return TOPIC_DEVICE_CLIENT + DEVICE_ID_PREFIX + openNum;
+        return TOPIC_DEVICE_CLIENT + openNum;
     }
 }

+ 1 - 19
src/main/java/com/zy/omp/common/redis/SessionManager.java

@@ -22,24 +22,6 @@ public class SessionManager {
     @Resource
     private StringRedisTemplate stringRedisTemplate;
 
-    /**
-     * 生成token
-     */
-    public String generateToken(Admin admin) {
-        String token = CodeGenerator.generateUUID();
-        stringRedisTemplate.opsForValue()
-                .set(Constant.REDIS_TOKEN_PREFIX + token, JSON.toJSONString(admin), 30, TimeUnit.MINUTES);
-        return token;
-    }
-
-    /**
-     * 删除Token
-     */
-    public void removeToken(String token) {
-        if (token == null) return;
-        stringRedisTemplate.delete(Constant.REDIS_TOKEN_PREFIX + token);
-    }
-
     /**
      * 获取登录的用户信息
      */
@@ -52,7 +34,7 @@ public class SessionManager {
      * 验证token有效
      */
     public boolean valid(String token) {
-        if (token == null || getUser(token) == null) return false;
+        if (getUser(token) == null) return false;
         stringRedisTemplate.expire(Constant.REDIS_TOKEN_PREFIX + token, 30, TimeUnit.MINUTES);
         return true;
     }

+ 0 - 58
src/main/java/com/zy/omp/controller/pc/AdminController.java

@@ -1,58 +0,0 @@
-package com.zy.omp.controller.pc;
-
-import com.zy.omp.common.ServerResponse;
-import com.zy.omp.common.controller.BaseController;
-import com.zy.omp.model.Admin;
-import com.zy.omp.common.redis.SessionManager;
-import com.zy.omp.service.AdminService;
-import com.zy.omp.utils.MD5Util;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * 管理员Controller
- *
- * @author yang xiao kun
- * create on 2021/2/24
- */
-@RestController
-@RequestMapping("omp/api/pc/admin")
-public class AdminController extends BaseController {
-
-    @Resource
-    private AdminService adminService;
-
-    @Resource
-    private SessionManager sessionManager;
-
-    /**
-     * 登录
-     */
-    @PostMapping("login.do")
-    public ServerResponse login(String username, String password) {
-        Admin admin = adminService.getByUsername(username);
-        if (admin == null) return ServerResponse.createByWarning("用户不存在");
-        //MD5密码
-        password = MD5Util.MD5Encode(password);
-        if (!admin.getPassword().equals(password)) return ServerResponse.createByWarning("密码错误");
-        // 返回 token 和 昵称
-        Map<String, String> result = new HashMap<>();
-        result.put("token", sessionManager.generateToken(admin));
-        result.put("nickname", admin.getNickname());
-        return ServerResponse.createBySuccess(result);
-    }
-
-    /**
-     * token 验证
-     */
-    @GetMapping("verify.do")
-    public ServerResponse verify() {
-        return ServerResponse.createBySuccess();
-    }
-}

+ 3 - 3
src/main/java/com/zy/omp/controller/pc/PcDeviceController.java

@@ -3,7 +3,7 @@ package com.zy.omp.controller.pc;
 import com.zy.omp.common.ServerResponse;
 import com.zy.omp.pojo.io.pc.DeviceIO;
 import com.zy.omp.service.DeviceService;
-import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -25,8 +25,8 @@ public class PcDeviceController {
     /**
      * 分页查询设备集合
      */
-    @PostMapping("listPage.do")
-    public ServerResponse getListPage(DeviceIO io) {
+    @GetMapping("listPage.do")
+    public ServerResponse listPage(DeviceIO io) {
         return ServerResponse.createBySuccess(deviceService.listPage(io));
     }
 

+ 0 - 28
src/main/java/com/zy/omp/controller/pc/PcMqttLogController.java

@@ -1,16 +1,13 @@
 package com.zy.omp.controller.pc;
 
-import com.zy.omp.common.Constant;
 import com.zy.omp.common.ServerResponse;
 import com.zy.omp.pojo.io.pc.MqttLogsIO;
 import com.zy.omp.service.MqttLogService;
-import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
-import java.util.HashMap;
 
 /**
  * mqtt收发日志
@@ -24,23 +21,6 @@ public class PcMqttLogController {
 
     @Resource
     private MqttLogService mqttLogService;
-    private static HashMap<String, String> instruction = new HashMap<>();
-
-    /*
-     * 所有指令暂时写死内存中
-     */
-    static {
-        instruction.put(Constant.M_CODE_REGISTER, "注册");
-        instruction.put(Constant.M_CODE_RETURN_CODE, "返回授权码");
-        instruction.put(Constant.M_CODE_UPLOAD_LOCATION, "上传位置信息");
-        instruction.put(Constant.M_CODE_GPS_RATE, "设置定位频率");
-        instruction.put(Constant.M_CODE_SOS, "设置联系人");
-        instruction.put(Constant.M_CODE_VOLUME, "设置音量");
-        instruction.put(Constant.M_CODE_AUTO_ANSWER, "设置自动接听");
-        instruction.put(Constant.M_CODE_NEWS, "设置语音播报");
-        instruction.put(Constant.M_CODE_UPLOAD_CALL_RECORD, "上传通话记录");
-        instruction.put(Constant.M_CODE_CONTINUE_GPS, "设置连续定位");
-    }
 
     /**
      * 分页查询日志
@@ -49,12 +29,4 @@ public class PcMqttLogController {
     public ServerResponse getListPage(MqttLogsIO io) {
         return ServerResponse.createBySuccess(mqttLogService.getListPage(io));
     }
-
-    /**
-     * 查询所有的指令
-     */
-    @GetMapping("getInstruction.do")
-    public ServerResponse getInstruction() {
-        return ServerResponse.createBySuccess(instruction);
-    }
 }

+ 3 - 3
src/main/java/com/zy/omp/controller/pc/PcSetController.java

@@ -28,11 +28,11 @@ public class PcSetController {
     /**
      * 其他设置
      *
-     * @param deviceId 设备ID
+     * @param openNum 设备ID
      */
     @GetMapping("baseSet.do")
-    public ServerResponse getBaseSet(String deviceId) {
-        return ServerResponse.createBySuccess(deviceSetService.getByDeviceId(deviceId));
+    public ServerResponse getBaseSet(String openNum) {
+        return ServerResponse.createBySuccess(deviceSetService.getByOpenNum(openNum));
     }
 
 

+ 0 - 12
src/main/java/com/zy/omp/service/DeviceService.java

@@ -1,6 +1,5 @@
 package com.zy.omp.service;
 
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -29,15 +28,4 @@ public class DeviceService extends ServiceImpl<DeviceMapper, Device> {
         Page<DeviceListVo> page = new Page<>(io.getCurrent(), io.getSize());
         return baseMapper.listPage(page, io);
     }
-
-
-    /**
-     * 通过设备 clientId 获取设备信息
-     *
-     * @param clientId 设备 MQTT 登录账号
-     */
-    public Device getByClientId(String clientId) {
-        QueryWrapper<Device> queryWrapper = new QueryWrapper<Device>().eq("clientId", clientId);
-        return baseMapper.selectOne(queryWrapper);
-    }
 }

+ 9 - 9
src/main/java/com/zy/omp/service/DeviceSetService.java

@@ -20,11 +20,11 @@ public class DeviceSetService extends ServiceImpl<DeviceSetMapper, DeviceSet> {
      * 后台
      * 获取全部的设置信息
      *
-     * @param deviceId 设备ID
+     * @param openNum 设备ID
      */
-    public DeviceSet getByDeviceId(String deviceId) {
+    public DeviceSet getByOpenNum(String openNum) {
         QueryWrapper<DeviceSet> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("deviceId", deviceId);
+        queryWrapper.eq("openNum", openNum);
         return baseMapper.selectOne(queryWrapper);
     }
 
@@ -33,8 +33,8 @@ public class DeviceSetService extends ServiceImpl<DeviceSetMapper, DeviceSet> {
      */
     public DeviceSet getVolumeSet(String deviceId) {
         QueryWrapper<DeviceSet> queryWrapper = new QueryWrapper<>();
-        queryWrapper.select("deviceId", "msgVol", "phoneVol", "ringVol");
-        queryWrapper.eq("deviceId", deviceId);
+        queryWrapper.select("openNum", "msgVol", "phoneVol", "ringVol");
+        queryWrapper.eq("openNum", deviceId);
         return baseMapper.selectOne(queryWrapper);
     }
 
@@ -43,8 +43,8 @@ public class DeviceSetService extends ServiceImpl<DeviceSetMapper, DeviceSet> {
      */
     public DeviceSet getSosSet(String deviceId) {
         QueryWrapper<DeviceSet> queryWrapper = new QueryWrapper<>();
-        queryWrapper.select("deviceId", "key0Name", "key0Phone", "key1Name", "key1Phone", "key2Name", "key2Phone");
-        queryWrapper.eq("deviceId", deviceId);
+        queryWrapper.select("openNum", "key0Name", "key0Phone", "key1Name", "key1Phone", "key2Name", "key2Phone");
+        queryWrapper.eq("openNum", deviceId);
         return baseMapper.selectOne(queryWrapper);
     }
 
@@ -53,8 +53,8 @@ public class DeviceSetService extends ServiceImpl<DeviceSetMapper, DeviceSet> {
      */
     public DeviceSet getOtherSet(String deviceId) {
         QueryWrapper<DeviceSet> queryWrapper = new QueryWrapper<>();
-        queryWrapper.select("deviceId", "autoAnswer", "gpsRate", "highFreq");
-        queryWrapper.eq("deviceId", deviceId);
+        queryWrapper.select("openNum", "autoAnswer", "gpsRate", "highFreq");
+        queryWrapper.eq("openNum", deviceId);
         return baseMapper.selectOne(queryWrapper);
     }
 }

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

@@ -66,7 +66,7 @@ public class SetService {
         // 3. 存储消息日志
         mqttLogService.saveSendLog(topic, msgDto.toJson());
         // 4. 消息转发前端webSocket
-        webSocketServer.massMessage(param.getOpenNum(), msgDto.toJson());
+//        webSocketServer.massMessage(param.getOpenNum(), msgDto.toJson());
     }
 
     /**

+ 0 - 8
src/main/java/com/zy/omp/websocket/WebSocketServer.java

@@ -43,14 +43,6 @@ public class WebSocketServer {
         webSocketMap.get(deviceId).remove(session);
     }
 
-    /**
-     * 连接错误
-     */
-    @OnError
-    public void onError(Session session, Throwable error, @PathParam("deviceId") String deviceId) {
-        webSocketMap.get(deviceId).remove(session);
-    }
-
     /**
      * 群发消息
      */

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

@@ -12,7 +12,7 @@ spring:
   datasource:
     type: com.alibaba.druid.pool.DruidDataSource
     driver-class-name: com.mysql.cj.jdbc.Driver
-    url: jdbc:mysql://59.110.141.39:3306/zy_mobile?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=true
+    url: jdbc:mysql://59.110.141.39:3306/old_phone?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=true
     username: useryxk
     password: CHENyi406@
     dbcp2:

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

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

+ 1 - 6
src/main/resources/mapper/DeviceMapping.xml

@@ -5,9 +5,7 @@
     <select id="listPage" resultType="com.zy.omp.pojo.vo.DeviceListVo">
         SELECT
             t1.openNum,
-            t1.groupId,
             t1.createTime,
-            t2.status,
             t2.batteryNum,
             t2.signalNum,
             t2.`mode`,
@@ -18,15 +16,12 @@
             t2.num,
             t2.uploadTime
         FROM
-            device t1
+            device_base t1
         LEFT JOIN device_info_state t2 ON t1.openNum = t2.openNum
         <where>
             <if test="io.openNum != null and io.openNum != ''">
                 AND t1.openNum LIKE CONCAT('%',#{io.openNum},'%')
             </if>
-            <if test="io.status != null and io.status > -1">
-                AND t2.status = #{io.status}
-            </if>
         </where>
         ORDER BY
         t1.createTime DESC