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
f718a23a
Commit
f718a23a
authored
Jul 11, 2025
by
tianyiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 新增许可状态统计及QueryBuilderUtils工具类
parent
e0d04900
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
129 additions
and
38 deletions
+129
-38
ComprehensiveStatisticalAnalysisServiceImpl.java
...ice/impl/ComprehensiveStatisticalAnalysisServiceImpl.java
+96
-38
QueryBuilderUtils.java
...os/boot/module/statistcs/biz/utils/QueryBuilderUtils.java
+33
-0
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/service/impl/ComprehensiveStatisticalAnalysisServiceImpl.java
View file @
f718a23a
...
@@ -20,6 +20,7 @@ import com.yeejoin.amos.boot.module.common.api.entity.ESEquipmentInfo;
...
@@ -20,6 +20,7 @@ import com.yeejoin.amos.boot.module.common.api.entity.ESEquipmentInfo;
import
com.yeejoin.amos.boot.module.common.biz.utils.TechParamUtil
;
import
com.yeejoin.amos.boot.module.common.biz.utils.TechParamUtil
;
import
com.yeejoin.amos.boot.module.statistcs.biz.utils.JsonUtils
;
import
com.yeejoin.amos.boot.module.statistcs.biz.utils.JsonUtils
;
import
com.yeejoin.amos.boot.module.statistcs.biz.utils.MinioUtils
;
import
com.yeejoin.amos.boot.module.statistcs.biz.utils.MinioUtils
;
import
com.yeejoin.amos.boot.module.statistcs.biz.utils.QueryBuilderUtils
;
import
com.yeejoin.amos.boot.module.statistcs.factory.DynamicQueryBuilder
;
import
com.yeejoin.amos.boot.module.statistcs.factory.DynamicQueryBuilder
;
import
com.yeejoin.amos.boot.module.statistcs.factory.EnhancedDynamicQueryBuilder
;
import
com.yeejoin.amos.boot.module.statistcs.factory.EnhancedDynamicQueryBuilder
;
import
com.yeejoin.amos.boot.module.statistics.api.enums.*
;
import
com.yeejoin.amos.boot.module.statistics.api.enums.*
;
...
@@ -325,31 +326,42 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
...
@@ -325,31 +326,42 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
boolMust
.
must
(
queryBuilder
);
boolMust
.
must
(
queryBuilder
);
}
}
}
else
if
(
k
.
equals
(
"expiryDate"
))
{
}
else
if
(
k
.
equals
(
"expiryDate"
))
{
boolMust
.
must
(
existsQuery
(
nestedField
)
);
EnhancedDynamicQueryBuilder
enhancedDynamicQueryBuilder
=
new
EnhancedDynamicQueryBuilder
(
);
if
(
item
.
equals
(
"overdue"
))
{
if
(
item
.
equals
(
"overdue"
))
{
// 超期:小于当前日期
// 超期:小于当前日期
NestedQueryBuilder
nestedQuery
=
QueryBuilders
.
nestedQuery
(
NestedQueryBuilder
nestedQuery
=
QueryBuilders
.
nestedQuery
(
path
,
path
,
QueryBuilders
.
boolQuery
().
filter
(
QueryBuilders
.
rangeQuery
(
nestedField
).
lt
(
LocalDate
.
now
().
format
(
formatter
))),
QueryBuilders
.
boolQuery
().
must
(
QueryBuilders
.
rangeQuery
(
nestedField
).
lt
(
LocalDate
.
now
().
format
(
formatter
))),
ScoreMode
.
None
ScoreMode
.
None
);
);
boolMust
.
must
(
nestedQuery
);
enhancedDynamicQueryBuilder
.
add
(
nestedQuery
,
or
);
boolMust
.
must
(
enhancedDynamicQueryBuilder
.
build
());
}
else
if
(
item
.
equals
(
"near"
))
{
}
else
if
(
item
.
equals
(
"near"
))
{
// 临期:小于等于当前日期加上30天
// 临期:小于等于当前日期加上30天
NestedQueryBuilder
nestedQuery
=
QueryBuilders
.
nestedQuery
(
NestedQueryBuilder
nestedQuery
=
QueryBuilders
.
nestedQuery
(
path
,
path
,
QueryBuilders
.
boolQuery
().
filter
(
QueryBuilders
.
rangeQuery
(
nestedField
).
lte
(
LocalDate
.
now
().
plusDays
(
30
).
format
(
formatter
)).
gte
(
LocalDate
.
now
().
format
(
formatter
))),
QueryBuilders
.
boolQuery
().
must
(
QueryBuilders
.
rangeQuery
(
nestedField
).
lte
(
LocalDate
.
now
().
plusDays
(
30
).
format
(
formatter
)).
gte
(
LocalDate
.
now
().
format
(
formatter
))),
ScoreMode
.
None
ScoreMode
.
None
);
);
boolMust
.
must
(
nestedQuery
);
enhancedDynamicQueryBuilder
.
add
(
nestedQuery
,
or
);
boolMust
.
must
(
enhancedDynamicQueryBuilder
.
build
());
}
else
if
(
item
.
equals
(
"normal"
))
{
}
else
if
(
item
.
equals
(
"normal"
))
{
// 正常:大于当前日期加上30天
// 正常:大于当前日期加上30天
NestedQueryBuilder
nestedQuery
=
QueryBuilders
.
nestedQuery
(
NestedQueryBuilder
nestedQuery
=
QueryBuilders
.
nestedQuery
(
path
,
path
,
QueryBuilders
.
boolQuery
().
filter
(
QueryBuilders
.
rangeQuery
(
nestedField
).
gt
(
LocalDate
.
now
().
plusDays
(
30
).
format
(
formatter
))),
QueryBuilders
.
boolQuery
().
must
(
QueryBuilders
.
rangeQuery
(
nestedField
).
gt
(
LocalDate
.
now
().
plusDays
(
30
).
format
(
formatter
))),
ScoreMode
.
None
ScoreMode
.
None
);
);
boolMust
.
must
(
nestedQuery
);
enhancedDynamicQueryBuilder
.
add
(
nestedQuery
,
or
);
boolMust
.
must
(
enhancedDynamicQueryBuilder
.
build
());
}
else
if
(
item
.
equals
(
"none"
))
{
NestedQueryBuilder
nestedQuery
=
QueryBuilders
.
nestedQuery
(
path
,
QueryBuilders
.
boolQuery
().
must
(
QueryBuilders
.
existsQuery
(
nestedField
)),
ScoreMode
.
None
);
enhancedDynamicQueryBuilder
.
add
(
nestedQuery
,
or
);
boolMust
.
must
(
enhancedDynamicQueryBuilder
.
build
());
}
}
}
else
if
(
k
.
equals
(
"certType"
)
||
k
.
equals
(
"permissionLevel"
))
{
}
else
if
(
k
.
equals
(
"certType"
)
||
k
.
equals
(
"permissionLevel"
))
{
NestedQueryBuilder
nestedQuery
=
QueryBuilders
.
nestedQuery
(
NestedQueryBuilder
nestedQuery
=
QueryBuilders
.
nestedQuery
(
...
@@ -461,8 +473,8 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
...
@@ -461,8 +473,8 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
List
<
String
>
permissionStatusList
=
new
ArrayList
<>();
List
<
String
>
permissionStatusList
=
new
ArrayList
<>();
for
(
Object
object
:
licenses
)
{
for
(
Object
object
:
licenses
)
{
JSONObject
json
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
object
));
JSONObject
json
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
object
));
if
(!
json
.
containsKey
(
"
certNo
"
))
{
if
(!
json
.
containsKey
(
"
expiryDate
"
))
{
licensesStauts
=
"无
资质
"
;
licensesStauts
=
"无
有效期
"
;
continue
;
continue
;
}
}
String
expiryDate
=
json
.
getString
(
"expiryDate"
);
String
expiryDate
=
json
.
getString
(
"expiryDate"
);
...
@@ -480,12 +492,15 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
...
@@ -480,12 +492,15 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
long
cq
=
permissionStatusList
.
stream
().
filter
(
e
->
e
.
equals
(
"超期"
)).
count
();
long
cq
=
permissionStatusList
.
stream
().
filter
(
e
->
e
.
equals
(
"超期"
)).
count
();
long
lq
=
permissionStatusList
.
stream
().
filter
(
e
->
e
.
equals
(
"临期"
)).
count
();
long
lq
=
permissionStatusList
.
stream
().
filter
(
e
->
e
.
equals
(
"临期"
)).
count
();
long
zc
=
permissionStatusList
.
stream
().
filter
(
e
->
e
.
equals
(
"正常"
)).
count
();
long
zc
=
permissionStatusList
.
stream
().
filter
(
e
->
e
.
equals
(
"正常"
)).
count
();
long
no
=
permissionStatusList
.
stream
().
filter
(
e
->
e
.
equals
(
"无有效期"
)).
count
();
if
(
cq
>
0
)
{
if
(
cq
>
0
)
{
licensesStauts
=
"超期"
;
licensesStauts
=
"
资质
超期"
;
}
else
if
(
lq
>
0
)
{
}
else
if
(
lq
>
0
)
{
licensesStauts
=
"临期"
;
licensesStauts
=
"
资质
临期"
;
}
else
if
(
zc
>
0
)
{
}
else
if
(
zc
>
0
)
{
licensesStauts
=
"正常"
;
licensesStauts
=
"资质正常"
;
}
else
if
(
no
>
0
)
{
licensesStauts
=
"无有效期"
;
}
}
}
else
{
}
else
{
licensesStauts
=
"无资质"
;
licensesStauts
=
"无资质"
;
...
@@ -512,6 +527,10 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
...
@@ -512,6 +527,10 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
statics
.
add
(
sum
);
statics
.
add
(
sum
);
result
.
put
(
"statics"
,
statics
);
result
.
put
(
"statics"
,
statics
);
// 获取许可状态统计
List
<
Map
<
String
,
Object
>>
staticMap
=
new
ArrayList
<>();
getCompanyOrPersonPermitStatusStatic
(
boolMust
,
staticMap
,
StatisticalAnalysisEnum
.
person
.
getKey
());
result
.
put
(
"keyIndicator"
,
staticMap
);
return
result
;
return
result
;
}
}
...
@@ -714,6 +733,11 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
...
@@ -714,6 +733,11 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
statics
.
add
(
sum
);
statics
.
add
(
sum
);
result
.
put
(
"statics"
,
statics
);
result
.
put
(
"statics"
,
statics
);
// 获取许可状态统计
List
<
Map
<
String
,
Object
>>
staticMap
=
new
ArrayList
<>();
getCompanyOrPersonPermitStatusStatic
(
boolMust
,
staticMap
,
StatisticalAnalysisEnum
.
company
.
getKey
());
result
.
put
(
"keyIndicator"
,
staticMap
);
return
result
;
return
result
;
}
}
...
@@ -1068,6 +1092,54 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
...
@@ -1068,6 +1092,54 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
}
}
private
void
getCompanyOrPersonPermitStatusStatic
(
BoolQueryBuilder
boolMust
,
List
<
Map
<
String
,
Object
>>
statics
,
String
index
)
{
String
path
=
"licenses"
;
String
nestedField
=
path
+
".expiryDate"
;
BoolQueryBuilder
normalBoolQuery
=
QueryBuilderUtils
.
copyBoolQuery
(
boolMust
);
NestedQueryBuilder
normalNestedQuery
=
QueryBuilders
.
nestedQuery
(
path
,
QueryBuilders
.
boolQuery
().
must
(
QueryBuilders
.
rangeQuery
(
nestedField
).
gt
(
LocalDate
.
now
().
plusDays
(
30
).
format
(
formatter
))),
ScoreMode
.
None
);
normalBoolQuery
.
must
(
normalNestedQuery
);
Long
normalCount
=
getStaticCount
(
normalBoolQuery
,
index
);
BoolQueryBuilder
nearBoolQuery
=
QueryBuilderUtils
.
copyBoolQuery
(
boolMust
);
NestedQueryBuilder
nearNestedQuery
=
QueryBuilders
.
nestedQuery
(
path
,
QueryBuilders
.
boolQuery
().
must
(
QueryBuilders
.
rangeQuery
(
nestedField
).
lte
(
LocalDate
.
now
().
plusDays
(
30
).
format
(
formatter
)).
gte
(
LocalDate
.
now
().
format
(
formatter
))),
ScoreMode
.
None
);
nearBoolQuery
.
must
(
nearNestedQuery
);
Long
nearCount
=
getStaticCount
(
nearBoolQuery
,
StatisticalAnalysisEnum
.
company
.
getKey
());
Map
<
String
,
Object
>
normalMap
=
new
HashMap
<>();
normalMap
.
put
(
"name"
,
index
.
equals
(
StatisticalAnalysisEnum
.
company
.
getKey
())
?
"许可正常"
:
"资质正常"
);
normalMap
.
put
(
"value"
,
normalCount
);
statics
.
add
(
normalMap
);
Map
<
String
,
Object
>
nearMap
=
new
HashMap
<>();
nearMap
.
put
(
"name"
,
index
.
equals
(
StatisticalAnalysisEnum
.
company
.
getKey
())
?
"许可临期"
:
"资质临期"
);
nearMap
.
put
(
"value"
,
nearCount
);
statics
.
add
(
nearMap
);
}
private
Long
getStaticCount
(
BoolQueryBuilder
builder
,
String
index
)
{
CountRequest
countRequest
=
new
CountRequest
();
countRequest
.
indices
(
index
);
CountResponse
response
=
null
;
countRequest
.
query
(
builder
);
try
{
response
=
restHighLevelClient
.
count
(
countRequest
,
RequestOptions
.
DEFAULT
);
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
e
);
}
return
ObjectUtils
.
isEmpty
(
response
)
?
0
:
response
.
getCount
();
}
private
BigDecimal
getPipeLength
(
BoolQueryBuilder
boolMust
,
SearchSourceBuilder
builder
)
{
private
BigDecimal
getPipeLength
(
BoolQueryBuilder
boolMust
,
SearchSourceBuilder
builder
)
{
SearchRequest
request
=
new
SearchRequest
();
SearchRequest
request
=
new
SearchRequest
();
request
.
indices
(
StatisticalAnalysisEnum
.
equip
.
getKey
());
request
.
indices
(
StatisticalAnalysisEnum
.
equip
.
getKey
());
...
@@ -1881,25 +1953,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
...
@@ -1881,25 +1953,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
}
}
result
.
put
(
"certNo"
,
certNoData
);
result
.
put
(
"certNo"
,
certNoData
);
//资质状态
//资质状态
JSONArray
permissionStatus
=
new
JSONArray
();
result
.
put
(
"expiryDate"
,
queryExpiryDate
());
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
JSONObject
object
=
new
JSONObject
();
if
(
0
==
i
)
{
object
.
put
(
"key"
,
"overdue"
);
object
.
put
(
"value"
,
"overdue"
);
object
.
put
(
"label"
,
"资质超期"
);
}
else
if
(
1
==
i
)
{
object
.
put
(
"key"
,
"near"
);
object
.
put
(
"value"
,
"near"
);
object
.
put
(
"label"
,
"资质临期"
);
}
else
{
object
.
put
(
"key"
,
"normal"
);
object
.
put
(
"value"
,
"normal"
);
object
.
put
(
"label"
,
"正常"
);
}
permissionStatus
.
add
(
object
);
}
result
.
put
(
"expiryDate"
,
permissionStatus
);
//证书类型
//证书类型
List
<
DictionarieValueModel
>
certType
=
Systemctl
.
dictionarieClient
.
dictValues
(
"CERT_TYPE"
).
getResult
();
List
<
DictionarieValueModel
>
certType
=
Systemctl
.
dictionarieClient
.
dictValues
(
"CERT_TYPE"
).
getResult
();
JSONArray
certTypeArray
=
new
JSONArray
();
JSONArray
certTypeArray
=
new
JSONArray
();
...
@@ -2442,20 +2496,24 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
...
@@ -2442,20 +2496,24 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
public
JSONArray
queryExpiryDate
()
{
public
JSONArray
queryExpiryDate
()
{
//资质状态
//资质状态
JSONArray
permissionStatus
=
new
JSONArray
();
JSONArray
permissionStatus
=
new
JSONArray
();
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
for
(
int
i
=
0
;
i
<
4
;
i
++)
{
JSONObject
object
=
new
JSONObject
();
JSONObject
object
=
new
JSONObject
();
if
(
0
==
i
)
{
if
(
0
==
i
)
{
object
.
put
(
"key"
,
"
overdue
"
);
object
.
put
(
"key"
,
"
normal
"
);
object
.
put
(
"value"
,
"
overdue
"
);
object
.
put
(
"value"
,
"
normal
"
);
object
.
put
(
"label"
,
"资质
超期
"
);
object
.
put
(
"label"
,
"资质
正常
"
);
}
else
if
(
1
==
i
)
{
}
else
if
(
1
==
i
)
{
object
.
put
(
"key"
,
"near"
);
object
.
put
(
"key"
,
"near"
);
object
.
put
(
"value"
,
"near"
);
object
.
put
(
"value"
,
"near"
);
object
.
put
(
"label"
,
"资质临期"
);
object
.
put
(
"label"
,
"资质临期"
);
}
else
if
(
2
==
i
)
{
object
.
put
(
"key"
,
"overdue"
);
object
.
put
(
"value"
,
"overdue"
);
object
.
put
(
"label"
,
"资质超期"
);
}
else
{
}
else
{
object
.
put
(
"key"
,
"no
rmal
"
);
object
.
put
(
"key"
,
"no
ne
"
);
object
.
put
(
"value"
,
"no
rmal
"
);
object
.
put
(
"value"
,
"no
ne
"
);
object
.
put
(
"label"
,
"
正常
"
);
object
.
put
(
"label"
,
"
无有效期
"
);
}
}
permissionStatus
.
add
(
object
);
permissionStatus
.
add
(
object
);
}
}
...
...
amos-boot-system-tzs/amos-boot-module-statistics/amos-boot-module-statistics-biz/src/main/java/com/yeejoin/amos/boot/module/statistcs/biz/utils/QueryBuilderUtils.java
0 → 100644
View file @
f718a23a
package
com
.
yeejoin
.
amos
.
boot
.
module
.
statistcs
.
biz
.
utils
;
import
org.elasticsearch.index.query.BoolQueryBuilder
;
import
org.elasticsearch.index.query.QueryBuilders
;
public
class
QueryBuilderUtils
{
public
static
BoolQueryBuilder
copyBoolQuery
(
BoolQueryBuilder
original
)
{
if
(
original
==
null
)
{
return
QueryBuilders
.
boolQuery
();
}
BoolQueryBuilder
copy
=
QueryBuilders
.
boolQuery
();
// 复制查询条件
original
.
must
().
forEach
(
copy:
:
must
);
original
.
filter
().
forEach
(
copy:
:
filter
);
original
.
should
().
forEach
(
copy:
:
should
);
original
.
mustNot
().
forEach
(
copy:
:
mustNot
);
// 复制minimumShouldMatch设置(新版本方式)
if
(
original
.
minimumShouldMatch
()
!=
null
)
{
copy
.
minimumShouldMatch
(
original
.
minimumShouldMatch
());
}
// 复制其他属性
copy
.
boost
(
original
.
boost
());
copy
.
queryName
(
original
.
queryName
());
return
copy
;
}
}
\ 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