| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- package cn.com.goldenwater.dcproj.utils;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.stream.Collectors;
- public class ExcelVerifyCollection<T> {
- List<VerifyItem<T>> VerifyItemList;
- public ExcelVerifyCollection(List<T> list){
- this.VerifyItemList = list.stream().map(o -> new VerifyItem<T>(o)).collect(Collectors.toList());
- }
- public List<VerifyItem<T>> getVerifyItemList(){
- return this.VerifyItemList;
- }
- /**
- * 获取通过校验的数据
- * @return
- */
- public List<T> getRightList(){
- List<T> rightList = new ArrayList<>();
- this.VerifyItemList.forEach(o -> {
- if(o.isTrueOrFalse()) {
- rightList.add(o.getObj());
- }
- });
- return rightList;
- }
- /**
- * 获取未通过的错误信息
- * @return
- */
- public List<String> getErrorList(){
- List<String> errorList = new ArrayList<>();
- for (int i = 0 ; i < this.VerifyItemList.size() ; i++) {
- String msg = this.VerifyItemList.get(i).getMsg();
- if(!(msg == null) && !("".equals(msg))){
- errorList.add("第【" + (i+2) + "】行" + msg);
- }
- }
- if(errorList.size() == 0){
- errorList.add("成功导入" + getRightList().size() + "条数据");
- }
- return errorList;
- }
- }
|