jiazx0107@163.com
2023-05-17 620eab6cca2bc9ef9ea6d3067a0a5ba1deadbd1c
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
package com.ld.igds.pressure.service.impl;
 
import com.ld.igds.constant.RedisConst;
import com.ld.igds.pressure.dto.PressureData;
import com.ld.igds.pressure.mapper.PressureServiceMapper;
import com.ld.igds.pressure.service.CorePressureService;
import com.ld.igds.util.RedisUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
 
import javax.annotation.Resource;
 
@Slf4j
@Component
public class CorePressureServiceImpl implements CorePressureService {
 
    @Resource
    private PressureServiceMapper mapper;
    @Resource
    private RedisUtil redisUtil;
 
    @Override
    public void savePressure(PressureData pressure) {
        try {
            mapper.savePressure(pressure);
            updateCacheMapPressureData(pressure);
        } catch (Exception e) {
            log.error("保存气压异常:{}", e);
        }
 
    }
 
    @Override
    public void updateCacheMapPressureData(PressureData data) {
        String key = RedisConst.buildKey(data.getCompanyId(), RedisConst.KEY_PRESSURE_DATA, data.getDepotId());
        redisUtil.set(key, data);
    }
 
    @Override
    public PressureData getCachePressure(String companyId, String depotId) {
        String key = RedisConst.buildKey(companyId, RedisConst.KEY_PRESSURE_DATA, depotId);
        return (PressureData) redisUtil.get(key);
    }
 
}