Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 4f6e99af
由
zshaohui
编写于
2023-12-06 14:03:53 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
入库单如果缓存没有,调用api接口获取
1 个父辈
6c958c57
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
53 行增加
和
20 行删除
src/main/java/com/neotel/smfcore/core/api/SmfApi.java
src/main/java/com/neotel/smfcore/core/api/listener/BaseSmfApiListener.java
src/main/java/com/neotel/smfcore/core/api/listener/DefaultSmfApiListener.java
src/main/java/com/neotel/smfcore/core/api/listener/ISmfApiListener.java
src/main/java/com/neotel/smfcore/core/inList/rest/InListController.java
src/main/java/com/neotel/smfcore/core/api/SmfApi.java
查看文件 @
4f6e99a
...
...
@@ -2,12 +2,14 @@ package com.neotel.smfcore.core.api;
import
cn.hutool.core.util.ObjectUtil
;
import
com.google.common.collect.Lists
;
import
com.neotel.smfcore.common.exception.ApiException
;
import
com.neotel.smfcore.common.exception.ValidateException
;
import
com.neotel.smfcore.common.init.MenuInit
;
import
com.neotel.smfcore.core.api.listener.ISmfApiListener
;
import
com.neotel.smfcore.core.barcode.service.po.Barcode
;
import
com.neotel.smfcore.core.api.bean.CodeValidateParam
;
import
com.neotel.smfcore.core.device.util.DataCache
;
import
com.neotel.smfcore.core.inList.service.po.InList
;
import
com.neotel.smfcore.core.order.service.po.LiteOrder
;
import
com.neotel.smfcore.core.system.service.po.DataLog
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -262,6 +264,20 @@ public class SmfApi {
return
false
;
}
public
InList
fetchInList
(
String
number
)
{
if
(
isUrlExist
(
fetchInListUrl
))
{
for
(
ISmfApiListener
apiListener
:
apiListenerList
)
{
if
(
apiListener
.
isForThisApi
(
apiName
))
{
InList
inList
=
apiListener
.
fetchInList
(
fetchInListUrl
,
number
);
if
(
inList
!=
null
)
{
return
inList
;
}
}
}
}
return
null
;
}
public
String
getApiName
(){
return
apiName
;
}
...
...
src/main/java/com/neotel/smfcore/core/api/listener/BaseSmfApiListener.java
查看文件 @
4f6e99a
...
...
@@ -118,6 +118,11 @@ public abstract class BaseSmfApiListener implements ISmfApiListener {
public
boolean
canLogin
(
String
loginCheckUrl
,
String
userName
,
String
pwd
)
throws
ValidateException
{
return
true
;
}
@Override
public
InList
fetchInList
(
String
fetchInListUrl
,
String
number
){
return
null
;
}
protected
String
getData
(
Map
<
String
,
Object
>
dataMap
,
String
dataKey
)
{
Object
data
=
dataMap
.
get
(
dataKey
);
if
(
data
==
null
)
{
...
...
src/main/java/com/neotel/smfcore/core/api/listener/DefaultSmfApiListener.java
查看文件 @
4f6e99a
...
...
@@ -197,31 +197,31 @@ public class DefaultSmfApiListener extends BaseSmfApiListener {
}
}
public
InList
fetchInList
(
String
fetchInListUrl
,
String
number
)
throws
ApiException
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"number"
,
number
);
public
InList
fetchInList
(
String
fetchInListUrl
,
String
number
)
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"number"
,
number
);
try
{
log
.
info
(
"调用获取入库单接口,参数"
+
JsonUtil
.
toJsonStr
(
paramMap
));
String
result
=
HttpHelper
.
postJson
(
fetchInListUrl
,
paramMap
);
log
.
info
(
number
+
"获取入库单接口返回"
+
result
);
ApiResult
apiResult
=
JsonUtil
.
toObj
(
result
,
ApiResult
.
class
);
if
(
apiResult
.
isOk
())
{
Map
<
String
,
Object
>
dataMap
=
(
Map
<
String
,
Object
>)
apiResult
.
getData
();
ApiResult
apiResult
=
JsonUtil
.
toObj
(
result
,
ApiResult
.
class
);
if
(
apiResult
.
isOk
())
{
Map
<
String
,
Object
>
dataMap
=
(
Map
<
String
,
Object
>)
apiResult
.
getData
();
String
returnNumber
=
dataMap
.
get
(
"number"
).
toString
();
InList
inList
=
new
InList
();
inList
.
setName
(
returnNumber
);
List
<
InListItem
>
items
=
new
ArrayList
<>();
List
<
Map
<
String
,
Object
>>
itemList
=
(
List
<
Map
<
String
,
Object
>>)
dataMap
.
get
(
"items"
);
List
<
Map
<
String
,
Object
>>
itemList
=
(
List
<
Map
<
String
,
Object
>>)
dataMap
.
get
(
"items"
);
for
(
Map
<
String
,
Object
>
itemMap
:
itemList
)
{
String
partNum
=
itemMap
.
get
(
"partNum"
).
toString
();
Object
qtyStr
=
itemMap
.
get
(
"qty"
);
Object
reelCountStr
=
itemMap
.
get
(
"reelCount"
);
InListItem
item
=
new
InListItem
();
item
.
setPN
(
partNum
);
if
(
qtyStr
!=
null
&&
!
qtyStr
.
toString
().
isEmpty
())
{
if
(
qtyStr
!=
null
&&
!
qtyStr
.
toString
().
isEmpty
())
{
item
.
setNum
(
Integer
.
valueOf
(
qtyStr
.
toString
()));
}
if
(
reelCountStr
!=
null
&&
!
qtyStr
.
toString
().
isEmpty
())
{
if
(
reelCountStr
!=
null
&&
!
qtyStr
.
toString
().
isEmpty
())
{
item
.
setInReelCount
(
Integer
.
valueOf
(
reelCountStr
.
toString
()));
}
items
.
add
(
item
);
...
...
@@ -231,12 +231,12 @@ public class DefaultSmfApiListener extends BaseSmfApiListener {
inList
=
inListManager
.
createWithItems
(
inList
);
inListCache
.
addInListToMap
(
inList
);
return
inList
;
}
else
{
throw
new
ApiException
(
"smfcore.fetchInList.ng"
,
"获取入库单MES返回NG:"
+
apiResult
.
getMsg
());
}
else
{
throw
new
ApiException
(
"smfcore.fetchInList.ng"
,
"获取入库单MES返回NG:"
+
apiResult
.
getMsg
());
}
}
catch
(
Exception
e
)
{
log
.
error
(
number
+
"获取入库单接口出错:"
+
e
.
getMessage
());
throw
new
ApiException
(
"smfcore.fetchInList.error"
,
"获取入库单出错:"
+
e
.
getMessage
())
;
return
null
;
}
}
...
...
src/main/java/com/neotel/smfcore/core/api/listener/ISmfApiListener.java
查看文件 @
4f6e99a
package
com
.
neotel
.
smfcore
.
core
.
api
.
listener
;
import
com.neotel.smfcore.common.exception.ApiException
;
import
com.neotel.smfcore.common.exception.ValidateException
;
import
com.neotel.smfcore.core.barcode.service.po.Barcode
;
import
com.neotel.smfcore.core.api.bean.CodeValidateParam
;
import
com.neotel.smfcore.core.inList.service.po.InList
;
import
com.neotel.smfcore.core.order.service.po.LiteOrder
;
import
com.neotel.smfcore.core.system.service.po.DataLog
;
...
...
@@ -67,4 +69,7 @@ public interface ISmfApiListener {
* 是否可以登陆
*/
boolean
canLogin
(
String
loginCheckUrl
,
String
userName
,
String
pwd
)
throws
ValidateException
;
InList
fetchInList
(
String
fetchInListUrl
,
String
number
);
}
src/main/java/com/neotel/smfcore/core/inList/rest/InListController.java
查看文件 @
4f6e99a
...
...
@@ -9,6 +9,7 @@ import com.neotel.smfcore.common.csv.CsvReader;
import
com.neotel.smfcore.common.exception.ValidateException
;
import
com.neotel.smfcore.common.utils.FileUtil
;
import
com.neotel.smfcore.common.utils.QueryHelp
;
import
com.neotel.smfcore.core.api.SmfApi
;
import
com.neotel.smfcore.core.device.util.DataCache
;
import
com.neotel.smfcore.core.inList.enums.INLIST_STATUS
;
import
com.neotel.smfcore.core.inList.rest.bean.dto.InListDto
;
...
...
@@ -73,6 +74,9 @@ public class InListController {
@Autowired
private
IStorageManager
storageManager
;
@Autowired
private
SmfApi
smfApi
;
@ApiOperation
(
"上传入库单"
)
@PostMapping
(
value
=
"/upload"
)
@AnonymousAccess
...
...
@@ -187,13 +191,16 @@ public class InListController {
String
inListName
=
params
.
get
(
"inListName"
);
String
storageId
=
params
.
get
(
"storageId"
);
String
groupId
=
params
.
get
(
"groupId"
);
if
(
ObjectUtil
.
isEmpty
(
inListName
))
{
if
(
ObjectUtil
.
isEmpty
(
inListName
))
{
}
else
{
}
else
{
InList
inList
=
inListCache
.
getInList
(
inListName
);
if
(
inList
==
null
)
{
return
ResultBean
.
newErrorResult
(
1
,
"smfcore.inlist.notFound"
,
"未找到入库单[{0}]"
,
new
String
[]{
inListName
});
//如果入库单为空的话,调用api获取
inList
=
smfApi
.
fetchInList
(
inListName
);
if
(
inList
==
null
)
{
return
ResultBean
.
newErrorResult
(
1
,
"smfcore.inlist.notFound"
,
"未找到入库单[{0}]"
,
new
String
[]{
inListName
});
}
}
if
(
inList
.
getStatus
()
==
INLIST_STATUS
.
OK
)
{
return
ResultBean
.
newErrorResult
(
1
,
"smfcore.inlist.listOk"
,
"入库单[{0}]已完成"
,
new
String
[]{
inListName
});
...
...
@@ -206,11 +213,11 @@ public class InListController {
for
(
String
cid
:
cidList
)
{
Storage
storage
=
dataCache
.
getStorage
(
cid
);
if
(
storage
!=
null
)
{
if
(
storage
.
isType
(
new
DeviceType
[]{
DeviceType
.
NLP
,
DeviceType
.
NL
,
DeviceType
.
NLS
}))
{
if
(
storage
.
isType
(
new
DeviceType
[]{
DeviceType
.
NLP
,
DeviceType
.
NL
,
DeviceType
.
NLS
}))
{
storage
.
setInListName
(
inListName
);
log
.
info
(
"设置组["
+
groupId
+
"]料架["
+
storage
.
getName
()
+
"]的入库单为:["
+
inListName
+
"]"
);
storageManager
.
save
(
storage
);
dataCache
.
reloadStorage
(
storage
,
""
);
dataCache
.
reloadStorage
(
storage
,
""
);
}
}
...
...
@@ -218,11 +225,11 @@ public class InListController {
}
else
{
Storage
storage
=
dataCache
.
getStorageById
(
storageId
);
if
(
storage
!=
null
)
{
if
(
storage
.
isType
(
new
DeviceType
[]{
DeviceType
.
NLP
,
DeviceType
.
NL
,
DeviceType
.
NLS
}))
{
if
(
storage
.
isType
(
new
DeviceType
[]{
DeviceType
.
NLP
,
DeviceType
.
NL
,
DeviceType
.
NLS
}))
{
storage
.
setInListName
(
inListName
);
log
.
info
(
"设置料架["
+
storage
.
getName
()
+
"]的入库单为:["
+
inListName
+
"]"
);
storageManager
.
save
(
storage
);
dataCache
.
reloadStorage
(
storage
,
""
);
dataCache
.
reloadStorage
(
storage
,
""
);
}
}
}
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论