package com.muyu.data.processing.strategy.core;

import com.github.yulichang.toolkit.SpringContentUtils;
import com.muyu.common.caffeine.enums.CacheNameEnums;
import com.muyu.common.core.utils.StringUtils;
import com.muyu.data.processing.domain.BasicData;
import java.util.HashMap;

import com.muyu.data.processing.domain.Temporary2;
import com.muyu.data.processing.service.impl.DataProcessingServiceImpl;
import com.muyu.data.processing.strategy.StrategyHandler;
import com.muyu.data.processing.strategy.abstractStrategyRouter;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.cache.CacheManager;
import org.springframework.stereotype.Component;

/**
 *  基础校验节点
 *  负责基础校验
 * @Author: 胡杨
 * @Name: BasicStrategy
 * @Description: 责任树 - 基础校验节点
 * @CreatedDate: 2024/9/30 下午7:24
 * @FilePath: com.muyu.data.processing.strategy.branch
 */

@Slf4j
@Component
public class BasicStrategy extends abstractStrategyRouter<HashMap<String, BasicData>, Temporary2>
        implements StrategyHandler<HashMap<String, BasicData>, Temporary2> {

    @Override
    protected StrategyMapper<HashMap<String, BasicData>, Temporary2> registerStrategy() {
        log.info("基础校验节点已通过。。。");
        return param -> new RoutingStrategy();
    }

    @Override
    public Temporary2 apply(HashMap<String, BasicData> basicDataMap) {
        log.info("开始执行基础校验节点。。。");
        basicDataMap.put(CacheNameEnums.STORAGE.getCode(), null);
        CacheNameEnums.getCodes()
                .stream()
                .filter(code -> cacheUtils.hasKey(code, basicDataMap.get("VIN").getKey()))
                .forEach(code-> basicDataMap.put(code, null));
        return applyStrategy(basicDataMap);
    }
}
