web :添加问诊序列号
parent
2e89edc985
commit
f7b8440195
@ -0,0 +1,29 @@
|
|||||||
|
package com.supervision.util;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.data.redis.core.ValueOperations;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
public class SequenceUtil {
|
||||||
|
|
||||||
|
private static final RedisTemplate<String, String> redisTemplate = SpringBeanUtil.getBean("redisTemplate", RedisTemplate.class);
|
||||||
|
|
||||||
|
|
||||||
|
public static String getProcessNo(){
|
||||||
|
|
||||||
|
// 从零开始计算
|
||||||
|
long processNoSeq = getIncrement("process_no_seq") -1;
|
||||||
|
|
||||||
|
char prefix = (char) ('a' + processNoSeq / 1000000);
|
||||||
|
Long suffix = processNoSeq % 1000000;
|
||||||
|
return prefix + String.format("%06d", suffix);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Long getIncrement(String key){
|
||||||
|
ValueOperations<String, String> operations = redisTemplate.opsForValue();
|
||||||
|
return operations.increment( key,1L);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue