public void invoke(ComparisonSpotEvaluationResultsExcel comparisonSpotEvaluationResultsExcel, AnalysisContext analysisContext) {
/**
* 记录行号码
*/
ReadRowHolder readRowHolder = analysisContext.readRowHolder();
Integer rowIndex = readRowHolder.getRowIndex();
String row = "第 " + (rowIndex + 1) + " 行,";
DetectionIndexServiceImpl.CheckResult error = new DetectionIndexServiceImpl.CheckResult();
if (comparisonSpotEvaluationResultsExcel.getTbbh() == null || comparisonSpotEvaluationResultsExcel.getTbbh().equals("")) {
error.setTableLocation(row);
error.setErrorMessage("图斑编号为空");
errors.add(error);
}
if (comparisonSpotEvaluationResultsExcel.getTbbh2() == null || comparisonSpotEvaluationResultsExcel.getTbbh2().equals("")) {
error.setErrorMessage("转换图斑编号为空");
error.setTableLocation(row);
errors.add(error);
}
if (comparisonSpotEvaluationResultsExcel.getProvince() == null || comparisonSpotEvaluationResultsExcel.getProvince().equals("")){
error.setErrorMessage("省份为空");
error.setTableLocation(row);
errors.add(error);
}
if (comparisonSpotEvaluationResultsExcel.getCity() == null || comparisonSpotEvaluationResultsExcel.getCity().equals("")) {
error.setErrorMessage("地市为空");
error.setTableLocation(row);
errors.add(error);
}
if (comparisonSpotEvaluationResultsExcel.getDistrict() == null || comparisonSpotEvaluationResultsExcel.getDistrict().equals("")) {
error.setErrorMessage("区县为空");
error.setTableLocation(row);
errors.add(error);
}
if(comparisonSpotEvaluationResultsExcel.getGrade()==null){
error.setErrorMessage("矿山(图斑)污染评分等级为空");
error.setTableLocation(row);
errors.add(error);
}
ComparisonSpotEvaluationResults results = new ComparisonSpotEvaluationResults();
BeanUtil.copyProperties(comparisonSpotEvaluationResultsExcel, results);
results.setType(type);
// 、、、
r.add(results);
}
原本想省劲儿只创建一个error,然后将该轮循环收集到错误放到集合里,然后就出现了每一行都是同一个错误提示。后来我又做了个小测试,发现确实会覆盖原来的,推断集合里存的是对象的引用地址。