Commit 1dae78ae authored by 刘林's avatar 刘林

fix(jg):监管业务系统,历史设备登记时,使用登记证编号校验规则未校验台套设备历史登记和车用气瓶历史登记

parent 55fddbff
...@@ -2853,60 +2853,9 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste ...@@ -2853,60 +2853,9 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
} }
if ("his".equals(equipInfoDto.getDataSource())) { if ("his".equals(equipInfoDto.getDataSource())) {
String useRegistrationCode = equipInfoDto.getUseOrgCode();
//使用登记证编号判断是否使用未来系统生成编号 //使用登记证编号判断是否使用未来系统生成编号
String key = useRegistrationCode.length() >= 5 ? useRegistrationCode.substring(0, 5) : useRegistrationCode; this.checkUseRegistrationCode(equipInfoDto.getUseOrgCode(), "cylinder");
List<String> prefixes = Collections.unmodifiableList(Arrays.asList("容", "锅", "管", "瓶", "梯", "起", "索", "游", "车"));
//容15鲁G00302(12)
if (useRegistrationCode.length() == 14 && prefixes.stream().anyMatch(key::startsWith)) {
// 如果 prefix 不等于 "瓶31" 或 "瓶32" 则继续执行逻辑
ValueOperations<String, String> valueOps = redisTemplate.opsForValue();
String currentSequenceStr = valueOps.get(key);
String extractedValue = useRegistrationCode.substring(5, 10);
String extractedYearStr = useRegistrationCode.substring(useRegistrationCode.indexOf('(') + 1, useRegistrationCode.indexOf(')'));
int currentYearLastTwoDigits = LocalDate.now().getYear() % 100;
// 提取年份
int extractedYear = Integer.parseInt(extractedYearStr);
if (currentYearLastTwoDigits == extractedYear) {
if (redisUtils.hasKey(useRegistrationCode.substring(0, 5))) {
String prefix = useRegistrationCode.substring(0, 3);
if (Stream.of("瓶31", "瓶32").noneMatch(prefix::equals) && currentSequenceStr != null) {
try {
if (Character.isLetter(extractedValue.charAt(0))) {
// 提取字母部分并比较
char extractedLetter = extractedValue.charAt(0);
int extractedNumber = Integer.parseInt(extractedValue.substring(1)); // 提取数字部分
// 提取 Redis 中的字母和数字部分
char redisLetter = currentSequenceStr.charAt(0);
//redis中不是字母开头,输入的是字母开头
if (!Character.isLetter(redisLetter)) {
throw new BadRequest("登记证编号不能使用系统还未生成编号!");
}
int redisNumber = Integer.parseInt(currentSequenceStr.substring(1));
// 比较字母和数字
if ((extractedLetter > redisLetter || (extractedLetter == redisLetter && extractedNumber > redisNumber))) {
throw new BadRequest("登记证编号不能使用系统还未生成编号!");
}
} else {
// 如果首字符不是字母,直接进行字符串比较
if (extractedValue.compareTo(currentSequenceStr) > 0) {
throw new BadRequest("登记证编号不能使用系统还未生成编号!");
}
}
} catch (NumberFormatException e) {
throw new BadRequest("数据格式错误");
}
}
} else {
throw new BadRequest("登记证编号不能使用系统还未生成编号!");
}
}
} }
}
String record = UUID.randomUUID().toString(); String record = UUID.randomUUID().toString();
jgRelationEquip.setEquId(record); jgRelationEquip.setEquId(record);
jgRelationEquip.setSequenceNbr(sequence.nextId()); jgRelationEquip.setSequenceNbr(sequence.nextId());
...@@ -3169,6 +3118,70 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste ...@@ -3169,6 +3118,70 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
return String.format("导入完成,成功导入: %d 条数据!", useInfoList.size()); return String.format("导入完成,成功导入: %d 条数据!", useInfoList.size());
} }
/**
* 使用登记证编号判断是否使用未来系统生成编号
* @param useRegistrationCode 使用登记证编号
* @param regType 历史登记类别(台套set,车用vehicle,气瓶Cylinder)
*/
public void checkUseRegistrationCode(String useRegistrationCode, String regType) {
// 使用登记证编号判断是否使用未来系统生成编号
String key = useRegistrationCode.length() >= 5 ? useRegistrationCode.substring(0, 5) : useRegistrationCode;
List<String> prefixes = Collections.unmodifiableList(Arrays.asList("容", "锅", "管", "瓶", "梯", "起", "索", "游", "车"));
if (useRegistrationCode.length() == 14 && prefixes.stream().anyMatch(key::startsWith)) {
// 如果 prefix 不等于 "瓶31" 或 "瓶32" 则继续执行逻辑
ValueOperations<String, String> valueOps = redisTemplate.opsForValue();
String currentSequenceStr = valueOps.get(key);
String extractedValue = useRegistrationCode.substring(5, 10);
String extractedYearStr = useRegistrationCode.substring(useRegistrationCode.indexOf('(') + 1, useRegistrationCode.indexOf(')'));
int currentYearLastTwoDigits = LocalDate.now().getYear() % 100;
// 提取年份
int extractedYear = Integer.parseInt(extractedYearStr);
if (currentYearLastTwoDigits == extractedYear) {
if (redisUtils.hasKey(useRegistrationCode.substring(0, 5))) {
String prefix = useRegistrationCode.substring(0, 3);
// 检查regType是否为Cylinder,如果是,才执行"瓶31" 和 "瓶32" 的条件判断
if (!"cylinder".equals(regType) || Stream.of("瓶31", "瓶32").noneMatch(prefix::equals)) {
if (currentSequenceStr != null) {
try {
if (Character.isLetter(extractedValue.charAt(0))) {
// 提取字母部分并比较
char extractedLetter = extractedValue.charAt(0);
int extractedNumber = Integer.parseInt(extractedValue.substring(1)); // 提取数字部分
// 提取 Redis 中的字母和数字部分
char redisLetter = currentSequenceStr.charAt(0);
// redis中不是字母开头,输入的是字母开头
if (!Character.isLetter(redisLetter)) {
throw new BadRequest("登记证编号不能使用系统还未生成编号!");
}
int redisNumber = Integer.parseInt(currentSequenceStr.substring(1));
// 比较字母和数字
if ((extractedLetter > redisLetter || (extractedLetter == redisLetter && extractedNumber > redisNumber))) {
throw new BadRequest("登记证编号不能使用系统还未生成编号!");
}
} else {
// 如果首字符不是字母,直接进行字符串比较
if (extractedValue.compareTo(currentSequenceStr) > 0) {
throw new BadRequest("登记证编号不能使用系统还未生成编号!");
}
}
} catch (NumberFormatException e) {
throw new BadRequest("数据格式错误");
}
}
}
} else {
throw new BadRequest("登记证编号不能使用系统还未生成编号!");
}
}
}
}
public void updateHistory(JSONObject map, String currentDocumentId) { public void updateHistory(JSONObject map, String currentDocumentId) {
JgRegistrationHistory jgRegistrationHistory = new JgRegistrationHistory(); JgRegistrationHistory jgRegistrationHistory = new JgRegistrationHistory();
LambdaQueryWrapper<JgRegistrationHistory> lambda = new QueryWrapper<JgRegistrationHistory>().lambda(); LambdaQueryWrapper<JgRegistrationHistory> lambda = new QueryWrapper<JgRegistrationHistory>().lambda();
......
...@@ -2807,6 +2807,8 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD ...@@ -2807,6 +2807,8 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
if (used){ if (used){
throw new BadRequest("使用登记证编号已存在!"); throw new BadRequest("使用登记证编号已存在!");
} }
//使用登记证编号判断是否使用未来系统生成编号
idxBizJgRegisterInfoService.checkUseRegistrationCode(useRegistrationCode, "set");
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class); ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
CompanyBo company = reginParams.getCompany(); CompanyBo company = reginParams.getCompany();
......
...@@ -1744,6 +1744,8 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform ...@@ -1744,6 +1744,8 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
if (used){ if (used){
throw new BadRequest("使用登记证编号已存在!"); throw new BadRequest("使用登记证编号已存在!");
} }
//使用登记证编号判断是否使用未来系统生成编号
idxBizJgRegisterInfoService.checkUseRegistrationCode(useRegistrationCode1,"vehicle");
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())) + "", ReginParams.class); ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())) + "", ReginParams.class);
JgVehicleInformationDto vehicleInfoDto = JSON.parseObject(JSON.toJSONString(map), JgVehicleInformationDto.class); JgVehicleInformationDto vehicleInfoDto = JSON.parseObject(JSON.toJSONString(map), JgVehicleInformationDto.class);
......
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