package com.muyu.data.processing.service.impl;


import javax.annotation.Resource;

import com.muyu.common.caffeine.enums.CacheNameEnums;
import com.muyu.common.caffeine.utils.CacheUtils;
import org.apache.iotdb.session.pool.SessionPool;
import org.springframework.stereotype.Service;
import lombok.extern.slf4j.Slf4j;
import com.muyu.data.processing.mapper.DataProcessingMapper;
import com.muyu.data.processing.service.DataProcessingService;

/**
 * 数据处理实现层
 *
 * @Author: 胡杨
 * @Name: DataProcessing
 * @Description: 数据处理实现层
 * @CreatedDate: 2024/9/28 下午3:52
 * @FilePath: com.muyu.data.processing.server.impl
 */

@Slf4j
@Service
public class DataProcessingServiceImpl implements DataProcessingService {
    @Resource
    private DataProcessingMapper mapper;
    @Resource
    private SessionPool sessionPool;
    @Resource
    private CacheUtils cacheUtils;


    /**
     * 启动或停止实时数据
     *
     * @param vin    车辆vin码
     * @param status 开关状态
     * @return 返回结果
     */
    @Override
    public String carRealTimeStatus(String vin, Boolean status) {
        if (status){
            cacheUtils.setCacheValue(CacheNameEnums.REALTIME.getCode(), vin, "Y");
        }else {
            cacheUtils.delCacheValue(CacheNameEnums.REALTIME.getCode(), vin);
        }
        return "实时数据状态更改成功,当前状态: " + status;
    }
}
