czt
2025-06-11 283da741b2429cf5a53786e5ee1b5528b757fdf6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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;
    }
 
}