Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 2cac58d7
由
LN
编写于
2024-07-29 15:43:56 +0800
浏览文件
选项
浏览文件
标签
下载
差异文件
Merge remote-tracking branch 'origin/SO1434' into SO1434
2 个父辈
1a31e6c8
32ef4b1d
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
27 行增加
和
20 行删除
src/main/java/com/neotel/smfcore/custom/luxsan_sp/api/LuxsanSpApi.java
src/main/resources/config/application-apiprod.yml
src/main/java/com/neotel/smfcore/custom/luxsan_sp/api/LuxsanSpApi.java
查看文件 @
2cac58d
...
...
@@ -19,6 +19,7 @@ import lombok.extern.slf4j.Slf4j;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -50,11 +51,12 @@ public class LuxsanSpApi extends DefaultSmfApiListener {
// 备品仓退库查询接口的GET方法
public
static
List
<
GetReturnInventoryResult
>
getReturnInventory
(
GetReturnInventoryRequest
request
)
{
String
url
=
null
;
try
{
// 记录请求日志
log
.
info
(
"备品仓退库查询接口请求为: "
+
JSON
.
toJSONString
(
request
));
// 构造请求URL,附加查询参数
String
url
=
GetReturnInventory
+
getQueryStr
(
request
);
url
=
GetReturnInventory
+
getQueryStr
(
request
);
// 发送GET请求并获取JSON格式的响应字符串
String
resJsonStr
=
HttpHelper
.
sendGet
(
url
);
log
.
info
(
"备品仓退库查询接口返回为:"
+
resJsonStr
);
...
...
@@ -63,45 +65,49 @@ public class LuxsanSpApi extends DefaultSmfApiListener {
// 检查API调用是否成功,并返回结果对象
if
(
ObjectUtil
.
isNotNull
(
lizhenApiResult
))
{
if
(
lizhenApiResult
.
getCode
()
!=
200
)
{
throw
new
Exception
(
String
.
format
(
"备品仓退库查询接口请求失败, 错误代码[%d],错误原因[%s]"
,
lizhenApiResult
.
getCode
(),
lizhenApiResult
.
getMsg
()));
throw
new
Exception
(
String
.
format
(
"备品仓退库查询接口
[%s]
请求失败, 错误代码[%d],错误原因[%s]"
,
url
,
lizhenApiResult
.
getCode
(),
lizhenApiResult
.
getMsg
()));
}
List
<
GetReturnInventoryResult
>
resultList
=
JSONObject
.
parseArray
(
lizhenApiResult
.
getData
(),
GetReturnInventoryResult
.
class
);
if
(
resultList
!=
null
&&
!
resultList
.
isEmpty
()){
if
(
resultList
!=
null
&&
!
resultList
.
isEmpty
())
{
return
resultList
;
}
else
{
return
new
ArrayList
<>();
}
}
}
catch
(
Exception
e
)
{
// 记录异常日志
log
.
error
(
"备品仓退库查询接口
请求失败: "
+
e
.
getMessage
(),
e
);
log
.
error
(
"备品仓退库查询接口
[{0}]请求失败: "
+
e
.
getMessage
(),
url
);
// 抛出自定义异常
throw
new
ValidateException
(
"smfcore.api.error"
,
"接口
请求失败[{0}]"
,
new
String
[]{
e
.
getMessage
()});
throw
new
ValidateException
(
"smfcore.api.error"
,
"接口
[{0}]请求失败[{1}]"
,
new
String
[]{
url
,
e
.
getMessage
()});
}
// 如果没有成功返回结果,抛出异常
throw
new
ValidateException
(
"smfcore.api.error"
,
"接口请求失败[{0}]"
,
new
String
[]{
"未找到对应的退库单信息"
});
}
public
static
List
<
GetUnclaimedResult
>
getUnclaimedDetails
(
GetUnclaimedRequest
request
)
{
String
url
=
null
;
try
{
log
.
info
(
"预约待领取接口请求为:"
+
JSON
.
toJSONString
(
request
));
String
url
=
GetUnclaimedUrl
+
getQueryStr
(
request
);
url
=
GetUnclaimedUrl
+
getQueryStr
(
request
);
String
resJsonStr
=
HttpHelper
.
sendGet
(
url
);
log
.
info
(
"预约待领取接口请求返回:"
+
resJsonStr
);
LuxsanSpApiResult
lizhenApiResult
=
JSONObject
.
parseObject
(
resJsonStr
,
LuxsanSpApiResult
.
class
);
if
(
lizhenApiResult
.
getCode
()
!=
200
)
{
throw
new
Exception
(
String
.
format
(
"预约待领取接口接口请求失败, 错误代码[%d],错误原因[%s]"
,
lizhenApiResult
.
getCode
(),
lizhenApiResult
.
getMsg
()));
throw
new
Exception
(
String
.
format
(
"预约待领取接口接口
[%s]
请求失败, 错误代码[%d],错误原因[%s]"
,
url
,
lizhenApiResult
.
getCode
(),
lizhenApiResult
.
getMsg
()));
}
String
data
=
lizhenApiResult
.
getData
();
List
<
GetUnclaimedResult
>
resultList
=
JSONObject
.
parseArray
(
data
,
GetUnclaimedResult
.
class
);
if
(
resultList
!=
null
&&
!
resultList
.
isEmpty
()){
if
(
resultList
!=
null
&&
!
resultList
.
isEmpty
())
{
return
resultList
;
}
else
{
return
new
ArrayList
<>();
}
}
catch
(
Exception
e
)
{
log
.
info
(
"getUnclaimedDetails请求失败:"
+
e
.
getMessage
());
throw
new
ValidateException
(
"smfcore.api.error"
,
"接口请求失败[{0}]
"
,
new
String
[]{
e
.
getMessage
()});
throw
new
ValidateException
(
"smfcore.api.error"
,
"接口请求失败[{0}]
,错误信息[{1}]"
,
new
String
[]{
url
,
e
.
getMessage
()});
}
throw
new
ValidateException
(
"smfcore.api.error"
,
"接口请求失败[{0}]"
,
new
String
[]{
"未找到对应的预约单接口"
});
}
...
...
@@ -112,28 +118,29 @@ public class LuxsanSpApi extends DefaultSmfApiListener {
log
.
info
(
"备品仓入库接口返回:"
+
resJsonStr
);
LuxsanSpApiResult
lizhenApiResult
=
JSONObject
.
parseObject
(
resJsonStr
,
LuxsanSpApiResult
.
class
);
if
(
lizhenApiResult
.
getCode
()
!=
200
)
{
throw
new
ApiException
(
String
.
format
(
"备品仓入库接口请求失败, 错误代码[%d],错误原因[%s]"
,
lizhenApiResult
.
getCode
(),
lizhenApiResult
.
getMsg
()));
throw
new
ApiException
(
String
.
format
(
"备品仓入库接口
[%s]
请求失败, 错误代码[%d],错误原因[%s]"
,
SpareInHourseUrl
,
lizhenApiResult
.
getCode
(),
lizhenApiResult
.
getMsg
()));
}
}
catch
(
ApiException
e
)
{
log
.
info
(
"备品仓入库接口请求失败:"
+
e
.
getMessage
());
throw
new
ValidateException
(
"smfcore.api.error"
,
"接口
请求失败[{0}]"
,
new
String
[]{
e
.
getMessage
()});
throw
new
ValidateException
(
"smfcore.api.error"
,
"接口
[{0}]请求失败[{1}]"
,
new
String
[]{
SpareInHourseUrl
,
e
.
getMessage
()});
}
//throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{SpareInHourseUrl});
}
public
static
List
<
GetSpareNoResult
>
getSpareNo
(
GetSpareNoRequest
request
)
{
String
url
=
null
;
try
{
String
url
=
GetSpareNoUrl
+
getQueryStr
(
request
);
url
=
GetSpareNoUrl
+
getQueryStr
(
request
);
log
.
info
(
"获取入库单号请求为:"
+
request
);
String
resJsonStr
=
HttpHelper
.
sendGet
(
url
);
// String resJsonStr = HttpHelper.sendGet(url);
log
.
info
(
"获取入库单号返回:"
+
resJsonStr
);
LuxsanSpApiResult
lizhenApiResult
=
JSONObject
.
parseObject
(
resJsonStr
,
LuxsanSpApiResult
.
class
);
if
(
lizhenApiResult
.
getCode
()
!=
200
)
{
throw
new
Exception
(
String
.
format
(
"获取入库单号接口请求失败, 错误代码[%d],错误原因[%s]"
,
lizhenApiResult
.
getCode
(),
lizhenApiResult
.
getMsg
()));
throw
new
Exception
(
String
.
format
(
"获取入库单号接口请
[{%s}]
求失败, 错误代码[%d],错误原因[%s]"
,
url
,
lizhenApiResult
.
getCode
(),
lizhenApiResult
.
getMsg
()));
}
List
<
GetSpareNoResult
>
resultList
=
JSONObject
.
parseArray
(
lizhenApiResult
.
getData
(),
GetSpareNoResult
.
class
);
if
(
resultList
!=
null
&&
!
resultList
.
isEmpty
())
{
...
...
@@ -141,7 +148,7 @@ public class LuxsanSpApi extends DefaultSmfApiListener {
}
}
catch
(
Exception
e
)
{
log
.
info
(
"getSpareNo请求失败:"
+
e
.
getMessage
());
throw
new
ValidateException
(
"smfcore.api.error"
,
"接口
请求失败[{0}]"
,
new
String
[]{
e
.
getMessage
()});
throw
new
ValidateException
(
"smfcore.api.error"
,
"接口
[{0}]请求失败[{1}]"
,
new
String
[]{
url
,
e
.
getMessage
()});
}
throw
new
ValidateException
(
"smfcore.api.error"
,
"接口请求失败[{0}]"
,
new
String
[]{
"未找到入库单信息"
});
}
...
...
src/main/resources/config/application-apiprod.yml
查看文件 @
2cac58d
api
:
name
:
Luxsan_sp
getSpareNo
:
http://lxkjgw.api.luxsan-ict.com:8000/iams
-
api/getSpareNo
getSpareNo
:
http://lxkjgw.api.luxsan-ict.com:8000/iams
prd
api/getSpareNo
spareInhourse
:
http://lxkjgw.api.luxsan-ict.com:8000/iamsprdapi/spareInhourse
getUnclaimed
:
http://lxkjgw.api.luxsan-ict.com:8000/iamsprdapi/getUnclaimed
getReturnInventory
:
http://lxkjgw.api.luxsan-ict.com:8000/iamsprdapi/getReturnInventory
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论