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
102bea26
Commit
102bea26
authored
Jun 27, 2025
by
tianyiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
综合统计分析列表查询设备/企业/人员快捷筛选完善
parent
94cca377
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
184 additions
and
46 deletions
+184
-46
ComprehensiveStatisticalAnalysisServiceImpl.java
...ice/impl/ComprehensiveStatisticalAnalysisServiceImpl.java
+184
-46
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 @
102bea26
...
@@ -8,8 +8,10 @@ import com.yeejoin.amos.boot.biz.common.annotation.TechnicalParameter;
...
@@ -8,8 +8,10 @@ import com.yeejoin.amos.boot.biz.common.annotation.TechnicalParameter;
import
com.yeejoin.amos.boot.biz.common.entity.DataDictionary
;
import
com.yeejoin.amos.boot.biz.common.entity.DataDictionary
;
import
com.yeejoin.amos.boot.biz.common.excel.ExcelUtil
;
import
com.yeejoin.amos.boot.biz.common.excel.ExcelUtil
;
import
com.yeejoin.amos.boot.biz.common.service.impl.DataDictionaryServiceImpl
;
import
com.yeejoin.amos.boot.biz.common.service.impl.DataDictionaryServiceImpl
;
import
com.yeejoin.amos.boot.biz.common.utils.DateUtils
;
import
com.yeejoin.amos.boot.module.common.api.dto.TechParamItem
;
import
com.yeejoin.amos.boot.module.common.api.dto.TechParamItem
;
import
com.yeejoin.amos.boot.module.common.biz.utils.TechParamUtil
;
import
com.yeejoin.amos.boot.module.common.biz.utils.TechParamUtil
;
import
com.yeejoin.amos.boot.module.jg.api.enums.DPMapStatisticsItemEnum
;
import
com.yeejoin.amos.boot.module.statistcs.biz.utils.JsonUtils
;
import
com.yeejoin.amos.boot.module.statistcs.biz.utils.JsonUtils
;
import
com.yeejoin.amos.boot.module.statistcs.biz.utils.MinioUtils
;
import
com.yeejoin.amos.boot.module.statistcs.biz.utils.MinioUtils
;
import
com.yeejoin.amos.boot.module.statistics.api.enums.AdvanceSearchEnum
;
import
com.yeejoin.amos.boot.module.statistics.api.enums.AdvanceSearchEnum
;
...
@@ -20,17 +22,16 @@ import com.yeejoin.amos.boot.module.statistics.api.vo.EquipInfoVo;
...
@@ -20,17 +22,16 @@ import com.yeejoin.amos.boot.module.statistics.api.vo.EquipInfoVo;
import
com.yeejoin.amos.boot.module.ymt.api.enums.EquipmentClassifityEnum
;
import
com.yeejoin.amos.boot.module.ymt.api.enums.EquipmentClassifityEnum
;
import
lombok.RequiredArgsConstructor
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.lucene.search.join.ScoreMode
;
import
org.elasticsearch.action.search.SearchRequest
;
import
org.elasticsearch.action.search.SearchRequest
;
import
org.elasticsearch.action.search.SearchResponse
;
import
org.elasticsearch.action.search.SearchResponse
;
import
org.elasticsearch.client.RequestOptions
;
import
org.elasticsearch.client.RequestOptions
;
import
org.elasticsearch.client.RestHighLevelClient
;
import
org.elasticsearch.client.RestHighLevelClient
;
import
org.elasticsearch.index.query.BoolQueryBuilder
;
import
org.elasticsearch.index.query.*
;
import
org.elasticsearch.index.query.QueryBuilders
;
import
org.elasticsearch.script.Script
;
import
org.elasticsearch.index.query.TermsQueryBuilder
;
import
org.elasticsearch.search.SearchHit
;
import
org.elasticsearch.search.SearchHit
;
import
org.elasticsearch.search.builder.SearchSourceBuilder
;
import
org.elasticsearch.search.builder.SearchSourceBuilder
;
import
org.elasticsearch.search.sort.SortOrder
;
import
org.elasticsearch.search.sort.SortOrder
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.core.io.Resource
;
import
org.springframework.core.io.Resource
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -64,6 +65,9 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
...
@@ -64,6 +65,9 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
private
final
TzsCustomFilterMapper
tzsCustomFilterMapper
;
private
final
TzsCustomFilterMapper
tzsCustomFilterMapper
;
private
final
DataDictionaryServiceImpl
dataDictionaryService
;
private
final
DataDictionaryServiceImpl
dataDictionaryService
;
private
final
EmqKeeper
emqKeeper
;
private
final
EmqKeeper
emqKeeper
;
private
final
StCommonServiceImpl
stCommonService
;
private
final
RestHighLevelClient
restHighLevelClient
;
private
final
RestHighLevelClient
restHighLevelClient
;
private
final
String
DOWN_LOAD_START_TEMP
=
"{\"id\":\"%s\",\"status\":\"starting\",\"fileName\":\"%s\",\"time\":\"%s\"}"
;
private
final
String
DOWN_LOAD_START_TEMP
=
"{\"id\":\"%s\",\"status\":\"starting\",\"fileName\":\"%s\",\"time\":\"%s\"}"
;
private
final
String
DOWNLOAD_TOPIC
=
"/topic/download/excel/%s"
;
private
final
String
DOWNLOAD_TOPIC
=
"/topic/download/excel/%s"
;
...
@@ -138,7 +142,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
...
@@ -138,7 +142,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
public
JSONObject
queryForPage
(
JSONObject
filter
)
{
public
JSONObject
queryForPage
(
JSONObject
filter
)
{
JSONObject
result
=
new
JSONObject
();
JSONObject
result
=
new
JSONObject
();
Integer
current
=
ObjectUtils
.
isEmpty
(
filter
.
getInteger
(
"current"
))
?
1
:
filter
.
getInteger
(
"current"
);
Integer
current
=
ObjectUtils
.
isEmpty
(
filter
.
getInteger
(
"current"
))
?
1
:
filter
.
getInteger
(
"current"
);
Integer
size
=
ObjectUtils
.
isEmpty
(
filter
.
getInteger
(
"
pageSize"
))
?
20
:
filter
.
getInteger
(
"pageS
ize"
);
Integer
size
=
ObjectUtils
.
isEmpty
(
filter
.
getInteger
(
"
size"
))
?
20
:
filter
.
getInteger
(
"s
ize"
);
Page
<
JSONObject
>
page
=
new
Page
<>(
current
,
size
);
Page
<
JSONObject
>
page
=
new
Page
<>(
current
,
size
);
String
businessType
=
filter
.
getString
(
"businessType"
);
String
businessType
=
filter
.
getString
(
"businessType"
);
...
@@ -170,6 +174,52 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
...
@@ -170,6 +174,52 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
SearchSourceBuilder
builder
=
new
SearchSourceBuilder
();
SearchSourceBuilder
builder
=
new
SearchSourceBuilder
();
builder
.
trackTotalHits
(
true
);
builder
.
trackTotalHits
(
true
);
BoolQueryBuilder
boolMust
=
QueryBuilders
.
boolQuery
();
BoolQueryBuilder
boolMust
=
QueryBuilders
.
boolQuery
();
String
orgCode
=
filter
.
getString
(
"orgCode"
);
boolMust
.
must
(
QueryBuilders
.
prefixQuery
(
"superviseOrgCode"
,
orgCode
));
JSONObject
filterParams
=
null
;
if
(!
ObjectUtils
.
isEmpty
(
filter
.
get
(
"filterParams"
)))
{
filterParams
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
filter
.
get
(
"filterParams"
)));
String
filterType
=
filter
.
getString
(
"filterType"
);
//快捷筛选和自定义筛选解析筛选规则不一致
if
(
filterType
.
equals
(
"advanced"
))
{
filterParams
.
forEach
((
k
,
v
)
->
{
if
(
v
instanceof
JSONArray
)
{
if
(!((
JSONArray
)
v
).
contains
(
"all"
))
{
String
field
=
k
;
if
(
k
.
equals
(
"newPost"
)
||
k
.
equals
(
"subPost"
)
||
k
.
equals
(
"equipType"
)
||
k
.
equals
(
"unitType"
))
{
boolMust
.
must
(
QueryBuilders
.
existsQuery
(
field
));
((
JSONArray
)
v
).
forEach
(
item
->
boolMust
.
should
(
QueryBuilders
.
wildcardQuery
(
field
+
".keyword"
,
"*"
+
item
+
"*"
)));
boolMust
.
minimumShouldMatch
(
1
);
}
else
if
(
k
.
equals
(
"education"
))
{
boolMust
.
must
(
QueryBuilders
.
existsQuery
(
field
));
TermsQueryBuilder
termsQuery
=
QueryBuilders
.
termsQuery
(
field
,
(
JSONArray
)
v
);
boolMust
.
must
(
termsQuery
);
}
else
if
(
k
.
equals
(
"licenses"
))
{
((
JSONArray
)
v
).
forEach
(
item
->
{
String
compareString
=
"doc['"
+
k
+
"'].length"
+
(
item
.
equals
(
"1"
)
?
" > 0"
:
"= 0"
);
// 检查嵌套字段存在且长度大于0
Script
script
=
new
Script
(
compareString
);
ScriptQueryBuilder
scriptQuery
=
QueryBuilders
.
scriptQuery
(
script
);
NestedQueryBuilder
nestedExistsQuery
=
QueryBuilders
.
nestedQuery
(
k
,
scriptQuery
,
ScoreMode
.
None
);
BoolQueryBuilder
query
=
QueryBuilders
.
boolQuery
()
.
must
(
nestedExistsQuery
);
boolMust
.
must
(
query
);
});
}
}
else
{
//todo 高级筛选
}
}
});
}
}
// 排序
// 排序
if
(!
ObjectUtils
.
isEmpty
(
filter
.
get
(
"sort"
)))
{
if
(!
ObjectUtils
.
isEmpty
(
filter
.
get
(
"sort"
)))
{
JSONObject
sort
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
filter
.
get
(
"sort"
)));
JSONObject
sort
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
filter
.
get
(
"sort"
)));
...
@@ -187,6 +237,9 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
...
@@ -187,6 +237,9 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
for
(
SearchHit
hit
:
response
.
getHits
().
getHits
())
{
for
(
SearchHit
hit
:
response
.
getHits
().
getHits
())
{
JSONObject
jsonObject
=
(
JSONObject
)
JSONObject
.
toJSON
(
hit
);
JSONObject
jsonObject
=
(
JSONObject
)
JSONObject
.
toJSON
(
hit
);
JSONObject
dto
=
jsonObject
.
getJSONObject
(
"sourceAsMap"
);
JSONObject
dto
=
jsonObject
.
getJSONObject
(
"sourceAsMap"
);
if
(
dto
.
containsKey
(
"identification"
))
{
dto
.
put
(
"identification"
,
JSONObject
.
parseObject
(
JSONObject
.
parseArray
(
dto
.
get
(
"identification"
).
toString
()).
get
(
0
).
toString
()).
get
(
"url"
));
}
list
.
add
(
dto
);
list
.
add
(
dto
);
}
}
totle
=
Objects
.
requireNonNull
(
response
.
getInternalResponse
().
hits
().
getTotalHits
()).
value
;
totle
=
Objects
.
requireNonNull
(
response
.
getInternalResponse
().
hits
().
getTotalHits
()).
value
;
...
@@ -217,6 +270,50 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
...
@@ -217,6 +270,50 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
builder
.
trackTotalHits
(
true
);
builder
.
trackTotalHits
(
true
);
BoolQueryBuilder
boolMust
=
QueryBuilders
.
boolQuery
();
BoolQueryBuilder
boolMust
=
QueryBuilders
.
boolQuery
();
String
orgCode
=
filter
.
getString
(
"orgCode"
);
boolMust
.
must
(
QueryBuilders
.
prefixQuery
(
"superviseOrgCode"
,
orgCode
));
JSONObject
filterParams
=
null
;
if
(!
ObjectUtils
.
isEmpty
(
filter
.
get
(
"filterParams"
)))
{
filterParams
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
filter
.
get
(
"filterParams"
)));
String
filterType
=
filter
.
getString
(
"filterType"
);
//快捷筛选和自定义筛选解析筛选规则不一致
if
(
filterType
.
equals
(
"advanced"
))
{
filterParams
.
forEach
((
k
,
v
)
->
{
if
(
v
instanceof
JSONArray
)
{
if
(!((
JSONArray
)
v
).
contains
(
"all"
))
{
String
field
=
k
;
if
(
k
.
equals
(
"regulatoryLabels"
)
||
k
.
equals
(
"equipCategory"
)
||
k
.
equals
(
"unitType"
))
{
boolMust
.
must
(
QueryBuilders
.
existsQuery
(
field
));
((
JSONArray
)
v
).
forEach
(
item
->
boolMust
.
should
(
QueryBuilders
.
wildcardQuery
(
field
+
".keyword"
,
"*"
+
item
+
"*"
)));
boolMust
.
minimumShouldMatch
(
1
);
}
else
if
(
k
.
equals
(
"industrySupervisor"
)
||
k
.
equals
(
"operatingStatus"
))
{
boolMust
.
must
(
QueryBuilders
.
existsQuery
(
field
));
TermsQueryBuilder
termsQuery
=
QueryBuilders
.
termsQuery
(
field
,
(
JSONArray
)
v
);
boolMust
.
must
(
termsQuery
);
}
else
if
(
k
.
equals
(
"itemCode"
)
||
k
.
equals
(
"subItemCode"
))
{
String
path
=
"licenses"
;
((
JSONArray
)
v
).
forEach
(
item
->
{
String
nestedField
=
path
+
"."
+
k
+
".keyword"
;
// 创建嵌套查询
NestedQueryBuilder
nestedQuery
=
QueryBuilders
.
nestedQuery
(
path
,
QueryBuilders
.
boolQuery
()
.
must
(
QueryBuilders
.
termQuery
(
nestedField
,
v
)),
ScoreMode
.
Avg
);
boolMust
.
must
(
nestedQuery
);
System
.
out
.
println
(
boolMust
.
toString
());
});
}
else
if
(
k
.
equals
(
"permitStatus"
))
{
}
}
}
});
}
}
// 排序
// 排序
if
(!
ObjectUtils
.
isEmpty
(
filter
.
get
(
"sort"
)))
{
if
(!
ObjectUtils
.
isEmpty
(
filter
.
get
(
"sort"
)))
{
JSONObject
sort
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
filter
.
get
(
"sort"
)));
JSONObject
sort
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
filter
.
get
(
"sort"
)));
...
@@ -246,6 +343,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
...
@@ -246,6 +343,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
throw
new
RuntimeException
(
e
);
throw
new
RuntimeException
(
e
);
}
}
List
<
Map
<
String
,
Object
>>
statics
=
new
ArrayList
<>();
List
<
Map
<
String
,
Object
>>
statics
=
new
ArrayList
<>();
Map
<
String
,
Object
>
sum
=
new
HashMap
<>();
Map
<
String
,
Object
>
sum
=
new
HashMap
<>();
sum
.
put
(
"name"
,
"企业总数(个)"
);
sum
.
put
(
"name"
,
"企业总数(个)"
);
...
@@ -266,13 +364,18 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
...
@@ -266,13 +364,18 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
builder
.
trackTotalHits
(
true
);
builder
.
trackTotalHits
(
true
);
BoolQueryBuilder
boolMust
=
QueryBuilders
.
boolQuery
();
BoolQueryBuilder
boolMust
=
QueryBuilders
.
boolQuery
();
String
orgCode
=
filter
.
getString
(
"orgCode"
);
boolMust
.
must
(
QueryBuilders
.
prefixQuery
(
"ORG_BRANCH_CODE"
,
orgCode
));
JSONObject
filterParams
=
null
;
// 筛选
// 筛选
if
(!
ObjectUtils
.
isEmpty
(
filter
.
get
(
"filterParams"
)))
{
if
(!
ObjectUtils
.
isEmpty
(
filter
.
get
(
"filterParams"
)))
{
JSONObject
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"
);
//快捷筛选和自定义筛选解析筛选规则不一致
if
(
filterType
.
equals
(
"advanced"
))
{
if
(
filterType
.
equals
(
"advanced"
))
{
filterParams
.
forEach
((
k
,
v
)
->
{
filterParams
.
forEach
((
k
,
v
)
->
{
if
(
k
.
equals
(
"techParam"
))
{
if
(
k
.
equals
(
"techParam"
))
{
// todo 计数参数筛选
}
else
{
}
else
{
if
(
v
instanceof
JSONArray
)
{
if
(
v
instanceof
JSONArray
)
{
...
@@ -281,39 +384,54 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
...
@@ -281,39 +384,54 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
// todo 所属单位筛选争议,需确认后完成
// todo 所属单位筛选争议,需确认后完成
if
(
k
.
equals
(
"NEXT_INSPECT_DATE"
))
{
if
(
k
.
equals
(
"NEXT_INSPECT_DATE"
))
{
String
finalField
=
field
;
String
finalField
=
field
;
boolMust
.
must
(
QueryBuilders
.
existsQuery
(
finalField
));
((
JSONArray
)
v
).
forEach
(
item
->
{
((
JSONArray
)
v
).
forEach
(
item
->
{
boolMust
.
must
(
QueryBuilders
.
existsQuery
(
finalField
));
if
(
item
.
equals
(
"overdue"
))
{
if
(
item
.
equals
(
"overdue"
))
{
// 超期:小于当前日期
// 超期:小于当前日期
boolMust
.
must
(
QueryBuilders
.
rangeQuery
(
finalField
).
lt
(
LocalDate
.
now
().
format
(
formatter
)));
boolMust
.
filter
(
QueryBuilders
.
rangeQuery
(
finalField
).
lt
(
LocalDate
.
now
().
format
(
formatter
)));
}
else
if
(
item
.
equals
(
"near"
))
{
}
else
if
(
item
.
equals
(
"near"
))
{
// 临期:小于等于当前日期加上30天
// 临期:小于等于当前日期加上30天
boolMust
.
must
(
QueryBuilders
.
rangeQuery
(
finalField
).
lte
(
LocalDate
.
now
().
plusDays
(
30
).
format
(
formatter
)));
boolMust
.
filter
(
QueryBuilders
.
rangeQuery
(
finalField
).
lte
(
LocalDate
.
now
().
plusDays
(
30
).
format
(
formatter
)));
}
else
{
}
else
{
// 正常:大于当前日期加上30天
// 正常:大于当前日期加上30天
boolMust
.
must
(
QueryBuilders
.
rangeQuery
(
finalField
).
gt
(
LocalDate
.
now
().
plusDays
(
30
).
format
(
formatter
)));
boolMust
.
filter
(
QueryBuilders
.
rangeQuery
(
finalField
).
gt
(
LocalDate
.
now
().
plusDays
(
30
).
format
(
formatter
)));
}
}
});
});
}
else
if
(
k
.
equals
(
"USC_DATE"
))
{
}
else
if
(
k
.
equals
(
"USC_DATE"
))
{
String
finalField
=
field
;
String
finalField
=
field
;
boolMust
.
must
(
QueryBuilders
.
existsQuery
(
finalField
));
((
JSONArray
)
v
).
forEach
(
item
->
{
((
JSONArray
)
v
).
forEach
(
item
->
{
boolMust
.
must
(
QueryBuilders
.
existsQuery
(
finalField
));
if
(
item
.
equals
(
"15"
))
{
if
(
item
.
equals
(
"15"
))
{
// 15年以上:大于当前日期减去15年
// 15年以上:大于当前日期减去15年
boolMust
.
must
(
QueryBuilders
.
rangeQuery
(
finalField
).
gt
(
LocalDate
.
now
().
minusYears
(
15
).
format
(
formatter
)));
boolMust
.
filter
(
QueryBuilders
.
rangeQuery
(
finalField
).
gt
(
LocalDate
.
now
().
minusYears
(
15
).
format
(
formatter
)));
}
else
if
(
item
.
equals
(
"10-15"
))
{
}
else
if
(
item
.
equals
(
"10-15"
))
{
// 10-15年:小于当前日期减去15年,大于等于当前日期减去10年
// 10-15年:小于当前日期减去15年,大于等于当前日期减去10年
boolMust
.
must
(
QueryBuilders
.
rangeQuery
(
finalField
).
lt
(
LocalDate
.
now
().
minusYears
(
15
).
format
(
formatter
)));
boolMust
.
filter
(
QueryBuilders
.
rangeQuery
(
finalField
).
lt
(
LocalDate
.
now
().
minusYears
(
15
).
format
(
formatter
)));
boolMust
.
must
(
QueryBuilders
.
rangeQuery
(
finalField
).
gte
(
LocalDate
.
now
().
minusYears
(
10
).
format
(
formatter
)));
boolMust
.
filter
(
QueryBuilders
.
rangeQuery
(
finalField
).
gte
(
LocalDate
.
now
().
minusYears
(
10
).
format
(
formatter
)));
}
else
if
(
item
.
equals
(
"5-10"
))
{
}
else
if
(
item
.
equals
(
"5-10"
))
{
// 5-10年:小于当前日期减去10年,大于等于当前日期减去5年
// 5-10年:小于当前日期减去10年,大于等于当前日期减去5年
boolMust
.
must
(
QueryBuilders
.
rangeQuery
(
finalField
).
lt
(
LocalDate
.
now
().
minusYears
(
10
).
format
(
formatter
)));
boolMust
.
filter
(
QueryBuilders
.
rangeQuery
(
finalField
).
lt
(
LocalDate
.
now
().
minusYears
(
10
).
format
(
formatter
)));
boolMust
.
must
(
QueryBuilders
.
rangeQuery
(
finalField
).
gte
(
LocalDate
.
now
().
minusYears
(
5
).
format
(
formatter
)));
boolMust
.
filter
(
QueryBuilders
.
rangeQuery
(
finalField
).
gte
(
LocalDate
.
now
().
minusYears
(
5
).
format
(
formatter
)));
}
else
if
(
item
.
equals
(
"0-5"
))
{
}
else
if
(
item
.
equals
(
"0-5"
))
{
// 0-5年:小于当前日期减去5年
// 0-5年:小于当前日期减去5年
boolMust
.
must
(
QueryBuilders
.
rangeQuery
(
finalField
).
lt
(
LocalDate
.
now
().
minusYears
(
5
).
format
(
formatter
)));
boolMust
.
filter
(
QueryBuilders
.
rangeQuery
(
finalField
).
lt
(
LocalDate
.
now
().
minusYears
(
5
).
format
(
formatter
)));
}
}
});
});
}
else
if
(
k
.
equals
(
"IS_SUPERVISORY"
))
{
String
finalField
=
"SUPERVISORY_CODE"
;
((
JSONArray
)
v
).
forEach
(
item
->
{
if
(
item
.
equals
(
"1"
))
{
boolMust
.
must
(
QueryBuilders
.
existsQuery
(
finalField
));
boolMust
.
mustNot
(
QueryBuilders
.
termQuery
(
finalField
,
"null"
));
}
else
{
boolMust
.
mustNot
(
QueryBuilders
.
existsQuery
(
finalField
));
}
});
}
else
if
(
k
.
equals
(
"createDate"
))
{
JSONArray
createDates
=
(
JSONArray
)
v
;
String
startDate
=
DateUtils
.
convertDateToString
(
createDates
.
getDate
(
0
),
"yyyy-MM-dd HH:mm:ss"
);
String
endDate
=
DateUtils
.
convertDateToString
(
createDates
.
getDate
(
1
),
"yyyy-MM-dd HH:mm:ss"
);
boolMust
.
filter
(
QueryBuilders
.
rangeQuery
(
"createDate"
).
gte
(
startDate
.
replace
(
" "
,
"T"
)).
lte
(
endDate
.
replace
(
" "
,
"T"
)));
}
else
if
(
k
.
equals
(
"EQU_LIST"
)
||
k
.
equals
(
"EQU_CATEGORY"
)
||
k
.
equals
(
"EQU_DEFINE"
)
||
k
.
equals
(
"EQU_STATE"
)
||
k
.
equals
(
"DATA_QUALITY_SCORE"
)
||
k
.
equals
(
"DATA_SOURCE"
))
{
}
else
if
(
k
.
equals
(
"EQU_LIST"
)
||
k
.
equals
(
"EQU_CATEGORY"
)
||
k
.
equals
(
"EQU_DEFINE"
)
||
k
.
equals
(
"EQU_STATE"
)
||
k
.
equals
(
"DATA_QUALITY_SCORE"
)
||
k
.
equals
(
"DATA_SOURCE"
))
{
if
(
k
.
equals
(
"EQU_LIST"
))
{
if
(
k
.
equals
(
"EQU_LIST"
))
{
field
=
"EQU_LIST_CODE"
;
field
=
"EQU_LIST_CODE"
;
...
@@ -332,48 +450,34 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
...
@@ -332,48 +450,34 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
}
}
});
});
}
else
{
}
else
{
// todo 自定义筛选
}
JSONArray
equList
=
JSONObject
.
parseArray
(
JSONObject
.
toJSONString
(
filterParams
.
get
(
EQU_LIST
)));
if
(!
ObjectUtils
.
isEmpty
(
equList
))
{
if
(
equList
.
contains
(
"8000"
))
{
// 压力管道长度
Map
<
String
,
Object
>
pipeLong
=
new
HashMap
<>();
pipeLong
.
put
(
"name"
,
"压力管道(千米)"
);
// todo 调用大屏总览接口获取压力管道长度
pipeLong
.
put
(
"value"
,
1000000
);
}
if
(
equList
.
contains
(
"2000"
))
{
// 气瓶数量
Map
<
String
,
Object
>
gasTank
=
new
HashMap
<>();
gasTank
.
put
(
"name"
,
"气瓶(个)"
);
// todo 调用大屏总览接口获取气瓶数量
gasTank
.
put
(
"value"
,
1000000
);
}
}
}
}
}
// 排序
//
排序
if
(!
ObjectUtils
.
isEmpty
(
filter
.
get
(
"sort"
)))
{
if
(!
ObjectUtils
.
isEmpty
(
filter
.
get
(
"sort"
)))
{
JSONObject
sort
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
filter
.
get
(
"sort"
)));
JSONObject
sort
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
filter
.
get
(
"sort"
)));
builder
.
sort
(
sort
.
getString
(
"field"
),
sort
.
getString
(
"order"
).
equals
(
"desc"
)
?
SortOrder
.
DESC
:
SortOrder
.
ASC
);
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"
;
}
builder
.
sort
(
field
,
sort
.
getString
(
"order"
).
equals
(
"desc"
)
?
SortOrder
.
DESC
:
SortOrder
.
ASC
);
}
}
builder
.
query
(
boolMust
);
builder
.
query
(
boolMust
);
// builder.sort("REC_DATE", SortOrder.DESC);
builder
.
from
((
current
-
1
)
*
size
);
builder
.
from
((
current
-
1
)
*
size
);
builder
.
size
(
size
);
builder
.
size
(
size
);
request
.
source
(
builder
);
request
.
source
(
builder
);
List
<
JSONObject
>
list
=
new
LinkedList
<>();
List
<
JSONObject
>
list
=
new
LinkedList
<>();
long
totle
=
0
;
long
totle
=
0
;
long
pipeLong
=
0L
;
try
{
try
{
SearchResponse
response
=
restHighLevelClient
.
search
(
request
,
RequestOptions
.
DEFAULT
);
SearchResponse
response
=
restHighLevelClient
.
search
(
request
,
RequestOptions
.
DEFAULT
);
for
(
SearchHit
hit
:
response
.
getHits
().
getHits
())
{
for
(
SearchHit
hit
:
response
.
getHits
().
getHits
())
{
...
@@ -381,6 +485,17 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
...
@@ -381,6 +485,17 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
JSONObject
dto
=
jsonObject
.
getJSONObject
(
"sourceAsMap"
);
JSONObject
dto
=
jsonObject
.
getJSONObject
(
"sourceAsMap"
);
dto
.
put
(
"record"
,
dto
.
get
(
"SEQUENCE_NBR"
));
dto
.
put
(
"record"
,
dto
.
get
(
"SEQUENCE_NBR"
));
dto
.
put
(
"equipAddress"
,
dto
.
get
(
"USE_PLACE"
)
+
"/"
+
dto
.
get
(
"ADDRESS"
));
dto
.
put
(
"equipAddress"
,
dto
.
get
(
"USE_PLACE"
)
+
"/"
+
dto
.
get
(
"ADDRESS"
));
if
(
dto
.
get
(
"EQU_LIST_CODE"
).
equals
(
"8000"
))
{
JSONArray
techParams
=
(
JSONArray
)
dto
.
get
(
"techParams"
);
if
(!
ObjectUtils
.
isEmpty
(
techParams
))
{
Object
obj
=
techParams
.
stream
().
filter
(
item
->
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
item
)).
get
(
"paramKey"
).
equals
(
"pipeLength"
)).
findFirst
().
get
();
JSONObject
jsonParam
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
obj
));
if
(
jsonParam
.
containsKey
(
"strValue"
))
{
String
pipeLength
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
obj
)).
get
(
"strValue"
).
toString
();
pipeLong
+=
Long
.
parseLong
(
pipeLength
);
}
}
}
list
.
add
(
dto
);
list
.
add
(
dto
);
}
}
totle
=
Objects
.
requireNonNull
(
response
.
getInternalResponse
().
hits
().
getTotalHits
()).
value
;
totle
=
Objects
.
requireNonNull
(
response
.
getInternalResponse
().
hits
().
getTotalHits
()).
value
;
...
@@ -397,8 +512,29 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
...
@@ -397,8 +512,29 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
sum
.
put
(
"value"
,
totle
);
sum
.
put
(
"value"
,
totle
);
statics
.
add
(
sum
);
statics
.
add
(
sum
);
if
(!
ObjectUtils
.
isEmpty
(
filterParams
)
&&
filterParams
.
containsKey
(
"EQU_LIST"
))
{
JSONArray
equList
=
(
JSONArray
)
filterParams
.
get
(
"EQU_LIST"
);
if
(
equList
.
contains
(
"8000"
)
||
equList
.
contains
(
"all"
))
{
// 压力管道长度
Map
<
String
,
Object
>
pipeMap
=
new
HashMap
<>();
pipeMap
.
put
(
"name"
,
"压力管道(千米)"
);
pipeMap
.
put
(
"value"
,
pipeLong
);
statics
.
add
(
pipeMap
);
}
if
(
equList
.
contains
(
"2000"
)
||
equList
.
contains
(
"all"
))
{
// 气瓶数量
Map
<
String
,
Object
>
gasMap
=
new
HashMap
<>();
gasMap
.
put
(
"name"
,
"气瓶(个)"
);
Map
<
String
,
Object
>
gas
=
new
HashMap
<>();
gas
.
put
(
DPMapStatisticsItemEnum
.
GAS
.
getCode
(),
0
);
long
cylinderNum
=
stCommonService
.
staticsCenterMapCountDataForCylinder
(
gas
,
orgCode
,
true
,
true
,
false
);
// 1. 8大类设备数量统计,压力容器里包括气瓶所以需要特殊处理,在统计压力容器时去掉气瓶的数量
stCommonService
.
staticsCenterMapCountDataForEquip
(
gas
,
cylinderNum
,
orgCode
,
true
,
true
,
false
);
gasMap
.
put
(
"value"
,
gas
.
get
(
DPMapStatisticsItemEnum
.
GAS
.
getCode
()));
statics
.
add
(
gasMap
);
}
}
result
.
put
(
"statics"
,
statics
);
result
.
put
(
"statics"
,
statics
);
return
result
;
return
result
;
}
}
...
@@ -414,6 +550,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
...
@@ -414,6 +550,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
log
.
error
(
e
.
getMessage
());
log
.
error
(
e
.
getMessage
());
}
}
}
}
/**
/**
* 发送主题消息,给企业推送excel 结束下载提醒
* 发送主题消息,给企业推送excel 结束下载提醒
*
*
...
@@ -430,7 +567,8 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
...
@@ -430,7 +567,8 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
/**
/**
* 综合统计分析接口-导出
* 综合统计分析接口-导出
* @param uuid uuid
*
* @param uuid uuid
* @param filter 过滤条件
* @param filter 过滤条件
*/
*/
public
void
export
(
String
uuid
,
JSONObject
filter
)
{
public
void
export
(
String
uuid
,
JSONObject
filter
)
{
...
...
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