Commit 8c774b2b sunke

工位缓存

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