puzhibing
2023-12-14 d20dbd5d97b3f418533d5d23fd337cdec9f95939
cloud-server-account/src/main/java/com/dsh/account/service/impl/TStudentServiceImpl.java
@@ -48,6 +48,9 @@
import java.math.RoundingMode;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.*;
import java.util.stream.Collectors;
@@ -163,6 +166,7 @@
        saveParticipant.setWeight(student.getWeight());
        saveParticipant.setPhone(student.getPhone());
        saveParticipant.setIdcard(student.getIdCard());
        participantClient.saveParticipant(saveParticipant);
        return ResultUtil.success();
    }
@@ -603,9 +607,17 @@
                                .filter(record -> {
                                    try {
                                        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
                                        String substring = record.getTimeFrame().substring(11);
                                        String substring = record.getTimeFrame().substring(0,16);
                                        Date time = sdf.parse(substring);
                                        return !time.before(lastWeekStartDate) && !time.after(lastOfDate);
                                        Instant instant = time.toInstant();
                                        LocalDate dateToCheck = instant.atZone(ZoneId.systemDefault()).toLocalDate();
                                        // 获取今天的日期
                                        LocalDate today = LocalDate.now();
                                        // 计算一周前的日期
                                        LocalDate oneWeekAgo = today.minusWeeks(1);
                                        // 计算一周后的日期
                                        LocalDate oneWeekLater = today.plusWeeks(1);
                                        return dateToCheck.isAfter(oneWeekAgo) && dateToCheck.isBefore(oneWeekLater);
                                    } catch (ParseException e) {
                                        e.printStackTrace();
                                        return false;
@@ -618,9 +630,18 @@
                        recordAppoints = recordAppoints.stream()
                                .filter(record -> {
                                    try {
                                        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                                        Date time = sdf.parse(record.getTimeFrame().substring(11));
                                        return !time.before(lastMonthStartDate) && !time.after(lastOfDate);
                                        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
                                        String substring = record.getTimeFrame().substring(0,16);
                                        Date time = sdf.parse(substring);
                                        Instant instant = time.toInstant();
                                        LocalDate dateToCheck = instant.atZone(ZoneId.systemDefault()).toLocalDate();
                                        // 获取今天的日期
                                        LocalDate today = LocalDate.now();
                                        // 计算一周前的日期
                                        LocalDate oneWeekAgo = today.minusMonths(1);
                                        // 计算一周后的日期
                                        LocalDate oneWeekLater = today.plusMonths(1);
                                        return dateToCheck.isAfter(oneWeekAgo) && dateToCheck.isBefore(oneWeekLater);
                                    } catch (ParseException e) {
                                        e.printStackTrace();
                                        return false;
@@ -634,8 +655,17 @@
                                .filter(record -> {
                                    try {
                                        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
                                        Date time = sdf.parse(record.getTimeFrame().substring(11));
                                        return !time.before(lastYearStartDate) && !time.after(lastOfDate);
                                        String substring = record.getTimeFrame().substring(0,16);
                                        Date time = sdf.parse(substring);
                                        Instant instant = time.toInstant();
                                        LocalDate dateToCheck = instant.atZone(ZoneId.systemDefault()).toLocalDate();
                                        // 获取今天的日期
                                        LocalDate today = LocalDate.now();
                                        // 计算一周前的日期
                                        LocalDate oneWeekAgo = today.minusYears(1);
                                        // 计算一周后的日期
                                        LocalDate oneWeekLater = today.plusYears(1);
                                        return dateToCheck.isAfter(oneWeekAgo) && dateToCheck.isBefore(oneWeekLater);
                                    } catch (ParseException e) {
                                        e.printStackTrace();
                                        return false;
@@ -684,14 +714,26 @@
        citycodeResp.setLatitude(longitude);
        List<StoreDetailList> queryStoreList = storeClient.getQueryStoreList(citycodeResp);
        if (queryStoreList.size() > 0) {
            if (ToolUtil.isEmpty(space) || space == 2) {
            if (ToolUtil.isEmpty(space) || space ==1) {
                queryStoreList = queryStoreList.stream().sorted(Comparator.comparing(o -> o.getStoreDistance())).collect(Collectors.toList());
            } else {
                queryStoreList = queryStoreList.stream()
                        .sorted(Comparator.comparing(StoreDetailList::getStoreDistance).reversed())
                        .collect(Collectors.toList());
            } else {
                queryStoreList = queryStoreList.stream().sorted(Comparator.comparing(o -> o.getStoreDistance())).collect(Collectors.toList());
            }
//            if (ToolUtil.isEmpty(space) || space == 2) {
//                queryStoreList = queryStoreList.stream()
//                        .sorted(Comparator.comparing(StoreDetailList::getStoreDistance).reversed())
//                        .collect(Collectors.toList());
//
//            } else {
//                queryStoreList = queryStoreList.stream().sorted(Comparator.comparing(o -> o.getStoreDistance())).collect(Collectors.toList());
//            }
            if (ToolUtil.isNotEmpty(search)) {
                queryStoreList = queryStoreList.stream().filter(o -> o.getStoreName().contains(search)).collect(Collectors.toList());
            }