liujie
2023-10-09 266fbc08e028cab1f276eeedc682f73215965833
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
package com.dsh.account.controller;
 
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dsh.account.dto.*;
import com.dsh.account.entity.*;
import com.dsh.account.feignclient.course.CoursePaymentClient;
import com.dsh.account.feignclient.course.model.TCoursePackagePayment;
import com.dsh.account.model.QueryDataFee;
import com.dsh.account.model.StudentVo;
import com.dsh.account.service.IVipPaymentService;
import com.dsh.account.service.RechargeRecordsService;
import com.dsh.account.service.TAppUserService;
import com.dsh.account.service.TStudentService;
import com.dsh.account.util.ResultUtil;
import com.dsh.account.util.TokenUtil;
import com.dsh.account.util.ToolUtil;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.swagger2.mappers.ModelMapper;
 
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.*;
import java.util.stream.Collectors;
 
/**
 * @author zhibing.pu
 * @date 2023/6/24 14:59
 */
@RestController
@RequestMapping("")
public class StudentController {
 
    @Autowired
    private TStudentService studentService;
 
    @Autowired
    private TokenUtil tokenUtil;
 
    @Autowired
    private TAppUserService appUserService;
 
    @Autowired
    private IVipPaymentService vipPaymentService;
 
    @Autowired
    private RechargeRecordsService rechargeRecordsService;
 
    /**
     * 添加学员
     * @return
     */
    @RequestMapping("/base/student/addStudent")
    public Object addStudent(@RequestBody TStudent student){
        student.setInsertTime(new Date());
        student.setIsDefault(1);
       return studentService.save(student);
    }
    /**
     * 获取用户学员列表
     * @param appUserId
     * @return
     */
    @ResponseBody
    @PostMapping("/student/queryStudentList")
    public List<TStudent> queryStudentList(@RequestBody Integer appUserId){
        try {
            List<TStudent> list = studentService.list(new QueryWrapper<TStudent>().eq("appUserId", appUserId).eq("state", 1));
            return list;
        }catch (Exception e){
            e.printStackTrace();
            return new ArrayList<>();
        }
    }
 
 
 
