package shop.alien.job.store;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import shop.alien.config.redis.BaseRedisService;
import shop.alien.entity.store.*;
import shop.alien.mapper.*;

import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import java.time.temporal.ChronoField;
import java.util.*;
import java.util.stream.Collectors;

@Slf4j
@Component
@RequiredArgsConstructor
public class DeliciousFoodJob {
    // 零点
    private final static String ZERO_TIME = "00:00";
    // twoTime
    private final static String TWO_TIME = "02:00";
    // sixTime
    private final static String SIX_TIME = "06:00";
    // nineTime
    private final static String NINE_TIME = "09:00";
    // elevenTime
    private final static String ELEVEN_TIME = "11:00";
    // fourteenTime
    private final static String FOURTEEN_TIME = "14:00";
    // seventeenTime
    private final static String SEVENTEEN_TIME = "17:00";
    // twentyTime
    private final static String TWENTY_TIME = "20:00";
    // twenty_twoTime
    private final static String TWENTY_TWO_TIME = "22:00";
    // 23:59
    private final static String TWENTY_FOUR_TIME = "23:59";

    private final StoreBusinessInfoMapper storeBusinessInfoMapper;

    private final EssentialModuleInformationMapper informationMapper;

    private final BaseRedisService baseRedisService;

    private final LifeCouponMapper lifeCouponMapper;

    private final StoreInfoMapper storeInfoMapper;

    private final StoreLabelTypeMapper storeLabelTypeMapper;

    private final StoreEvaluationMapper storeEvaluationMapper;

