|
@@ -1,5 +1,6 @@
|
|
package com.gzlh.background.client;
|
|
package com.gzlh.background.client;
|
|
|
|
|
|
|
|
+import cn.hutool.json.JSONObject;
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
import com.gzlh.bus.EventBus;
|
|
import com.gzlh.bus.EventBus;
|
|
import com.gzlh.bus.EventConfig;
|
|
import com.gzlh.bus.EventConfig;
|
|
@@ -10,12 +11,17 @@ import com.gzlh.config.hksdk.HkUtils;
|
|
import com.gzlh.config.hksdk.bo.HKCacheManager;
|
|
import com.gzlh.config.hksdk.bo.HKCacheManager;
|
|
import com.gzlh.device.capture.brand.CaptureBrandType;
|
|
import com.gzlh.device.capture.brand.CaptureBrandType;
|
|
import com.gzlh.device.capture.properties.CapturePropertiesConfig;
|
|
import com.gzlh.device.capture.properties.CapturePropertiesConfig;
|
|
|
|
+import com.gzlh.device.led.utils.LedOptions;
|
|
|
|
+import com.gzlh.entity.CommandBO;
|
|
|
|
+import com.gzlh.entity.DeviceStatus;
|
|
import com.gzlh.utils.DeviceCache;
|
|
import com.gzlh.utils.DeviceCache;
|
|
import io.netty.channel.ChannelHandler;
|
|
import io.netty.channel.ChannelHandler;
|
|
import io.netty.channel.ChannelHandlerContext;
|
|
import io.netty.channel.ChannelHandlerContext;
|
|
import io.netty.channel.SimpleChannelInboundHandler;
|
|
import io.netty.channel.SimpleChannelInboundHandler;
|
|
import io.netty.handler.timeout.IdleStateEvent;
|
|
import io.netty.handler.timeout.IdleStateEvent;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
@@ -41,9 +47,18 @@ public class BackgroundClientHandler extends SimpleChannelInboundHandler<String>
|
|
|
|
|
|
@Override
|
|
@Override
|
|
protected void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception {
|
|
protected void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception {
|
|
- System.out.println("Client received: " + msg);
|
|
|
|
|
|
+// System.out.println("Client received: " + msg);
|
|
if (!"back message".equalsIgnoreCase(msg)){
|
|
if (!"back message".equalsIgnoreCase(msg)){
|
|
- eventBus.startEvent(msg);
|
|
|
|
|
|
+ log.info(msg);
|
|
|
|
+ CommandBO commandBO = JSONUtil.toBean(msg, CommandBO.class);
|
|
|
|
+// log.info(commandBO.toString());
|
|
|
|
+ CommandBO.Command command = commandBO.getCommand();
|
|
|
|
+ eventBus.startEvent(command.getModule()+"."+command.getCommand());
|
|
|
|
+ if (!StringUtils.isEmpty(command.getExtra())){
|
|
|
|
+ LedOptions options = new LedOptions().setLine("04").setColor("03").setShowType("00");
|
|
|
|
+ SystemObject.ledFactory.handler(EventConfig.serialSetting.getLed().getBrand())
|
|
|
|
+ .sendMsg(command.getExtra(),options);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -53,9 +68,6 @@ public class BackgroundClientHandler extends SimpleChannelInboundHandler<String>
|
|
// 获取海康摄像头连接状态
|
|
// 获取海康摄像头连接状态
|
|
if (SystemObject.capturePropertiesConfig.getBrand()== CaptureBrandType.HK_BRAND.getCode()){
|
|
if (SystemObject.capturePropertiesConfig.getBrand()== CaptureBrandType.HK_BRAND.getCode()){
|
|
Map<String,Object> captrue = new HashMap<String,Object>();
|
|
Map<String,Object> captrue = new HashMap<String,Object>();
|
|
- captrue.put("brand",SystemObject.capturePropertiesConfig.getBrand());
|
|
|
|
- captrue.put("host",SystemObject.capturePropertiesConfig.getHost());
|
|
|
|
- captrue.put("port",SystemObject.capturePropertiesConfig.getPort());
|
|
|
|
int userId = HKCacheManager.getUserId(ModuleEnum.CAPTURE_MODULE);
|
|
int userId = HKCacheManager.getUserId(ModuleEnum.CAPTURE_MODULE);
|
|
boolean status = hkUtils.getStatus(hcNetSDK, userId);
|
|
boolean status = hkUtils.getStatus(hcNetSDK, userId);
|
|
|
|
|
|
@@ -66,29 +78,11 @@ public class BackgroundClientHandler extends SimpleChannelInboundHandler<String>
|
|
String ip=capturePropertiesConfig.getHost();
|
|
String ip=capturePropertiesConfig.getHost();
|
|
loginV40 = hkUtils.Login_V40(ip, port, capturePropertiesConfig.getUsername(), capturePropertiesConfig.getPwd(), hcNetSDK);
|
|
loginV40 = hkUtils.Login_V40(ip, port, capturePropertiesConfig.getUsername(), capturePropertiesConfig.getPwd(), hcNetSDK);
|
|
}
|
|
}
|
|
- captrue.put("status",loginV40!=-1?1:0);
|
|
|
|
- DeviceCache.put("captrue",captrue);
|
|
|
|
|
|
+ DeviceCache.changeDeviceStatus(ModuleEnum.CAPTURE_MODULE.getModuleEn(), loginV40!=-1?1:0);
|
|
}
|
|
}
|
|
|
|
|
|
-// Map<String,Object> led = new HashMap<String,Object>();
|
|
|
|
-// led.put("brand",SystemObject.ledPropertiesConfig.getBrand());
|
|
|
|
-// led.put("host",SystemObject.ledPropertiesConfig.getHost());
|
|
|
|
-// led.put("port",SystemObject.ledPropertiesConfig.getPort());
|
|
|
|
-// led.put("status",0);
|
|
|
|
-// DeviceCache.add("led",led);
|
|
|
|
-
|
|
|
|
- Map<String,Object> led = new HashMap<String,Object>();
|
|
|
|
- led.put("brand",EventConfig.serialSetting.getLed().getBrand());
|
|
|
|
- led.put("host",EventConfig.serialSetting.getHost());
|
|
|
|
- led.put("port",EventConfig.serialSetting.getLed().getPort());
|
|
|
|
- led.put("status",0);
|
|
|
|
- DeviceCache.put("led",led);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- DeviceCache.put("channelCode", SystemObject.applicationConfig.getChannelCode());
|
|
|
|
- String jsonStr = JSONUtil.toJsonStr(DeviceCache.getCacheMap());
|
|
|
|
|
|
+ String jsonStr = DeviceCache.getDeviceStatusJson();
|
|
context.writeAndFlush(jsonStr);
|
|
context.writeAndFlush(jsonStr);
|
|
-// System.out.println(" sent ping msg to " + context.channel().remoteAddress());
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|