package com.tcctlo.law; import cn.hutool.core.util.IdUtil; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; import java.text.SimpleDateFormat; import java.util.Date; @SpringBootTest(classes = LawApplication.class) public class LawApplicationTest { @Test public void caseNo() { // 获取当前日期和时间(精确到秒) SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss"); String currentDateTime = dateFormat.format(new Date()); // 生成4位随机数 String strRandom = IdUtil.fastSimpleUUID(); // 组合成订单编号 String orderNumber = currentDateTime + "-" + strRandom; // 输出订单编号 System.out.println("生成的订单编号为: " + orderNumber); } }