    /**
     * 美食筛选标签定时存储数据
     */
    @XxlJob("deliciousFoodJob")
    public void deliciousFoodJob() {
        // 获取所有美食筛选
        List<EssentialModuleInformation> essentialModuleInformations = informationMapper.selectList(
                new LambdaQueryWrapper<EssentialModuleInformation>().eq(EssentialModuleInformation::getParentId, 12));
        // 获取所有商家的营业时间
        List<StoreBusinessInfo> storeBusinessInfos = storeBusinessInfoMapper.selectBusinessInfo("美食");
        // 获取所有的代金券价格
        List<LifeCoupon> lifeCoupons = lifeCouponMapper.selectCoupon("美食");
        // 获取所有的商家信息
        List<StoreInfo> storeInfos = storeInfoMapper.selectList(new LambdaQueryWrapper<StoreInfo>().eq(StoreInfo::getBusinessSectionName, "美食"));
        // 获取所有美食门店标签
        List<StoreLabelType> storeLabelTypes = storeLabelTypeMapper.selectList(new LambdaQueryWrapper<StoreLabelType>().eq(StoreLabelType::getStoreType, "美食"));

        for (EssentialModuleInformation essentialModuleInformation : essentialModuleInformations) {
            Integer informationId = essentialModuleInformation.getId();
            // 获取所有数据值
            List<EssentialModuleInformation> businessHours = informationMapper.selectList(
                    new LambdaQueryWrapper<EssentialModuleInformation>().eq(EssentialModuleInformation::getParentId, informationId));
            switch (informationId) {
                case 303:
                    for (EssentialModuleInformation businessHour : businessHours) {
                        Integer businessHourId = businessHour.getId();
                        // 获取符合的商家
                        List<StoreBusinessInfo> list = new ArrayList<>();
                        // 获取过滤后列表中每个对象的 storeId 字段，并用逗号连接成字符串
                        String storeIds = "";
                        switch (businessHourId) {
                            case 313:  // 营业中
                                //获取当前时间
                                Date date = new Date();
                                SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
                                String time = sdf.format(date);
                                // 将字符串解析为 LocalTime 对象
                                LocalTime localTime = LocalTime.parse(time);
                                DateTimeFormatter formatter = new DateTimeFormatterBuilder()
                                        .appendValue(ChronoField.HOUR_OF_DAY, 1, 2, java.time.format.SignStyle.NOT_NEGATIVE)
                                        .appendLiteral(':')
                                        .appendValue(ChronoField.MINUTE_OF_HOUR, 2)
                                        .toFormatter();
                                // 获取当前在营业的商家
                                list = storeBusinessInfos.stream()
                                        .filter(item -> localTime.isBefore(LocalTime.parse(item.getEndTime(), formatter)))
                                        .collect(Collectors.toList());
                                storeIds = list.stream()
                                        .map(item -> String.valueOf(item.getStoreId()))
                                        .collect(Collectors.joining(","));
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("313", storeIds);
                                break;
                            case 314: // 24小时营业
                                list = storeBusinessInfos.stream()
                                        .filter(item -> ZERO_TIME.equals(item.getStartTime()) && TWENTY_FOUR_TIME.equals(item.getEndTime()))
                                        .collect(Collectors.toList());
                                // 获取过滤后列表中每个对象的 storeId 字段，并用逗号连接成字符串
                                storeIds = list.stream()
                                        .map(item -> String.valueOf(item.getStoreId()))
                                        .collect(Collectors.joining(","));
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("314", storeIds);
                                break;
                            case 315: // 6-9点
                                storeIds = getStoreBusinessInfos(storeBusinessInfos, SIX_TIME, NINE_TIME);
                                baseRedisService.setString("315", storeIds);
                                break;
                            case 316: // 11-14点
                                storeIds = getStoreBusinessInfos(storeBusinessInfos, ELEVEN_TIME, FOURTEEN_TIME);
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("316", storeIds);
                                break;
                            case 317: // 14-17点
                                storeIds = getStoreBusinessInfos(storeBusinessInfos, FOURTEEN_TIME, SEVENTEEN_TIME);
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("317", storeIds);
                                break;
                            case 318: // 17-20点
                                storeIds = getStoreBusinessInfos(storeBusinessInfos, SEVENTEEN_TIME, TWENTY_TIME);
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("318", storeIds);
                                break;
                            case 319: // 22-2点
                                storeIds = getStoreBusinessInfos(storeBusinessInfos, TWENTY_TWO_TIME, TWO_TIME);
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("319", storeIds);
                                break;
                            default:
                                break;
                        }
                    }
                    break;
                case 304:
                    for (EssentialModuleInformation businessHour : businessHours) {
                        Integer businessHourId = businessHour.getId();
                        // 获取符合的商家
                        List<LifeCoupon> list = new ArrayList<>();
                        // 获取过滤后列表中每个对象的 storeId 字段，并用逗号连接成字符串
                        String storeIds = "";
                        switch (businessHourId) {
                            case 321:  // 50一下
                                storeIds = getLifeCoupons(lifeCoupons, 0, 50);
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("321", storeIds);
                                break;
                            case 322: // 50-100
                                storeIds = getLifeCoupons(lifeCoupons, 50, 100);
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("322", storeIds);
                                break;
                            case 323: // 100-150
                                storeIds = getLifeCoupons(lifeCoupons, 100, 150);
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("323", storeIds);
                                break;
                            case 324: // 150-200
                                storeIds = getLifeCoupons(lifeCoupons, 150, 200);
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("324", storeIds);
                                break;
                            case 325: // 200-300
                                storeIds = getLifeCoupons(lifeCoupons, 200, 300);
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("325", storeIds);
                                break;
                            case 326: // 300以上
                                storeIds = getLifeCoupons(lifeCoupons, 300, Integer.MAX_VALUE);
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("326", storeIds);
                                break;
                            default:
                                break;
                        }
                    }
                    break;
                case 307:
                    for (EssentialModuleInformation businessHour : businessHours) {
                        Integer businessHourId = businessHour.getId();
                        // 获取符合的商家
                        List<StoreInfo> list = new ArrayList<>();
                        // 获取过滤后列表中每个对象的 storeId 字段，并用逗号连接成字符串
                        String storeIds = "";
                        switch (businessHourId) {
                            case 342:  // 新店
                                // 获取当前时间三年前的日期
                                LocalDate threeYearsAgo = LocalDate.now().minusYears(3);
                                // 筛选出 createdTime 小于三年前的 StoreInfo 对象
                                list = storeInfos.stream()
                                        .filter(item -> {
                                            // 将 Date 转换为 LocalDate
                                            LocalDate createdDate = item.getCreatedTime().toInstant()
                                                    .atZone(ZoneId.systemDefault())
                                                    .toLocalDate();
                                            return createdDate.isAfter(threeYearsAgo);
                                        })
                                        .collect(Collectors.toList());
                                // 获取过滤后列表中每个对象的 storeId 字段，并用逗号连接成字符串
                                storeIds = list.stream()
                                        .map(item -> String.valueOf(item.getId()))
                                        .collect(Collectors.joining(","));
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("342", storeIds);
                                break;
                            case 343: // 三年以上
                                storeIds = getStoreInfos(storeInfos, LocalDate.now().minusYears(3));
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("343", storeIds);
                                break;
                            case 344: // 五年以上
                                storeIds = getStoreInfos(storeInfos, LocalDate.now().minusYears(5));
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("344", storeIds);
                                break;
                            case 345: // 10年以上
                                storeIds = getStoreInfos(storeInfos, LocalDate.now().minusYears(10));
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("345", storeIds);
                                break;
                            default:
                                break;
                        }
                    }
                    break;
                case 305:
                    for (EssentialModuleInformation businessHour : businessHours) {
                        Integer businessHourId = businessHour.getId();
                        List<LifeCoupon> list = new ArrayList<>();
                        // 获取过滤后列表中每个对象的 storeId 字段，并用逗号连接成字符串
                        String storeIds = "";
                        switch (businessHourId) {
                            case 331:  // 促销
                                storeIds = getLifeYouhui(lifeCoupons, "0");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("331", storeIds);
                                break;
                            case 329: // 套餐/代金券
                                storeIds = getLifeYouhui(lifeCoupons, "1");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("329", storeIds);
                                break;
                            case 330: // 买单立减
                                storeIds = getLifeYouhui(lifeCoupons, "2");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("330", storeIds);
                                break;
                            case 332: // 单人餐
                                storeIds = getLifeYouhui(lifeCoupons, "3");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("332", storeIds);
                                break;
                            case 333: // 双人餐
                                storeIds = getLifeYouhui(lifeCoupons, "4");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("333", storeIds);
                                break;
                            case 334: // 3-4人餐
                                storeIds = getLifeYouhui(lifeCoupons, "5");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("334", storeIds);
                                break;
                            case 335: // 5-10人餐
                                storeIds = getLifeYouhui(lifeCoupons, "6");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("335", storeIds);
                                break;
                            default:
                                break;
                        }

                    }
                    break;
                case 310:
                    for (EssentialModuleInformation businessHour : businessHours) {
                        Integer businessHourId = businessHour.getId();
                        // 获取符合的商家
                        List<StoreLabel> list = new ArrayList<>();
                        // 获取过滤后列表中每个对象的 storeId 字段，并用逗号连接成字符串
                        String storeIds = "";
                        switch (businessHourId) {
                            case 358: // 免费停车
                                storeIds = getStoreLabelTypes(storeLabelTypes, "358");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("358", storeIds);
                                break;
                            case 359: // 可带宠物
                                storeIds = getStoreLabelTypes(storeLabelTypes, "359");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("359", storeIds);
                                break;
                            case 360: // 不可吸烟
                                storeIds = getStoreLabelTypes(storeLabelTypes, "360");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("360", storeIds);
                                break;
                            case 2938: // 近机场
                                storeIds = getStoreLabelTypes(storeLabelTypes, "2938");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("2938", storeIds);
                                break;
                            default:
                                break;
                        }
                    }
                    break;
                case 309:
                    for (EssentialModuleInformation businessHour : businessHours) {
                        Integer businessHourId = businessHour.getId();
                        // 获取符合的商家
                        List<StoreLabel> list = new ArrayList<>();
                        // 获取过滤后列表中每个对象的 storeId 字段，并用逗号连接成字符串
                        String storeIds = "";
                        switch (businessHourId) {
                            case 352: // 有包厢
                                storeIds = getStoreLabelTypes(storeLabelTypes, "352");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("352", storeIds);
                                break;
                            case 353: // 10人以上包厢
                                storeIds = getStoreLabelTypes(storeLabelTypes, "353");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("353", storeIds);
                                break;
                            case 354: // 10人以下包厢
                                storeIds = getStoreLabelTypes(storeLabelTypes, "354");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("354", storeIds);
                                break;
                            case 355: // 双人包厢
                                storeIds = getStoreLabelTypes(storeLabelTypes, "355");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("355", storeIds);
                                break;
                            case 356: // 10人以上大桌
                                storeIds = getStoreLabelTypes(storeLabelTypes, "356");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("356", storeIds);
                                break;
                            case 357: // 8-10人大桌
                                storeIds = getStoreLabelTypes(storeLabelTypes, "357");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("357", storeIds);
                                break;
                            default:
                                break;
                        }
                    }
                    break;
                case 306:
                    for (EssentialModuleInformation businessHour : businessHours) {
                        Integer businessHourId = businessHour.getId();
                        // 获取符合的商家
                        List<StoreLabel> list = new ArrayList<>();
                        // 获取过滤后列表中每个对象的 storeId 字段，并用逗号连接成字符串
                        String storeIds = "";
                        switch (businessHourId) {
                            case 336: // 五星餐厅
                                // 筛选出 box 等于 1 的 StoreLabel 对象
                                storeIds = getStoreLabelTypes(storeLabelTypes, "336");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("336", storeIds);
                                break;
                            case 337: // 四星餐厅
                                // 筛选出 box 等于 1 的 StoreLabel 对象
                                storeIds = getStoreLabelTypes(storeLabelTypes, "337");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("337", storeIds);
                                break;
                            case 338: // 上榜餐厅
                                // 筛选出 box 等于 1 的 StoreLabel 对象
                                storeIds = getStoreLabelTypes(storeLabelTypes, "338");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("338", storeIds);
                                break;
                            case 341: // 当地推荐
                                // 筛选出 box 等于 1 的 StoreLabel 对象
                                storeIds = getStoreLabelTypes(storeLabelTypes, "341");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("341", storeIds);
                                break;
                            default:
                                break;
                        }
                    }
                    break;
                case 308:
                    for (EssentialModuleInformation businessHour : businessHours) {
                        Integer businessHourId = businessHour.getId();
                        // 获取符合的商家
                        List<StoreLabel> list = new ArrayList<>();
                        // 获取过滤后列表中每个对象的 storeId 字段，并用逗号连接成字符串
                        String storeIds = "";
                        switch (businessHourId) {
                            case 346: // 多人聚餐
                                storeIds = getStoreLabelTypes(storeLabelTypes, "346");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("346", storeIds);
                                break;
                            case 347: // 商务宴请
                                storeIds = getStoreLabelTypes(storeLabelTypes, "347");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("347", storeIds);
                                break;
                            case 348: // 情侣约会
                                storeIds = getStoreLabelTypes(storeLabelTypes, "348");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("348", storeIds);
                                break;
                            case 349: // 生日聚会
                                storeIds = getStoreLabelTypes(storeLabelTypes, "349");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("349", storeIds);
                                break;
                            case 350: // 闺蜜小聚
                                storeIds = getStoreLabelTypes(storeLabelTypes, "350");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("350", storeIds);
                                break;
                            case 351: // 带娃吃饭
                                storeIds = getStoreLabelTypes(storeLabelTypes, "351");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("351", storeIds);
                                break;
                            default:
                                break;
                        }
                    }
                    break;
                case 311:
                    for (EssentialModuleInformation businessHour : businessHours) {
                        Integer businessHourId = businessHour.getId();
                        // 获取符合的商家
                        List<StoreLabel> list = new ArrayList<>();
                        // 获取过滤后列表中每个对象的 storeId 字段，并用逗号连接成字符串
                        String storeIds = "";
                        switch (businessHourId) {
                            case 362: // 在线订座
                                storeIds = getStoreLabelTypes(storeLabelTypes, "362");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("362", storeIds);
                                break;
                            case 363: // 在线排队
                                storeIds = getStoreLabelTypes(storeLabelTypes, "363");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("363", storeIds);
                                break;
                            default:
                                break;
                        }

                    }
                default:
                    break;
            }
        }

        // 获取所有美食
        List<EssentialModuleInformation> moduleInformations = informationMapper.selectList(
                new LambdaQueryWrapper<EssentialModuleInformation>().eq(EssentialModuleInformation::getParentId, 11));
        storeInfoHandle(moduleInformations);

        // 行政区
        administrativeRegion(storeInfos);
    }

