Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
S
SoSsDome
Project
Project
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
Graph
比较
统计图
议题
0
议题
0
列表
看板
标记
Milestones
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
李炎
SoSsDome
Commits
23110049
提交
23110049
authored
12月 27, 2021
作者:
李炎
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
加速http
上级
4f1ebad1
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
287 行增加
和
50 行删除
+287
-50
pom.xml
pom.xml
+25
-12
WebApi.java
src/main/java/com/santos/iost/controller/WebApi.java
+1
-17
SoSsDao.java
src/main/java/com/santos/iost/dao/SoSsDao.java
+16
-11
HttpClientUtil.java
src/main/java/com/santos/iost/utils/HttpClientUtil.java
+237
-0
JintaiDomeApplicationTests.java
...test/java/com/santos/iost/JintaiDomeApplicationTests.java
+8
-10
没有找到文件。
pom.xml
浏览文件 @
23110049
...
@@ -74,13 +74,13 @@
...
@@ -74,13 +74,13 @@
</dependency>
</dependency>
<
dependency
>
<
!--<dependency>--
>
<
groupId>
client
</groupId
>
<
!--<groupId>client</groupId>--
>
<
artifactId>
k3cloud-webapi-client
</artifactId
>
<
!--<artifactId>k3cloud-webapi-client</artifactId>--
>
<
scope>
system
</scope
>
<
!--<scope>system</scope>--
>
<
version>
1.0
</version
>
<
!--<version>1.0</version>--
>
<
systemPath>
${project.basedir}/src/main/resources/lib/k3cloud-webapi-client.jar
</systemPath
>
<
!--<systemPath>${project.basedir}/src/main/resources/lib/k3cloud-webapi-client.jar</systemPath>--
>
<
/dependency
>
<
!--</dependency>--
>
<!--<dependency>-->
<!--<dependency>-->
<!--<groupId>httpmime</groupId>-->
<!--<groupId>httpmime</groupId>-->
...
@@ -89,11 +89,12 @@
...
@@ -89,11 +89,12 @@
<!--<version>1.0</version>-->
<!--<version>1.0</version>-->
<!--<systemPath>${project.basedir}/src/main/resources/lib/httpmime-4.1.1.jar</systemPath>-->
<!--<systemPath>${project.basedir}/src/main/resources/lib/httpmime-4.1.1.jar</systemPath>-->
<!--</dependency>-->
<!--</dependency>-->
<dependency>
<!--<dependency>-->
<groupId>
org.apache.httpcomponents
</groupId>
<!--<groupId>org.apache.httpcomponents</groupId>-->
<artifactId>
httpmime
</artifactId>
<!--<artifactId>httpmime</artifactId>-->
<version>
4.1.1
</version>
<!--<version>4.1.1</version>-->
</dependency>
<!--</dependency>-->
<!--<dependency>-->
<!--<dependency>-->
<!--<groupId>commons-httpclient</groupId>-->
<!--<groupId>commons-httpclient</groupId>-->
...
@@ -114,6 +115,18 @@
...
@@ -114,6 +115,18 @@
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpmime
</artifactId>
<version>
4.5.2
</version>
</dependency>
<dependency>
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpasyncclient
</artifactId>
<version>
4.1.4
</version>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<groupId>
com.alibaba
</groupId>
<artifactId>
fastjson
</artifactId>
<artifactId>
fastjson
</artifactId>
<version>
1.2.72
</version>
<version>
1.2.72
</version>
...
...
src/main/java/com/santos/iost/controller/WebApi.java
浏览文件 @
23110049
...
@@ -143,21 +143,5 @@ public class WebApi {
...
@@ -143,21 +143,5 @@ public class WebApi {
}
}
ConnectionKeepAliveStrategy
myStrategy
=
new
ConnectionKeepAliveStrategy
()
{
@Override
public
long
getKeepAliveDuration
(
HttpResponse
response
,
HttpContext
context
)
{
HeaderElementIterator
it
=
new
BasicHeaderElementIterator
(
response
.
headerIterator
(
HTTP
.
CONN_KEEP_ALIVE
));
while
(
it
.
hasNext
())
{
HeaderElement
he
=
it
.
nextElement
();
String
param
=
he
.
getName
();
String
value
=
he
.
getValue
();
if
(
value
!=
null
&&
param
.
equalsIgnoreCase
(
"timeout"
))
{
return
Long
.
parseLong
(
value
)
*
1000
;
}
}
return
60
*
1000
;
//如果没有约定,则默认定义时长为60s
}
};
}
}
src/main/java/com/santos/iost/dao/SoSsDao.java
浏览文件 @
23110049
package
com
.
santos
.
iost
.
dao
;
package
com
.
santos
.
iost
.
dao
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.santos.iost.utils.HttpClientUtil
;
import
com.santos.iost.utils.HttpUtil
;
import
com.santos.iost.utils.HttpUtil
;
import
com.santos.iost.utils.JsonUtil
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.PostConstruct
;
import
javax.annotation.PostConstruct
;
...
@@ -34,26 +36,29 @@ public class SoSsDao {
...
@@ -34,26 +36,29 @@ public class SoSsDao {
//请求主体
//请求主体
public
String
requestK3Api
(
String
getMaterialUrl
,
String
paramsMap
)
throws
Exception
{
public
String
requestK3Api
(
String
getMaterialUrl
,
String
paramsMap
)
throws
Exception
{
System
.
out
.
println
(
"====head====="
+
paramsMap
+
"====head===="
);
System
.
out
.
println
(
"====head====="
+
paramsMap
+
"====head===="
);
String
post
=
HttpUtil
.
post
(
requestUrl
+
getMaterialUrl
+
"?token="
+
token
,
paramsMap
,
hreader
);
// String post = HttpUtil.post(requestUrl + getMaterialUrl + "?token=" + token, paramsMap, hreader);//以弃用
String
post
=
HttpClientUtil
.
doPostJson
(
requestUrl
+
getMaterialUrl
+
"?token="
+
token
,
paramsMap
);
System
.
out
.
println
(
token
);
System
.
out
.
println
(
token
);
// System.out.println("================response=============="+post+"=================response===================");
// System.out.println("================response=============="+post+"=================response===================");
return
post
;
return
post
;
}
}
//请求主体
public
String
requestK3ApiDetail
(
String
getMaterialUrl
,
String
paramsMap
)
throws
Exception
{
System
.
out
.
println
(
"====Detail====="
+
paramsMap
+
"====Detail===="
);
// String post = HttpUtil.post(requestUrl + getMaterialUrl + "?token=" + token, paramsMap, hreader);
String
post
=
HttpClientUtil
.
doPostJson
(
requestUrl
+
getMaterialUrl
+
"?token="
+
token
,
paramsMap
);
// System.out.println(token);
// System.out.println("================response=============="+post+"=================response===================");
return
post
;
}
//
public
String
setK3Api
(
String
getMaterialUrl
,
String
paramsMap
)
throws
Exception
{
public
String
setK3Api
(
String
getMaterialUrl
,
String
paramsMap
)
throws
Exception
{
System
.
out
.
println
(
"====head====="
+
paramsMap
+
"====head===="
);
System
.
out
.
println
(
"====head====="
+
paramsMap
+
"====head===="
);
String
post
=
Http
Util
.
post
(
requestUrl
+
getMaterialUrl
+
"?token="
+
token
,
paramsMap
,
hreader
);
String
post
=
Http
ClientUtil
.
doPostJson
(
requestUrl
+
getMaterialUrl
+
"?token="
+
token
,
paramsMap
);
System
.
out
.
println
(
token
);
System
.
out
.
println
(
token
);
// System.out.println("================response=============="+post+"=================response===================");
// System.out.println("================response=============="+post+"=================response===================");
return
post
;
return
post
;
}
}
//请求主体
public
String
requestK3ApiDetail
(
String
getMaterialUrl
,
String
paramsMap
)
throws
Exception
{
System
.
out
.
println
(
"====Detail====="
+
paramsMap
+
"====Detail===="
);
String
post
=
HttpUtil
.
post
(
requestUrl
+
getMaterialUrl
+
"?token="
+
token
,
paramsMap
,
hreader
);
// System.out.println(token);
// System.out.println("================response=============="+post+"=================response===================");
return
post
;
}
}
}
src/main/java/com/santos/iost/utils/HttpClientUtil.java
0 → 100644
浏览文件 @
23110049
差异被折叠。
点击展开。
src/test/java/com/santos/iost/JintaiDomeApplicationTests.java
浏览文件 @
23110049
...
@@ -8,17 +8,16 @@ import com.fasterxml.jackson.databind.ObjectMapper;
...
@@ -8,17 +8,16 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import
com.santos.iost.dao.SoSsDao
;
import
com.santos.iost.dao.SoSsDao
;
import
com.santos.iost.dto.SoSsRequestData
;
import
com.santos.iost.dto.SoSsRequestData
;
import
com.santos.iost.dto.SoSsResponseDate
;
import
com.santos.iost.dto.SoSsResponseDate
;
import
com.santos.iost.utils.HttpUtil
;
import
com.santos.iost.utils.*
;
import
com.santos.iost.utils.HttpUtils
;
import
com.santos.iost.utils.JsonUtil
;
import
com.santos.iost.utils.StringUtil
;
import
com.santos.iost.vo.SoSsRequestVo
;
import
com.santos.iost.vo.SoSsRequestVo
;
import
kingdee.bos.webapi.client.K3CloudApiClient
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
net.sf.json.JSONObject
;
import
net.sf.json.JSONObject
;
import
org.apache.http.HttpResponse
;
import
org.apache.http.auth.AuthScope
;
import
org.apache.http.auth.AuthScope
;
import
org.apache.http.auth.UsernamePasswordCredentials
;
import
org.apache.http.auth.UsernamePasswordCredentials
;
import
org.apache.http.client.ClientProtocolException
;
import
org.apache.http.client.CredentialsProvider
;
import
org.apache.http.client.CredentialsProvider
;
import
org.apache.http.client.ResponseHandler
;
import
org.apache.http.client.ResponseHandler
;
import
org.apache.http.client.config.RequestConfig
;
import
org.apache.http.client.config.RequestConfig
;
...
@@ -70,7 +69,7 @@ class JintaiDomeApplicationTests {
...
@@ -70,7 +69,7 @@ class JintaiDomeApplicationTests {
//
//
// Map<String, String> hreader = new HashMap<>();
// Map<String, String> hreader = new HashMap<>();
// hreader.put("Content-Type", "application/json");
// hreader.put("Content-Type", "application/json");
//
//
String post = HttpClientUtil.doPostJson(getGetMaterialUrl + token,JsonUtil.Mapjson(paramsMap));
// String post = HttpUtil.post(getGetMaterialUrl + token, JsonUtil.Mapjson(paramsMap), hreader);
// String post = HttpUtil.post(getGetMaterialUrl + token, JsonUtil.Mapjson(paramsMap), hreader);
// System.out.println(post);
// System.out.println(post);
}
}
...
@@ -116,13 +115,12 @@ class JintaiDomeApplicationTests {
...
@@ -116,13 +115,12 @@ class JintaiDomeApplicationTests {
@Test
@Test
void
asd
()
throws
Exception
{
void
asd
()
throws
Exception
{
// System.out.println(SoSsDao.token);
// System.out.println(StringUtil.isNumber("1473048265"));
// System.out.println(TimeStamp2Date("1609499999", "yyyy-MM-dd HH:mm:ss"));
// System.out.println(TimeStamp2Date("1609999999", "yyyy-MM-dd HH:mm:ss"));
}
}
public
static
String
TimeStamp2Date
(
String
timestampString
,
String
formats
)
{
public
static
String
TimeStamp2Date
(
String
timestampString
,
String
formats
)
{
// System.out.println(TimeStamp2Date("1609499999", "yyyy-MM-dd HH:mm:ss"));
// System.out.println(TimeStamp2Date("1609999999", "yyyy-MM-dd HH:mm:ss"));
if
(
TextUtils
.
isEmpty
(
formats
))
if
(
TextUtils
.
isEmpty
(
formats
))
formats
=
"yyyy-MM-dd HH:mm:ss"
;
formats
=
"yyyy-MM-dd HH:mm:ss"
;
Long
timestamp
=
Long
.
parseLong
(
timestampString
)
*
1000
;
Long
timestamp
=
Long
.
parseLong
(
timestampString
)
*
1000
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论