mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
1、收支明细流水号生成方式修正,新增yyyyMMddHHmmss+7位顺序号的流水号的公用生成方式;2、管理端分析页组织总数/用户总数/用户活跃数迁移到system;3、组织管理查询首购记录不展示问题恢复;
This commit is contained in:
+4
@@ -22,4 +22,8 @@ public class MinuteCounter {
|
||||
atom.set(newValue & MASK);
|
||||
}
|
||||
|
||||
public boolean compareAndSet(int expect, int update) {
|
||||
return atom.compareAndSet(expect, update & MASK);
|
||||
}
|
||||
|
||||
}
|
||||
+39
@@ -4,6 +4,9 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
/**
|
||||
* @ClassName: SnowflakeIdWorker3rd
|
||||
@@ -36,6 +39,10 @@ public class SnowflakeIdWorker3rd {
|
||||
private final MinuteCounter counter = new MinuteCounter();
|
||||
/** 预支时间标志 */
|
||||
boolean isAdvance = false;
|
||||
/** 时间格式 */
|
||||
private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyMMddHHmmss");
|
||||
/** 上次时间格式 */
|
||||
private final AtomicReference<String> lastTimestampStr = new AtomicReference<>("");
|
||||
|
||||
// ==============================Constructors=====================================
|
||||
|
||||
@@ -127,4 +134,36 @@ public class SnowflakeIdWorker3rd {
|
||||
return Integer.valueOf(timestamp);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取下一个流水号
|
||||
*
|
||||
* @return SerialNo
|
||||
*/
|
||||
public String nextSerialNo() {
|
||||
String now = LocalDateTime.now().format(FORMATTER);
|
||||
|
||||
// 跨秒重置序列号
|
||||
String last = lastTimestampStr.get();
|
||||
if (!now.equals(last)) {
|
||||
// 仅在跨秒时重置序列号
|
||||
if (lastTimestampStr.compareAndSet(last, now)) {
|
||||
counter.set(0);
|
||||
}
|
||||
}
|
||||
|
||||
// 原子递增序列号
|
||||
int seq = counter.incrementAndGet();
|
||||
|
||||
// 序列号100000(5位)以内
|
||||
if (seq > 9999) {
|
||||
if (counter.compareAndSet(seq, 1)) {
|
||||
seq = 1;
|
||||
} else {
|
||||
seq = counter.incrementAndGet();
|
||||
}
|
||||
}
|
||||
|
||||
// 拼接时间 + 序列号
|
||||
return String.format("%s%05d", now, seq);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user