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
78d91a2e
Commit
78d91a2e
authored
Jan 31, 2024
by
黄明步
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复查询法院调用量错误
parent
a2ec6745
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
15 deletions
+15
-15
src/main/java/com/gxmailu/ocrCloudPlatform/service/impl/ElasticSearchService.java
+15
-15
No files found.
src/main/java/com/gxmailu/ocrCloudPlatform/service/impl/ElasticSearchService.java
View file @
78d91a2e
...
@@ -33,6 +33,7 @@ import com.gxmailu.ocrCloudPlatform.service.CourtService;
...
@@ -33,6 +33,7 @@ import com.gxmailu.ocrCloudPlatform.service.CourtService;
import
com.gxmailu.ocrCloudPlatform.utils.IpUtils
;
import
com.gxmailu.ocrCloudPlatform.utils.IpUtils
;
import
com.gxmailu.ocrCloudPlatform.vo.BrokenLineData
;
import
com.gxmailu.ocrCloudPlatform.vo.BrokenLineData
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.poi.ss.formula.functions.T
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -145,8 +146,12 @@ public class ElasticSearchService {
...
@@ -145,8 +146,12 @@ public class ElasticSearchService {
*/
*/
public
Object
getCourtUseCount
(
Court
court
,
DateTime
start
,
DateTime
end
)
{
public
Object
getCourtUseCount
(
Court
court
,
DateTime
start
,
DateTime
end
)
{
JSONObject
object
=
new
JSONObject
();
JSONObject
object
=
new
JSONObject
();
SearchResponse
<
Map
>
searchResponse
;
SearchResponse
<
Void
>
searchResponse
;
try
{
try
{
// 获取法院ip段
List
<
String
>
ipScopes
=
StrUtil
.
splitTrim
(
court
.
getIpScope
(),
"-"
);
List
<
String
>
ipRange
=
ipScopes
.
size
()
!=
2
?
Arrays
.
asList
(
"255.255.255.255"
,
"255.255.255.255"
)
:
IpUtils
.
getIPRange
(
ipScopes
.
get
(
0
),
ipScopes
.
get
(
1
),
3
);
searchResponse
=
client
.
search
(
srBuilder
->
srBuilder
searchResponse
=
client
.
search
(
srBuilder
->
srBuilder
.
index
(
APP_ABILITY_RECORD_INDEX
)
.
index
(
APP_ABILITY_RECORD_INDEX
)
.
query
(
queryBuilder
->
queryBuilder
.
bool
(
boolQuery
->
{
.
query
(
queryBuilder
->
queryBuilder
.
bool
(
boolQuery
->
{
...
@@ -155,20 +160,15 @@ public class ElasticSearchService {
...
@@ -155,20 +160,15 @@ public class ElasticSearchService {
.
field
(
"callTime"
)
.
field
(
"callTime"
)
.
gte
(
JsonData
.
of
(
start
.
toString
()))
.
gte
(
JsonData
.
of
(
start
.
toString
()))
.
lte
(
JsonData
.
of
(
end
.
toString
()))));
.
lte
(
JsonData
.
of
(
end
.
toString
()))));
// 法院ip前缀查询
// 多个ip前缀过滤
if
(
ObjUtil
.
isNotNull
(
court
)
&&
StrUtil
.
isNotBlank
(
court
.
getIpScope
()))
{
boolQuery
.
must
(
mustQuery
->
mustQuery
.
bool
(
bq
->
{
List
<
String
>
ipScopes
=
StrUtil
.
splitTrim
(
court
.
getIpScope
(),
"-"
);
ipRange
.
forEach
(
ip
->
bq
.
should
(
q
->
q
.
prefix
(
pq
->
pq
.
field
(
"ip.keyword"
).
value
(
ip
))));
try
{
return
bq
;
List
<
String
>
ipRange
=
ipScopes
.
size
()
!=
2
?
new
ArrayList
<>()
:
IpUtils
.
getIPRange
(
ipScopes
.
get
(
0
),
ipScopes
.
get
(
1
),
3
);
}));
ipRange
.
forEach
(
ip
->
boolQuery
.
must
(
q
->
q
.
prefix
(
pq
->
pq
.
field
(
"ip.keyword"
).
value
(
ip
))));
}
catch
(
Exception
e
)
{
log
.
error
(
"IP段解析错误"
,
e
);
}
}
return
boolQuery
;
return
boolQuery
;
}))
}))
// 总命中数,与hits.size()不同的是trackTotalHits不会限制10000
// 总命中数,与hits.size()不同的是trackTotalHits不会限制10000
.
trackTotalHits
(
tb
->
tb
.
enabled
(
true
)),
Map
.
class
);
.
trackTotalHits
(
tb
->
tb
.
enabled
(
true
)),
Void
.
class
);
TotalHits
totalHits
=
searchResponse
.
hits
().
total
();
TotalHits
totalHits
=
searchResponse
.
hits
().
total
();
object
.
set
(
"count"
,
ObjUtil
.
isNull
(
totalHits
)
?
0
:
totalHits
.
value
());
object
.
set
(
"count"
,
ObjUtil
.
isNull
(
totalHits
)
?
0
:
totalHits
.
value
());
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -194,7 +194,7 @@ public class ElasticSearchService {
...
@@ -194,7 +194,7 @@ public class ElasticSearchService {
for
(
Court
court
:
courtList
)
{
for
(
Court
court
:
courtList
)
{
List
<
String
>
ipScopes
=
StrUtil
.
splitTrim
(
court
.
getIpScope
(),
"-"
);
List
<
String
>
ipScopes
=
StrUtil
.
splitTrim
(
court
.
getIpScope
(),
"-"
);
try
{
try
{
List
<
String
>
ipRange
=
ipScopes
.
size
()
!=
2
?
new
ArrayList
<>(
)
:
IpUtils
.
getIPRange
(
ipScopes
.
get
(
0
),
ipScopes
.
get
(
1
),
3
);
List
<
String
>
ipRange
=
ipScopes
.
size
()
!=
2
?
Arrays
.
asList
(
"255.255.255.255"
,
"255.255.255.255"
)
:
IpUtils
.
getIPRange
(
ipScopes
.
get
(
0
),
ipScopes
.
get
(
1
),
3
);
ipRange
.
forEach
(
ip
->
boolQuery
.
should
(
q
->
q
.
prefix
(
pq
->
pq
.
field
(
"ip.keyword"
).
value
(
ip
))));
ipRange
.
forEach
(
ip
->
boolQuery
.
should
(
q
->
q
.
prefix
(
pq
->
pq
.
field
(
"ip.keyword"
).
value
(
ip
))));
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"IP段解析错误"
,
e
);
log
.
error
(
"IP段解析错误"
,
e
);
...
@@ -214,7 +214,7 @@ public class ElasticSearchService {
...
@@ -214,7 +214,7 @@ public class ElasticSearchService {
for
(
Court
court
:
courtList
)
{
for
(
Court
court
:
courtList
)
{
List
<
String
>
ipScopes
=
StrUtil
.
splitTrim
(
court
.
getIpScope
(),
"-"
);
List
<
String
>
ipScopes
=
StrUtil
.
splitTrim
(
court
.
getIpScope
(),
"-"
);
try
{
try
{
List
<
String
>
ipRange
=
ipScopes
.
size
()
!=
2
?
new
ArrayList
<>(
)
:
IpUtils
.
getIPRange
(
ipScopes
.
get
(
0
),
ipScopes
.
get
(
1
),
3
);
List
<
String
>
ipRange
=
ipScopes
.
size
()
!=
2
?
Arrays
.
asList
(
"255.255.255.255"
,
"255.255.255.255"
)
:
IpUtils
.
getIPRange
(
ipScopes
.
get
(
0
),
ipScopes
.
get
(
1
),
3
);
ipRange
.
forEach
(
ip
->
{
ipRange
.
forEach
(
ip
->
{
if
(
bucket
.
key
().
stringValue
().
startsWith
(
ip
))
{
if
(
bucket
.
key
().
stringValue
().
startsWith
(
ip
))
{
// 若此 IP 范围已存在,则取出并更新 sum
// 若此 IP 范围已存在,则取出并更新 sum
...
@@ -359,7 +359,7 @@ public class ElasticSearchService {
...
@@ -359,7 +359,7 @@ public class ElasticSearchService {
if
(
StrUtil
.
isNotBlank
(
ipScope
))
{
if
(
StrUtil
.
isNotBlank
(
ipScope
))
{
List
<
String
>
ipScopes
=
StrUtil
.
splitTrim
(
ipScope
,
"-"
);
List
<
String
>
ipScopes
=
StrUtil
.
splitTrim
(
ipScope
,
"-"
);
try
{
try
{
List
<
String
>
ipRange
=
ipScopes
.
size
()
!=
2
?
new
ArrayList
<>(
)
:
IpUtils
.
getIPRange
(
ipScopes
.
get
(
0
),
ipScopes
.
get
(
1
),
3
);
List
<
String
>
ipRange
=
ipScopes
.
size
()
!=
2
?
Arrays
.
asList
(
"255.255.255.255"
,
"255.255.255.255"
)
:
IpUtils
.
getIPRange
(
ipScopes
.
get
(
0
),
ipScopes
.
get
(
1
),
3
);
ipRange
.
forEach
(
ip
->
bq
.
should
(
q
->
q
.
prefix
(
pq
->
pq
.
field
(
"ip.keyword"
).
value
(
ip
))));
ipRange
.
forEach
(
ip
->
bq
.
should
(
q
->
q
.
prefix
(
pq
->
pq
.
field
(
"ip.keyword"
).
value
(
ip
))));
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"IP段解析错误"
,
e
);
log
.
error
(
"IP段解析错误"
,
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