Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 45d27156
由
hc
编写于
2024-06-27 15:02:02 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
代码优化
1 个父辈
980761b1
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
21 行增加
和
50 行删除
src/main/java/com/neotel/smfcore/custom/luxsan/api/LuxsanApi.java
src/main/java/com/neotel/smfcore/custom/luxsan/common/json/IJsonRule.java
src/main/java/com/neotel/smfcore/custom/luxsan/common/json/impl/DataResultJsonRule.java
src/main/java/com/neotel/smfcore/custom/luxsan/common/util/RequestURLUtil.java
src/main/java/com/neotel/smfcore/custom/luxsan/factory_c/wipstor/controller/LineController.java
src/main/java/com/neotel/smfcore/custom/luxsan/api/LuxsanApi.java
查看文件 @
45d2715
...
@@ -1004,48 +1004,6 @@ public class LuxsanApi extends DefaultSmfApiListener {
...
@@ -1004,48 +1004,6 @@ public class LuxsanApi extends DefaultSmfApiListener {
}
}
}
}
public
static
List
<
GetBoxNGResult
>
getBoxNGsnList
(
Map
request
)
throws
ApiException
{
return
RequestURLUtil
.
request
(
BusinessConst
.
DATA_RESULT_TYPE
,
request
,
BusinessConst
.
POST_METHOD
,
getBoxNGsnListUrl
,
GetBoxNGResult
.
class
);
}
public
static
List
<
GetBoxNGResult
>
getBoxNGsnList
(
GetBoxNGsnListRequest
request
)
throws
ApiException
{
log
.
info
(
"getBoxNGsnList接口请求参数为:"
+
JSON
.
toJSONString
(
request
));
String
resultStr
=
null
;
// 调用外部接口
try
{
resultStr
=
HttpHelper
.
postJson
(
getBoxNGsnListUrl
,
request
);
}
catch
(
Exception
e
)
{
log
.
error
(
String
.
format
(
"接口请求失败[%s]"
,
getBoxNGsnListUrl
));
throw
new
ValidateException
(
"smfcore.api.error"
,
"接口请求失败[{0}]"
,
new
String
[]{
getBoxNGsnListUrl
});
}
log
.
info
(
"getBoxNGsnList接口返回结果为:"
+
resultStr
);
JSONObject
resultJson
=
JsonUtil
.
toObj
(
resultStr
,
JSONObject
.
class
);
String
data
=
resultJson
.
getString
(
"data"
);
if
(
StringUtils
.
isEmpty
(
data
))
{
throw
new
ApiException
(
String
.
format
(
"接口返回内容有误[%s]"
,
getBoxNGsnListUrl
));
}
JSONObject
dataJson
=
resultJson
.
getJSONObject
(
"data"
);
// 远程接口返回的数据错误
if
(
dataJson
.
get
(
"result"
)
!=
null
&&
!
dataJson
.
getBoolean
(
"result"
))
{
String
errorMessage
=
(
String
)
dataJson
.
get
(
"message"
);
if
(
StringUtils
.
isEmpty
(
errorMessage
))
{
errorMessage
=
""
;
}
log
.
error
(
String
.
format
(
"接口请求失败[%s],失败原因[%s]"
,
getBoxNGsnListUrl
,
errorMessage
));
throw
new
ApiException
(
String
.
format
(
"smfcore.api.error 接口请求失败[%s],失败原因[%s]"
,
getBoxNGsnListUrl
,
errorMessage
));
}
else
{
JSONArray
arrayData
=
dataJson
.
getJSONArray
(
"data"
);
System
.
out
.
println
(
arrayData
);
List
<
GetBoxNGResult
>
resultList
=
JSONObject
.
parseArray
(
JSONArray
.
toJSONString
(
arrayData
),
GetBoxNGResult
.
class
);
if
(
resultList
!=
null
&&
!
resultList
.
isEmpty
())
{
return
resultList
;
}
else
{
return
new
ArrayList
<>();
}
}
}
public
static
void
ticketPick
(
TicketPickRequest
request
)
{
public
static
void
ticketPick
(
TicketPickRequest
request
)
{
log
.
info
(
"ticketPick接口请求参数为:"
+
JSON
.
toJSONString
(
request
)+
",地址为:"
+
ticketPickUrl
);
log
.
info
(
"ticketPick接口请求参数为:"
+
JSON
.
toJSONString
(
request
)+
",地址为:"
+
ticketPickUrl
);
try
{
try
{
...
@@ -1062,6 +1020,10 @@ public class LuxsanApi extends DefaultSmfApiListener {
...
@@ -1062,6 +1020,10 @@ public class LuxsanApi extends DefaultSmfApiListener {
}
}
}
}
public
static
List
<
GetBoxNGResult
>
getBoxNGsnListWithStrategyPattern
(
GetBoxNGsnListRequest
request
)
throws
ApiException
{
return
RequestURLUtil
.
INSTANCE
.
request
(
BusinessConst
.
DATA_RESULT_TYPE
,
request
,
BusinessConst
.
POST_METHOD
,
getBoxNGsnListUrl
,
GetBoxNGResult
.
class
);
}
@Override
@Override
public
void
outTaskStatusChange
(
String
outNotifyUrl
,
DataLog
task
)
{
public
void
outTaskStatusChange
(
String
outNotifyUrl
,
DataLog
task
)
{
...
...
src/main/java/com/neotel/smfcore/custom/luxsan/common/json/IJsonRule.java
查看文件 @
45d2715
...
@@ -8,8 +8,8 @@ import java.util.Map;
...
@@ -8,8 +8,8 @@ import java.util.Map;
/**
/**
* 解析外部接口返回的json规则
* 解析外部接口返回的json规则
*/
*/
public
interface
IJsonRule
{
public
interface
IJsonRule
<
T
>
{
String
getType
();
String
getType
();
List
request
(
Map
request
,
String
httpMethod
,
String
url
,
Class
<?>
returnType
)
throws
ApiException
;
List
request
(
T
request
,
String
httpMethod
,
String
url
,
Class
<?>
returnType
)
throws
ApiException
;
}
}
src/main/java/com/neotel/smfcore/custom/luxsan/common/json/impl/DataResultJsonRule.java
查看文件 @
45d2715
...
@@ -19,14 +19,14 @@ import java.util.Map;
...
@@ -19,14 +19,14 @@ import java.util.Map;
@Slf4j
@Slf4j
@Service
@Service
public
class
DataResultJsonRule
implements
IJsonRule
{
public
class
DataResultJsonRule
<
T
>
implements
IJsonRule
<
T
>
{
@Override
@Override
public
String
getType
()
{
public
String
getType
()
{
return
BusinessConst
.
DATA_RESULT_TYPE
;
return
BusinessConst
.
DATA_RESULT_TYPE
;
}
}
@Override
@Override
public
List
request
(
Map
request
,
String
httpMethod
,
String
url
,
Class
<?>
returnType
)
throws
ApiException
{
public
List
request
(
T
request
,
String
httpMethod
,
String
url
,
Class
<?>
returnType
)
throws
ApiException
{
log
.
info
(
String
.
format
(
"[%s]接口请求参数为:"
+
JSON
.
toJSONString
(
request
),
url
));
log
.
info
(
String
.
format
(
"[%s]接口请求参数为:"
+
JSON
.
toJSONString
(
request
),
url
));
String
resultStr
=
null
;
String
resultStr
=
null
;
// 调用外部接口
// 调用外部接口
...
...
src/main/java/com/neotel/smfcore/custom/luxsan/common/util/RequestURLUtil.java
查看文件 @
45d2715
...
@@ -2,6 +2,10 @@ package com.neotel.smfcore.custom.luxsan.common.util;
...
@@ -2,6 +2,10 @@ package com.neotel.smfcore.custom.luxsan.common.util;
import
com.neotel.smfcore.common.exception.ApiException
;
import
com.neotel.smfcore.common.exception.ApiException
;
import
com.neotel.smfcore.custom.luxsan.common.json.IJsonRule
;
import
com.neotel.smfcore.custom.luxsan.common.json.IJsonRule
;
import
org.springframework.beans.BeansException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContextAware
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
java.util.HashMap
;
import
java.util.HashMap
;
...
@@ -9,7 +13,9 @@ import java.util.List;
...
@@ -9,7 +13,9 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Map
;
@Component
@Component
public
class
RequestURLUtil
{
public
class
RequestURLUtil
<
T
>
implements
ApplicationContextAware
{
public
static
RequestURLUtil
INSTANCE
;
private
static
Map
<
String
,
IJsonRule
>
iJsonRuleMap
=
new
HashMap
<>();
private
static
Map
<
String
,
IJsonRule
>
iJsonRuleMap
=
new
HashMap
<>();
public
RequestURLUtil
(
List
<
IJsonRule
>
iJsonRules
)
{
public
RequestURLUtil
(
List
<
IJsonRule
>
iJsonRules
)
{
...
@@ -18,10 +24,14 @@ public class RequestURLUtil {
...
@@ -18,10 +24,14 @@ public class RequestURLUtil {
}
}
}
}
public
static
List
request
(
String
type
,
Map
request
,
String
httpMethod
,
String
url
,
Class
<?>
returnType
)
throws
ApiException
{
public
List
request
(
String
type
,
T
request
,
String
httpMethod
,
String
url
,
Class
<?>
returnType
)
throws
ApiException
{
IJsonRule
iJsonRule
=
iJsonRuleMap
.
get
(
type
);
IJsonRule
iJsonRule
=
iJsonRuleMap
.
get
(
type
);
List
res
=
iJsonRule
.
request
(
request
,
httpMethod
,
url
,
returnType
);
List
res
=
iJsonRule
.
request
(
request
,
httpMethod
,
url
,
returnType
);
return
res
;
return
res
;
}
}
@Override
public
void
setApplicationContext
(
ApplicationContext
applicationContext
)
throws
BeansException
{
INSTANCE
=
applicationContext
.
getBean
(
RequestURLUtil
.
class
);
}
}
}
src/main/java/com/neotel/smfcore/custom/luxsan/factory_c/wipstor/controller/LineController.java
查看文件 @
45d2715
...
@@ -355,8 +355,7 @@ public class LineController {
...
@@ -355,8 +355,7 @@ public class LineController {
Map
<
String
,
String
>
map
=
new
HashMap
<>();
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"model"
,
result
.
getModel
());
map
.
put
(
"model"
,
result
.
getModel
());
map
.
put
(
"carton_id"
,
result
.
getCarton_id
());
map
.
put
(
"carton_id"
,
result
.
getCarton_id
());
List
<
GetBoxNGResult
>
boxNGsnList
=
LuxsanApi
.
getBoxNGsnList
(
map
);
return
ResultBean
.
newOkResult
(
LuxsanApi
.
getBoxNGsnListWithStrategyPattern
(
result
));
return
ResultBean
.
newOkResult
(
boxNGsnList
);
}
}
@ApiOperation
(
"手动完成入库任务"
)
@ApiOperation
(
"手动完成入库任务"
)
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论