package cn.cecep.talroad.service.impl;

import cn.cecep.talroad.common.redis.service.RedisService;
import cn.cecep.talroad.domain.BasThresholdConfig;
import com.baomidou.dynamic.datasource.annotation.DS;
import java.math.BigDecimal;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.cecep.talroad.domain.OdsAirRegionHourI;
import cn.cecep.talroad.mapper.OdsAirRegionHourIMapper;
import cn.cecep.talroad.service.IOdsAirRegionHourIService;
import cn.cecep.talroad.mapper.OdsAirRegionHourIMapper;
import cn.cecep.talroad.domain.OdsAirRegionHourI;
import cn.cecep.talroad.service.IOdsAirRegionHourIService;




/**
 * 【请填写功能名称】Service业务层处理
 *
 * @author szhpt
 * @date 2023-06-27*/
@DS("ods")
@Service
public class OdsAirRegionHourIServiceImpl extends ServiceImpl<OdsAirRegionHourIMapper,OdsAirRegionHourI> implements IOdsAirRegionHourIService
{
    @Autowired
    private OdsAirRegionHourIMapper odsAirRegionHourIMapper;
    @Autowired
    private RedisService  redisService;

    /**
     * 查询【请填写功能名称】列表
     *
     * @param odsAirRegionHourI 【请填写功能名称】
     * @return 【请填写功能名称】
     */
    @Override
    public List<OdsAirRegionHourI> selectOdsAirRegionHourIList(OdsAirRegionHourI odsAirRegionHourI)
    {
        return odsAirRegionHourIMapper.selectOdsAirRegionHourIList(odsAirRegionHourI);
    }

    @Override
    public BigDecimal selectAvgTemp(String lastHour) {
        String key = "ods_air_region_hour_temp_"+lastHour;
        BigDecimal avgTemp = redisService.getCacheObject(key);
        if(avgTemp==null){
            avgTemp = odsAirRegionHourIMapper.selectAvgTemp(lastHour);
            redisService.setCacheObject(key,avgTemp,1L, TimeUnit.HOURS);
        }
        return avgTemp;
    }

}
