13bf2626f3e37ac231f47639b474c2484c9ee272.svn-base 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package cn.com.goldenwater.dcproj.utils;
  2. import java.util.ArrayList;
  3. import java.util.List;
  4. import java.util.stream.Collectors;
  5. public class ExcelVerifyCollection<T> {
  6. List<VerifyItem<T>> VerifyItemList;
  7. public ExcelVerifyCollection(List<T> list){
  8. this.VerifyItemList = list.stream().map(o -> new VerifyItem<T>(o)).collect(Collectors.toList());
  9. }
  10. public List<VerifyItem<T>> getVerifyItemList(){
  11. return this.VerifyItemList;
  12. }
  13. /**
  14. * 获取通过校验的数据
  15. * @return
  16. */
  17. public List<T> getRightList(){
  18. List<T> rightList = new ArrayList<>();
  19. this.VerifyItemList.forEach(o -> {
  20. if(o.isTrueOrFalse()) {
  21. rightList.add(o.getObj());
  22. }
  23. });
  24. return rightList;
  25. }
  26. /**
  27. * 获取未通过的错误信息
  28. * @return
  29. */
  30. public List<String> getErrorList(){
  31. List<String> errorList = new ArrayList<>();
  32. for (int i = 0 ; i < this.VerifyItemList.size() ; i++) {
  33. String msg = this.VerifyItemList.get(i).getMsg();
  34. if(!(msg == null) && !("".equals(msg))){
  35. errorList.add("第【" + (i+2) + "】行" + msg);
  36. }
  37. }
  38. if(errorList.size() == 0){
  39. errorList.add("成功导入" + getRightList().size() + "条数据");
  40. }
  41. return errorList;
  42. }
  43. }