    /**
     * 酒店和民宿筛选标签定时存储数据
     */
    @XxlJob("hotelAndHomestayJob")
    public void hotelAndHomestayJob() {
        // 获取所有酒店民宿筛选
        List<EssentialModuleInformation> essentialModuleInformations = informationMapper.selectList(
                new LambdaQueryWrapper<EssentialModuleInformation>().eq(EssentialModuleInformation::getParentId, 1648));
        // 获取所有酒店民宿门店标签
        List<StoreLabelType> storeLabelTypes = storeLabelTypeMapper.selectList(new LambdaQueryWrapper<StoreLabelType>().eq(StoreLabelType::getStoreType, "酒店民宿"));
        // 获取所有的代金券价格
        List<LifeCoupon> lifeCoupons = lifeCouponMapper.selectCoupon("酒店民宿");
        // 获取所有的商家信息
        List<StoreInfo> storeInfos = storeInfoMapper.selectList(new LambdaQueryWrapper<StoreInfo>().eq(StoreInfo::getBusinessSectionName, "酒店民宿"));
        for (EssentialModuleInformation essentialModuleInformation : essentialModuleInformations) {
            Integer moduleInformationId = essentialModuleInformation.getId();
            // 获取所有数据值
            List<EssentialModuleInformation> businessHours = informationMapper.selectList(
                    new LambdaQueryWrapper<EssentialModuleInformation>().eq(EssentialModuleInformation::getParentId, moduleInformationId));
            List<EssentialModuleInformation> informations = new ArrayList<>();
            switch (moduleInformationId) {
                case 1666:
                    for (EssentialModuleInformation businessHour : businessHours) {
                        Integer businessHourId = businessHour.getId();
                        switch (businessHourId) {
                            case 1679: // 床型
                                // 获取所有床型
                                informations = informationMapper.selectList(
                                        new LambdaQueryWrapper<EssentialModuleInformation>().eq(EssentialModuleInformation::getParentId, 1679));
                                for (EssentialModuleInformation information : informations) {
                                    Integer informationId = information.getId();
                                    // 获取过滤后列表中每个对象的 storeId 字段，并用逗号连接成字符串
                                    String storeIds = "";
                                    switch (informationId) {
                                        case 1681: // 大床房
                                            storeIds = getStoreLabelTypes(storeLabelTypes, "1681");
                                            // 将商家storeId添加到redis中
                                            baseRedisService.setString("1681", storeIds);
                                            break;
                                        case 1682: // 双床房
                                            storeIds = getStoreLabelTypes(storeLabelTypes, "1682");
                                            // 将商家storeId添加到redis中
                                            baseRedisService.setString("1682", storeIds);
                                            break;
                                        case 1683: // 三床房
                                            storeIds = getStoreLabelTypes(storeLabelTypes, "1683");
                                            // 将商家storeId添加到redis中
                                            baseRedisService.setString("1683", storeIds);
                                            break;
                                        case 1684: // 多床房
                                            storeIds = getStoreLabelTypes(storeLabelTypes, "1684");
                                            // 将商家storeId添加到redis中
                                            baseRedisService.setString("1684", storeIds);
                                            break;
                                        case 1685: // 家庭房
                                            storeIds = getStoreLabelTypes(storeLabelTypes, "1685");
                                            // 将商家storeId添加到redis中
                                            baseRedisService.setString("1685", storeIds);
                                            break;
                                        default:
                                            break;
                                    }
                                }
                                break;
                            case 1680: // 餐食
                                // 获取所有餐食
                                informations = informationMapper.selectList(
                                        new LambdaQueryWrapper<EssentialModuleInformation>().eq(EssentialModuleInformation::getParentId, 1680));
                                for (EssentialModuleInformation information : informations) {
                                    Integer informationId = information.getId();
                                    // 获取过滤后列表中每个对象的 storeId 字段，并用逗号连接成字符串
                                    String storeIds = "";
                                    switch (informationId) {
                                        case 1686: // 单份早餐
                                            storeIds = getStoreLabelTypes(storeLabelTypes, "1686");
                                            // 将商家storeId添加到redis中
                                            baseRedisService.setString("1686", storeIds);
                                            break;
                                        case 1687: // 双份早餐
                                            storeIds = getStoreLabelTypes(storeLabelTypes, "1687");
                                            // 将商家storeId添加到redis中
                                            baseRedisService.setString("1687", storeIds);
                                            break;
                                        case 1688: // 含早餐
                                            storeIds = getStoreLabelTypes(storeLabelTypes, "1688");
                                            // 将商家storeId添加到redis中
                                            baseRedisService.setString("1688", storeIds);
                                            break;
                                        default:
                                            break;
                                    }
                                }
                                break;
                            default:
                                break;
                        }

                    }
                    break;
                case 1667:
                    for (EssentialModuleInformation businessHour : businessHours) {
                        Integer businessHourId = businessHour.getId();
                        switch (businessHourId) {
                            case 1689: // 公共设施
                                // 获取所有床型
                                informations = informationMapper.selectList(
                                        new LambdaQueryWrapper<EssentialModuleInformation>().eq(EssentialModuleInformation::getParentId, 1689));
                                for (EssentialModuleInformation information : informations) {
                                    Integer informationId = information.getId();
                                    // 获取过滤后列表中每个对象的 storeId 字段，并用逗号连接成字符串
                                    String storeIds = "";
                                    switch (informationId) {
                                        case 1691: // 健身房
                                            storeIds = getStoreLabelTypes(storeLabelTypes, "1691");
                                            // 将商家storeId添加到redis中
                                            baseRedisService.setString("1691", storeIds);
                                            break;
                                        case 1692: // 游泳池
                                            storeIds = getStoreLabelTypes(storeLabelTypes, "1692");
                                            // 将商家storeId添加到redis中
                                            baseRedisService.setString("1692", storeIds);
                                            break;
                                        case 1693: // 免费机场班车
                                            storeIds = getStoreLabelTypes(storeLabelTypes, "1693");
                                            // 将商家storeId添加到redis中
                                            baseRedisService.setString("1693", storeIds);
                                            break;
                                        case 2939: // 免费停车场
                                            storeIds = getStoreLabelTypes(storeLabelTypes, "2939");
                                            // 将商家storeId添加到redis中
                                            baseRedisService.setString("2939", storeIds);
                                            break;
                                        default:
                                            break;
                                    }
                                }
                                break;
                            case 1690: // 客房设施
                                // 获取所有餐食
                                informations = informationMapper.selectList(
                                        new LambdaQueryWrapper<EssentialModuleInformation>().eq(EssentialModuleInformation::getParentId, 1690));
                                for (EssentialModuleInformation information : informations) {
                                    Integer informationId = information.getId();
                                    // 获取过滤后列表中每个对象的 storeId 字段，并用逗号连接成字符串
                                    String storeIds = "";
                                    switch (informationId) {
                                        case 1694: // 厨房
                                            storeIds = getStoreLabelTypes(storeLabelTypes, "1694");
                                            // 将商家storeId添加到redis中
                                            baseRedisService.setString("1694", storeIds);
                                            break;
                                        case 1695: // 空调
                                            storeIds = getStoreLabelTypes(storeLabelTypes, "1695");
                                            // 将商家storeId添加到redis中
                                            baseRedisService.setString("1695", storeIds);
                                            break;
                                        case 1696: // WIFI
                                            storeIds = getStoreLabelTypes(storeLabelTypes, "1696");
                                            // 将商家storeId添加到redis中
                                            baseRedisService.setString("1696", storeIds);
                                        case 1697: // 浴缸
                                            storeIds = getStoreLabelTypes(storeLabelTypes, "1697");
                                            // 将商家storeId添加到redis中
                                            baseRedisService.setString("1697", storeIds);
                                            break;
                                        default:
                                            break;
                                    }
                                }
                                break;
                            default:
                                break;
                        }

                    }
                    break;
                case 1668:
                    // 获取所有特色民宿
                    informations = informationMapper.selectList(
                            new LambdaQueryWrapper<EssentialModuleInformation>().eq(EssentialModuleInformation::getParentId, 1668));
                    for (EssentialModuleInformation information : informations) {
                        Integer informationId = information.getId();
                        // 获取过滤后列表中每个对象的 storeId 字段，并用逗号连接成字符串
                        String storeIds = "";
                        switch (informationId) {
                            case 1698: // 民宿
                                storeIds = getStoreLabelTypes(storeLabelTypes, "1698");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("1698", storeIds);
                                break;
                            case 1699: // 棋牌房
                                storeIds = getStoreLabelTypes(storeLabelTypes, "1699");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("1699", storeIds);
                                break;
                            case 1700: // 电竞房
                                storeIds = getStoreLabelTypes(storeLabelTypes, "1700");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("1700", storeIds);
                                break;
                            case 1701: // 酒店公寓
                                storeIds = getStoreLabelTypes(storeLabelTypes, "1701");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("1701", storeIds);
                                break;
                            case 1702: // 复式Loft
                                storeIds = getStoreLabelTypes(storeLabelTypes, "1702");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("1702", storeIds);
                                break;
                            case 1703: // 别墅
                                storeIds = getStoreLabelTypes(storeLabelTypes, "1703");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("1703", storeIds);
                                break;
                            default:
                                break;
                        }
                    }
                    break;
                case 1670:
                    // 获取所有政策服务
                    informations = informationMapper.selectList(
                            new LambdaQueryWrapper<EssentialModuleInformation>().eq(EssentialModuleInformation::getParentId, 1670));
                    for (EssentialModuleInformation information : informations) {
                        Integer informationId = information.getId();
                        // 获取过滤后列表中每个对象的 storeId 字段，并用逗号连接成字符串
                        String storeIds = "";
                        switch (informationId) {
                            case 1717: // 接送机/站
                                storeIds = getStoreLabelTypes(storeLabelTypes, "1717");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("1717", storeIds);
                                break;
                            case 1718: // 可携带宠物
                                storeIds = getStoreLabelTypes(storeLabelTypes, "1718");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("1718", storeIds);
                                break;
                            case 1719: // 可取消
                                storeIds = getStoreLabelTypes(storeLabelTypes, "1719");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("1719", storeIds);
                                break;
                            default:
                                break;
                        }
                    }
                    break;
                case 1671:
                    // 获取所有酒店周边
                    informations = informationMapper.selectList(
                            new LambdaQueryWrapper<EssentialModuleInformation>().eq(EssentialModuleInformation::getParentId, 1671));
                    for (EssentialModuleInformation information : informations) {
                        Integer informationId = information.getId();
                        // 获取过滤后列表中每个对象的 storeId 字段，并用逗号连接成字符串
                        String storeIds = "";
                        switch (informationId) {
                            case 1720: // 近地铁
                                storeIds = getStoreLabelTypes(storeLabelTypes, "1720");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("1720", storeIds);
                                break;
                            case 1721: // 近海边
                                storeIds = getStoreLabelTypes(storeLabelTypes, "1721");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("1721", storeIds);
                                break;
                            case 1722: // 近景点
                                storeIds = getStoreLabelTypes(storeLabelTypes, "1722");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("1722", storeIds);
                            case 1723: // 近机场
                                storeIds = getStoreLabelTypes(storeLabelTypes, "1723");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("1723", storeIds);
                                break;
                            default:
                                break;
                        }
                    }
                    break;
                case 1669:
                    List<StoreEvaluation> storeEvaluations = storeEvaluationMapper.selectList(new LambdaQueryWrapper<StoreEvaluation>().eq(StoreEvaluation::getEvaluationTagsType, "酒店民宿"));
                    for (EssentialModuleInformation businessHour : businessHours) {
                        Integer businessHourId = businessHour.getId();
                        switch (businessHourId) {
                            case 1704: // 评分
                                // 获取所有床型
                                informations = informationMapper.selectList(
                                        new LambdaQueryWrapper<EssentialModuleInformation>().eq(EssentialModuleInformation::getParentId, 1704));
                                for (EssentialModuleInformation information : informations) {
                                    Integer informationId = information.getId();
                                    // 获取过滤后列表中每个对象的 storeId 字段，并用逗号连接成字符串
                                    String storeIds = "";
                                    switch (informationId) {
                                        case 1707: // 4.8分以上
                                            // 使用流对数据进行分组并计算平均值，筛选出结果大于 4.8 的分组
                                            storeIds = storeEvaluations.stream()
                                                    .collect(Collectors.groupingBy(
                                                            StoreEvaluation::getStoreId,
                                                            Collectors.averagingDouble(StoreEvaluation::getScore)
                                                    ))
                                                    .entrySet().stream()
                                                    .filter(entry -> entry.getValue() > 4.8)
                                                    .map(Map.Entry::getKey)
                                                    .collect(Collectors.joining(","));
                                            // 将商家storeId添加到redis中
                                            baseRedisService.setString("1707", storeIds);
                                            break;
                                        case 1708: // 4.5分以上
                                            // 使用流对数据进行分组并计算平均值，筛选出结果大于 4.5 的分组
                                            storeIds = storeEvaluations.stream()
                                                    .collect(Collectors.groupingBy(
                                                            StoreEvaluation::getStoreId,
                                                            Collectors.averagingDouble(StoreEvaluation::getScore)
                                                    ))
                                                    .entrySet().stream()
                                                    .filter(entry -> entry.getValue() > 4.5)
                                                    .map(Map.Entry::getKey)
                                                    .collect(Collectors.joining(","));
                                            // 将商家storeId添加到redis中
                                            baseRedisService.setString("1708", storeIds);
                                            break;
                                        case 1709: // 4.2分以上
                                            // 使用流对数据进行分组并计算平均值，筛选出结果大于 4.2 的分组
                                            storeIds = storeEvaluations.stream()
                                                    .collect(Collectors.groupingBy(
                                                            StoreEvaluation::getStoreId,
                                                            Collectors.averagingDouble(StoreEvaluation::getScore)
                                                    ))
                                                    .entrySet().stream()
                                                    .filter(entry -> entry.getValue() > 4.2)
                                                    .map(Map.Entry::getKey)
                                                    .collect(Collectors.joining(","));
                                            // 将商家storeId添加到redis中
                                            baseRedisService.setString("1709", storeIds);
                                            break;
                                        default:
                                            break;
                                    }
                                }
                                break;
                            case 1705: // 评论数
                                // 获取所有餐食
                                informations = informationMapper.selectList(
                                        new LambdaQueryWrapper<EssentialModuleInformation>().eq(EssentialModuleInformation::getParentId, 1705));
                                for (EssentialModuleInformation information : informations) {
                                    Integer informationId = information.getId();
                                    // 获取过滤后列表中每个对象的 storeId 字段，并用逗号连接成字符串
                                    String storeIds = "";
                                    switch (informationId) {
                                        case 1710: // 200条以上
                                            // 获取评论200以上的商家
                                            storeIds = storeEvaluations.stream()
                                                    .collect(Collectors.groupingBy(
                                                            StoreEvaluation::getStoreId,
                                                            Collectors.counting()
                                                    ))
                                                    .entrySet().stream()
                                                    .filter(entry -> entry.getValue() > 200)
                                                    .map(Map.Entry::getKey)
                                                    .collect(Collectors.joining(","));
                                            // 将商家storeId添加到redis中
                                            baseRedisService.setString("1710", storeIds);
                                            break;
                                        case 1711: // 100条以上
                                            // 获取评论100以上的商家
                                            storeIds = storeEvaluations.stream()
                                                    .collect(Collectors.groupingBy(
                                                            StoreEvaluation::getStoreId,
                                                            Collectors.counting()
                                                    ))
                                                    .entrySet().stream()
                                                    .filter(entry -> entry.getValue() > 100)
                                                    .map(Map.Entry::getKey)
                                                    .collect(Collectors.joining(","));
                                            // 将商家storeId添加到redis中
                                            baseRedisService.setString("1711", storeIds);
                                            break;
                                        case 1712: // 50条以上
                                            // 获取评论50以上的商家
                                            storeIds = storeEvaluations.stream()
                                                    .collect(Collectors.groupingBy(
                                                            StoreEvaluation::getStoreId,
                                                            Collectors.counting()
                                                    ))
                                                    .entrySet().stream()
                                                    .filter(entry -> entry.getValue() > 50)
                                                    .map(Map.Entry::getKey)
                                                    .collect(Collectors.joining(","));
                                            // 将商家storeId添加到redis中
                                            baseRedisService.setString("1712", storeIds);
                                            break;
                                        default:
                                            break;
                                    }
                                }
                                break;
                            case 1706: // 住客印象
                                // 获取所有餐食
                                informations = informationMapper.selectList(
                                        new LambdaQueryWrapper<EssentialModuleInformation>().eq(EssentialModuleInformation::getParentId, 1706));
                                for (EssentialModuleInformation information : informations) {
                                    Integer informationId = information.getId();
                                    // 获取过滤后列表中每个对象的 storeId 字段，并用逗号连接成字符串
                                    String storeIds = "";
                                    switch (informationId) {
                                        case 1713: // 干净卫生
                                            storeIds = storeEvaluations.stream()
                                                    .filter(evaluation -> evaluation.getEvaluationTags().contains("1713"))
                                                    .map(StoreEvaluation::getStoreId)
                                                    .distinct()
                                                    .collect(Collectors.joining(","));
                                            // 将商家storeId添加到redis中
                                            baseRedisService.setString("1713", storeIds);
                                            break;
                                        case 1714: // 隔音好
                                            storeIds = storeEvaluations.stream()
                                                    .filter(evaluation -> evaluation.getEvaluationTags().contains("1714"))
                                                    .map(StoreEvaluation::getStoreId)
                                                    .distinct()
                                                    .collect(Collectors.joining(","));
                                            // 将商家storeId添加到redis中
                                            baseRedisService.setString("1714", storeIds);
                                            break;
                                        case 1715: // 性价比高
                                            storeIds = storeEvaluations.stream()
                                                    .filter(evaluation -> evaluation.getEvaluationTags().contains("1715"))
                                                    .map(StoreEvaluation::getStoreId)
                                                    .distinct()
                                                    .collect(Collectors.joining(","));
                                            // 将商家storeId添加到redis中
                                            baseRedisService.setString("1715", storeIds);
                                            break;
                                        case 1716: // 交通便利
                                            storeIds = storeEvaluations.stream()
                                                    .filter(evaluation -> evaluation.getEvaluationTags().contains("1716"))
                                                    .map(StoreEvaluation::getStoreId)
                                                    .distinct()
                                                    .collect(Collectors.joining(","));
                                            // 将商家storeId添加到redis中
                                            baseRedisService.setString("1716", storeIds);
                                            break;
                                        default:
                                            break;
                                    }
                                }
                                break;
                            default:
                                break;
                        }
                    }
                    break;
                case 1673:
                    // 获取所有支付方式
                    informations = informationMapper.selectList(
                            new LambdaQueryWrapper<EssentialModuleInformation>().eq(EssentialModuleInformation::getParentId, 1673));
                    for (EssentialModuleInformation information : informations) {
                        Integer informationId = information.getId();
                        // 获取过滤后列表中每个对象的 storeId 字段，并用逗号连接成字符串
                        String storeIds = "";
                        switch (informationId) {
                            case 1724: // 到店付
                                storeIds = getStoreLabelTypes(storeLabelTypes, "1724");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("1724", storeIds);
                                break;
                            case 1725: // 在线付
                                storeIds = getStoreLabelTypes(storeLabelTypes, "1725");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("1725", storeIds);
                                break;
                            default:
                                break;
                        }
                    }
                    break;
            }
        }
        // 获取所有酒店民宿价格区间
        List<EssentialModuleInformation> priceRange = informationMapper.selectList(
                new LambdaQueryWrapper<EssentialModuleInformation>().eq(EssentialModuleInformation::getParentId, 1649));
        for (EssentialModuleInformation information : priceRange) {
            Integer businessHourId = information.getId();
            // 获取符合的商家
            List<LifeCoupon> list = new ArrayList<>();
            // 获取过滤后列表中每个对象的 storeId 字段，并用逗号连接成字符串
            String storeIds = "";
            switch (businessHourId) {
                case 1651:  // 100一下
                    storeIds = getLifeCoupons(lifeCoupons, 0, 100);
                    // 将商家storeId添加到redis中
                    baseRedisService.setString("1651", storeIds);
                    break;
                case 1652: // 100-300
                    storeIds = getLifeCoupons(lifeCoupons, 100, 300);
                    // 将商家storeId添加到redis中
                    baseRedisService.setString("1652", storeIds);
                    break;
                case 1653: // 300-500
                    storeIds = getLifeCoupons(lifeCoupons, 300, 500);
                    // 将商家storeId添加到redis中
                    baseRedisService.setString("1653", storeIds);
                    break;
                case 1654: // 1000-2000
                    storeIds = getLifeCoupons(lifeCoupons, 1000, 2000);
                    // 将商家storeId添加到redis中
                    baseRedisService.setString("1654", storeIds);
                    break;
                case 1655: // 2000-3000
                    storeIds = getLifeCoupons(lifeCoupons, 2000, 3000);
                    // 将商家storeId添加到redis中
                    baseRedisService.setString("1655", storeIds);
                    break;
                case 1656: // 3000-5000
                    storeIds = getLifeCoupons(lifeCoupons, 3000, 5000);
                    // 将商家storeId添加到redis中
                    baseRedisService.setString("1656", storeIds);
                    break;
                case 1657: // 5000以上
                    storeIds = getLifeCoupons(lifeCoupons, 5000, Integer.MAX_VALUE);
                    // 将商家storeId添加到redis中
                    baseRedisService.setString("1657", storeIds);
                    break;
                default:
                    break;
            }
        }

        // 行政区
        administrativeRegion(storeInfos);
    }