    @ResponseBody
    @PostMapping("/student/queryDefaultStudent")
    public TStudent queryDefaultStudent(@RequestBody Integer appUserId){
        try {
            TStudent one = studentService.getOne(new QueryWrapper<TStudent>().eq("appUserId", appUserId).eq("isDefault", 1).eq("state", 1).last("limit 1"));
            return one;
        }catch (Exception e){
            e.printStackTrace();
            return null;
        }
    }
 
 
    @ResponseBody
    @PostMapping("/api/student/queryStudentList")
    @ApiOperation(value = "获取学员列表", tags = {"APP-课程列表"})
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil<List<StudentVo>> queryStudentList(){
        try {
            Integer uid = tokenUtil.getUserIdFormRedis();
            if(null == uid){
                return ResultUtil.tokenErr();
            }
            List<TStudent> list = studentService.list(new QueryWrapper<TStudent>().eq("appUserId", uid).eq("state", 1));
            List<StudentVo> listVo = new ArrayList<>();
            for (TStudent tStudent : list) {
                StudentVo studentVo = new StudentVo();
                studentVo.setId(tStudent.getId());
                studentVo.setPhone(tStudent.getPhone());
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
                studentVo.setAge(Integer.valueOf(sdf.format(new Date())) - Integer.valueOf(sdf.format(tStudent.getBirthday())));
                listVo.add(studentVo);
                studentVo.setName(tStudent.getName());
            }
            return ResultUtil.success(listVo);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
    /**
     * 根据电话号码学员信息
     * @param phone
     * @return
     */
    @ResponseBody
    @PostMapping("/student/queryStudentByPhone")
    public TStudent queryStudentByPhone(@RequestBody String phone){
        try {
            TStudent one = studentService.getOne(new QueryWrapper<TStudent>().eq("phone", phone).eq("state", 1));
            return one;
        }catch (Exception e){
            e.printStackTrace();
            return null;
        }
    }
 
 
    /**
     * 根据id获取数据
     * @param id
     * @return
     */
    @ResponseBody
    @PostMapping("/student/queryStudentById")
    public TStudent queryStudentById(@RequestBody Integer id){
        TStudent student = studentService.getById(id);
        return student;
    }
 
 
 
 
    /**
     * 根据名称模糊搜索学员
     * @param name
     * @return
     */
    @ResponseBody
    @PostMapping("/student/queryStudentListByName")
    public List<TStudent> queryStudentListByName(@RequestBody String name){
        return studentService.list(new QueryWrapper<TStudent>().eq("state", 1).like("name", name));
    }
    /**
     * 根据名称模糊搜索学员
     * @param name
     * @return
     */
    @PostMapping("/student/queryTStudentListByName")
    public List<TStudent> queryTStudentListByName(@RequestBody String name){
        return studentService.list(new QueryWrapper<TStudent>().eq("state", 1).like("name", name));
    }
 
    /**
     * web端查找学员
     *
     * @return
     */
 
    @ResponseBody
    @PostMapping("/student/webStudentList")
    public List<TStudentDto> querywebStudent(@RequestBody StudentSearch search){
        return studentService.listAll(search);
    }
 
    @ResponseBody
    @PostMapping("/student/webOneStudent")
    public TStudentDto querywebStudentOne(@RequestParam("id")Integer id){
        System.out.println("===?==》"+id);
        return studentService.listOne(id);
    }
 
    @ResponseBody
    @PostMapping("/student/update")
    public  void update(@RequestBody TStudent tStudent){
        System.out.println("======tStudent======"+tStudent);
        studentService.updateById(tStudent);
    }
 
    @ResponseBody
    @PostMapping("/student/createHistory")
    public  void createHistory(@RequestBody CreateHistoryDto createHistoryDto){
        createHistoryDto.setDate(new Date());
        studentService.createHistory(createHistoryDto);
    }
 
    @ResponseBody
    @PostMapping("/student/getHisory")
    public  List<GetHistoryDto> getHisory(){
        List<GetHistoryDto> getHistoryDtos =  studentService.getHistory();
        return getHistoryDtos;
    }
 
 
    @Resource
    private CoursePaymentClient paymentClient;
    @ResponseBody
    @PostMapping("/student/giftSelect")
    public  List<SelectDto> giftSelect(@RequestBody GiftSearchDto giftSearchDto){
        System.out.println("======giftSelect=========giftSearchDto===="+giftSearchDto);
 
//       Integer appId = studentService.getGiftSelect(giftSearchDto);
        TCoursePackagePayment1 coursePackagePaymentById = paymentClient.getCoursePackagePaymentById1(giftSearchDto.getId());
//        System.out.println("=======giftSelect======appId====>"+appId);
        List<TStudent> selectDtos =  studentService.list(new QueryWrapper<TStudent>()
                .select("name, id")
                .eq("state", 1)
                .eq("name", giftSearchDto.getName()).eq("phone",giftSearchDto.getPhone()).ne("appUserId",coursePackagePaymentById.getAppUserId()));
 
 
        List<SelectDto> list = new ArrayList<>();
        for (TStudent student : selectDtos) {
            SelectDto selectDto = new SelectDto();
            selectDto.setValue(student.getName());
            selectDto.setId(student.getId());
            list.add(selectDto);
        }
        System.out.println("=======giftSelect======selectDtos====>"+list);
        return list;
    }
 
 
    @PostMapping("/student/getUserPt")
    @ResponseBody
    public List<Integer> getUserPt(@RequestBody List<Integer> ids){
        if(ids.size()==0){
            ids.add(-1);
        }
        List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 1));
        return list.stream().map(TAppUser::getId).collect(Collectors.toList());
    }
    @PostMapping("/student/getUserYYs")
    @ResponseBody
   public  List<Integer> getUserYYs(@RequestBody Integer id){
        List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 2).eq(TAppUser::getAddUserId,id));
        return list.stream().map(TAppUser::getId).collect(Collectors.toList());
    }
    @ResponseBody
    @PostMapping("/student/getUserPtVip")
    public List<Integer> getUserPtVip(){
        List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 1).eq(TAppUser::getIsVip,1));
        return list.stream().map(TAppUser::getId).collect(Collectors.toList());
    }
 
    @PostMapping("/student/getUserStore")
    @ResponseBody
   public  List<Integer> getUserStore(@RequestBody Integer id){
        List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 3).eq(TAppUser::getAddUserId,id));
        return list.stream().map(TAppUser::getId).collect(Collectors.toList());
    }
 
 
    @ResponseBody
    @PostMapping("/student/userAndVipPt")
    public HashMap<String, Object>  userAndVipPt(@RequestBody Integer type){
        HashMap<String, Object> map = new HashMap<>();
        // 所有的
        List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 1));
        map.put("allUser",list.size());
        List<TAppUser> list1 = appUserService.list(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 1).eq(TAppUser::getIsVip,1));
        map.put("allVip",list1.size());
 
 
        ArrayList<Object> integers = new ArrayList<>();
        int year = DateUtil.year(new Date());
        for (int i = 0; i < 10; i++) {
            integers.add(year-i);
        }
        List<Object> collect = integers.stream().sorted().collect(Collectors.toList());
        // 年
        ArrayList<Long> years = new ArrayList<>();
        ArrayList<Long> yearsVip = new ArrayList<>();
        for (Object o : collect) {
            String s = o.toString();
            long count = list.stream().filter(e -> e.getInsertTime().toString().contains(s)).count();
            long count1 = list1.stream().filter(e -> e.getInsertTime().toString().contains(s)).count();
            years.add(count);
            yearsVip.add(count1);
        }
        map.put("yearData",years);
        map.put("yearsVip",yearsVip);
 
        ArrayList<Long> months = new ArrayList<>();
        ArrayList<Long> monthsVip = new ArrayList<>();
        // 月
        for (int i = 1; i <= 12; i++) {
            String m=i+"";
            if(i<10){
                m="0"+i;
            }
            String s = year + "-" + m;
            long count = list.stream().filter(e -> e.getInsertTime().toString().contains(s)).count();
            long count1 = list1.stream().filter(e -> e.getInsertTime().toString().contains(s)).count();
            months.add(count);
            monthsVip.add(count1);
        }
        map.put("monthData",months);
        map.put("monthsVip",monthsVip);
 
        // 周
 
        // 获取最近四周
        LocalDateTime minNow = LocalDateTime.now().with(LocalTime.MIN);
        LocalDateTime maxNow = LocalDateTime.now().with(LocalTime.MAX);
        // 周度数据
        String s1 = minNow.minusDays(6).toString();
        String s2 = maxNow.toString();
 
        String s3 = minNow.minusDays(13).toString();
        String s4 = maxNow.minusDays(6).toString();
 
 
        String s5 = minNow.minusDays(20).toString();
        String s6 = maxNow.minusDays(13).toString();
 
        String s7 = minNow.minusDays(27).toString();
        String s8 = maxNow.minusDays(20).toString();
 
 
        int count = appUserService.count(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 1).between(TAppUser::getInsertTime, s7, s8));
        int countVip = appUserService.count(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 1).eq(TAppUser::getIsVip,1).between(TAppUser::getInsertTime, s7, s8));
 
        int count1 = appUserService.count(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 1).between(TAppUser::getInsertTime,s5,s6));
        int countVip1 = appUserService.count(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 1).eq(TAppUser::getIsVip,1).between(TAppUser::getInsertTime, s5,s6));
 
        int count2 = appUserService.count(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 1).between(TAppUser::getInsertTime,s3,s4));
        int countVip2 = appUserService.count(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 1).eq(TAppUser::getIsVip,1).between(TAppUser::getInsertTime, s3,s4));
 
        int count3 = appUserService.count(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 1).between(TAppUser::getInsertTime,s1,s2));
        int countVip3 = appUserService.count(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 1).eq(TAppUser::getIsVip,1).between(TAppUser::getInsertTime, s1,s2));
        map.put("count",count);
        map.put("count1",count1);
        map.put("count2",count2);
        map.put("count3",count3);
        map.put("countVip",countVip);
        map.put("countVip1",countVip1);
        map.put("countVip2",countVip2);
        map.put("countVip3",countVip3);
 
 
        // 日
        ArrayList<Integer> days = new ArrayList<>();
        ArrayList<Integer> daysVip = new ArrayList<>();
        for (int i = 6; i >= 0; i--) {
            String s = minNow.minusDays(i).toString();
            String s9 = maxNow.minusDays(i).toString();
            int count4 = appUserService.count(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 1).between(TAppUser::getInsertTime,s,s9));
            int countVip5 = appUserService.count(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 1).eq(TAppUser::getIsVip,1).between(TAppUser::getInsertTime, s,s9));
            days.add(count4);
            daysVip.add(countVip5);
        }
        map.put("dayData",days);
        map.put("daysVip",daysVip);
 
 
        return map;
 
    }
 
 
 
 
 
 
    @PostMapping("/student/queryFee")
    public HashMap<String, Object> queryFee(@RequestBody QueryDataFee queryDataFee){
        HashMap<String, Object> map = new HashMap<>();
        String data = queryDataFee.getData();
        List<Integer> ids = queryDataFee.getIds();
        if(ids.size()==0){
            ids.add(-1);
        }
        LambdaQueryWrapper<VipPayment> vipPaymentLambdaQueryWrapper = new LambdaQueryWrapper<>();
        if(ToolUtil.isNotEmpty(data)){
            String stime = data.split(" - ")[0]+" 00:00:00";
            String etime = data.split(" - ")[1]+" 23:59:59";
            vipPaymentLambdaQueryWrapper.between(VipPayment::getInsertTime,stime,etime);
        }
        vipPaymentLambdaQueryWrapper.in(VipPayment::getAppUserId,ids);
        vipPaymentLambdaQueryWrapper.eq(VipPayment::getPayStatus,2);
        List<VipPayment> list = vipPaymentService.list(vipPaymentLambdaQueryWrapper);
        double sum = list.stream().mapToDouble(VipPayment::getAmount).sum();
 
        map.put("fee1",sum);
 
        LambdaQueryWrapper<RechargeRecords> rechargeRecordsLambdaQueryWrapper = new LambdaQueryWrapper<>();
        if(ToolUtil.isNotEmpty(data)){
            String stime = data.split(" - ")[0]+" 00:00:00";
            String etime = data.split(" - ")[1]+" 23:59:59";
            rechargeRecordsLambdaQueryWrapper.between(RechargeRecords::getInsertTime,stime,etime);
        }
        rechargeRecordsLambdaQueryWrapper.in(RechargeRecords::getAppUserId,ids);
        rechargeRecordsLambdaQueryWrapper.eq(RechargeRecords::getPayStatus,2);
        List<RechargeRecords> list1 = rechargeRecordsService.list(rechargeRecordsLambdaQueryWrapper);
        double sum1 = list1.stream().map(RechargeRecords::getAmount).reduce(BigDecimal.ZERO,BigDecimal::add).doubleValue();
 
        map.put("fee2",sum1);
 
 
 
 
        return map;
 
 
    }
 
 
 
    @PostMapping("/student/queryUserAge")
    public HashMap<String, Object> queryUserAge(){
        HashMap<String, Object> map = new HashMap<>();
        List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 1));
        List<Integer> collect = list.stream().map(TAppUser::getId).collect(Collectors.toList());
        if(collect.size()==0){
            collect.add(-1);
        }
        List<TStudent> list1 = studentService.list(new LambdaQueryWrapper<TStudent>().in(TStudent::getAppUserId, collect));
        int age1=0;
        int age2=0;
        int age3=0;
        int age4=0;
        int boy=0;
        int girl=0;
        for (TStudent tStudent : list1) {
            Date birthday = tStudent.getBirthday();
            long l = DateUtil.betweenYear(birthday, new Date(), true);
            if(l<7){
                age1++;
            }else if(l>=8 && l<11){
                age2++;
            }else if(l>=11 && l<=12){
                age3++;
            }else {
                age4++;
            }
            if(tStudent.getSex()==1){
                boy++;
            }else {
                girl++;
            }
        }
        map.put("age1",age1);
        map.put("age2",age2);
        map.put("age3",age3);
        map.put("age4",age4);
        map.put("boy",boy);
        map.put("girl",girl);
        return map;
 
 
 
    }
    @PostMapping("/student/queryUserAge1")
    public HashMap<String, Object> queryUserAge1(){
        HashMap<String, Object> map = new HashMap<>();
        List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 1));
        List<Integer> collect = list.stream().map(TAppUser::getId).collect(Collectors.toList());
        if(collect.size()==0){
            collect.add(-1);
        }
 
 
        Set<String> strings = list.stream().collect(Collectors.groupingBy(TAppUser::getCity)).keySet();
        ArrayList<String> strings1 = new ArrayList<>();
        ArrayList<Integer> integers = new ArrayList<>();
 
        for (String string : strings) {
            int a = 0;
            strings1.add(string);
            for (TAppUser tAppUser : list) {
                if(tAppUser.getCity().equals(string)){
                    a++;
                }
            }
            integers.add(a);
        }
 
        map.put("cityData",strings1);
        map.put("cityNum",integers);
        int age1=0;
        int age2=0;
        int age3=0;
        int age4=0;
        int age5=0;
        int age6=0;
        int boy=0;
        int girl=0;
        for (TAppUser tStudent : list) {
            Date birthday = tStudent.getBirthday();
            long l =0;
            if(birthday!=null){
 
                 l = DateUtil.betweenYear(birthday, new Date(), true);
            }
            if(l<=12){
                age1++;
            }else if(l>12 && l<18){
                age2++;
            }else if(l>=19 && l<=25){
                age3++;
            }else if(l>=26 && l<=35){
                age4++;
            }else if(l>=36 && l<=50){
                age5++;
            }else {
                age6++;
            }
            if(tStudent.getGender()!=null &&tStudent.getGender()==1){
                boy++;
            }else {
                girl++;
            }
        }
        map.put("age1",age1);
        map.put("age2",age2);
        map.put("age3",age3);
        map.put("age4",age4);
        map.put("age5",age5);
        map.put("age6",age6);
        map.put("boy",boy);
        map.put("girl",girl);
        return map;
 
 
 
    }
    @PostMapping("/student/queryUserAgeYys")
    public HashMap<String, Object> queryUserAgeYys(Integer id){
        HashMap<String, Object> map = new HashMap<>();
        List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 2).eq(TAppUser::getAddUserId,id));
        List<Integer> collect = list.stream().map(TAppUser::getId).collect(Collectors.toList());
        if(collect.size()==0){
            collect.add(-1);
        }
 
 
        Set<String> strings = list.stream().collect(Collectors.groupingBy(TAppUser::getCity)).keySet();
        ArrayList<String> strings1 = new ArrayList<>();
        ArrayList<Integer> integers = new ArrayList<>();
 
        for (String string : strings) {
            int a = 0;
            strings1.add(string);
            for (TAppUser tAppUser : list) {
                if(tAppUser.getCity().equals(string)){
                    a++;
                }
            }
            integers.add(a);
        }
 
        map.put("cityData",strings1);
        map.put("cityNum",integers);
        int age1=0;
        int age2=0;
        int age3=0;
        int age4=0;
        int age5=0;
        int age6=0;
        int boy=0;
        int girl=0;
        for (TAppUser tStudent : list) {
            Date birthday = tStudent.getBirthday();
            long l =0;
            if(birthday!=null){
 
                 l = DateUtil.betweenYear(birthday, new Date(), true);
            }
            if(l<=12){
                age1++;
            }else if(l>12 && l<18){
                age2++;
            }else if(l>=19 && l<=25){
                age3++;
            }else if(l>=26 && l<=35){
                age4++;
            }else if(l>=36 && l<=50){
                age5++;
            }else {
                age6++;
            }
            if(tStudent.getGender()!=null &&tStudent.getGender()==1){
                boy++;
            }else {
                girl++;
            }
        }
        map.put("age1",age1);
        map.put("age2",age2);
        map.put("age3",age3);
        map.put("age4",age4);
        map.put("age5",age5);
        map.put("age6",age6);
        map.put("boy",boy);
        map.put("girl",girl);
        return map;
 
    }
    @PostMapping("/student/queryUserAgeStore")
    public HashMap<String, Object> queryUserAgeStore(Integer id){
        HashMap<String, Object> map = new HashMap<>();
        List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 3).eq(TAppUser::getAddUserId,id));
        List<Integer> collect = list.stream().map(TAppUser::getId).collect(Collectors.toList());
        if(collect.size()==0){
            collect.add(-1);
        }
 
 
        Set<String> strings = list.stream().collect(Collectors.groupingBy(TAppUser::getCity)).keySet();
        ArrayList<String> strings1 = new ArrayList<>();
        ArrayList<Integer> integers = new ArrayList<>();
 
        for (String string : strings) {
            int a = 0;
            strings1.add(string);
            for (TAppUser tAppUser : list) {
                if(tAppUser.getCity().equals(string)){
                    a++;
                }
            }
            integers.add(a);
        }
 
        map.put("cityData",strings1);
        map.put("cityNum",integers);
        int age1=0;
        int age2=0;
        int age3=0;
        int age4=0;
        int age5=0;
        int age6=0;
        int boy=0;
        int girl=0;
        for (TAppUser tStudent : list) {
            Date birthday = tStudent.getBirthday();
            long l =0;
            if(birthday!=null){
 
                 l = DateUtil.betweenYear(birthday, new Date(), true);
            }
            if(l<=12){
                age1++;
            }else if(l>12 && l<18){
                age2++;
            }else if(l>=19 && l<=25){
                age3++;
            }else if(l>=26 && l<=35){
                age4++;
            }else if(l>=36 && l<=50){
                age5++;
            }else {
                age6++;
            }
            if(tStudent.getGender()!=null &&tStudent.getGender()==1){
                boy++;
            }else {
                girl++;
            }
        }
        map.put("age1",age1);
        map.put("age2",age2);
        map.put("age3",age3);
        map.put("age4",age4);
        map.put("age5",age5);
        map.put("age6",age6);
        map.put("boy",boy);
        map.put("girl",girl);
        return map;
 
    }
    @PostMapping("/student/queryUserAgeYys1")
    public HashMap<String, Object> queryUserAgeYys1(@RequestBody Integer id){
        HashMap<String, Object> map = new HashMap<>();
        List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 2).eq(TAppUser::getAddUserId,id));
        List<Integer> collect = list.stream().map(TAppUser::getId).collect(Collectors.toList());
        if(collect.size()==0){
            collect.add(-1);
        }
        List<TStudent> list1 = studentService.list(new LambdaQueryWrapper<TStudent>().in(TStudent::getAppUserId, collect));
        int age1=0;
        int age2=0;
        int age3=0;
        int age4=0;
        int boy=0;
        int girl=0;
        for (TStudent tStudent : list1) {
            Date birthday = tStudent.getBirthday();
            long l = DateUtil.betweenYear(birthday, new Date(), true);
            if(l<7){
                age1++;
            }else if(l>=8 && l<11){
                age2++;
            }else if(l>=11 && l<=12){
                age3++;
            }else {
                age4++;
            }
            if(tStudent.getSex()==1){
                boy++;
            }else {
                girl++;
            }
        }
        map.put("age1",age1);
        map.put("age2",age2);
        map.put("age3",age3);
        map.put("age4",age4);
        map.put("boy",boy);
        map.put("girl",girl);
        return map;
 
 
    }
    @PostMapping("/student/queryUserAgeStore1")
    public HashMap<String, Object> queryUserAgeStore1(@RequestBody Integer id){
        HashMap<String, Object> map = new HashMap<>();
        List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 3).eq(TAppUser::getAddUserId,id));
        List<Integer> collect = list.stream().map(TAppUser::getId).collect(Collectors.toList());
        if(collect.size()==0){
            collect.add(-1);
        }
        List<TStudent> list1 = studentService.list(new LambdaQueryWrapper<TStudent>().in(TStudent::getAppUserId, collect));
        int age1=0;
        int age2=0;
        int age3=0;
        int age4=0;
        int boy=0;
        int girl=0;
        for (TStudent tStudent : list1) {
            Date birthday = tStudent.getBirthday();
            long l = DateUtil.betweenYear(birthday, new Date(), true);
            if(l<7){
                age1++;
            }else if(l>=8 && l<11){
                age2++;
            }else if(l>=11 && l<=12){
                age3++;
            }else {
                age4++;
            }
            if(tStudent.getSex()==1){
                boy++;
            }else {
                girl++;
            }
        }
        map.put("age1",age1);
        map.put("age2",age2);
        map.put("age3",age3);
        map.put("age4",age4);
        map.put("boy",boy);
        map.put("girl",girl);
        return map;
 
 
    }
}