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
236c5212
Commit
236c5212
authored
Jun 01, 2024
by
韩桐桐
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(cyl):市级为维度,各市的充装次数和累计充装量
parent
e94990e4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
74 additions
and
20 deletions
+74
-20
CylinderInfoController.java
...e/cylinder/flc/biz/controller/CylinderInfoController.java
+1
-1
CylinderInfoServiceImpl.java
...ylinder/flc/biz/service/impl/CylinderInfoServiceImpl.java
+68
-14
application-cyl.properties
...ylinder-biz/src/main/resources/application-cyl.properties
+4
-4
application.properties
...le-cylinder-biz/src/main/resources/application.properties
+1
-1
No files found.
amos-boot-system-tzs/amos-boot-module-cylinder/amos-boot-module-cylinder-biz/src/main/java/com/yeejoin/amos/boot/module/cylinder/flc/biz/controller/CylinderInfoController.java
View file @
236c5212
...
...
@@ -1361,7 +1361,7 @@ public class CylinderInfoController extends BaseController {
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"市级为维度,各市的充装次数和累计充装量"
)
@GetMapping
(
value
=
"/countFillingTimesAndQuantityByCity"
)
public
ResponseModel
<
Object
>
countFillingTimesAndQuantityByCity
()
{
public
ResponseModel
<
Map
<
String
,
Object
>
>
countFillingTimesAndQuantityByCity
()
{
return
ResponseHelper
.
buildResponse
(
cylinderInfoServiceImpl
.
countFillingTimesAndQuantityByCity
());
}
}
amos-boot-system-tzs/amos-boot-module-cylinder/amos-boot-module-cylinder-biz/src/main/java/com/yeejoin/amos/boot/module/cylinder/flc/biz/service/impl/CylinderInfoServiceImpl.java
View file @
236c5212
...
...
@@ -1260,66 +1260,120 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
public
List
<
Map
<
String
,
Object
>
>
countFillingTimesAndQuantityByCity
()
{
public
Map
<
String
,
Object
>
countFillingTimesAndQuantityByCity
()
{
// 查询所有的市级城市
List
<
RegionModel
>
regionModelList
=
Systemctl
.
regionClient
.
queryByLevel
(
"2"
).
getResult
();
// 并行处理每个城市的数据
List
<
CompletableFuture
<
Map
<
String
,
Object
>>>
futures
=
regionModelList
.
stream
()
.
map
(
regionModel
->
CompletableFuture
.
supplyAsync
(()
->
esQuery
(
regionModel
)))
.
collect
(
Collectors
.
toList
());
return
futures
.
stream
()
List
<
Map
<
String
,
Object
>>
collect
=
futures
.
stream
()
.
map
(
CompletableFuture:
:
join
)
.
collect
(
Collectors
.
toList
());
return
assemblingHistogramData
(
collect
);
// Map<String, Object> stringObjectMap = esQuery(regionModelList.get(3));
// ArrayList<Map<String, Object>> ss = new ArrayList<>();
// ss.add(stringObjectMap);
// return assemblingHistogramData(ss);
}
private
static
Map
<
String
,
Object
>
assemblingHistogramData
(
List
<
Map
<
String
,
Object
>>
collect
)
{
// 组装数据
// {
// "seriesData": [
// {
// "data": [
// 3,
// 2,
// 2,
// 3,
// 1
// ],
// "name": "正常点",
// "stack": "正常点"
// },
// {
// "data": [
// 1,
// 1,
// 2,
// 1,
// 2
// ],
// "name": "异常点",
// "stack": "巡检点"
// }
// ],
// "axisData": [
// "A",
// "B",
// "C",
// "D",
// "E"
// ]
// }
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
List
<
Map
<
String
,
Object
>>
seriesData
=
new
ArrayList
<>();
List
<
String
>
axisData
=
new
ArrayList
<>();
List
<
String
>
seriesFillingTimesDataList
=
new
ArrayList
<>();
List
<
String
>
seriesCumulativeFillingQuantityDataList
=
new
ArrayList
<>();
collect
.
forEach
(
x
->{
axisData
.
add
(
String
.
valueOf
(
x
.
get
(
"regionName"
)));
seriesFillingTimesDataList
.
add
(
String
.
valueOf
(
x
.
get
(
"fillingTimes"
)));
seriesCumulativeFillingQuantityDataList
.
add
(
String
.
valueOf
(
x
.
get
(
"fillingQuantity"
)));
});
HashMap
<
String
,
Object
>
temMap1
=
new
HashMap
<>();
temMap1
.
put
(
"data"
,
seriesFillingTimesDataList
);
temMap1
.
put
(
"name"
,
"充装次数"
);
temMap1
.
put
(
"stack"
,
"充装次数"
);
HashMap
<
String
,
Object
>
temMap2
=
new
HashMap
<>();
temMap2
.
put
(
"data"
,
seriesCumulativeFillingQuantityDataList
);
temMap2
.
put
(
"name"
,
"累计充装量"
);
temMap2
.
put
(
"stack"
,
"累计充装量"
);
seriesData
.
add
(
temMap1
);
seriesData
.
add
(
temMap2
);
result
.
put
(
"seriesData"
,
seriesData
);
result
.
put
(
"axisData"
,
axisData
);
return
result
;
}
private
Map
<
String
,
Object
>
esQuery
(
RegionModel
regionModel
)
{
SearchRequest
searchRequest
=
new
SearchRequest
(
INDEX_NAME
);
SearchSourceBuilder
searchSourceBuilder
=
new
SearchSourceBuilder
();
// 将 regionModel.getRegionCode() 转换成匹配中间部分的格式
String
regionCodePattern
=
"*"
+
regionModel
.
getRegionCode
()
+
"*"
;
BoolQueryBuilder
boolQueryBuilder
=
QueryBuilders
.
boolQuery
();
boolQueryBuilder
.
must
(
QueryBuilders
.
wildcardQuery
(
"regionCode"
,
regionCodePattern
));
searchSourceBuilder
.
query
(
boolQueryBuilder
);
searchSourceBuilder
.
aggregation
(
AggregationBuilders
.
cardinality
(
"total_filling_count"
)
.
field
(
"sequenceNbr
.keyword
"
)
.
field
(
"sequenceNbr"
)
);
searchSourceBuilder
.
aggregation
(
AggregationBuilders
.
sum
(
"total_filling_quantity"
)
.
field
(
"fillingQuantity"
)
);
searchRequest
.
source
(
searchSourceBuilder
);
System
.
out
.
println
(
"Search Request: "
+
searchRequest
);
try
{
// 执行搜索请求
SearchResponse
searchResponse
=
restHighLevelClient
.
search
(
searchRequest
,
RequestOptions
.
DEFAULT
);
// 获取所有聚合结果
Aggregations
aggregations
=
searchResponse
.
getAggregations
();
ParsedCardinality
cardinalityAgg
=
aggregations
.
get
(
"total_filling_count"
);
long
uniqueCount
=
cardinalityAgg
.
getValue
();
Sum
sumAgg
=
aggregations
.
get
(
"total_filling_quantity"
);
double
totalSum
=
sumAgg
.
getValue
();
System
.
out
.
println
(
"填充数量的唯一值数量: "
+
uniqueCount
);
System
.
out
.
println
(
"填充量的总和: "
+
totalSum
);
Map
<
String
,
Object
>
resultMap
=
new
HashMap
<>();
resultMap
.
put
(
REGION_CODE
,
regionModel
.
getRegionCode
());
resultMap
.
put
(
REGION_NAME
,
regionModel
.
getRegionName
());
resultMap
.
put
(
FILLING_TIMES
,
uniqueCount
);
resultMap
.
put
(
FILLING_QUANTITY
,
totalSum
);
return
resultMap
;
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
...
...
amos-boot-system-tzs/amos-boot-module-cylinder/amos-boot-module-cylinder-biz/src/main/resources/application-cyl.properties
View file @
236c5212
...
...
@@ -19,12 +19,12 @@ eureka.client.service-url.defaultZone=http://172.16.10.243:10001/eureka/
eureka.instance.prefer-ip-address
=
true
management.endpoint.health.show-details
=
always
management.endpoints.web.exposure.include
=
*
eureka.instance.health-check-url
=
http://172.16.3.
17
:${server.port}${server.servlet.context-path}/actuator/health
eureka.instance.health-check-url
=
http://172.16.3.
68
:${server.port}${server.servlet.context-path}/actuator/health
eureka.instance.metadata-map.management.context-path
=
${server.servlet.context-path}/actuator
eureka.instance.status-page-url
=
http://172.16.3.
17
:${server.port}${server.servlet.context-path}/actuator/info
eureka.instance.metadata-map.management.api-docs
=
http://172.16.3.
17
:${server.port}${server.servlet.context-path}/doc
\
eureka.instance.status-page-url
=
http://172.16.3.
68
:${server.port}${server.servlet.context-path}/actuator/info
eureka.instance.metadata-map.management.api-docs
=
http://172.16.3.
68
:${server.port}${server.servlet.context-path}/doc
\
.html
eureka.instance.ip-address
=
172.16.3.
17
eureka.instance.ip-address
=
172.16.3.
68
## ES properties:
elasticsearch.username
=
elastic
elasticsearch.password
=
a123456
...
...
amos-boot-system-tzs/amos-boot-module-cylinder/amos-boot-module-cylinder-biz/src/main/resources/application.properties
View file @
236c5212
spring.application.name
=
TZS-CYLINDER
spring.application.name
=
TZS-CYLINDER
-htt
server.servlet.context-path
=
/cylinder
server.port
=
11003
spring.profiles.active
=
cyl
...
...
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