Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit ac1d1fd3
由
zshaohui
编写于
2025-10-28 09:46:10 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
1.禁用料按model取交集
1 个父辈
6201d872
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
124 行增加
和
71 行删除
src/main/java/com/neotel/smfcore/custom/luxsan/api/LuxsanApi.java
src/main/java/com/neotel/smfcore/custom/luxsan/api/LuxsanApi.java
查看文件 @
ac1d1fd
...
@@ -1230,100 +1230,153 @@ public class LuxsanApi extends DefaultSmfApiListener {
...
@@ -1230,100 +1230,153 @@ public class LuxsanApi extends DefaultSmfApiListener {
}
}
public
static
List
<
String
>
batchCheckReel
(
List
<
Barcode
>
barcodeList
,
String
pickingId
,
String
model
)
{
public
static
List
<
String
>
batchCheckReel
(
List
<
Barcode
>
barcodeList
,
String
pickingId
,
String
model
)
{
List
<
Map
<
String
,
Object
>>
paramList
=
new
ArrayList
<>();
//key为barcode,value为禁用信息
for
(
Barcode
barcode
:
barcodeList
)
{
Map
<
String
,
String
>
disAbleAllMap
=
new
HashMap
<>();
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
Map
<
String
,
List
<
String
>>
disAbleModeMap
=
new
HashMap
<>();
paramMap
.
put
(
"ipn"
,
barcode
.
getPartNumber
());
if
(
StringUtils
.
isEmpty
(
model
))
{
paramMap
.
put
(
"reelId"
,
barcode
.
getBarcode
());
model
=
"ALL"
;
paramMap
.
put
(
"wo"
,
""
);
paramMap
.
put
(
"datecode"
,
barcode
.
getDateCode
());
paramMap
.
put
(
"lot"
,
barcode
.
getBatch
());
paramMap
.
put
(
"vendor"
,
barcode
.
getProvider
());
paramMap
.
put
(
"remark"
,
"ALL"
);
paramMap
.
put
(
"werks"
,
"ALL"
);
paramMap
.
put
(
"model"
,
"ALL"
);
if
(
StringUtils
.
isNotEmpty
(
model
))
{
paramMap
.
put
(
"model"
,
model
);
}
paramMap
.
put
(
"picking"
,
"ALL"
);
if
(
StringUtils
.
isNotEmpty
(
pickingId
))
{
paramMap
.
put
(
"picking"
,
pickingId
);
}
paramList
.
add
(
paramMap
);
}
}
log
.
info
(
"批量禁用入参为:"
+
JSON
.
toJSONString
(
paramList
));
//开始循环调用接口
for
(
String
singleModel
:
model
.
split
(
","
))
{
Map
<
String
,
String
>
resultMap
=
new
HashMap
<>();
List
<
Map
<
String
,
Object
>>
paramList
=
new
ArrayList
<>();
List
<
String
>
reelList
=
new
ArrayList
<>();
for
(
Barcode
barcode
:
barcodeList
)
{
int
maxRetries
=
3
;
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
int
retryCount
=
0
;
paramMap
.
put
(
"ipn"
,
barcode
.
getPartNumber
());
boolean
isSuccess
=
false
;
paramMap
.
put
(
"reelId"
,
barcode
.
getBarcode
());
paramMap
.
put
(
"wo"
,
""
);
// 重试机制:最多请求3次
paramMap
.
put
(
"datecode"
,
barcode
.
getDateCode
());
while
(
retryCount
<
maxRetries
&&
!
isSuccess
)
{
paramMap
.
put
(
"lot"
,
barcode
.
getBatch
());
retryCount
++;
paramMap
.
put
(
"vendor"
,
barcode
.
getProvider
());
try
{
paramMap
.
put
(
"remark"
,
"ALL"
);
String
resultStr
=
HttpHelper
.
postJson
(
batchCheckReelUrl
,
paramList
);
paramMap
.
put
(
"werks"
,
"ALL"
);
log
.
info
(
"第"
+
retryCount
+
"次批量禁用接口返回结果为:"
+
resultStr
);
paramMap
.
put
(
"model"
,
singleModel
);
paramMap
.
put
(
"picking"
,
"ALL"
);
JSONObject
resultObj
=
JSONObject
.
parseObject
(
resultStr
);
if
(
StringUtils
.
isNotEmpty
(
pickingId
))
{
String
status
=
resultObj
.
getString
(
"status"
);
paramMap
.
put
(
"picking"
,
pickingId
);
}
// 只有返回200才认为成功
paramList
.
add
(
paramMap
);
if
(
"200"
.
equals
(
status
))
{
}
isSuccess
=
true
;
log
.
info
(
"批量禁用入参为:"
+
JSON
.
toJSONString
(
paramList
));
JSONArray
dataArr
=
resultObj
.
getJSONArray
(
"data"
);
if
(
dataArr
!=
null
&&
!
dataArr
.
isEmpty
())
{
//禁用的信息
for
(
int
i
=
0
;
i
<
dataArr
.
size
();
i
++)
{
List
<
String
>
disAbleModelList
=
new
ArrayList
<>();
JSONObject
data
=
dataArr
.
getJSONObject
(
i
);
JSONArray
resultList
=
data
.
getJSONArray
(
"resultList"
);
//如果超过3次,没有记录,则直接
if
(
resultList
!=
null
&&
!
resultList
.
isEmpty
())
{
int
maxRetries
=
3
;
for
(
int
j
=
0
;
j
<
resultList
.
size
();
j
++)
{
int
retryCount
=
0
;
JSONObject
result
=
resultList
.
getJSONObject
(
j
);
boolean
isSuccess
=
false
;
String
reelId
=
result
.
getString
(
"reelId"
);
String
message
=
result
.
getString
(
"message"
);
while
(
retryCount
<
maxRetries
&&
!
isSuccess
)
{
if
(
StringUtils
.
isNotBlank
(
reelId
))
{
retryCount
++;
reelList
.
add
(
reelId
);
try
{
resultMap
.
put
(
reelId
,
message
);
String
resultStr
=
HttpHelper
.
postJson
(
batchCheckReelUrl
,
paramList
);
log
.
info
(
"第"
+
retryCount
+
"次批量禁用接口返回结果为:"
+
resultStr
);
JSONObject
resultObj
=
JSONObject
.
parseObject
(
resultStr
);
String
status
=
resultObj
.
getString
(
"status"
);
// 只有返回200才认为成功
if
(
"200"
.
equals
(
status
))
{
isSuccess
=
true
;
JSONArray
dataArr
=
resultObj
.
getJSONArray
(
"data"
);
if
(
dataArr
!=
null
&&
!
dataArr
.
isEmpty
())
{
for
(
int
i
=
0
;
i
<
dataArr
.
size
();
i
++)
{
JSONObject
data
=
dataArr
.
getJSONObject
(
i
);
JSONArray
resultList
=
data
.
getJSONArray
(
"resultList"
);
if
(
resultList
!=
null
&&
!
resultList
.
isEmpty
())
{
for
(
int
j
=
0
;
j
<
resultList
.
size
();
j
++)
{
JSONObject
result
=
resultList
.
getJSONObject
(
j
);
String
reelId
=
result
.
getString
(
"reelId"
);
String
message
=
result
.
getString
(
"message"
);
if
(
StringUtils
.
isNotBlank
(
reelId
))
{
disAbleModelList
.
add
(
reelId
);
String
disAbleMsg
=
disAbleAllMap
.
get
(
reelId
);
if
(
StringUtils
.
isNotEmpty
(
disAbleMsg
))
{
disAbleMsg
=
disAbleMsg
+
";"
+
singleModel
+
":"
+
message
;
}
else
{
disAbleMsg
=
singleModel
+
":"
+
message
;
}
disAbleAllMap
.
put
(
reelId
,
disAbleMsg
);
}
}
}
}
}
}
}
}
}
}
else
{
log
.
info
(
"第"
+
retryCount
+
"次调用返回非200状态: "
+
status
);
}
}
}
else
{
}
catch
(
Exception
e
)
{
log
.
info
(
"第"
+
retryCount
+
"次调用返回非200状态: "
+
status
);
log
.
error
(
"第"
+
retryCount
+
"次批量禁用接口调用失败: "
+
e
.
getMessage
(),
e
);
}
}
}
catch
(
Exception
e
)
{
log
.
error
(
"第"
+
retryCount
+
"次批量禁用接口调用失败: "
+
e
.
getMessage
(),
e
);
}
}
}
// 如果3次都失败,将所有barcode加入reelList
// 如果3次都失败,将所有barcode加入reelList
if
(!
isSuccess
)
{
if
(!
isSuccess
)
{
log
.
info
(
"经过"
+
maxRetries
+
"次重试后仍失败,将所有条码加入结果列表"
);
log
.
info
(
"经过"
+
maxRetries
+
"次重试后仍失败,将所有条码加入结果列表"
);
for
(
Barcode
barcode
:
barcodeList
)
{
for
(
Barcode
barcode
:
barcodeList
)
{
String
reelId
=
barcode
.
getBarcode
();
String
reelId
=
barcode
.
getBarcode
();
reelList
.
add
(
reelId
);
disAbleModelList
.
add
(
reelId
);
resultMap
.
put
(
reelId
,
"接口调用失败,默认禁用"
);
String
disAbleMsg
=
disAbleAllMap
.
get
(
reelId
);
if
(
StringUtils
.
isNotEmpty
(
disAbleMsg
))
{
disAbleMsg
=
disAbleMsg
+
";"
+
singleModel
+
":接口调用失败,默认禁用"
;
}
else
{
disAbleMsg
=
singleModel
+
":接口调用失败,默认禁用"
;
}
disAbleAllMap
.
put
(
reelId
,
disAbleMsg
);
}
}
}
disAbleModeMap
.
put
(
singleModel
,
disAbleModelList
);
}
}
// 更新条码状态
// ==================== 取交集逻辑 ====================
List
<
String
>
intersectionReelList
=
getIntersectionFromMap
(
disAbleModeMap
);
log
.
info
(
"多model检查完成 - model数量: {}, 交集禁用条码数量: {}"
,
disAbleModeMap
.
size
(),
intersectionReelList
.
size
());
// 更新条码状态 - 只更新交集中的条码
for
(
Barcode
barcode
:
barcodeList
)
{
for
(
Barcode
barcode
:
barcodeList
)
{
if
(
reelList
.
contains
(
barcode
.
getBarcode
()))
{
String
reelId
=
barcode
.
getBarcode
();
String
message
=
resultMap
.
get
(
barcode
.
getBarcode
());
if
(
intersectionReelList
.
contains
(
reelId
))
{
// 在交集中,设置禁用信息
String
message
=
disAbleAllMap
.
get
(
reelId
);
barcode
.
setDisableMsg
(
message
);
barcode
.
setDisableMsg
(
message
);
barcodeManager
.
save
(
barcode
);
barcodeManager
.
save
(
barcode
);
log
.
debug
(
"设置条码 {} 禁用信息: {}"
,
reelId
,
message
);
}
else
{
}
else
{
// 不在交集中,清除禁用信息
if
(
StringUtils
.
isNotEmpty
(
barcode
.
getDisableMsg
()))
{
if
(
StringUtils
.
isNotEmpty
(
barcode
.
getDisableMsg
()))
{
barcode
.
setDisableMsg
(
""
);
barcode
.
setDisableMsg
(
""
);
barcodeManager
.
save
(
barcode
);
barcodeManager
.
save
(
barcode
);
log
.
debug
(
"清除条码 {} 的禁用信息"
,
reelId
);
}
}
}
}
}
}
return
reelList
;
return
intersectionReelList
;
}
/**
* 从Map中获取所有List的交集
*/
private
static
List
<
String
>
getIntersectionFromMap
(
Map
<
String
,
List
<
String
>>
disAbleModeMap
)
{
if
(
disAbleModeMap
==
null
||
disAbleModeMap
.
isEmpty
())
{
return
new
ArrayList
<>();
}
List
<
String
>
intersection
=
null
;
for
(
List
<
String
>
reelList
:
disAbleModeMap
.
values
())
{
if
(
reelList
==
null
||
reelList
.
isEmpty
())
{
// 如果任何一个model没有禁用条码,则交集为空
return
new
ArrayList
<>();
}
if
(
intersection
==
null
)
{
// 第一次遍历,初始化交集
intersection
=
new
ArrayList
<>(
reelList
);
}
else
{
// 后续遍历,取交集
intersection
.
retainAll
(
reelList
);
}
}
return
intersection
!=
null
?
intersection
:
new
ArrayList
<>();
}
}
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论