Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gdtel-gztel-school-center
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
吴学德
gdtel-gztel-school-center
Commits
054b6b8e
Commit
054b6b8e
authored
Jan 28, 2021
by
罗承锋
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加智能平台状态获取方法
parent
ee4baef8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
67 additions
and
4 deletions
+67
-4
common/src/main/java/com/winsun/outSideSystem/IntelligenceSendOrder.java
+67
-4
No files found.
common/src/main/java/com/winsun/outSideSystem/IntelligenceSendOrder.java
View file @
054b6b8e
package
com
.
winsun
.
outSideSystem
;
import
c
om.alibaba.fastjson.JSON
;
import
c
n.hutool.crypto.digest.DigestUtil
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.mapper.EntityWrapper
;
import
com.baomidou.mybatisplus.mapper.Wrapper
;
import
com.netflix.discovery.converters.Auto
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.winsun.auth.core.util.DateUtil
;
import
com.winsun.bean.Order
;
import
com.winsun.bean.OrderHistory
;
import
com.winsun.bean.OrderView
;
...
...
@@ -31,10 +32,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Component
;
import
javax.net.ssl.SSLHandshakeException
;
import
java.io.IOException
;
import
java.io.UnsupportedEncodingException
;
import
java.net.SocketTimeoutException
;
import
java.net.URLEncoder
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
...
...
@@ -1842,4 +1842,67 @@ public class IntelligenceSendOrder {
}
}
}
/**
* 查询智能平台状态
*
* @param orderNum 智能平台订单号
* @return 返回结果为json字符串,若错误则返回空字符串
*/
public
String
queryStatus
(
String
orderNum
)
{
ObjectMapper
OBJECT_MAPPER
=
new
ObjectMapper
();
List
<
BasicNameValuePair
>
qParams
=
new
ArrayList
<>();
Map
<
String
,
Object
>
signMap
=
new
HashMap
<>();
//待签名参数
RequestConfig
defaultRequestConfig
=
RequestConfig
.
custom
().
setSocketTimeout
(
50000
)
.
setConnectTimeout
(
50000
).
setConnectionRequestTimeout
(
50000
).
build
();
CloseableHttpClient
httpclient
=
HttpClients
.
custom
().
setDefaultRequestConfig
(
defaultRequestConfig
)
.
build
();
HttpEntity
entity
=
null
;
HttpPost
httpPost
=
new
HttpPost
(
Constant
.
ZHANGSHIURL
+
"query.action"
);
RequestConfig
requestConfig
=
RequestConfig
.
copy
(
defaultRequestConfig
).
build
();
httpPost
.
setConfig
(
requestConfig
);
qParams
.
add
(
new
BasicNameValuePair
(
"service"
,
"query.order.status"
));
//api标识,必填
signMap
.
put
(
"service"
,
"query.order.status"
);
qParams
.
add
(
new
BasicNameValuePair
(
"userName"
,
Constant
.
ZHENGSHIAUCCON
));
//用户名,必填
signMap
.
put
(
"userName"
,
Constant
.
ZHENGSHIAUCCON
);
String
timeStamp
=
DateUtil
.
format
(
new
Date
(),
DateUtil
.
yyyyMMddHHmmss
);
qParams
.
add
(
new
BasicNameValuePair
(
"timeStamp"
,
timeStamp
));
signMap
.
put
(
"timeStamp"
,
timeStamp
);
qParams
.
add
(
new
BasicNameValuePair
(
"orderNumber"
,
orderNum
));
//智能平台订单编号,非必填
signMap
.
put
(
"orderNumber"
,
orderNum
);
try
{
List
<
String
>
keys
=
new
ArrayList
<>();
keys
.
addAll
(
signMap
.
keySet
());
Collections
.
sort
(
keys
);
//key按字符串升序
String
value
,
plaintext
=
""
;
for
(
String
key
:
keys
){
value
=
signMap
.
get
(
key
).
toString
();
plaintext
=
plaintext
.
concat
(
value
);
}
plaintext
=
plaintext
.
concat
(
Constant
.
ZHANGSHIKEY
);
System
.
out
.
println
(
plaintext
);
// plaintext = plaintext.concat("ef6f0b823b5cecc9972dee2bf9fb9936");
String
sign
=
DigestUtil
.
md5Hex
(
plaintext
).
toUpperCase
();
qParams
.
add
(
new
BasicNameValuePair
(
"sign"
,
sign
));
//签名,必填
httpPost
.
setHeader
(
"Content-Type"
,
"application/x-www-form-urlencoded;charset=utf-8"
);
httpPost
.
setEntity
(
new
UrlEncodedFormEntity
(
qParams
,
"UTF-8"
));
HttpResponse
response
=
httpclient
.
execute
(
httpPost
);
// 请求返回结果
String
httpResult
=
EntityUtils
.
toString
(
response
.
getEntity
());
// String 转化为 Map格式结果
HashMap
<
String
,
Object
>
mapData
=
new
HashMap
<>();
mapData
.
putAll
(
OBJECT_MAPPER
.
readValue
(
httpResult
,
mapData
.
getClass
()));
return
JSONObject
.
toJSONString
(
mapData
);
}
catch
(
SocketTimeoutException
e
)
{
e
.
printStackTrace
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
httpPost
.
releaseConnection
();
}
return
""
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment