From bf4d67474ff023a7e3ec6fb29b906a698a84f0c5 Mon Sep 17 00:00:00 2001
From: 101captain <237651143@qq.com>
Date: 星期四, 09 九月 2021 13:59:05 +0800
Subject: [PATCH] 物业报警相关提交

---
 springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/netty/NettyServerHandler.java |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/netty/NettyServerHandler.java b/springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/netty/NettyServerHandler.java
index 7e62442..2d6e071 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/netty/NettyServerHandler.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/netty/NettyServerHandler.java
@@ -10,6 +10,7 @@
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Component;
 
+import javax.annotation.PostConstruct;
 import javax.annotation.Resource;
 import java.util.Date;
 
@@ -18,6 +19,8 @@
 public class NettyServerHandler extends ChannelInboundHandlerAdapter {
     @Resource
     private ComPropertyAlarmDao comPropertyAlarmDao;
+
+    private static NettyServerHandler nettyServerHandler;
     /**
      * 客户端连接会触发
      */
@@ -40,13 +43,13 @@
             myTools.writeToClient("404A01"+ DateUtils.getDateFormatString(new Date(),"HHmmss")+"23",ctx,"心跳包");
         }
         if(msg.toString().startsWith("4A1803")){
-            String serial=msg.toString().substring(12,22);
+            String serial=msg.toString().substring(14,24);
             myTools.writeToClient("404A03"+msg.toString().substring(msg.toString().length()-2)+"23",ctx,"事件包");
             ComPropertyAlarm comPropertyAlarm=new ComPropertyAlarm();
             comPropertyAlarm.setCreateTime(DateUtil.date());
             comPropertyAlarm.setSerialNo(serial);
             comPropertyAlarm.setType(ComPropertyAlarm.type.one);
-            comPropertyAlarmDao.insert(comPropertyAlarm);
+            nettyServerHandler.comPropertyAlarmDao.insert(comPropertyAlarm);
         }
         ctx.flush();
     }
@@ -59,4 +62,10 @@
         cause.printStackTrace();
         ctx.close();
     }
+
+    @PostConstruct
+    public void init() {
+        nettyServerHandler=this;
+        nettyServerHandler.comPropertyAlarmDao=this.comPropertyAlarmDao;
+    }
 }

--
Gitblit v1.7.1