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
d283570a
Commit
d283570a
authored
Jul 06, 2023
by
caotao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
社会贡献使用消息发送
parent
06c8fd9d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
21 deletions
+61
-21
IndicatorsDto.java
...yeejoin/amos/boot/module/jxiop/biz/dto/IndicatorsDto.java
+8
-0
MonitoringServiceImpl.java
.../module/jxiop/biz/service/impl/MonitoringServiceImpl.java
+53
-21
No files found.
amos-boot-system-jxiop/amos-boot-module-jxiop-monitor-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/dto/IndicatorsDto.java
0 → 100644
View file @
d283570a
package
com
.
yeejoin
.
amos
.
boot
.
module
.
jxiop
.
biz
.
dto
;
import
lombok.Data
;
@Data
public
class
IndicatorsDto
{
}
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 @
d283570a
...
@@ -10,17 +10,25 @@ import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper;
...
@@ -10,17 +10,25 @@ 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.api.mapper.StationCoordinateMapper
;
import
com.yeejoin.amos.boot.module.jxiop.biz.dto.RegionNationWideDto
;
import
com.yeejoin.amos.boot.module.jxiop.biz.dto.RegionNationWideDto
;
import
com.yeejoin.amos.boot.module.jxiop.biz.dto.SocialContributionDto
;
import
com.yeejoin.amos.boot.module.jxiop.biz.dto.SocialContributionDto
;
import
com.yeejoin.amos.boot.module.jxiop.biz.utils.InfluxDButils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
import
org.typroject.tyboot.component.emq.EmqKeeper
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.concurrent.atomic.AtomicReference
;
import
java.util.concurrent.atomic.AtomicReference
;
@Async
@Service
@Service
public
class
MonitoringServiceImpl
{
public
class
MonitoringServiceImpl
{
Logger
logger
=
LoggerFactory
.
getLogger
(
MonitoringServiceImpl
.
class
);
/**
/**
* 区域mapper
* 区域mapper
*/
*/
...
@@ -50,8 +58,14 @@ public class MonitoringServiceImpl {
...
@@ -50,8 +58,14 @@ public class MonitoringServiceImpl {
@Autowired
@Autowired
MonitorFanIndicatorImpl
monitorFanIndicatorImpl
;
MonitorFanIndicatorImpl
monitorFanIndicatorImpl
;
@Autowired
EmqKeeper
emqKeeper
;
@Autowired
InfluxDButils
influxDButils
;
/**
/**
* 根据省份名称查询电站详情
* 根据省份名称查询电站详情
*
* @param provinceName
* @param provinceName
* @return
* @return
*/
*/
...
@@ -69,7 +83,7 @@ public class MonitoringServiceImpl {
...
@@ -69,7 +83,7 @@ public class MonitoringServiceImpl {
Region
region
=
regionList
.
get
(
i
);
Region
region
=
regionList
.
get
(
i
);
List
<
StationBasic
>
list
=
stationBasicMapper
.
selectList
(
new
QueryWrapper
<
StationBasic
>().
like
(
"belong_area"
,
region
.
getRegionCode
()));
List
<
StationBasic
>
list
=
stationBasicMapper
.
selectList
(
new
QueryWrapper
<
StationBasic
>().
like
(
"belong_area"
,
region
.
getRegionCode
()));
list
.
forEach
(
stationBasic
->
{
list
.
forEach
(
stationBasic
->
{
if
(!
ObjectUtils
.
isEmpty
(
stationBasic
.
getFanGatewayId
())&&!
ObjectUtils
.
isEmpty
(
stationBasic
.
getStationNumber
()))
{
if
(!
ObjectUtils
.
isEmpty
(
stationBasic
.
getGatewayId
())
&&
!
ObjectUtils
.
isEmpty
(
stationBasic
.
getStationNumber
()))
{
regionNationWideDto
.
setJsJoin
(
true
);
regionNationWideDto
.
setJsJoin
(
true
);
}
}
if
(
stationBasic
.
getStationType
().
equals
(
"FDZ"
)){
if
(
stationBasic
.
getStationType
().
equals
(
"FDZ"
)){
...
@@ -97,8 +111,8 @@ public class MonitoringServiceImpl {
...
@@ -97,8 +111,8 @@ public class MonitoringServiceImpl {
regionNationWideDto
.
setStaitionName
(
stationBasic
.
getStationName
());
regionNationWideDto
.
setStaitionName
(
stationBasic
.
getStationName
());
regionNationWideDto
.
setStaitionType
(
stationBasic
.
getStationType
());
regionNationWideDto
.
setStaitionType
(
stationBasic
.
getStationType
());
String
speendOrirradiate
=
""
;
String
speendOrirradiate
=
""
;
if
(
stationBasic
.
getStationType
().
equals
(
"FDZ"
))
{
if
(
stationBasic
.
getStationType
().
equals
(
"FDZ"
))
{
speendOrirradiate
=
String
.
valueOf
(
getIndicatoralueAvage
(
stationBasic
.
getFanGatewayId
(),
"30秒平均风速"
));
speendOrirradiate
=
String
.
valueOf
(
getIndicatoralueAvage
(
stationBasic
.
getGatewayId
(),
"30秒平均风速"
));
regionNationWideDto
.
setSpeendOrirradiate
(
speendOrirradiate
);
regionNationWideDto
.
setSpeendOrirradiate
(
speendOrirradiate
);
}
else
{
}
else
{
regionNationWideDto
.
setSpeendOrirradiate
(
String
.
valueOf
(
Math
.
random
()*
1000
));
regionNationWideDto
.
setSpeendOrirradiate
(
String
.
valueOf
(
Math
.
random
()*
1000
));
...
@@ -116,50 +130,58 @@ public class MonitoringServiceImpl {
...
@@ -116,50 +130,58 @@ public class MonitoringServiceImpl {
/**
/**
* 根据场站编号获取该场站的装机容量
* 根据场站编号获取该场站的装机容量
*
* @param werks
* @param werks
* @return
* @return
*/
*/
public
Double
getStationCaPACITYL
(
String
werks
){
public
Double
getStationCaPACITYL
(
String
werks
)
{
return
this
.
SjglZsjZsbtzServiceImpl
.
getStationCapactityByStationWerks
(
werks
);
return
this
.
SjglZsjZsbtzServiceImpl
.
getStationCapactityByStationWerks
(
werks
);
}
}
/**
/**
* 根据网关id以及指标值 获取同一网关下指标的平均值
* 根据网关id以及指标值 获取同一网关下指标的平均值
* @param gateway 网关id
*
* @param gateway 网关id
* @param indicatorcName 指标名称
* @param indicatorcName 指标名称
* @return 同一网关下指标的平均值
* @return 同一网关下指标的平均值
*/
*/
public
Object
getIndicatoralueAvage
(
String
gateway
,
String
indicatorcName
)
{
public
Object
getIndicatoralueAvage
(
String
gateway
,
String
indicatorcName
)
{
return
this
.
monitorFanIndicatorImpl
.
getIndicatoralueAvage
(
gateway
,
indicatorcName
);
return
this
.
monitorFanIndicatorImpl
.
getIndicatoralueAvage
(
gateway
,
indicatorcName
);
}
}
/**
/**
* 根据网关id以及指标值 同一网关下指标的值总和
* 根据网关id以及指标值 同一网关下指标的值总和
* @param gateway 网关id
*
* @param gateway 网关id
* @param indicatorcName 指标名称
* @param indicatorcName 指标名称
* @return 同一网关下指标的值总和
* @return 同一网关下指标的值总和
*/
*/
public
Object
getIndicatoralueTotal
(
String
gateway
,
String
indicatorcName
)
{
public
Object
getIndicatoralueTotal
(
String
gateway
,
String
indicatorcName
)
{
return
this
.
monitorFanIndicatorImpl
.
getIndicatoralueTotal
(
gateway
,
indicatorcName
);
return
this
.
monitorFanIndicatorImpl
.
getIndicatoralueTotal
(
gateway
,
indicatorcName
);
}
}
public
List
<
SocialContributionDto
>
getTotalSocialContribution
(){
@Scheduled
(
cron
=
"*/10 * * * * *"
)
List
<
SocialContributionDto
>
socialContributionDtoList
=
new
ArrayList
<>();
public
void
getTotalSocialContribution
()
{
Page
<
SocialContributionDto
>
socialContributionDtoPage
=
new
Page
<
SocialContributionDto
>();
logger
.
error
(
"--------------------------社会贡献定时执行----------------------------------------------"
);
List
<
SocialContributionDto
>
socialContributionDtoList
=
new
ArrayList
<>();
//定义社会贡献列表
AtomicReference
<
Double
>
totalSocialContribution
=
new
AtomicReference
<>(
0.0
);
AtomicReference
<
Double
>
totalSocialContribution
=
new
AtomicReference
<>(
0.0
);
//获取所有网关id不为空的数据
//获取所有网关id不为空的数据
List
<
StationBasic
>
stationBasicList
=
stationBasicMapper
.
selectList
(
new
QueryWrapper
<
StationBasic
>().
isNotNull
(
"gateway_id"
));
List
<
StationBasic
>
stationBasicList
=
stationBasicMapper
.
selectList
(
new
QueryWrapper
<
StationBasic
>().
isNotNull
(
"gateway_id"
));
stationBasicList
.
forEach
(
stationBasic
->
{
stationBasicList
.
forEach
(
stationBasic
->
{
totalSocialContribution
.
updateAndGet
(
v
->
v
+
(
Double
)
monitorFanIndicatorImpl
.
getIndicatoralueTotal
(
stationBasic
.
get
Fan
GatewayId
(),
"年发电量"
));
totalSocialContribution
.
updateAndGet
(
v
->
v
+
(
Double
)
monitorFanIndicatorImpl
.
getIndicatoralueTotal
(
stationBasic
.
getGatewayId
(),
"年发电量"
));
});
});
SocialContributionDto
co2
=
new
SocialContributionDto
();
SocialContributionDto
co2
=
new
SocialContributionDto
();
SocialContributionDto
coal
=
new
SocialContributionDto
();
SocialContributionDto
coal
=
new
SocialContributionDto
();
SocialContributionDto
toner
=
new
SocialContributionDto
();
SocialContributionDto
toner
=
new
SocialContributionDto
();
SocialContributionDto
so2
=
new
SocialContributionDto
();
SocialContributionDto
so2
=
new
SocialContributionDto
();
/** 社会贡献原始计算公式,后边的数据已经经过处理
/** 社会贡献原始计算公式,后边的数据已经经过处理
//二氧化碳计算公式 *10000*832/10000/1000/1000
//二氧化碳计算公式 *10000*832/10000/1000/1000
//标准煤计算公式 *10000*304.9/10000/1000/1000
//标准煤计算公式 *10000*304.9/10000/1000/1000
//碳粉尘计算公式 *10000*0.032/1000/1000
//碳粉尘计算公式 *10000*0.032/1000/1000
//二氧化硫计算公式 =A2*10000*0.16/1000/1000
//二氧化硫计算公式 =A2*10000*0.16/1000/1000
*/
*/
co2
.
setUnit
(
"二氧化碳减排量(万t)"
);
co2
.
setUnit
(
"二氧化碳减排量(万t)"
);
co2
.
setTitle
(
totalSocialContribution
.
get
()
*
0.000832
);
co2
.
setTitle
(
totalSocialContribution
.
get
()
*
0.000832
);
socialContributionDtoList
.
add
(
co2
);
socialContributionDtoList
.
add
(
co2
);
...
@@ -172,6 +194,16 @@ public class MonitoringServiceImpl {
...
@@ -172,6 +194,16 @@ public class MonitoringServiceImpl {
so2
.
setUnit
(
"二氧化硫减排量(万t)"
);
so2
.
setUnit
(
"二氧化硫减排量(万t)"
);
so2
.
setTitle
(
totalSocialContribution
.
get
()
*
0.0016
);
so2
.
setTitle
(
totalSocialContribution
.
get
()
*
0.0016
);
socialContributionDtoList
.
add
(
so2
);
socialContributionDtoList
.
add
(
so2
);
return
socialContributionDtoList
;
socialContributionDtoPage
.
setRecords
(
socialContributionDtoList
);
socialContributionDtoPage
.
setTotal
(
100
);
socialContributionDtoPage
.
setCurrent
(
1
);
try
{
emqKeeper
.
getMqttClient
().
publish
(
"SocialContribution"
,
JSON
.
toJSON
(
socialContributionDtoPage
).
toString
().
getBytes
(
"UTF-8"
),
1
,
true
);
logger
.
info
(
"-----------------发送社会贡献消息=================== 失败!"
+
JSON
.
toJSONString
(
socialContributionDtoPage
));
}
catch
(
Exception
exception
)
{
logger
.
error
(
"-----------------发送社会贡献消息=================== 失败!"
);
}
}
}
}
}
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