广州市综治平台后端
xusd
2 days ago c490640493f04e2ed0fc5c4c8fbc92ebdd4d5380
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package cn.huge.module.mediate.utils;
 
import java.text.SimpleDateFormat;
import java.util.Date;
 
/**
 * @title: 公共ID生成工具
 * @description: 公共ID生成工具
 * @company: hugeinfo
 * @author: liyj
 * @time: 2021-11-05 16:51:48
 * @version: 1.0.0
 */
public class MediateIdUtils {
 
    /**
     * 时间Id统计常量
     */
    private static int COUNT_NUM = 1000;
 
    /**
     * 时间Id统计常量,常量前缀
     */
    private static int SIGN_COUNT_NUM = 1000;
 
    /**
     * 时间Id统计常量,常量后缀
     */
    private static int COUNT_NUM_SIGN = 1000;
 
    /**
     * 获取时间Id,后四位常量
     * @return String
     */
    public synchronized static String getNewTimeId(){
        String  timeId = getNowTime() + (COUNT_NUM++);
        if(COUNT_NUM > 9999){
            COUNT_NUM = 1000;
        }
        timeId=timeId.substring(2, timeId.length());
        return timeId;
    }
 
    /**
     * 获取时间Id,常量前缀
     * @param sign 常量前缀
     * @return String
     */
    public synchronized static String getSignNewTimeId(String sign){
        String  timeId = getNowTime() + sign + (SIGN_COUNT_NUM++);
        if(SIGN_COUNT_NUM > 9999){
            SIGN_COUNT_NUM = 1000;
        }
        timeId=timeId.substring(2, timeId.length());
        return timeId;
    }
 
    /**
     * 获取带有后缀的时间Id,常量后缀
     * @param sign 常量后缀
     * @return String
     */
    public synchronized static String getNewTimeIdSign(String sign){
        String timeId = getNowTime() + (COUNT_NUM_SIGN++) + sign;
        if(COUNT_NUM_SIGN > 9999){
            COUNT_NUM_SIGN = 1000;
        }
        timeId=timeId.substring(2, timeId.length());
        return timeId;
    }
 
    /**
     * 获取时间Id,后四位常量
     * @return String
     */
    public synchronized static String getNowTime(){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
        String nowTime = sdf.format(new Date());
        return nowTime;
    }
}
/**
 * -------------------_ooOoo_-------------------
 * ------------------o8888888o------------------
 * ------------------88" . "88------------------
 * ------------------(| -_- |)------------------
 * ------------------O\  =  /O------------------
 * ---------------____/`---'\____---------------
 * -------------.'  \\|     |//  `.-------------
 * ------------/  \\|||  :  |||//  \------------
 * -----------/  _||||| -:- |||||-  \-----------
 * -----------|   | \\\  -  /// |   |-----------
 * -----------| \_|  ''\---/''  |   |-----------
 * -----------\  .-\__  `-`  ___/-. /-----------
 * ---------___`. .'  /--.--\  `. . __----------
 * ------."" '<  `.___\_<|>_/___.'  >'"".-------
 * -----| | :  `- \`.;`\ _ /`;.`/ - ` : | |-----
 * -----\  \ `-.   \_ __\ /__ _/   .-` /  /-----
 * ======`-.____`-.___\_____/___.-`____.-'======
 * -------------------`=---='
 * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 * ---------佛祖保佑---hugeinfo---永无BUG----------
 */