Commit 5cc11ff1 zshaohui

Gr数量缓存

1 个父辈 241b2ed9
package com.neotel.smfcore.custom.luxsan.factory_c.rawstor.bean;
import lombok.AllArgsConstructor;
import lombok.Data;
@Data
@AllArgsConstructor
public class GrUdNum {
private String grCode;
private String grItem;
private int udQty;
private int lotQty;
}
package com.neotel.smfcore.custom.luxsan.factory_c.rawstor.util;
import com.google.common.collect.Maps;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.bean.GrUdNum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Map;
@Service
public class GrUtil {
private static DataCache dataCache;
public static final String CACHE_GR_UDQTY = "CACHE_GR_UDQTY";
@Autowired
private void setDataCache(DataCache cache){
GrUtil.dataCache = cache;
}
private synchronized static void updateGrUdQty(String grCode, String grItem, int udQty, int lotQty) {
Map<String, GrUdNum> cacheMap = dataCache.getCache(CACHE_GR_UDQTY);
if (cacheMap == null) {
cacheMap = Maps.newConcurrentMap();
}
String key = grCode + "_" + grItem;
cacheMap.put(key, new GrUdNum(grCode, grItem, udQty, lotQty));
dataCache.updateCache(CACHE_GR_UDQTY, cacheMap);
}
private static GrUdNum getGrUdQty(String grCode, String grItem){
Map<String, GrUdNum> cacheMap = dataCache.getCache(CACHE_GR_UDQTY);
if (cacheMap == null) {
cacheMap = Maps.newConcurrentMap();
}
String key = grCode + "_" + grItem;
return cacheMap.get(key);
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!