package com.fzzy.igds.gas.service;
|
|
import com.fzzy.igds.dzhwk.constant.RedisConst;
|
import com.fzzy.igds.gas.dto.GasData;
|
import com.fzzy.igds.gas.dto.GasParam;
|
import com.fzzy.igds.gas.mapper.GasServiceMapper;
|
import com.ruoyi.common.core.redis.RedisCache;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.stereotype.Service;
|
import javax.annotation.Resource;
|
import java.util.*;
|
|
/**
|
* @Description
|
* @Author CZT
|
* @Date 2024/12/09 11:05
|
*/
|
@Slf4j
|
@Service
|
public class GasService {
|
|
@Resource
|
private GasServiceMapper gasMapper;
|
@Resource
|
private RedisCache redisCache;
|
|
/**
|
*
|
* @param companyId
|
* @param depotId
|
* @return
|
*/
|
@SuppressWarnings("unchecked")
|
public GasData getCacheGrainDate(String companyId, String depotId) {
|
|
String key = RedisConst.buildKey(companyId, RedisConst.KEY_GAS_DATA, depotId);
|
|
GasData gasData = redisCache.getCacheObject(key);
|
|
if (null == gasData) {
|
GasParam param = new GasParam();;
|
param.setCompanyId(companyId);
|
param.setDepotId(depotId);
|
List<GasData> list = gasMapper.getGrainData(param);
|
if (list != null && !list.isEmpty()) {
|
gasData = list.get(0);
|
redisCache.setCacheObject(key, gasData);
|
}
|
return null;
|
}
|
return gasData;
|
}
|
|
}
|