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
28dd425a
Commit
28dd425a
authored
Jul 19, 2023
by
caotao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
省份随地图联动
parent
938b7331
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
105 additions
and
33 deletions
+105
-33
MonitoringServiceImpl.java
.../module/jxiop/biz/service/impl/MonitoringServiceImpl.java
+105
-33
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/MonitoringServiceImpl.java
View file @
28dd425a
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.yeejoin.amos.boot.module.jxiop.api.entity.MapRegion
;
...
...
@@ -11,13 +12,16 @@ 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
org.eclipse.paho.client.mqttv3.MqttException
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
org.typroject.tyboot.component.emq.EmqKeeper
;
import
java.net.URLDecoder
;
import
java.nio.charset.StandardCharsets
;
import
java.util.*
;
import
java.util.concurrent.atomic.AtomicReference
;
import
java.util.stream.Collectors
;
...
...
@@ -55,6 +59,9 @@ public class MonitoringServiceImpl {
@Autowired
MapRegionMapper
mapRegionMapper
;
@Autowired
EmqKeeper
emqKeeper
;
/**
* 根据场站编号获取该场站的装机容量
...
...
@@ -104,10 +111,10 @@ public class MonitoringServiceImpl {
regionNationWideDto
.
setGuangfuMW
(
"0"
);
regionNationWideDto
.
setFengdianMV
(
"0"
);
if
(!
ObjectUtils
.
isEmpty
(
guangfuMW
.
get
()))
{
regionNationWideDto
.
setGuangfuMW
(
String
.
format
(
"%.2f"
,
guangfuMW
.
get
()));
regionNationWideDto
.
setGuangfuMW
(
String
.
format
(
"%.2f"
,
guangfuMW
.
get
()));
}
if
(!
ObjectUtils
.
isEmpty
(
fengdianMW
.
get
()))
{
regionNationWideDto
.
setFengdianMV
(
String
.
format
(
"%.2f"
,
fengdianMW
.
get
()));
regionNationWideDto
.
setFengdianMV
(
String
.
format
(
"%.2f"
,
fengdianMW
.
get
()));
}
regionNationWideDto
.
setName
(
region
.
getRegionName
());
regionNationWideDtoList
.
add
(
regionNationWideDto
);
...
...
@@ -143,6 +150,19 @@ public class MonitoringServiceImpl {
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
);
}
try
{
emqKeeper
.
getMqttClient
().
publish
(
"proviceName_topic"
,
provinceNameTopic
.
getBytes
(
StandardCharsets
.
UTF_8
),
1
,
true
);
logger
.
info
(
"----------------------------------推送省份名称消息成功败--------------------------------"
);
}
catch
(
MqttException
e
)
{
logger
.
info
(
"----------------------------------推送省份名称消息失败--------------------------------"
);
}
getCompletionOfPowerIndicatorsByCurrentData
(
provinceName
);
}
}
...
...
@@ -151,8 +171,7 @@ public class MonitoringServiceImpl {
public
ResultsData
getCompletionOfPowerIndicatorsByProvinceName
(
int
current
,
int
size
,
String
provinceName
)
{
Region
region
=
this
.
regionMapper
.
selectOne
(
new
QueryWrapper
<
Region
>().
eq
(
"level"
,
1
).
eq
(
"region_name"
,
provinceName
));
List
<
StationBasic
>
stationBasicList
=
stationBasicMapper
.
selectList
(
new
QueryWrapper
<
StationBasic
>().
like
(
"belong_area"
,
region
.
getRegionCode
()));
List
<
ColModel
>
colModels
=
new
ArrayList
<>();
List
<
CompletionOfPowerIndicatorsDto
>
completionOfPowerIndicatorsDtoList
=
new
ArrayList
<>();
ColModel
colModelStatitonName
=
new
ColModel
(
"stationName"
,
"stationName"
,
"场站"
,
"场站"
,
"dataGrid"
,
"stationName"
);
...
...
@@ -169,13 +188,15 @@ public class MonitoringServiceImpl {
colModels
.
add
(
colModelDailyPower
);
colModels
.
add
(
colModelMonthlyPower
);
colModels
.
add
(
colModelAnnualPower
);
Region
region
=
this
.
regionMapper
.
selectOne
(
new
QueryWrapper
<
Region
>().
eq
(
"level"
,
1
).
eq
(
"region_name"
,
provinceName
));
List
<
StationBasic
>
stationBasicList
=
stationBasicMapper
.
selectList
(
new
QueryWrapper
<
StationBasic
>().
like
(
"belong_area"
,
region
.
getRegionCode
()));
//遍历列表
stationBasicList
.
forEach
(
stationBasic
->
{
CompletionOfPowerIndicatorsDto
completionOfPowerIndicatorsDto
=
new
CompletionOfPowerIndicatorsDto
();
completionOfPowerIndicatorsDto
.
setStationName
(
stationBasic
.
getStationName
());
completionOfPowerIndicatorsDto
.
setInstallCapactity
(
"0"
);
if
(
getStationCaPACITYL
(
stationBasic
.
getStationNumber
())
!=
null
)
{
completionOfPowerIndicatorsDto
.
setInstallCapactity
(
String
.
format
(
"%.2f"
,
getStationCaPACITYL
(
stationBasic
.
getStationNumber
())));
completionOfPowerIndicatorsDto
.
setInstallCapactity
(
String
.
format
(
"%.2f"
,
getStationCaPACITYL
(
stationBasic
.
getStationNumber
())));
}
try
{
completionOfPowerIndicatorsDto
.
setWindSpeedOrIrradiance
(
String
.
valueOf
(
commonServiceImpl
.
getAvgvalueByIndicatior
(
stationBasic
.
getFanGatewayId
(),
"30秒平均风速"
)));
...
...
@@ -198,7 +219,58 @@ public class MonitoringServiceImpl {
return
resultsData
;
}
public
void
getCompletionOfPowerIndicatorsByCurrentData
(
String
provinceName
)
{
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
);
//月发电量
AtomicReference
<
Double
>
monthlyPower
=
new
AtomicReference
<>(
0.0
);
//年发电量
AtomicReference
<
Double
>
annualPower
=
new
AtomicReference
<>(
0.0
);
//年发电量完成比例
String
completionRatio
=
"23.11"
;
//年利用小时数
AtomicReference
<
Double
>
useHours
=
new
AtomicReference
<>(
0.01
);
stationBasicList
.
forEach
(
stationBasic
->
{
dailyPower
.
updateAndGet
(
v
->
v
+
commonServiceImpl
.
getTotalByIndicatior
(
stationBasic
.
getFanGatewayId
(),
"日发电量"
));
monthlyPower
.
updateAndGet
(
v
->
v
+
commonServiceImpl
.
getTotalByIndicatior
(
stationBasic
.
getFanGatewayId
(),
"月发电量"
));
annualPower
.
updateAndGet
(
v
->
v
+
commonServiceImpl
.
getTotalByIndicatior
(
stationBasic
.
getFanGatewayId
(),
"年发电量"
));
useHours
.
updateAndGet
(
v
->
v
+
commonServiceImpl
.
getTotalByIndicatior
(
stationBasic
.
getFanGatewayId
(),
"日工作时间"
));
});
SocialContributionDto
dailyPowerdto
=
new
SocialContributionDto
();
dailyPowerdto
.
setTitle
(
String
.
format
(
"%.2f"
,
dailyPower
.
get
()));
dailyPowerdto
.
setUnit
(
"万kWh"
);
SocialContributionDto
monthlyPowerdto
=
new
SocialContributionDto
();
monthlyPowerdto
.
setTitle
(
String
.
format
(
"%.2f"
,
monthlyPower
.
get
()));
monthlyPowerdto
.
setUnit
(
"万kWh"
);
SocialContributionDto
annualPowerdto
=
new
SocialContributionDto
();
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
.
setUnit
(
"h"
);
socialContributionDtoList
.
add
(
dailyPowerdto
);
socialContributionDtoList
.
add
(
monthlyPowerdto
);
socialContributionDtoList
.
add
(
annualPowerdto
);
socialContributionDtoList
.
add
(
completionRatioDto
);
socialContributionDtoList
.
add
(
useHoursDto
);
socialContributionDtoPage
.
setRecords
(
socialContributionDtoList
);
socialContributionDtoPage
.
setTotal
(
100
);
socialContributionDtoPage
.
setCurrent
(
1
);
try
{
emqKeeper
.
getMqttClient
().
publish
(
"completionofpowerindicator_topic"
,
JSON
.
toJSON
(
socialContributionDtoPage
).
toString
().
getBytes
(
"UTF-8"
),
1
,
true
);
logger
.
info
(
"-----------------发送区域实时生产数据消息=================== 成功!"
+
JSON
.
toJSONString
(
socialContributionDtoPage
));
}
catch
(
Exception
exception
)
{
logger
.
error
(
"-----------------发送区域实时生产数据消息=================== 失败!"
);
}
}
public
List
<
TabDto
>
getTabsByStationBasicId
(
String
stationBasicId
)
{
StationBasic
stationBasic
=
stationBasicMapper
.
selectById
(
stationBasicId
);
List
<
TabDto
>
tabDtoList
=
new
ArrayList
<>();
...
...
@@ -378,8 +450,8 @@ public class MonitoringServiceImpl {
}
//获取装机容量
public
HashMap
<
String
,
String
>
getInstallCapityByAreaName
(
String
areaName
)
{
HashMap
<
String
,
String
>
hashMap
=
new
HashMap
<>();
public
HashMap
<
String
,
String
>
getInstallCapityByAreaName
(
String
areaName
)
{
HashMap
<
String
,
String
>
hashMap
=
new
HashMap
<>();
AtomicReference
<
Double
>
total
=
new
AtomicReference
<>(
0.0
);
List
<
StationBasic
>
stationBasicListAll
=
new
ArrayList
<>();
if
(!
ObjectUtils
.
isEmpty
(
areaName
))
{
...
...
@@ -399,13 +471,13 @@ public class MonitoringServiceImpl {
stationBasicListAll
.
forEach
(
stationBasic
->
{
total
.
updateAndGet
(
v
->
v
+
getStationCaPACITYL
(
stationBasic
.
getStationNumber
()));
});
hashMap
.
put
(
"title"
,
String
.
format
(
"%.2f"
,
total
.
get
()))
;
hashMap
.
put
(
"title"
,
String
.
format
(
"%.2f"
,
total
.
get
()))
;
return
hashMap
;
}
//获取有功功率
public
HashMap
<
String
,
String
>
getActivePowerByAreaName
(
String
areaName
)
{
HashMap
<
String
,
String
>
hashMap
=
new
HashMap
<>();
public
HashMap
<
String
,
String
>
getActivePowerByAreaName
(
String
areaName
)
{
HashMap
<
String
,
String
>
hashMap
=
new
HashMap
<>();
AtomicReference
<
Double
>
total
=
new
AtomicReference
<>(
0.0
);
List
<
StationBasic
>
stationBasicListAll
=
new
ArrayList
<>();
if
(!
ObjectUtils
.
isEmpty
(
areaName
))
{
...
...
@@ -425,14 +497,13 @@ public class MonitoringServiceImpl {
stationBasicListAll
.
forEach
(
stationBasic
->
{
total
.
updateAndGet
(
v
->
v
+
commonServiceImpl
.
getTotalByIndicatior
(
stationBasic
.
getFanGatewayId
(),
"有功功率"
));
});
hashMap
.
put
(
"title"
,
String
.
format
(
"%.2f"
,
total
.
get
()))
;
hashMap
.
put
(
"title"
,
String
.
format
(
"%.2f"
,
total
.
get
()))
;
return
hashMap
;
}
//获取社会贡献
/**
*
* @param areaName 片区名称
* @param stationId 场站id
* @return 社会贡献列表
...
...
@@ -463,21 +534,21 @@ public class MonitoringServiceImpl {
return
commonServiceImpl
.
getSocialContributionDtoList
(
total
.
get
());
}
public
HashMap
<
String
,
List
<
String
>>
getPowerGenerationTrends
(
String
areaName
)
{
List
<
StationBasic
>
stationBasicList
=
stationBasicMapper
.
selectList
(
new
QueryWrapper
<
StationBasic
>().
eq
(
"station_type"
,
"FDZ"
).
isNotNull
(
"fan_gateway_id"
));
public
HashMap
<
String
,
List
<
String
>>
getPowerGenerationTrends
(
String
areaName
)
{
List
<
StationBasic
>
stationBasicList
=
stationBasicMapper
.
selectList
(
new
QueryWrapper
<
StationBasic
>().
eq
(
"station_type"
,
"FDZ"
).
isNotNull
(
"fan_gateway_id"
));
//月发电量
AtomicReference
<
Double
>
monthlyPower
=
new
AtomicReference
<>(
0.0
);
stationBasicList
.
forEach
(
stationBasic
->
{
monthlyPower
.
updateAndGet
(
v
->
v
+
commonServiceImpl
.
getTotalByIndicatior
(
stationBasic
.
getFanGatewayId
(),
"月发电量"
));
});
HashMap
<
String
,
List
<
String
>>
hashMap
=
new
HashMap
<>();
HashMap
<
String
,
List
<
String
>>
hashMap
=
new
HashMap
<>();
List
<
String
>
xList
=
new
ArrayList
<>();
List
<
String
>
yList
=
new
ArrayList
<>();
for
(
int
i
=
1
;
i
<
13
;
i
++)
{
xList
.
add
(
i
+
"月"
);
if
(
i
==
new
Date
().
getMonth
())
{
yList
.
add
(
String
.
format
(
"%.2f"
,
monthlyPower
.
get
()));
}
else
{
for
(
int
i
=
1
;
i
<
13
;
i
++)
{
xList
.
add
(
i
+
"月"
);
if
(
i
==
new
Date
().
getMonth
())
{
yList
.
add
(
String
.
format
(
"%.2f"
,
monthlyPower
.
get
()));
}
else
{
yList
.
add
(
"0"
);
}
}
...
...
@@ -485,10 +556,11 @@ public class MonitoringServiceImpl {
hashMap
.
put
(
"seriesData"
,
yList
);
return
hashMap
;
}
public
Page
<
HashMap
<
String
,
String
>>
getDetailsOnPowergeneration
(
String
areaName
){
Page
<
HashMap
<
String
,
String
>>
hashMapPage
=
new
Page
<>(
1
,
99
);
List
<
HashMap
<
String
,
String
>>
hashMapList
=
new
ArrayList
<>();
List
<
StationBasic
>
stationBasicList
=
stationBasicMapper
.
selectList
(
new
QueryWrapper
<
StationBasic
>().
eq
(
"station_type"
,
"FDZ"
).
isNotNull
(
"fan_gateway_id"
));
public
Page
<
HashMap
<
String
,
String
>>
getDetailsOnPowergeneration
(
String
areaName
)
{
Page
<
HashMap
<
String
,
String
>>
hashMapPage
=
new
Page
<>(
1
,
99
);
List
<
HashMap
<
String
,
String
>>
hashMapList
=
new
ArrayList
<>();
List
<
StationBasic
>
stationBasicList
=
stationBasicMapper
.
selectList
(
new
QueryWrapper
<
StationBasic
>().
eq
(
"station_type"
,
"FDZ"
).
isNotNull
(
"fan_gateway_id"
));
//日发电量
AtomicReference
<
Double
>
dailyPower
=
new
AtomicReference
<>(
0.0
);
//月发电量
...
...
@@ -500,14 +572,14 @@ public class MonitoringServiceImpl {
monthlyPower
.
updateAndGet
(
v
->
v
+
commonServiceImpl
.
getTotalByIndicatior
(
stationBasic
.
getFanGatewayId
(),
"月发电量"
));
annualPower
.
updateAndGet
(
v
->
v
+
commonServiceImpl
.
getTotalByIndicatior
(
stationBasic
.
getFanGatewayId
(),
"年发电量"
));
});
HashMap
<
String
,
String
>
dayHashMap
=
new
HashMap
<>();
dayHashMap
.
put
(
"title"
,
String
.
format
(
"%.2f"
,
dailyPower
.
get
())+
"KWh"
);
HashMap
<
String
,
String
>
monthHashMap
=
new
HashMap
<>();
monthHashMap
.
put
(
"title"
,
String
.
format
(
"%.2f"
,
monthlyPower
.
get
())+
"KWh"
);
HashMap
<
String
,
String
>
annualHashMap
=
new
HashMap
<>();
annualHashMap
.
put
(
"title"
,
String
.
format
(
"%.2f"
,
annualPower
.
get
())+
"KWh"
);
HashMap
<
String
,
String
>
totalHashMap
=
new
HashMap
<>();
totalHashMap
.
put
(
"title"
,
String
.
format
(
"%.2f"
,
annualPower
.
get
())+
"KWh"
);
HashMap
<
String
,
String
>
dayHashMap
=
new
HashMap
<>();
dayHashMap
.
put
(
"title"
,
String
.
format
(
"%.2f"
,
dailyPower
.
get
())
+
"KWh"
);
HashMap
<
String
,
String
>
monthHashMap
=
new
HashMap
<>();
monthHashMap
.
put
(
"title"
,
String
.
format
(
"%.2f"
,
monthlyPower
.
get
())
+
"KWh"
);
HashMap
<
String
,
String
>
annualHashMap
=
new
HashMap
<>();
annualHashMap
.
put
(
"title"
,
String
.
format
(
"%.2f"
,
annualPower
.
get
())
+
"KWh"
);
HashMap
<
String
,
String
>
totalHashMap
=
new
HashMap
<>();
totalHashMap
.
put
(
"title"
,
String
.
format
(
"%.2f"
,
annualPower
.
get
())
+
"KWh"
);
hashMapList
.
add
(
dayHashMap
);
hashMapList
.
add
(
monthHashMap
);
hashMapList
.
add
(
annualHashMap
);
...
...
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