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
d3970aba
Commit
d3970aba
authored
Jul 14, 2025
by
tianyiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: 提交大屏综合统计查询接口
parent
bee59c90
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
261 additions
and
120 deletions
+261
-120
StatisticalAnalysisEnum.java
.../module/statistics/api/enums/StatisticalAnalysisEnum.java
+9
-0
ComprehensiveStatisticalAnalysisController.java
...ontroller/ComprehensiveStatisticalAnalysisController.java
+2
-2
ComprehensiveStatisticalAnalysisServiceImpl.java
...ice/impl/ComprehensiveStatisticalAnalysisServiceImpl.java
+249
-117
QueryBuilderUtils.java
...os/boot/module/statistcs/biz/utils/QueryBuilderUtils.java
+1
-1
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/StatisticalAnalysisEnum.java
View file @
d3970aba
...
@@ -34,6 +34,15 @@ public enum StatisticalAnalysisEnum {
...
@@ -34,6 +34,15 @@ public enum StatisticalAnalysisEnum {
}
}
}
}
public
static
Map
<
String
,
String
>
getKey
=
new
HashMap
<>();
static
{
for
(
StatisticalAnalysisEnum
e
:
StatisticalAnalysisEnum
.
values
())
{
getKey
.
put
(
e
.
code
,
e
.
key
);
}
}
/**
/**
* 根据code获取枚举实例(优化版)
* 根据code获取枚举实例(优化版)
* @param code 枚举编码
* @param code 枚举编码
...
...
amos-boot-system-tzs/amos-boot-module-statistics/amos-boot-module-statistics-biz/src/main/java/com/yeejoin/amos/boot/module/statistcs/biz/controller/ComprehensiveStatisticalAnalysisController.java
View file @
d3970aba
...
@@ -189,11 +189,11 @@ public class ComprehensiveStatisticalAnalysisController extends BaseController {
...
@@ -189,11 +189,11 @@ public class ComprehensiveStatisticalAnalysisController extends BaseController {
* @return inspectStatus
* @return inspectStatus
*/
*/
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@PostMapping
(
value
=
"/dp/
page
"
)
@PostMapping
(
value
=
"/dp/
statistics
"
)
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"大屏综合统计查询接口"
,
notes
=
"大屏综合统计查询接口"
)
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"大屏综合统计查询接口"
,
notes
=
"大屏综合统计查询接口"
)
public
ResponseModel
<
JSONObject
>
queryDpStatistics
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
public
ResponseModel
<
JSONObject
>
queryDpStatistics
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
JSONObject
jsonObject
=
new
JSONObject
(
map
);
JSONObject
jsonObject
=
new
JSONObject
(
map
);
return
ResponseHelper
.
buildResponse
(
statisticalAnalysisService
.
query
ForPage
(
jsonObject
));
return
ResponseHelper
.
buildResponse
(
statisticalAnalysisService
.
query
DpStatistics
(
jsonObject
));
}
}
/**
/**
...
...
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 @
d3970aba
...
@@ -552,7 +552,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
...
@@ -552,7 +552,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
BoolQueryBuilder
boolMust
=
QueryBuilders
.
boolQuery
();
BoolQueryBuilder
boolMust
=
QueryBuilders
.
boolQuery
();
String
orgCode
=
filter
.
getString
(
"orgCode"
);
String
orgCode
=
filter
.
getString
(
"orgCode"
);
boolMust
.
must
(
QueryBuilders
.
prefixQuery
(
"superviseOrgCode
.keyword
"
,
orgCode
));
boolMust
.
must
(
QueryBuilders
.
prefixQuery
(
"superviseOrgCode"
,
orgCode
));
JSONObject
filterParams
=
null
;
JSONObject
filterParams
=
null
;
if
(!
ObjectUtils
.
isEmpty
(
filter
.
get
(
"filterParams"
)))
{
if
(!
ObjectUtils
.
isEmpty
(
filter
.
get
(
"filterParams"
)))
{
filterParams
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
filter
.
get
(
"filterParams"
)));
filterParams
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
filter
.
get
(
"filterParams"
)));
...
@@ -781,6 +781,125 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
...
@@ -781,6 +781,125 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
if
(!
ObjectUtils
.
isEmpty
(
filter
.
get
(
"filterParams"
)))
{
if
(!
ObjectUtils
.
isEmpty
(
filter
.
get
(
"filterParams"
)))
{
filterParams
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
filter
.
get
(
"filterParams"
)));
filterParams
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
filter
.
get
(
"filterParams"
)));
String
filterType
=
filter
.
getString
(
"filterType"
);
String
filterType
=
filter
.
getString
(
"filterType"
);
// 组装查询条件
getEquipmentBoolQueryBuilder
(
boolMust
,
filterParams
,
filterType
);
}
// 排序
if
(!
ObjectUtils
.
isEmpty
(
filter
.
get
(
"sort"
)))
{
JSONObject
sort
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
filter
.
get
(
"sort"
)));
String
field
=
sort
.
getString
(
"field"
);
if
(
field
.
equals
(
"EQU_LIST"
))
{
field
=
"EQU_LIST_CODE"
;
}
else
if
(
field
.
equals
(
"EQU_CATEGORY"
))
{
field
=
"EQU_CATEGORY_CODE"
;
}
else
if
(
field
.
equals
(
"EQU_DEFINE"
))
{
field
=
"EQU_DEFINE_CODE"
;
}
else
if
(
field
.
equals
(
"ORG_BRANCH_NAME"
))
{
field
=
"ORG_BRANCH_CODE"
;
}
else
if
(
field
.
equals
(
"USE_UNIT_NAME"
))
{
field
=
"USE_UNIT_CREDIT_CODE"
;
}
builder
.
sort
(
field
,
sort
.
getString
(
"order"
).
equals
(
"desc"
)
?
SortOrder
.
DESC
:
SortOrder
.
ASC
);
}
builder
.
query
(
boolMust
);
List
<
Map
<
String
,
Object
>>
statics
=
new
ArrayList
<>();
builder
.
from
((
current
-
1
)
*
size
);
builder
.
size
(
size
);
request
.
source
(
builder
);
List
<
JSONObject
>
list
=
new
LinkedList
<>();
long
totle
=
0
;
try
{
SearchResponse
response
=
restHighLevelClient
.
search
(
request
,
RequestOptions
.
DEFAULT
);
for
(
SearchHit
hit
:
response
.
getHits
().
getHits
())
{
JSONObject
jsonObject
=
(
JSONObject
)
JSONObject
.
toJSON
(
hit
);
JSONObject
dto
=
jsonObject
.
getJSONObject
(
"sourceAsMap"
);
dto
.
put
(
"record"
,
dto
.
get
(
"SEQUENCE_NBR"
));
dto
.
put
(
"equipAddress"
,
dto
.
get
(
"USE_PLACE"
)
+
"/"
+
dto
.
get
(
"ADDRESS"
));
String
dataQualityScore
=
ObjectUtils
.
isEmpty
(
dto
.
get
(
"DATA_QUALITY_SCORE"
))
?
null
:
DataQualityScoreEnum
.
getLabelByCode
(
dto
.
get
(
"DATA_QUALITY_SCORE"
).
toString
());
dto
.
put
(
"DATA_QUALITY_SCORE"
,
dataQualityScore
);
dto
.
put
(
"WHETHER_VEHICLE_CYLINDER"
,
ObjectUtils
.
isEmpty
(
dto
.
get
(
"WHETHER_VEHICLE_CYLINDER"
))
?
""
:
"1"
.
equals
(
dto
.
get
(
"WHETHER_VEHICLE_CYLINDER"
))
?
"是"
:
"否"
);
dto
.
put
(
"WHETHER_SKID_MOUNTED_PRESSURE_VESSEL"
,
ObjectUtils
.
isEmpty
(
dto
.
get
(
"WHETHER_SKID_MOUNTED_PRESSURE_VESSEL"
))
?
""
:
"1"
.
equals
(
dto
.
get
(
"WHETHER_SKID_MOUNTED_PRESSURE_VESSEL"
))
?
"是"
:
"否"
);
dto
.
put
(
"whetherSphericalTank"
,
ObjectUtils
.
isEmpty
(
dto
.
get
(
"whetherSphericalTank"
))
?
""
:
"1"
.
equals
(
dto
.
get
(
"whetherSphericalTank"
))
?
"是"
:
"否"
);
dto
.
put
(
"EQU_STATE"
,
ObjectUtils
.
isEmpty
(
dto
.
get
(
"EQU_STATE"
))
?
"无状态"
:
EquipStateEnum
.
getNameByCode
(
dto
.
get
(
"EQU_STATE"
).
toString
()));
String
inspectStatus
=
"无下次检验日期"
;
if
(
dto
.
containsKey
(
"NEXT_INSPECT_DATE"
))
{
String
nextInspectDate
=
dto
.
getString
(
"NEXT_INSPECT_DATE"
);
long
daysBetween
=
ChronoUnit
.
DAYS
.
between
(
LocalDate
.
now
(),
LocalDate
.
parse
(
nextInspectDate
,
formatter
));
if
(
daysBetween
<=
0
)
{
inspectStatus
=
"超期"
;
}
else
if
(
daysBetween
<=
30
)
{
inspectStatus
=
"临期"
;
}
else
{
inspectStatus
=
"正常"
;
}
dto
.
put
(
"inspectStatus"
,
inspectStatus
);
}
else
{
dto
.
put
(
"inspectStatus"
,
inspectStatus
);
}
list
.
add
(
dto
);
}
totle
=
Objects
.
requireNonNull
(
response
.
getInternalResponse
().
hits
().
getTotalHits
()).
value
;
page
.
setRecords
(
list
);
page
.
setTotal
(
totle
);
result
.
put
(
"pageData"
,
page
);
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
e
);
}
Map
<
String
,
Object
>
sum
=
new
HashMap
<>();
sum
.
put
(
"name"
,
"设备总数(台套)"
);
sum
.
put
(
"value"
,
totle
);
statics
.
add
(
sum
);
List
<
Map
<
String
,
Object
>>
equipStatusMap
=
new
ArrayList
<>();
getEquipStatusStatic
(
boolMust
,
builder
,
equipStatusMap
);
result
.
put
(
"keyIndicator"
,
equipStatusMap
);
if
(
ObjectUtils
.
isEmpty
(
filterParams
)
||
!
filterParams
.
containsKey
(
"EQU_LIST"
))
{
filterParams
=
new
JSONObject
();
JSONArray
jsonArray
=
new
JSONArray
();
jsonArray
.
add
(
"all"
);
filterParams
.
put
(
"EQU_LIST"
,
jsonArray
);
}
JSONArray
equList
=
(
JSONArray
)
filterParams
.
get
(
"EQU_LIST"
);
if
(
ObjectUtils
.
isEmpty
(
equList
)
||
equList
.
contains
(
"8000"
)
||
equList
.
contains
(
"all"
))
{
// 获取压力管道长度
BigDecimal
pipeLength
=
getPipeLength
(
boolMust
,
builder
);
Map
<
String
,
Object
>
pipeMap
=
new
HashMap
<>();
pipeMap
.
put
(
"name"
,
"压力管道(千米)"
);
pipeMap
.
put
(
"value"
,
pipeLength
.
divide
(
new
BigDecimal
(
1000
),
4
,
BigDecimal
.
ROUND_HALF_UP
));
statics
.
add
(
pipeMap
);
}
if
(
ObjectUtils
.
isEmpty
(
equList
)
||
equList
.
contains
(
"2000"
)
||
equList
.
contains
(
"all"
))
{
// 气瓶数量
CountRequest
countRequest
=
new
CountRequest
();
countRequest
.
indices
(
StatisticalAnalysisEnum
.
equip
.
getKey
());
boolMust
.
must
(
QueryBuilders
.
termQuery
(
"EQU_CATEGORY_CODE"
,
"2300"
));
countRequest
.
query
(
boolMust
);
CountResponse
response
=
null
;
try
{
response
=
restHighLevelClient
.
count
(
countRequest
,
RequestOptions
.
DEFAULT
);
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
e
);
}
Map
<
String
,
Object
>
gasMap
=
new
HashMap
<>();
gasMap
.
put
(
"name"
,
"气瓶(个)"
);
gasMap
.
put
(
"value"
,
ObjectUtils
.
isEmpty
(
response
)
?
0
:
response
.
getCount
());
statics
.
add
(
gasMap
);
}
result
.
put
(
"statics"
,
statics
);
return
result
;
}
private
void
getEquipmentBoolQueryBuilder
(
BoolQueryBuilder
boolMust
,
JSONObject
filterParams
,
String
filterType
)
{
//快捷筛选和自定义筛选解析筛选规则不一致
//快捷筛选和自定义筛选解析筛选规则不一致
if
(
filterType
.
equals
(
"advanced"
))
{
if
(
filterType
.
equals
(
"advanced"
))
{
JSONObject
finalFilterParams
=
filterParams
;
JSONObject
finalFilterParams
=
filterParams
;
...
@@ -951,120 +1070,6 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
...
@@ -951,120 +1070,6 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
}
}
}
}
// 排序
if
(!
ObjectUtils
.
isEmpty
(
filter
.
get
(
"sort"
)))
{
JSONObject
sort
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
filter
.
get
(
"sort"
)));
String
field
=
sort
.
getString
(
"field"
);
if
(
field
.
equals
(
"EQU_LIST"
))
{
field
=
"EQU_LIST_CODE"
;
}
else
if
(
field
.
equals
(
"EQU_CATEGORY"
))
{
field
=
"EQU_CATEGORY_CODE"
;
}
else
if
(
field
.
equals
(
"EQU_DEFINE"
))
{
field
=
"EQU_DEFINE_CODE"
;
}
else
if
(
field
.
equals
(
"ORG_BRANCH_NAME"
))
{
field
=
"ORG_BRANCH_CODE"
;
}
else
if
(
field
.
equals
(
"USE_UNIT_NAME"
))
{
field
=
"USE_UNIT_CREDIT_CODE"
;
}
builder
.
sort
(
field
,
sort
.
getString
(
"order"
).
equals
(
"desc"
)
?
SortOrder
.
DESC
:
SortOrder
.
ASC
);
}
builder
.
query
(
boolMust
);
List
<
Map
<
String
,
Object
>>
statics
=
new
ArrayList
<>();
builder
.
from
((
current
-
1
)
*
size
);
builder
.
size
(
size
);
request
.
source
(
builder
);
List
<
JSONObject
>
list
=
new
LinkedList
<>();
long
totle
=
0
;
try
{
SearchResponse
response
=
restHighLevelClient
.
search
(
request
,
RequestOptions
.
DEFAULT
);
for
(
SearchHit
hit
:
response
.
getHits
().
getHits
())
{
JSONObject
jsonObject
=
(
JSONObject
)
JSONObject
.
toJSON
(
hit
);
JSONObject
dto
=
jsonObject
.
getJSONObject
(
"sourceAsMap"
);
dto
.
put
(
"record"
,
dto
.
get
(
"SEQUENCE_NBR"
));
dto
.
put
(
"equipAddress"
,
dto
.
get
(
"USE_PLACE"
)
+
"/"
+
dto
.
get
(
"ADDRESS"
));
String
dataQualityScore
=
ObjectUtils
.
isEmpty
(
dto
.
get
(
"DATA_QUALITY_SCORE"
))
?
null
:
DataQualityScoreEnum
.
getLabelByCode
(
dto
.
get
(
"DATA_QUALITY_SCORE"
).
toString
());
dto
.
put
(
"DATA_QUALITY_SCORE"
,
dataQualityScore
);
dto
.
put
(
"WHETHER_VEHICLE_CYLINDER"
,
ObjectUtils
.
isEmpty
(
dto
.
get
(
"WHETHER_VEHICLE_CYLINDER"
))
?
""
:
"1"
.
equals
(
dto
.
get
(
"WHETHER_VEHICLE_CYLINDER"
))
?
"是"
:
"否"
);
dto
.
put
(
"WHETHER_SKID_MOUNTED_PRESSURE_VESSEL"
,
ObjectUtils
.
isEmpty
(
dto
.
get
(
"WHETHER_SKID_MOUNTED_PRESSURE_VESSEL"
))
?
""
:
"1"
.
equals
(
dto
.
get
(
"WHETHER_SKID_MOUNTED_PRESSURE_VESSEL"
))
?
"是"
:
"否"
);
dto
.
put
(
"whetherSphericalTank"
,
ObjectUtils
.
isEmpty
(
dto
.
get
(
"whetherSphericalTank"
))
?
""
:
"1"
.
equals
(
dto
.
get
(
"whetherSphericalTank"
))
?
"是"
:
"否"
);
dto
.
put
(
"EQU_STATE"
,
ObjectUtils
.
isEmpty
(
dto
.
get
(
"EQU_STATE"
))
?
"无状态"
:
EquipStateEnum
.
getNameByCode
(
dto
.
get
(
"EQU_STATE"
).
toString
()));
String
inspectStatus
=
"无下次检验日期"
;
if
(
dto
.
containsKey
(
"NEXT_INSPECT_DATE"
))
{
String
nextInspectDate
=
dto
.
getString
(
"NEXT_INSPECT_DATE"
);
long
daysBetween
=
ChronoUnit
.
DAYS
.
between
(
LocalDate
.
now
(),
LocalDate
.
parse
(
nextInspectDate
,
formatter
));
if
(
daysBetween
<=
0
)
{
inspectStatus
=
"超期"
;
}
else
if
(
daysBetween
<=
30
)
{
inspectStatus
=
"临期"
;
}
else
{
inspectStatus
=
"正常"
;
}
dto
.
put
(
"inspectStatus"
,
inspectStatus
);
}
else
{
dto
.
put
(
"inspectStatus"
,
inspectStatus
);
}
list
.
add
(
dto
);
}
totle
=
Objects
.
requireNonNull
(
response
.
getInternalResponse
().
hits
().
getTotalHits
()).
value
;
page
.
setRecords
(
list
);
page
.
setTotal
(
totle
);
result
.
put
(
"pageData"
,
page
);
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
e
);
}
Map
<
String
,
Object
>
sum
=
new
HashMap
<>();
sum
.
put
(
"name"
,
"设备总数(台套)"
);
sum
.
put
(
"value"
,
totle
);
statics
.
add
(
sum
);
List
<
Map
<
String
,
Object
>>
equipStatusMap
=
new
ArrayList
<>();
getEquipStatusStatic
(
boolMust
,
builder
,
equipStatusMap
);
result
.
put
(
"keyIndicator"
,
equipStatusMap
);
if
(
ObjectUtils
.
isEmpty
(
filterParams
)
||
!
filterParams
.
containsKey
(
"EQU_LIST"
))
{
filterParams
=
new
JSONObject
();
JSONArray
jsonArray
=
new
JSONArray
();
jsonArray
.
add
(
"all"
);
filterParams
.
put
(
"EQU_LIST"
,
jsonArray
);
}
JSONArray
equList
=
(
JSONArray
)
filterParams
.
get
(
"EQU_LIST"
);
if
(
ObjectUtils
.
isEmpty
(
equList
)
||
equList
.
contains
(
"8000"
)
||
equList
.
contains
(
"all"
))
{
// 获取压力管道长度
BigDecimal
pipeLength
=
getPipeLength
(
boolMust
,
builder
);
Map
<
String
,
Object
>
pipeMap
=
new
HashMap
<>();
pipeMap
.
put
(
"name"
,
"压力管道(千米)"
);
pipeMap
.
put
(
"value"
,
pipeLength
.
divide
(
new
BigDecimal
(
1000
),
4
,
BigDecimal
.
ROUND_HALF_UP
));
statics
.
add
(
pipeMap
);
}
if
(
ObjectUtils
.
isEmpty
(
equList
)
||
equList
.
contains
(
"2000"
)
||
equList
.
contains
(
"all"
))
{
// 气瓶数量
CountRequest
countRequest
=
new
CountRequest
();
countRequest
.
indices
(
StatisticalAnalysisEnum
.
equip
.
getKey
());
boolMust
.
must
(
QueryBuilders
.
termQuery
(
"EQU_CATEGORY_CODE"
,
"2300"
));
countRequest
.
query
(
boolMust
);
CountResponse
response
=
null
;
try
{
response
=
restHighLevelClient
.
count
(
countRequest
,
RequestOptions
.
DEFAULT
);
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
e
);
}
Map
<
String
,
Object
>
gasMap
=
new
HashMap
<>();
gasMap
.
put
(
"name"
,
"气瓶(个)"
);
gasMap
.
put
(
"value"
,
ObjectUtils
.
isEmpty
(
response
)
?
0
:
response
.
getCount
());
statics
.
add
(
gasMap
);
}
result
.
put
(
"statics"
,
statics
);
return
result
;
}
private
void
getEquipStatusStatic
(
BoolQueryBuilder
boolMust
,
SearchSourceBuilder
builder
,
List
<
Map
<
String
,
Object
>>
statics
)
{
private
void
getEquipStatusStatic
(
BoolQueryBuilder
boolMust
,
SearchSourceBuilder
builder
,
List
<
Map
<
String
,
Object
>>
statics
)
{
SearchRequest
request
=
new
SearchRequest
();
SearchRequest
request
=
new
SearchRequest
();
request
.
indices
(
StatisticalAnalysisEnum
.
equip
.
getKey
());
request
.
indices
(
StatisticalAnalysisEnum
.
equip
.
getKey
());
...
@@ -2553,7 +2558,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
...
@@ -2553,7 +2558,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
}
}
public
JSONArray
queryQzOrTank
()
{
public
JSONArray
queryQzOrTank
()
{
//
是否车用气瓶
//
撬装球罐
JSONArray
qzOrTank
=
new
JSONArray
();
JSONArray
qzOrTank
=
new
JSONArray
();
for
(
int
i
=
0
;
i
<
2
;
i
++)
{
for
(
int
i
=
0
;
i
<
2
;
i
++)
{
JSONObject
object
=
new
JSONObject
();
JSONObject
object
=
new
JSONObject
();
...
@@ -2572,7 +2577,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
...
@@ -2572,7 +2577,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
}
}
public
JSONArray
queryRegisterStatus
()
{
public
JSONArray
queryRegisterStatus
()
{
//
是否车用气瓶
//
登记状态
JSONArray
registerStatus
=
new
JSONArray
();
JSONArray
registerStatus
=
new
JSONArray
();
for
(
int
i
=
0
;
i
<
2
;
i
++)
{
for
(
int
i
=
0
;
i
<
2
;
i
++)
{
JSONObject
object
=
new
JSONObject
();
JSONObject
object
=
new
JSONObject
();
...
@@ -2590,4 +2595,130 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
...
@@ -2590,4 +2595,130 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
return
registerStatus
;
return
registerStatus
;
}
}
public
JSONObject
queryDpStatistics
(
JSONObject
filter
)
{
JSONObject
result
=
new
JSONObject
();
String
businessType
=
filter
.
getString
(
"businessType"
);
if
(
ObjectUtils
.
isEmpty
(
businessType
))
{
return
result
;
}
SearchRequest
request
=
new
SearchRequest
();
SearchSourceBuilder
builder
=
new
SearchSourceBuilder
();
builder
.
trackTotalHits
(
true
);
BoolQueryBuilder
boolMust
=
QueryBuilders
.
boolQuery
();
Map
<
String
,
Object
>
tabTotalMap
=
new
HashMap
<>();
String
orgCode
=
filter
.
getString
(
"orgCode"
);
if
(
StatisticalAnalysisEnum
.
equip
.
getCode
().
equals
(
businessType
))
{
boolMust
.
must
(
QueryBuilders
.
prefixQuery
(
"ORG_BRANCH_CODE"
,
orgCode
));
result
=
queryDpEquipStatistics
(
filter
,
request
,
builder
,
boolMust
,
tabTotalMap
);
}
else
if
(
StatisticalAnalysisEnum
.
company
.
getCode
().
equals
(
businessType
))
{
boolMust
.
must
(
QueryBuilders
.
prefixQuery
(
"superviseOrgCode"
,
orgCode
));
result
=
queryDpCompanyStatistics
(
filter
,
request
,
builder
,
boolMust
,
tabTotalMap
);
}
else
{
boolMust
.
must
(
QueryBuilders
.
prefixQuery
(
"superviseOrgCode"
,
orgCode
));
result
=
queryDpPersonStatistics
(
filter
,
request
,
builder
,
boolMust
,
tabTotalMap
);
}
getOtherTypeCount
(
businessType
,
tabTotalMap
,
orgCode
);
result
.
put
(
"tabTotalMap"
,
tabTotalMap
);
return
result
;
}
private
void
getOtherTypeCount
(
String
businessType
,
Map
<
String
,
Object
>
tabTotalMap
,
String
orgCode
)
{
BoolQueryBuilder
equipBoolMust
=
QueryBuilders
.
boolQuery
();
equipBoolMust
.
must
(
QueryBuilders
.
prefixQuery
(
"ORG_BRANCH_CODE"
,
orgCode
));
BoolQueryBuilder
companyBoolMust
=
QueryBuilders
.
boolQuery
();
companyBoolMust
.
must
(
QueryBuilders
.
prefixQuery
(
"superviseOrgCode"
,
orgCode
));
BoolQueryBuilder
personBoolMust
=
QueryBuilders
.
boolQuery
();
personBoolMust
.
must
(
QueryBuilders
.
prefixQuery
(
"superviseOrgCode"
,
orgCode
));
String
equipIndex
=
StatisticalAnalysisEnum
.
equip
.
getKey
();
String
companyIndex
=
StatisticalAnalysisEnum
.
company
.
getKey
();
String
personIndex
=
StatisticalAnalysisEnum
.
person
.
getKey
();
if
(
businessType
.
equals
(
StatisticalAnalysisEnum
.
equip
.
getCode
()))
{
// 获取企业总数
Long
companyCount
=
getStaticCount
(
companyBoolMust
,
companyIndex
);
// 获取人员总数
Long
personCount
=
getStaticCount
(
personBoolMust
,
personIndex
);
tabTotalMap
.
put
(
StatisticalAnalysisEnum
.
company
.
getCode
(),
companyCount
);
tabTotalMap
.
put
(
StatisticalAnalysisEnum
.
person
.
getCode
(),
personCount
);
}
else
if
(
businessType
.
equals
(
StatisticalAnalysisEnum
.
company
.
getCode
()))
{
// 获取设备总数
Long
equipCount
=
getStaticCount
(
equipBoolMust
,
equipIndex
);
// 获取人员总数
Long
personCount
=
getStaticCount
(
personBoolMust
,
personIndex
);
tabTotalMap
.
put
(
StatisticalAnalysisEnum
.
equip
.
getCode
(),
equipCount
);
tabTotalMap
.
put
(
StatisticalAnalysisEnum
.
person
.
getCode
(),
personCount
);
}
else
{
// 获取设备总数
Long
equipCount
=
getStaticCount
(
equipBoolMust
,
equipIndex
);
// 获取企业总数
Long
companyCount
=
getStaticCount
(
companyBoolMust
,
companyIndex
);
tabTotalMap
.
put
(
StatisticalAnalysisEnum
.
equip
.
getCode
(),
equipCount
);
tabTotalMap
.
put
(
StatisticalAnalysisEnum
.
company
.
getCode
(),
companyCount
);
}
}
private
JSONObject
queryDpPersonStatistics
(
JSONObject
filter
,
SearchRequest
request
,
SearchSourceBuilder
builder
,
BoolQueryBuilder
boolMust
,
Map
<
String
,
Object
>
tabTotalMap
)
{
return
null
;
}
private
JSONObject
queryDpCompanyStatistics
(
JSONObject
filter
,
SearchRequest
request
,
SearchSourceBuilder
builder
,
BoolQueryBuilder
boolMust
,
Map
<
String
,
Object
>
tabTotalMap
)
{
return
null
;
}
private
JSONObject
queryDpEquipStatistics
(
JSONObject
filter
,
SearchRequest
request
,
SearchSourceBuilder
builder
,
BoolQueryBuilder
boolMust
,
Map
<
String
,
Object
>
tabTotalMap
)
{
request
.
indices
(
StatisticalAnalysisEnum
.
equip
.
getKey
());
JSONObject
filterParams
=
new
JSONObject
();
// 筛选
if
(!
ObjectUtils
.
isEmpty
(
filter
.
get
(
"filterParams"
)))
{
filterParams
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
filter
.
get
(
"filterParams"
)));
String
filterType
=
"advanced"
;
// 组装查询条件
getEquipmentBoolQueryBuilder
(
boolMust
,
filterParams
,
filterType
);
}
JSONArray
typeData
=
filter
.
getJSONArray
(
"typeData"
);
String
groupField
=
"EQU_LIST_CODE"
;
if
(!
ObjectUtils
.
isEmpty
(
typeData
))
{
if
(
typeData
.
size
()
==
1
)
{
groupField
=
"EQU_LIST_CODE"
;
}
else
if
(
typeData
.
size
()
==
2
)
{
groupField
=
"EQU_CATEGORY_CODE"
;
}
else
if
(
typeData
.
size
()
==
3
)
{
groupField
=
"EQU_DEFINE_CODE"
;
}
}
Map
<
String
,
Object
>
staticCountByGroup
=
getStaticCountByGroup
(
request
,
builder
,
boolMust
,
groupField
);
return
JSONObject
.
parseObject
(
JSON
.
toJSONString
(
staticCountByGroup
));
}
private
Map
<
String
,
Object
>
getStaticCountByGroup
(
SearchRequest
request
,
SearchSourceBuilder
builder
,
BoolQueryBuilder
boolMust
,
String
groupField
)
{
builder
.
query
(
boolMust
);
builder
.
aggregation
(
AggregationBuilders
.
terms
(
groupField
).
field
(
groupField
).
missing
(
"null"
));
request
.
source
(
builder
);
try
{
SearchResponse
response
=
restHighLevelClient
.
search
(
request
,
RequestOptions
.
DEFAULT
);
Terms
terms
=
response
.
getAggregations
().
get
(
groupField
);
Map
<
String
,
Object
>
tabTotalMap
=
new
HashMap
<>();
for
(
Terms
.
Bucket
bucket
:
terms
.
getBuckets
())
{
tabTotalMap
.
put
(
bucket
.
getKeyAsString
(),
bucket
.
getDocCount
());
}
return
tabTotalMap
;
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
}
}
\ No newline at end of file
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
View file @
d3970aba
...
@@ -4,7 +4,7 @@ import org.elasticsearch.index.query.BoolQueryBuilder;
...
@@ -4,7 +4,7 @@ import org.elasticsearch.index.query.BoolQueryBuilder;
import
org.elasticsearch.index.query.QueryBuilders
;
import
org.elasticsearch.index.query.QueryBuilders
;
public
class
QueryBuilderUtils
{
public
class
QueryBuilderUtils
{
// 复制BoolQueryBuilder
public
static
BoolQueryBuilder
copyBoolQuery
(
BoolQueryBuilder
original
)
{
public
static
BoolQueryBuilder
copyBoolQuery
(
BoolQueryBuilder
original
)
{
if
(
original
==
null
)
{
if
(
original
==
null
)
{
return
QueryBuilders
.
boolQuery
();
return
QueryBuilders
.
boolQuery
();
...
...
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