From e14d3145c47aaa482429d6c9e3aa0ccbed780f97 Mon Sep 17 00:00:00 2001
From: 18516761980 <56479841@qq.com>
Date: 星期三, 10 八月 2022 10:42:18 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/core/netty/handle/PackageServerHandler.java |   28 +++++++++++++++++++++-------
 1 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/src/main/java/com/zy/core/netty/handle/PackageServerHandler.java b/src/main/java/com/zy/core/netty/handle/PackageServerHandler.java
index 52c96b9..b7d89c3 100644
--- a/src/main/java/com/zy/core/netty/handle/PackageServerHandler.java
+++ b/src/main/java/com/zy/core/netty/handle/PackageServerHandler.java
@@ -1,5 +1,9 @@
 package com.zy.core.netty.handle;
 
+import com.baomidou.mybatisplus.mapper.EntityWrapper;
+import com.core.common.SpringUtils;
+import com.zy.asrs.entity.LocMast;
+import com.zy.asrs.service.LocMastService;
 import com.zy.asrs.service.impl.MainServiceImpl;
 import com.zy.core.netty.AbstractInboundHandler;
 import com.zy.core.netty.cache.ChannelCache;
@@ -13,6 +17,8 @@
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
+
+import java.util.Date;
 
 /**
  * 鍥芥爣涓氬姟澶勭悊handler
@@ -29,17 +35,27 @@
     @Override
     protected boolean channelRead0(ChannelHandlerContext ctx, ChPackage pac) {
         FireDataType dataType = FireDataType.get(pac.getBytes()[1], pac.getBytes()[2]);
+        Fire_3030 fire3030 = new Fire_3030().readFromBytes(pac.getBytes());
         switch (dataType) {
             case HEARTBEAT:
-                Fire_3030 fire3030 = new Fire_3030().readFromBytes(pac.getBytes());
-                String now = "20" + fire3030.getYear() + "-" + fire3030.getMonth() + "-" + fire3030.getDay()
-                        + " " + fire3030.getHour() + ":" + fire3030.getMinute() + ":" + fire3030.getSeconds();
-
                 ChannelCache.setChannel(String.valueOf(fire3030.getNo()), ctx.channel());
                 Constant.errorMap.remove(fire3030.getNo());
                 break;
             case FIRE_ALARM:
+                //娑堥槻IO鐐圭紪鍙�
+                String fireNo = fire3030.getNo().toString() + fire3030.getLoop().toString() + fire3030.getPartNo().toString();
+                String fireTime = "20" + fire3030.getYear() + "-" + fire3030.getMonth() + "-" + fire3030.getDay()
+                        + " " + fire3030.getHour() + ":" + fire3030.getMinute() + ":" + fire3030.getSeconds();
 
+                LocMastService locMastService = SpringUtils.getBean(LocMastService.class);
+                if(null != locMastService){
+                    LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("fire_no",fireNo));
+                    if(null != locMast){
+                        locMast.setFireStatus(1);
+                        locMast.setModiTime(new Date());
+                        locMastService.update(locMast, new EntityWrapper<LocMast>().eq("fire_no",fireNo));
+                    }
+                }
                 break;
             default:
                 break;
@@ -60,11 +76,9 @@
         channel.writeAndFlush(chPackage);
     }
 
-    /******************************************************************************************/
     /**************************************** 娴嬭瘯涓撶敤 *****************************************/
-    /*****************************************************************************************/
     public static void main(String[] args){
-        byte[] bytes = new byte[]{(byte)0x82, 0x38, 0x30, 0x32, 0x34, 0x30, 0x38, 0x38, 0x3B, 0x30, 0x31, 0x31, 0x31,
+        byte[] bytes = new byte[]{(byte)0x82, 0x38, 0x30, 0x32, 0x34, 0x30, 0x38, 0x39, 0x3B, 0x30, 0x31, 0x31, 0x31,
                                     0x30, 0x33, 0x30, 0x38, 0x31, 0x30, 0x30, 0x34, 0x30, 0x38, 0x38, 0x30, (byte)0x83};
         Fire_3030 fire3030 = new Fire_3030().readFromBytes(bytes);
         String now = "20" + fire3030.getYear() + "-" + fire3030.getMonth() + "-" + fire3030.getDay()

--
Gitblit v1.9.1