Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit ba4afaed
由
LN
编写于
2024-04-07 09:45:53 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
库位锁定时key中的.替换为__
1 个父辈
85ee94db
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
42 行增加
和
22 行删除
src/main/java/com/neotel/smfcore/common/utils/ReelLockPosUtil.java
src/main/java/com/neotel/smfcore/common/utils/ReelLockPosUtil.java
查看文件 @
ba4afae
package
com
.
neotel
.
smfcore
.
common
.
utils
;
package
com
.
neotel
.
smfcore
.
common
.
utils
;
import
c
om.google.common.collect.Lists
;
import
c
n.hutool.core.util.ObjectUtil
;
import
com.google.common.collect.Maps
;
import
com.google.common.collect.Maps
;
import
com.neotel.smfcore.core.device.util.DataCache
;
import
com.neotel.smfcore.core.device.util.DataCache
;
import
com.neotel.smfcore.common.bean.ReelLockPosInfo
;
import
com.neotel.smfcore.common.bean.ReelLockPosInfo
;
...
@@ -8,7 +8,6 @@ import org.apache.logging.log4j.LogManager;
...
@@ -8,7 +8,6 @@ import org.apache.logging.log4j.LogManager;
import
org.apache.logging.log4j.Logger
;
import
org.apache.logging.log4j.Logger
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.PostConstruct
;
import
javax.annotation.PostConstruct
;
import
java.util.*
;
import
java.util.*
;
...
@@ -44,26 +43,33 @@ public class ReelLockPosUtil {
...
@@ -44,26 +43,33 @@ public class ReelLockPosUtil {
* @param reelLockPosInfo
* @param reelLockPosInfo
*/
*/
public
static
synchronized
ReelLockPosInfo
addReelLockPosInfo
(
ReelLockPosInfo
reelLockPosInfo
,
List
<
String
>
cidList
)
{
public
static
synchronized
ReelLockPosInfo
addReelLockPosInfo
(
ReelLockPosInfo
reelLockPosInfo
,
List
<
String
>
cidList
)
{
log
.
info
(
"为["
+
reelLockPosInfo
.
getBarcode
()
+
"]锁定库位["
+
reelLockPosInfo
.
getLockPosName
()
+
"]"
);
String
key
=
processBarcode
(
reelLockPosInfo
.
getBarcode
());
ReelLockPosInfo
oldLocInfo
=
reelLocKPosMap
.
get
(
reelLockPosInfo
.
getBarcode
());
log
.
info
(
"为["
+
reelLockPosInfo
.
getBarcode
()
+
"]锁定库位["
+
reelLockPosInfo
.
getLockPosName
()
+
"],key=["
+
key
+
"]"
);
if
(
oldLocInfo
!=
null
&&
oldLocInfo
.
getLockPosName
()
!=
null
)
{
ReelLockPosInfo
oldLocInfo
=
reelLocKPosMap
.
get
(
key
);
if
(
cidList
.
contains
(
oldLocInfo
.
getCid
())){
try
{
log
.
info
(
"["
+
oldLocInfo
.
getBarcode
()
+
"]已有锁定库位["
+
oldLocInfo
.
getLockPosName
()
+
"],返回之前锁定的库位"
);
return
oldLocInfo
;
if
(
oldLocInfo
!=
null
&&
oldLocInfo
.
getLockPosName
()
!=
null
)
{
}
else
{
if
(
cidList
.
contains
(
oldLocInfo
.
getCid
()))
{
//锁定库位不在cid列表中
log
.
info
(
"["
+
oldLocInfo
.
getBarcode
()
+
"]已有锁定库位["
+
oldLocInfo
.
getLockPosName
()
+
"],返回之前锁定的库位"
);
log
.
info
(
"["
+
oldLocInfo
.
getBarcode
()
+
"]已有锁定库位["
+
oldLocInfo
.
getLockPosName
()
+
"],Cid["
+
oldLocInfo
.
getCid
()+
"]不在["
+
String
.
join
(
","
,
cidList
)+
"]中,清理原有锁定库位"
);
return
oldLocInfo
;
reelLocKPosMap
.
remove
(
reelLockPosInfo
.
getBarcode
());
}
else
{
//锁定库位不在cid列表中
log
.
info
(
"["
+
oldLocInfo
.
getBarcode
()
+
"]已有锁定库位["
+
oldLocInfo
.
getLockPosName
()
+
"],Cid["
+
oldLocInfo
.
getCid
()
+
"]不在["
+
String
.
join
(
","
,
cidList
)
+
"]中,清理原有锁定库位"
);
reelLocKPosMap
.
remove
(
key
);
}
}
}
}
for
(
ReelLockPosInfo
locInfo
:
reelLocKPosMap
.
values
())
{
for
(
ReelLockPosInfo
locInfo
:
reelLocKPosMap
.
values
(
))
{
if
(
locInfo
.
getLockPosId
().
equals
(
reelLockPosInfo
.
getLockPosId
())
&&
!
locInfo
.
getBarcode
().
equals
(
key
))
{
if
(
locInfo
.
getLockPosId
().
equals
(
reelLockPosInfo
.
getLockPosId
())
&&
!
locInfo
.
getBarcode
().
equals
(
reelLockPosInfo
.
getBarcode
()))
{
log
.
info
(
"为["
+
reelLockPosInfo
.
getBarcode
()
+
"]锁定库位["
+
reelLockPosInfo
.
getLockPosName
()
+
"]时,库位已被["
+
locInfo
.
getBarcode
()
+
"]锁定"
);
log
.
info
(
"为["
+
reelLockPosInfo
.
getBarcode
()
+
"]锁定库位["
+
reelLockPosInfo
.
getLockPosName
()
+
"]时,库位已被["
+
locInfo
.
getBarcode
()
+
"]锁定"
)
;
return
null
;
return
null
;
}
}
}
reelLocKPosMap
.
put
(
key
,
reelLockPosInfo
);
dataCache
.
updateCache
(
REEL_LOCK_POS_MAP_KEY
,
reelLocKPosMap
);
}
catch
(
Exception
exception
)
{
log
.
error
(
"为["
+
reelLockPosInfo
.
getBarcode
()
+
"]锁定库位["
+
reelLockPosInfo
.
getLockPosName
()
+
"],key=["
+
key
+
"]出错:"
+
exception
.
toString
());
}
}
reelLocKPosMap
.
put
(
reelLockPosInfo
.
getBarcode
(),
reelLockPosInfo
);
dataCache
.
updateCache
(
REEL_LOCK_POS_MAP_KEY
,
reelLocKPosMap
);
return
reelLockPosInfo
;
return
reelLockPosInfo
;
}
}
...
@@ -74,7 +80,7 @@ public class ReelLockPosUtil {
...
@@ -74,7 +80,7 @@ public class ReelLockPosUtil {
String
lockBarcode
=
reelLockPosInfo
.
getBarcode
();
String
lockBarcode
=
reelLockPosInfo
.
getBarcode
();
if
(
org
.
apache
.
logging
.
log4j
.
util
.
Strings
.
isNotBlank
(
lockBarcode
))
{
if
(
org
.
apache
.
logging
.
log4j
.
util
.
Strings
.
isNotBlank
(
lockBarcode
))
{
if
(
lockBarcode
.
equals
(
barcode
))
{
if
(
lockBarcode
.
equals
(
processBarcode
(
barcode
)
))
{
return
reelLockPosInfo
;
return
reelLockPosInfo
;
}
}
}
}
...
@@ -89,7 +95,7 @@ public class ReelLockPosUtil {
...
@@ -89,7 +95,7 @@ public class ReelLockPosUtil {
* 清理条码锁定库位信息
* 清理条码锁定库位信息
*/
*/
public
static
void
removeReelLockPosInfo
(
String
barcode
)
{
public
static
void
removeReelLockPosInfo
(
String
barcode
)
{
reelLocKPosMap
.
remove
(
barcode
);
reelLocKPosMap
.
remove
(
processBarcode
(
barcode
)
);
dataCache
.
updateCache
(
REEL_LOCK_POS_MAP_KEY
,
reelLocKPosMap
);
dataCache
.
updateCache
(
REEL_LOCK_POS_MAP_KEY
,
reelLocKPosMap
);
}
}
...
@@ -100,7 +106,7 @@ public class ReelLockPosUtil {
...
@@ -100,7 +106,7 @@ public class ReelLockPosUtil {
* @return
* @return
*/
*/
public
static
String
getReelLockPosId
(
String
barcode
)
{
public
static
String
getReelLockPosId
(
String
barcode
)
{
ReelLockPosInfo
lockPosInfo
=
reelLocKPosMap
.
get
(
barcode
);
ReelLockPosInfo
lockPosInfo
=
reelLocKPosMap
.
get
(
processBarcode
(
barcode
)
);
if
(
lockPosInfo
!=
null
)
{
if
(
lockPosInfo
!=
null
)
{
return
lockPosInfo
.
getLockPosId
();
return
lockPosInfo
.
getLockPosId
();
}
}
...
@@ -117,4 +123,18 @@ public class ReelLockPosUtil {
...
@@ -117,4 +123,18 @@ public class ReelLockPosUtil {
}
}
return
lockPosIds
;
return
lockPosIds
;
}
}
private
static
String
processBarcode
(
String
str
)
{
if
(
ObjectUtil
.
isEmpty
(
str
))
{
return
str
;
}
if
(
str
.
contains
(
"."
))
{
String
res
=
str
.
replace
(
"."
,
"__"
);
return
res
;
}
else
{
return
str
;
}
}
}
}
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论