|
|
@@ -206,19 +206,9 @@ public class BlindStructuresServiceImpl implements IBlindStructuresService {
|
|
|
validEntityBeforeSave(update);
|
|
|
Long userId = LoginHelper.getUserId();
|
|
|
update.setUpdateUserId(userId);
|
|
|
- // 2. 更新主表
|
|
|
- int i = baseMapper.updateBlindStructuresById(update);
|
|
|
- if (i <= 0) {
|
|
|
- return R.fail("更新失败");
|
|
|
- }
|
|
|
|
|
|
- // 3. 删除原有等级数据
|
|
|
- Boolean b = blindLevelsService.deleteBlindLevelByBlindStructureId(update.getId());
|
|
|
- if (!b) {
|
|
|
- return R.fail("删除历史等级失败");
|
|
|
- }
|
|
|
|
|
|
- // 4. 解析 Excel 文件
|
|
|
+ // 1. 解析 Excel 文件
|
|
|
List<BlindLevelsImportVo> dataList;
|
|
|
try (InputStream inputStream = file.getInputStream()) {
|
|
|
dataList = parseExcel(inputStream);
|
|
|
@@ -231,6 +221,27 @@ public class BlindStructuresServiceImpl implements IBlindStructuresService {
|
|
|
return R.fail("导入数据为空");
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ // 校验数据逻辑(可选)
|
|
|
+ BlindLevelsValidatorUtils.ValidationResult validationResult = BlindLevelsValidatorUtils.validateBlindLevels(dataList);
|
|
|
+ if (validationResult.isValid()) {
|
|
|
+ System.out.println("数据校验通过");
|
|
|
+ } else {
|
|
|
+ return R.fail(validationResult.getErrorMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 更新主表
|
|
|
+ int i = baseMapper.updateBlindStructuresById(update);
|
|
|
+ if (i <= 0) {
|
|
|
+ return R.fail("更新失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3. 删除原有等级数据
|
|
|
+ Boolean b = blindLevelsService.deleteBlindLevelByBlindStructureId(update.getId());
|
|
|
+ if (!b) {
|
|
|
+ return R.fail("删除历史等级失败");
|
|
|
+ }
|
|
|
+
|
|
|
// 5. 插入新等级数据
|
|
|
for (BlindLevelsImportVo vo : dataList) {
|
|
|
BlindLevelsBo levelBo = new BlindLevelsBo();
|