Showing
2 changed files
with
8 additions
and
6 deletions
@@ -309,14 +309,15 @@ public class CaseExcelListener extends AnalysisEventListener<CaseExcelData> | @@ -309,14 +309,15 @@ public class CaseExcelListener extends AnalysisEventListener<CaseExcelData> | ||
309 | } | 309 | } |
310 | } | 310 | } |
311 | }); | 311 | }); |
312 | - if (CollectionUtils.isEmpty(errorList)) { | ||
313 | - List<String> repeatDataList = caseService.listByFeild(field.getName(), uniqueCodeList); | 312 | + if (CollectionUtils.isEmpty(errorList) && CollectionUtils.isNotEmpty(list)) { |
313 | + List<String> repeatDataList = Optional.ofNullable(caseService) | ||
314 | + .map(e->e.listByFeild(field.getName(), uniqueCodeList)).orElse(new ArrayList<>()); | ||
314 | for (int i = 0; i < list.size(); i++) { | 315 | for (int i = 0; i < list.size(); i++) { |
315 | try { | 316 | try { |
316 | Object value = field.get(list.get(i)); | 317 | Object value = field.get(list.get(i)); |
317 | String uc = ObjectValueOption.getObjString(value); | 318 | String uc = ObjectValueOption.getObjString(value); |
318 | if (repeatDataList.contains(uc)) { | 319 | if (repeatDataList.contains(uc)) { |
319 | - addError(i + 1, annotation.getHeadName() + "字段已存在!"); | 320 | + addError(i + 2, annotation.getHeadName() + "字段已存在!"); |
320 | } | 321 | } |
321 | 322 | ||
322 | } catch (IllegalAccessException e) { | 323 | } catch (IllegalAccessException e) { |
@@ -311,14 +311,15 @@ public class WarningInstanceExcelListener extends AnalysisEventListener<WarningI | @@ -311,14 +311,15 @@ public class WarningInstanceExcelListener extends AnalysisEventListener<WarningI | ||
311 | } | 311 | } |
312 | } | 312 | } |
313 | }); | 313 | }); |
314 | - if (CollectionUtils.isEmpty(errorList)) { | ||
315 | - List<String> repeatDataList = warningInstanceService.listByFeild(field.getName(), uniqueCodeList); | 314 | + if (CollectionUtils.isEmpty(errorList) && CollectionUtils.isNotEmpty(list)) { |
315 | + List<String> repeatDataList = Optional.ofNullable(warningInstanceService) | ||
316 | + .map(e -> e.listByFeild(field.getName(), uniqueCodeList)).orElse(new ArrayList<>()); | ||
316 | for (int i = 0; i < list.size(); i++) { | 317 | for (int i = 0; i < list.size(); i++) { |
317 | try { | 318 | try { |
318 | Object value = field.get(list.get(i)); | 319 | Object value = field.get(list.get(i)); |
319 | String uc = ObjectValueOption.getObjString(value); | 320 | String uc = ObjectValueOption.getObjString(value); |
320 | if (repeatDataList.contains(uc)) { | 321 | if (repeatDataList.contains(uc)) { |
321 | - addError(i + 1, annotation.getHeadName() + "字段已存在!"); | 322 | + addError(i + 2, annotation.getHeadName() + "字段已存在!"); |
322 | } | 323 | } |
323 | 324 | ||
324 | } catch (IllegalAccessException e) { | 325 | } catch (IllegalAccessException e) { |