结论:最大取数 不超过 999999999 9位
workflowInstance.setWorkflowInstanceId("WFI" + SNNoTools.getIntUUID().toString());
WFI101687200
package com.tn.mdm.workflow.tools;
/**
* 生成编号
*
* @author admin
* @date 2022-04-25
*/
public class SNNoTools {
public static synchronized Integer getIntUUID() {
Integer data = 0;
while (data <= 0) {
Integer numOne = Math.abs((int) Math.round((Math.random() * 10) * 10000000)); // [0,1)x10=个位数,个位数x7个0 <= 8位
Integer numTwo = Math.abs((int) Math.round((Math.random() * 10))); // [0,1)x10=个位数,个位数x最大8位 <= 9位
data = numOne * numTwo;
}
return data;
}
public static void main(String[] args) {
Integer data = 0;
Integer numOne = Math.abs((int) Math.round((Math.random() * 10) * 10000000));
Integer numTwo = Math.abs((int) Math.round((Math.random() * 10)));
data = numOne * numTwo;
}
}