From 19251fb5596415bfa83c51b8ed130ecbb31644ce Mon Sep 17 00:00:00 2001 From: 44323 <443237572@qq.com> Date: 星期一, 09 十月 2023 18:31:30 +0800 Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/PlayPai --- cloud-server-account/src/main/java/com/dsh/account/controller/StudentController.java | 446 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 440 insertions(+), 6 deletions(-) diff --git a/cloud-server-account/src/main/java/com/dsh/account/controller/StudentController.java b/cloud-server-account/src/main/java/com/dsh/account/controller/StudentController.java index b7c7d88..394eec2 100644 --- a/cloud-server-account/src/main/java/com/dsh/account/controller/StudentController.java +++ b/cloud-server-account/src/main/java/com/dsh/account/controller/StudentController.java @@ -26,10 +26,9 @@ import javax.annotation.Resource; import java.math.BigDecimal; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.util.*; import java.util.stream.Collectors; /** @@ -256,9 +255,140 @@ if(ids.size()==0){ ids.add(-1); } - List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>().in(TAppUser::getInsertType, 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") @@ -308,7 +438,7 @@ @PostMapping("/student/queryUserAge") public HashMap<String, Object> queryUserAge(){ HashMap<String, Object> map = new HashMap<>(); - List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>().in(TAppUser::getInsertType, 1)); + 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); @@ -349,4 +479,308 @@ } + @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; + + + } } -- Gitblit v1.7.1