Commit 00a496e7 authored by 刘林's avatar 刘林

fix(jg):修改使用登记作废-气瓶导入作废,修改气瓶导入

parent 91738d0d
......@@ -2768,30 +2768,25 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
@Override
public Object importPressureData(MultipartFile multipartFile) throws Exception {
List<EquipInfoCylinderExcelDto> aircraftList = new ArrayList<>();
List<String> errorList = new ArrayList<>(); // 临时错误列表,用于批量插入
List<String> innerCodeList = new ArrayList<>(); // 临时列表
List<String> codeList = new ArrayList<>();
List<String> factoryList = new ArrayList<>();
resultError.clear();
useInnerCodeList.clear();
equCodeList.clear();
factoryNumList.clear();
try {
EasyExcel.read(multipartFile.getInputStream(), EquipInfoCylinderExcelDto.class, new AnalysisEventListener<EquipInfoCylinderExcelDto>() {
// 每读取一行时调用
// 每读取一行就调用该方法
@Override
public void invoke(EquipInfoCylinderExcelDto data, AnalysisContext context) {
// 直接操作原数据,避免不必要的对象复制
errorList.add(checkExcelData(data, context).toString());
aircraftList.add(data); // 直接加入原对象,而不是复制
innerCodeList.add(data.getUseInnerCode());
codeList.add(data.getEquCode());
factoryList.add("0".equals(data.getWhetherVehicleCylinder()) ? data.getFactoryNum() : null);
EquipInfoCylinderExcelDto fireExperts = new EquipInfoCylinderExcelDto();
BeanUtils.copyProperties(data, fireExperts);
resultError.add(checkExcelData(data, context).toString());
aircraftList.add(fireExperts);
useInnerCodeList.add(data.getUseInnerCode());
equCodeList.add(data.getEquCode());
factoryNumList.add("0".equals(data.getWhetherVehicleCylinder()) ? data.getFactoryNum() : null);
}
// 全部读取完成后调用
// 全部读取完成就调用该方法
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
if (CollectionUtils.isEmpty(aircraftList)) {
......@@ -2799,23 +2794,13 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
resultError.add("你上传了一个空数据的Excel文档!");
throw new BadRequest("你上传了一个空数据的Excel文档!");
}
// 批量添加,减少集合操作的次数
resultError.addAll(errorList);
useInnerCodeList.addAll(innerCodeList);
equCodeList.addAll(codeList);
factoryNumList.addAll(factoryList);
}
}).headRowNumber(4).sheet().doRead();
// 检查错误
if (resultError.stream().anyMatch(input -> !input.isEmpty())) {
throw new BadRequest("上传失败!");
}
return aircraftList;
} catch (Exception e) {
// 处理并抛出所有错误
throw new Exception(resultError.stream()
.filter(s -> !s.isEmpty())
.collect(Collectors.joining("<br/>")));
......@@ -2874,47 +2859,51 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
String key = useRegistrationCode.length() >= 5 ? useRegistrationCode.substring(0, 5) : useRegistrationCode;
List<String> prefixes = Collections.unmodifiableList(Arrays.asList("容", "锅", "管", "瓶", "梯", "起", "索", "游", "车"));
//容15鲁G00302(12)
if (useRegistrationCode.length() == 14 && prefixes.stream().anyMatch(key::startsWith) && redisUtils.hasKey(useRegistrationCode.substring(0, 5))) {
String prefix = useRegistrationCode.substring(0, 3);
// 如果 prefix 不等于 "瓶31" 或 "瓶32" 则继续执行逻辑
ValueOperations<String, String> valueOps = redisTemplate.opsForValue();
String currentSequenceStr = valueOps.get(key);
if (Stream.of("瓶31", "瓶32").noneMatch(prefix::equals) && currentSequenceStr != null) {
String extractedValue = useRegistrationCode.substring(5, 10);
String extractedYearStr = useRegistrationCode.substring(useRegistrationCode.indexOf('(') + 1, useRegistrationCode.indexOf(')'));
int currentYearLastTwoDigits = LocalDate.now().getYear() % 100;
try {
// 提取年份
int extractedYear = Integer.parseInt(extractedYearStr);
if(currentYearLastTwoDigits == extractedYear){
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 (useRegistrationCode.length() == 14 && prefixes.stream().anyMatch(key::startsWith)) {
if (redisUtils.hasKey(useRegistrationCode.substring(0, 5))){
String prefix = useRegistrationCode.substring(0, 3);
// 如果 prefix 不等于 "瓶31" 或 "瓶32" 则继续执行逻辑
ValueOperations<String, String> valueOps = redisTemplate.opsForValue();
String currentSequenceStr = valueOps.get(key);
if (Stream.of("瓶31", "瓶32").noneMatch(prefix::equals) && currentSequenceStr != null) {
String extractedValue = useRegistrationCode.substring(5, 10);
String extractedYearStr = useRegistrationCode.substring(useRegistrationCode.indexOf('(') + 1, useRegistrationCode.indexOf(')'));
int currentYearLastTwoDigits = LocalDate.now().getYear() % 100;
try {
// 提取年份
int extractedYear = Integer.parseInt(extractedYearStr);
if(currentYearLastTwoDigits == extractedYear){
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("登记证编号不能使用系统还未生成编号!");
// 比较字母和数字
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("数据格式错误");
}
} catch (NumberFormatException e) {
throw new BadRequest("数据格式错误");
}
} else {
throw new BadRequest("登记证编号不能使用系统还未生成编号!");
}
}
}
......
......@@ -2441,6 +2441,8 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
superviseInfoMapper.deleteDataAll(records);
//删除es中的数据
esEquipmentCategory.deleteAll(esDtoList);
//作废使用登记证 & 生成使用登记证的流水
this.invalidUseRegistrationCertificate(jgUseRegistration);
}else{
// 处理非批量导入数据,更新关联业务状态
processElseDataByStatus(oldStatus, jgUseRegistration);
......
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