add
yj
2024-12-05 a160d838f9c0a79dfc2f18e7cd46bdd4faa59c6d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package com.dobbinsoft.fw.core.util;
 
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicInteger;
 
/**
 * Created by rize on 2019/7/1.
 */
public class GeneratorUtil {
 
    private static AtomicInteger orderIdCount = new AtomicInteger();
 
    private static final SimpleDateFormat ORDER_ID_FORMAT = new SimpleDateFormat("yyyyMMHHmmss");
 
    public static final String genSalt() {
        return genUUId().substring(0, 7);
    }
 
    public static String genSixVerifyCode() {
        String time = System.nanoTime() + "";
        return time.substring(time.length() - 6);
    }
 
    public static String genSessionId() {
        return UUID.randomUUID().toString().replace("-","").toUpperCase();
    }
 
 
    public static String genOrderId(String machineNo, String env) {
        int i = orderIdCount.incrementAndGet() % 1000;
        if (i < 1000)
            i += 1000;
        return env + machineNo + ORDER_ID_FORMAT.format(new Date()) + i;
    }
 
    public static String genFileName(){
        return UUID.randomUUID().toString().replaceAll("-", "");
    }
 
    public static String genUUId() {
        return UUID.randomUUID().toString().replace("-", "");
    }
}