mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 11:05:18 +08:00
update 生成桩号缓存
This commit is contained in:
@@ -36,20 +36,22 @@ public class SnUtils {
|
||||
* @param prefix 生成序列号的前缀
|
||||
* @return
|
||||
*/
|
||||
private String getPileSn(String prefix) {
|
||||
public String getPileSn(String prefix) {
|
||||
//序列号前缀加特定标识,如系统模块名之类的 防止重复
|
||||
String key = CacheConstants.PILE_SN_GENERATE_KEY + prefix;
|
||||
String increResult = null;
|
||||
try {
|
||||
String pileNum = redisCache.getCacheObject(key);
|
||||
if (StringUtils.isBlank(pileNum)) {
|
||||
// 取缓存
|
||||
Integer pileNum = redisCache.getCacheObject(key);
|
||||
if (pileNum == null) {
|
||||
// 缓存中没有,从数据库中取
|
||||
PileBasicInfo pileInfo = pileBasicInfoService.getMaxNumPileInfo();
|
||||
String pileSn = pileInfo.getSn();
|
||||
// 将前四位截取,并将后面转为long
|
||||
long pileSnNum = Long.parseLong(StringUtils.substring(pileSn, 4, pileSn.length()));
|
||||
Long pileSnNum = Long.parseLong(StringUtils.substring(pileSn, 4, pileSn.length()));
|
||||
// String pileSnNum = StringUtils.substring(pileSn, 4, pileSn.length());
|
||||
// 再将该值存入数据库
|
||||
redisCache.setCacheObject(key, pileSnNum);
|
||||
redisCache.setCacheObject(key, pileSnNum.intValue());
|
||||
|
||||
}
|
||||
Long increNum = redisCache.increment(key, 1);
|
||||
@@ -64,11 +66,13 @@ public class SnUtils {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String pileSn = "88230000002060";
|
||||
String substring = StringUtils.substring(pileSn, 4, pileSn.length());
|
||||
long l = Long.parseLong(substring);
|
||||
System.out.println(substring);
|
||||
System.out.println(l);
|
||||
// String pileSn = "88230000002060";
|
||||
// String substring = StringUtils.substring(pileSn, 4, pileSn.length());
|
||||
// long l = Long.parseLong(substring);
|
||||
// System.out.println(substring);
|
||||
// System.out.println(l);
|
||||
|
||||
Long a = 3147483647L;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user