    private void administrativeRegion(List<StoreInfo> storeInfos) {
        List<EssentialModuleInformation> administrativeRegion = informationMapper.selectList(
                new LambdaQueryWrapper<EssentialModuleInformation>().eq(EssentialModuleInformation::getParentId, 21));
        for (EssentialModuleInformation essentialModuleInformation : administrativeRegion) {
            String informationKey = essentialModuleInformation.getInformationKey();
            List<StoreInfo> infos = storeInfos.stream().filter(item -> informationKey.equals(item.getAdministrativeRegionDistrictName())).collect(Collectors.toList());
            String storeIds = infos.stream()
                    .map(item -> String.valueOf(item.getId()))
                    .collect(Collectors.joining(","));
            baseRedisService.setString(essentialModuleInformation.getId().toString(), storeIds);
        }
    }

    /**
     * 汗蒸洗浴筛选标签定时存储数据
     */
    @XxlJob("takeABathAndSaunaJob")
    public void takeABathAndSaunaJob() {
        // 获取所有洗浴汗蒸筛选
        List<EssentialModuleInformation> essentialModuleInformations = informationMapper.selectList(
                new LambdaQueryWrapper<EssentialModuleInformation>().eq(EssentialModuleInformation::getParentId, 591));
        // 获取所有商家的营业时间
        List<StoreBusinessInfo> storeBusinessInfos = storeBusinessInfoMapper.selectBusinessInfo("洗浴汗蒸");
        // 获取所有的代金券价格
        List<LifeCoupon> lifeCoupons = lifeCouponMapper.selectCoupon("洗浴汗蒸");
        // 获取所有标签
        List<StoreLabelType> storeLabelTypes = storeLabelTypeMapper.selectList(new LambdaQueryWrapper<StoreLabelType>().eq(StoreLabelType::getStoreType, "洗浴汗蒸"));
        for (EssentialModuleInformation essentialModuleInformation : essentialModuleInformations) {
            Integer moduleInformationId = essentialModuleInformation.getId();
            // 获取所有数据值
            List<EssentialModuleInformation> informations = informationMapper.selectList(
                    new LambdaQueryWrapper<EssentialModuleInformation>().eq(EssentialModuleInformation::getParentId, moduleInformationId));
            switch (moduleInformationId) {
                case 819:
                    for (EssentialModuleInformation information : informations) {
                        Integer informationId = information.getId();
                        // 获取过滤后列表中每个对象的 storeId 字段，并用逗号连接成字符串
                        String storeIds = "";
                        switch (informationId) {
                            case 829: // 洗浴中心
                                storeIds = getStoreLabelTypes(storeLabelTypes, "829");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("829", storeIds);
                                break;
                            case 830: // 汗蒸馆
                                storeIds = getStoreLabelTypes(storeLabelTypes, "830");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("830", storeIds);
                                break;
                            case 831: // 浴室澡堂
                                storeIds = getStoreLabelTypes(storeLabelTypes, "831");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("831", storeIds);
                                break;
                            case 832: // 私汤/温泉
                                storeIds = getStoreLabelTypes(storeLabelTypes, "832");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("832", storeIds);
                                break;
                            default:
                                break;
                        }
                    }
                    break;
                case 820:
                    for (EssentialModuleInformation information : informations) {
                        Integer informationId = information.getId();
                        // 获取过滤后列表中每个对象的 storeId 字段，并用逗号连接成字符串
                        String storeIds = "";
                        // 获取符合的商家
                        List<StoreBusinessInfo> list = new ArrayList<>();
                        switch (informationId) {
                            case 833: // 营业中
                                //获取当前时间
                                Date date = new Date();
                                SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
                                String time = sdf.format(date);
                                // 将字符串解析为 LocalTime 对象
                                LocalTime localTime = LocalTime.parse(time);
                                DateTimeFormatter formatter = new DateTimeFormatterBuilder()
                                        .appendValue(ChronoField.HOUR_OF_DAY, 1, 2, java.time.format.SignStyle.NOT_NEGATIVE)
                                        .appendLiteral(':')
                                        .appendValue(ChronoField.MINUTE_OF_HOUR, 2)
                                        .toFormatter();
                                // 获取当前在营业的商家
                                list = storeBusinessInfos.stream()
                                        .filter(item -> localTime.isBefore(LocalTime.parse(item.getEndTime(), formatter)))
                                        .collect(Collectors.toList());
                                storeIds = list.stream()
                                        .map(item -> String.valueOf(item.getStoreId()))
                                        .collect(Collectors.joining(","));
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("833", storeIds);
                                break;
                            case 834: // 24小时
                                list = storeBusinessInfos.stream()
                                        .filter(item -> ZERO_TIME.equals(item.getStartTime()) && TWENTY_FOUR_TIME.equals(item.getEndTime()))
                                        .collect(Collectors.toList());
                                // 获取过滤后列表中每个对象的 storeId 字段，并用逗号连接成字符串
                                storeIds = list.stream()
                                        .map(item -> String.valueOf(item.getStoreId()))
                                        .collect(Collectors.joining(","));
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("834", storeIds);
                                break;
                            default:
                                break;
                        }
                    }
                    break;
                case 821:
                    for (EssentialModuleInformation information : informations) {
                        Integer businessHourId = information.getId();
                        // 获取过滤后列表中每个对象的 storeId 字段，并用逗号连接成字符串
                        String storeIds = "";
                        switch (businessHourId) {
                            case 835:  // 0-100
                                storeIds = getLifeCoupons(lifeCoupons, 0, 100);
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("835", storeIds);
                                break;
                            case 836: // 100-200
                                storeIds = getLifeCoupons(lifeCoupons, 100, 200);
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("836", storeIds);
                                break;
                            case 837: // 200-300
                                storeIds = getLifeCoupons(lifeCoupons, 200, 300);
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("837", storeIds);
                                break;
                            case 838: // 300以上
                                storeIds = getLifeCoupons(lifeCoupons, 300, Integer.MAX_VALUE);
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("838", storeIds);
                                break;
                            default:
                                break;
                        }
                    }
                    break;
                case 822:
                    // 841 汗蒸房
                    // 将商家storeId添加到redis中
                    baseRedisService.setString("841", getStoreLabelTypes(storeLabelTypes, "841"));
                case 823:
                    for (EssentialModuleInformation information : informations) {
                        Integer informationId = information.getId();
                        // 获取过滤后列表中每个对象的 storeId 字段，并用逗号连接成字符串
                        String storeIds = "";
                        switch (informationId) {
                            case 842: // 棋牌室
                                storeIds = getStoreLabelTypes(storeLabelTypes, "842");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("842", storeIds);
                                break;
                            case 843: // 儿童游乐园
                                storeIds = getStoreLabelTypes(storeLabelTypes, "843");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("843", storeIds);
                                break;
                            case 844: // 电影房
                                storeIds = getStoreLabelTypes(storeLabelTypes, "844");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("844", storeIds);
                                break;
                            case 845: // KTV
                                storeIds = getStoreLabelTypes(storeLabelTypes, "845");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("845", storeIds);
                                break;
                            case 846: // 网吧
                                storeIds = getStoreLabelTypes(storeLabelTypes, "846");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("846", storeIds);
                                break;
                            case 847: // 桌游
                                storeIds = getStoreLabelTypes(storeLabelTypes, "847");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("847", storeIds);
                                break;
                            default:
                                break;
                        }
                    }
                    break;
                case 824:
                    for (EssentialModuleInformation information : informations) {
                        Integer informationId = information.getId();
                        // 获取过滤后列表中每个对象的 storeId 字段，并用逗号连接成字符串
                        String storeIds = "";
                        switch (informationId) {
                            case 848: // 有餐厅
                                storeIds = getStoreLabelTypes(storeLabelTypes, "848");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("848", storeIds);
                                break;
                            case 849: // 有自助餐
                                storeIds = getStoreLabelTypes(storeLabelTypes, "849");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("849", storeIds);
                                break;
                            default:
                                break;
                        }
                    }
                    break;
                case 825:
                    for (EssentialModuleInformation information : informations) {
                        Integer informationId = information.getId();
                        // 获取过滤后列表中每个对象的 storeId 字段，并用逗号连接成字符串
                        String storeIds = "";
                        switch (informationId) {
                            case 850: // 日式
                                storeIds = getStoreLabelTypes(storeLabelTypes, "850");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("850", storeIds);
                                break;
                            case 851: // 韩式
                                storeIds = getStoreLabelTypes(storeLabelTypes, "851");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("851", storeIds);
                                break;
                            default:
                                break;
                        }
                    }
                    break;
                case 826:
                    for (EssentialModuleInformation information : informations) {
                        Integer informationId = information.getId();
                        // 获取过滤后列表中每个对象的 storeId 字段，并用逗号连接成字符串
                        String storeIds = "";
                        switch (informationId) {
                            case 852: // 豪华型
                                storeIds = getStoreLabelTypes(storeLabelTypes, "852");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("852", storeIds);
                                break;
                            case 853: // 高档型
                                storeIds = getStoreLabelTypes(storeLabelTypes, "853");
                                // 将商家storeId添加到redis中
                                baseRedisService.setString("853", storeIds);
                                break;
                            default:
                                break;
                        }
                    }
                    break;
                case 827:
                    // 854 充电宝
                    // 将商家storeId添加到redis中
                    baseRedisService.setString("854", getStoreLabelTypes(storeLabelTypes, "854"));
                    break;
                default:
                    break;
            }
        }
        // 获取所有的商家信息
        List<StoreInfo> storeInfos = storeInfoMapper.selectList(new LambdaQueryWrapper<StoreInfo>().eq(StoreInfo::getBusinessSectionName, "洗浴汗蒸"));
        // 行政区
        administrativeRegion(storeInfos);
    }

