| | |
| | | import java.math.BigDecimal; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.Instant; |
| | | import java.time.LocalDateTime; |
| | | import java.time.LocalTime; |
| | | import java.time.ZoneId; |
| | | import java.time.temporal.ChronoUnit; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | Integer studentId = packagePayment.getStudentId(); |
| | | // 添加学员上课记录 |
| | | CoursePackageStudent coursePackageStudent = new CoursePackageStudent(); |
| | | TCoursePackagePayment one = packagePaymentService.getOne(new QueryWrapper<TCoursePackagePayment>().eq("studentId", packagePayment) |
| | | TCoursePackagePayment one = packagePaymentService.getOne(new QueryWrapper<TCoursePackagePayment>().eq("studentId", packagePayment.getStudentId()) |
| | | .orderByDesc("insertTime") |
| | | .last("LIMIT 1")); |
| | | |
| | |
| | | .eq("coursePackageId", coursePackage.getId()) |
| | | .eq("classDate", classDate.getTime()) |
| | | .eq("endDate", endDate.getTime())); |
| | | if (list.size()+1>coursePackage.getMaxSubscribeNumber()){ |
| | | if (list1.size()+1>coursePackage.getMaxSubscribeNumber()){ |
| | | // 当前课包预约人数已满 |
| | | return 5001; |
| | | } |
| | |
| | | public Object changeState(@RequestBody CoursePackagePayDTO dto){ |
| | | |
| | | return packagePaymentService.changeState(dto); |
| | | } |
| | | @GetMapping("/coursePackagePayment/courseStore/{appUserId}/{coursePackageId}") |
| | | public List<TCoursePackagePayment> getByUserIdAndCoursePackageId(@PathVariable("appUserId") Integer appUserId,@PathVariable("coursePackageId") Integer coursePackageId){ |
| | | List<TCoursePackagePayment> list = packagePaymentService.list(new QueryWrapper<TCoursePackagePayment>() |
| | | .eq("appUserId", appUserId) |
| | | .eq("coursePackageId", coursePackageId)); |
| | | return list; |
| | | } |
| | | /** |
| | | * 获取购课记录 |
| | |
| | | re.setPhone(appUser.getPhone()); |
| | | re.setStoreName(store.getName()); |
| | | // 在这里添加条件来删除不满足要求的元素 |
| | | if (appUser.getInsertType() != query.getInsertType()) { |
| | | |
| | | if (query.getInsertType() !=null && appUser.getInsertType() != query.getInsertType()) { |
| | | iterator.remove(); // 使用迭代器的 remove 方法删除元素 |
| | | } |
| | | } |
| | |
| | | resp.setTotalCourseNums(tCoursePackagePayment.getTotalClassHours()); |
| | | resp.setResidueNums(tCoursePackagePayment.getLaveClassHours()); |
| | | resp.setDeductionNums(tCoursePackagePayment.getTotalClassHours()-tCoursePackagePayment.getLaveClassHours()); |
| | | if (tCoursePackage.getValidDays()!=null){ |
| | | String afterDayDate = DateUtil.getAfterDayDate2(tCoursePackage.getInsertTime(),tCoursePackage.getValidDays() + ""); |
| | | resp.setPeriodOfValidity(afterDayDate); |
| | | } |
| | | resps.add(resp); |
| | | } |
| | | } |
| | |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), |
| | | }) |
| | | public ResultUtil<List<AppUserVideoResponse>> queryAfterSourceList( CourseOfAfterRequest search){ |
| | | try { |
| | | public ResultUtil<List<AppUserVideoResponse>> queryAfterSourceList( CourseOfAfterRequest search) throws Exception { |
| | | // try { |
| | | Integer appUserId = tokenUtil.getUserIdFormRedis(); |
| | | |
| | | if(null == appUserId){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | List<Integer> courseIds = new ArrayList<>(); |
| | | QueryWrapper<TCoursePackagePayment> queryWrapper = new QueryWrapper<TCoursePackagePayment>().eq("appUserId", appUserId) |
| | | .groupBy("coursePackageId"); |
| | | // |
| | | // List<Integer> courseIds = new ArrayList<>(); |
| | | // QueryWrapper<TCoursePackagePayment> queryWrapper = new QueryWrapper<TCoursePackagePayment>().eq("appUserId", appUserId) |
| | | // .groupBy("coursePackageId"); |
| | | // if (ToolUtil.isNotEmpty(search.getCourseTypeId())){ |
| | | // queryWrapper.eq("coursePackageId",search.getCourseTypeId()); |
| | | // } |
| | | // List<TCoursePackagePayment> tCoursePackagePayments = packagePaymentService.list(queryWrapper); |
| | | // if (tCoursePackagePayments.size() > 0 ){ |
| | | // courseIds = tCoursePackagePayments.stream().map(TCoursePackagePayment::getCoursePackageId).collect(Collectors.toList()); |
| | | // } |
| | | |
| | | |
| | | QueryWrapper<CoursePackageStudent> queryWrapper1 = new QueryWrapper<CoursePackageStudent>().eq("appUserId", appUserId); |
| | | if (ToolUtil.isNotEmpty(search.getCourseTypeId())){ |
| | | queryWrapper.eq("coursePackageId",search.getCourseTypeId()); |
| | | queryWrapper1.eq("coursePackageId",search.getCourseTypeId()); |
| | | } |
| | | List<TCoursePackagePayment> tCoursePackagePayments = packagePaymentService.list(queryWrapper); |
| | | if (tCoursePackagePayments.size() > 0 ){ |
| | | courseIds = tCoursePackagePayments.stream().map(TCoursePackagePayment::getCoursePackageId).collect(Collectors.toList()); |
| | | |
| | | List<CoursePackageStudent> list = coursePackageStudentService.list(queryWrapper1); |
| | | List<Long> longs = new ArrayList<>(); |
| | | for (CoursePackageStudent coursePackageStudent : list) { |
| | | longs.add(coursePackageStudent.getCoursePackageSchedulingId()); |
| | | } |
| | | return ResultUtil.success(packagePaymentService.queryAfterVideo(search,courseIds)); |
| | | }catch (Exception e){ |
| | | return ResultUtil.runErr(); |
| | | } |
| | | |
| | | System.out.println("======longs========"+longs); |
| | | List<CoursePackageScheduling> coursePackageSchedulings = coursePackageSchedulingService.list(new QueryWrapper<CoursePackageScheduling>().in("id",longs).isNotNull("courseId")); |
| | | List<AppUserVideoResponse> coursePackageSchedulings1 = coursePackageSchedulingService.queryAll(longs); |
| | | |
| | | |
| | | |
| | | |
| | | return ResultUtil.success(coursePackageSchedulings1); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | // }catch (Exception e){ |
| | | // return ResultUtil.runErr(); |
| | | // } |
| | | } |
| | | |
| | | /** |
| | |
| | | @ResponseBody |
| | | @PostMapping("/base/coursePack/obtainStudentClassDetails") |
| | | public List<RecordAppoint> obtainStudentClassDetailsData(@RequestBody WeeksOfCourseRest stuId){ |
| | | try { |
| | | return packagePaymentService.obtainStuClassDetails(stuId.getStuId(),stuId.getAppUserId()); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | throw new RuntimeException(); |
| | | } |
| | | // try { |
| | | return packagePaymentService.obtainStuClassDetails(stuId.getStuId(),stuId.getAppUserId(),stuId.getPageNum()); |
| | | // }catch (Exception e){ |
| | | // e.printStackTrace(); |
| | | // throw new RuntimeException(); |
| | | // } |
| | | } |
| | | |
| | | |
| | |
| | | if(ToolUtil.isEmpty(coursePackage.getNeedNum())){ |
| | | coursePackageStudent.setNeedNum(0); |
| | | }else { |
| | | coursePackageStudent.setNeedNum(coursePackageStudent.getNeedNum()); |
| | | coursePackageStudent.setNeedNum(coursePackage.getNeedNum()); |
| | | } |
| | | } |
| | | } |
| | |
| | | ArrayList<Integer> years = new ArrayList<>(); |
| | | for (Object o : collect) { |
| | | String s = o.toString(); |
| | | List<CoursePackageStudent> collect1 = list.stream().filter(e -> e.getInsertTime().toString().contains(s)).collect(Collectors.toList()); |
| | | List<CoursePackageStudent> collect1 = list.stream().filter(e -> e.getInsertTime().toString().contains(s)).filter(student -> student.getNeedNum() != null).collect(Collectors.toList()); |
| | | int sum2 = collect1.stream().mapToInt(CoursePackageStudent::getNeedNum).sum(); |
| | | years.add(sum2); |
| | | } |
| | |
| | | m="0"+i; |
| | | } |
| | | String s = year + "-" + m; |
| | | List<CoursePackageStudent> collect1 = list.stream().filter(e -> format.format(e.getInsertTime()).contains(s)).collect(Collectors.toList()); |
| | | List<CoursePackageStudent> collect1 = list.stream().filter(e -> format.format(e.getInsertTime()).contains(s)).filter(student -> student.getNeedNum() != null).collect(Collectors.toList()); |
| | | int sum2 = collect1.stream().mapToInt(CoursePackageStudent::getNeedNum).sum(); |
| | | months.add(sum2); |
| | | } |
| | | map.put("monthData",months); |
| | | |
| | | |
| | | |
| | | // 周 |
| | | // 获取最近四周 |
| | | LocalDateTime minNow = LocalDateTime.now().with(LocalTime.MIN); |
| | | LocalDateTime maxNow = LocalDateTime.now().with(LocalTime.MAX); |
| | | // 周度数据 |
| | | String s1 = minNow.minusDays(6).toString(); |
| | | String s2 = maxNow.toString(); |
| | | LocalDateTime s1 = minNow.minusDays(6); |
| | | LocalDateTime s2 = maxNow; |
| | | |
| | | String s3 = minNow.minusDays(13).toString(); |
| | | String s4 = maxNow.minusDays(6).toString(); |
| | | LocalDateTime s3 = minNow.minusDays(13); |
| | | LocalDateTime s4 = maxNow.minusDays(6); |
| | | |
| | | |
| | | String s5 = minNow.minusDays(20).toString(); |
| | | String s6 = maxNow.minusDays(13).toString(); |
| | | LocalDateTime s5 = minNow.minusDays(20); |
| | | LocalDateTime s6 = maxNow.minusDays(13); |
| | | |
| | | String s7 = minNow.minusDays(27).toString(); |
| | | String s8 = maxNow.minusDays(20).toString(); |
| | | LocalDateTime s7 = minNow.minusDays(27); |
| | | LocalDateTime s8 = maxNow.minusDays(20); |
| | | ArrayList<Object> weekData = new ArrayList<>(); |
| | | |
| | | // |
| | | // int count = studentService.count(new LambdaQueryWrapper<TStudent>().in(TStudent::getAppUserId, collect1).between(TStudent::getInsertTime, s7, s8)); |
| | | // |
| | | // int count1 = studentService.count(new LambdaQueryWrapper<TStudent>().in(TStudent::getAppUserId, collect1).between(TStudent::getInsertTime,s5,s6)); |
| | | // |
| | | // int count2 = studentService.count(new LambdaQueryWrapper<TStudent>().in(TStudent::getAppUserId, collect1).between(TStudent::getInsertTime,s3,s4)); |
| | | // |
| | | // int count3 = studentService.count(new LambdaQueryWrapper<TStudent>().in(TStudent::getAppUserId, collect1).between(TStudent::getInsertTime,s1,s2)); |
| | | int count = 0; |
| | | |
| | | // map.put("count",count); |
| | | // map.put("count1",count1); |
| | | // map.put("count2",count2); |
| | | // map.put("count3",count3); |
| | | return null; |
| | | int count1 = 0; |
| | | |
| | | int count2 = 0; |
| | | |
| | | int count3 = 0; |
| | | for (CoursePackageStudent coursePackageStudent : list) { |
| | | if (coursePackageStudent.getNeedNum()==null){ |
| | | continue; |
| | | } |
| | | // 如果到课状态为否 则不计算 |
| | | if (coursePackageStudent.getSignInOrNot() != 0) { |
| | | Date insertTime = coursePackageStudent.getInsertTime(); |
| | | Instant instant = insertTime.toInstant(); |
| | | ZoneId zoneId = ZoneId.systemDefault(); |
| | | LocalDateTime dateTime = instant.atZone(zoneId).toLocalDateTime(); |
| | | if (dateTime.isAfter(s1) && dateTime.isBefore(s2)){ |
| | | |
| | | count+=coursePackageStudent.getNeedNum(); |
| | | }else if(dateTime.isAfter(s3) && dateTime.isBefore(s4)){ |
| | | count1+=coursePackageStudent.getNeedNum(); |
| | | }else if(dateTime.isAfter(s5) && dateTime.isBefore(s6)){ |
| | | count2+=coursePackageStudent.getNeedNum(); |
| | | }else if(dateTime.isAfter(s7) && dateTime.isBefore(s8)){ |
| | | count3+=coursePackageStudent.getNeedNum(); |
| | | } |
| | | |
| | | } |
| | | } |
| | | weekData.add(count3); |
| | | weekData.add(count2); |
| | | weekData.add(count1); |
| | | weekData.add(count); |
| | | |
| | | map.put("weekData",weekData); |
| | | |
| | | |
| | | LocalDateTime currentDateTime = LocalDateTime.now(); |
| | | List<Integer> amountByDay = new ArrayList<>(Collections.nCopies(7,0)); |
| | | for (CoursePackageStudent coursePackageStudent : list) { |
| | | Date insertTime = coursePackageStudent.getInsertTime(); |
| | | // 将 Date 转换为 LocalDateTime |
| | | LocalDateTime insertDateTime = LocalDateTime.ofInstant(insertTime.toInstant(), ZoneId.systemDefault()); |
| | | // 计算日期与当前日期的差距 |
| | | long daysDifference = ChronoUnit.DAYS.between(insertDateTime.toLocalDate(), currentDateTime.toLocalDate()); |
| | | // 如果日期在七天内,累加金额 |
| | | if (daysDifference >= 0 && daysDifference < 7) { |
| | | int index = (int) (6 - daysDifference); // 计算对应的索引位置 |
| | | Integer needNum = coursePackageStudent.getNeedNum(); |
| | | if (needNum!=null){ |
| | | int i = amountByDay.get(index) + needNum; |
| | | amountByDay.set(index, i); |
| | | } |
| | | |
| | | } |
| | | } |
| | | map.put("dayData", amountByDay); |
| | | |
| | | return map; |
| | | |
| | | } |
| | | @ResponseBody |
| | | @PostMapping("/coursePackagePayment/courseYys") |
| | | HashMap<String, Object> courseYys(@RequestBody List<Integer> userPt){ |
| | | if(userPt.size()==0){ |
| | | userPt.add(-1); |
| | | } |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | List<TCoursePackagePayment> tCoursePackagePayments = packagePaymentService.listOne(userPt); |
| | | int sum = tCoursePackagePayments.stream().mapToInt(TCoursePackagePayment::getTotalClassHours).sum(); |
| | | int sum1 = tCoursePackagePayments.stream().mapToInt(TCoursePackagePayment::getLaveClassHours).sum(); |
| | | map.put("allCourse",sum-sum1); |
| | | |
| | | //所有课包 |
| | | List<TCoursePackage> coursePackages = tcpService.list(); |
| | | |
| | | |
| | | // 年 |
| | | List<CoursePackageStudent> list = cspsService.list(new LambdaQueryWrapper<CoursePackageStudent>().in(CoursePackageStudent::getAppUserId, userPt)); |
| | | |
| | | |
| | | for (CoursePackageStudent coursePackageStudent : list) { |
| | | for (TCoursePackage coursePackage : coursePackages) { |
| | | if(coursePackageStudent.getCoursePackageId().equals(coursePackage.getId())){ |
| | | if(ToolUtil.isEmpty(coursePackage.getNeedNum())){ |
| | | coursePackageStudent.setNeedNum(0); |
| | | }else { |
| | | coursePackageStudent.setNeedNum(coursePackage.getNeedNum()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | ArrayList<Object> integers = new ArrayList<>(); |
| | | int year = cn.hutool.core.date.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<Integer> years = new ArrayList<>(); |
| | | for (Object o : collect) { |
| | | String s = o.toString(); |
| | | List<CoursePackageStudent> collect1 = list.stream().filter(e -> e.getInsertTime().toString().contains(s)).filter(student -> student.getNeedNum() != null).collect(Collectors.toList()); |
| | | int sum2 = collect1.stream().mapToInt(CoursePackageStudent::getNeedNum).sum(); |
| | | years.add(sum2); |
| | | } |
| | | |
| | | map.put("yearData",years); |
| | | |
| | | |
| | | |
| | | ArrayList<Integer> months = new ArrayList<>(); |
| | | |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | |
| | | |
| | | // 月 |
| | | for (int i = 1; i <= 12; i++) { |
| | | String m=i+""; |
| | | if(i<10){ |
| | | m="0"+i; |
| | | } |
| | | String s = year + "-" + m; |
| | | List<CoursePackageStudent> collect1 = list.stream().filter(e -> format.format(e.getInsertTime()).contains(s)).filter(student -> student.getNeedNum() != null).collect(Collectors.toList()); |
| | | int sum2 = collect1.stream().mapToInt(CoursePackageStudent::getNeedNum).sum(); |
| | | months.add(sum2); |
| | | } |
| | | map.put("monthData",months); |
| | | |
| | | // 周 |
| | | // 获取最近四周 |
| | | LocalDateTime minNow = LocalDateTime.now().with(LocalTime.MIN); |
| | | LocalDateTime maxNow = LocalDateTime.now().with(LocalTime.MAX); |
| | | // 周度数据 |
| | | LocalDateTime s1 = minNow.minusDays(6); |
| | | LocalDateTime s2 = maxNow; |
| | | |
| | | LocalDateTime s3 = minNow.minusDays(13); |
| | | LocalDateTime s4 = maxNow.minusDays(6); |
| | | |
| | | |
| | | LocalDateTime s5 = minNow.minusDays(20); |
| | | LocalDateTime s6 = maxNow.minusDays(13); |
| | | |
| | | LocalDateTime s7 = minNow.minusDays(27); |
| | | LocalDateTime s8 = maxNow.minusDays(20); |
| | | ArrayList<Object> weekData = new ArrayList<>(); |
| | | |
| | | int count = 0; |
| | | |
| | | int count1 = 0; |
| | | |
| | | int count2 = 0; |
| | | |
| | | int count3 = 0; |
| | | for (CoursePackageStudent coursePackageStudent : list) { |
| | | if (coursePackageStudent.getNeedNum()==null){ |
| | | continue; |
| | | } |
| | | // 如果到课状态为否 则不计算 |
| | | if (coursePackageStudent.getSignInOrNot() != 0) { |
| | | Date insertTime = coursePackageStudent.getInsertTime(); |
| | | Instant instant = insertTime.toInstant(); |
| | | ZoneId zoneId = ZoneId.systemDefault(); |
| | | LocalDateTime dateTime = instant.atZone(zoneId).toLocalDateTime(); |
| | | if (dateTime.isAfter(s1) && dateTime.isBefore(s2)){ |
| | | |
| | | count+=coursePackageStudent.getNeedNum(); |
| | | }else if(dateTime.isAfter(s3) && dateTime.isBefore(s4)){ |
| | | count1+=coursePackageStudent.getNeedNum(); |
| | | }else if(dateTime.isAfter(s5) && dateTime.isBefore(s6)){ |
| | | count2+=coursePackageStudent.getNeedNum(); |
| | | }else if(dateTime.isAfter(s7) && dateTime.isBefore(s8)){ |
| | | count3+=coursePackageStudent.getNeedNum(); |
| | | } |
| | | |
| | | } |
| | | } |
| | | weekData.add(count3); |
| | | weekData.add(count2); |
| | | weekData.add(count1); |
| | | weekData.add(count); |
| | | |
| | | map.put("weekData",weekData); |
| | | |
| | | |
| | | LocalDateTime currentDateTime = LocalDateTime.now(); |
| | | List<Integer> amountByDay = new ArrayList<>(Collections.nCopies(7,0)); |
| | | for (CoursePackageStudent coursePackageStudent : list) { |
| | | Date insertTime = coursePackageStudent.getInsertTime(); |
| | | // 将 Date 转换为 LocalDateTime |
| | | LocalDateTime insertDateTime = LocalDateTime.ofInstant(insertTime.toInstant(), ZoneId.systemDefault()); |
| | | // 计算日期与当前日期的差距 |
| | | long daysDifference = ChronoUnit.DAYS.between(insertDateTime.toLocalDate(), currentDateTime.toLocalDate()); |
| | | // 如果日期在七天内,累加金额 |
| | | if (daysDifference >= 0 && daysDifference < 7) { |
| | | int index = (int) (6 - daysDifference); // 计算对应的索引位置 |
| | | Integer needNum = coursePackageStudent.getNeedNum(); |
| | | if (needNum!=null){ |
| | | int i = amountByDay.get(index) + needNum; |
| | | amountByDay.set(index, i); |
| | | } |
| | | |
| | | } |
| | | } |
| | | map.put("dayData", amountByDay); |
| | | |
| | | return map; |
| | | |
| | | } |
| | | @ResponseBody |
| | | @PostMapping("/coursePackagePayment/courseStore") |
| | | HashMap<String, Object> courseStore(@RequestBody List<Integer> userPt){ |
| | | if(userPt.size()==0){ |
| | | userPt.add(-1); |
| | | } |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | List<TCoursePackagePayment> tCoursePackagePayments = packagePaymentService.listOne(userPt); |
| | | int sum = tCoursePackagePayments.stream().mapToInt(TCoursePackagePayment::getTotalClassHours).sum(); |
| | | int sum1 = tCoursePackagePayments.stream().mapToInt(TCoursePackagePayment::getLaveClassHours).sum(); |
| | | map.put("allCourse",sum-sum1); |
| | | |
| | | //所有课包 |
| | | List<TCoursePackage> coursePackages = tcpService.list(); |
| | | |
| | | |
| | | // 年 |
| | | List<CoursePackageStudent> list = cspsService.list(new LambdaQueryWrapper<CoursePackageStudent>().in(CoursePackageStudent::getAppUserId, userPt)); |
| | | |
| | | |
| | | for (CoursePackageStudent coursePackageStudent : list) { |
| | | for (TCoursePackage coursePackage : coursePackages) { |
| | | if(coursePackageStudent.getCoursePackageId().equals(coursePackage.getId())){ |
| | | if(ToolUtil.isEmpty(coursePackage.getNeedNum())){ |
| | | coursePackageStudent.setNeedNum(0); |
| | | }else { |
| | | coursePackageStudent.setNeedNum(coursePackage.getNeedNum()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | ArrayList<Object> integers = new ArrayList<>(); |
| | | int year = cn.hutool.core.date.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<Integer> years = new ArrayList<>(); |
| | | for (Object o : collect) { |
| | | String s = o.toString(); |
| | | List<CoursePackageStudent> collect1 = list.stream().filter(e -> e.getInsertTime().toString().contains(s)).filter(student -> student.getNeedNum() != null).collect(Collectors.toList()); |
| | | int sum2 = collect1.stream().mapToInt(CoursePackageStudent::getNeedNum).sum(); |
| | | years.add(sum2); |
| | | } |
| | | |
| | | map.put("yearData",years); |
| | | |
| | | |
| | | |
| | | ArrayList<Integer> months = new ArrayList<>(); |
| | | |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | |
| | | |
| | | // 月 |
| | | for (int i = 1; i <= 12; i++) { |
| | | String m=i+""; |
| | | if(i<10){ |
| | | m="0"+i; |
| | | } |
| | | String s = year + "-" + m; |
| | | List<CoursePackageStudent> collect1 = list.stream().filter(e -> format.format(e.getInsertTime()).contains(s)).filter(student -> student.getNeedNum() != null).collect(Collectors.toList()); |
| | | int sum2 = collect1.stream().mapToInt(CoursePackageStudent::getNeedNum).sum(); |
| | | months.add(sum2); |
| | | } |
| | | map.put("monthData",months); |
| | | |
| | | // 周 |
| | | // 获取最近四周 |
| | | LocalDateTime minNow = LocalDateTime.now().with(LocalTime.MIN); |
| | | LocalDateTime maxNow = LocalDateTime.now().with(LocalTime.MAX); |
| | | // 周度数据 |
| | | LocalDateTime s1 = minNow.minusDays(6); |
| | | LocalDateTime s2 = maxNow; |
| | | |
| | | LocalDateTime s3 = minNow.minusDays(13); |
| | | LocalDateTime s4 = maxNow.minusDays(6); |
| | | |
| | | |
| | | LocalDateTime s5 = minNow.minusDays(20); |
| | | LocalDateTime s6 = maxNow.minusDays(13); |
| | | |
| | | LocalDateTime s7 = minNow.minusDays(27); |
| | | LocalDateTime s8 = maxNow.minusDays(20); |
| | | ArrayList<Object> weekData = new ArrayList<>(); |
| | | |
| | | int count = 0; |
| | | |
| | | int count1 = 0; |
| | | |
| | | int count2 = 0; |
| | | |
| | | int count3 = 0; |
| | | for (CoursePackageStudent coursePackageStudent : list) { |
| | | if (coursePackageStudent.getNeedNum()==null){ |
| | | continue; |
| | | } |
| | | // 如果到课状态为否 则不计算 |
| | | if (coursePackageStudent.getSignInOrNot() != 0) { |
| | | Date insertTime = coursePackageStudent.getInsertTime(); |
| | | Instant instant = insertTime.toInstant(); |
| | | ZoneId zoneId = ZoneId.systemDefault(); |
| | | LocalDateTime dateTime = instant.atZone(zoneId).toLocalDateTime(); |
| | | if (dateTime.isAfter(s1) && dateTime.isBefore(s2)){ |
| | | |
| | | count+=coursePackageStudent.getNeedNum(); |
| | | }else if(dateTime.isAfter(s3) && dateTime.isBefore(s4)){ |
| | | count1+=coursePackageStudent.getNeedNum(); |
| | | }else if(dateTime.isAfter(s5) && dateTime.isBefore(s6)){ |
| | | count2+=coursePackageStudent.getNeedNum(); |
| | | }else if(dateTime.isAfter(s7) && dateTime.isBefore(s8)){ |
| | | count3+=coursePackageStudent.getNeedNum(); |
| | | } |
| | | |
| | | } |
| | | } |
| | | weekData.add(count3); |
| | | weekData.add(count2); |
| | | weekData.add(count1); |
| | | weekData.add(count); |
| | | |
| | | map.put("weekData",weekData); |
| | | |
| | | |
| | | LocalDateTime currentDateTime = LocalDateTime.now(); |
| | | List<Integer> amountByDay = new ArrayList<>(Collections.nCopies(7,0)); |
| | | for (CoursePackageStudent coursePackageStudent : list) { |
| | | Date insertTime = coursePackageStudent.getInsertTime(); |
| | | // 将 Date 转换为 LocalDateTime |
| | | LocalDateTime insertDateTime = LocalDateTime.ofInstant(insertTime.toInstant(), ZoneId.systemDefault()); |
| | | // 计算日期与当前日期的差距 |
| | | long daysDifference = ChronoUnit.DAYS.between(insertDateTime.toLocalDate(), currentDateTime.toLocalDate()); |
| | | // 如果日期在七天内,累加金额 |
| | | if (daysDifference >= 0 && daysDifference < 7) { |
| | | int index = (int) (6 - daysDifference); // 计算对应的索引位置 |
| | | Integer needNum = coursePackageStudent.getNeedNum(); |
| | | if (needNum!=null){ |
| | | int i = amountByDay.get(index) + needNum; |
| | | amountByDay.set(index, i); |
| | | } |
| | | |
| | | } |
| | | } |
| | | map.put("dayData", amountByDay); |
| | | |
| | | return map; |
| | | |
| | | } |
| | | } |