代码提交

main
zhangshengli 4 weeks ago
parent d6d31aee87
commit d41f7088e7

@ -97,5 +97,6 @@ public class BeeHive implements Serializable {
/**
*
*/
@TableField(exist = false)
private String dateUploadTimeHex;
}

@ -67,4 +67,6 @@ public class BeeHiveLog implements Serializable {
*
*/
private LocalDateTime dateUploadTime;
@TableField(exist = false)
private String dateUploadTimeHex;
}

@ -1,6 +1,7 @@
package com.hive.bee.vo;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
@ -85,5 +86,7 @@ public class BeeHiveVo implements Serializable {
*
*/
private LocalDateTime dateUploadTime;
@TableField(exist = false)
private String dateUploadTimeHex;
}

@ -55,8 +55,8 @@ public class EchoServer {
System.out.println("报告完毕");
ch.pipeline().addLast(new StringEncoder(Charset.forName("UTF-8")));
String startDelimiterStr = "99";
String endDelimiterStr = "0A";
String startDelimiterStr = "55";
String endDelimiterStr = "aa";
ByteBuf startDelimiter = Unpooled.copiedBuffer(startDelimiterStr, Charset.forName("UTF-8"));
ByteBuf endDelimiter = Unpooled.copiedBuffer(endDelimiterStr, Charset.forName("UTF-8"));
// ch.pipeline().addLast(new DelimiterBasedFrameDecoder(startDelimiter, endDelimiter));

@ -1,6 +1,8 @@
package com.hive.communication.netty.server.dataprocessing;
import cn.hutool.core.util.HexUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.hive.bee.entity.BeeHive;
@ -88,10 +90,14 @@ public class HandlerDateProcessing {
public BeeHive dataAnalysis(String data) {
BeeHiveAdd beeHiveAdd = SpringUtil.getBean(BeeHiveAdd.class);
BeeHive beeHive = new BeeHive();
if (data.length() != 61) {
System.out.println(data.length());
String substring = data.substring(0, 6);
String sub = StrUtil.sub(data, -6,data.length());
if (ObjectUtil.notEqual(substring,"558511")||ObjectUtil.notEqual(sub,"aa")) {
return beeHive;
}
for (int i = 0; i < 7; i++) {
Integer startIndex = 0;
Integer endIndex = 0;
switch (i) {

@ -1,6 +1,7 @@
package com.hive.communication.netty.server.handler;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.hive.bee.entity.BeeHive;
import com.hive.communication.netty.server.dataprocessing.HandlerDateProcessing;
@ -17,6 +18,7 @@ import java.io.UnsupportedEncodingException;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.*;
@ -54,13 +56,14 @@ public class EchoServerHandler extends ChannelInboundHandlerAdapter {
stringBuilder.append(start);
stringBuilder.append("8561");
stringBuilder.append(beeHive.getDateUploadTimeHex());
stringBuilder.append("0b01");
stringBuilder.append("0801");
// String paddedString = String.format("%4s", code).replace(' ', '0');
//获取十分钟后的时间秒数,
// 转换为16进制
String hexSeconds = Long.toHexString(getCurrentSeconds()).toUpperCase();
stringBuilder.append(hexSeconds);
stringBuilder.append("0000ff000000");
// String hexSeconds = Long.toHexString(getCurrentSeconds()).toUpperCase();
String upperCase = Long.toHexString(DateUtil.offsetHour(new Date(), -8).toInstant().getEpochSecond()).toUpperCase();
stringBuilder.append(upperCase);
stringBuilder.append("0000ff");
byte[] dataSum = hexStringToByteArray(stringBuilder.toString());
// 计算校验码1

@ -55,4 +55,5 @@ public class DateConvetUtil {
return newSeconds;
}
}

Loading…
Cancel
Save