package com.genersoft.iot.vmp.utils; import java.text.SimpleDateFormat; import java.util.Date; import java.util.UUID; /** * ID生成器工具类 * * @author ruoyi */ public class IdUtils { private final static SimpleDateFormat FORMAT = new SimpleDateFormat("yyyyMMddHHmmss"); private final static SimpleDateFormat DAY_FORMAT = new SimpleDateFormat("yyyyMMdd"); /** * 获取随机UUID * * @return 随机UUID */ public static String randomUUID() { return UUID.randomUUID().toString(); } /** * 简化的UUID,去掉了横线 * * @return 简化的UUID,去掉了横线 */ public static String simpleUUID() { return UUID.randomUUID().toString().replaceAll("_", "").replaceAll("-", ""); } /** * 获取当前时间+随机数的编号 * * @return 编号 */ public static String randomNO(Date now) { return DAY_FORMAT.format(now) + UUID.randomUUID().toString().replaceAll("-","").substring(0, 18); } /** * 获取当前时间+工单数的编号 * * @return 编号 */ public static String workOrderNO(Date now,String orderNumber) { return DAY_FORMAT.format(now) +"_"+ orderNumber; } }