|
@@ -88,9 +88,8 @@ public class EnvInputServerHandler extends ChannelInboundHandlerAdapter {
|
|
|
public static void main(String[] args) {
|
|
|
|
|
|
String str =
|
|
|
-
|
|
|
- "55 86 56 00 49 00 01 50 00 78 f1 88 f7 88 f8 88 f6 88 f2 88 f2 88 ef 88 04 89 18 89 64 8d 19 8d 15 87 12 87 fc 88 fb 84 31 85 29 85 2c 85 2b 85 25 85 23 85 1d 85 35 85 3d 85 38 85 33 85 30 85 2c 85 28 85 29 85 2e 85 31 85 34 85 34 85 36 85 38 85 3a 85 3f 85 44 85 42 85 44 85 48 85 4a 85 48 85 44 85 3e 85 44 85 4a 85 48 85 30 86 3c 8a 96 90 88 82 03 82 fb 81 e9 81 03 82 5d 83 ea 81 e4 81 18 01 1C 0B 11 02 AA ";
|
|
|
- String[] s = str.split(" ");
|
|
|
+ "55 86 45 00 49 00 01 4F 00 78 45 27 54 27 34 27 21 27 ef 26 fa 26 2c 27 11 27 27 27 23 27 1b 27 1a 27 88 27 67 27 0e 27 0a 27 bf 27 76 27 87 27 1e 27 1c 27 89 27 0a 28 4c 28 2b 28 48 28 96 28 44 28 47 28 81 28 11 28 17 28 6f 28 6a 28 c2 26 d7 23 e6 2f 70 43 35 26 e8 37 c1 39 9d 27 90 27 ab 27 99 27 5b 28 6c 28 c6 29 bb 29 e8 29 84 29 28 2a 99 2a f7 2a 3b 2a d0 29 cc 29 e1 29 d7 2a 2c 27 18 01 1C 12 0A 07 AA ";
|
|
|
+ String[] s = str.split(" ");
|
|
|
String dateTimeString = "2023-12-07 23:22:54";
|
|
|
// 创建 DateTimeFormatter 对象,指定日期时间格式
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
@@ -111,15 +110,16 @@ public class EnvInputServerHandler extends ChannelInboundHandlerAdapter {
|
|
|
String str1 = s[i * 2 + 11] + s[i * 2 + 10];
|
|
|
BigDecimal weight = new BigDecimal(Integer.parseInt(str1, 16));
|
|
|
System.out.println("" + sdf.format(thenTime)+" 重量:" +weight );
|
|
|
-// Integer multiply = weight.multiply(BigDecimal.valueOf(0.8)).intValue();
|
|
|
-// System.out.println("计算后重量:"+ multiply);
|
|
|
-// // 将 BigInteger 转换为 16 进制 String
|
|
|
-// String s1 = Integer.toHexString(multiply);
|
|
|
-// s[i * 2 + 11] = s1.substring(0,2);
|
|
|
-// s[i * 2 + 10] = s1.substring(s1.length() - 2, s1.length());
|
|
|
+ Integer multiply = weight.multiply(BigDecimal.valueOf(0.9945)).intValue();
|
|
|
+ System.out.println("计算后重量:"+ multiply);
|
|
|
+ // 将 BigInteger 转换为 16 进制 String
|
|
|
+ String s1 = Integer.toHexString(multiply);
|
|
|
+ System.out.println("转换后"+s1);
|
|
|
+ s[i * 2 + 11] = s1.substring(0,2);
|
|
|
+ s[i * 2 + 10] = s1.substring(s1.length() - 2, s1.length());
|
|
|
}
|
|
|
-// String result = String.join(" ", s);
|
|
|
-// System.out.println(result);
|
|
|
+ String result = String.join(" ", s);
|
|
|
+ System.out.println(result);
|
|
|
}
|
|
|
|
|
|
public String replace(String str, double ratio){
|
|
@@ -130,8 +130,13 @@ public class EnvInputServerHandler extends ChannelInboundHandlerAdapter {
|
|
|
Integer multiply = weight.multiply(BigDecimal.valueOf(ratio)).intValue();
|
|
|
// 将 BigInteger 转换为 16 进制 String
|
|
|
String s1 = Integer.toHexString(multiply);
|
|
|
+ for (int j = s1.length(); j < 4; j++){
|
|
|
+ s1 = "0"+s1;
|
|
|
+ }
|
|
|
s[i * 2 + 11] = s1.substring(0,2);
|
|
|
s[i * 2 + 10] = s1.substring(s1.length() - 2, s1.length());
|
|
|
+ System.out.println(s[i * 2 + 11]);
|
|
|
+ System.out.println(s[i * 2 + 10]);
|
|
|
}
|
|
|
String result = String.join(" ", s);
|
|
|
return result;
|