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
0cf773bd
Commit
0cf773bd
authored
Jul 20, 2023
by
caotao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
接口查询慢问题优化
parent
1301c96e
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
87 deletions
+75
-87
CommonServiceImpl.java
...boot/module/jxiop/biz/service/impl/CommonServiceImpl.java
+9
-7
MonitoringServiceImpl.java
.../module/jxiop/biz/service/impl/MonitoringServiceImpl.java
+54
-46
InfluxDButils.java
...ejoin/amos/boot/module/jxiop/biz/utils/InfluxDButils.java
+12
-34
No files found.
amos-boot-system-jxiop/amos-boot-module-jxiop-monitor-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/service/impl/CommonServiceImpl.java
View file @
0cf773bd
...
...
@@ -7,11 +7,14 @@ import com.yeejoin.amos.boot.module.jxiop.biz.dto.IndicatorsDto;
import
com.yeejoin.amos.boot.module.jxiop.biz.dto.SocialContributionDto
;
import
com.yeejoin.amos.boot.module.jxiop.biz.mapper2.SjglZsjZsbtzMapper
;
import
com.yeejoin.amos.boot.module.jxiop.biz.utils.InfluxDButils
;
import
com.yeejoin.amos.component.influxdb.InfluxdbUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.atomic.AtomicReference
;
import
java.util.stream.Collectors
;
...
...
@@ -20,7 +23,8 @@ public class CommonServiceImpl {
@Autowired
InfluxDButils
influxDButils
;
@Autowired
InfluxdbUtil
influxdbUtil
;
@Autowired
SjglZsjZsbtzMapper
sjglZsjZsbtzMapper
;
...
...
@@ -33,9 +37,8 @@ public class CommonServiceImpl {
public
Double
getTotalByIndicatior
(
String
gatewayId
,
String
indicator
){
String
sql
=
"SELECT * FROM indicators_"
+
gatewayId
+
" where equipmentIndexName='"
+
indicator
+
"'"
;
Double
totalvalue
=
0.0
;
List
<
IndicatorsDto
>
indicatorsDtoList
=
influxDButils
.
getListData
(
sql
,
IndicatorsDto
.
class
);
List
<
Double
>
doubleList
=
indicatorsDtoList
.
stream
().
map
(
indicatorsDto
->
Double
.
parseDouble
(
indicatorsDto
.
getValue
())).
collect
(
Collectors
.
toList
());
totalvalue
=
doubleList
.
stream
().
mapToDouble
(
Double:
:
doubleValue
).
sum
();
List
<
Map
<
String
,
Object
>>
mapList
=
influxdbUtil
.
query
(
sql
);
totalvalue
=
mapList
.
stream
().
filter
(
stringObjectMap
->
!
ObjectUtils
.
isEmpty
(
stringObjectMap
.
get
(
"value"
))).
mapToDouble
(
l
->
Double
.
parseDouble
((
String
)
l
.
get
(
"value"
))).
sum
();
return
Double
.
valueOf
(
String
.
format
(
"%.2f"
,
totalvalue
));
}
/**
...
...
@@ -47,9 +50,8 @@ public class CommonServiceImpl {
public
Double
getAvgvalueByIndicatior
(
String
gatewayId
,
String
indicator
){
String
sql
=
"SELECT * FROM indicators_"
+
gatewayId
+
" where equipmentIndexName='"
+
indicator
+
"'"
;
Double
avageValue
=
0.0
;
List
<
IndicatorsDto
>
indicatorsDtoList
=
influxDButils
.
getListData
(
sql
,
IndicatorsDto
.
class
);
List
<
Double
>
doubleList
=
indicatorsDtoList
.
stream
().
map
(
indicatorsDto
->
Double
.
parseDouble
(
indicatorsDto
.
getValue
())).
collect
(
Collectors
.
toList
());
avageValue
=
doubleList
.
stream
().
mapToDouble
(
Double:
:
doubleValue
).
average
().
getAsDouble
();
List
<
Map
<
String
,
Object
>>
mapList
=
influxdbUtil
.
query
(
sql
);
avageValue
=
mapList
.
stream
().
filter
(
stringObjectMap
->
!
ObjectUtils
.
isEmpty
(
stringObjectMap
.
get
(
"value"
))).
mapToDouble
(
l
->
Double
.
parseDouble
((
String
)
l
.
get
(
"value"
))).
average
().
getAsDouble
();
return
Double
.
valueOf
(
String
.
format
(
"%.2f"
,
avageValue
));
}
...
...
amos-boot-system-jxiop/amos-boot-module-jxiop-monitor-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/service/impl/MonitoringServiceImpl.java
View file @
0cf773bd
...
...
@@ -3,6 +3,7 @@ package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import
com.alibaba.fastjson.JSON
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.sun.org.apache.bcel.internal.generic.NEW
;
import
com.yeejoin.amos.boot.module.jxiop.api.entity.MapRegion
;
import
com.yeejoin.amos.boot.module.jxiop.api.entity.Region
;
import
com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic
;
...
...
@@ -12,11 +13,14 @@ import com.yeejoin.amos.boot.module.jxiop.api.mapper.RegionMapper;
import
com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper
;
import
com.yeejoin.amos.boot.module.jxiop.api.mapper.StationCoordinateMapper
;
import
com.yeejoin.amos.boot.module.jxiop.biz.dto.*
;
import
com.yeejoin.amos.component.influxdb.InfluxdbUtil
;
import
org.eclipse.paho.client.mqttv3.MqttException
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.stereotype.Service
;
import
org.springframework.ui.context.ThemeSource
;
import
org.springframework.util.ObjectUtils
;
import
org.typroject.tyboot.component.emq.EmqKeeper
;
...
...
@@ -62,7 +66,6 @@ public class MonitoringServiceImpl {
@Autowired
EmqKeeper
emqKeeper
;
/**
* 根据场站编号获取该场站的装机容量
*
...
...
@@ -83,9 +86,11 @@ public class MonitoringServiceImpl {
*/
public
List
<
RegionNationWideDto
>
getNationWideInfo
(
String
provinceName
)
{
List
<
RegionNationWideDto
>
regionNationWideDtoList
=
new
ArrayList
<>();
List
<
StationBasic
>
stationBasicList
=
stationBasicMapper
.
selectList
(
new
QueryWrapper
<
StationBasic
>().
isNotNull
(
"belong_area"
));
List
<
Region
>
regionList
=
this
.
regionMapper
.
selectList
(
new
QueryWrapper
<
Region
>().
eq
(
"level"
,
1
));
List
<
StationBasic
>
list
=
new
ArrayList
<>();
//如果 provinceName 为空则表示当前为全国地图 否则则为省份地图
if
(
ObjectUtils
.
isEmpty
(
provinceName
)
||
provinceName
.
equals
(
""
))
{
List
<
Region
>
regionList
=
this
.
regionMapper
.
selectList
(
new
QueryWrapper
<
Region
>().
eq
(
"level"
,
1
));
for
(
int
i
=
0
;
i
<
regionList
.
size
();
i
++)
{
RegionNationWideDto
regionNationWideDto
=
new
RegionNationWideDto
();
AtomicReference
<
Double
>
guangfuMW
=
new
AtomicReference
<>(
0.0
);
...
...
@@ -93,7 +98,7 @@ public class MonitoringServiceImpl {
AtomicReference
<
Integer
>
guangfu
=
new
AtomicReference
<>(
0
);
AtomicReference
<
Integer
>
fengdian
=
new
AtomicReference
<>(
0
);
Region
region
=
regionList
.
get
(
i
);
List
<
StationBasic
>
list
=
stationBasicMapper
.
selectList
(
new
QueryWrapper
<
StationBasic
>().
like
(
"belong_area"
,
region
.
getRegionCode
()
));
list
=
stationBasicList
.
stream
().
filter
(
stationBasic
->
stationBasic
.
getBelongArea
().
contains
(
String
.
valueOf
(
region
.
getRegionCode
()))).
collect
(
Collectors
.
toList
(
));
list
.
forEach
(
stationBasic
->
{
if
(!
ObjectUtils
.
isEmpty
(
stationBasic
.
getFanGatewayId
())
&&
!
ObjectUtils
.
isEmpty
(
stationBasic
.
getStationNumber
()))
{
regionNationWideDto
.
setJsJoin
(
true
);
...
...
@@ -127,8 +132,10 @@ public class MonitoringServiceImpl {
}
}
Region
region
=
this
.
regionMapper
.
selectOne
(
new
QueryWrapper
<
Region
>().
eq
(
"level"
,
1
).
eq
(
"region_name"
,
provinceName
));
List
<
StationBasic
>
list
=
stationBasicMapper
.
selectList
(
new
QueryWrapper
<
StationBasic
>().
like
(
"belong_area"
,
region
.
getRegionCode
()));
String
finalProvinceName
=
provinceName
;
Region
region
=
regionList
.
stream
().
filter
(
region1
->
region1
.
getRegionName
().
equals
(
finalProvinceName
)).
collect
(
Collectors
.
toList
()).
get
(
0
);
list
=
stationBasicList
.
stream
().
filter
(
stationBasic
->
stationBasic
.
getBelongArea
().
contains
(
String
.
valueOf
(
region
.
getRegionCode
()))
&&
stationBasic
.
getFanGatewayId
()
!=
null
).
collect
(
Collectors
.
toList
());
List
<
StationCoordinate
>
stationCoordinateList
=
stationCoordinateMapper
.
selectList
(
new
QueryWrapper
<
StationCoordinate
>().
isNotNull
(
"station_id"
).
eq
(
"is_main_coordinate"
,
0
));
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
HashMap
<
String
,
Double
>
hashMap
=
new
HashMap
<>();
StationBasic
stationBasic
=
list
.
get
(
i
);
...
...
@@ -145,28 +152,19 @@ public class MonitoringServiceImpl {
regionNationWideDto
.
setSpeendOrirradiate
(
String
.
valueOf
(
Math
.
random
()
*
100
));
regionNationWideDto
.
setStationCapacity
(
"0"
);
}
StationCoordinate
stationCoordinate
=
stationCoordinate
Mapper
.
selectOne
(
new
QueryWrapper
<
StationCoordinate
>().
eq
(
"station_id"
,
stationBasic
.
getSequenceNbr
()).
eq
(
"is_main_coordinate"
,
0
)
);
StationCoordinate
stationCoordinate
=
stationCoordinate
List
.
stream
().
filter
(
stationCoordinate1
->
stationCoordinate1
.
getStationId
().
equals
(
stationBasic
.
getSequenceNbr
())).
collect
(
Collectors
.
toList
()).
get
(
0
);
hashMap
.
put
(
"lng"
,
Double
.
valueOf
(
stationCoordinate
.
getLongitude
()));
hashMap
.
put
(
"lat"
,
Double
.
valueOf
(
stationCoordinate
.
getLaitude
()));
regionNationWideDto
.
setPosition
(
hashMap
);
regionNationWideDtoList
.
add
(
regionNationWideDto
);
}
String
provinceNameTopic
=
""
;
if
(
provinceName
.
contains
(
"黑龙江"
)
||
provinceName
.
contains
(
"内蒙古"
))
{
provinceNameTopic
=
provinceName
.
substring
(
0
,
3
);
}
else
{
provinceNameTopic
=
provinceName
.
substring
(
0
,
2
);
}
HashMap
<
String
,
String
>
stringHashMap
=
new
HashMap
<>();
stringHashMap
.
put
(
"title"
,
provinceNameTopic
+
"区域"
);
try
{
emqKeeper
.
getMqttClient
().
publish
(
"proviceName_topic"
,
JSON
.
toJSON
(
stringHashMap
).
toString
().
getBytes
(
"UTF-8"
),
1
,
true
);
logger
.
info
(
"----------------------------------推送省份名称消息成功败--------------------------------"
);
}
catch
(
Exception
e
)
{
logger
.
info
(
"----------------------------------推送省份名称消息失败--------------------------------"
);
}
getCompletionOfPowerIndicatorsByCurrentData
(
provinceName
);
}
List
<
StationBasic
>
finalList
=
list
;
String
finalProvinceName1
=
provinceName
;
Thread
thread
=
new
Thread
(()->{
getCompletionOfPowerIndicatorsByCurrentData
(
finalList
,
finalProvinceName1
);
});
thread
.
start
();
return
regionNationWideDtoList
;
}
...
...
@@ -220,12 +218,24 @@ public class MonitoringServiceImpl {
return
resultsData
;
}
public
void
getCompletionOfPowerIndicatorsByCurrentData
(
String
provinceName
)
{
public
void
getCompletionOfPowerIndicatorsByCurrentData
(
List
<
StationBasic
>
stationBasicList
,
String
provinceName
)
{
String
provinceNameTopic
=
""
;
if
(
provinceName
.
contains
(
"黑龙江"
)
||
provinceName
.
contains
(
"内蒙古"
))
{
provinceNameTopic
=
provinceName
.
substring
(
0
,
3
);
}
else
{
provinceNameTopic
=
provinceName
.
substring
(
0
,
2
);
}
HashMap
<
String
,
String
>
stringHashMap
=
new
HashMap
<>();
stringHashMap
.
put
(
"title"
,
provinceNameTopic
+
"区域"
);
try
{
emqKeeper
.
getMqttClient
().
publish
(
"proviceName_topic"
,
JSON
.
toJSON
(
stringHashMap
).
toString
().
getBytes
(
"UTF-8"
),
1
,
true
);
logger
.
info
(
"----------------------------------推送省份名称消息成功败--------------------------------"
);
}
catch
(
Exception
e
)
{
logger
.
info
(
"----------------------------------推送省份名称消息失败--------------------------------"
);
}
Page
<
SocialContributionDto
>
socialContributionDtoPage
=
new
Page
<
SocialContributionDto
>();
logger
.
error
(
"--------------------------区域实时数据消息开始发送----------------------------------------------"
);
List
<
SocialContributionDto
>
socialContributionDtoList
=
new
ArrayList
<>();
Region
region
=
this
.
regionMapper
.
selectOne
(
new
QueryWrapper
<
Region
>().
eq
(
"level"
,
1
).
eq
(
"region_name"
,
"江西省"
));
List
<
StationBasic
>
stationBasicList
=
stationBasicMapper
.
selectList
(
new
QueryWrapper
<
StationBasic
>().
like
(
"belong_area"
,
region
.
getRegionCode
()).
isNotNull
(
"fan_gateway_id"
));
//日发电量
AtomicReference
<
Double
>
dailyPower
=
new
AtomicReference
<>(
0.0
);
//月发电量
...
...
@@ -243,19 +253,19 @@ public class MonitoringServiceImpl {
useHours
.
updateAndGet
(
v
->
v
+
commonServiceImpl
.
getTotalByIndicatior
(
stationBasic
.
getFanGatewayId
(),
"日工作时间"
));
});
SocialContributionDto
dailyPowerdto
=
new
SocialContributionDto
();
dailyPowerdto
.
setTitle
(
String
.
format
(
"%.2f"
,
dailyPower
.
get
()));
dailyPowerdto
.
setTitle
(
String
.
format
(
"%.2f"
,
dailyPower
.
get
()));
dailyPowerdto
.
setUnit
(
"万kWh"
);
SocialContributionDto
monthlyPowerdto
=
new
SocialContributionDto
();
monthlyPowerdto
.
setTitle
(
String
.
format
(
"%.2f"
,
monthlyPower
.
get
()));
monthlyPowerdto
.
setTitle
(
String
.
format
(
"%.2f"
,
monthlyPower
.
get
()));
monthlyPowerdto
.
setUnit
(
"万kWh"
);
SocialContributionDto
annualPowerdto
=
new
SocialContributionDto
();
annualPowerdto
.
setTitle
(
String
.
format
(
"%.2f"
,
annualPower
.
get
()));
annualPowerdto
.
setTitle
(
String
.
format
(
"%.2f"
,
annualPower
.
get
()));
annualPowerdto
.
setUnit
(
"万kWh"
);
SocialContributionDto
completionRatioDto
=
new
SocialContributionDto
();
completionRatioDto
.
setTitle
(
completionRatio
);
completionRatioDto
.
setUnit
(
"%"
);
SocialContributionDto
useHoursDto
=
new
SocialContributionDto
();
useHoursDto
.
setTitle
(
String
.
format
(
"%.2f"
,
useHours
.
get
()));
useHoursDto
.
setTitle
(
String
.
format
(
"%.2f"
,
useHours
.
get
()));
useHoursDto
.
setUnit
(
"h"
);
socialContributionDtoList
.
add
(
dailyPowerdto
);
socialContributionDtoList
.
add
(
monthlyPowerdto
);
...
...
@@ -272,6 +282,7 @@ public class MonitoringServiceImpl {
logger
.
error
(
"-----------------发送区域实时生产数据消息=================== 失败!"
);
}
}
public
List
<
TabDto
>
getTabsByStationBasicId
(
String
stationBasicId
)
{
StationBasic
stationBasic
=
stationBasicMapper
.
selectById
(
stationBasicId
);
List
<
TabDto
>
tabDtoList
=
new
ArrayList
<>();
...
...
@@ -311,19 +322,18 @@ public class MonitoringServiceImpl {
public
List
<
MapAreaInfoDto
>
getAreaInfo
()
{
List
<
MapAreaInfoDto
>
mapAreaInfoDtoList
=
new
ArrayList
<>();
List
<
StationBasic
>
stationBasicList
All
=
new
ArrayList
<>(
);
List
<
StationBasic
>
stationBasicList
=
stationBasicMapper
.
selectList
(
new
QueryWrapper
<
StationBasic
>().
isNotNull
(
"belong_area"
)
);
List
<
MapRegion
>
mapRegionList
=
mapRegionMapper
.
selectList
(
new
QueryWrapper
<
MapRegion
>().
isNotNull
(
"name"
));
List
<
Region
>
regionList
=
regionMapper
.
selectList
(
new
QueryWrapper
<
Region
>().
eq
(
"LEVEL"
,
1
));
mapRegionList
.
forEach
(
mapRegion
->
{
MapAreaInfoDto
mapAreaInfoDto
=
new
MapAreaInfoDto
();
//开始处理省份名称-三维与二维的名称有差异
ArrayList
<
String
>
stringArrayList
=
mapRegion
.
getProvince
();
for
(
int
i
=
0
;
i
<
stringArrayList
.
size
();
i
++)
{
Region
region
=
regionMapper
.
selectOne
(
new
QueryWrapper
<
Region
>().
eq
(
"LEVEL"
,
1
).
like
(
"REGION_NAME"
,
stringArrayList
.
get
(
i
)));
List
<
StationBasic
>
stationBasicList
=
stationBasicMapper
.
selectList
(
new
QueryWrapper
<
StationBasic
>().
like
(
"belong_area"
,
region
.
getRegionCode
()));
stringArrayList
.
set
(
i
,
region
.
getRegionName
());
stationBasicListAll
.
addAll
(
stationBasicList
);
}
mapAreaInfoDto
.
setProvince
(
stringArrayList
);
List
<
Region
>
regions
=
regionList
.
stream
().
filter
(
region
->
stringArrayList
.
contains
(
region
.
getRegionName
().
substring
(
0
,
2
))
||
stringArrayList
.
contains
(
region
.
getRegionName
().
substring
(
0
,
3
))).
collect
(
Collectors
.
toList
());
List
<
String
>
regionNames
=
regions
.
stream
().
map
(
region
->
region
.
getRegionName
()).
collect
(
Collectors
.
toList
());
List
<
String
>
regionCodes
=
regions
.
stream
().
map
(
region
->
String
.
valueOf
(
region
.
getRegionCode
())).
collect
(
Collectors
.
toList
());
List
<
StationBasic
>
stationBasicListAll
=
stationBasicList
.
stream
().
filter
(
stationBasic
->
regionCodes
.
contains
(
stationBasic
.
getBelongArea
().
replace
(
"["
,
""
).
replace
(
"]"
,
""
).
split
(
","
)[
0
])).
collect
(
Collectors
.
toList
());
mapAreaInfoDto
.
setProvince
(
regionNames
);
// --------------------省份名称处理结束----------------------------
//设置片区名称
mapAreaInfoDto
.
setAreaName
(
mapRegion
.
getName
());
...
...
@@ -350,20 +360,17 @@ public class MonitoringServiceImpl {
public
List
<
HomeMapStationInfoDto
>
getStaitonListInfoByAreaName
(
String
areaName
)
{
List
<
HomeMapStationInfoDto
>
homeMapStationInfoDtoList
=
new
ArrayList
<>();
List
<
StationBasic
>
stationBasicListAll
=
new
ArrayList
<>();
List
<
StationBasic
>
stationBasicList
=
stationBasicMapper
.
selectList
(
new
QueryWrapper
<
StationBasic
>().
isNotNull
(
"belong_area"
).
isNotNull
(
"fan_gateway_id"
));
List
<
Region
>
regionList
=
regionMapper
.
selectList
(
new
QueryWrapper
<
Region
>().
eq
(
"LEVEL"
,
1
));
//根据areaName获取area信息
MapRegion
mapRegion
=
mapRegionMapper
.
selectOne
(
new
QueryWrapper
<
MapRegion
>().
eq
(
"name"
,
areaName
));
//获取片区下的省份名称
ArrayList
<
String
>
stringArrayList
=
mapRegion
.
getProvince
();
//变量获取所有的场站信息
for
(
int
i
=
0
;
i
<
stringArrayList
.
size
();
i
++)
{
Region
region
=
regionMapper
.
selectOne
(
new
QueryWrapper
<
Region
>().
eq
(
"LEVEL"
,
1
).
like
(
"REGION_NAME"
,
stringArrayList
.
get
(
i
)));
List
<
StationBasic
>
stationBasicList
=
stationBasicMapper
.
selectList
(
new
QueryWrapper
<
StationBasic
>().
like
(
"belong_area"
,
region
.
getRegionCode
()));
stringArrayList
.
set
(
i
,
region
.
getRegionName
());
stationBasicListAll
.
addAll
(
stationBasicList
);
}
List
<
Region
>
regions
=
regionList
.
stream
().
filter
(
region
->
stringArrayList
.
contains
(
region
.
getRegionName
().
substring
(
0
,
2
))
||
stringArrayList
.
contains
(
region
.
getRegionName
().
substring
(
0
,
3
))).
collect
(
Collectors
.
toList
());
List
<
String
>
regionCodes
=
regions
.
stream
().
map
(
region
->
String
.
valueOf
(
region
.
getRegionCode
())).
collect
(
Collectors
.
toList
());
List
<
StationBasic
>
stationBasicListAll
=
stationBasicList
.
stream
().
filter
(
stationBasic
->
regionCodes
.
contains
(
stationBasic
.
getBelongArea
().
replace
(
"["
,
""
).
replace
(
"]"
,
""
).
split
(
","
)[
0
])).
collect
(
Collectors
.
toList
());
List
<
StationCoordinate
>
stationCoordinateList
=
stationCoordinateMapper
.
selectList
(
new
QueryWrapper
<
StationCoordinate
>().
eq
(
"is_main_coordinate"
,
0
));
if
(!
stationBasicListAll
.
isEmpty
())
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
stationBasicListAll
.
forEach
(
stationBasic
->
{
HomeMapStationInfoDto
homeMapStationInfoDto
=
new
HomeMapStationInfoDto
();
//设置场站id
...
...
@@ -380,7 +387,7 @@ public class MonitoringServiceImpl {
}
else
{
homeMapStationInfoDto
.
setSpeendOrirradiate
(
String
.
valueOf
(
Math
.
random
()
*
100
));
}
StationCoordinate
stationCoordinate
=
stationCoordinate
Mapper
.
selectOne
(
new
QueryWrapper
<
StationCoordinate
>().
eq
(
"station_id"
,
stationBasic
.
getSequenceNbr
()).
eq
(
"is_main_coordinate"
,
0
)
);
StationCoordinate
stationCoordinate
=
stationCoordinate
List
.
stream
().
filter
(
stationCoordinate1
->
stationCoordinate1
.
getStationId
().
equals
(
stationBasic
.
getSequenceNbr
())).
collect
(
Collectors
.
toList
()).
get
(
0
);
//获取场站经纬度
List
<
String
>
list
=
new
ArrayList
<>();
list
.
add
(
stationCoordinate
.
getLongitude
());
...
...
@@ -409,6 +416,7 @@ public class MonitoringServiceImpl {
}
public
String
getPowerOfDaily
(
List
<
StationBasic
>
stationBasicList
)
{
AtomicReference
<
Double
>
total
=
new
AtomicReference
<>(
0.0
);
stationBasicList
.
forEach
(
stationBasic
->
{
if
(
stationBasic
.
getFanGatewayId
()
!=
null
)
{
...
...
amos-boot-system-jxiop/amos-boot-module-jxiop-monitor-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/utils/InfluxDButils.java
View file @
0cf773bd
package
com
.
yeejoin
.
amos
.
boot
.
module
.
jxiop
.
biz
.
utils
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.squareup.moshi.Json
;
import
com.yeejoin.amos.boot.module.jxiop.biz.dto.IndicatorsDto
;
import
com.yeejoin.amos.component.influxdb.InfluxDbConnection
;
import
com.yeejoin.amos.component.influxdb.InfluxdbUtil
;
import
org.influxdb.dto.QueryResult
;
import
org.springframework.beans.BeanWrapperImpl
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -10,11 +15,15 @@ import org.springframework.util.ObjectUtils;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
@Component
public
class
InfluxDButils
{
@Autowired
InfluxDbConnection
influxDbConnection
;
@Autowired
InfluxdbUtil
influxdbUtil
;
public
<
T
>
List
<
T
>
getListData
(
String
sql
,
Class
<
T
>
clazz
)
{
List
<
T
>
list
=
new
ArrayList
<>();
try
{
...
...
@@ -53,39 +62,8 @@ public class InfluxDButils {
public
<
T
>
List
<
T
>
getListData1
(
String
sql
,
Class
<
T
>
clazz
)
{
List
<
T
>
list
=
new
ArrayList
<>();
try
{
QueryResult
query
=
influxDbConnection
.
query
(
sql
);
List
<
QueryResult
.
Result
>
queryResults
=
query
.
getResults
();
for
(
QueryResult
.
Result
result
:
queryResults
)
{
List
<
QueryResult
.
Series
>
series
=
result
.
getSeries
();
if
(
series
==
null
)
{
continue
;
}
for
(
QueryResult
.
Series
serie
:
series
)
{
List
<
List
<
Object
>>
values
=
serie
.
getValues
();
List
<
String
>
columns
=
serie
.
getColumns
();
for
(
int
i
=
0
;
i
<
values
.
size
();
++
i
)
{
T
object
=
clazz
.
newInstance
();
BeanWrapperImpl
bean
=
new
BeanWrapperImpl
(
object
);
for
(
int
j
=
0
;
j
<
columns
.
size
();
++
j
)
{
String
k
=
columns
.
get
(
j
).
replace
(
"last_"
,
""
);
Object
v
=
values
.
get
(
i
).
get
(
j
);
System
.
out
.
println
(
k
);
System
.
out
.
println
(
v
);
if
(
"time"
.
equals
(
k
))
{
continue
;
}
else
{
// if(ObjectUtils.isEmpty(v)){
// bean.setPropertyValue(k, "");
// }else{
bean
.
setPropertyValue
(
k
,
v
);
// }
}
}
list
.
add
(
object
);
}
}
}
List
<
Map
<
String
,
Object
>>
mapList
=
influxdbUtil
.
query
(
sql
);
list
=
mapList
.
stream
().
map
(
stringObjectMap
->
JSONObject
.
parseObject
(
JSON
.
toJSONString
(
stringObjectMap
),
clazz
)).
collect
(
Collectors
.
toList
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
...
...
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