1
zhang
1 天以前 e9cc2b361b5788c5e7aac0af3fe53031a76a6787
zy-acs-common/src/main/java/com/zy/acs/common/utils/Utils.java
@@ -2,10 +2,7 @@
import com.zy.acs.framework.common.Cools;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Optional;
import java.util.*;
import java.util.function.BiConsumer;
import java.util.function.Function;
@@ -37,7 +34,7 @@
            if (parentId.equals(dParentId)) {
                R dId = idMapper.apply(d);
                List<T> children = toTreeData(data, dId, parentIdMapper, idMapper, consumer);
                if(!children.isEmpty()) {
                if (!children.isEmpty()) {
                    consumer.accept(d, children);
                }
                result.add(d);
@@ -76,6 +73,7 @@
    /**
     * 截取数组
     *
     * @param bytes 原数组
     * @param pos   定位(截取后包含定位点数据)
     * @param len   长度
@@ -120,7 +118,7 @@
                idx += bytes.length;
            }
            if (object instanceof Byte) {
                byte[] bytes = new byte[] {(Byte) object};
                byte[] bytes = new byte[]{(Byte) object};
                System.arraycopy(bytes, 0, arr, idx, bytes.length);
                idx += bytes.length;
            }
@@ -143,14 +141,14 @@
    public static String zeroFill(String msg, Integer len) {
        len = Optional.ofNullable(len).orElse(16);
        if (msg.length() == len){
        if (msg.length() == len) {
            return msg;
        } else if (msg.length() > len){
        } else if (msg.length() > len) {
            return msg.substring(0, 16);
        } else {
            StringBuilder msgBuilder = new StringBuilder(msg);
            for (int i = 0; i<len-msg.length(); i++){
                msgBuilder.insert(0,"0");
            for (int i = 0; i < len - msg.length(); i++) {
                msgBuilder.insert(0, "0");
            }
            return msgBuilder.toString();
        }
@@ -187,7 +185,7 @@
            int length = str.length();
            StringBuilder sb = new StringBuilder();
            for(int i = 0; i < length; ++i) {
            for (int i = 0; i < length; ++i) {
                char c = str.charAt(i);
                if (Character.isUpperCase(c)) {
                    Character preChar = i > 0 ? str.charAt(i - 1) : null;
@@ -228,7 +226,7 @@
                StringBuilder sb = new StringBuilder(length);
                boolean upperCase = false;
                for(int i = 0; i < length; ++i) {
                for (int i = 0; i < length; ++i) {
                    char c = name2.charAt(i);
                    if (c == '_') {
                        upperCase = true;
@@ -258,15 +256,29 @@
        if (Cools.isEmpty(lastSeqNum)) {
            return zeroFill("1", 4);
        } else {
            int i = Integer.parseInt(lastSeqNum);
            if (i >= 9999) {
                return zeroFill("1", 4);
            if (isNumericZidai(lastSeqNum)) {
                int i = Integer.parseInt(lastSeqNum);
                if (i >= 9999) {
                    return zeroFill("1", 4);
                } else {
                    return zeroFill(String.valueOf(i + 1), 4);
                }
            } else {
                return zeroFill(String.valueOf(i+1), 4);
                return zeroFill(new Random().nextInt(1000000) + "", 6);
            }
        }
    }
    public static boolean isNumericZidai(String str) {
        for (int i = 0; i < str.length(); i++) {
            if (!Character.isDigit(str.charAt(i))) {
                return false;
            }
        }
        return true;
    }
    // pos start in 0
    public static boolean getBit(byte b, int position) {
        if (position < 0 || position > 7) {