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
8f565915
Commit
8f565915
authored
Aug 26, 2025
by
tianyiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: 调整综合查询
parent
77fa2049
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
24 deletions
+52
-24
ComprehensiveStatisticalAnalysisServiceImpl.java
...ice/impl/ComprehensiveStatisticalAnalysisServiceImpl.java
+52
-24
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 @
8f565915
...
@@ -123,6 +123,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
...
@@ -123,6 +123,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
private
final
String
DOWNLOAD_TOPIC
=
"/topic/download/excel/%s"
;
private
final
String
DOWNLOAD_TOPIC
=
"/topic/download/excel/%s"
;
private
final
String
BUCKET_NAME
=
"upload"
;
private
final
String
BUCKET_NAME
=
"upload"
;
private
final
String
UPLOAD_PATH
=
"/tzs/excelTempFile"
;
private
final
String
UPLOAD_PATH
=
"/tzs/excelTempFile"
;
private
final
List
<
String
>
equList
=
Arrays
.
asList
(
"1000"
,
"2000"
,
"3000"
,
"4000"
,
"5000"
,
"6000"
,
"8000"
,
"9000"
);
// 大屏统计图片路径前缀
// 大屏统计图片路径前缀
private
final
String
dpEquipPhotoPrefix
=
"/upload/tzs/dpscreen/statistic/equip/"
;
private
final
String
dpEquipPhotoPrefix
=
"/upload/tzs/dpscreen/statistic/equip/"
;
// 大屏统计图片路径后缀
// 大屏统计图片路径后缀
...
@@ -955,27 +956,25 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
...
@@ -955,27 +956,25 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
throw
new
RuntimeException
(
e
);
throw
new
RuntimeException
(
e
);
}
}
Map
<
String
,
Object
>
sum
=
new
HashMap
<>();
sum
.
put
(
"name"
,
"设备总数(台套)"
);
sum
.
put
(
"value"
,
totle
);
statics
.
add
(
sum
);
BoolQueryBuilder
pipeQuery
=
QueryBuilderUtils
.
copyBoolQuery
(
boolMust
);
List
<
Map
<
String
,
Object
>>
equipStatusMap
=
new
ArrayList
<>();
List
<
Map
<
String
,
Object
>>
equipStatusMap
=
new
ArrayList
<>();
getEquipStatusStatic
(
boolMust
,
builder
,
equipStatusMap
);
getEquipStatusStatic
(
boolMust
,
builder
,
equipStatusMap
);
result
.
put
(
"keyIndicator"
,
equipStatusMap
);
result
.
put
(
"keyIndicator"
,
equipStatusMap
);
if
(
ObjectUtils
.
isEmpty
(
filterParams
)
||
!
filterParams
.
containsKey
(
"EQU_LIST"
))
{
String
equList
=
ObjectUtils
.
isEmpty
(
filterParams
)
||
""
.
equals
(
filterParams
.
get
(
"equList"
).
toString
())
?
"all"
:
filterParams
.
get
(
"equList"
).
toString
();
filterParams
=
new
JSONObject
();
String
equCategory
=
ObjectUtils
.
isEmpty
(
filterParams
)
||
""
.
equals
(
filterParams
.
get
(
"equCategory"
).
toString
())
?
"all"
:
filterParams
.
get
(
"equCategory"
).
toString
();
JSONArray
jsonArray
=
new
JSONArray
();
jsonArray
.
add
(
"all"
);
if
(!
equList
.
equals
(
"8000"
)
&&
!
equCategory
.
equals
(
"2300"
))
{
filterParams
.
put
(
"EQU_LIST"
,
jsonArray
);
BoolQueryBuilder
queryBuilder
=
QueryBuilderUtils
.
copyBoolQuery
(
boolMust
);
queryBuilder
.
mustNot
(
QueryBuilders
.
termQuery
(
"EQU_LIST_CODE"
,
"8000"
))
.
mustNot
(
QueryBuilders
.
termQuery
(
"EQU_CATEGORY_CODE"
,
"2300"
));
Long
count
=
getStatisticCount
(
queryBuilder
,
StatisticalAnalysisEnum
.
equip
.
getKey
());
Map
<
String
,
Object
>
sum
=
new
HashMap
<>();
sum
.
put
(
"name"
,
"设备总数(台套)"
);
sum
.
put
(
"value"
,
count
);
statics
.
add
(
sum
);
}
}
JSONArray
equList
=
(
JSONArray
)
filterParams
.
get
(
"EQU_LIST"
);
if
(
equList
.
contains
(
"8000"
)
||
equList
.
contains
(
"all"
))
{
if
(
ObjectUtils
.
isEmpty
(
equList
)
||
equList
.
contains
(
"8000"
)
||
equList
.
contains
(
"all"
))
{
// 获取压力管道长度
// 获取压力管道长度
BigDecimal
pipeLength
=
getPipeLength
(
boolMust
,
builder
,
"pipeLength"
);
BigDecimal
pipeLength
=
getPipeLength
(
boolMust
,
builder
,
"pipeLength"
);
Map
<
String
,
Object
>
pipeMap
=
new
HashMap
<>();
Map
<
String
,
Object
>
pipeMap
=
new
HashMap
<>();
...
@@ -984,7 +983,8 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
...
@@ -984,7 +983,8 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
statics
.
add
(
pipeMap
);
statics
.
add
(
pipeMap
);
}
}
if
(
ObjectUtils
.
isEmpty
(
equList
)
||
equList
.
contains
(
"2000"
)
||
equList
.
contains
(
"all"
))
{
if
(
equList
.
contains
(
"all"
)
||
(
equList
.
contains
(
"2000"
)
&&
"all"
.
equals
(
equCategory
))
||
equCategory
.
contains
(
"2300"
))
{
// 气瓶数量
// 气瓶数量
CountRequest
countRequest
=
new
CountRequest
();
CountRequest
countRequest
=
new
CountRequest
();
countRequest
.
indices
(
StatisticalAnalysisEnum
.
equip
.
getKey
());
countRequest
.
indices
(
StatisticalAnalysisEnum
.
equip
.
getKey
());
...
@@ -996,7 +996,6 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
...
@@ -996,7 +996,6 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
e
);
throw
new
RuntimeException
(
e
);
}
}
Map
<
String
,
Object
>
gasMap
=
new
HashMap
<>();
Map
<
String
,
Object
>
gasMap
=
new
HashMap
<>();
gasMap
.
put
(
"name"
,
"气瓶(个)"
);
gasMap
.
put
(
"name"
,
"气瓶(个)"
);
gasMap
.
put
(
"value"
,
ObjectUtils
.
isEmpty
(
response
)
?
0
:
response
.
getCount
());
gasMap
.
put
(
"value"
,
ObjectUtils
.
isEmpty
(
response
)
?
0
:
response
.
getCount
());
...
@@ -1030,6 +1029,8 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
...
@@ -1030,6 +1029,8 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
}
}
private
void
getEquipmentBoolQueryBuilder
(
BoolQueryBuilder
boolMust
,
JSONObject
filterParams
,
String
filterType
)
{
private
void
getEquipmentBoolQueryBuilder
(
BoolQueryBuilder
boolMust
,
JSONObject
filterParams
,
String
filterType
)
{
List
<
String
>
equListCodes
=
new
ArrayList
<>();
List
<
String
>
equCategoryCodes
=
new
ArrayList
<>();
//快捷筛选和自定义筛选解析筛选规则不一致
//快捷筛选和自定义筛选解析筛选规则不一致
if
(
filterType
.
equals
(
"advanced"
))
{
if
(
filterType
.
equals
(
"advanced"
))
{
JSONObject
finalFilterParams
=
filterParams
;
JSONObject
finalFilterParams
=
filterParams
;
...
@@ -1098,10 +1099,13 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
...
@@ -1098,10 +1099,13 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
boolMust
.
filter
(
QueryBuilders
.
rangeQuery
(
field
).
gte
(
startDate
).
lte
(
endDate
));
boolMust
.
filter
(
QueryBuilders
.
rangeQuery
(
field
).
gte
(
startDate
).
lte
(
endDate
));
}
}
}
else
if
(
k
.
equals
(
"EQU_LIST"
)
||
k
.
equals
(
"EQU_CATEGORY"
)
||
k
.
equals
(
"EQU_DEFINE"
)
||
k
.
equals
(
"DATA_QUALITY_SCORE"
))
{
}
else
if
(
k
.
equals
(
"EQU_LIST"
)
||
k
.
equals
(
"EQU_CATEGORY"
)
||
k
.
equals
(
"EQU_DEFINE"
)
||
k
.
equals
(
"DATA_QUALITY_SCORE"
))
{
JSONArray
jsonArray
=
(
JSONArray
)
v
;
if
(
k
.
equals
(
"EQU_LIST"
))
{
if
(
k
.
equals
(
"EQU_LIST"
))
{
field
=
"EQU_LIST_CODE"
;
field
=
"EQU_LIST_CODE"
;
equListCodes
.
addAll
((
jsonArray
).
toJavaList
(
String
.
class
));
}
else
if
(
k
.
equals
(
"EQU_CATEGORY"
))
{
}
else
if
(
k
.
equals
(
"EQU_CATEGORY"
))
{
field
=
"EQU_CATEGORY_CODE"
;
field
=
"EQU_CATEGORY_CODE"
;
equCategoryCodes
.
addAll
((
jsonArray
).
toJavaList
(
String
.
class
));
}
else
if
(
k
.
equals
(
"EQU_DEFINE"
))
{
}
else
if
(
k
.
equals
(
"EQU_DEFINE"
))
{
field
=
"EQU_DEFINE_CODE"
;
field
=
"EQU_DEFINE_CODE"
;
}
}
...
@@ -1180,27 +1184,51 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
...
@@ -1180,27 +1184,51 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
}
else
{
}
else
{
JSONArray
leftGroup
=
filterParams
.
getJSONArray
(
"group1"
);
JSONArray
leftGroup
=
filterParams
.
getJSONArray
(
"group1"
);
JSONArray
rightGroup
=
filterParams
.
getJSONArray
(
"group2"
);
JSONArray
rightGroup
=
filterParams
.
getJSONArray
(
"group2"
);
JSONArray
equListCodes
=
new
JSONArray
();
leftGroup
.
forEach
(
item
->
{
leftGroup
.
forEach
(
item
->
{
JSONObject
left
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
item
));
JSONObject
left
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
item
));
String
leftField
=
left
.
getString
(
"field"
);
String
leftField
=
left
.
getString
(
"field"
);
String
leftValue
=
left
.
getString
(
"value"
);
String
leftValue
=
left
.
getString
(
"value"
);
String
leftItemCondition
=
left
.
getString
(
"itemCondition"
);
if
(!
ObjectUtils
.
isEmpty
(
leftField
)
&&
leftField
.
equals
(
"EQU_LIST_CODE"
)
&&
!
ObjectUtils
.
isEmpty
(
leftValue
))
{
if
(!
ObjectUtils
.
isEmpty
(
leftField
)
&&
leftField
.
equals
(
"EQU_LIST_CODE"
)
&&
!
ObjectUtils
.
isEmpty
(
leftValue
))
{
equListCodes
.
add
(
leftValue
);
if
(
"in"
.
equals
(
leftItemCondition
)
||
"eq"
.
equals
(
leftItemCondition
))
{
equListCodes
.
add
(
leftValue
);
}
else
{
//todo
}
}
if
(!
ObjectUtils
.
isEmpty
(
leftField
)
&&
leftField
.
equals
(
"EQU_CATEGORY_CODE"
)
&&
!
ObjectUtils
.
isEmpty
(
leftValue
))
{
if
(
"in"
.
equals
(
leftItemCondition
)
||
"eq"
.
equals
(
leftItemCondition
))
{
equCategoryCodes
.
add
(
leftValue
);
}
else
{
// todo
}
}
}
});
});
rightGroup
.
forEach
(
item
->
{
rightGroup
.
forEach
(
item
->
{
JSONObject
left
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
item
));
JSONObject
right
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
item
));
String
rightField
=
left
.
getString
(
"field"
);
String
rightField
=
right
.
getString
(
"field"
);
String
rightValue
=
left
.
getString
(
"value"
);
String
rightValue
=
right
.
getString
(
"value"
);
String
rightItemCondition
=
right
.
getString
(
"itemCondition"
);
if
(!
ObjectUtils
.
isEmpty
(
rightField
)
&&
rightField
.
equals
(
"EQU_LIST_CODE"
)
&&
!
ObjectUtils
.
isEmpty
(
rightValue
))
{
if
(!
ObjectUtils
.
isEmpty
(
rightField
)
&&
rightField
.
equals
(
"EQU_LIST_CODE"
)
&&
!
ObjectUtils
.
isEmpty
(
rightValue
))
{
equListCodes
.
add
(
rightValue
);
if
(
"in"
.
equals
(
rightItemCondition
)
||
"eq"
.
equals
(
rightItemCondition
))
{
equListCodes
.
add
(
rightValue
);
}
else
{
// todo
}
}
if
(!
ObjectUtils
.
isEmpty
(
rightField
)
&&
rightField
.
equals
(
"EQU_CATEGORY_CODE"
)
&&
!
ObjectUtils
.
isEmpty
(
rightValue
))
{
if
(
"in"
.
equals
(
rightItemCondition
)
||
"eq"
.
equals
(
rightItemCondition
))
{
equCategoryCodes
.
add
(
rightValue
);
}
else
{
// todo
}
}
}
});
});
filterParams
.
put
(
"EQU_LIST"
,
equListCodes
);
Boolean
isOrGroup
=
or
.
equals
(
filterParams
.
getString
(
"groupAndOr"
))
?
Boolean
.
TRUE
:
Boolean
.
FALSE
;
Boolean
isOrGroup
=
or
.
equals
(
filterParams
.
getString
(
"groupAndOr"
))
?
Boolean
.
TRUE
:
Boolean
.
FALSE
;
handleAdvancedFilter
(
boolMust
,
leftGroup
,
rightGroup
,
isOrGroup
,
StatisticalAnalysisEnum
.
equip
.
getCode
());
handleAdvancedFilter
(
boolMust
,
leftGroup
,
rightGroup
,
isOrGroup
,
StatisticalAnalysisEnum
.
equip
.
getCode
());
}
}
filterParams
.
put
(
"equList"
,
String
.
join
(
","
,
equListCodes
));
filterParams
.
put
(
"equCategory"
,
String
.
join
(
","
,
equCategoryCodes
));
}
}
private
void
getEquipStatusStatic
(
BoolQueryBuilder
boolMust
,
SearchSourceBuilder
builder
,
List
<
Map
<
String
,
Object
>>
statics
)
{
private
void
getEquipStatusStatic
(
BoolQueryBuilder
boolMust
,
SearchSourceBuilder
builder
,
List
<
Map
<
String
,
Object
>>
statics
)
{
...
...
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