Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
ocrCloudPlatForm
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
ocr-cloud-platform
ocrCloudPlatForm
Commits
ae5e426e
Commit
ae5e426e
authored
Jul 03, 2024
by
黄明步
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增服务器资源总监控。修改文件下载方式为minio。
parent
f1c5a835
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
256 additions
and
25 deletions
+256
-25
pom.xml
+25
-8
src/main/java/com/gxmailu/ocrCloudPlatform/config/MinioConfig.java
+34
-0
src/main/java/com/gxmailu/ocrCloudPlatform/config/MinioProperties.java
+31
-0
src/main/java/com/gxmailu/ocrCloudPlatform/controller/RetransmissionController.java
+0
-4
src/main/java/com/gxmailu/ocrCloudPlatform/controller/StatController.java
+10
-0
src/main/java/com/gxmailu/ocrCloudPlatform/service/MinioService.java
+42
-0
src/main/java/com/gxmailu/ocrCloudPlatform/service/impl/RetransmissionService.java
+28
-9
src/main/java/com/gxmailu/ocrCloudPlatform/service/impl/StatService.java
+0
-0
src/main/resources/application-147prod.yml
+76
-0
src/main/resources/application-dev.yml
+10
-4
No files found.
pom.xml
View file @
ae5e426e
...
@@ -33,6 +33,11 @@
...
@@ -33,6 +33,11 @@
<type>
pom
</type>
<type>
pom
</type>
<scope>
import
</scope>
<scope>
import
</scope>
</dependency>
</dependency>
<dependency>
<groupId>
com.squareup.okhttp3
</groupId>
<artifactId>
okhttp
</artifactId>
<version>
4.12.0
</version>
</dependency>
</dependencies>
</dependencies>
</dependencyManagement>
</dependencyManagement>
<dependencies>
<dependencies>
...
@@ -91,13 +96,7 @@
...
@@ -91,13 +96,7 @@
<artifactId>
spring-boot-starter-test
</artifactId>
<artifactId>
spring-boot-starter-test
</artifactId>
<scope>
test
</scope>
<scope>
test
</scope>
</dependency>
</dependency>
<!-- <!– https://mvnrepository.com/artifact/org.mybatis.generator/mybatis-generator-maven-plugin –>
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.4.2</version>
</dependency>-->
<!-- https://mvnrepository.com/artifact/cn.hutool/hutool-all -->
<dependency>
<dependency>
<groupId>
cn.hutool
</groupId>
<groupId>
cn.hutool
</groupId>
<artifactId>
hutool-all
</artifactId>
<artifactId>
hutool-all
</artifactId>
...
@@ -201,7 +200,25 @@
...
@@ -201,7 +200,25 @@
<dependency>
<dependency>
<groupId>
com.squareup.okhttp3
</groupId>
<groupId>
com.squareup.okhttp3
</groupId>
<artifactId>
okhttp
</artifactId>
<artifactId>
okhttp
</artifactId>
<version>
3.10.0
</version>
<version>
4.12.0
</version>
</dependency>
<dependency>
<groupId>
io.minio
</groupId>
<artifactId>
minio
</artifactId>
<version>
8.5.2
</version>
<exclusions>
<exclusion>
<artifactId>
kotlin-stdlib-common
</artifactId>
<groupId>
org.jetbrains.kotlin
</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>
org.jetbrains.kotlin
</groupId>
<artifactId>
kotlin-stdlib
</artifactId>
<version>
1.3.70
</version>
<scope>
compile
</scope>
</dependency>
</dependency>
</dependencies>
</dependencies>
...
...
src/main/java/com/gxmailu/ocrCloudPlatform/config/MinioConfig.java
0 → 100644
View file @
ae5e426e
package
com
.
gxmailu
.
ocrCloudPlatform
.
config
;
import
io.minio.MinioClient
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* @author Hmb
* @version 1.0.0
* @since 2024/7/2 22:36:53
*/
@Configuration
public
class
MinioConfig
{
@Autowired
private
MinioProperties
minioProperties
;
@Bean
public
Map
<
String
,
MinioClient
>
minioClients
()
{
Map
<
String
,
MinioClient
>
clients
=
new
HashMap
<>();
for
(
MinioProperties
.
MinioClientConfig
config
:
minioProperties
.
getClients
())
{
MinioClient
client
=
MinioClient
.
builder
()
.
endpoint
(
config
.
getEndpoint
())
.
credentials
(
config
.
getAccessKey
(),
config
.
getSecretKey
())
.
build
();
clients
.
put
(
config
.
getName
(),
client
);
}
return
clients
;
}
}
src/main/java/com/gxmailu/ocrCloudPlatform/config/MinioProperties.java
0 → 100644
View file @
ae5e426e
package
com
.
gxmailu
.
ocrCloudPlatform
.
config
;
import
lombok.*
;
import
org.checkerframework.checker.units.qual.A
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.context.annotation.Configuration
;
import
java.util.List
;
/**
* @author Hmb
* @version 1.0.0
* @since 2024/7/2 22:34:28
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Configuration
@ConfigurationProperties
(
prefix
=
"minio"
)
public
class
MinioProperties
{
private
List
<
MinioClientConfig
>
clients
;
@Data
public
static
class
MinioClientConfig
{
private
String
name
;
private
String
endpoint
;
private
String
accessKey
;
private
String
secretKey
;
}
}
src/main/java/com/gxmailu/ocrCloudPlatform/controller/RetransmissionController.java
View file @
ae5e426e
...
@@ -47,25 +47,21 @@ public class RetransmissionController {
...
@@ -47,25 +47,21 @@ public class RetransmissionController {
@PostMapping
(
"/ofs/api/sync/v1/pdf"
)
@PostMapping
(
"/ofs/api/sync/v1/pdf"
)
public
void
downloadDoubleDeckPdf
(
@RequestBody
JSONObject
body
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
public
void
downloadDoubleDeckPdf
(
@RequestBody
JSONObject
body
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
// retransmissionService.downloadDoubleDeckPdf(body, request, response);
retransmissionService
.
downloadPdfNew
(
body
,
response
);
retransmissionService
.
downloadPdfNew
(
body
,
response
);
}
}
@PostMapping
(
"/ofs/api/sync/v1/ft/pdf"
)
@PostMapping
(
"/ofs/api/sync/v1/ft/pdf"
)
public
void
downloadDoubleDeckPdfByFt
(
@RequestBody
JSONObject
body
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
public
void
downloadDoubleDeckPdfByFt
(
@RequestBody
JSONObject
body
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
// retransmissionService.downloadDoubleDeckPdf(body, request, response);
retransmissionService
.
downloadPdfNew
(
body
,
response
);
retransmissionService
.
downloadPdfNew
(
body
,
response
);
}
}
@PostMapping
(
"/ofs/api/sync/v1/ofd"
)
@PostMapping
(
"/ofs/api/sync/v1/ofd"
)
public
void
downloadDoubleDeckOfd
(
@RequestBody
JSONObject
body
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
public
void
downloadDoubleDeckOfd
(
@RequestBody
JSONObject
body
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
// retransmissionService.downloadDoubleDeckOfd(body, request, response);
retransmissionService
.
downloadOfdNew
(
body
,
response
);
retransmissionService
.
downloadOfdNew
(
body
,
response
);
}
}
@PostMapping
(
"/ofs/api/sync/v1/ft/ofd"
)
@PostMapping
(
"/ofs/api/sync/v1/ft/ofd"
)
public
void
downloadDoubleDeckOfdByFt
(
@RequestBody
JSONObject
body
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
public
void
downloadDoubleDeckOfdByFt
(
@RequestBody
JSONObject
body
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
// retransmissionService.downloadDoubleDeckOfd(body, request, response);
retransmissionService
.
downloadOfdNew
(
body
,
response
);
retransmissionService
.
downloadOfdNew
(
body
,
response
);
}
}
...
...
src/main/java/com/gxmailu/ocrCloudPlatform/controller/StatController.java
View file @
ae5e426e
...
@@ -53,4 +53,14 @@ public class StatController {
...
@@ -53,4 +53,14 @@ public class StatController {
public
Result
getServerMonitoring
(
@RequestParam
(
value
=
"time"
,
required
=
false
)
Long
time
)
{
public
Result
getServerMonitoring
(
@RequestParam
(
value
=
"time"
,
required
=
false
)
Long
time
)
{
return
statService
.
getServerMonitoring
(
time
);
return
statService
.
getServerMonitoring
(
time
);
}
}
@ApiOperation
(
value
=
"获取服务器监控总数据"
)
@ApiImplicitParams
(
value
=
{
@ApiImplicitParam
(
name
=
"time"
,
value
=
"秒级别的时间戳,不传该值则默认当前时刻"
,
dataType
=
"Long"
)
})
@GetMapping
(
"/getAllMonitoring"
)
public
Result
getAllMonitoring
(
@RequestParam
(
value
=
"time"
,
required
=
false
)
Long
time
)
{
return
statService
.
getAllMonitoring
(
time
);
}
}
}
src/main/java/com/gxmailu/ocrCloudPlatform/service/MinioService.java
0 → 100644
View file @
ae5e426e
package
com
.
gxmailu
.
ocrCloudPlatform
.
service
;
import
io.minio.GetObjectArgs
;
import
io.minio.MinioClient
;
import
io.minio.errors.MinioException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.security.InvalidKeyException
;
import
java.security.NoSuchAlgorithmException
;
import
java.util.Map
;
/**
* @author Hmb
* @version 1.0.0
* @since 2024/7/2 22:39:18
*/
@Service
public
class
MinioService
{
private
final
Map
<
String
,
MinioClient
>
minioClients
;
@Autowired
public
MinioService
(
Map
<
String
,
MinioClient
>
minioClients
)
{
this
.
minioClients
=
minioClients
;
}
public
InputStream
downloadFile
(
String
clientName
,
String
bucketName
,
String
objectName
)
throws
MinioException
,
IOException
,
NoSuchAlgorithmException
,
InvalidKeyException
{
MinioClient
minioClient
=
minioClients
.
get
(
clientName
);
if
(
minioClient
==
null
)
{
throw
new
IllegalArgumentException
(
"未知的Minio客户端: "
+
clientName
);
}
return
minioClient
.
getObject
(
GetObjectArgs
.
builder
()
.
bucket
(
bucketName
)
.
object
(
objectName
)
.
build
());
}
}
src/main/java/com/gxmailu/ocrCloudPlatform/service/impl/RetransmissionService.java
View file @
ae5e426e
...
@@ -24,8 +24,10 @@ import com.gxmailu.ocrCloudPlatform.entity.AppAbilityRecordAll;
...
@@ -24,8 +24,10 @@ import com.gxmailu.ocrCloudPlatform.entity.AppAbilityRecordAll;
import
com.gxmailu.ocrCloudPlatform.entity.ServerInfo
;
import
com.gxmailu.ocrCloudPlatform.entity.ServerInfo
;
import
com.gxmailu.ocrCloudPlatform.entity.TmpRecordByTrigger
;
import
com.gxmailu.ocrCloudPlatform.entity.TmpRecordByTrigger
;
import
com.gxmailu.ocrCloudPlatform.mapper.*
;
import
com.gxmailu.ocrCloudPlatform.mapper.*
;
import
com.gxmailu.ocrCloudPlatform.service.MinioService
;
import
com.gxmailu.ocrCloudPlatform.service.ServerInfoService
;
import
com.gxmailu.ocrCloudPlatform.service.ServerInfoService
;
import
com.gxmailu.ocrCloudPlatform.vo.OcrResult
;
import
com.gxmailu.ocrCloudPlatform.vo.OcrResult
;
import
io.minio.errors.MinioException
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -40,6 +42,7 @@ import javax.servlet.http.HttpServletRequest;
...
@@ -40,6 +42,7 @@ import javax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.File
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.io.OutputStream
;
import
java.util.*
;
import
java.util.*
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
...
@@ -89,6 +92,9 @@ public class RetransmissionService {
...
@@ -89,6 +92,9 @@ public class RetransmissionService {
@Autowired
@Autowired
private
ElasticSearchService
elasticSearchService
;
private
ElasticSearchService
elasticSearchService
;
@Autowired
private
MinioService
minioService
;
@Value
(
"${temp.dir}"
)
@Value
(
"${temp.dir}"
)
private
String
tempDir
;
private
String
tempDir
;
...
@@ -449,12 +455,20 @@ public class RetransmissionService {
...
@@ -449,12 +455,20 @@ public class RetransmissionService {
String
serverIp
=
appAbilityRecordAll
.
getServerIp
();
String
serverIp
=
appAbilityRecordAll
.
getServerIp
();
String
dstUrl
=
appAbilityRecordAll
.
getDstUrl
();
String
dstUrl
=
appAbilityRecordAll
.
getDstUrl
();
String
objName
=
appAbilityRecordAll
.
getPdf
();
String
objName
=
appAbilityRecordAll
.
getPdf
();
String
fileUrl
=
StrUtil
.
format
(
"http://{}:9000/{}/{}"
,
serverIp
,
dstUrl
,
objName
);
byte
[]
bytes
=
HttpUtil
.
downloadBytes
(
fileUrl
);
try
(
OutputStream
outputStream
=
response
.
getOutputStream
())
{
try
(
InputStream
inputStream
=
minioService
.
downloadFile
(
serverIp
,
dstUrl
,
objName
);
outputStream
.
write
(
bytes
);
OutputStream
outputStream
=
response
.
getOutputStream
())
{
response
.
setContentType
(
"application/octet-stream"
);
response
.
setHeader
(
"Content-Disposition"
,
"attachment; filename="
+
objName
);
byte
[]
buffer
=
new
byte
[
8192
];
int
bytesRead
;
while
((
bytesRead
=
inputStream
.
read
(
buffer
))
!=
-
1
)
{
outputStream
.
write
(
buffer
,
0
,
bytesRead
);
}
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"在处理ID为 {} 的PDF下载过程中发生异常"
,
id
,
e
);
log
.
error
(
"在处理ID为 {} 的PDF下载过程中发生异常"
,
id
,
e
);
}
}
...
@@ -496,15 +510,20 @@ public class RetransmissionService {
...
@@ -496,15 +510,20 @@ public class RetransmissionService {
String
serverIp
=
appAbilityRecordAll
.
getServerIp
();
String
serverIp
=
appAbilityRecordAll
.
getServerIp
();
String
dstUrl
=
appAbilityRecordAll
.
getDstUrl
();
String
dstUrl
=
appAbilityRecordAll
.
getDstUrl
();
String
objName
=
appAbilityRecordAll
.
getPdf
().
substring
(
0
,
appAbilityRecordAll
.
getPdf
().
lastIndexOf
(
"."
))
+
".ofd"
;
String
objName
=
appAbilityRecordAll
.
getPdf
().
substring
(
0
,
appAbilityRecordAll
.
getPdf
().
lastIndexOf
(
"."
))
+
".ofd"
;
String
fileUrl
=
StrUtil
.
format
(
"http://{}:9000/{}/{}"
,
serverIp
,
dstUrl
,
objName
);
try
(
InputStream
inputStream
=
minioService
.
downloadFile
(
serverIp
,
dstUrl
,
objName
);
OutputStream
outputStream
=
response
.
getOutputStream
())
{
byte
[]
bytes
=
HttpUtil
.
downloadBytes
(
fileUrl
);
response
.
setContentType
(
"application/octet-stream"
);
response
.
setHeader
(
"Content-Disposition"
,
"attachment; filename="
+
objName
);
try
(
OutputStream
outputStream
=
response
.
getOutputStream
())
{
byte
[]
buffer
=
new
byte
[
8192
];
outputStream
.
write
(
bytes
);
int
bytesRead
;
while
((
bytesRead
=
inputStream
.
read
(
buffer
))
!=
-
1
)
{
outputStream
.
write
(
buffer
,
0
,
bytesRead
);
}
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"在处理ID为 {} 的
PDF
下载过程中发生异常"
,
id
,
e
);
log
.
error
(
"在处理ID为 {} 的
OFD
下载过程中发生异常"
,
id
,
e
);
}
}
}
}
...
...
src/main/java/com/gxmailu/ocrCloudPlatform/service/impl/StatService.java
View file @
ae5e426e
This diff is collapsed.
Click to expand it.
src/main/resources/application-147prod.yml
View file @
ae5e426e
...
@@ -87,3 +87,79 @@ elasticsearch:
...
@@ -87,3 +87,79 @@ elasticsearch:
http
:
http
http
:
http
username
:
elastic
username
:
elastic
password
:
vvOxUJVNwxoN4FeIQeYC
password
:
vvOxUJVNwxoN4FeIQeYC
minio
:
clients
:
-
name
:
147.1.7.131
endpoint
:
http://147.1.7.131:9000
accessKey
:
admin
secretKey
:
Docimax@123
-
name
:
147.1.7.132
endpoint
:
http://147.1.7.132:9000
accessKey
:
admin
secretKey
:
Docimax@123
-
name
:
147.1.7.133
endpoint
:
http://147.1.7.133:9000
accessKey
:
admin
secretKey
:
Docimax@123
-
name
:
147.1.7.136
endpoint
:
http://147.1.7.136:9000
accessKey
:
admin
secretKey
:
Docimax@123
-
name
:
147.1.7.137
endpoint
:
http://147.1.7.137:9000
accessKey
:
admin
secretKey
:
Docimax@123
-
name
:
147.1.7.138
endpoint
:
http://147.1.7.138:9000
accessKey
:
admin
secretKey
:
Docimax@123
-
name
:
147.1.7.139
endpoint
:
http://147.1.7.139:9000
accessKey
:
admin
secretKey
:
Docimax@123
-
name
:
147.1.7.140
endpoint
:
http://147.1.7.140:9000
accessKey
:
admin
secretKey
:
Docimax@123
-
name
:
147.1.7.141
endpoint
:
http://147.1.7.141:9000
accessKey
:
admin
secretKey
:
Docimax@123
-
name
:
147.1.7.142
endpoint
:
http://147.1.7.142:9000
accessKey
:
admin
secretKey
:
Docimax@123
-
name
:
147.1.7.143
endpoint
:
http://147.1.7.143:9000
accessKey
:
admin
secretKey
:
Docimax@123
-
name
:
147.1.7.144
endpoint
:
http://147.1.7.144:9000
accessKey
:
admin
secretKey
:
Docimax@123
-
name
:
147.1.6.152
endpoint
:
http://147.1.6.152:9000
accessKey
:
admin
secretKey
:
Docimax@123
-
name
:
147.2.4.1
endpoint
:
http://147.2.4.1:9000
accessKey
:
admin
secretKey
:
Docimax@123
-
name
:
147.2.4.2
endpoint
:
http://147.2.4.2:9000
accessKey
:
admin
secretKey
:
Docimax@123
-
name
:
147.2.4.5
endpoint
:
http://147.2.4.5:9000
accessKey
:
admin
secretKey
:
Docimax@123
-
name
:
147.2.4.18
endpoint
:
http://147.2.4.18:9000
accessKey
:
admin
secretKey
:
Docimax@123
-
name
:
147.2.4.19
endpoint
:
http://147.2.4.19:9000
accessKey
:
admin
secretKey
:
Docimax@123
src/main/resources/application-dev.yml
View file @
ae5e426e
...
@@ -4,7 +4,7 @@ spring:
...
@@ -4,7 +4,7 @@ spring:
db-type
:
com.alibaba.druid.pool.DruidDataSource
db-type
:
com.alibaba.druid.pool.DruidDataSource
driver-class-name
:
com.mysql.cj.jdbc.Driver
driver-class-name
:
com.mysql.cj.jdbc.Driver
username
:
root
username
:
root
password
:
Dk2019!23456
password
:
ZqTestDB#2024#
url
:
jdbc:mysql://119.45.183.210:13308/ocr_cloud?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
url
:
jdbc:mysql://119.45.183.210:13308/ocr_cloud?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
initial-size
:
3
# 初始化时建立物理连接的个数
initial-size
:
3
# 初始化时建立物理连接的个数
min-idle
:
5
# 最小连接池数量
min-idle
:
5
# 最小连接池数量
...
@@ -40,7 +40,7 @@ spring:
...
@@ -40,7 +40,7 @@ spring:
port
:
6379
port
:
6379
database
:
0
database
:
0
password
:
password
:
jedis
:
lettuce
:
pool
:
pool
:
max-active
:
128
max-active
:
128
max-wait
:
60s
max-wait
:
60s
...
@@ -72,6 +72,13 @@ elasticsearch:
...
@@ -72,6 +72,13 @@ elasticsearch:
username
:
elastic
username
:
elastic
password
:
RQuT4eQIdIZ57waX9f87
password
:
RQuT4eQIdIZ57waX9f87
minio
:
clients
:
-
name
:
127.0.0.1
endpoint
:
http://127.0.0.1:9000
accessKey
:
minioadmin
secretKey
:
minioadmin
#eureka:
#eureka:
# client:
# client:
# enabled: false
# enabled: false
\ No newline at end of file
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