随机流水号
WFI99884958
生成流程实例随机流水号
workflowInstance.setWorkflowInstanceId("WFI" + SNNoTools.getIntUUID().toString());
工具类
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));
Integer numTwo = Math.abs((int) Math.round((Math.random() * 10)));
data = numOne * numTwo;
}
return data;
}
}
文章介绍了一个Java工具类SNNoTools,用于生成随机流水号。该类使用Math.random()函数结合乘法运算创建一个介于0和10之间的数,再将其转换为0-10000000的范围,然后与另一个0-10的随机数相乘,确保生成的ID具有唯一性。此方法应用于设置工作流实例的ID,如WFI99884958。
775

被折叠的 条评论
为什么被折叠?



