• lambda表达式


    //判断集合中元素的重复
    List<User> distinctClass = recordsList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(data -> data.getCustomerCode()))), ArrayList::new));
    if(distinctClass.size()!=recordsList.size()) throw new ExcelImortException("1","编码不一致,只能存在一个编码",importResult.getList());
    
    //判断集合中的元素是否存在值
    List<User> recordsListNo = recordsList.stream().filter(data -> StringUtils.isNotBlank(data.getErrorMsg())).collect(Collectors.toList());
    if(recordsListNo.size() > 0) throw new ExcelImortException("1","有异常数据,请修改完成后重新提交",importResult.getList());
    
    List<User> recordsListYes = recordsList.stream().filter(data -> StringUtils.isEmpty(data.getErrorMsg())).collect(Collectors.toList());
    if(recordsListYes.size()==0) throw new ExcelImortException("1","正常数据为空,请修改完成后重新提交",importResult.getList());
    

      

    detailList.forEach(item->{
    	UserDetailBiz.insertSelective(item);
    });
    

     

    //分组并计算出现次数
    Map<String, Long> customerAndCout = list.stream().
    		collect(Collectors.groupingBy(OrderOutDetail::getCustomerName,Collectors.counting()));
    //排序
    Map<String, String> customerAndCoutMap  = new LinkedHashMap<>();
    customerAndCout.entrySet().stream().sorted(Map.Entry.<String, Long>comparingByValue().reversed())
    		.forEachOrdered(e -> customerAndCoutMap.put(e.getKey(), e.getValue().toString()));;
    //循环赋值
    for(String key : customerAndCoutMap.keySet()){
    	c3=new Cell(new Paragraph(key+": "+customerAndCoutMap.get(key),keyfont));
    	tFoot.addCell(c3);
    }
    

      

  • 相关阅读:
    java 新建文件夹保存
    android AppWidgwtProvider学习
    GPS定位
    android ContentProvider学习
    Android 解屏幕锁与点亮屏幕(来电时效果)
    RecyclerView 分页滑动,设置可以滑动下一页,下一个item作为起点方法
    Glide 加载图片 到动态ImageView
    一个例子了解 HandlerThread,Looper,ThreadLocal,Handler,MessageQueue,Message的关系
    android TabLayout 相关
    屏幕相关
  • 原文地址:https://www.cnblogs.com/hellowzd/p/9907538.html
Copyright © 2020-2023  润新知