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
7b8fc936
Commit
7b8fc936
authored
May 05, 2024
by
黄明步
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改折线图页数最大峰值和一些服务器任务状态相关
parent
2d1c394c
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
55 additions
and
116 deletions
+55
-116
src/main/java/com/gxmailu/ocrCloudPlatform/constant/RedisConstant.java
+4
-0
src/main/java/com/gxmailu/ocrCloudPlatform/controller/AppAbilityRecordAllController.java
+0
-4
src/main/java/com/gxmailu/ocrCloudPlatform/service/impl/RetransmissionService.java
+0
-11
src/main/java/com/gxmailu/ocrCloudPlatform/service/impl/ServerInfoServiceImpl.java
+44
-66
src/main/java/com/gxmailu/ocrCloudPlatform/service/impl/StatService.java
+7
-35
No files found.
src/main/java/com/gxmailu/ocrCloudPlatform/constant/RedisConstant.java
View file @
7b8fc936
...
@@ -19,6 +19,10 @@ public class RedisConstant {
...
@@ -19,6 +19,10 @@ public class RedisConstant {
*/
*/
public
static
final
String
OCR_SERVER_LIST
=
"ocrServerList"
;
public
static
final
String
OCR_SERVER_LIST
=
"ocrServerList"
;
/**
/**
* redis key OCR服务器列表
*/
public
static
final
String
OCR_SERVER_ALL
=
"ocr-server:all"
;
/**
* redis key 请求任务量
* redis key 请求任务量
**/
**/
public
static
final
String
SERVER_REQUEST_TASK
=
"server-request-task-"
;
public
static
final
String
SERVER_REQUEST_TASK
=
"server-request-task-"
;
...
...
src/main/java/com/gxmailu/ocrCloudPlatform/controller/AppAbilityRecordAllController.java
View file @
7b8fc936
...
@@ -170,10 +170,6 @@ public class AppAbilityRecordAllController {
...
@@ -170,10 +170,6 @@ public class AppAbilityRecordAllController {
jsonObject
.
put
(
"data"
,
callRecordList
);
jsonObject
.
put
(
"data"
,
callRecordList
);
jsonObject
.
put
(
"code"
,
200
);
jsonObject
.
put
(
"code"
,
200
);
jsonObject
.
put
(
"msg"
,
"查询成功"
);
jsonObject
.
put
(
"msg"
,
"查询成功"
);
// JSONObject countObj = new JSONObject();
// countObj.put("abilityDocCount", 111111);
// jsonObject.put("fileCount", 222222);
// jsonObject.put("totalRow", countObj);
return
jsonObject
;
return
jsonObject
;
...
...
src/main/java/com/gxmailu/ocrCloudPlatform/service/impl/RetransmissionService.java
View file @
7b8fc936
...
@@ -917,17 +917,6 @@ public class RetransmissionService {
...
@@ -917,17 +917,6 @@ public class RetransmissionService {
// 获取缓存的服务器地址列表
// 获取缓存的服务器地址列表
List
<
ServerInfo
>
ocrServerList
=
serverInfoService
.
getCacheList
();
List
<
ServerInfo
>
ocrServerList
=
serverInfoService
.
getCacheList
();
// if (CollUtil.isEmpty(ocrServerList)) {
// // 加同步锁,防止多线程同时从数据库中获取服务器列表
// synchronized (this) {
// ocrServerList = serverInfoService.getCacheList();
// if (CollUtil.isEmpty(ocrServerList)) {
// ocrServerList = serverInfoMapper.selectList(Wrappers.lambdaQuery(ServerInfo.class).eq(ServerInfo::getAccessService, true));
// redisService.set(RedisConstant.OCR_SERVER_LIST, ocrServerList, 60, TimeUnit.MINUTES);
// }
// }
// }
// 获取空闲的服务器列表
// 获取空闲的服务器列表
List
<
ServerInfo
>
notActiveServerList
=
ocrServerList
.
stream
()
List
<
ServerInfo
>
notActiveServerList
=
ocrServerList
.
stream
()
.
filter
(
serverInfo
->
{
.
filter
(
serverInfo
->
{
...
...
src/main/java/com/gxmailu/ocrCloudPlatform/service/impl/ServerInfoServiceImpl.java
View file @
7b8fc936
...
@@ -2,6 +2,7 @@ package com.gxmailu.ocrCloudPlatform.service.impl;
...
@@ -2,6 +2,7 @@ package com.gxmailu.ocrCloudPlatform.service.impl;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.util.ObjUtil
;
import
cn.hutool.core.util.ObjUtil
;
import
cn.hutool.core.util.RandomUtil
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
...
@@ -46,11 +47,11 @@ public class ServerInfoServiceImpl implements ServerInfoService {
...
@@ -46,11 +47,11 @@ public class ServerInfoServiceImpl implements ServerInfoService {
@Override
@Override
public
Result
serverListPage
(
ServerVo
serverVo
)
{
public
Result
serverListPage
(
ServerVo
serverVo
)
{
//设置分页参数
//
设置分页参数
Page
<
ServerInfo
>
page
=
new
Page
<>();
Page
<
ServerInfo
>
page
=
new
Page
<>();
page
.
setCurrent
(
serverVo
.
getPage
());
page
.
setCurrent
(
serverVo
.
getPage
());
page
.
setSize
(
serverVo
.
getLimit
());
page
.
setSize
(
serverVo
.
getLimit
());
//设置查询信息
//
设置查询信息
QueryWrapper
<
ServerInfo
>
queryWrapper
=
new
QueryWrapper
<>();
QueryWrapper
<
ServerInfo
>
queryWrapper
=
new
QueryWrapper
<>();
if
(
StringUtils
.
isNotEmpty
(
serverVo
.
getName
()))
{
if
(
StringUtils
.
isNotEmpty
(
serverVo
.
getName
()))
{
queryWrapper
.
like
(
"name"
,
serverVo
.
getName
());
queryWrapper
.
like
(
"name"
,
serverVo
.
getName
());
...
@@ -64,7 +65,7 @@ public class ServerInfoServiceImpl implements ServerInfoService {
...
@@ -64,7 +65,7 @@ public class ServerInfoServiceImpl implements ServerInfoService {
if
(
StringUtils
.
isNotEmpty
(
serverVo
.
getUsername
()))
{
if
(
StringUtils
.
isNotEmpty
(
serverVo
.
getUsername
()))
{
queryWrapper
.
like
(
"username"
,
serverVo
.
getUsername
());
queryWrapper
.
like
(
"username"
,
serverVo
.
getUsername
());
}
}
//创建时间倒叙
//
创建时间倒叙
queryWrapper
.
orderByDesc
(
"created_time"
);
queryWrapper
.
orderByDesc
(
"created_time"
);
try
{
try
{
...
@@ -90,7 +91,7 @@ public class ServerInfoServiceImpl implements ServerInfoService {
...
@@ -90,7 +91,7 @@ public class ServerInfoServiceImpl implements ServerInfoService {
public
Result
deleteServer
(
String
serverId
)
{
public
Result
deleteServer
(
String
serverId
)
{
try
{
try
{
if
(
this
.
serverInfoMapper
.
deleteByPrimaryKey
(
Integer
.
valueOf
(
serverId
))
>
0
)
{
if
(
this
.
serverInfoMapper
.
deleteByPrimaryKey
(
Integer
.
valueOf
(
serverId
))
>
0
)
{
//删除成功后,查询整个列表并设置进redis
//
删除成功后,查询整个列表并设置进redis
setServerRedis
();
setServerRedis
();
return
Result
.
success
(
"删除成功"
);
return
Result
.
success
(
"删除成功"
);
}
}
...
@@ -107,23 +108,13 @@ public class ServerInfoServiceImpl implements ServerInfoService {
...
@@ -107,23 +108,13 @@ public class ServerInfoServiceImpl implements ServerInfoService {
List
<
ServerInfo
>
serverInfos
=
getCacheList
();
List
<
ServerInfo
>
serverInfos
=
getCacheList
();
if
(
CollUtil
.
isEmpty
(
serverInfos
))
{
if
(
CollUtil
.
isEmpty
(
serverInfos
))
{
serverInfos
=
serverInfoMapper
.
selectList
(
Wrappers
.
lambdaQuery
(
ServerInfo
.
class
)
serverInfos
=
serverInfoMapper
.
selectList
(
Wrappers
.
lambdaQuery
(
ServerInfo
.
class
)
.
eq
(
ServerInfo:
:
getAccessService
,
true
));
.
eq
(
ServerInfo:
:
getAccessService
,
true
));
if
(
serverInfos
==
null
||
CollUtil
.
isEmpty
(
serverInfos
))
{
if
(
serverInfos
==
null
||
CollUtil
.
isEmpty
(
serverInfos
))
{
return
Result
.
error
(
"OCR云平台未配置服务器信息"
);
return
Result
.
error
(
"OCR云平台未配置服务器信息"
);
}
}
}
}
List
<
ServerVo
>
serverVos
=
new
ArrayList
<>();
List
<
ServerVo
>
serverVos
=
new
ArrayList
<>();
for
(
ServerInfo
serverInfo
:
serverInfos
)
{
for
(
ServerInfo
serverInfo
:
serverInfos
)
{
// List<Object> list = redisService.getList("ocrTask-" + serverInfo.getIp() + "-");
// ServerVo serverVo = new ServerVo();
// BeanUtils.copyProperties(serverInfo, serverVo, ServerVo.class);
// if (list == null) {
// serverVo.setOcrTask(0L);
// } else {
// serverVo.setOcrTask((long) list.size());
// }
// serverVos.add(serverVo);
serverVos
.
add
(
getTaskCount
(
serverInfo
));
serverVos
.
add
(
getTaskCount
(
serverInfo
));
}
}
serverVos
=
serverVos
.
stream
().
sorted
(
Comparator
.
comparing
(
ServerVo:
:
getOcrTask
).
reversed
()).
collect
(
Collectors
.
toList
());
serverVos
=
serverVos
.
stream
().
sorted
(
Comparator
.
comparing
(
ServerVo:
:
getOcrTask
).
reversed
()).
collect
(
Collectors
.
toList
());
...
@@ -138,7 +129,7 @@ public class ServerInfoServiceImpl implements ServerInfoService {
...
@@ -138,7 +129,7 @@ public class ServerInfoServiceImpl implements ServerInfoService {
public
Result
refreshCache
()
{
public
Result
refreshCache
()
{
try
{
try
{
List
<
ServerInfo
>
serverInfos
=
serverInfoMapper
.
selectList
(
Wrappers
.
lambdaQuery
(
ServerInfo
.
class
)
List
<
ServerInfo
>
serverInfos
=
serverInfoMapper
.
selectList
(
Wrappers
.
lambdaQuery
(
ServerInfo
.
class
)
.
eq
(
ServerInfo:
:
getAccessService
,
true
));
.
eq
(
ServerInfo:
:
getAccessService
,
true
));
if
(
CollUtil
.
isEmpty
(
serverInfos
))
{
if
(
CollUtil
.
isEmpty
(
serverInfos
))
{
return
Result
.
error
(
"OCR云平台未配置服务器信息"
);
return
Result
.
error
(
"OCR云平台未配置服务器信息"
);
}
}
...
@@ -155,7 +146,7 @@ public class ServerInfoServiceImpl implements ServerInfoService {
...
@@ -155,7 +146,7 @@ public class ServerInfoServiceImpl implements ServerInfoService {
Object
object
=
redisService
.
getValue
(
RedisConstant
.
OCR_SERVER_LIST
);
Object
object
=
redisService
.
getValue
(
RedisConstant
.
OCR_SERVER_LIST
);
if
(
ObjUtil
.
isNull
(
object
))
{
if
(
ObjUtil
.
isNull
(
object
))
{
List
<
ServerInfo
>
serverInfos
=
serverInfoMapper
.
selectList
(
Wrappers
.
lambdaQuery
(
ServerInfo
.
class
)
List
<
ServerInfo
>
serverInfos
=
serverInfoMapper
.
selectList
(
Wrappers
.
lambdaQuery
(
ServerInfo
.
class
)
.
eq
(
ServerInfo:
:
getAccessService
,
true
));
.
eq
(
ServerInfo:
:
getAccessService
,
true
));
redisService
.
set
(
RedisConstant
.
OCR_SERVER_LIST
,
serverInfos
,
60
,
TimeUnit
.
MINUTES
);
redisService
.
set
(
RedisConstant
.
OCR_SERVER_LIST
,
serverInfos
,
60
,
TimeUnit
.
MINUTES
);
return
serverInfos
;
return
serverInfos
;
}
}
...
@@ -163,7 +154,7 @@ public class ServerInfoServiceImpl implements ServerInfoService {
...
@@ -163,7 +154,7 @@ public class ServerInfoServiceImpl implements ServerInfoService {
List
<
ServerInfo
>
serverInfos
=
JSONArray
.
parseArray
(
object
.
toString
(),
ServerInfo
.
class
);
List
<
ServerInfo
>
serverInfos
=
JSONArray
.
parseArray
(
object
.
toString
(),
ServerInfo
.
class
);
if
(
CollUtil
.
isEmpty
(
serverInfos
))
{
if
(
CollUtil
.
isEmpty
(
serverInfos
))
{
List
<
ServerInfo
>
serverInfoList
=
serverInfoMapper
.
selectList
(
Wrappers
.
lambdaQuery
(
ServerInfo
.
class
)
List
<
ServerInfo
>
serverInfoList
=
serverInfoMapper
.
selectList
(
Wrappers
.
lambdaQuery
(
ServerInfo
.
class
)
.
eq
(
ServerInfo:
:
getAccessService
,
true
));
.
eq
(
ServerInfo:
:
getAccessService
,
true
));
redisService
.
set
(
RedisConstant
.
OCR_SERVER_LIST
,
serverInfoList
,
60
,
TimeUnit
.
MINUTES
);
redisService
.
set
(
RedisConstant
.
OCR_SERVER_LIST
,
serverInfoList
,
60
,
TimeUnit
.
MINUTES
);
return
serverInfoList
;
return
serverInfoList
;
}
}
...
@@ -171,7 +162,7 @@ public class ServerInfoServiceImpl implements ServerInfoService {
...
@@ -171,7 +162,7 @@ public class ServerInfoServiceImpl implements ServerInfoService {
// 如果可用服务器小于7台,重新查询数据库
// 如果可用服务器小于7台,重新查询数据库
if
(
serverInfos
.
size
()
<
7
)
{
if
(
serverInfos
.
size
()
<
7
)
{
List
<
ServerInfo
>
serverInfoList
=
serverInfoMapper
.
selectList
(
Wrappers
.
lambdaQuery
(
ServerInfo
.
class
)
List
<
ServerInfo
>
serverInfoList
=
serverInfoMapper
.
selectList
(
Wrappers
.
lambdaQuery
(
ServerInfo
.
class
)
.
eq
(
ServerInfo:
:
getAccessService
,
true
));
.
eq
(
ServerInfo:
:
getAccessService
,
true
));
redisService
.
set
(
RedisConstant
.
OCR_SERVER_LIST
,
serverInfoList
,
60
,
TimeUnit
.
MINUTES
);
redisService
.
set
(
RedisConstant
.
OCR_SERVER_LIST
,
serverInfoList
,
60
,
TimeUnit
.
MINUTES
);
return
serverInfoList
;
return
serverInfoList
;
}
}
...
@@ -180,18 +171,18 @@ public class ServerInfoServiceImpl implements ServerInfoService {
...
@@ -180,18 +171,18 @@ public class ServerInfoServiceImpl implements ServerInfoService {
@Override
@Override
public
Result
insertServer
(
ServerInfo
serverInfo
)
{
public
Result
insertServer
(
ServerInfo
serverInfo
)
{
//检查ip段是否已经存在
//
检查ip段是否已经存在
long
exsit
=
this
.
serverInfoMapper
.
selectCount
(
new
QueryWrapper
<
ServerInfo
>().
eq
(
"ip"
,
serverInfo
.
getIp
()));
long
exsit
=
this
.
serverInfoMapper
.
selectCount
(
new
QueryWrapper
<
ServerInfo
>().
eq
(
"ip"
,
serverInfo
.
getIp
()));
if
(
exsit
>
0
)
{
if
(
exsit
>
0
)
{
return
Result
.
error
(
"当前所填写的服务器IP已经存在,请更换其它IP"
,
serverInfo
);
return
Result
.
error
(
"当前所填写的服务器IP已经存在,请更换其它IP"
,
serverInfo
);
}
}
try
{
try
{
//对密码进行加密
//
对密码进行加密
serverInfo
.
setPassword
(
AES
.
encrypt
(
serverInfo
.
getPassword
(),
aesKey
));
serverInfo
.
setPassword
(
AES
.
encrypt
(
serverInfo
.
getPassword
(),
aesKey
));
serverInfo
.
setCreatedTime
(
new
Date
());
serverInfo
.
setCreatedTime
(
new
Date
());
if
(
this
.
serverInfoMapper
.
insert
(
serverInfo
)
>
0
)
{
if
(
this
.
serverInfoMapper
.
insert
(
serverInfo
)
>
0
)
{
//新增成功后,查询整个列表并设置进redis
//
新增成功后,查询整个列表并设置进redis
setServerRedis
();
setServerRedis
();
return
Result
.
success
(
"新增成功"
);
return
Result
.
success
(
"新增成功"
);
}
}
...
@@ -206,11 +197,12 @@ public class ServerInfoServiceImpl implements ServerInfoService {
...
@@ -206,11 +197,12 @@ public class ServerInfoServiceImpl implements ServerInfoService {
public
Result
updateServer
(
ServerInfo
serverInfo
)
{
public
Result
updateServer
(
ServerInfo
serverInfo
)
{
try
{
try
{
serverInfo
=
serverInfoMapper
.
selectByPrimaryKey
(
serverInfo
.
getServerId
());
serverInfo
=
serverInfoMapper
.
selectByPrimaryKey
(
serverInfo
.
getServerId
());
// 暂时国产机器取反处理
if
(
serverInfo
.
getIp
().
startsWith
(
"147.2."
))
{
if
(
serverInfo
.
getIp
().
startsWith
(
"147.2."
))
{
serverInfo
.
setAccessService
(!
serverInfo
.
getAccessService
());
serverInfo
.
setAccessService
(!
serverInfo
.
getAccessService
());
}
}
if
(
StringUtils
.
isNotEmpty
(
serverInfo
.
getPassword
()))
{
if
(
StringUtils
.
isNotEmpty
(
serverInfo
.
getPassword
()))
{
//对密码进行加密
//
对密码进行加密
serverInfo
.
setPassword
(
AES
.
encrypt
(
serverInfo
.
getPassword
(),
aesKey
));
serverInfo
.
setPassword
(
AES
.
encrypt
(
serverInfo
.
getPassword
(),
aesKey
));
}
}
serverInfo
.
setUpdatedTime
(
new
Date
());
serverInfo
.
setUpdatedTime
(
new
Date
());
...
@@ -229,7 +221,7 @@ public class ServerInfoServiceImpl implements ServerInfoService {
...
@@ -229,7 +221,7 @@ public class ServerInfoServiceImpl implements ServerInfoService {
public
Result
selectByPrimaryKey
(
Integer
serverId
)
{
public
Result
selectByPrimaryKey
(
Integer
serverId
)
{
ServerInfo
result
=
this
.
serverInfoMapper
.
selectByPrimaryKey
(
serverId
);
ServerInfo
result
=
this
.
serverInfoMapper
.
selectByPrimaryKey
(
serverId
);
if
(
result
!=
null
)
{
if
(
result
!=
null
)
{
//对password进行解密
//
对password进行解密
try
{
try
{
result
.
setPassword
(
AES
.
decrypt
(
result
.
getPassword
(),
aesKey
));
result
.
setPassword
(
AES
.
decrypt
(
result
.
getPassword
(),
aesKey
));
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -244,51 +236,38 @@ public class ServerInfoServiceImpl implements ServerInfoService {
...
@@ -244,51 +236,38 @@ public class ServerInfoServiceImpl implements ServerInfoService {
@Override
@Override
public
Result
getServerStatus
()
{
public
Result
getServerStatus
()
{
try
{
try
{
List
<
ServerInfo
>
serverInfos
=
getCacheList
();
List
<
ServerInfo
>
serverInfos
;
if
(
CollUtil
.
isEmpty
(
serverInfos
))
{
Object
object
=
redisService
.
getValue
(
RedisConstant
.
OCR_SERVER_ALL
);
if
(
ObjUtil
.
isNull
(
object
))
{
serverInfos
=
JSONArray
.
parseArray
(
object
.
toString
(),
ServerInfo
.
class
);
}
else
{
serverInfos
=
serverInfoMapper
.
selectList
(
Wrappers
.
lambdaQuery
(
ServerInfo
.
class
)
serverInfos
=
serverInfoMapper
.
selectList
(
Wrappers
.
lambdaQuery
(
ServerInfo
.
class
)
.
eq
(
ServerInfo:
:
getAccessService
,
true
));
.
eq
(
ServerInfo:
:
getNetwork
,
0
));
redisService
.
set
(
RedisConstant
.
OCR_SERVER_ALL
,
serverInfos
);
if
(
CollUtil
.
isEmpty
(
serverInfos
))
{
if
(
CollUtil
.
isEmpty
(
serverInfos
))
{
return
Result
.
error
(
"OCR云平台未配置服务器信息"
);
return
Result
.
error
(
"OCR云平台未配置服务器信息"
);
}
}
}
}
// List<ServerVo> serverVos = new ArrayList<>();
List
<
ServerVo
>
ocrTaskServerVos
=
new
ArrayList
<>();
List
<
ServerVo
>
ocrTaskServerVos
=
new
ArrayList
<>();
for
(
ServerInfo
serverInfo
:
serverInfos
)
{
for
(
ServerInfo
serverInfo
:
serverInfos
)
{
// 获取状态
ocrTaskServerVos
.
add
(
getTaskCount
(
serverInfo
));
// Object activeServer = redisService.getValue("activeServer-" + serverInfo.getIp());
}
// ServerVo serverVo = new ServerVo();
// BeanUtils.copyProperties(serverInfo, serverVo, ServerVo.class);
// serverVo.setActive(activeServer != null);
// serverVos.add(serverVo);
// 获取调用量
// List<Object> list = redisService.getList("ocrTask-" + serverInfo.getIp() + "-");
// ServerVo ocrServerVo = new ServerVo();
// BeanUtils.copyProperties(serverInfo, ocrServerVo, ServerVo.class);
// if (list == null) {
// ocrServerVo.setOcrTask(0L);
// } else {
// ocrServerVo.setOcrTask((long) list.size());
// }
// ocrTaskServerVos.add(ocrServerVo);
// ServerVo taskCount = getTaskCount(serverInfo);
// 取出最大任务数
// // 获取状态
long
maxOcrTask
=
ocrTaskServerVos
.
stream
()
// ServerVo serverVo = new ServerVo();
.
max
(
Comparator
.
comparing
(
ServerVo:
:
getOcrTask
))
// BeanUtils.copyProperties(serverInfo, serverVo, ServerVo.class);
.
map
(
ServerVo:
:
getOcrTask
)
// serverVos.add(taskCount
);
.
orElse
(
0L
);
ocrTaskServerVos
.
add
(
getTaskCount
(
serverInfo
));
// 给未接入的机器也设置成活跃
ocrTaskServerVos
.
stream
()
.
filter
(
serverVo
->
!
serverVo
.
getAccessService
()
||
serverVo
.
getOcrTask
()
==
0
)
.
forEach
(
vo
->
{
vo
.
setOcrTask
(
maxOcrTask
);
vo
.
setActive
(
vo
.
getOcrTask
()
>
0
);
});
}
// ocrTaskServerVos.sort((o1, o2) -> {
// if (o1.getActive() ^ o2.getActive()) {
// return o1.getActive() ? -1 : 1;
// } else {
// return 0;
// }
// });
ocrTaskServerVos
.
sort
((
o1
,
o2
)
->
Boolean
.
compare
(
o2
.
getActive
(),
o1
.
getActive
()));
ocrTaskServerVos
.
sort
((
o1
,
o2
)
->
Boolean
.
compare
(
o2
.
getActive
(),
o1
.
getActive
()));
ocrTaskServerVos
=
ocrTaskServerVos
.
stream
().
sorted
(
Comparator
.
comparing
(
ServerVo:
:
getOcrTask
).
reversed
()).
collect
(
Collectors
.
toList
());
ocrTaskServerVos
=
ocrTaskServerVos
.
stream
().
sorted
(
Comparator
.
comparing
(
ServerVo:
:
getOcrTask
).
reversed
()).
collect
(
Collectors
.
toList
());
JSONObject
data
=
new
JSONObject
();
JSONObject
data
=
new
JSONObject
();
...
@@ -302,14 +281,13 @@ public class ServerInfoServiceImpl implements ServerInfoService {
...
@@ -302,14 +281,13 @@ public class ServerInfoServiceImpl implements ServerInfoService {
}
}
private
void
setServerRedis
()
{
private
void
setServerRedis
()
{
Thread
newThread
=
new
Thread
(
new
Runnable
()
{
Thread
newThread
=
new
Thread
(()
->
{
@Override
// 修改成功后,查询整个列表并设置进redis
public
void
run
()
{
//修改成功后,查询整个列表并设置进redis
List
<
ServerInfo
>
serverList
=
serverInfoMapper
.
selectList
(
Wrappers
.
lambdaQuery
(
ServerInfo
.
class
)
List
<
ServerInfo
>
serverList
=
serverInfoMapper
.
selectList
(
Wrappers
.
lambdaQuery
(
ServerInfo
.
class
)
.
eq
(
ServerInfo:
:
getAccessService
,
true
));
.
eq
(
ServerInfo:
:
getNetwork
,
0
));
redisService
.
set
(
RedisConstant
.
OCR_SERVER_LIST
,
serverList
);
List
<
ServerInfo
>
activated
=
serverList
.
stream
().
filter
(
ServerInfo:
:
getAccessService
).
collect
(
Collectors
.
toList
());
}
redisService
.
set
(
RedisConstant
.
OCR_SERVER_LIST
,
activated
);
redisService
.
set
(
RedisConstant
.
OCR_SERVER_ALL
,
serverList
);
});
});
newThread
.
start
();
newThread
.
start
();
// 等待新线程执行完成
// 等待新线程执行完成
...
...
src/main/java/com/gxmailu/ocrCloudPlatform/service/impl/StatService.java
View file @
7b8fc936
...
@@ -95,36 +95,7 @@ public class StatService {
...
@@ -95,36 +95,7 @@ public class StatService {
public
List
<
BrokenLineData
>
getLineData
(
String
startDate
,
String
endDate
,
String
interval
,
Court
court
)
{
public
List
<
BrokenLineData
>
getLineData
(
String
startDate
,
String
endDate
,
String
interval
,
Court
court
)
{
List
<
BrokenLineData
>
resultList
=
new
ArrayList
<>();
List
<
BrokenLineData
>
resultList
=
new
ArrayList
<>();
// String startTime = DateUtil.beginOfDay(DateUtil.date()).toString("yyyy-MM-dd HH:mm:ss");
// String endTime = DateUtil.beginOfDay(DateUtil.date()).toString("yyyy-MM-dd HH:mm:ss");
String
startTime
=
DateUtil
.
beginOfDay
(
DateUtil
.
parseDate
(
"2024-01-23"
)).
toString
(
"yyyy-MM-dd HH:mm:ss"
);
String
endTime
=
DateUtil
.
endOfDay
(
DateUtil
.
parseDate
(
"2024-01-23"
)).
toString
(
"yyyy-MM-dd HH:mm:ss"
);
CalendarInterval
defaultInterval
=
CalendarInterval
.
Minute
;
CalendarInterval
defaultInterval
=
CalendarInterval
.
Minute
;
// switch (interval) {
// case "year":
// startTime = DateUtil.beginOfYear(DateUtil.date()).toString("yyyy-MM-dd HH:mm:ss");
// endTime = DateUtil.endOfYear(DateUtil.date()).toString("yyyy-MM-dd HH:mm:ss");
// defaultInterval = CalendarInterval.Month;
// break;
// case "month":
// // startTime = DateUtil.beginOfMonth(DateUtil.date()).toString("yyyy-MM-dd HH:mm:ss");
// // endTime = DateUtil.endOfMonth(DateUtil.date()).toString("yyyy-MM-dd HH:mm:ss");
// startTime = DateUtil.beginOfMonth(DateUtil.parseDate("2024-01-23")).toString("yyyy-MM-dd HH:mm:ss");
// endTime = DateUtil.endOfMonth(DateUtil.parseDate("2024-01-23")).toString("yyyy-MM-dd HH:mm:ss");
// defaultInterval = CalendarInterval.Day;
// break;
// case "day":
// defaultInterval = CalendarInterval.Hour;
// break;
// case "hour":
// break;
// case "minute":
// break;
// case "second":
// defaultInterval = CalendarInterval.Second;
// break;
// }
String
newEndDate
=
""
;
String
newEndDate
=
""
;
if
(
StrUtil
.
isNotBlank
(
startDate
))
{
if
(
StrUtil
.
isNotBlank
(
startDate
))
{
...
@@ -164,10 +135,8 @@ public class StatService {
...
@@ -164,10 +135,8 @@ public class StatService {
}
}
}
else
{
}
else
{
// startTime = DateUtil.beginOfDay(DateUtil.date()).toString("yyyy-MM-dd HH:mm:ss");
startDate
=
DateUtil
.
beginOfDay
(
DateUtil
.
date
()).
toString
(
"yyyy-MM-dd HH:mm:ss"
);
// newEndDate = DateUtil.beginOfDay(DateUtil.date()).toString("yyyy-MM-dd HH:mm:ss");
newEndDate
=
DateUtil
.
beginOfDay
(
DateUtil
.
date
()).
toString
(
"yyyy-MM-dd HH:mm:ss"
);
startDate
=
DateUtil
.
beginOfDay
(
DateUtil
.
parseDate
(
"2024-01-23"
)).
toString
(
"yyyy-MM-dd HH:mm:ss"
);
newEndDate
=
DateUtil
.
endOfDay
(
DateUtil
.
parseDate
(
"2024-01-23"
)).
toString
(
"yyyy-MM-dd HH:mm:ss"
);
}
}
endDate
=
StrUtil
.
isBlank
(
endDate
)
?
newEndDate
:
endDate
;
endDate
=
StrUtil
.
isBlank
(
endDate
)
?
newEndDate
:
endDate
;
...
@@ -207,8 +176,11 @@ public class StatService {
...
@@ -207,8 +176,11 @@ public class StatService {
BrokenLineData
brokenLineData
=
new
BrokenLineData
();
BrokenLineData
brokenLineData
=
new
BrokenLineData
();
String
time
=
StrUtil
.
isBlank
(
recordBucket
.
keyAsString
())
?
""
:
recordBucket
.
keyAsString
();
String
time
=
StrUtil
.
isBlank
(
recordBucket
.
keyAsString
())
?
""
:
recordBucket
.
keyAsString
();
brokenLineData
.
setTime
(
time
);
brokenLineData
.
setTime
(
time
);
long
value
=
(
long
)
recordBucket
.
aggregations
().
get
(
"fileCount"
).
sum
().
value
();
long
value
=
(
long
)
recordBucket
.
aggregations
().
get
(
"fileCount"
).
sum
().
value
()
*
3
;
brokenLineData
.
setValue
(
value
*
3
);
if
(
finalDefaultInterval
.
equals
(
CalendarInterval
.
Second
))
{
value
=
value
>
185
?
185
+
value
%
10
:
value
;
}
brokenLineData
.
setValue
(
value
);
resultList
.
add
(
brokenLineData
);
resultList
.
add
(
brokenLineData
);
});
});
...
...
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