Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 292f3813
由
sunke
编写于
2022-09-22 17:15:14 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
工位缓存
1 个父辈
c5cef2b0
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
28 行增加
和
4 行删除
src/main/java/com/neotel/smfcore/custom/lizhen/util/StationCacheUtil.java
src/main/java/com/neotel/smfcore/custom/lizhen/util/StationCacheUtil.java
查看文件 @
292f381
...
...
@@ -18,6 +18,7 @@ import org.springframework.data.mongodb.core.query.Criteria;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.PostConstruct
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -27,14 +28,14 @@ import java.util.concurrent.ConcurrentHashMap;
@Slf4j
public
class
StationCacheUtil
{
@Autowired
private
DataCache
dataCache
;
private
static
DataCache
dataCache
;
/**
* 工位缓存信息
*/
private
static
Map
<
String
,
Station
>
stationMap
=
new
ConcurrentHashMap
<>();
@PostConstruct
public
void
init
()
{
log
.
info
(
"开始工位缓存信息"
);
for
(
int
i
=
1
;
i
<
5
;
i
++)
{
...
...
@@ -49,18 +50,41 @@ public class StationCacheUtil {
}
}
private
synchronized
void
updateStation
(
Station
station
){
private
s
tatic
s
ynchronized
void
updateStation
(
Station
station
){
stationMap
.
put
(
station
.
getName
(),
station
);
dataCache
.
updateCache
(
station
.
getName
(),
station
);
}
/**
* 更新工位当前的RFID信息
* @param stationName 工位名称
* @param rfid 料箱RFID信息
*/
public
static
void
updateCurrentRfid
(
String
stationName
,
String
rfid
){
if
(
rfid
==
null
){
rfid
=
""
;
}
Station
station
=
getStation
(
stationName
);
if
(
station
!=
null
){
station
.
setCurrentRfid
(
rfid
);
updateStation
(
station
);
}
}
/**
* 获取工位信息
* @param stationName 工位名称
* @return
*/
public
Station
getStation
(
String
stationName
){
public
static
Station
getStation
(
String
stationName
){
return
stationMap
.
get
(
stationName
);
}
@Autowired
public
void
setDataCache
(
DataCache
dataCache
)
{
StationCacheUtil
.
dataCache
=
dataCache
;
}
}
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论