Commit b4f93e832f2e1b16e163b8da010d1e36150bc192

Authored by LesanOuO
1 parent 362b872a

fix: 无时间中缀不设置Redis过期时间

yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/redis/BpmProcessIdRedisDAO.java
@@ -29,6 +29,7 @@ public class BpmProcessIdRedisDAO { @@ -29,6 +29,7 @@ public class BpmProcessIdRedisDAO {
29 public String generate(BpmModelMetaInfoVO.ProcessIdRule processIdRule) { 29 public String generate(BpmModelMetaInfoVO.ProcessIdRule processIdRule) {
30 // 生成日期前缀 30 // 生成日期前缀
31 String infix = ""; 31 String infix = "";
  32 + boolean expireEnable = true;
32 switch (processIdRule.getInfix()) { 33 switch (processIdRule.getInfix()) {
33 case "DAY": 34 case "DAY":
34 infix = DateUtil.format(LocalDateTime.now(), "yyyyMMDD"); 35 infix = DateUtil.format(LocalDateTime.now(), "yyyyMMDD");
@@ -42,13 +43,18 @@ public class BpmProcessIdRedisDAO { @@ -42,13 +43,18 @@ public class BpmProcessIdRedisDAO {
42 case "SECOND": 43 case "SECOND":
43 infix = DateUtil.format(LocalDateTime.now(), "yyyyMMDDHHmmss"); 44 infix = DateUtil.format(LocalDateTime.now(), "yyyyMMDDHHmmss");
44 break; 45 break;
  46 + default:
  47 + expireEnable = false;
  48 + break;
45 } 49 }
46 50
47 // 生成序号 51 // 生成序号
48 String noPrefix = processIdRule.getPrefix() + infix + processIdRule.getPostfix(); 52 String noPrefix = processIdRule.getPrefix() + infix + processIdRule.getPostfix();
49 String key = RedisKeyConstants.BPM_PROCESS_ID + noPrefix; 53 String key = RedisKeyConstants.BPM_PROCESS_ID + noPrefix;
50 Long no = stringRedisTemplate.opsForValue().increment(key); 54 Long no = stringRedisTemplate.opsForValue().increment(key);
51 - stringRedisTemplate.expire(key, Duration.ofDays(1L)); 55 + if (Boolean.TRUE.equals(expireEnable)) {
  56 + stringRedisTemplate.expire(key, Duration.ofDays(1L));
  57 + }
52 return noPrefix + String.format("%0" + processIdRule.getLength() + "d", no); 58 return noPrefix + String.format("%0" + processIdRule.getLength() + "d", no);
53 } 59 }
54 60