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
5e52fc76
Commit
5e52fc76
authored
Jul 15, 2025
by
tianyiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: 使用新枚举并优化统计逻辑
parent
43236926
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
30 deletions
+71
-30
UnitTypeEnum.java
...n/amos/boot/module/statistics/api/enums/UnitTypeEnum.java
+1
-3
UnitTypeNewEnum.java
...mos/boot/module/statistics/api/enums/UnitTypeNewEnum.java
+3
-3
ComprehensiveStatisticalAnalysisServiceImpl.java
...ice/impl/ComprehensiveStatisticalAnalysisServiceImpl.java
+67
-24
No files found.
amos-boot-system-tzs/amos-boot-module-statistics/amos-boot-module-statistics-api/src/main/java/com/yeejoin/amos/boot/module/statistics/api/enums/UnitTypeEnum.java
View file @
5e52fc76
...
...
@@ -23,9 +23,7 @@ public enum UnitTypeEnum {
azgzwxdw
(
"安装改造维修单位"
,
"1234"
,
"license"
),
zzdw
(
"制造单位"
,
"1236"
,
"license"
),
sjdw
(
"设计单位"
,
"1235"
,
"license"
),
grzt
(
"个人主体"
,
"6599"
,
"use"
),
jyjg
(
"检验机构"
,
"1233-1"
,
"license"
),
jcjg
(
"检测机构"
,
"1233-2"
,
"license"
);
grzt
(
"个人主体"
,
"6599"
,
"use"
);
private
String
name
;
private
String
code
;
...
...
amos-boot-system-tzs/amos-boot-module-statistics/amos-boot-module-statistics-api/src/main/java/com/yeejoin/amos/boot/module/statistics/api/enums/UnitTypeNewEnum.java
View file @
5e52fc76
...
...
@@ -12,15 +12,15 @@ import java.util.Map;
@AllArgsConstructor
@Getter
public
enum
UnitTypeNewEnum
{
// todo 检验单位和检测单位的code待确认
/**
* *注册单位类型
*/
sydw
(
"企业"
,
"使用单位"
,
"1232"
,
"use"
),
czdw
(
"充装单位"
,
"充装单位"
,
"1231"
,
"license"
),
jy
dw
(
"检验单位"
,
"检验单位"
,
"1233
1"
,
"license"
),
jc
dw
(
"检测单位"
,
"检测单位"
,
"1233
"
,
"license"
),
jy
jg
(
"检验机构"
,
"检验机构"
,
"1233-
1"
,
"license"
),
jc
jg
(
"检测机构"
,
"检测机构"
,
"1233-2
"
,
"license"
),
azgzwxdw
(
"安装改造维修单位"
,
"安装改造维修单位"
,
"1234"
,
"license"
),
zzdw
(
"制造单位"
,
"制造单位"
,
"1236"
,
"license"
),
sjdw
(
"设计单位"
,
"设计单位"
,
"1235"
,
"license"
),
...
...
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 @
5e52fc76
...
...
@@ -112,6 +112,8 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
private
final
String
UPLOAD_PATH
=
"/tzs/excelTempFile"
;
// 大屏统计图片路径前缀
private
final
String
dpEquipPhotoPrefix
=
"/upload/tzs/dpscreen/statistic/equip/"
;
// 大屏统计图片路径后缀
private
final
String
dpEquipPhotoSuffix
=
".png"
;
private
final
List
<
String
>
equipHandleOtherFields
=
Arrays
.
asList
(
"techParam"
,
"paramRange"
,
"JDJY"
,
"DQJY"
,
"SCJY"
,
"DTJY"
,
"QZ_OR_TANK"
);
private
final
List
<
String
>
companyHandleOtherFields
=
Arrays
.
asList
(
"itemCode"
,
"subItemCode"
,
"permitStatus"
,
"equipCategory"
,
"regulatoryLabels"
,
"unitType"
);
...
...
@@ -2712,25 +2714,25 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
if
(
bucket
.
getKeyAsString
().
equals
(
UnitTypeEnum
.
sydw
.
getName
()))
{
result
.
put
(
"sydw"
,
bucket
.
getDocCount
());
}
if
(
bucket
.
getKeyAsString
().
equals
(
UnitType
Enum
.
grzt
.
getName
()))
{
if
(
bucket
.
getKeyAsString
().
equals
(
UnitType
NewEnum
.
grzt
.
getLabel
()))
{
result
.
put
(
"grzt"
,
bucket
.
getDocCount
());
}
if
(
bucket
.
getKeyAsString
().
equals
(
UnitType
Enum
.
sjdw
.
getName
()))
{
if
(
bucket
.
getKeyAsString
().
equals
(
UnitType
NewEnum
.
sjdw
.
getLabel
()))
{
result
.
put
(
"sjdw"
,
bucket
.
getDocCount
());
}
if
(
bucket
.
getKeyAsString
().
equals
(
UnitType
Enum
.
zzdw
.
getName
()))
{
if
(
bucket
.
getKeyAsString
().
equals
(
UnitType
NewEnum
.
zzdw
.
getLabel
()))
{
result
.
put
(
"zzdw"
,
bucket
.
getDocCount
());
}
if
(
bucket
.
getKeyAsString
().
equals
(
UnitType
Enum
.
azgzwxdw
.
getName
()))
{
if
(
bucket
.
getKeyAsString
().
equals
(
UnitType
NewEnum
.
azgzwxdw
.
getLabel
()))
{
result
.
put
(
"azgzwxdw"
,
bucket
.
getDocCount
());
}
if
(
bucket
.
getKeyAsString
().
equals
(
UnitType
Enum
.
czdw
.
getName
()))
{
if
(
bucket
.
getKeyAsString
().
equals
(
UnitType
NewEnum
.
czdw
.
getLabel
()))
{
result
.
put
(
"czdw"
,
bucket
.
getDocCount
());
}
if
(
bucket
.
getKeyAsString
().
equals
(
UnitType
Enum
.
jyjg
.
getName
()))
{
if
(
bucket
.
getKeyAsString
().
equals
(
UnitType
NewEnum
.
jyjg
.
getLabel
()))
{
result
.
put
(
"jyjg"
,
bucket
.
getDocCount
());
}
if
(
bucket
.
getKeyAsString
().
equals
(
UnitType
Enum
.
jcjg
.
getName
()))
{
if
(
bucket
.
getKeyAsString
().
equals
(
UnitType
NewEnum
.
jcjg
.
getLabel
()))
{
result
.
put
(
"jcjg"
,
bucket
.
getDocCount
());
}
}
...
...
@@ -2793,34 +2795,75 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
staticCountByGroupMap
=
resourceJson
.
get
(
EquipmentClassifityEnum
.
ZHTJFX
.
getCode
());
}
SearchSourceBuilder
nextInspectBuilder
=
new
SearchSourceBuilder
();
List
<
Map
<
String
,
Long
>>
staticCountByGroup
=
new
ArrayList
<>();
Map
<
String
,
Long
>
staticCountByGroup
=
new
HashMap
<>();
getStatisticCountByGroup
(
request
,
builder
,
boolMust
,
groupField
,
staticCountByGroup
);
Long
otherCount
=
staticCountByGroup
.
stream
().
map
(
item
->
item
.
values
().
stream
().
reduce
(
0L
,
Long:
:
sum
)).
reduce
(
0L
,
Long:
:
sum
);
Long
otherCount
=
staticCountByGroup
.
values
().
stream
().
reduce
(
0L
,
Long:
:
sum
);
tabTotalMap
.
put
(
StatisticalAnalysisEnum
.
equip
.
getCode
(),
otherCount
);
// 组装数据
for
(
Map
<
String
,
Object
>
map
:
staticCountByGroupMap
)
{
}
return
staticCountByGroupMap
;
}
private
void
getStatisticCountByGroup
(
SearchRequest
request
,
SearchSourceBuilder
builder
,
BoolQueryBuilder
boolMust
,
String
groupField
,
List
<
Map
<
String
,
Long
>>
staticCountByGroup
)
{
List
<
Map
<
String
,
Object
>>
dataMapList
=
new
ArrayList
<>();
for
(
Map
<
String
,
Object
>
categoryMap
:
staticCountByGroupMap
)
{
String
code
=
categoryMap
.
get
(
"value"
).
toString
();
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
putAll
(
categoryMap
);
map
.
put
(
"value"
,
staticCountByGroup
.
get
(
code
));
map
.
put
(
"img"
,
dpEquipPhotoPrefix
+
code
+
dpEquipPhotoSuffix
);
map
.
put
(
"measurementUnit"
,
"台套"
);
// 统计该分类下的数据完整性的分组数量 DATA_QUALITY_SCORE
BoolQueryBuilder
scoreQuery
=
QueryBuilderUtils
.
copyBoolQuery
(
boolMust
);
scoreQuery
.
must
(
QueryBuilders
.
termQuery
(
groupField
,
code
));
SearchSourceBuilder
scoreBuilder
=
new
SearchSourceBuilder
();
Map
<
String
,
Long
>
scoreCountByGroup
=
new
HashMap
<>();
getStatisticCountByGroup
(
request
,
scoreBuilder
,
scoreQuery
,
"DATA_QUALITY_SCORE"
,
scoreCountByGroup
);
map
.
put
(
"DATA_QUALITY_SCORE"
,
scoreCountByGroup
);
// 统计该分类下红黄绿码分别的分组数量 NEXT_INSPECT_DATE
Map
<
String
,
Long
>
nextInspectCountByGroup
=
new
HashMap
<>();
BoolQueryBuilder
nextInspectQuery
=
QueryBuilderUtils
.
copyBoolQuery
(
boolMust
);
nextInspectQuery
.
must
(
QueryBuilders
.
termQuery
(
groupField
,
code
));
getStatisticCountByDate
(
StatisticalAnalysisEnum
.
equip
.
getKey
(),
nextInspectQuery
,
nextInspectCountByGroup
);
getStatisticCountByGroup
(
request
,
nextInspectBuilder
,
nextInspectQuery
,
"NEXT_INSPECT_DATE"
,
nextInspectCountByGroup
);
map
.
put
(
"NEXT_INSPECT_DATE"
,
nextInspectCountByGroup
);
dataMapList
.
add
(
map
);
}
return
dataMapList
;
}
private
void
getStatisticCountByDate
(
String
key
,
BoolQueryBuilder
nextInspectQuery
,
Map
<
String
,
Long
>
nextInspectCountByGroup
)
{
// 超期
// BoolQueryBuilder overdueQuery = QueryBuilderUtils.copyBoolQuery(nextInspectQuery);
// overdueQuery.must(QueryBuilders.rangeQuery("NEXT_INSPECT_DATE").lte(DateUtils.addDays(new Date(), -1)));
// if (item.equals("overdue")) {
// // 超期:小于当前日期
// queryBuilder.add(QueryBuilders.boolQuery().filter(QueryBuilders.rangeQuery(finalField).lt(LocalDate.now().format(formatter))), or);
// } else if (item.equals("near")) {
// // 临期:小于等于当前日期加上30天
// queryBuilder.add(QueryBuilders.boolQuery().filter(QueryBuilders.rangeQuery(finalField).gte(LocalDate.now().format(formatter)).lte(LocalDate.now().plusDays(30).format(formatter))), or);
// } else if (item.equals("normal")) {
// // 正常:大于当前日期加上30天
// queryBuilder.add(QueryBuilders.boolQuery().filter(QueryBuilders.rangeQuery(finalField).gt(LocalDate.now().plusDays(30).format(formatter))), or);
// } else {
// queryBuilder.add(QueryBuilders.boolQuery().mustNot(QueryBuilders.existsQuery(finalField)), or);
// }
// 临期
// 正常
// 无日期
}
private
void
getStatisticCountByGroup
(
SearchRequest
request
,
SearchSourceBuilder
builder
,
BoolQueryBuilder
boolMust
,
String
groupField
,
Map
<
String
,
Long
>
staticCountByGroup
)
{
builder
.
query
(
boolMust
);
builder
.
aggregation
(
AggregationBuilders
.
terms
(
groupField
).
field
(
groupField
).
missing
(
"null"
));
builder
.
aggregation
(
AggregationBuilders
.
terms
(
"groupCount"
).
field
(
groupField
));
request
.
source
(
builder
);
try
{
SearchResponse
response
=
restHighLevelClient
.
search
(
request
,
RequestOptions
.
DEFAULT
);
Terms
terms
=
response
.
getAggregations
().
get
(
groupField
);
Terms
terms
=
response
.
getAggregations
().
get
(
"groupCount"
);
for
(
Terms
.
Bucket
bucket
:
terms
.
getBuckets
())
{
Map
<
String
,
Long
>
groupMap
=
new
HashMap
<>();
groupMap
.
put
(
bucket
.
getKeyAsString
(),
bucket
.
getDocCount
());
staticCountByGroup
.
add
(
groupMap
);
staticCountByGroup
.
put
(
bucket
.
getKeyAsString
(),
bucket
.
getDocCount
());
}
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
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