You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.5 KiB
Java
66 lines
1.5 KiB
Java
3 years ago
|
package com.glxp.api.util;
|
||
|
|
||
|
import java.util.*;
|
||
|
|
||
|
public class CustomUtil {
|
||
|
|
||
|
public static String getUUId() {
|
||
|
UUID uuid = UUID.randomUUID();
|
||
|
return uuid.toString().replace("-", "");
|
||
|
}
|
||
|
|
||
|
//随机生成ID
|
||
|
public static String getId() {
|
||
|
String id = System.currentTimeMillis() + "";
|
||
|
int number = new Random().nextInt(90) + 10;
|
||
|
id = id + number;
|
||
|
return id.substring(1);
|
||
|
}
|
||
|
|
||
|
|
||
|
public static <T> List<List<T>> splitList(List<T> list, int len) {
|
||
|
|
||
|
if (list == null || list.isEmpty() || len < 1) {
|
||
|
return Collections.emptyList();
|
||
|
}
|
||
|
|
||
|
List<List<T>> result = new ArrayList<>();
|
||
|
|
||
|
int size = list.size();
|
||
|
int count = (size + len - 1) / len;
|
||
|
|
||
|
for (int i = 0; i < count; i++) {
|
||
|
List<T> subList = list.subList(i * len, ((i + 1) * len > size ? size : len * (i + 1)));
|
||
|
result.add(subList);
|
||
|
}
|
||
|
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
|
||
|
//随机生成往来单位ID
|
||
|
public static String getUnitId() {
|
||
|
String id = System.currentTimeMillis() + "";
|
||
|
int number = new Random().nextInt(90) + 10;
|
||
|
id = id + number;
|
||
|
return "HZ" + id.substring(4);
|
||
|
}
|
||
|
|
||
|
public static boolean isEmpty(List data) {
|
||
|
if (data == null || data.isEmpty()) {
|
||
|
return true;
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
public static boolean isNotEmpty(List data) {
|
||
|
if (data != null && !data.isEmpty()) {
|
||
|
return true;
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
}
|