From 7635dc25bd2a4d565df496b2d96354639966768d Mon Sep 17 00:00:00 2001
From: Junjie <xjj@123>
Date: 星期四, 25 九月 2025 11:09:44 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/common/utils/CommonUtils.java | 68 ++++++++++++++++++++++++++++++++++
1 files changed, 68 insertions(+), 0 deletions(-)
diff --git a/src/main/java/com/zy/common/utils/CommonUtils.java b/src/main/java/com/zy/common/utils/CommonUtils.java
index d3233b7..411cc44 100644
--- a/src/main/java/com/zy/common/utils/CommonUtils.java
+++ b/src/main/java/com/zy/common/utils/CommonUtils.java
@@ -1,5 +1,7 @@
package com.zy.common.utils;
+import com.core.common.RadixTools;
+
import java.math.BigDecimal;
/**
@@ -27,4 +29,70 @@
}
}
+ //int杞瑂hort鏁扮粍
+ public static short[] intToShorts(int num) {
+ //鍏堝皢int杞负byte鏁扮粍锛屽啀灏哹yte鏁扮粍杞垚涓や釜short锛屽垎鍒崰鐢�4鍜�5绌洪棿
+ byte[] bytes = RadixTools.intToBytes(num);
+ byte[] tmp1 = {bytes[0], bytes[1]};
+ short byteToShort = RadixTools.byteToShort(tmp1);
+ byte[] tmp2 = {bytes[2], bytes[3]};
+ short byteToShort2 = RadixTools.byteToShort(tmp2);
+ return new short[]{byteToShort, byteToShort2};
+ }
+
+ public static boolean intToBoolean(Integer num) {
+ return num != 0;
+ }
+
+ public static boolean shortToBoolean(Short num) {
+ return num != 0;
+ }
+
+ //浠巖ow銆乥ay銆乴ev鍙傛暟鑾峰彇瀹屾暣搴撲綅鍙�
+ public static String getLocNoFromRBL(Integer row, Integer bay, Integer lev) {
+ StringBuffer sb = new StringBuffer();
+ if (row < 10) {
+ sb.append("0");
+ }
+ sb.append(row);
+ if (bay < 10) {
+ sb.append("00");
+ } else if (bay < 100) {
+ sb.append("0");
+ }
+ sb.append(bay);
+ if (lev < 10) {
+ sb.append("0");
+ }
+ sb.append(lev);
+ 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