Commit 0f04e559 authored by tianbo's avatar tianbo

feat(ymt): 生成监码时支持自定义起始序列号

- 在 EquipmentCategoryServiceImpl 中添加 startCode 属性,用于配置起始序列号 - 修改生成监码逻辑,支持使用配置的起始序列号 - 在 GenerateCodeServiceImpl 中添加 SUPERVISOR_SEQUENCE_TYPE 常量,用于生成监码序列
parent 4df63d57
...@@ -273,6 +273,11 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -273,6 +273,11 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
private ESElavtorRepository esElavtorRepository; private ESElavtorRepository esElavtorRepository;
@Value("${regulator.unit.code}") @Value("${regulator.unit.code}")
private String code; private String code;
// 仅测试时使用该起始序列号,默认为空。正式环境不配置该属性时使用枚举里的值
@Value("${ymt.createCode.96333.startCode:}")
private String startCode;
@Autowired @Autowired
private RedisUtils redisUtils; private RedisUtils redisUtils;
// 一码通checkCode中redis key过期时间 // 一码通checkCode中redis key过期时间
...@@ -718,7 +723,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -718,7 +723,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
} }
log.info("生成码成功"); log.info("生成码成功");
SupervisoryCodeInfo supervisoryCodeInfo = new SupervisoryCodeInfo(); SupervisoryCodeInfo supervisoryCodeInfo = new SupervisoryCodeInfo();
SupervisoryCodeInfo selectOne = supervisoryCodeInfoMapper.selectOne(new QueryWrapper<SupervisoryCodeInfo>().eq("supervisory_code", supervisionCode)); SupervisoryCodeInfo selectOne = supervisoryCodeInfoMapper.selectOne(new QueryWrapper<SupervisoryCodeInfo>().eq("supervisory_code", supervisorCode.toString()));
// 将生成的码添加到码表中,码的使用状态为初始状态 // 将生成的码添加到码表中,码的使用状态为初始状态
String equState = EquipmentCategoryEnum.CSZT.getCode(); String equState = EquipmentCategoryEnum.CSZT.getCode();
supervisoryCodeInfo.setCode96333(String.valueOf(elevatorCode)); supervisoryCodeInfo.setCode96333(String.valueOf(elevatorCode));
...@@ -882,7 +887,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -882,7 +887,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
if (!ObjectUtils.isEmpty(elevatorOtherInfo) && elevatorOtherInfo.getCode() != null) { if (!ObjectUtils.isEmpty(elevatorOtherInfo) && elevatorOtherInfo.getCode() != null) {
StopWatch stopWatch = new StopWatch(); StopWatch stopWatch = new StopWatch();
stopWatch.start(); stopWatch.start();
Integer start = Integer.valueOf(prefix + EquipmentCategoryEnum.getCode.get(prefix)); Integer start = Integer.valueOf(prefix + (ValidationUtil.isEmpty(startCode) ? EquipmentCategoryEnum.getCode.get(prefix) : startCode));
Integer end = Integer.valueOf(elevatorOtherInfo.getCode()); Integer end = Integer.valueOf(elevatorOtherInfo.getCode());
// List<Integer> allCodeList = IntStream.rangeClosed(start, end) // List<Integer> allCodeList = IntStream.rangeClosed(start, end)
// .boxed() // .boxed()
......
...@@ -35,6 +35,8 @@ public class GenerateCodeServiceImpl implements IGenerateCodeService { ...@@ -35,6 +35,8 @@ public class GenerateCodeServiceImpl implements IGenerateCodeService {
private static final String LOCK_KEY_SUPERVISORY = "sequence_lock_supervisory"; private static final String LOCK_KEY_SUPERVISORY = "sequence_lock_supervisory";
private static final String SEQUENCE_TYPE_UR = "%05d"; private static final String SEQUENCE_TYPE_UR = "%05d";
private static final String SEQUENCE_TYPE = "%08d"; private static final String SEQUENCE_TYPE = "%08d";
private static final String SUPERVISOR_SEQUENCE_TYPE = "%07d";
private final RedisTemplate<String, String> redisTemplate; private final RedisTemplate<String, String> redisTemplate;
private final StringRedisTemplate stringRedisTemplate; private final StringRedisTemplate stringRedisTemplate;
private final CategoryOtherInfoMapper categoryOtherInfoMapper; private final CategoryOtherInfoMapper categoryOtherInfoMapper;
...@@ -128,7 +130,7 @@ public class GenerateCodeServiceImpl implements IGenerateCodeService { ...@@ -128,7 +130,7 @@ public class GenerateCodeServiceImpl implements IGenerateCodeService {
log.info("===================>获取《{}》当前顺序码:{}<===================", sequenceKey, currentSequenceStr); log.info("===================>获取《{}》当前顺序码:{}<===================", sequenceKey, currentSequenceStr);
currentSequence++; currentSequence++;
// 生成顺序码 // 生成顺序码
String formattedSequence = String.format(GenerateCodeServiceImpl.SEQUENCE_TYPE, currentSequence); String formattedSequence = String.format(GenerateCodeServiceImpl.SUPERVISOR_SEQUENCE_TYPE, currentSequence);
log.info("===================>更新《{}》顺序码:{}<===================", sequenceKey, formattedSequence); log.info("===================>更新《{}》顺序码:{}<===================", sequenceKey, formattedSequence);
// 更新顺序码 // 更新顺序码
valueOps.set(sequenceKey, formattedSequence); valueOps.set(sequenceKey, formattedSequence);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment