From 7149ebf2e7dab8229e3114c8f95013833316405b Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期一, 24 七月 2023 08:29:15 +0800
Subject: [PATCH] 计算中间点到目标点行走距离

---
 src/main/java/com/zy/common/utils/CommonUtils.java |   33 ++++++++++++++++++++++++++++++++-
 1 files changed, 32 insertions(+), 1 deletions(-)

diff --git a/src/main/java/com/zy/common/utils/CommonUtils.java b/src/main/java/com/zy/common/utils/CommonUtils.java
index 9e612fe..411cc44 100644
--- a/src/main/java/com/zy/common/utils/CommonUtils.java
+++ b/src/main/java/com/zy/common/utils/CommonUtils.java
@@ -37,7 +37,11 @@
         short byteToShort = RadixTools.byteToShort(tmp1);
         byte[] tmp2 = {bytes[2], bytes[3]};
         short byteToShort2 = RadixTools.byteToShort(tmp2);
-        return new short[]{byteToShort2, byteToShort};
+        return new short[]{byteToShort, byteToShort2};
+    }
+
+    public static boolean intToBoolean(Integer num) {
+        return num != 0;
     }
 
     public static boolean shortToBoolean(Short num) {
@@ -64,4 +68,31 @@
         return sb.toString();
     }
 
+    public static int[] byteToBits(byte by) {
+        StringBuffer sb = new StringBuffer();
+        sb.append((by >> 0) & 0x1);
+        sb.append((by >> 1) & 0x1);
+        sb.append((by >> 2) & 0x1);
+        sb.append((by >> 3) & 0x1);
+        sb.append((by >> 4) & 0x1);
+        sb.append((by >> 5) & 0x1);
+        sb.append((by >> 6) & 0x1);
+        sb.append((by >> 7) & 0x1);
+
+        int[] data = new int[8];
+        for (int i = 0; i < sb.length(); i++) {
+            data[i] = Integer.parseInt(String.valueOf(sb.charAt(i)));
+        }
+
+        return data;
+    }
+
+    public static String bytesToBarcode(byte[] bytes) {
+        StringBuffer sb = new StringBuffer();
+        for (byte by : bytes) {
+            sb.append(by);
+        }
+        return sb.toString();
+    }
+
 }

--
Gitblit v1.9.1