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
3754f2db
Commit
3754f2db
authored
Jul 10, 2024
by
suhuiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.大屏地图图列统计接口开发
parent
8c41fd7d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
67 additions
and
3 deletions
+67
-3
DPStatisticsServiceImpl.java
...t/module/jg/biz/service/impl/DPStatisticsServiceImpl.java
+67
-3
No files found.
amos-boot-system-tzs/amos-boot-module-jg/amos-boot-module-jg-biz/src/main/java/com/yeejoin/amos/boot/module/jg/biz/service/impl/DPStatisticsServiceImpl.java
View file @
3754f2db
...
...
@@ -4,14 +4,30 @@ import cn.hutool.core.date.DateUtil;
import
com.yeejoin.amos.boot.module.common.api.dto.DPFilterParamDto
;
import
com.yeejoin.amos.boot.module.common.api.dto.LegendDataDto
;
import
com.yeejoin.amos.boot.module.jg.api.dto.EquipBizCountDto
;
import
com.yeejoin.amos.boot.module.jg.api.enums.DPMapStatisticsItemEnum
;
import
com.yeejoin.amos.boot.module.jg.api.mapper.JgEnableDisableMapper
;
import
com.yeejoin.amos.boot.module.jg.api.mapper.JgScrapCancelMapper
;
import
com.yeejoin.amos.boot.module.jg.api.mapper.JgUseRegistrationMapper
;
import
com.yeejoin.amos.boot.module.ymt.api.dto.EquipmentCategoryDto
;
import
com.yeejoin.amos.boot.module.ymt.api.mapper.EquipmentCategoryMapper
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.elasticsearch.action.search.SearchRequest
;
import
org.elasticsearch.action.search.SearchResponse
;
import
org.elasticsearch.client.RequestOptions
;
import
org.elasticsearch.client.RestHighLevelClient
;
import
org.elasticsearch.client.core.CountRequest
;
import
org.elasticsearch.client.core.CountResponse
;
import
org.elasticsearch.index.query.BoolQueryBuilder
;
import
org.elasticsearch.index.query.QueryBuilders
;
import
org.elasticsearch.search.aggregations.AggregationBuilders
;
import
org.elasticsearch.search.aggregations.bucket.terms.Terms
;
import
org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder
;
import
org.elasticsearch.search.builder.SearchSourceBuilder
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.PostConstruct
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
...
...
@@ -24,6 +40,7 @@ import java.util.stream.Collectors;
* @author Administrator
*/
@Service
@Slf4j
public
class
DPStatisticsServiceImpl
{
/**
...
...
@@ -44,12 +61,23 @@ public class DPStatisticsServiceImpl {
private
JgScrapCancelMapper
scrapCancelMapper
;
private
RestHighLevelClient
restHighLevelClient
;
public
DPStatisticsServiceImpl
(
EquipmentCategoryMapper
equipmentCategoryMapper
,
JgUseRegistrationMapper
useRegistrationMapper
,
JgEnableDisableMapper
enableDisableMapper
,
JgScrapCancelMapper
scrapCancelMapper
)
{
private
static
List
<
EquipmentCategoryDto
>
equipmentCategoryDtos
;
public
DPStatisticsServiceImpl
(
EquipmentCategoryMapper
equipmentCategoryMapper
,
JgUseRegistrationMapper
useRegistrationMapper
,
JgEnableDisableMapper
enableDisableMapper
,
JgScrapCancelMapper
scrapCancelMapper
,
RestHighLevelClient
restHighLevelClient
)
{
this
.
equipmentCategoryMapper
=
equipmentCategoryMapper
;
this
.
useRegistrationMapper
=
useRegistrationMapper
;
this
.
enableDisableMapper
=
enableDisableMapper
;
this
.
scrapCancelMapper
=
scrapCancelMapper
;
this
.
restHighLevelClient
=
restHighLevelClient
;
}
@PostConstruct
public
void
init
()
{
// 数据不变所以放到内存,提高响应时间
equipmentCategoryDtos
=
equipmentCategoryMapper
.
selectClassify
();
}
...
...
@@ -61,8 +89,6 @@ public class DPStatisticsServiceImpl {
List
<
LegendDataDto
>
legendDataDtos
=
this
.
buildLegendDataList
();
//2.1 图列数据构造
result
.
put
(
"legendData"
,
legendDataDtos
);
// 8大类设备种类
List
<
EquipmentCategoryDto
>
equipmentCategoryDtos
=
equipmentCategoryMapper
.
selectClassify
();
//2.2 x轴数据构造
result
.
put
(
"xdata"
,
this
.
getXData
(
equipmentCategoryDtos
));
//2.3 y轴数据构造
...
...
@@ -160,8 +186,46 @@ public class DPStatisticsServiceImpl {
}
private
void
staticsCenterMapCountDataForPipeline
(
Map
<
String
,
Object
>
result
,
DPFilterParamDto
dpFilterParamDto
)
{
CountRequest
request
=
new
CountRequest
();
request
.
indices
(
"idx_biz_view_jg_all"
);
BoolQueryBuilder
boolMust
=
QueryBuilders
.
boolQuery
();
// 区域信息模糊查询
boolMust
.
must
(
QueryBuilders
.
wildcardQuery
(
"USE_PLACE_CODE"
,
"*"
+
dpFilterParamDto
.
getCityCode
()
+
"*"
));
// 设备类别精确查询气瓶
boolMust
.
must
(
QueryBuilders
.
termsQuery
(
"EQU_CATEGORY_CODE"
,
EQU_CATEGORY_CYLINDER
));
// 纳管状态为已纳管
boolMust
.
must
(
QueryBuilders
.
termsQuery
(
"IS_INTO_MANAGEMENT"
,
true
));
try
{
CountResponse
response
=
restHighLevelClient
.
count
(
request
,
RequestOptions
.
DEFAULT
);
result
.
put
(
DPMapStatisticsItemEnum
.
GAS
.
getCode
(),
response
.
getCount
());
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
private
void
staticsCenterMapCountDataForEquip
(
Map
<
String
,
Object
>
result
,
DPFilterParamDto
dpFilterParamDto
)
{
SearchRequest
request
=
new
SearchRequest
();
request
.
indices
(
"idx_biz_view_jg_all"
);
BoolQueryBuilder
boolMust
=
QueryBuilders
.
boolQuery
();
// 区域信息模糊查询
boolMust
.
must
(
QueryBuilders
.
wildcardQuery
(
"USE_PLACE_CODE"
,
"*"
+
dpFilterParamDto
.
getCityCode
()
+
"*"
));
// 纳管状态为已纳管
boolMust
.
must
(
QueryBuilders
.
termsQuery
(
"IS_INTO_MANAGEMENT"
,
true
));
SearchSourceBuilder
builder
=
new
SearchSourceBuilder
();
builder
.
query
(
boolMust
);
TermsAggregationBuilder
aggregationBuilder
=
AggregationBuilders
.
terms
(
"count_by_equ_list_code"
).
field
(
"EQU_LIST_CODE"
);
builder
.
aggregation
(
aggregationBuilder
);
request
.
source
(
builder
);
try
{
SearchResponse
response
=
restHighLevelClient
.
search
(
request
,
RequestOptions
.
DEFAULT
);
Terms
terms
=
response
.
getAggregations
().
get
(
"count_by_equ_list_code"
);
for
(
Terms
.
Bucket
bucket
:
terms
.
getBuckets
())
{
log
.
info
(
bucket
.
getKeyAsString
());
log
.
info
(
String
.
valueOf
(
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