|  |  |  | 
|---|
|  |  |  | import cc.mrbird.febs.common.exception.FebsException; | 
|---|
|  |  |  | import cc.mrbird.febs.common.properties.FebsProperties; | 
|---|
|  |  |  | import cc.mrbird.febs.common.properties.ValidateCodeProperties; | 
|---|
|  |  |  | import cn.hutool.json.JSONObject; | 
|---|
|  |  |  | import cn.hutool.json.JSONUtil; | 
|---|
|  |  |  | import com.wf.captcha.GifCaptcha; | 
|---|
|  |  |  | import com.wf.captcha.SpecCaptcha; | 
|---|
|  |  |  | import com.wf.captcha.base.Captcha; | 
|---|
|  |  |  | 
|---|
|  |  |  | import javax.servlet.http.HttpServletResponse; | 
|---|
|  |  |  | import javax.servlet.http.HttpSession; | 
|---|
|  |  |  | import java.io.IOException; | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  | import java.util.stream.Collectors; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 验证码服务 | 
|---|
|  |  |  | 
|---|
|  |  |  | response.setHeader(HttpHeaders.CACHE_CONTROL, "No-cache"); | 
|---|
|  |  |  | response.setDateHeader(HttpHeaders.EXPIRES, 0L); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //    public static void main(String[] args) { | 
|---|
|  |  |  | //        List<Integer> lists = new ArrayList<>(); | 
|---|
|  |  |  | ////        lists.add(1); | 
|---|
|  |  |  | ////        lists.add(2); | 
|---|
|  |  |  | ////        lists.add(3); | 
|---|
|  |  |  | ////        lists.add(4); | 
|---|
|  |  |  | //        System.out.println(lists); | 
|---|
|  |  |  | //        List<Integer> collect = lists | 
|---|
|  |  |  | //                .stream() | 
|---|
|  |  |  | //                .filter(list -> 1 == list) | 
|---|
|  |  |  | //                .collect(Collectors.toList()); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //        System.out.println(collect); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //        List<Integer> collect1 = lists.stream().filter( | 
|---|
|  |  |  | //                list -> { | 
|---|
|  |  |  | //                    if (1 != list) { | 
|---|
|  |  |  | //                        return true; | 
|---|
|  |  |  | //                    } | 
|---|
|  |  |  | //                    return false; | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | //        ).collect(Collectors.toList()); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //        System.out.println(collect1); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //        List<Integer> list2 = new ArrayList<>(); | 
|---|
|  |  |  | //        Random rd = new Random(); | 
|---|
|  |  |  | //        for (int i = 0; i < 100; i++) { | 
|---|
|  |  |  | //            list2.add(rd.nextInt(101));// 随机产生一个[0,100]的数字 | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | //        System.out.println(list2); | 
|---|
|  |  |  | //        // 流处理, 进行数据处理 | 
|---|
|  |  |  | //        DoubleSummaryStatistics ds = list2.stream().collect(Collectors.summarizingDouble(e -> e)); | 
|---|
|  |  |  | //        Map<Boolean, List<Integer>> collect2 = list2.stream().collect(Collectors.partitioningBy(e -> e >= 60)); | 
|---|
|  |  |  | //        Map<Boolean, List<Integer>> collect3 = list2.stream().collect(Collectors.partitioningBy(e -> e >= 80)); | 
|---|
|  |  |  | //        Map<Boolean, List<Integer>> collect4 = list2.stream().collect(Collectors.partitioningBy(e -> e >= 200)); | 
|---|
|  |  |  | //        System.out.println("平均分"+ds.getAverage()); | 
|---|
|  |  |  | //        System.out.println("最高分"+ds.getMax()); | 
|---|
|  |  |  | //        System.out.println("最低分"+ds.getMin()); | 
|---|
|  |  |  | //        System.out.println("总分"+ds.getSum()); | 
|---|
|  |  |  | //        System.out.println("人数"+ds.getCount()); | 
|---|
|  |  |  | //        System.out.println("大于60分"+collect2.toString()); | 
|---|
|  |  |  | //        System.out.println("大于80分"+collect3.get(true).toString()); | 
|---|
|  |  |  | //        System.out.println("大于90分"+collect4.get(true).toString()); | 
|---|
|  |  |  | //        JSONObject jsonObject = JSONUtil.parseObj(collect2); | 
|---|
|  |  |  | //        System.out.println(jsonObject); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //    } | 
|---|
|  |  |  | } | 
|---|