Commit 8c774b2b sunke

工位缓存

1 个父辈 cd12c7eb
......@@ -30,29 +30,28 @@ public class StationCacheUtil {
@Autowired
private DataCache dataCache;
private static final String STATION_CACHE_KEY = "STATION_CACHE";
/**
* 工位缓存信息
*/
private static Map<String, Station> stationMap = new ConcurrentHashMap<>();
public void loadMap() {
public void init() {
log.info("开始工位缓存信息");
stationMap = dataCache.getCache(STATION_CACHE_KEY);
if(stationMap.isEmpty()){
for (int i = 1; i < 5; i++) {
String stationName = "s" + i;
Station station = new Station();
Station station = dataCache.getCache(stationName);
if(station == null){
station = new Station();
station.setName(stationName);
stationMap.put(stationName,station);
dataCache.updateCache(STATION_CACHE_KEY, stationMap);
dataCache.updateCache(stationName, station);
}
}
}
private synchronized void updateStation(Station station){
stationMap.put(station.getName(),station);
dataCache.updateCache(STATION_CACHE_KEY, stationMap);
dataCache.updateCache(station.getName(), station);
}
/**
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!