mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-06-19 22:59:46 +08:00
update 生成桩号缓存
This commit is contained in:
@@ -283,6 +283,18 @@ public class SpringBootTestController {
|
|||||||
System.out.println(JSON.toJSONString(list));
|
System.out.println(JSON.toJSONString(list));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGeneratePileSn() {
|
||||||
|
// String key = CacheConstants.PILE_SN_GENERATE_KEY + "88";
|
||||||
|
// redisCache.setCacheObject(key, null);
|
||||||
|
// Long pileNum = redisCache.getCacheLong(key);
|
||||||
|
// System.out.println(pileNum);
|
||||||
|
|
||||||
|
snUtils.getPileSn("88");
|
||||||
|
// List<String> list = snUtils.generateSN(2);
|
||||||
|
// System.out.println(list);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGenerateOccupyPileOrder() {
|
public void testGenerateOccupyPileOrder() {
|
||||||
String memberId = "67569684";
|
String memberId = "67569684";
|
||||||
|
|||||||
@@ -168,6 +168,9 @@ public class RedisCache {
|
|||||||
public Long getCacheLong(final String key) {
|
public Long getCacheLong(final String key) {
|
||||||
Long l = null;
|
Long l = null;
|
||||||
Object cacheObject = getCacheObject(key);
|
Object cacheObject = getCacheObject(key);
|
||||||
|
if (Objects.isNull(cacheObject)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
if (cacheObject instanceof Integer) {
|
if (cacheObject instanceof Integer) {
|
||||||
l = ((Integer) cacheObject).longValue();
|
l = ((Integer) cacheObject).longValue();
|
||||||
} else if (cacheObject instanceof Long) {
|
} else if (cacheObject instanceof Long) {
|
||||||
|
|||||||
@@ -36,20 +36,22 @@ public class SnUtils {
|
|||||||
* @param prefix 生成序列号的前缀
|
* @param prefix 生成序列号的前缀
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private String getPileSn(String prefix) {
|
public String getPileSn(String prefix) {
|
||||||
//序列号前缀加特定标识,如系统模块名之类的 防止重复
|
//序列号前缀加特定标识,如系统模块名之类的 防止重复
|
||||||
String key = CacheConstants.PILE_SN_GENERATE_KEY + prefix;
|
String key = CacheConstants.PILE_SN_GENERATE_KEY + prefix;
|
||||||
String increResult = null;
|
String increResult = null;
|
||||||
try {
|
try {
|
||||||
String pileNum = redisCache.getCacheObject(key);
|
// 取缓存
|
||||||
if (StringUtils.isBlank(pileNum)) {
|
Integer pileNum = redisCache.getCacheObject(key);
|
||||||
|
if (pileNum == null) {
|
||||||
// 缓存中没有,从数据库中取
|
// 缓存中没有,从数据库中取
|
||||||
PileBasicInfo pileInfo = pileBasicInfoService.getMaxNumPileInfo();
|
PileBasicInfo pileInfo = pileBasicInfoService.getMaxNumPileInfo();
|
||||||
String pileSn = pileInfo.getSn();
|
String pileSn = pileInfo.getSn();
|
||||||
// 将前四位截取,并将后面转为long
|
// 将前四位截取,并将后面转为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);
|
Long increNum = redisCache.increment(key, 1);
|
||||||
@@ -64,11 +66,13 @@ public class SnUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
String pileSn = "88230000002060";
|
// String pileSn = "88230000002060";
|
||||||
String substring = StringUtils.substring(pileSn, 4, pileSn.length());
|
// String substring = StringUtils.substring(pileSn, 4, pileSn.length());
|
||||||
long l = Long.parseLong(substring);
|
// long l = Long.parseLong(substring);
|
||||||
System.out.println(substring);
|
// System.out.println(substring);
|
||||||
System.out.println(l);
|
// System.out.println(l);
|
||||||
|
|
||||||
|
Long a = 3147483647L;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -402,9 +402,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
|
|
||||||
<select id="getMaxNumPileInfo" resultMap="PileBasicInfoResult">
|
<select id="getMaxNumPileInfo" resultMap="PileBasicInfoResult">
|
||||||
select
|
select
|
||||||
max(id),
|
id,
|
||||||
sn
|
sn
|
||||||
from
|
from
|
||||||
pile_basic_info
|
pile_basic_info
|
||||||
|
order by
|
||||||
|
id desc
|
||||||
|
limit 1
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user