package cn.cecep.talroad.service.impl;

import cn.cecep.talroad.common.redis.service.RedisService;
import java.util.List;
import cn.cecep.talroad.common.core.utils.DateUtils;
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.mapper.BasControlValueMapper;
import cn.cecep.talroad.domain.BasControlValue;
import cn.cecep.talroad.service.IBasControlValueService;

/**
 * basControlValueService业务层处理
 *
 * @author admin
 * @date 2023-06-27
 */
@Service
public class BasControlValueServiceImpl extends ServiceImpl<BasControlValueMapper,BasControlValue> implements IBasControlValueService
{
    @Autowired
    private BasControlValueMapper basControlValueMapper;
    @Autowired
    private RedisService redisService;
    /**
     * 查询basControlValue列表
     *
     * @param basControlValue basControlValue
     * @return basControlValue
     */
    @Override
    public List<BasControlValue> selectBasControlValueList(BasControlValue basControlValue)
    {
        return basControlValueMapper.selectBasControlValueList(basControlValue);
    }

    @Override
    public BasControlValue selectByFactoryId(String factoryId, String industry, String deviceType) {
        String key = "bas_control_value_"+factoryId+industry+deviceType;
        BasControlValue basControlValue = redisService.getCacheObject(key);
        if(basControlValue==null){
            basControlValue = basControlValueMapper.selectByFactoryId(factoryId,industry,deviceType);
            redisService.setCacheObject(key,basControlValue,1L, TimeUnit.DAYS);
        }

        return basControlValue;
    }
}
