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

import com.github.yulichang.toolkit.SpringContentUtils;
import com.muyu.data.processing.domain.BasicData;
import java.util.HashMap;

import com.muyu.data.processing.domain.Temporary2;
import com.muyu.data.processing.strategy.StrategyHandler;
import com.muyu.data.processing.strategy.abstractStrategyRouter;
import com.muyu.data.processing.strategy.core.RoutingStrategy;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
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 RealTimeAlarmStrategy extends abstractStrategyRouter<HashMap<String, BasicData>, Temporary2>
        implements StrategyHandler<HashMap<String, BasicData>, Temporary2> {
//    private final RedisTemplate<String,String> redisTemplate = SpringContentUtils.getBean(RedisTemplate.class);

    @Override
    protected StrategyMapper<HashMap<String, BasicData>, Temporary2> registerStrategy() {
        log.info("实时数据处理分支已完成。。。");
        return param -> new RoutingStrategy();
    }

    @Override
    public Temporary2 apply(HashMap<String, BasicData> basicDataMap) {
        log.info("开始执行实时数据处理节点。。。");
//        String vin = basicDataMap.get("VIN").getKey();
//        basicDataMap.keySet().forEach(key -> {
//            BasicData basicData = basicDataMap.get(key);
//            redisTemplate.opsForValue().set(vin+":"+basicData.getKey(), basicData.getValue());
//        });
        return applyStrategy(basicDataMap);
    }
}
