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

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

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