Commit cd12c7eb sunke

工位缓存

1 个父辈 ffea11d2
package com.neotel.smfcore.custom.lizhen.bean;
import lombok.Data;
/**
* @author sunke
* @date 2022/9/22 4:32 PM
*/
@Data
public class Station {
/**
* 工位名称
*/
private String name;
/**
* 当前料箱的RFID
*/
private String currentRfid = "";
}
package com.neotel.smfcore.custom.lizhen.util;
import cn.hutool.core.util.ObjectUtil;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.inList.bean.ItemReelInfo;
import com.neotel.smfcore.core.inList.enums.INLIST_STATUS;
import com.neotel.smfcore.core.inList.service.manager.IInListItemManager;
import com.neotel.smfcore.core.inList.service.manager.IInListManager;
import com.neotel.smfcore.core.inList.service.po.InList;
import com.neotel.smfcore.core.inList.service.po.InListItem;
import com.neotel.smfcore.core.storage.service.po.StoragePos;
import com.neotel.smfcore.custom.lizhen.bean.Station;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@Service
@Slf4j
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() {
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.setName(stationName);
stationMap.put(stationName,station);
dataCache.updateCache(STATION_CACHE_KEY, stationMap);
}
}
}
private synchronized void updateStation(Station station){
stationMap.put(station.getName(),station);
dataCache.updateCache(STATION_CACHE_KEY, stationMap);
}
/**
* 获取工位信息
* @param stationName 工位名称
* @return
*/
public Station getStation(String stationName){
return stationMap.get(stationName);
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!