Bläddra i källkod

增加主机基础数据/磁盘数据/索引数据主动获取 代码修改

jingyuanchao 1 år sedan
förälder
incheckning
d1ce03fedc

+ 2 - 2
project_data/sql/0.1.1/soc/soc.sql

@@ -964,10 +964,10 @@ INSERT INTO `sys_menu` VALUES ('01806206030435823618', '升级状态查询', '18
 INSERT INTO `sys_menu` VALUES ('01806206236392927233', '白令海管理', '1806204625679527938', '4', 'bering', 'deploy/bering/index', null, '1', '0', 'C', '0', '0', 'deploy:bering:list', '1', 'component', null, '超级管理员', '2024-06-27 14:01:39', '', null, '');
 INSERT INTO `sys_menu` VALUES ('01808375108978040834', '日志', '1806204625679527938', '5', 'log', 'deploy/log/index', null, '1', '0', 'C', '0', '0', 'deploy:log:list', '1', 'log', null, '超级管理员', '2024-07-03 13:39:58', '', null, '');
 
--- 新增iot接入服务菜单
+-- 新增巡检主机接入服务菜单
 delete from sys_menu where  id in ('1810216137011572738');
 INSERT INTO sys_menu (id, menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, platform_type, icon, image_path, create_by, create_time, update_by, update_time, remark) VALUES (1810216137011572738, '巡检主机接入', 1747911340288892930, 0, 'server/center', 'iot/server/index', null, 1, 0, 'C', '0', '0', null, '1', 'tree', null, '景远超', '2024-07-08 15:35:39', '', null, '');
--- iot接入服务菜单角色授权
+-- 巡检主机接入菜单角色授权
 delete from sys_role_menu where sys_role_menu.menu_id = 1810216137011572738;
 insert into sys_role_menu select  id,1810216137011572738 from sys_role where org_type in (1,2,3,4);
 

+ 7 - 1
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/iot/service/impl/IotDeviceInfoServiceImpl.java

@@ -260,8 +260,12 @@ public class IotDeviceInfoServiceImpl extends ServiceImpl<IotDeviceInfoMapper, I
             return;
         }
         for (DeviceStatusInfo statusInfo : statusInfos){
-            LogUtils.WEBSOCKET_MSG.error("收到设备状态变更消息,根据token:{},productName:{},deviceName:{}未查询到设备信息", serverInfo.getIotCode(), statusInfo.getProductName(), statusInfo.getDeviceCode());
+
             IotDeviceInfo deviceInfo = this.selectByTokenProductAndDeviceCode(serverInfo.getIotCode(), statusInfo.getProductName(), statusInfo.getDeviceCode());
+            if (ObjectUtil.isEmpty(deviceInfo)) {
+                LogUtils.SOCKET_DEVICE_STATUS_INFO.error("收到设备状态变更消息,根据token:{},productName:{},deviceName:{}未查询到设备信息", serverInfo.getIotCode(), statusInfo.getProductName(), statusInfo.getDeviceCode());
+                continue;
+            }
             deviceInfo.setNetStatus(DeviceNetStatusEnum.getValue(statusInfo.getDeviceStatus()));
             deviceInfo.setUpdateTime(new Date());
             baseMapper.updateById(deviceInfo);
@@ -277,6 +281,7 @@ public class IotDeviceInfoServiceImpl extends ServiceImpl<IotDeviceInfoMapper, I
     public String routerKey() {
         StringJoiner result = new StringJoiner(",");
         //设备基础数据
+        result.add(WebSocketConstants.GET_DEVICES);
         result.add(WebSocketConstants.DEVICES_EVENT);
         //设备状态数据
         result.add(WebSocketConstants.DEVICES_STATUS_EVENT);
@@ -307,6 +312,7 @@ public class IotDeviceInfoServiceImpl extends ServiceImpl<IotDeviceInfoMapper, I
         String event = req.getEvent();
         switch (event) {
             case WebSocketConstants.DEVICES_EVENT:
+            case WebSocketConstants.GET_DEVICES:
                 List<DvsBaseInfo> dataList = dataArray.toJavaList(DvsBaseInfo.class);
                 String lockKey = LOCK_DEVICE_BASE_INFO + token;
                 String key = LOCK_ALARM_HOST_BASE_INFO + token;

+ 4 - 15
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/websocket/handler/SocWebSocketHandler.java

@@ -64,7 +64,7 @@ public class SocWebSocketHandler extends AbstractWebSocketHandler {
             Map<String, Object> map = new HashMap<>();
             IotServerInfo serverInfo = iotServerInfoService.getToken(registerCode);
             if (serverInfo == null) {
-                map.put("statusDescription", "验证码不存在!");
+                map.put("statusDescription", "验证码不存在或已被使用!");
                 map.put("statusCode", WebsocketStatus.ERROR.getStatusCode());
             } else {
                 final SysOrg sysOrg = orgService.selectOrgById(serverInfo.getOrgId(), SecurityConstants.INNER);
@@ -83,7 +83,7 @@ public class SocWebSocketHandler extends AbstractWebSocketHandler {
         String token = (String) session.getAttributes().get("token");
         if (StringUtils.isNotEmpty(token)) {
             String ip =WebSocketUtils.getIp(session);
-            LogUtils.WEBSOCKET_MSG.info("[准备建立连接],ip:{}", ip);
+            LogUtils.WEBSOCKET_MSG.info("[准备建立连接],ip:{},token:{}", ip,token);
             IotServerInfo serverInfo = iotServerInfoService.selectByToken(token);
             Map<String, Object> map = new HashMap<>();
             if (serverInfo == null) {
@@ -133,7 +133,7 @@ public class SocWebSocketHandler extends AbstractWebSocketHandler {
         // 从WebSocket会话中获取登录用户信息
         String token = WebSocketSessionHolder.updateToken(session);
         if (StringUtils.isEmpty(token)) {
-            LogUtils.WEBSOCKET_MSG.error("无法根据会话找到token,ip:{}", WebSocketUtils.getIp(session));
+            LogUtils.WEBSOCKET_MSG.error("会话消息不存在,ip:{}", WebSocketUtils.getIp(session));
             return;
         }
         //String token ="9e08595b-868e-4eac-ab44-45bdeec51185";
@@ -163,14 +163,7 @@ public class SocWebSocketHandler extends AbstractWebSocketHandler {
             WebsocketExecuteReq executeReq = new WebsocketExecuteReq(payloadResolve.getRoutingKey(), args, token, websocketResult.getId(), topic, payloadResolve.getHeader(), typeEnums.getProductName(), typeEnums.getDeviceName());
             WebsocketResult result = null;
             switch (typeEnums) {
-                //系统通知
-                case SYS_NOTICE:
-                    break;
-              /*  //设备状态通知
-                case DEVICE_STATUS:
-                    iotDeviceStatusService.deviceStatusChangeDeal(executeReq);
-                    break;*/
-                //产品事件通知消息
+
                 case PRODUCT_EVENT_NOTICE:
                     //IoT返回服务调用消息
                 case PRODUCT_SERVICE_REPLY:
@@ -180,10 +173,6 @@ public class SocWebSocketHandler extends AbstractWebSocketHandler {
                     }
                     result = (WebsocketResult) routeService.execute(executeReq);
                     break;
-                //IoT上报属性变化
-               /* case PRODUCT_PROPERTY_POST:
-                    result = iotDeviceStatusService.dealDeviceStatusChange(executeReq);
-                    break;*/
                 default:
                     break;
             }

+ 0 - 1
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/websocket/service/impl/WebsocketServiceImpl.java

@@ -62,7 +62,6 @@ public class WebsocketServiceImpl implements WebsocketService {
     public void getDevices() {
         final String topic = TopicTypeEnums.formatUrl(TopicTypeEnums.PRODUCT_SERVICE_INVOKE.getUrl(),ProductEnums.DETECTION_HOST.getProductName()[0], ProductEnums.DETECTION_HOST.getProductName()[1]);
         final WebsocketResult result = IotServerUtils.invokeHostServer(topic, new JSONObject(), WebSocketConstants.GET_DEVICES, new JSONObject());
-        System.out.println(JSON.toJSONString(result));
         WebSocketUtils.sendAll(JacksonUtils.toJSONString(result));
     }