    /**
     * 丽人美发筛选标签定时存储数据
     */
    @XxlJob("lirenHairdressingJob")
    public void lirenHairdressingJob() {
        // 获取所有丽人筛选
        List<EssentialModuleInformation> essentialModuleInformations = informationMapper.selectList(
                new LambdaQueryWrapper<EssentialModuleInformation>().eq(EssentialModuleInformation::getParentId, 1602));
        storeInfoHandle(essentialModuleInformations);
        // 获取所有的商家信息
        List<StoreInfo> storeInfos = storeInfoMapper.selectList(new LambdaQueryWrapper<StoreInfo>().eq(StoreInfo::getBusinessSectionName, "丽人美发"));
        // 行政区
        administrativeRegion(storeInfos);
    }

    /**
     * 运动健身筛选标签定时存储数据
     */
    @XxlJob("sportsAndFitnessJob")
    public void sportsAndFitnessJob() {
        // 获取所有的运动健身1级菜单
        List<EssentialModuleInformation> moduleInformations = informationMapper.selectList(
                new LambdaQueryWrapper<EssentialModuleInformation>().eq(EssentialModuleInformation::getParentId, 7));
        for (EssentialModuleInformation moduleInformation : moduleInformations) {
            Integer id = moduleInformation.getId();
            if (id == 1079) {
                // 获取所有的运动健身2级菜单
                List<EssentialModuleInformation> informationList = informationMapper.selectList(
                        new LambdaQueryWrapper<EssentialModuleInformation>().eq(EssentialModuleInformation::getParentId, id));
                for (EssentialModuleInformation information : informationList) {
                    // 获取所有的运动健身3级菜单
                    List<EssentialModuleInformation> informations = informationMapper.selectList(
                            new LambdaQueryWrapper<EssentialModuleInformation>().eq(EssentialModuleInformation::getParentId, information.getId()));
                    for (EssentialModuleInformation essentialModuleInformation : informations) {
                        storeInfoHandle(informationMapper.selectList(
                                new LambdaQueryWrapper<EssentialModuleInformation>().eq(EssentialModuleInformation::getParentId, essentialModuleInformation.getId())));
                    }
                }
            } else if (id == 1081) {
                // 获取所有的运动健身2级菜单
                List<EssentialModuleInformation> informationList = informationMapper.selectList(
                        new LambdaQueryWrapper<EssentialModuleInformation>().eq(EssentialModuleInformation::getParentId, id));
                for (EssentialModuleInformation information : informationList) {
                    if (information.getId() == 1338) {
                        // 获取所有的代金券价格
                        List<LifeCoupon> lifeCoupons = lifeCouponMapper.selectCoupon("运动健身");
                        // 获取所有酒店民宿价格区间
                        List<EssentialModuleInformation> priceRange = informationMapper.selectList(
                                new LambdaQueryWrapper<EssentialModuleInformation>().eq(EssentialModuleInformation::getParentId, 1338));
                        for (EssentialModuleInformation essentialModuleInformation : priceRange) {
                            Integer businessHourId = essentialModuleInformation.getId();
                            // 获取过滤后列表中每个对象的 storeId 字段，并用逗号连接成字符串
                            String storeIds = "";
                            switch (businessHourId) {
                                case 1340:  // 50一下
                                    storeIds = getLifeCoupons(lifeCoupons, 0, 50);
                                    // 将商家storeId添加到redis中
                                    baseRedisService.setString("1340", storeIds);
                                    break;
                                case 1341: // 50-100
                                    storeIds = getLifeCoupons(lifeCoupons, 500, 100);
                                    // 将商家storeId添加到redis中
                                    baseRedisService.setString("1341", storeIds);
                                    break;
                                case 1342: // 100-200
                                    storeIds = getLifeCoupons(lifeCoupons, 100, 200);
                                    // 将商家storeId添加到redis中
                                    baseRedisService.setString("1342", storeIds);
                                    break;
                                case 1343: // 200以上
                                    storeIds = getLifeCoupons(lifeCoupons, 200, Integer.MAX_VALUE);
                                    // 将商家storeId添加到redis中
                                    baseRedisService.setString("1343", storeIds);
                                    break;
                                default:
                                    break;
                            }
                        }
                    }
                }
            }
        }
        // 获取所有的商家信息
        List<StoreInfo> storeInfos = storeInfoMapper.selectList(new LambdaQueryWrapper<StoreInfo>().eq(StoreInfo::getBusinessSectionName, "运动健身"));
        // 行政区
        administrativeRegion(storeInfos);
    }

