Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
项目统一框架
amos-boot-biz
Commits
c863c6fd
Commit
c863c6fd
authored
Dec 12, 2025
by
suhuiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(statis):性能
1.大屏接口优化
parent
0ec38bc0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
11 deletions
+27
-11
ElasticSearchClientConfig.java
...odule/statistcs/biz/config/ElasticSearchClientConfig.java
+3
-1
RestTemplateConfig.java
.../boot/module/statistcs/biz/config/RestTemplateConfig.java
+18
-4
DPSubServiceImpl.java
...t/module/statistcs/biz/service/impl/DPSubServiceImpl.java
+6
-6
No files found.
amos-boot-system-tzs/amos-boot-module-statistics/amos-boot-module-statistics-biz/src/main/java/com/yeejoin/amos/boot/module/statistcs/biz/config/ElasticSearchClientConfig.java
View file @
c863c6fd
...
...
@@ -36,7 +36,9 @@ public class ElasticSearchClientConfig {
RestClientBuilder
builder
=
RestClient
.
builder
(
httpHosts
);
builder
.
setHttpClientConfigCallback
(
httpClientBuilder
->
{
httpClientBuilder
.
disableAuthCaching
();
return
httpClientBuilder
.
setDefaultCredentialsProvider
(
credentialsProvider
);
return
httpClientBuilder
.
setDefaultCredentialsProvider
(
credentialsProvider
)
.
setMaxConnTotal
(
200
)
.
setMaxConnPerRoute
(
60
);
});
// 该方法接收一个RequestConfig.Builder对象,对该对象进行修改后然后返回。
builder
.
setRequestConfigCallback
(
requestConfigBuilder
->
{
...
...
amos-boot-system-tzs/amos-boot-module-statistics/amos-boot-module-statistics-biz/src/main/java/com/yeejoin/amos/boot/module/statistcs/biz/config/RestTemplateConfig.java
View file @
c863c6fd
package
com
.
yeejoin
.
amos
.
boot
.
module
.
statistcs
.
biz
.
config
;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
org.apache.http.impl.client.HttpClients
;
import
org.apache.http.impl.conn.PoolingHttpClientConnectionManager
;
import
org.springframework.cloud.client.loadbalancer.LoadBalanced
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.http.client.HttpComponentsClientHttpRequestFactory
;
import
org.springframework.web.client.RestTemplate
;
/**
...
...
@@ -15,7 +19,18 @@ public class RestTemplateConfig {
@Bean
@LoadBalanced
public
RestTemplate
getRestTemplate
()
{
return
new
RestTemplate
();
public
RestTemplate
loadBalancedRestTemplate
()
{
PoolingHttpClientConnectionManager
manager
=
new
PoolingHttpClientConnectionManager
();
manager
.
setMaxTotal
(
200
);
manager
.
setDefaultMaxPerRoute
(
50
);
CloseableHttpClient
httpClient
=
HttpClients
.
custom
()
.
setConnectionManager
(
manager
)
.
build
();
// 2. 创建自定义工厂(最终会被 InterceptingClientHttpRequestFactory 包装)
HttpComponentsClientHttpRequestFactory
factory
=
new
HttpComponentsClientHttpRequestFactory
(
httpClient
);
factory
.
setConnectTimeout
(
5000
);
factory
.
setReadTimeout
(
60000
);
return
new
RestTemplate
(
factory
);
}
}
\ No newline at end of file
}
amos-boot-system-tzs/amos-boot-module-statistics/amos-boot-module-statistics-biz/src/main/java/com/yeejoin/amos/boot/module/statistcs/biz/service/impl/DPSubServiceImpl.java
View file @
c863c6fd
...
...
@@ -54,8 +54,7 @@ public class DPSubServiceImpl {
private
static
final
String
GATEWAY_SERVER_NAME
=
"AMOS-SERVER-GATEWAY"
;
@Autowired
@LoadBalanced
private
RestTemplate
restTemplate
;
private
RestTemplate
loadBalancedRestTemplate
;
@Autowired
DataDictionaryServiceImpl
iDataDictionaryService
;
...
...
@@ -857,6 +856,7 @@ public class DPSubServiceImpl {
}
public
ResponseModel
getApiResult
(
JSONObject
apiObj
,
String
resultConvert
,
JSONObject
detailResult
)
{
log
.
info
(
"restTemplate 请求的客户端是:{}"
,
loadBalancedRestTemplate
.
getRequestFactory
().
getClass
());;
String
url
=
apiObj
.
getString
(
"apiPath"
);
if
(
ValidationUtil
.
isEmpty
(
url
)){
return
null
;
...
...
@@ -893,19 +893,19 @@ public class DPSubServiceImpl {
URI
reqUri
=
new
URI
(
reqUrl
);
if
(
StringUtils
.
contrastLowerStr
(
"GET"
,
reqType
))
{
responseEntity
=
reqUrl
.
contains
(
GATEWAY_SERVER_NAME
)
?
RestTemplateUtils
.
get
(
r
estTemplate
,
reqUri
,
httpHeaders
,
body
,
String
.
class
,
new
HashMap
<>())
?
RestTemplateUtils
.
get
(
loadBalancedR
estTemplate
,
reqUri
,
httpHeaders
,
body
,
String
.
class
,
new
HashMap
<>())
:
RestTemplateUtils
.
get
(
reqUri
,
httpHeaders
,
body
,
String
.
class
,
new
HashMap
<>());
}
else
if
(
StringUtils
.
contrastLowerStr
(
"POST"
,
reqType
))
{
responseEntity
=
reqUrl
.
contains
(
GATEWAY_SERVER_NAME
)
?
RestTemplateUtils
.
post
(
r
estTemplate
,
reqUri
,
httpHeaders
,
body
,
String
.
class
,
new
HashMap
<>())
?
RestTemplateUtils
.
post
(
loadBalancedR
estTemplate
,
reqUri
,
httpHeaders
,
body
,
String
.
class
,
new
HashMap
<>())
:
RestTemplateUtils
.
post
(
reqUri
,
httpHeaders
,
body
,
String
.
class
,
new
HashMap
<>());
}
else
if
(
StringUtils
.
contrastLowerStr
(
"PUT"
,
reqType
))
{
responseEntity
=
reqUrl
.
contains
(
GATEWAY_SERVER_NAME
)
?
RestTemplateUtils
.
put
(
r
estTemplate
,
reqUri
,
httpHeaders
,
body
,
String
.
class
)
?
RestTemplateUtils
.
put
(
loadBalancedR
estTemplate
,
reqUri
,
httpHeaders
,
body
,
String
.
class
)
:
RestTemplateUtils
.
put
(
reqUri
,
httpHeaders
,
body
,
String
.
class
);
}
else
if
(
StringUtils
.
contrastLowerStr
(
"DELETE"
,
reqType
))
{
responseEntity
=
reqUrl
.
contains
(
GATEWAY_SERVER_NAME
)
?
RestTemplateUtils
.
delete
(
r
estTemplate
,
reqUri
,
httpHeaders
,
body
,
String
.
class
)
?
RestTemplateUtils
.
delete
(
loadBalancedR
estTemplate
,
reqUri
,
httpHeaders
,
body
,
String
.
class
)
:
RestTemplateUtils
.
delete
(
reqUri
,
httpHeaders
,
body
,
String
.
class
);
}
}
catch
(
Exception
e
)
{
...
...
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