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
9efb7698
Commit
9efb7698
authored
Jul 16, 2025
by
tianbo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(statistics): 修复下钻查询总数不正确的问题
-移除了不必要的 .keyword 后缀,使用 prefixQuery 查询 superviseOrgCode
parent
a2a3fa8b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
33 deletions
+37
-33
ComprehensiveStatisticalAnalysisServiceImpl.java
...ice/impl/ComprehensiveStatisticalAnalysisServiceImpl.java
+36
-32
JGDPStatisticsServiceImpl.java
...statistcs/biz/service/impl/JGDPStatisticsServiceImpl.java
+1
-1
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 @
9efb7698
...
...
@@ -257,7 +257,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
BoolQueryBuilder
boolMust
=
QueryBuilders
.
boolQuery
();
String
orgCode
=
filter
.
getString
(
"orgCode"
);
boolMust
.
must
(
QueryBuilders
.
prefixQuery
(
"superviseOrgCode
.keyword
"
,
orgCode
));
boolMust
.
must
(
QueryBuilders
.
prefixQuery
(
"superviseOrgCode"
,
orgCode
));
JSONObject
filterParams
=
null
;
if
(!
ObjectUtils
.
isEmpty
(
filter
.
get
(
"filterParams"
)))
{
...
...
@@ -2669,7 +2669,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
boolMust
.
must
(
QueryBuilders
.
prefixQuery
(
"superviseOrgCode.keyword"
,
orgCode
));
data
=
queryDpCompanyStatistics
(
filter
,
request
,
builder
,
boolMust
,
tabTotalMap
);
}
else
{
boolMust
.
must
(
QueryBuilders
.
prefixQuery
(
"superviseOrgCode
.keyword
"
,
orgCode
));
boolMust
.
must
(
QueryBuilders
.
prefixQuery
(
"superviseOrgCode"
,
orgCode
));
data
=
queryDpPersonStatistics
(
filter
,
request
,
builder
,
boolMust
,
tabTotalMap
);
}
...
...
@@ -2695,7 +2695,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
BoolQueryBuilder
companyBoolMust
=
QueryBuilders
.
boolQuery
();
companyBoolMust
.
must
(
QueryBuilders
.
prefixQuery
(
"superviseOrgCode.keyword"
,
orgCode
));
BoolQueryBuilder
personBoolMust
=
QueryBuilders
.
boolQuery
();
personBoolMust
.
must
(
QueryBuilders
.
prefixQuery
(
"superviseOrgCode
.keyword
"
,
orgCode
));
personBoolMust
.
must
(
QueryBuilders
.
prefixQuery
(
"superviseOrgCode"
,
orgCode
));
String
equipIndex
=
StatisticalAnalysisEnum
.
equip
.
getKey
();
String
companyIndex
=
StatisticalAnalysisEnum
.
company
.
getKey
();
String
personIndex
=
StatisticalAnalysisEnum
.
person
.
getKey
();
...
...
@@ -2830,7 +2830,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
request
.
indices
(
StatisticalAnalysisEnum
.
company
.
getKey
());
JSONObject
filterParams
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
filter
.
get
(
"filterParams"
)));
String
unitCategory
=
filterParams
.
getString
(
"unitCategory"
);
String
unitType
=
filterParams
.
getJSONArray
(
"unitType"
).
getString
(
0
);
// 构造企业查询条件
filter
.
put
(
"filterType"
,
"advanced"
);
getCompanyBoolQueryBuilder
(
filter
,
boolMust
);
...
...
@@ -2846,11 +2846,20 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
}
else
{
// 二级统计
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
// 使用单位:使用单位,个人主体 返回管控级别和所属行业
String
unitType
=
filterParams
.
getJSONArray
(
"unitType"
).
getString
(
0
);
// 使用单位:使用单位 返回管控级别和所属行业;个人主体 前端不下钻
boolMust
.
must
(
QueryBuilders
.
matchQuery
(
"unitType"
,
unitType
));
if
(
unitCategory
.
equals
(
UnitCategoryEnum
.
use
.
getCode
()))
{
JSONObject
regulatoryLabels
=
this
.
getItemGroupStatisticsByItemName
(
boolMust
,
StatisticalAnalysisEnum
.
company
.
getKey
(),
"regulatoryLabelsAggName"
,
"regulatoryLabels"
,
this
::
buildRegulatoryLabelsGroupResult
);
JSONObject
industrySupervisor
=
this
.
getItemGroupStatisticsByItemName
(
boolMust
,
StatisticalAnalysisEnum
.
company
.
getKey
(),
"industrySupervisorAggName"
,
"industrySupervisor"
,
this
::
buildIndustrySupervisorGroupResult
);
JSONObject
regulatoryLabels
=
this
.
getItemGroupStatisticsByItemName
(
boolMust
,
StatisticalAnalysisEnum
.
company
.
getKey
(),
"regulatoryLabelsAggName"
,
"regulatoryLabels"
,
this
::
buildRegulatoryLabelsGroupResult
);
JSONObject
industrySupervisor
=
this
.
getItemGroupStatisticsByItemName
(
boolMust
,
StatisticalAnalysisEnum
.
company
.
getKey
(),
"industrySupervisorAggName"
,
"industrySupervisor"
,
this
::
buildIndustrySupervisorGroupResult
);
result
.
put
(
"tabTotalMap"
,
new
JSONObject
()
.
fluentPut
(
"regulatoryLabelsTotal"
,
this
.
sumWithJSONObjectValues
(
regulatoryLabels
))
.
fluentPut
(
"industrySupervisorTotal"
,
this
.
sumWithJSONObjectValues
(
industrySupervisor
)));
...
...
@@ -3078,7 +3087,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
BoolQueryBuilder
boolQuery
=
QueryBuilders
.
boolQuery
();
String
orgCode
=
filter
.
getString
(
"orgCode"
);
boolQuery
.
must
(
QueryBuilders
.
prefixQuery
(
"superviseOrgCode
.keyword
"
,
orgCode
));
boolQuery
.
must
(
QueryBuilders
.
prefixQuery
(
"superviseOrgCode"
,
orgCode
));
JSONObject
filterParams
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
filter
.
get
(
"filterParams"
)));
String
filterType
=
"advanced"
;
...
...
@@ -3269,22 +3278,10 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
try
{
SearchResponse
searchResponse
=
restHighLevelClient
.
search
(
searchRequest
,
RequestOptions
.
DEFAULT
);
Terms
itemGroupAgg
=
searchResponse
.
getAggregations
().
get
(
aggName
);
// this.buildGroupResult(itemGroupAgg, result);
task
.
accept
(
itemGroupAgg
,
result
);
}
catch
(
Exception
ex
)
{
throw
new
RuntimeException
(
ex
);
}
CountRequest
countRequest
=
new
CountRequest
();
countRequest
.
indices
(
indexName
);
countRequest
.
query
(
boolQueryCopy
);
CountResponse
countResponse
;
try
{
countResponse
=
restHighLevelClient
.
count
(
countRequest
,
RequestOptions
.
DEFAULT
);
}
catch
(
Exception
exception
)
{
throw
new
RuntimeException
(
exception
);
}
result
.
put
(
"total"
,
ObjectUtils
.
isEmpty
(
countResponse
)
?
0L
:
countResponse
.
getCount
());
return
result
;
}
...
...
@@ -3327,7 +3324,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
String
bucketKey
=
bucket
.
getKeyAsString
();
for
(
Object
obj
:
regulatoryLabels
)
{
JSONObject
jsonObject
=
(
JSONObject
)
obj
;
result
.
put
(
jsonObject
.
getString
(
"
valu
e"
),
0
);
result
.
put
(
jsonObject
.
getString
(
"
extendCod
e"
),
0
);
if
(
jsonObject
.
getString
(
"label"
).
equals
(
bucketKey
))
{
result
.
put
(
jsonObject
.
getString
(
"extendCode"
),
bucket
.
getDocCount
());
break
;
...
...
@@ -3344,18 +3341,25 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
return
;
}
JSONArray
industrySupervisor
=
deployDictionary
(
dataDictionaryService
.
getByType
(
"HYZGBM"
));
// 枚举遍历 + 动态匹配
for
(
Terms
.
Bucket
bucket
:
groupAgg
.
getBuckets
())
{
String
bucketKey
=
bucket
.
getKeyAsString
();
for
(
Object
obj
:
industrySupervisor
)
{
JSONObject
jsonObject
=
(
JSONObject
)
obj
;
result
.
put
(
jsonObject
.
getString
(
"value"
),
0
);
if
(
jsonObject
.
getString
(
"label"
).
equals
(
bucketKey
)
)
{
result
.
put
(
jsonObject
.
getString
(
"value"
),
bucket
.
getDocCount
()
);
break
;
Map
<
String
,
String
>
keyToValueMap
=
new
HashMap
<>();
for
(
Object
obj
:
industrySupervisor
)
{
if
(
obj
instanceof
JSONObject
)
{
String
key
=
((
JSONObject
)
obj
).
getString
(
"key"
)
;
String
value
=
((
JSONObject
)
obj
).
getString
(
"value"
);
if
(
key
!=
null
&&
value
!=
null
)
{
keyToValueMap
.
put
(
key
,
value
);
result
.
put
(
value
,
0
);
// 初始化为 0
}
}
if
(
bucketKey
.
equals
(
"其他"
))
{
}
// 处理 buckets
for
(
Terms
.
Bucket
bucket
:
groupAgg
.
getBuckets
())
{
String
bucketKey
=
bucket
.
getKeyAsString
();
String
mappedValue
=
keyToValueMap
.
get
(
bucketKey
);
if
(
mappedValue
!=
null
)
{
result
.
put
(
mappedValue
,
bucket
.
getDocCount
());
}
else
if
(
"其他"
.
equals
(
bucketKey
))
{
result
.
put
(
"other"
,
bucket
.
getDocCount
());
}
}
...
...
@@ -3403,7 +3407,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
BoolQueryBuilder
nothingBoolQuery
=
QueryBuilderUtils
.
copyBoolQuery
(
boolQuery
);
NestedQueryBuilder
nothingNestedQuery
=
QueryBuilders
.
nestedQuery
(
path
,
QueryBuilders
.
boolQuery
().
must
(
QueryBuilders
.
existsQuery
(
nestedField
)),
QueryBuilders
.
boolQuery
().
must
Not
(
QueryBuilders
.
existsQuery
(
nestedField
)),
ScoreMode
.
None
);
nothingBoolQuery
.
must
(
nothingNestedQuery
);
...
...
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/JGDPStatisticsServiceImpl.java
View file @
9efb7698
...
...
@@ -454,7 +454,7 @@ public class JGDPStatisticsServiceImpl {
builder
.
trackTotalHits
(
true
);
request
.
indices
(
key
);
BoolQueryBuilder
boolMust
=
QueryBuilders
.
boolQuery
();
boolMust
.
must
(
QueryBuilders
.
prefixQuery
(
"superviseOrgCode
.keyword
"
,
orgCode
));
boolMust
.
must
(
QueryBuilders
.
prefixQuery
(
"superviseOrgCode"
,
orgCode
));
Long
personSum
=
statisticalAnalysisService
.
getStatisticCount
(
boolMust
,
key
);
boolMust
.
must
(
QueryBuilders
.
matchQuery
(
"newPost"
,
"6552"
));
Long
operatorsNum
=
statisticalAnalysisService
.
getStatisticCount
(
boolMust
,
key
);
...
...
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