Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
S
semiconductor
Project
Project
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
Graph
比较
统计图
议题
0
议题
0
列表
看板
标记
Milestones
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
inroi
semiconductor
Commits
2c7c186e
提交
2c7c186e
authored
10月 27, 2022
作者:
inroi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
微调
上级
8be694c1
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
100 行增加
和
37 行删除
+100
-37
KingDeeApi.java
...uctor-system/src/main/java/com/system/api/KingDeeApi.java
+5
-6
KingDeeApiClient.java
...system/src/main/java/com/system/api/KingDeeApiClient.java
+7
-6
Constants.java
...-system/src/main/java/com/system/constants/Constants.java
+3
-1
KingDeeConstants.java
.../src/main/java/com/system/constants/KingDeeConstants.java
+3
-0
LicScheduler.java
...stem/src/main/java/com/system/scheduler/LicScheduler.java
+1
-1
HttpUtil.java
...uctor-system/src/main/java/com/system/utils/HttpUtil.java
+81
-23
没有找到文件。
semiconductor-system/src/main/java/com/system/api/KingDeeApi.java
浏览文件 @
2c7c186e
...
@@ -8,7 +8,7 @@ import com.system.exception.KingDeeConnectException;
...
@@ -8,7 +8,7 @@ import com.system.exception.KingDeeConnectException;
import
com.system.model.DelayedElement
;
import
com.system.model.DelayedElement
;
import
com.system.model.InitConnectParam
;
import
com.system.model.InitConnectParam
;
import
com.system.serivce.ISynchronizationService
;
import
com.system.serivce.ISynchronizationService
;
import
com.system.utils.Http
Client
Util
;
import
com.system.utils.HttpUtil
;
import
com.system.utils.JsonUtil
;
import
com.system.utils.JsonUtil
;
import
com.system.utils.KingDeeLogUtil
;
import
com.system.utils.KingDeeLogUtil
;
import
com.system.utils.StringUtil
;
import
com.system.utils.StringUtil
;
...
@@ -17,7 +17,6 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -17,7 +17,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.PostConstruct
;
import
javax.annotation.PostConstruct
;
import
java.io.IOException
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -271,8 +270,8 @@ public class KingDeeApi {
...
@@ -271,8 +270,8 @@ public class KingDeeApi {
public
String
sendThirdParty
(
String
json
,
int
index
)
{
public
String
sendThirdParty
(
String
json
,
int
index
)
{
try
{
try
{
return
Http
ClientUtil
.
sendPost
(
this
.
thirdPartyUrl
,
json
);
return
Http
Util
.
httpPost
(
this
.
thirdPartyUrl
,
json
).
getBody
(
);
}
catch
(
IO
Exception
e
)
{
}
catch
(
Exception
e
)
{
if
(
index
!=
0
)
{
if
(
index
!=
0
)
{
this
.
sendThirdParty
(
json
,
index
-
1
);
this
.
sendThirdParty
(
json
,
index
-
1
);
}
else
{
}
else
{
...
@@ -302,8 +301,8 @@ public class KingDeeApi {
...
@@ -302,8 +301,8 @@ public class KingDeeApi {
public
String
sendPlugInUnit
(
String
plugInUrl
,
String
json
,
Integer
index
)
{
public
String
sendPlugInUnit
(
String
plugInUrl
,
String
json
,
Integer
index
)
{
try
{
try
{
return
Http
ClientUtil
.
sendPost
(
plugInUrl
,
json
);
return
Http
Util
.
httpPost
(
plugInUrl
,
json
).
getBody
(
);
}
catch
(
IO
Exception
e
)
{
}
catch
(
Exception
e
)
{
if
(
index
!=
0
)
{
if
(
index
!=
0
)
{
this
.
sendPlugInUnit
(
plugInUrl
,
json
,
index
-
1
);
this
.
sendPlugInUnit
(
plugInUrl
,
json
,
index
-
1
);
}
}
...
...
semiconductor-system/src/main/java/com/system/api/KingDeeApiClient.java
浏览文件 @
2c7c186e
package
com
.
system
.
api
;
package
com
.
system
.
api
;
import
com.system.config.ThreadLocalConfig
;
import
com.system.config.ThreadLocalConfig
;
import
com.system.constants.Constants
;
import
com.system.constants.KingDeeConstants
;
import
com.system.constants.KingDeeConstants
;
import
com.system.serializer.SerializerProxy
;
import
com.system.serializer.SerializerProxy
;
import
com.system.utils.HttpUtil
;
import
com.system.utils.JsonUtil
;
import
com.system.utils.JsonUtil
;
import
com.system.utils.StringUtil
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
...
@@ -51,7 +52,7 @@ public class KingDeeApiClient {
...
@@ -51,7 +52,7 @@ public class KingDeeApiClient {
System
.
out
.
println
(
"------------>"
+
url
);
System
.
out
.
println
(
"------------>"
+
url
);
long
start
=
System
.
currentTimeMillis
();
long
start
=
System
.
currentTimeMillis
();
ResponseEntity
<
String
>
responseEntity
=
KingDeeHttpApi
.
httpPost
(
url
,
header
,
JsonUtil
.
toString
(
request
));
ResponseEntity
<
String
>
responseEntity
=
HttpUtil
.
httpPost
(
url
,
header
,
JsonUtil
.
toString
(
request
));
long
costTime
=
System
.
currentTimeMillis
()
-
start
;
long
costTime
=
System
.
currentTimeMillis
()
-
start
;
Map
<
String
,
Object
>
map
=
ThreadLocalConfig
.
get
();
Map
<
String
,
Object
>
map
=
ThreadLocalConfig
.
get
();
...
@@ -68,13 +69,13 @@ public class KingDeeApiClient {
...
@@ -68,13 +69,13 @@ public class KingDeeApiClient {
request
.
put
(
"parameters"
,
new
Object
[]{
dbId
,
userName
,
password
,
lcid
});
request
.
put
(
"parameters"
,
new
Object
[]{
dbId
,
userName
,
password
,
lcid
});
String
url
=
serverUrl
+
"Kingdee.BOS.WebApi.ServicesStub.AuthService.ValidateUser"
+
HTTP_SUFFIX
;
String
url
=
serverUrl
+
"Kingdee.BOS.WebApi.ServicesStub.AuthService.ValidateUser"
+
HTTP_SUFFIX
;
ResponseEntity
<
String
>
responseEntity
=
KingDeeHttpApi
.
httpPost
(
url
,
JsonUtil
.
toString
(
request
));
ResponseEntity
<
String
>
responseEntity
=
HttpUtil
.
httpPost
(
url
,
JsonUtil
.
toString
(
request
));
System
.
out
.
println
(
responseEntity
.
getBody
());
System
.
out
.
println
(
responseEntity
.
getBody
());
if
(
responseEntity
.
getStatusCode
()
==
HttpStatus
.
OK
)
{
if
(
responseEntity
.
getStatusCode
()
==
HttpStatus
.
OK
)
{
String
cookieStore
=
this
.
getCookieStore
(
responseEntity
);
Map
<
String
,
Object
>
map
=
JsonUtil
.
toMap
(
responseEntity
.
getBody
(),
String
.
class
,
Object
.
class
);
if
(
StringUtil
.
isNotBlank
(
cookieStore
))
{
if
(
!
CollectionUtils
.
isEmpty
(
map
)
&&
Constants
.
ONE
.
equals
(
String
.
valueOf
(
map
.
get
(
KingDeeConstants
.
LOGIN_RESULT_TYPE
))
))
{
this
.
cookieStore
=
cookieStore
;
this
.
cookieStore
=
this
.
getCookieStore
(
responseEntity
)
;
return
true
;
return
true
;
}
else
{
}
else
{
return
false
;
return
false
;
...
...
semiconductor-system/src/main/java/com/system/constants/Constants.java
浏览文件 @
2c7c186e
...
@@ -5,6 +5,9 @@ package com.system.constants;
...
@@ -5,6 +5,9 @@ package com.system.constants;
*/
*/
public
interface
Constants
{
public
interface
Constants
{
String
ONE
=
"1"
;
String
TIME_FORMAT
=
"yyyy-MM-dd HH:mm:ss"
;
String
TIME_FORMAT
=
"yyyy-MM-dd HH:mm:ss"
;
...
@@ -23,5 +26,4 @@ public interface Constants {
...
@@ -23,5 +26,4 @@ public interface Constants {
String
DATA_NAME
=
"data"
;
String
DATA_NAME
=
"data"
;
}
}
semiconductor-system/src/main/java/com/system/constants/KingDeeConstants.java
浏览文件 @
2c7c186e
...
@@ -11,6 +11,9 @@ public interface KingDeeConstants {
...
@@ -11,6 +11,9 @@ public interface KingDeeConstants {
String
KING_DEE_SESSION_NAME
=
"kdservice-sessionid"
;
String
KING_DEE_SESSION_NAME
=
"kdservice-sessionid"
;
String
LOGIN_RESULT_TYPE
=
"LoginResultType"
;
String
CODE_NAME
=
"resultCode"
;
String
CODE_NAME
=
"resultCode"
;
...
...
semiconductor-system/src/main/java/com/system/scheduler/LicScheduler.java
浏览文件 @
2c7c186e
...
@@ -97,7 +97,7 @@ public class LicScheduler {
...
@@ -97,7 +97,7 @@ public class LicScheduler {
Map
<
String
,
Object
>
map
=
new
HashMap
<>(
1
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>(
1
);
map
.
put
(
"data"
,
RsaUtil
.
encryptByPublicKeyToLong
(
JsonUtil
.
toString
(
request
),
publicKey
));
map
.
put
(
"data"
,
RsaUtil
.
encryptByPublicKeyToLong
(
JsonUtil
.
toString
(
request
),
publicKey
));
String
result
=
Http
ClientUtil
.
sendPost
(
"http://192.168.0.37:8090/lic/api/lic/online/verification"
,
JsonUtil
.
toString
(
map
)
);
String
result
=
Http
Util
.
httpPost
(
"http://192.168.0.37:8090/lic/api/lic/online/verification"
,
JsonUtil
.
toString
(
map
)).
getBody
(
);
Map
<
String
,
Object
>
temp
=
JsonUtil
.
toMap
(
RsaUtil
.
decryptByPublicKeyToLong
(
result
,
publicKey
),
String
.
class
,
Object
.
class
);
Map
<
String
,
Object
>
temp
=
JsonUtil
.
toMap
(
RsaUtil
.
decryptByPublicKeyToLong
(
result
,
publicKey
),
String
.
class
,
Object
.
class
);
if
(!
CollectionUtils
.
isEmpty
(
temp
))
{
if
(!
CollectionUtils
.
isEmpty
(
temp
))
{
...
...
semiconductor-system/src/main/java/com/system/
api/KingDeeHttpApi
.java
→
semiconductor-system/src/main/java/com/system/
utils/HttpUtil
.java
浏览文件 @
2c7c186e
package
com
.
system
.
api
;
package
com
.
system
.
utils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpMethod
;
import
org.springframework.http.HttpMethod
;
...
@@ -14,7 +16,9 @@ import java.util.Set;
...
@@ -14,7 +16,9 @@ import java.util.Set;
/**
/**
* @author Inori
* @author Inori
*/
*/
public
class
KingDeeHttpApi
{
public
class
HttpUtil
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
HttpUtil
.
class
);
/**
/**
* 连接超时时间
* 连接超时时间
...
@@ -41,27 +45,6 @@ public class KingDeeHttpApi {
...
@@ -41,27 +45,6 @@ public class KingDeeHttpApi {
}
}
/**
/**
* 发送Post请求
*/
public
static
ResponseEntity
<
String
>
httpPost
(
String
url
,
String
json
)
{
//初始化header公共参数
HttpHeaders
httpHeaders
=
initHeader
();
//发送请求
return
toPost
(
url
,
httpHeaders
,
json
);
}
/**
* 发送Post请求
*/
public
static
ResponseEntity
<
String
>
httpPost
(
String
url
,
Map
<
String
,
Object
>
header
,
String
json
)
{
//初始化header公共参数
HttpHeaders
httpHeaders
=
initHeader
();
setHeaderParam
(
httpHeaders
,
header
);
//发送请求
return
toPost
(
url
,
httpHeaders
,
json
);
}
/**
* 设置header公共参数
* 设置header公共参数
*/
*/
private
static
HttpHeaders
initHeader
()
{
private
static
HttpHeaders
initHeader
()
{
...
@@ -86,6 +69,81 @@ public class KingDeeHttpApi {
...
@@ -86,6 +69,81 @@ public class KingDeeHttpApi {
}
}
/**
/**
* 发送Get请求
*/
public
static
ResponseEntity
<
String
>
httpGet
(
String
url
)
{
//初始化header公共参数
HttpHeaders
httpHeaders
=
initHeader
();
//发送请求
HttpEntity
<
String
>
httpEntity
=
new
HttpEntity
<>(
null
,
httpHeaders
);
return
restTemplate
.
exchange
(
url
,
HttpMethod
.
GET
,
httpEntity
,
String
.
class
);
}
/**
* 发送Get请求
*/
public
static
ResponseEntity
<
String
>
httpGet
(
String
url
,
Map
<
String
,
Object
>
param
)
{
//初始化header公共参数
HttpHeaders
httpHeaders
=
initHeader
();
//组装查询参数
url
=
setParam
(
url
,
param
);
//发送请求
HttpEntity
<
String
>
httpEntity
=
new
HttpEntity
<>(
null
,
httpHeaders
);
log
.
info
(
"【Get请求】Url: {}"
,
url
);
return
restTemplate
.
exchange
(
url
,
HttpMethod
.
GET
,
httpEntity
,
String
.
class
);
}
private
static
String
setParam
(
String
url
,
Map
<
String
,
Object
>
param
)
{
Set
<
String
>
keys
=
param
.
keySet
();
StringBuilder
builder
=
new
StringBuilder
();
builder
.
append
(
"?"
);
for
(
String
key
:
keys
)
{
builder
.
append
(
key
).
append
(
"="
).
append
(
param
.
get
(
key
)).
append
(
"&"
);
}
builder
.
deleteCharAt
(
builder
.
lastIndexOf
(
"&"
));
url
=
url
+
builder
.
toString
();
return
url
;
}
/**
* 发送Get请求
*/
public
static
ResponseEntity
<
String
>
httpGet
(
String
url
,
Map
<
String
,
Object
>
headers
,
Map
<
String
,
Object
>
param
)
{
//如果查询参数为空,则调用不带参数的Get请求
if
(
CollectionUtils
.
isEmpty
(
param
))
{
return
httpGet
(
url
,
headers
);
}
//组装查询参数
url
=
setParam
(
url
,
param
);
//发送请求
log
.
info
(
"【Get请求】Url: {}"
,
url
);
return
httpGet
(
url
,
headers
);
}
/**
* 发送Post请求
*/
public
static
ResponseEntity
<
String
>
httpPost
(
String
url
,
String
json
)
{
//初始化header公共参数
HttpHeaders
httpHeaders
=
initHeader
();
//发送请求
log
.
info
(
"【Post请求】Url: {}"
,
url
);
return
toPost
(
url
,
httpHeaders
,
json
);
}
/**
* 发送Post请求
*/
public
static
ResponseEntity
<
String
>
httpPost
(
String
url
,
Map
<
String
,
Object
>
header
,
String
json
)
{
//初始化header公共参数
HttpHeaders
httpHeaders
=
initHeader
();
setHeaderParam
(
httpHeaders
,
header
);
//发送请求
log
.
info
(
"【Post请求】Url: {}"
,
url
);
return
toPost
(
url
,
httpHeaders
,
json
);
}
/**
* 发送请求
* 发送请求
*/
*/
private
static
ResponseEntity
<
String
>
toPost
(
String
url
,
HttpHeaders
httpHeaders
,
String
json
)
{
private
static
ResponseEntity
<
String
>
toPost
(
String
url
,
HttpHeaders
httpHeaders
,
String
json
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论