| | |
| | | |
| | | 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; |
| | | |
| | |
| | | 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); |
| | |
| | | |
| | | /** |
| | | * 截取数组 |
| | | * |
| | | * @param bytes 原数组 |
| | | * @param pos 定位(截取后包含定位点数据) |
| | | * @param len 长度 |
| | |
| | | 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; |
| | | } |
| | |
| | | |
| | | 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(); |
| | | } |
| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | 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) { |