From 70d2a5d0f9c6951b2d4cac954041ed73582ff7eb Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期一, 09 六月 2025 11:54:00 +0800
Subject: [PATCH] 6.9新增登录失败冻结逻辑

---
 springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/config/WebSocketClient.java |   81 +++++++++++++++++++++++++++++-----------
 1 files changed, 59 insertions(+), 22 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/config/WebSocketClient.java b/springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/config/WebSocketClient.java
index fe1d535..1a383e1 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/config/WebSocketClient.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/config/WebSocketClient.java
@@ -1,23 +1,21 @@
 package com.panzhihua.service_property.config;
 
-import java.io.IOException;
-import java.util.Date;
-
-import javax.annotation.Resource;
-import javax.websocket.*;
-
+import cn.hutool.extra.spring.SpringUtil;
+import com.alibaba.fastjson.JSONObject;;
+import com.panzhihua.service_property.dao.ComPropertyAlarmDao;
+import com.panzhihua.service_property.dto.DeviceDto;
+import com.panzhihua.service_property.entity.ComPropertyAlarm;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Component;
 
-import com.alibaba.fastjson.JSONObject;
-import com.panzhihua.service_property.dao.ComPropertyAlarmDao;
-import com.panzhihua.service_property.dto.DeviceDto;
-import com.panzhihua.service_property.entity.ComPropertyAlarm;
-
-import cn.hutool.extra.spring.SpringUtil;
-import lombok.extern.slf4j.Slf4j;
+import javax.annotation.Resource;
+import javax.websocket.*;
+import java.io.IOException;
+import java.util.Date;
 
 /**
  * 应用模块名称
@@ -39,7 +37,9 @@
 
     private static final Logger logger = LoggerFactory.getLogger(WebSocketClient.class);
 
-    /** 保存报警记录服务 */
+    /**
+     * 保存报警记录服务
+     */
     @Resource
     private ComPropertyAlarmDao comPropertyAlarmDao;
     /**
@@ -65,19 +65,58 @@
     @OnMessage
     public void onMessage(String message, Session session) {
         // 提取数据
-        dealData(message);
+        logger.info("收到的原始数据:{}", message);
+        dealNewData(message);
     }
 
+    @Deprecated
+    @Async
+    void dealNewData(String message) {
+        comPropertyAlarmDao = SpringUtil.getBean(ComPropertyAlarmDao.class);
+        JSONObject deviceMess = JSONObject.parseObject(message);
+        boolean checkFlag =
+                ("trace_call".equals(deviceMess.getString("cmd")) && (StringUtils.isNotEmpty(deviceMess.getString("userid"))));
+        if (checkFlag) {
+            log.info("已经接收到报警记录,记录信息:{}",deviceMess.toJSONString());
+            boolean panzhihuaDevice = deviceMess.getString("userid").startsWith("7") || deviceMess.getString("userid").startsWith("8");
+            if(panzhihuaDevice) {
+                log.info("报警记录是攀枝花设备7-8开头的设备");
+                logger.info("收到设备报警信息:{}", message);
+                for (int i = 1; i < 10; i++) {
+                    if (org.apache.commons.lang.StringUtils.isNotEmpty(deviceMess.getString("num" + i))) {
+                        ComPropertyAlarm comPropertyAlarm = new ComPropertyAlarm();
+                        comPropertyAlarm.setSerialNo(deviceMess.getString("userid"));
+                        comPropertyAlarm.setReceiveNo(deviceMess.getString("num" + i));
+                        comPropertyAlarm.setStatus(0);
+                        // 10位的秒级别的时间戳
+                        Date createDate = new Date(deviceMess.getLong("ts" + i) * 1000);
+                        //对应的就是时间戳对应的Date
+                        comPropertyAlarm.setCreateTime(createDate);
+                        comPropertyAlarm.setType(1);
+                        comPropertyAlarmDao.insert(comPropertyAlarm);
+                    } else {
+                        break;
+                    }
+                }
+            }
+        }
+    }
+
+    @Deprecated
     @Async
     void dealData(String message) {
         comPropertyAlarmDao = SpringUtil.getBean(ComPropertyAlarmDao.class);
         DeviceDto deviceInfo = JSONObject.parseObject(message, DeviceDto.class);
-        if (deviceInfo.getCallstatus().equals("RINGING")) {
+        boolean checkFlag =
+                "RINGING".equals(deviceInfo.getCallstatus()) && StringUtils.isNotEmpty(deviceInfo.getOri_number());
+        if (checkFlag) {
             logger.info("收到设备报警信息:{}", message);
             ComPropertyAlarm comPropertyAlarm = new ComPropertyAlarm();
-            comPropertyAlarm.setSerialNo(deviceInfo.getCallid());
-            comPropertyAlarm.setStatus(1);
+            comPropertyAlarm.setSerialNo(deviceInfo.getOri_number());
+            comPropertyAlarm.setReceiveNo(deviceInfo.getUserid());
+            comPropertyAlarm.setStatus(0);
             comPropertyAlarm.setCreateTime(new Date());
+            comPropertyAlarm.setType(1);
             comPropertyAlarmDao.insert(comPropertyAlarm);
         }
     }
@@ -95,8 +134,7 @@
     /**
      * <异步发送message>
      *
-     * @param message
-     *            message @throws
+     * @param message message @throws
      */
     public void send(String message) {
         this.session.getAsyncRemote().sendText(message);
@@ -105,8 +143,7 @@
     /**
      * <发送message>
      *
-     * @param message
-     *            message @throws
+     * @param message message @throws
      */
     public void sendMessage(String message) {
         try {

--
Gitblit v1.7.1