从List集合每次处理固定条数数据
public void dealBySubList(List sourList, int batchCount) {
int sourListSize = sourList.size();
int subCount = sourListSize % batchCount == 0 ? sourListSize / batchCount : sourListSize / batchCount + 1;
int startIndext = 0;
int stopIndext = 0;
for (int i = 0; i < subCount; i++) {
stopIndext = (i == subCount - 1) ? stopIndext + sourListSize % batchCount : stopIndext + batchCount;
List list = sourList.subList(startIndext, stopIndext);
startIndext = stopIndext;
具体逻辑处理上面的list
}
}
计算一个数字是几位数
public static int getNumLenght(Long num){
num = num>0?num:-num;
if (num==0) {
return 1;
}
return (int) Math.log10(num)+1;
}