|
@@ -10,13 +10,13 @@ import com.zd.laboratory.domain.LabHardware;
|
|
|
import com.zd.laboratory.domain.vo.LabHardwareVO;
|
|
import com.zd.laboratory.domain.vo.LabHardwareVO;
|
|
|
import com.zd.laboratory.mapper.LabAbnormalMapper;
|
|
import com.zd.laboratory.mapper.LabAbnormalMapper;
|
|
|
import com.zd.laboratory.mapper.LabHardwareMapper;
|
|
import com.zd.laboratory.mapper.LabHardwareMapper;
|
|
|
|
|
+import com.zd.laboratory.socket.constant.SocketTypes;
|
|
|
import com.zd.laboratory.socket.runner.TCPServer;
|
|
import com.zd.laboratory.socket.runner.TCPServer;
|
|
|
import com.zd.laboratory.utils.CRCCHECK;
|
|
import com.zd.laboratory.utils.CRCCHECK;
|
|
|
import io.netty.channel.ChannelHandlerContext;
|
|
import io.netty.channel.ChannelHandlerContext;
|
|
|
import io.netty.channel.ChannelInboundHandler;
|
|
import io.netty.channel.ChannelInboundHandler;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
|
|
-import java.nio.ByteBuffer;
|
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
import java.util.concurrent.Executors;
|
|
import java.util.concurrent.Executors;
|
|
@@ -40,32 +40,15 @@ public class NettyServerHandler implements ChannelInboundHandler {
|
|
|
if(data.equals("6862")){
|
|
if(data.equals("6862")){
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
+ // 采集器规范定义 hex发送 结构 31 11 01 01 后两位递增方式增加
|
|
|
|
|
+ String relayCode = data.substring(0, 8);
|
|
|
|
|
|
|
|
- log.info("netty服务端接受消息转10进制为:" + ByteBuffer.wrap(msg).getLong());
|
|
|
|
|
-// if(data.startsWith(SocketTypes.LOCK_PREFIX)){
|
|
|
|
|
-// if(data.startsWith("33")){
|
|
|
|
|
-
|
|
|
|
|
- String relayCode = data.substring(0, 108);
|
|
|
|
|
-// 33 31 20 33 30 20 36 33 20 33 36 20 36 34 20 33 37 20 33 36 20 33 33 20 33 31 20 33 35 20 33 31 20 33 35 20 33 30 20 36 33 20 33 33 20 33 35 20 33 32 20 33 37 20
|
|
|
|
|
-
|
|
|
|
|
-// 05 05 00 01 ee 00 d0 2e
|
|
|
|
|
-
|
|
|
|
|
|
|
+ if(relayCode.startsWith(SocketTypes.SZZQ_PREFIX)){
|
|
|
// 将通道加入ChannelMap
|
|
// 将通道加入ChannelMap
|
|
|
- ChannelMap.getChannelMap().put(data, channelHandlerContext);
|
|
|
|
|
-// }else {
|
|
|
|
|
-// if(data.length() != 12){
|
|
|
|
|
-// log.info("netty柜锁回调指令非状态指令!" + data);
|
|
|
|
|
-// return;
|
|
|
|
|
-// }
|
|
|
|
|
|
|
+ if(relayCode.length() == data.length()){
|
|
|
|
|
+ ChannelMap.getChannelMap().put(data, channelHandlerContext);
|
|
|
|
|
|
|
|
-// AtomicReference<String> relayCode = new AtomicReference<>("");
|
|
|
|
|
-// ChannelMap.getChannelMap().entrySet().forEach(a -> {
|
|
|
|
|
-// if(a.getValue() == channelHandlerContext){
|
|
|
|
|
-// relayCode.set(a.getKey());
|
|
|
|
|
-// }
|
|
|
|
|
-// });
|
|
|
|
|
-
|
|
|
|
|
- if(data.length() > relayCode.length()) {
|
|
|
|
|
|
|
+ }else if(data.length() > relayCode.length()) {
|
|
|
data = data.replaceAll(relayCode, "");
|
|
data = data.replaceAll(relayCode, "");
|
|
|
// 柜锁bit 位
|
|
// 柜锁bit 位
|
|
|
long bit = CRCCHECK.getBitByCommand(data);
|
|
long bit = CRCCHECK.getBitByCommand(data);
|
|
@@ -83,6 +66,7 @@ public class NettyServerHandler implements ChannelInboundHandler {
|
|
|
RedisService redisService = SpringUtils.getBean(RedisService.class);
|
|
RedisService redisService = SpringUtils.getBean(RedisService.class);
|
|
|
redisService.setCacheObject(relayCode + ":" + bit, status, 3 * 60L, TimeUnit.SECONDS);
|
|
redisService.setCacheObject(relayCode + ":" + bit, status, 3 * 60L, TimeUnit.SECONDS);
|
|
|
}
|
|
}
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|