From 43f0578e80af82ecae6c61b51bd0539c6b960603 Mon Sep 17 00:00:00 2001
From: puhanshu <a9236326>
Date: 星期二, 16 八月 2022 19:08:32 +0800
Subject: [PATCH] 服务范围优化
---
springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/config/WebSocketClient.java | 43 ++++++++++++++++++++++++++++++++++++++++---
1 files changed, 40 insertions(+), 3 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 db7f3e6..d37ef14 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
@@ -12,6 +12,7 @@
import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSONObject;
+import com.panzhihua.common.utlis.StringUtils;
import com.panzhihua.service_property.dao.ComPropertyAlarmDao;
import com.panzhihua.service_property.dto.DeviceDto;
import com.panzhihua.service_property.entity.ComPropertyAlarm;
@@ -70,14 +71,50 @@
}
@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.getUserid());
- 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);
--
Gitblit v1.7.1