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
e0f4ab54
Commit
e0f4ab54
authored
Jul 03, 2025
by
yangyang
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop_tzs_register' of…
Merge branch 'develop_tzs_register' of
http://39.100.92.250:5000/moa/amos-boot-biz
into develop_tzs_register
parents
6eb94bc0
54a74bd0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
86 additions
and
48 deletions
+86
-48
ComprehensiveStatisticalAnalysisServiceImpl.java
...ice/impl/ComprehensiveStatisticalAnalysisServiceImpl.java
+86
-48
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 @
e0f4ab54
...
...
@@ -55,6 +55,8 @@ import java.time.LocalDate;
import
java.time.format.DateTimeFormatter
;
import
java.util.*
;
import
static
org
.
elasticsearch
.
index
.
query
.
QueryBuilders
.
existsQuery
;
/**
* 综合统计分析服务实现类
*
...
...
@@ -193,6 +195,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
page
.
setRecords
(
new
ArrayList
<>());
page
.
setTotal
(
0
);
result
.
put
(
"pageData"
,
page
);
result
.
put
(
"businessType"
,
businessType
);
return
result
;
}
if
(
StatisticalAnalysisEnum
.
equip
.
getCode
().
equals
(
businessType
))
{
...
...
@@ -202,6 +205,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
}
else
{
result
=
queryPersonPage
(
filter
,
page
,
current
,
size
);
}
result
.
put
(
"businessType"
,
businessType
);
return
result
;
}
...
...
@@ -229,30 +233,53 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
if
(!((
JSONArray
)
v
).
contains
(
"all"
))
{
String
field
=
k
;
if
(
k
.
equals
(
"equipType"
)
||
k
.
equals
(
"unitType"
)
||
k
.
equals
(
"newPost"
)
||
k
.
equals
(
"subPost"
))
{
boolMust
.
must
(
QueryBuilders
.
existsQuery
(
field
));
boolMust
.
must
(
existsQuery
(
field
));
((
JSONArray
)
v
).
forEach
(
item
->
boolMust
.
must
(
QueryBuilders
.
wildcardQuery
(
k
.
equals
(
"equipType"
)
?
field
:
field
+
".keyword"
,
"*"
+
item
+
"*"
)));
// boolMust.minimumShouldMatch(1);
}
else
if
(
k
.
equals
(
"education"
))
{
boolMust
.
must
(
QueryBuilders
.
existsQuery
(
field
));
boolMust
.
must
(
existsQuery
(
field
));
TermsQueryBuilder
termsQuery
=
QueryBuilders
.
termsQuery
(
field
,
(
JSONArray
)
v
);
boolMust
.
must
(
termsQuery
);
}
else
if
(
k
.
equals
(
"certNo"
)
||
k
.
equals
(
"expiryDate"
)
||
k
.
equals
(
"permissionLevel"
)
||
k
.
equals
(
"certType"
)
||
k
.
equals
(
"jobItem"
)
||
k
.
equals
(
"permissionItem"
))
{
String
path
=
"licenses"
;
((
JSONArray
)
v
).
forEach
(
item
->
{
String
nestedField
=
path
+
"."
+
k
;
// 根据证书编号判断有无资质
if
(
k
.
equals
(
"certNo"
))
{
NestedQueryBuilder
nestedQuery
=
QueryBuilders
.
nestedQuery
(
path
,
QueryBuilders
.
existsQuery
(
nestedField
),
existsQuery
(
nestedField
),
ScoreMode
.
Avg
);
// 以下人员类型有资质要求
// 人员类型(newPost):检验人员:66151、检测人员:66152
// 人员子类型(subPost): 持证人员:6712、持证人员(P):6764、持证人员(R2):6765
if
(
item
.
equals
(
"1"
))
{
boolMust
.
must
(
nestedQuery
);
}
else
{
}
else
if
(
item
.
equals
(
"0"
))
{
// 无资质
BoolQueryBuilder
queryBuilder
=
QueryBuilders
.
boolQuery
()
.
should
(
QueryBuilders
.
wildcardQuery
(
"newPost.keyword"
,
"*66151*"
))
.
should
(
QueryBuilders
.
wildcardQuery
(
"newPost.keyword"
,
"*66152*"
))
.
should
(
QueryBuilders
.
wildcardQuery
(
"subPost.keyword"
,
"*6712*"
))
.
should
(
QueryBuilders
.
wildcardQuery
(
"subPost.keyword"
,
"*6764*"
))
.
should
(
QueryBuilders
.
wildcardQuery
(
"subPost.keyword"
,
"*6765*"
))
.
minimumShouldMatch
(
1
);
boolMust
.
must
(
queryBuilder
);
boolMust
.
mustNot
(
nestedQuery
);
}
else
{
// 无资质要求
BoolQueryBuilder
queryBuilder
=
QueryBuilders
.
boolQuery
()
.
mustNot
(
QueryBuilders
.
wildcardQuery
(
"newPost.keyword"
,
"*66151*"
))
.
mustNot
(
QueryBuilders
.
wildcardQuery
(
"newPost.keyword"
,
"*66152*"
))
.
mustNot
(
QueryBuilders
.
wildcardQuery
(
"subPost.keyword"
,
"*6712*"
))
.
mustNot
(
QueryBuilders
.
wildcardQuery
(
"subPost.keyword"
,
"*6764*"
))
.
mustNot
(
QueryBuilders
.
wildcardQuery
(
"subPost.keyword"
,
"*6765*"
));
boolMust
.
must
(
queryBuilder
);
}
}
else
if
(
k
.
equals
(
"expiryDate"
))
{
boolMust
.
must
(
existsQuery
(
nestedField
));
if
(
item
.
equals
(
"overdue"
))
{
// 超期:小于当前日期
NestedQueryBuilder
nestedQuery
=
QueryBuilders
.
nestedQuery
(
...
...
@@ -277,14 +304,6 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
ScoreMode
.
Avg
);
boolMust
.
must
(
nestedQuery
);
}
else
{
// 无资质要求
NestedQueryBuilder
nestedQuery
=
QueryBuilders
.
nestedQuery
(
path
,
QueryBuilders
.
existsQuery
(
nestedField
),
ScoreMode
.
Avg
);
boolMust
.
mustNot
(
nestedQuery
);
}
}
else
if
(
k
.
equals
(
"certType"
)
||
k
.
equals
(
"permissionLevel"
))
{
NestedQueryBuilder
nestedQuery
=
QueryBuilders
.
nestedQuery
(
...
...
@@ -393,7 +412,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
BoolQueryBuilder
boolMust
=
QueryBuilders
.
boolQuery
();
String
orgCode
=
filter
.
getString
(
"orgCode"
);
boolMust
.
must
(
QueryBuilders
.
prefixQuery
(
"superviseOrgCode"
,
orgCode
));
boolMust
.
must
(
QueryBuilders
.
prefixQuery
(
"superviseOrgCode
.keyword
"
,
orgCode
));
JSONObject
filterParams
=
null
;
if
(!
ObjectUtils
.
isEmpty
(
filter
.
get
(
"filterParams"
)))
{
filterParams
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
filter
.
get
(
"filterParams"
)));
...
...
@@ -405,11 +424,11 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
if
(!((
JSONArray
)
v
).
contains
(
"all"
))
{
String
field
=
k
;
if
(
k
.
equals
(
"regulatoryLabels"
)
||
k
.
equals
(
"equipCategory"
)
||
k
.
equals
(
"unitType"
))
{
boolMust
.
must
(
QueryBuilders
.
existsQuery
(
field
));
boolMust
.
must
(
existsQuery
(
field
));
((
JSONArray
)
v
).
forEach
(
item
->
boolMust
.
should
(
QueryBuilders
.
wildcardQuery
(
field
+
".keyword"
,
"*"
+
item
+
"*"
)));
boolMust
.
minimumShouldMatch
(
1
);
}
else
if
(
k
.
equals
(
"industrySupervisor"
)
||
k
.
equals
(
"operatingStatus"
))
{
boolMust
.
must
(
QueryBuilders
.
existsQuery
(
field
));
boolMust
.
must
(
existsQuery
(
field
));
TermsQueryBuilder
termsQuery
=
QueryBuilders
.
termsQuery
(
field
+
".keyword"
,
((
JSONArray
)
v
).
get
(
0
));
boolMust
.
must
(
termsQuery
);
}
else
if
(
k
.
equals
(
"itemCode"
)
||
k
.
equals
(
"subItemCode"
)
||
k
.
equals
(
"permitStatus"
))
{
...
...
@@ -550,7 +569,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
boolMust
.
must
(
queryBuilder
.
build
());
}
else
if
(
k
.
equals
(
"NEXT_INSPECT_DATE"
))
{
String
finalField
=
field
;
boolMust
.
must
(
QueryBuilders
.
existsQuery
(
finalField
));
boolMust
.
must
(
existsQuery
(
finalField
));
EnhancedDynamicQueryBuilder
queryBuilder
=
new
EnhancedDynamicQueryBuilder
();
((
JSONArray
)
v
).
forEach
(
item
->
{
if
(
item
.
equals
(
"overdue"
))
{
...
...
@@ -567,7 +586,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
boolMust
.
must
(
queryBuilder
.
build
());
}
else
if
(
k
.
equals
(
"USC_DATE"
))
{
String
finalField
=
field
;
boolMust
.
must
(
QueryBuilders
.
existsQuery
(
finalField
));
boolMust
.
must
(
existsQuery
(
finalField
));
EnhancedDynamicQueryBuilder
queryBuilder
=
new
EnhancedDynamicQueryBuilder
();
((
JSONArray
)
v
).
forEach
(
item
->
{
if
(
item
.
equals
(
"15"
))
{
...
...
@@ -589,10 +608,10 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
String
finalField
=
k
;
((
JSONArray
)
v
).
forEach
(
item
->
{
if
(
item
.
equals
(
"1"
))
{
boolMust
.
must
(
QueryBuilders
.
existsQuery
(
finalField
));
boolMust
.
must
(
existsQuery
(
finalField
));
boolMust
.
mustNot
(
QueryBuilders
.
termQuery
(
finalField
,
"null"
));
}
else
{
boolMust
.
mustNot
(
QueryBuilders
.
existsQuery
(
finalField
));
boolMust
.
mustNot
(
existsQuery
(
finalField
));
}
});
}
else
if
(
k
.
equals
(
"createDate"
))
{
...
...
@@ -608,7 +627,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
}
else
if
(
k
.
equals
(
"EQU_DEFINE"
))
{
field
=
"EQU_DEFINE_CODE"
;
}
boolMust
.
must
(
QueryBuilders
.
existsQuery
(
field
));
boolMust
.
must
(
existsQuery
(
field
));
TermsQueryBuilder
termsQuery
=
QueryBuilders
.
termsQuery
(
field
,
(
JSONArray
)
v
);
boolMust
.
must
(
termsQuery
);
}
...
...
@@ -932,7 +951,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
Object
value
=
itemObj
.
get
(
"value"
);
String
andOr
=
itemObj
.
getString
(
"andOr"
);
// 组装查询条件
getItemQuery
New
(
field
,
itemCondition
,
value
,
andOr
,
builder
);
getItemQuery
(
field
,
itemCondition
,
value
,
andOr
,
builder
);
}
}
...
...
@@ -952,7 +971,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
});
}
private
void
getItemQuery
New
(
String
field
,
String
itemCondition
,
Object
value
,
String
isOr
,
EnhancedDynamicQueryBuilder
builder
)
{
private
void
getItemQuery
(
String
field
,
String
itemCondition
,
Object
value
,
String
isOr
,
EnhancedDynamicQueryBuilder
builder
)
{
// 如果包含需要特殊处理的字段,则调用对应的处理方法,否则调用通用处理方法
if
(
equipHandleOtherFields
.
contains
(
field
)
||
companyHandleOtherFields
.
contains
(
field
)
||
personHandleOtherFields
.
contains
(
field
))
{
handleOtherField
(
field
,
itemCondition
,
value
,
isOr
,
builder
);
...
...
@@ -1023,13 +1042,49 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
if
(
field
.
equals
(
"certNo"
))
{
NestedQueryBuilder
nestedQuery
=
QueryBuilders
.
nestedQuery
(
path
,
QueryBuilders
.
existsQuery
(
nestedField
),
existsQuery
(
nestedField
),
ScoreMode
.
Avg
);
if
(
itemCondition
.
equals
(
"eq"
)
||
itemCondition
.
equals
(
"in"
))
{
builder
.
add
(
value
.
equals
(
"1"
)
?
nestedQuery
:
QueryBuilders
.
boolQuery
().
mustNot
(
nestedQuery
),
isOr
);
// 无资质查询
BoolQueryBuilder
noCertQuery
=
QueryBuilders
.
boolQuery
()
.
should
(
QueryBuilders
.
wildcardQuery
(
"newPost.keyword"
,
"*66151*"
))
.
should
(
QueryBuilders
.
wildcardQuery
(
"newPost.keyword"
,
"*66152*"
))
.
should
(
QueryBuilders
.
wildcardQuery
(
"subPost.keyword"
,
"*6712*"
))
.
should
(
QueryBuilders
.
wildcardQuery
(
"subPost.keyword"
,
"*6764*"
))
.
should
(
QueryBuilders
.
wildcardQuery
(
"subPost.keyword"
,
"*6765*"
))
.
minimumShouldMatch
(
1
);
// 无资质要求查询
BoolQueryBuilder
noCertRequestQuery
=
QueryBuilders
.
boolQuery
()
.
mustNot
(
QueryBuilders
.
wildcardQuery
(
"newPost.keyword"
,
"*66151*"
))
.
mustNot
(
QueryBuilders
.
wildcardQuery
(
"newPost.keyword"
,
"*66152*"
))
.
mustNot
(
QueryBuilders
.
wildcardQuery
(
"subPost.keyword"
,
"*6712*"
))
.
mustNot
(
QueryBuilders
.
wildcardQuery
(
"subPost.keyword"
,
"*6764*"
))
.
mustNot
(
QueryBuilders
.
wildcardQuery
(
"subPost.keyword"
,
"*6765*"
));
if
(
value
.
equals
(
"1"
))
{
if
(
itemCondition
.
equals
(
"eq"
)
||
itemCondition
.
equals
(
"in"
))
{
builder
.
add
(
nestedQuery
,
isOr
);
}
else
{
builder
.
add
(
QueryBuilders
.
boolQuery
().
mustNot
(
nestedQuery
),
isOr
);
}
}
else
if
(
value
.
equals
(
"0"
))
{
if
(
itemCondition
.
equals
(
"eq"
)
||
itemCondition
.
equals
(
"in"
))
{
builder
.
add
(
noCertQuery
,
isOr
);
}
else
{
EnhancedDynamicQueryBuilder
builders
=
new
EnhancedDynamicQueryBuilder
();
builders
.
add
(
nestedQuery
,
and
);
builders
.
add
(
noCertRequestQuery
,
and
);
builder
.
add
(
builders
.
build
(),
isOr
);
}
}
else
{
builder
.
add
(
value
.
equals
(
"1"
)
?
QueryBuilders
.
boolQuery
().
mustNot
(
nestedQuery
)
:
nestedQuery
,
isOr
);
if
(
itemCondition
.
equals
(
"eq"
)
||
itemCondition
.
equals
(
"in"
))
{
builder
.
add
(
noCertRequestQuery
,
isOr
);
}
else
{
EnhancedDynamicQueryBuilder
builders
=
new
EnhancedDynamicQueryBuilder
();
builders
.
add
(
nestedQuery
,
and
);
builders
.
add
(
noCertQuery
,
and
);
builder
.
add
(
builders
.
build
(),
isOr
);
}
}
}
else
if
(
field
.
equals
(
"expiryDate"
))
{
if
(
value
.
equals
(
"overdue"
))
{
...
...
@@ -1067,14 +1122,8 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
QueryBuilders
.
boolQuery
().
filter
(
QueryBuilders
.
rangeQuery
(
nestedField
).
gt
(
LocalDate
.
now
().
plusDays
(
30
).
format
(
formatter
))),
ScoreMode
.
Avg
);
NestedQueryBuilder
noLicensesNestedQuery
=
QueryBuilders
.
nestedQuery
(
path
,
QueryBuilders
.
existsQuery
(
nestedField
),
ScoreMode
.
Avg
);
builder
.
add
(
overdueNestedQuery
,
or
);
builder
.
add
(
normalNestedQuery
,
or
);
builder
.
add
(
noLicensesNestedQuery
,
or
);
}
}
else
if
(
value
.
equals
(
"normal"
))
{
if
(
itemCondition
.
equals
(
"eq"
)
||
itemCondition
.
equals
(
"in"
))
{
...
...
@@ -1092,22 +1141,10 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
);
NestedQueryBuilder
noLicensesNestedQuery
=
QueryBuilders
.
nestedQuery
(
path
,
QueryBuilders
.
existsQuery
(
nestedField
),
existsQuery
(
nestedField
),
ScoreMode
.
Avg
);
builder
.
add
(
elseNestedQuery
,
or
);
builder
.
add
(
noLicensesNestedQuery
,
or
);
}
}
else
{
NestedQueryBuilder
nestedQuery
=
QueryBuilders
.
nestedQuery
(
path
,
QueryBuilders
.
existsQuery
(
nestedField
),
ScoreMode
.
Avg
);
if
(
itemCondition
.
equals
(
"eq"
)
||
itemCondition
.
equals
(
"in"
))
{
builder
.
add
(
nestedQuery
,
isOr
);
}
else
{
builder
.
add
(
QueryBuilders
.
boolQuery
().
mustNot
(
nestedQuery
),
isOr
);
}
}
}
else
{
...
...
@@ -1248,10 +1285,11 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
}
}
}
else
if
(
field
.
equals
(
"IS_SUPERVISORY_CODE"
))
{
String
finalField
=
"SUPERVISORY_CODE"
;
if
(
value
.
equals
(
"1"
))
{
builder
.
add
(
QueryBuilders
.
boolQuery
().
must
(
QueryBuilders
.
existsQuery
(
field
)).
mustNot
(
QueryBuilders
.
termsQuery
(
f
ield
,
"null"
)),
isOr
);
builder
.
add
(
QueryBuilders
.
boolQuery
().
must
(
existsQuery
(
finalField
)).
mustNot
(
QueryBuilders
.
termsQuery
(
finalF
ield
,
"null"
)),
isOr
);
}
else
{
builder
.
add
(
QueryBuilders
.
boolQuery
().
mustNot
(
QueryBuilders
.
existsQuery
(
f
ield
)),
isOr
);
builder
.
add
(
QueryBuilders
.
boolQuery
().
mustNot
(
existsQuery
(
finalF
ield
)),
isOr
);
}
}
else
if
(
field
.
equals
(
"USC_DATE"
))
{
if
(
value
.
equals
(
"15"
))
{
...
...
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