    private void storeInfoHandle(List<EssentialModuleInformation> informationList) {
        for (EssentialModuleInformation item : informationList) {
            List<StoreInfo> infos = storeInfoMapper.selectList(new LambdaQueryWrapper<StoreInfo>().like(StoreInfo::getBusinessTypesName, item.getInformationKey()));
            // 获取去重后的 id 并拼接成用逗号分隔的字符串
            String storeIds = infos.stream()
                    .map(StoreInfo::getId)
                    .distinct()
                    .map(String::valueOf)
                    .collect(Collectors.joining(","));
            baseRedisService.setString(item.getId().toString(), storeIds);
        }
    }

    /**
     * 医美医疗筛选标签定时存储数据
     */
    @XxlJob("medicalAestheticsJob")
    public void medicalAestheticsJob() {
        // 获取所有医美医疗筛选标签
        List<EssentialModuleInformation> essentialModuleInformations = informationMapper.selectList(
                new LambdaQueryWrapper<EssentialModuleInformation>().eq(EssentialModuleInformation::getParentId, 1843));
        storeInfoHandle(essentialModuleInformations);
        // 获取所有的商家信息
        List<StoreInfo> storeInfos = storeInfoMapper.selectList(new LambdaQueryWrapper<StoreInfo>().eq(StoreInfo::getBusinessSectionName, "医美医疗"));
        // 行政区
        administrativeRegion(storeInfos);
    }

