From ff2b6e2329ae2c5d3fede2f9413170fd6e87c46c Mon Sep 17 00:00:00 2001 From: Junjie <540245094@qq.com> Date: 星期五, 08 十二月 2023 09:27:52 +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