    /**
     * 处理标签
     *
     * @param storeLabelTypes
     * @param label
     * @return
     */
    private String getStoreLabelTypes(List<StoreLabelType> storeLabelTypes, String label) {
        List<StoreLabelType> list = storeLabelTypes.stream()
                .filter(item -> item.getLabel().contains(label))
                .collect(Collectors.toList());
        // 获取过滤后列表中每个对象的 storeId 字段，并用逗号连接成字符串
        return list.stream()
                .map(item -> String.valueOf(item.getStoreId()))
                .collect(Collectors.joining(","));
    }

    /**
     * 处理优惠tag
     *
     * @param lifeCoupons
     * @param number
     * @return
     */
    public String getLifeYouhui(List<LifeCoupon> lifeCoupons, String number) {
        return lifeCoupons.stream()
                .filter(item -> {
                    String discountTag = item.getDiscountTag();
                    if (discountTag == null) return false;
                    String[] tags = discountTag.split(",");
                    for (String tag : tags) {
                        if (tag.equals(number)) return true;
                    }
                    return false;
                })
                .map(LifeCoupon::getStoreId)
                .map(String::valueOf)
                .collect(Collectors.joining(","));
    }

    /**
     * 处理入驻时间
     *
     * @param storeInfos
     * @param yearsAgo
     * @return
     */
    private String getStoreInfos(List<StoreInfo> storeInfos, LocalDate yearsAgo) {
        List<StoreInfo> list = storeInfos.stream()
                .filter(item -> {
                    // 将 Date 转换为 LocalDate
                    LocalDate createdDate = item.getCreatedTime().toInstant()
                            .atZone(ZoneId.systemDefault())
                            .toLocalDate();
                    return !createdDate.isBefore(yearsAgo);
                })
                .collect(Collectors.toList());
        // 获取过滤后列表中每个对象的 storeId 字段，并用逗号连接成字符串
        return list.stream()
                .map(item -> String.valueOf(item.getId()))
                .collect(Collectors.joining(","));
    }

    /**
     * 处理营业时间段
     *
     * @param storeBusinessInfos
     * @param startTime
     * @param endTime
     * @return
     */
    private String getStoreBusinessInfos(List<StoreBusinessInfo> storeBusinessInfos, String startTime, String
            endTime) {
        DateTimeFormatter formatter = new DateTimeFormatterBuilder()
                .appendValue(ChronoField.HOUR_OF_DAY, 1, 2, java.time.format.SignStyle.NOT_NEGATIVE)
                .appendLiteral(':')
                .appendValue(ChronoField.MINUTE_OF_HOUR, 2)
                .toFormatter();
        List<StoreBusinessInfo> list = storeBusinessInfos.stream()
                .filter(item -> {
                    // 商家开门时间
                    LocalTime timeStart = LocalTime.parse(item.getEndTime(), formatter);
                    // 商家关门时间
                    LocalTime timeEnd = LocalTime.parse(item.getEndTime(), formatter);
                    // 开始时间
                    LocalTime time1 = LocalTime.parse(startTime);
                    // 结束时间
                    LocalTime time2 = LocalTime.parse(endTime);
                    return !time1.isBefore(timeStart) && !time2.isAfter(timeEnd);
                })
                .collect(Collectors.toList());
        // 获取过滤后列表中每个对象的 storeId 字段，并用逗号连接成字符串
        return list.stream()
                .map(item -> String.valueOf(item.getStoreId()))
                .collect(Collectors.joining(","));
    }

    /**
     * 处理商家价格区间
     *
     * @param lifeCoupons
     * @param startNum
     * @param endNum
     * @return
     */
    private String getLifeCoupons(List<LifeCoupon> lifeCoupons, Integer startNum, Integer endNum) {
        List<LifeCoupon> list = lifeCoupons.stream()
                .filter(item -> Double.parseDouble(item.getPrice()) >= startNum && Double.parseDouble(item.getPrice()) < endNum)
                .collect(Collectors.toList());
        // 获取过滤后列表中每个对象的 storeId 字段，并用逗号连接成字符串
        return list.stream()
                .map(LifeCoupon::getStoreId)
                .filter(Objects::nonNull) // 确保 storeId 不为 null
                .distinct() // 去重
                .map(String::valueOf)
                .collect(Collectors.joining(","));
    }
}
