Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-zx-biz
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
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
Jobs
Commits
Open sidebar
项目统一框架
一体化_户用光伏项目代码
amos-boot-zx-biz
Commits
323ff25b
Commit
323ff25b
authored
Jul 01, 2024
by
朱晨阳
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/developer' into developer
parents
9f5b7577
a9691c08
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
1400 additions
and
1020 deletions
+1400
-1020
application-kingbase8.properties
...f-biz/src/main/resources/application-kingbase8.properties
+243
-0
logback-kingbase8.xml
...-module-hygf-biz/src/main/resources/logback-kingbase8.xml
+45
-0
Constants.java
...om/yeejoin/amos/boot/module/jxiop/api/util/Constants.java
+3
-0
HttpRequestUtil.java
...join/amos/boot/module/jxiop/api/util/HttpRequestUtil.java
+14
-0
LargeScreenImpl.java
...s/boot/module/jxiop/biz/service/impl/LargeScreenImpl.java
+1068
-1011
MonitoringServiceImpl.java
.../module/jxiop/biz/service/impl/MonitoringServiceImpl.java
+27
-9
No files found.
amos-boot-system-jxiop/amos-boot-module-hygf-biz/src/main/resources/application-kingbase8.properties
0 → 100644
View file @
323ff25b
## DB properties:
spring.datasource.dynamic.primary
=
mysql-service
spring.datasource.mysql-service.driver-class-name
=
com.kingbase8.Driver
spring.datasource.mysql-service.jdbc-url
=
jdbc:kingbase8://10.20.1.176:54321/amos_project?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8¤tSchema=root
spring.datasource.mysql-service.username
=
root
spring.datasource.mysql-service.password
=
Yeejoin@2020
spring.datasource.mysql-service.type
=
com.zaxxer.hikari.HikariDataSource
#最小连接
spring.datasource.mysql-service.minimum-idle
:
5
#最大连接
spring.datasource.mysql-service.maximum-pool-size
:
15
#自动提交
spring.datasource.mysql-service.auto-commit
:
true
#最大空闲时常
spring.datasource.mysql-service.idle-timeout
:
30000
#连接池名
spring.datasource.mysql-service.pool-name
:
MysqlDruidCP
#最大生命周期
spring.datasource.mysql-service.max-lifetime
:
1800000
#连接超时时间
spring.datasource.mysql-service.connection-timeout
:
30000
spring.datasource.tdengine-service.driver-class-name
=
com.taosdata.jdbc.rs.RestfulDriver
spring.datasource.tdengine-service.jdbc-url
=
jdbc:TAOS-RS://47.92.234.253:6041/house_pv_data?user=root&password=taosdata&timezone=GMT+8
spring.datasource.tdengine-service.username
=
root
spring.datasource.tdengine-service.password
=
taosdata
spring.datasource.tdengine-service.type
=
com.zaxxer.hikari.HikariDataSource
#最小连接
spring.datasource.tdengine-service.minimum-idle
:
5
#最大连接
spring.datasource.tdengine-service.maximum-pool-size
:
15
#自动提交
spring.datasource.tdengine-service.auto-commit
:
true
#最大空闲时常
spring.datasource.tdengine-service.idle-timeout
:
30000
#连接池名
spring.datasource.tdengine-service.pool-name
:
Data_trans_HikariCP
#最大生命周期
spring.datasource.tdengine-service.max-lifetime
:
1800000
#连接超时时间
spring.datasource.tdengine-service.connection-timeout
:
30000
spring.datasource.tdengine-service.connection-test-query
:
SELECT 1
## eureka properties:
eureka.instance.hostname
=
10.20.1.160
eureka.client.serviceUrl.defaultZone
=
http://admin:a1234560@${eureka.instance.hostname}:10001/eureka/
## redis properties:
spring.redis.database
=
1
spring.redis.host
=
10.20.1.210
spring.redis.port
=
6379
spring.redis.password
=
yeejoin@2020
spring.cache.type
=
GENERIC
j2cache.open-spring-cache
=
true
j2cache.cache-clean-mode
=
passive
j2cache.allow-null-values
=
true
j2cache.redis-client
=
lettuce
j2cache.l2-cache-open
=
true
j2cache.broadcast
=
net.oschina.j2cache.cache.support.redis.SpringRedisPubSubPolicy
j2cache.L1.provider_class
=
caffeine
j2cache.L2.provider_class
=
net.oschina.j2cache.cache.support.redis.SpringRedisProvider
j2cache.L2.config_section
=
lettuce
j2cache.sync_ttl_to_redis
=
true
j2cache.default_cache_null_object
=
false
j2cache.serialization
=
fst
caffeine.properties
=
/caffeine.properties
lettuce.mode
=
single
lettuce.namespace
=
lettuce.storage
=
generic
lettuce.channel
=
j2cache
lettuce.scheme
=
redis
lettuce.hosts
=
${spring.redis.host}:${spring.redis.port}
lettuce.password
=
${spring.redis.password}
lettuce.database
=
${spring.redis.database}
lettuce.sentinelMasterId
=
lettuce.maxTotal
=
100
lettuce.maxIdle
=
10
lettuce.minIdle
=
10
lettuce.timeout
=
10000
emqx.clean-session
=
true
emqx.client-id
=
${spring.application.name}-${random.int[1024,65536]}
emqx.broker
=
tcp://10.20.1.210:2883
emqx.user-name
=
admin
emqx.password
=
public
emqx.max-inflight
=
1000
spring.influx.url
=
http://47.92.234.253:8086
spring.influx.password
=
Yeejoin@2020
spring.influx.user
=
root
spring.influx.database
=
iot_platform
spring.influx.retention_policy
=
default
spring.influx.retention_policy_time
=
30d
spring.influx.actions
=
10000
spring.influx.bufferLimit
=
20000
knife4j.production
=
false
knife4j.enable
=
true
knife4j.basic.enable
=
true
knife4j.basic.username
=
admin
knife4j.basic.password
=
a1234560
management.security.enabled
=
true
spring.security.user.name
=
admin
spring.security.user.password
=
a1234560
fire-rescue
=
123
mybatis-plus.global-config.db-config.update-strategy
=
ignored
# user-amos setting : This value is the secretkey for person manage moudle accout password encryption.please don't change it!!!
amos.secret.key
=
qaz
# if your service can't be access ,you can use this setting , you need change ip as your.
#eureka.instance.prefer-ip-address=true
#eureka.instance.ip-address=172.16.3.122
spring.activemq.broker-url
=
tcp://10.20.1.210:61616
spring.activemq.user
=
admin
spring.activemq.password
=
admin
spring.jms.pub-sub-domain
=
false
myqueue
=
amos.privilege.v1.JXIOP.AQSC_FDGL.userBusiness
regulator.unit.code
=
86*258
# ������Ӧ��code
dealer.appcode
=
studio_normalapp_5133538
hygf.sms.tempCode
=
SMS_HYGF_0001
# �������������
sms.huawei.url
=
https://smsapi.cn-north-4.myhuaweicloud.com:443/sms/batchSendSms/v1
sms.huawei.appKey
=
n3FYPWO7Heo1ze212QRBvF4VA2E2
sms.huawei.appSecret
=
IFhiMpWROi7w4Ei21ZbfIjKyt97b
# �id
sms.huawei.templateId
=
67931857f6f74e119fadc429bc25a531
# ǩ��ͨ����
sms.huawei.sender
=
1069368924410006092
# 签名名称
sms.huawei.signature
=
江西电建
# 锟斤拷站锟斤拷锟絧ageId
power.station.examine.pageId
=
1680853427061551106
# 锟斤拷站锟斤拷思苹锟絠d
power.station.examine.planId
=
c4ed1873-0dc6-4518-a7a9-dbc588ef35e5
unitInfo.station.examine.planId
=
51776087-a9cf-4a87-9a03-24fd24a8cf45
hygf.sms.tempCodeJXS
=
SMS_HYGF_0002
#工程角色id
hygf.role.gc.roleSeq
=
1702550832882413570
# 锟矫伙拷锟斤拷userGroupId
hygf.user.group.id
=
1702512164058718210
#锟斤拷锟斤拷司
regionalCompanies.company.seq
=
1701778292098498561
hygf.user.group.empty
=
1775056568031645697
#qiyuesuo.serverUrl = https://openapi.qiyuesuo.cn
#qiyuesuo.accessKey = a1lcd3WRRV
#qiyuesuo.accessSecret = haqYIOxTP20ZYiDNEN92GVBa6aoJLu
#qiyuesuo.secretKey=Fp2LQAqK5gc68hi5
qiyuesuo.serverUrl
=
https://openapi.qiyuesuo.com
qiyuesuo.accessKey
=
QcmHQu55pl
qiyuesuo.accessSecret
=
em0zvOMRNCAXoD1ePNTL7hGR5KpKUs
qiyuesuo.secretKey
=
B6OYbHyfXikAghB2
# ============================================= v20230821 add properties =============================================
security.productWeb
=
AMOS_STUDIO_WEB
security.appKey
=
AMOS_STUDIO
login.environment
=
dev
# 锟斤拷锟脚╋拷锟轿拷锟叫★拷锟斤拷锟斤拷锟斤拷?
hygfProgram.appid
=
wx0a2b054a237a3b34
hygfProgram.secret
=
5fc6af660920f6211b1b69bc9c451b09
# 默锟斤拷微锟斤拷小锟斤拷锟斤拷农锟斤拷锟斤拷锟斤拷锟斤拷
farmer.orgCode
=
86
#农锟斤拷锟斤拷锟斤拷锟斤拷位
farmer.sequenceNbr
=
1703583838279593985
farmer.orgNamesWithoutRole
=
#农锟斤拷锟斤拷色
farmer.roleId
=
1702551322030534658
# 锟斤拷锟矫接匡拷锟斤拷权锟矫伙拷
platform.access.loginId
=
hygf_platform
platform.access.password
=
AC286A35E74D2DD281EB979789DECF3A
# 锟斤拷锟斤拷锟矫的撅拷锟斤拷锟斤拷userid
dealer.userId
=
# 锟斤拷锟皆碉拷时锟斤拷默锟斤拷锟斤拷锟斤拷
farmer.registerPassword
=
a123456
#锟斤拷锟斤拷锟教碉拷位锟斤拷锟节碉拷id
dealer.managementUnitId
=
1702211822385393665
#锟斤拷锟斤拷锟教癸拷锟斤拷员锟斤拷色
dealer.roleId
=
1702512164058718210
#锟斤拷询锟斤拷锟斤拷锟斤拷锟矫伙拷锟斤拷
dealer.group
=
1702511386875158529
#锟斤拷锟矫癸拷锟斤拷锟斤拷探锟斤拷?
dealer.engineering
=
1702512052154687489
#锟斤拷时锟斤拷锟斤拷锟饺★拷锟斤拷锟斤拷锟较?
cheduled.crons
=
0 10 0 * * ?
dealer.appcode.manage
=
studio_normalapp_5155413,studio_normalapp_5133538
dealer.appcode.role
=
1767363928842571777
dealer.amosDealerId
=
1767820997374775298
#Seata Config
seata.tx-service-group
=
hygf-seata
seata.service.grouplist.hygf-seata
=
47.92.234.253:8091
# Seata 配置
seata.enabled
=
true
seata.enable-auto-data-source-proxy
=
false
#seata.client.undo.log-serialization=kryo
seata.datasource.autoproxy.datasource-proxy-mode
=
original
seata.datasource.autoproxy.enabled
=
true
seata.datasource.autoproxy.data-source-names
=
postgresql
\ No newline at end of file
amos-boot-system-jxiop/amos-boot-module-hygf-biz/src/main/resources/logback-kingbase8.xml
0 → 100644
View file @
323ff25b
<?xml version="1.0" encoding="UTF-8"?>
<configuration
debug=
"false"
>
<!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径-->
<property
name=
"LOG_HOME"
value=
"log"
/>
<property
name=
"LOG_PATTERN"
value=
"%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %-50.50logger{50} - %msg [%file:%line] %n"
/>
<!-- 按照每天生成日志文件 -->
<appender
name=
"FILE"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.TimeBasedRollingPolicy"
>
<!--日志文件输出的文件名-->
<FileNamePattern>
${LOG_HOME}/ccs.log.%d{yyyy-MM-dd}.log
</FileNamePattern>
<!--日志文件保留天数-->
<MaxHistory>
7
</MaxHistory>
</rollingPolicy>
<encoder
class=
"ch.qos.logback.classic.encoder.PatternLayoutEncoder"
>
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
<pattern>
${LOG_PATTERN}
</pattern>
</encoder>
<!--日志文件最大的大小-->
<triggeringPolicy
class=
"ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"
>
<MaxFileSize>
30mb
</MaxFileSize>
</triggeringPolicy>
</appender>
<!-- 控制台输出 -->
<appender
name=
"STDOUT"
class=
"ch.qos.logback.core.ConsoleAppender"
>
<encoder
class=
"ch.qos.logback.classic.encoder.PatternLayoutEncoder"
>
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
<pattern>
${LOG_PATTERN}
</pattern>
</encoder>
</appender>
<!--myibatis log configure-->
<logger
name=
"com.apache.ibatis"
level=
"DEBUG"
/>
<logger
name=
"java.sql.Connection"
level=
"DEBUG"
/>
<logger
name=
"java.sql.Statement"
level=
"DEBUG"
/>
<logger
name=
"java.sql.PreparedStatement"
level=
"DEBUG"
/>
<logger
name=
"com.baomidou.mybatisplus"
level=
"DEBUG"
/>
<logger
name=
"org.springframework"
level=
"DEBUG"
/>
<logger
name=
"org.typroject"
level=
"DEBUG"
/>
<logger
name=
"com.yeejoin"
level=
"DEBUG"
/>
<!-- 日志输出级别 -->
<root
level=
"INFO"
>
<appender-ref
ref=
"FILE"
/>
<appender-ref
ref=
"STDOUT"
/>
</root>
</configuration>
amos-boot-system-jxiop/amos-boot-module-jxiop-api/src/main/java/com/yeejoin/amos/boot/module/jxiop/api/util/Constants.java
View file @
323ff25b
...
...
@@ -81,6 +81,9 @@ public class Constants {
public
static
final
String
get_generated_quota_trend
=
"method=scene_screen.data_interface.get_generated_quota_trend"
;
public
static
final
String
get_province_station_item
=
"method=scene_screen.data_interface.get_province_station_item"
;
public
static
final
String
get_day_generation_trend
=
"method=scene_screen.data_interface.get_day_generation_trend"
;
public
static
final
String
get_quota_info
=
"method=scene_screen.large_screen.get_quota_info"
;
public
static
final
String
get_station_actual_installed_capacity
=
"method=scene_screen.large_screen.get_station_actual_installed_capacity"
;
public
static
final
String
get_quota_complate_info
=
"method=scene_screen.large_screen.get_quota_complate_info"
;
public
static
final
String
resovleRule_data
=
"data"
;
public
static
final
String
areaChinese
=
"区域"
;
}
...
...
amos-boot-system-jxiop/amos-boot-module-jxiop-api/src/main/java/com/yeejoin/amos/boot/module/jxiop/api/util/HttpRequestUtil.java
View file @
323ff25b
...
...
@@ -66,4 +66,18 @@ public class HttpRequestUtil {
}
return
result
;
}
public
JSONObject
getResPonse
(
String
apiurl
,
String
requestMethod
,
String
requestParmInfo
,
String
ResultResolveRule
)
{
String
response
=
""
;
String
params
=
""
;
JSONObject
jsonObject
=
null
;
try
{
response
=
sendRequest
(
requestMethod
,
apiurl
,
requestParmInfo
,
null
);
jsonObject
=
JSONObject
.
parseObject
(
response
);
jsonObject
=
jsonObject
.
getJSONObject
(
ResultResolveRule
);
}
catch
(
Exception
exception
)
{
return
jsonObject
;
}
return
jsonObject
;
}
}
amos-boot-system-jxiop/amos-boot-module-jxiop-bigscreen-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/service/impl/LargeScreenImpl.java
View file @
323ff25b
package
com
.
yeejoin
.
amos
.
boot
.
module
.
jxiop
.
biz
.
service
.
impl
;
import
java.math.BigDecimal
;
import
java.text.DecimalFormat
;
import
java.text.SimpleDateFormat
;
import
java.time.LocalDate
;
import
java.time.format.DateTimeFormatter
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.TimeZone
;
import
java.util.concurrent.atomic.AtomicReference
;
import
java.util.stream.Collectors
;
import
javax.annotation.PostConstruct
;
import
org.eclipse.paho.client.mqttv3.MqttException
;
import
org.elasticsearch.search.aggregations.Aggregation
;
import
org.elasticsearch.search.aggregations.Aggregations
;
import
org.elasticsearch.search.aggregations.bucket.terms.Terms
;
import
org.elasticsearch.search.aggregations.metrics.ParsedAvg
;
import
org.elasticsearch.search.aggregations.metrics.ParsedSum
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
org.typroject.tyboot.component.emq.EmqKeeper
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.yeejoin.amos.boot.biz.common.utils.DateUtils
;
import
com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic
;
import
com.yeejoin.amos.boot.module.jxiop.api.entity.StationPlan
;
import
com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper
;
import
com.yeejoin.amos.boot.module.jxiop.api.mapper.StationPlanMapper
;
import
com.yeejoin.amos.boot.module.jxiop.api.util.Constants
;
import
com.yeejoin.amos.boot.module.jxiop.api.util.HttpRequestUtil
;
import
com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESDailyPowerGeneration
;
import
com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESEquipments
;
import
com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESMoonPowerGeneration
;
...
...
@@ -18,27 +50,6 @@ import com.yeejoin.amos.boot.module.jxiop.biz.dto.StationCacheInfoDto;
import
com.yeejoin.amos.boot.module.jxiop.biz.entity.IndicatorData
;
import
com.yeejoin.amos.boot.module.jxiop.biz.tdmapper.IndicatorDataMapper
;
import
com.yeejoin.amos.boot.module.jxiop.biz.utils.DateUtil
;
import
org.eclipse.paho.client.mqttv3.MqttException
;
import
org.elasticsearch.search.aggregations.Aggregation
;
import
org.elasticsearch.search.aggregations.Aggregations
;
import
org.elasticsearch.search.aggregations.bucket.terms.Terms
;
import
org.elasticsearch.search.aggregations.metrics.ParsedAvg
;
import
org.elasticsearch.search.aggregations.metrics.ParsedSum
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
org.typroject.tyboot.component.emq.EmqKeeper
;
import
java.math.BigDecimal
;
import
java.text.DecimalFormat
;
import
java.text.SimpleDateFormat
;
import
java.time.LocalDate
;
import
java.util.*
;
import
java.util.concurrent.atomic.AtomicReference
;
import
java.util.stream.Collectors
;
import
javax.annotation.PostConstruct
;
/**
* @description:
...
...
@@ -46,76 +57,100 @@ import javax.annotation.PostConstruct;
* @createDate: 2023/8/10
*/
@Service
//@RequiredArgsConstructor
public
class
LargeScreenImpl
{
@Autowired
CommonServiceImpl
commonServiceImpl
;
@Autowired
StationPlanMapper
StationPlanMapper
;
@Autowired
MonitoringServiceImpl
monitoringServiceImpl
;
@Autowired
StationBasicMapper
stationBasicMapper
;
@Autowired
EmqKeeper
emqKeeper
;
@Autowired
IndicatorDataMapper
indicatorDataMapper
;
@Autowired
SjglZsjZsbtzServiceImpl
SjglZsjZsbtzServiceImpl
;
private
final
String
SS
=
"瞬时风速"
;
private
final
String
ZFS
=
"WTX-801_25_WTX-801_总辐射"
;
private
final
String
ZFSLJ
=
"WTX-801_25_WTX-801_总辐射累计"
;
private
final
String
RSD
=
"日发电量"
;
private
final
String
YFD
=
"月发电量"
;
private
final
String
NFD
=
"年发电量"
;
/**
* 全国
*/
@Scheduled
(
cron
=
"0/10 * * * * ?"
)
@PostConstruct
public
Map
<
String
,
Double
>
getqg
()
{
Map
<
String
,
Double
>
mapdta
=
new
HashMap
<>();
mapdta
.
put
(
"SS"
,
0
d
);
mapdta
.
put
(
"ZFS"
,
0
d
);
mapdta
.
put
(
"ZFSLJ"
,
0
d
);
@Autowired
CommonServiceImpl
commonServiceImpl
;
@Autowired
StationPlanMapper
StationPlanMapper
;
@Autowired
MonitoringServiceImpl
monitoringServiceImpl
;
@Autowired
StationBasicMapper
stationBasicMapper
;
@Autowired
EmqKeeper
emqKeeper
;
@Autowired
IndicatorDataMapper
indicatorDataMapper
;
@Autowired
SjglZsjZsbtzServiceImpl
SjglZsjZsbtzServiceImpl
;
@Autowired
private
HttpRequestUtil
httpRequestUtil
;
private
final
String
SS
=
"瞬时风速"
;
private
final
String
ZFS
=
"WTX-801_25_WTX-801_总辐射"
;
private
final
String
ZFSLJ
=
"WTX-801_25_WTX-801_总辐射累计"
;
private
final
String
RSD
=
"日发电量"
;
private
final
String
YFD
=
"月发电量"
;
private
final
String
NFD
=
"年发电量"
;
/**
* 全国
*/
@Scheduled
(
cron
=
"0/10 * * * * ?"
)
@PostConstruct
public
Map
<
String
,
Double
>
getqg
()
{
Map
<
String
,
Double
>
mapdta
=
new
HashMap
<>();
mapdta
.
put
(
"SS"
,
0
d
);
mapdta
.
put
(
"ZFS"
,
0
d
);
mapdta
.
put
(
"ZFSLJ"
,
0
d
);
// mapdta.put("RSD", 0d);
// mapdta.put("YFD", 0d);
// mapdta.put("NFD", 0d);
// mapdta.put("YJHWC", 0d);
// mapdta.put("NJHWC", 0d);
//平均数
List
<
String
>
value
=
new
ArrayList
<>();
value
.
add
(
SS
);
value
.
add
(
ZFS
);
value
.
add
(
ZFSLJ
);
Map
<
String
,
List
<
String
>>
map
=
new
HashMap
<>();
map
.
put
(
"equipmentIndexName.keyword"
,
value
);
List
<
StationCacheInfoDto
>
stationCacheInfoDtos
=
commonServiceImpl
.
getListStationCacheInfoDto
();
List
<?
extends
Terms
.
Bucket
>
lidate
=
commonServiceImpl
.
getgroupavg
(
map
,
"valueF"
,
"equipmentIndexName.keyword"
,
ESEquipments
.
class
);
DecimalFormat
format2
=
new
DecimalFormat
(
"#.00"
);
for
(
Terms
.
Bucket
bucket
:
lidate
)
{
Aggregations
aggregation
=
bucket
.
getAggregations
();
List
<
Aggregation
>
listdata
=
Objects
.
nonNull
(
aggregation
)
?
aggregation
.
asList
()
:
null
;
for
(
Aggregation
agg
:
listdata
)
{
ParsedAvg
parsedAvg
=
(
ParsedAvg
)
agg
;
switch
(
bucket
.
getKeyAsString
())
{
case
SS:
mapdta
.
put
(
"SS"
,
Double
.
valueOf
(
format2
.
format
(
parsedAvg
.
getValue
())));
break
;
case
ZFS:
mapdta
.
put
(
"ZFS"
,
Double
.
valueOf
(
format2
.
format
(
parsedAvg
.
getValue
())));
break
;
case
ZFSLJ:
mapdta
.
put
(
"ZFSLJ"
,
Double
.
valueOf
(
format2
.
format
(
parsedAvg
.
getValue
())));
break
;
default
:
break
;
}
}
}
// 平均数
// List<String> value = new ArrayList<>();
// value.add(SS);
// value.add(ZFS);
// value.add(ZFSLJ);
// Map<String, List<String>> map = new HashMap<>();
// map.put("equipmentIndexName.keyword", value);
// List<StationCacheInfoDto> stationCacheInfoDtos = commonServiceImpl.getListStationCacheInfoDto();
// List<? extends Terms.Bucket> lidate = commonServiceImpl.getgroupavg(map, "valueF", "equipmentIndexName.keyword",
// ESEquipments.class);
// DecimalFormat format2 = new DecimalFormat("#.00");
// for (Terms.Bucket bucket : lidate) {
// Aggregations aggregation = bucket.getAggregations();
// List<Aggregation> listdata = Objects.nonNull(aggregation) ? aggregation.asList() : null;
// for (Aggregation agg : listdata) {
// ParsedAvg parsedAvg = (ParsedAvg) agg;
//
// switch (bucket.getKeyAsString()) {
// case SS:
// mapdta.put("SS", Double.valueOf(format2.format(parsedAvg.getValue())));
// break;
// case ZFS:
// mapdta.put("ZFS", Double.valueOf(format2.format(parsedAvg.getValue())));
// break;
// case ZFSLJ:
// mapdta.put("ZFSLJ", Double.valueOf(format2.format(parsedAvg.getValue())));
// break;
// default:
// break;
// }
// }
// }
//改为部盾接口
String
requestUrl
=
Constants
.
BASE_URL
+
"?"
+
Constants
.
get_quota_info
;
LocalDate
currentDate
=
LocalDate
.
now
();
DateTimeFormatter
formatter
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd"
);
String
formattedDate
=
currentDate
.
format
(
formatter
);
JSONObject
data
=
httpRequestUtil
.
getResPonse
(
requestUrl
+
"&reporting_data="
+
formattedDate
,
Constants
.
REQUEST_GET
,
""
,
Constants
.
resovleRule_data
);
//部盾每天十二点才填报,如果十二点前没有数据则获取前一天的数据
if
(
data
.
getDouble
(
"sum_irradiance"
)==
0
)
{
// 计算昨天日期
LocalDate
yesterday
=
currentDate
.
minusDays
(
1
);
formattedDate
=
yesterday
.
format
(
formatter
);
data
=
httpRequestUtil
.
getResPonse
(
requestUrl
+
"&reporting_data="
+
formattedDate
,
Constants
.
REQUEST_GET
,
""
,
Constants
.
resovleRule_data
);
}
mapdta
.
put
(
"SS"
,
data
.
getDouble
(
"average_wind_speed"
));
mapdta
.
put
(
"ZFS"
,
data
.
getDouble
(
"avg_irradiance"
));
mapdta
.
put
(
"ZFSLJ"
,
data
.
getDouble
(
"sum_irradiance"
));
// //日发电量
// AtomicReference<Double> dailyPower = new AtomicReference<>(0.0);
// //月发电量
...
...
@@ -148,7 +183,7 @@ public class LargeScreenImpl {
// mapdta.put("YFD", keepFourdecimalPlaces(monthlyPower.get()));
// mapdta.put("NFD", keepFourdecimalPlaces(annualPower.get()));
//
总和
//
总和
// value.clear();
// value.add(RSD);
// value.add(YFD);
...
...
@@ -197,699 +232,715 @@ public class LargeScreenImpl {
// Double ybfbn = sumValuen > 0 ? mapdta.get("NFD") / sumValue * 100 : 0;
// ybfbn = new BigDecimal(ybfbn).setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue();
// mapdta.put("NJHWC", ybfbn);
try
{
emqKeeper
.
getMqttClient
().
publish
(
"qg/yxzb"
,
JSON
.
toJSONString
(
mapdta
).
getBytes
(),
0
,
true
);
}
catch
(
MqttException
e
)
{
e
.
printStackTrace
();
}
return
mapdta
;
}
@Scheduled
(
cron
=
"0/10 * * * * ?"
)
private
void
sendQYYXZBMqtt
(){
List
<
StationCacheInfoDto
>
listStationCacheInfoDto
=
commonServiceImpl
.
getListStationCacheInfoDto
();
Map
<
String
,
List
<
StationCacheInfoDto
>>
belongAreaList
=
listStationCacheInfoDto
.
stream
().
collect
(
Collectors
.
groupingBy
(
StationCacheInfoDto:
:
getAreaCode
));
for
(
String
s
:
belongAreaList
.
keySet
())
{
//List<String> ids = belongAreaList.get(s).stream().map(StationCacheInfoDto::getFanGatewayId).collect(Collectors.toList());
getqy
(
belongAreaList
.
get
(
s
),
s
);
}
}
/**
* 区域
**/
public
Map
<
String
,
Double
>
getqy
(
List
<
StationCacheInfoDto
>
gatewayId
,
String
s
)
{
Map
<
String
,
Double
>
mapdta
=
new
HashMap
<>();
mapdta
.
put
(
"SS"
,
0
d
);
mapdta
.
put
(
"ZFS"
,
0
d
);
mapdta
.
put
(
"ZFSLJ"
,
0
d
);
mapdta
.
put
(
"RSD"
,
0
d
);
mapdta
.
put
(
"YFD"
,
0
d
);
mapdta
.
put
(
"NFD"
,
0
d
);
mapdta
.
put
(
"YJHWC"
,
0
d
);
mapdta
.
put
(
"NJHWC"
,
0
d
);
//平均数
List
<
String
>
value
=
new
ArrayList
<>();
List
<
String
>
ids
=
new
ArrayList
<>();
for
(
StationCacheInfoDto
stationCacheInfoDto
:
gatewayId
)
{
ids
.
add
(
stationCacheInfoDto
.
getFanGatewayId
());
ids
.
add
(
stationCacheInfoDto
.
getBoosterGatewayId
());
}
// List<String> ids = gatewayId.stream().map(StationCacheInfoDto::getFanGatewayId).collect(Collectors.toList());
value
.
add
(
SS
);
value
.
add
(
ZFS
);
value
.
add
(
ZFSLJ
);
Map
<
String
,
List
<
String
>>
map
=
new
HashMap
<>();
map
.
put
(
"equipmentIndexName.keyword"
,
value
);
map
.
put
(
"gatewayId.keyword"
,
ids
);
List
<?
extends
Terms
.
Bucket
>
lidate
=
commonServiceImpl
.
getgroupavg
(
map
,
"valueF"
,
"equipmentIndexName.keyword"
,
ESEquipments
.
class
);
DecimalFormat
format2
=
new
DecimalFormat
(
"#.00"
);
for
(
Terms
.
Bucket
bucket
:
lidate
)
{
Aggregations
aggregation
=
bucket
.
getAggregations
();
List
<
Aggregation
>
listdata
=
Objects
.
nonNull
(
aggregation
)
?
aggregation
.
asList
()
:
null
;
for
(
Aggregation
agg
:
listdata
)
{
ParsedAvg
parsedAvg
=
(
ParsedAvg
)
agg
;
switch
(
bucket
.
getKeyAsString
())
{
case
SS:
mapdta
.
put
(
"SS"
,
Double
.
valueOf
(
format2
.
format
(
parsedAvg
.
getValue
())));
break
;
case
ZFS:
mapdta
.
put
(
"ZFS"
,
Double
.
valueOf
(
format2
.
format
(
parsedAvg
.
getValue
())));
break
;
case
ZFSLJ:
mapdta
.
put
(
"ZFSLJ"
,
Double
.
valueOf
(
format2
.
format
(
parsedAvg
.
getValue
())));
break
;
default
:
break
;
}
}
}
//日发电量
AtomicReference
<
Double
>
dailyPower
=
new
AtomicReference
<>(
0.0
);
//月发电量
AtomicReference
<
Double
>
monthlyPower
=
new
AtomicReference
<>(
0.0
);
//年发电量
AtomicReference
<
Double
>
annualPower
=
new
AtomicReference
<>(
0.0
);
for
(
StationCacheInfoDto
stationBasic
:
gatewayId
)
{
if
(
"FDZ"
.
equals
(
stationBasic
.
getStationType
()))
{
Map
<
String
,
List
<
String
>>
queryCondtion
=
new
HashMap
<>();
queryCondtion
.
put
(
CommonConstans
.
QueryStringEquipmentIndexName
,
Arrays
.
asList
(
"日发电量"
,
"月发电量"
,
"年发电量"
));
queryCondtion
.
put
(
CommonConstans
.
QueryStringGateWayId
,
Arrays
.
asList
(
stationBasic
.
getFanGatewayId
()));
List
<
ESEquipments
>
result
=
commonServiceImpl
.
getListDataByCondtions
(
queryCondtion
,
null
,
ESEquipments
.
class
);
dailyPower
.
updateAndGet
(
v
->
v
+
keepFourdecimalPlaces
(
commonServiceImpl
.
getSumByEquipmentIndxName
(
result
,
"日发电量"
)));
monthlyPower
.
updateAndGet
(
v
->
v
+
keepFourdecimalPlaces
(
commonServiceImpl
.
getSumByEquipmentIndxName
(
result
,
"月发电量"
)));
annualPower
.
updateAndGet
(
v
->
v
+
keepFourdecimalPlaces
(
commonServiceImpl
.
getSumByEquipmentIndxName
(
result
,
"年发电量"
)));
}
else
{
Map
<
String
,
List
<
String
>>
queryCondtion
=
new
HashMap
<>();
queryCondtion
.
put
(
CommonConstans
.
QueryStringEquipmentIndexName
,
CommonConstans
.
taiHeGenIndicator
);
queryCondtion
.
put
(
CommonConstans
.
QueryStringGateWayId
,
Arrays
.
asList
(
stationBasic
.
getBoosterGatewayId
()));
List
<
ESEquipments
>
result
=
commonServiceImpl
.
getListDataByCondtions
(
queryCondtion
,
null
,
ESEquipments
.
class
);
dailyPower
.
updateAndGet
(
v
->
v
+
keepFourdecimalPlaces
(
commonServiceImpl
.
getSumByEquipmentIndxName
(
result
,
CommonConstans
.
taiHeGenIndicatorDay
)));
monthlyPower
.
updateAndGet
(
v
->
v
+
keepFourdecimalPlaces
(
commonServiceImpl
.
getSumByEquipmentIndxName
(
result
,
CommonConstans
.
taiHeGenIndicatorMonth
)));
annualPower
.
updateAndGet
(
v
->
v
+
keepFourdecimalPlaces
(
commonServiceImpl
.
getSumByEquipmentIndxName
(
result
,
CommonConstans
.
taiHeGenIndicatorYear
)));
}
}
mapdta
.
put
(
"RSD"
,
keepFourdecimalPlaces
(
dailyPower
.
get
()));
mapdta
.
put
(
"YFD"
,
keepFourdecimalPlaces
(
monthlyPower
.
get
()));
mapdta
.
put
(
"NFD"
,
keepFourdecimalPlaces
(
annualPower
.
get
()));
// //总和
// value.clear();
// value.add(RSD);
// value.add(YFD);
// value.add(NFD);
// List<? extends Terms.Bucket> lidatesum = commonServiceImpl.getgroupsum(map, "valueF", "equipmentIndexName.keyword", ESEquipments.class);
try
{
emqKeeper
.
getMqttClient
().
publish
(
"qg/yxzb"
,
JSON
.
toJSONString
(
mapdta
).
getBytes
(),
0
,
true
);
}
catch
(
MqttException
e
)
{
e
.
printStackTrace
();
}
return
mapdta
;
}
@Scheduled
(
cron
=
"0/10 * * * * ?"
)
@PostConstruct
private
void
sendQYYXZBMqtt
()
{
List
<
StationCacheInfoDto
>
listStationCacheInfoDto
=
commonServiceImpl
.
getListStationCacheInfoDto
();
Map
<
String
,
List
<
StationCacheInfoDto
>>
belongAreaList
=
listStationCacheInfoDto
.
stream
()
.
collect
(
Collectors
.
groupingBy
(
StationCacheInfoDto:
:
getAreaCode
));
for
(
String
s
:
belongAreaList
.
keySet
())
{
// List<String> ids =
// belongAreaList.get(s).stream().map(StationCacheInfoDto::getFanGatewayId).collect(Collectors.toList());
getqy
(
belongAreaList
.
get
(
s
),
s
);
}
}
/**
* 区域
**/
public
Map
<
String
,
Double
>
getqy
(
List
<
StationCacheInfoDto
>
gatewayId
,
String
s
)
{
Map
<
String
,
Double
>
mapdta
=
new
HashMap
<>();
mapdta
.
put
(
"SS"
,
0
d
);
mapdta
.
put
(
"ZFS"
,
0
d
);
mapdta
.
put
(
"ZFSLJ"
,
0
d
);
mapdta
.
put
(
"RSD"
,
0
d
);
mapdta
.
put
(
"YFD"
,
0
d
);
mapdta
.
put
(
"NFD"
,
0
d
);
mapdta
.
put
(
"YJHWC"
,
0
d
);
mapdta
.
put
(
"NJHWC"
,
0
d
);
// // 平均数
// List<String> value = new ArrayList<>();
// List<String> ids = new ArrayList<>();
// for (StationCacheInfoDto stationCacheInfoDto : gatewayId) {
// ids.add(stationCacheInfoDto.getFanGatewayId());
// ids.add(stationCacheInfoDto.getBoosterGatewayId());
// }
//
// for (Terms.Bucket bucket : lidatesum) {
// Aggregations aggregation = bucket.getAggregations();
// List<Aggregation> listdata = Objects.nonNull(aggregation) ? aggregation.asList() : null;
// for (Aggregation agg : listdata) {
// ParsedSum parsedSum = (ParsedSum) agg;
// switch (bucket.getKeyAsString()) {
// case RSD:
// mapdta.put("RSD", Double.valueOf(format2.format(parsedSum.getValue()*CommonConstans.pvGenPoweActor* CommonConstans.pvGenPoweActorDay)));
// break;
// case YFD:
// mapdta.put("YFD", Double.valueOf(format2.format(parsedSum.getValue()*CommonConstans.pvGenPoweActornew)));
// break;
// case NFD:
// mapdta.put("NFD", Double.valueOf(format2.format(parsedSum.getValue()*CommonConstans.pvGenPoweActornew)));
// break;
// default:
// break;
// }
// }
// }
//计算月完成百分比
//当前月份 获取
LocalDate
currentDate
=
LocalDate
.
now
();
int
month
=
currentDate
.
getMonthValue
();
QueryWrapper
<
StationPlan
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
select
(
"ifnull(sum(value), 0) as sum_value"
);
wrapper
.
eq
(
"monthly"
,
month
);
List
<
Map
<
String
,
Object
>>
list
=
StationPlanMapper
.
selectMaps
(
wrapper
);
Double
sumValue
=
list
!=
null
&&
!
list
.
isEmpty
()
?
(
Double
)
list
.
get
(
0
).
get
(
"sum_value"
)
:
0
;
//计算年完成百分比
Double
ybfb
=
sumValue
>
0
?
mapdta
.
get
(
"YFD"
)
/
sumValue
*
100
:
0
;
ybfb
=
new
BigDecimal
(
ybfb
).
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
).
doubleValue
();
mapdta
.
put
(
"YJHWC"
,
ybfb
);
QueryWrapper
<
StationPlan
>
wrapper1
=
new
QueryWrapper
<>();
wrapper1
.
select
(
"ifnull(sum(value), 0) as sum_value"
);
List
<
Map
<
String
,
Object
>>
list1
=
StationPlanMapper
.
selectMaps
(
wrapper1
);
Double
sumValuen
=
list1
!=
null
&&
!
list1
.
isEmpty
()
?
(
Double
)
list1
.
get
(
0
).
get
(
"sum_value"
)
:
0
;
Double
ybfbn
=
sumValuen
>
0
?
mapdta
.
get
(
"NFD"
)
/
sumValuen
*
100
:
0
;
ybfbn
=
new
BigDecimal
(
ybfbn
).
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
).
doubleValue
();
mapdta
.
put
(
"NJHWC"
,
ybfbn
);
try
{
System
.
out
.
println
(
JSON
.
toJSONString
(
mapdta
));
emqKeeper
.
getMqttClient
().
publish
(
"qyyxzb/"
+
s
,
JSON
.
toJSONString
(
mapdta
).
getBytes
(),
1
,
true
);
}
catch
(
MqttException
e
)
{
e
.
printStackTrace
();
}
return
mapdta
;
}
public
Double
keepFourdecimalPlaces
(
Double
param
)
{
return
Double
.
valueOf
(
String
.
format
(
"%.4f"
,
param
));
}
//全国发电趋势
@Scheduled
(
cron
=
"0/10 * * * * ? "
)
public
SeriesData
getSeriesDataqg
(){
//获取今年当月 日发电趋势
List
<
Double
>
listjn
=
gettimedate
(
new
Date
());
//获取去年当月 日发电趋势
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
add
(
Calendar
.
YEAR
,
-
1
);
Date
oneYearAgoToday
=
calendar
.
getTime
();
List
<
Double
>
listqn
=
gettimedate
(
oneYearAgoToday
);
Map
<
String
,
Object
>
mapjn
=
new
HashMap
<>();
mapjn
.
put
(
"data"
,
listjn
);
mapjn
.
put
(
"name"
,
"当前值"
);
Map
<
String
,
Object
>
mapqn
=
new
HashMap
<>();
mapqn
.
put
(
"data"
,
listqn
);
mapqn
.
put
(
"name"
,
"同期值"
);
List
<
Map
<
String
,
Object
>>
list
=
new
ArrayList
<>();
list
.
add
(
mapjn
);
list
.
add
(
mapqn
);
SeriesData
seriesData
=
new
SeriesData
();
seriesData
.
setSeriesData
(
list
);
//获取日期
List
<
String
>
listdate
=
dayReportnq
(
new
Date
());
seriesData
.
setAxisData
(
listdate
);
try
{
emqKeeper
.
getMqttClient
().
publish
(
"countryFd"
,
JSON
.
toJSONString
(
seriesData
).
getBytes
(),
0
,
false
);
}
catch
(
MqttException
e
)
{
e
.
printStackTrace
();
}
return
seriesData
;
}
//获取区域月日发电量
@Scheduled
(
cron
=
"0/10 * * * * ?"
)
private
void
sendQYFDLMqtt
(){
List
<
StationCacheInfoDto
>
listStationCacheInfoDto
=
commonServiceImpl
.
getListStationCacheInfoDto
();
Map
<
String
,
List
<
StationCacheInfoDto
>>
belongAreaList
=
listStationCacheInfoDto
.
stream
().
collect
(
Collectors
.
groupingBy
(
StationCacheInfoDto:
:
getBelongArea
));
for
(
String
s
:
belongAreaList
.
keySet
())
{
List
<
String
>
ids
=
belongAreaList
.
get
(
s
).
stream
().
map
(
StationCacheInfoDto:
:
getFanGatewayId
).
collect
(
Collectors
.
toList
());
getSeriesDataqy
(
new
Date
(),
ids
,
s
);
}
}
//区域发电趋势
public
SeriesData
getSeriesDataqy
(
Date
date
,
List
<
String
>
gatewayId
,
String
areaCode
){
//获取今年当月 日发电趋势
List
<
Double
>
listjn
=
gettimedateqy
(
new
Date
(),
gatewayId
);
//获取去年当月 日发电趋势
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
add
(
Calendar
.
YEAR
,
-
1
);
Date
oneYearAgoToday
=
calendar
.
getTime
();
List
<
Double
>
listqn
=
gettimedateqy
(
oneYearAgoToday
,
gatewayId
);
Map
<
String
,
Object
>
mapjn
=
new
HashMap
<>();
mapjn
.
put
(
"data"
,
listjn
);
mapjn
.
put
(
"name"
,
"当前值"
);
Map
<
String
,
Object
>
mapqn
=
new
HashMap
<>();
mapqn
.
put
(
"data"
,
listqn
);
mapqn
.
put
(
"name"
,
"同期值"
);
List
<
Map
<
String
,
Object
>>
list
=
new
ArrayList
<>();
list
.
add
(
mapjn
);
list
.
add
(
mapqn
);
SeriesData
seriesData
=
new
SeriesData
();
seriesData
.
setSeriesData
(
list
);
//获取日期
List
<
String
>
listdate
=
dayReportnq
(
new
Date
());
seriesData
.
setAxisData
(
listdate
);
try
{
emqKeeper
.
getMqttClient
().
publish
(
"qy/fdqs/"
+
areaCode
,
JSON
.
toJSONString
(
seriesData
).
getBytes
(),
1
,
true
);
}
catch
(
MqttException
e
)
{
e
.
printStackTrace
();
}
return
seriesData
;
}
//获取全国月日发电量
public
List
<
Double
>
gettimedate
(
Date
date
){
SimpleDateFormat
myFmt2
=
new
SimpleDateFormat
(
"yyyyMM"
);
String
monthy
=
myFmt2
.
format
(
date
);
List
<
Double
>
listdate
=
new
ArrayList
<>();
List
<
String
>
value
=
new
ArrayList
<>();
value
.
add
(
RSD
);
Map
<
String
,
List
<
String
>>
map
=
new
HashMap
<>();
map
.
put
(
"equipmentIndexName.keyword"
,
value
);
List
<
String
>
value1
=
new
ArrayList
<>();
value1
.
add
(
monthy
);
map
.
put
(
"moon.keyword"
,
value1
);
List
<?
extends
Terms
.
Bucket
>
lidate
=
commonServiceImpl
.
getgroupsum
(
map
,
"value"
,
"day.keyword"
,
ESDailyPowerGeneration
.
class
);
Map
<
String
,
Double
>
mapdta
=
new
HashMap
<>();
DecimalFormat
format2
=
new
DecimalFormat
(
"#.0000"
);
for
(
Terms
.
Bucket
bucket
:
lidate
)
{
Aggregations
aggregation
=
bucket
.
getAggregations
();
List
<
Aggregation
>
listdata
=
Objects
.
nonNull
(
aggregation
)?
aggregation
.
asList
():
null
;
for
(
Aggregation
agg
:
listdata
)
{
ParsedSum
parsedSum
=(
ParsedSum
)
agg
;
mapdta
.
put
(
bucket
.
getKeyAsString
(),
Double
.
valueOf
(
format2
.
format
(
parsedSum
.
getValue
())));
}
}
//组装数据
List
<
String
>
list
=
dayReport
(
date
);
for
(
String
s
:
list
)
{
if
(
mapdta
!=
null
&&
mapdta
.
containsKey
(
s
)){
listdate
.
add
(
mapdta
.
get
(
s
));
}
else
{
listdate
.
add
(
0
d
);
}
}
try
{
emqKeeper
.
getMqttClient
().
publish
(
"topic"
,
JSON
.
toJSONString
(
listdate
).
getBytes
(),
0
,
false
);
}
catch
(
MqttException
e
)
{
e
.
printStackTrace
();
}
return
listdate
;
}
public
List
<
Double
>
gettimedateqy
(
Date
date
,
List
<
String
>
stationId
){
SimpleDateFormat
myFmt2
=
new
SimpleDateFormat
(
"yyyyMM"
);
String
monthy
=
myFmt2
.
format
(
date
);
List
<
Double
>
listdate
=
new
ArrayList
<>();
List
<
String
>
value
=
new
ArrayList
<>();
value
.
add
(
RSD
);
Map
<
String
,
List
<
String
>>
map
=
new
HashMap
<>();
map
.
put
(
"equipmentIndexName.keyword"
,
value
);
map
.
put
(
"stationId.keyword"
,
stationId
);
List
<
String
>
value1
=
new
ArrayList
<>();
value1
.
add
(
monthy
);
map
.
put
(
"moon.keyword"
,
value1
);
List
<?
extends
Terms
.
Bucket
>
lidate
=
commonServiceImpl
.
getgroupsum
(
map
,
"value"
,
"day.keyword"
,
ESDailyPowerGeneration
.
class
);
Map
<
String
,
Double
>
mapdta
=
new
HashMap
<>();
DecimalFormat
format2
=
new
DecimalFormat
(
"#.0000"
);
for
(
Terms
.
Bucket
bucket
:
lidate
)
{
Aggregations
aggregation
=
bucket
.
getAggregations
();
List
<
Aggregation
>
listdata
=
Objects
.
nonNull
(
aggregation
)?
aggregation
.
asList
():
null
;
for
(
Aggregation
agg
:
listdata
)
{
ParsedSum
parsedSum
=(
ParsedSum
)
agg
;
mapdta
.
put
(
bucket
.
getKeyAsString
(),
Double
.
valueOf
(
format2
.
format
(
parsedSum
.
getValue
())));
}
}
//组装数据
List
<
String
>
list
=
dayReport
(
date
);
for
(
String
s
:
list
)
{
if
(
mapdta
!=
null
&&
mapdta
.
containsKey
(
s
)){
listdate
.
add
(
mapdta
.
get
(
s
));
}
else
{
listdate
.
add
(
0
d
);
}
}
return
listdate
;
}
// // List<String> ids =
// // gatewayId.stream().map(StationCacheInfoDto::getFanGatewayId).collect(Collectors.toList());
//
// value.add(SS);
// value.add(ZFS);
// value.add(ZFSLJ);
// Map<String, List<String>> map = new HashMap<>();
// map.put("equipmentIndexName.keyword", value);
// map.put("gatewayId.keyword", ids);
//
// List<? extends Terms.Bucket> lidate = commonServiceImpl.getgroupavg(map, "valueF", "equipmentIndexName.keyword",
// ESEquipments.class);
// DecimalFormat format2 = new DecimalFormat("#.00");
// for (Terms.Bucket bucket : lidate) {
// Aggregations aggregation = bucket.getAggregations();
// List<Aggregation> listdata = Objects.nonNull(aggregation) ? aggregation.asList() : null;
// for (Aggregation agg : listdata) {
// ParsedAvg parsedAvg = (ParsedAvg) agg;
//
// switch (bucket.getKeyAsString()) {
// case SS:
// mapdta.put("SS", Double.valueOf(format2.format(parsedAvg.getValue())));
// break;
// case ZFS:
// mapdta.put("ZFS", Double.valueOf(format2.format(parsedAvg.getValue())));
// break;
// case ZFSLJ:
// mapdta.put("ZFSLJ", Double.valueOf(format2.format(parsedAvg.getValue())));
// break;
// default:
// break;
// }
// }
// }
//
// // 日发电量
// AtomicReference<Double> dailyPower = new AtomicReference<>(0.0);
// // 月发电量
// AtomicReference<Double> monthlyPower = new AtomicReference<>(0.0);
// // 年发电量
// AtomicReference<Double> annualPower = new AtomicReference<>(0.0);
// for (StationCacheInfoDto stationBasic : gatewayId) {
//
// if ("FDZ".equals(stationBasic.getStationType())) {
// Map<String, List<String>> queryCondtion = new HashMap<>();
// queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("日发电量", "月发电量", "年发电量"));
// queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getFanGatewayId()));
// List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null,
// ESEquipments.class);
// dailyPower.updateAndGet(
// v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量")));
// monthlyPower.updateAndGet(
// v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量")));
// annualPower.updateAndGet(
// v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "年发电量")));
// } else {
// Map<String, List<String>> queryCondtion = new HashMap<>();
// queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, CommonConstans.taiHeGenIndicator);
// queryCondtion.put(CommonConstans.QueryStringGateWayId,
// Arrays.asList(stationBasic.getBoosterGatewayId()));
// List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null,
// ESEquipments.class);
// dailyPower.updateAndGet(v -> v + keepFourdecimalPlaces(
// commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorDay)));
// monthlyPower.updateAndGet(v -> v + keepFourdecimalPlaces(
// commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorMonth)));
// annualPower.updateAndGet(v -> v + keepFourdecimalPlaces(
// commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorYear)));
// }
//
// }
//
// mapdta.put("RSD", keepFourdecimalPlaces(dailyPower.get()));
// mapdta.put("YFD", keepFourdecimalPlaces(monthlyPower.get()));
// mapdta.put("NFD", keepFourdecimalPlaces(annualPower.get()));
//
//// //总和
//// value.clear();
//// value.add(RSD);
//// value.add(YFD);
//// value.add(NFD);
//// List<? extends Terms.Bucket> lidatesum = commonServiceImpl.getgroupsum(map, "valueF", "equipmentIndexName.keyword", ESEquipments.class);
////
//// for (Terms.Bucket bucket : lidatesum) {
//// Aggregations aggregation = bucket.getAggregations();
//// List<Aggregation> listdata = Objects.nonNull(aggregation) ? aggregation.asList() : null;
//// for (Aggregation agg : listdata) {
//// ParsedSum parsedSum = (ParsedSum) agg;
//// switch (bucket.getKeyAsString()) {
//// case RSD:
//// mapdta.put("RSD", Double.valueOf(format2.format(parsedSum.getValue()*CommonConstans.pvGenPoweActor* CommonConstans.pvGenPoweActorDay)));
//// break;
//// case YFD:
//// mapdta.put("YFD", Double.valueOf(format2.format(parsedSum.getValue()*CommonConstans.pvGenPoweActornew)));
//// break;
//// case NFD:
//// mapdta.put("NFD", Double.valueOf(format2.format(parsedSum.getValue()*CommonConstans.pvGenPoweActornew)));
//// break;
//// default:
//// break;
//// }
//// }
//// }
// // 计算月完成百分比
// // 当前月份 获取
// LocalDate currentDate = LocalDate.now();
// int month = currentDate.getMonthValue();
//
// QueryWrapper<StationPlan> wrapper = new QueryWrapper<>();
// wrapper.select("ifnull(sum(value), 0) as sum_value");
// wrapper.eq("monthly", month);
// List<Map<String, Object>> list = StationPlanMapper.selectMaps(wrapper);
// Double sumValue = list != null && !list.isEmpty() ? (Double) list.get(0).get("sum_value") : 0;
// // 计算年完成百分比
// Double ybfb = sumValue > 0 ? mapdta.get("YFD") / sumValue * 100 : 0;
// ybfb = new BigDecimal(ybfb).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
//
// mapdta.put("YJHWC", ybfb);
// QueryWrapper<StationPlan> wrapper1 = new QueryWrapper<>();
// wrapper1.select("ifnull(sum(value), 0) as sum_value");
// List<Map<String, Object>> list1 = StationPlanMapper.selectMaps(wrapper1);
// Double sumValuen = list1 != null && !list1.isEmpty() ? (Double) list1.get(0).get("sum_value") : 0;
// Double ybfbn = sumValuen > 0 ? mapdta.get("NFD") / sumValuen * 100 : 0;
// ybfbn = new BigDecimal(ybfbn).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
// mapdta.put("NJHWC", ybfbn);
//改为部盾接口
String
requestUrl
=
Constants
.
BASE_URL
+
"?"
+
Constants
.
get_quota_info
;
LocalDate
currentDate
=
LocalDate
.
now
();
DateTimeFormatter
formatter
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd"
);
String
formattedDate
=
currentDate
.
format
(
formatter
);
JSONObject
data
=
httpRequestUtil
.
getResPonse
(
requestUrl
+
"&reporting_data="
+
formattedDate
,
Constants
.
REQUEST_GET
,
""
,
Constants
.
resovleRule_data
);
mapdta
.
put
(
"Day"
,
data
.
getDouble
(
"day_generating_capacity"
));
mapdta
.
put
(
"Moon"
,
data
.
getDouble
(
"month_generating_capacity"
));
mapdta
.
put
(
"Year"
,
data
.
getDouble
(
"year_generating_capacity"
));
mapdta
.
put
(
"YJHWC"
,
Double
.
valueOf
(
data
.
getString
(
"year_quota_rate"
).
replace
(
"%"
,
""
)));
mapdta
.
put
(
"NJHWC"
,
Double
.
valueOf
(
data
.
getString
(
"month_quota_rate"
).
replace
(
"%"
,
""
)));
//部盾每天十二点才填报,如果十二点前没有数据则获取前一天的数据
if
(
data
.
getDouble
(
"sum_irradiance"
)==
0
)
{
// 计算昨天日期
LocalDate
yesterday
=
currentDate
.
minusDays
(
1
);
formattedDate
=
yesterday
.
format
(
formatter
);
data
=
httpRequestUtil
.
getResPonse
(
requestUrl
+
"&reporting_data="
+
formattedDate
,
Constants
.
REQUEST_GET
,
""
,
Constants
.
resovleRule_data
);
}
mapdta
.
put
(
"SS"
,
data
.
getDouble
(
"average_wind_speed"
));
mapdta
.
put
(
"ZFS"
,
data
.
getDouble
(
"avg_irradiance"
));
mapdta
.
put
(
"ZFSLJ"
,
data
.
getDouble
(
"sum_irradiance"
));
try
{
System
.
out
.
println
(
JSON
.
toJSONString
(
mapdta
));
emqKeeper
.
getMqttClient
().
publish
(
"qyyxzb/"
+
s
,
JSON
.
toJSONString
(
mapdta
).
getBytes
(),
1
,
true
);
}
catch
(
MqttException
e
)
{
e
.
printStackTrace
();
}
return
mapdta
;
}
public
Double
keepFourdecimalPlaces
(
Double
param
)
{
return
Double
.
valueOf
(
String
.
format
(
"%.4f"
,
param
));
}
// 全国发电趋势
@Scheduled
(
cron
=
"0/10 * * * * ? "
)
public
SeriesData
getSeriesDataqg
()
{
// 获取今年当月 日发电趋势
List
<
Double
>
listjn
=
gettimedate
(
new
Date
());
// 获取去年当月 日发电趋势
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
add
(
Calendar
.
YEAR
,
-
1
);
Date
oneYearAgoToday
=
calendar
.
getTime
();
List
<
Double
>
listqn
=
gettimedate
(
oneYearAgoToday
);
Map
<
String
,
Object
>
mapjn
=
new
HashMap
<>();
mapjn
.
put
(
"data"
,
listjn
);
mapjn
.
put
(
"name"
,
"当前值"
);
Map
<
String
,
Object
>
mapqn
=
new
HashMap
<>();
mapqn
.
put
(
"data"
,
listqn
);
mapqn
.
put
(
"name"
,
"同期值"
);
List
<
Map
<
String
,
Object
>>
list
=
new
ArrayList
<>();
list
.
add
(
mapjn
);
list
.
add
(
mapqn
);
SeriesData
seriesData
=
new
SeriesData
();
seriesData
.
setSeriesData
(
list
);
// 获取日期
List
<
String
>
listdate
=
dayReportnq
(
new
Date
());
seriesData
.
setAxisData
(
listdate
);
try
{
emqKeeper
.
getMqttClient
().
publish
(
"countryFd"
,
JSON
.
toJSONString
(
seriesData
).
getBytes
(),
0
,
false
);
}
catch
(
MqttException
e
)
{
e
.
printStackTrace
();
}
return
seriesData
;
}
// 获取区域月日发电量
@Scheduled
(
cron
=
"0/10 * * * * ?"
)
private
void
sendQYFDLMqtt
()
{
List
<
StationCacheInfoDto
>
listStationCacheInfoDto
=
commonServiceImpl
.
getListStationCacheInfoDto
();
Map
<
String
,
List
<
StationCacheInfoDto
>>
belongAreaList
=
listStationCacheInfoDto
.
stream
()
.
collect
(
Collectors
.
groupingBy
(
StationCacheInfoDto:
:
getBelongArea
));
for
(
String
s
:
belongAreaList
.
keySet
())
{
List
<
String
>
ids
=
belongAreaList
.
get
(
s
).
stream
().
map
(
StationCacheInfoDto:
:
getFanGatewayId
)
.
collect
(
Collectors
.
toList
());
getSeriesDataqy
(
new
Date
(),
ids
,
s
);
}
}
// 区域发电趋势
public
SeriesData
getSeriesDataqy
(
Date
date
,
List
<
String
>
gatewayId
,
String
areaCode
)
{
// 获取今年当月 日发电趋势
List
<
Double
>
listjn
=
gettimedateqy
(
new
Date
(),
gatewayId
);
// 获取去年当月 日发电趋势
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
add
(
Calendar
.
YEAR
,
-
1
);
Date
oneYearAgoToday
=
calendar
.
getTime
();
List
<
Double
>
listqn
=
gettimedateqy
(
oneYearAgoToday
,
gatewayId
);
Map
<
String
,
Object
>
mapjn
=
new
HashMap
<>();
mapjn
.
put
(
"data"
,
listjn
);
mapjn
.
put
(
"name"
,
"当前值"
);
Map
<
String
,
Object
>
mapqn
=
new
HashMap
<>();
mapqn
.
put
(
"data"
,
listqn
);
mapqn
.
put
(
"name"
,
"同期值"
);
List
<
Map
<
String
,
Object
>>
list
=
new
ArrayList
<>();
list
.
add
(
mapjn
);
list
.
add
(
mapqn
);
SeriesData
seriesData
=
new
SeriesData
();
seriesData
.
setSeriesData
(
list
);
// 获取日期
List
<
String
>
listdate
=
dayReportnq
(
new
Date
());
seriesData
.
setAxisData
(
listdate
);
try
{
emqKeeper
.
getMqttClient
().
publish
(
"qy/fdqs/"
+
areaCode
,
JSON
.
toJSONString
(
seriesData
).
getBytes
(),
1
,
true
);
}
catch
(
MqttException
e
)
{
e
.
printStackTrace
();
}
return
seriesData
;
}
// 获取全国月日发电量
public
List
<
Double
>
gettimedate
(
Date
date
)
{
SimpleDateFormat
myFmt2
=
new
SimpleDateFormat
(
"yyyyMM"
);
String
monthy
=
myFmt2
.
format
(
date
);
List
<
Double
>
listdate
=
new
ArrayList
<>();
List
<
String
>
value
=
new
ArrayList
<>();
value
.
add
(
RSD
);
Map
<
String
,
List
<
String
>>
map
=
new
HashMap
<>();
map
.
put
(
"equipmentIndexName.keyword"
,
value
);
List
<
String
>
value1
=
new
ArrayList
<>();
value1
.
add
(
monthy
);
map
.
put
(
"moon.keyword"
,
value1
);
List
<?
extends
Terms
.
Bucket
>
lidate
=
commonServiceImpl
.
getgroupsum
(
map
,
"value"
,
"day.keyword"
,
ESDailyPowerGeneration
.
class
);
Map
<
String
,
Double
>
mapdta
=
new
HashMap
<>();
DecimalFormat
format2
=
new
DecimalFormat
(
"#.0000"
);
for
(
Terms
.
Bucket
bucket
:
lidate
)
{
Aggregations
aggregation
=
bucket
.
getAggregations
();
List
<
Aggregation
>
listdata
=
Objects
.
nonNull
(
aggregation
)
?
aggregation
.
asList
()
:
null
;
for
(
Aggregation
agg
:
listdata
)
{
ParsedSum
parsedSum
=
(
ParsedSum
)
agg
;
mapdta
.
put
(
bucket
.
getKeyAsString
(),
Double
.
valueOf
(
format2
.
format
(
parsedSum
.
getValue
())));
}
}
// 组装数据
List
<
String
>
list
=
dayReport
(
date
);
for
(
String
s
:
list
)
{
if
(
mapdta
!=
null
&&
mapdta
.
containsKey
(
s
))
{
listdate
.
add
(
mapdta
.
get
(
s
));
}
else
{
listdate
.
add
(
0
d
);
}
}
try
{
emqKeeper
.
getMqttClient
().
publish
(
"topic"
,
JSON
.
toJSONString
(
listdate
).
getBytes
(),
0
,
false
);
}
catch
(
MqttException
e
)
{
e
.
printStackTrace
();
}
return
listdate
;
}
public
List
<
Double
>
gettimedateqy
(
Date
date
,
List
<
String
>
stationId
)
{
SimpleDateFormat
myFmt2
=
new
SimpleDateFormat
(
"yyyyMM"
);
String
monthy
=
myFmt2
.
format
(
date
);
List
<
Double
>
listdate
=
new
ArrayList
<>();
List
<
String
>
value
=
new
ArrayList
<>();
value
.
add
(
RSD
);
Map
<
String
,
List
<
String
>>
map
=
new
HashMap
<>();
map
.
put
(
"equipmentIndexName.keyword"
,
value
);
map
.
put
(
"stationId.keyword"
,
stationId
);
List
<
String
>
value1
=
new
ArrayList
<>();
value1
.
add
(
monthy
);
map
.
put
(
"moon.keyword"
,
value1
);
List
<?
extends
Terms
.
Bucket
>
lidate
=
commonServiceImpl
.
getgroupsum
(
map
,
"value"
,
"day.keyword"
,
ESDailyPowerGeneration
.
class
);
Map
<
String
,
Double
>
mapdta
=
new
HashMap
<>();
DecimalFormat
format2
=
new
DecimalFormat
(
"#.0000"
);
for
(
Terms
.
Bucket
bucket
:
lidate
)
{
Aggregations
aggregation
=
bucket
.
getAggregations
();
List
<
Aggregation
>
listdata
=
Objects
.
nonNull
(
aggregation
)
?
aggregation
.
asList
()
:
null
;
for
(
Aggregation
agg
:
listdata
)
{
ParsedSum
parsedSum
=
(
ParsedSum
)
agg
;
mapdta
.
put
(
bucket
.
getKeyAsString
(),
Double
.
valueOf
(
format2
.
format
(
parsedSum
.
getValue
())));
}
}
// 组装数据
List
<
String
>
list
=
dayReport
(
date
);
for
(
String
s
:
list
)
{
if
(
mapdta
!=
null
&&
mapdta
.
containsKey
(
s
))
{
listdate
.
add
(
mapdta
.
get
(
s
));
}
else
{
listdate
.
add
(
0
d
);
}
}
return
listdate
;
}
//全国月发电量趋势
@Scheduled
(
cron
=
"0/10 * * * * ?"
)
public
Map
<
String
,
Object
>
gettimedateyfd
(
){
SimpleDateFormat
myFmt2
=
new
SimpleDateFormat
(
"yyyy"
);
String
monthy
=
myFmt2
.
format
(
new
Date
());
List
<
Double
>
listdate
=
new
ArrayList
<>();
List
<
String
>
value
=
new
ArrayList
<>();
value
.
add
(
YFD
);
Map
<
String
,
List
<
String
>>
map
=
new
HashMap
<>();
map
.
put
(
"equipmentIndexName.keyword"
,
value
);
List
<
String
>
value1
=
new
ArrayList
<>();
value1
.
add
(
monthy
);
map
.
put
(
"year.keyword"
,
value1
);
List
<?
extends
Terms
.
Bucket
>
lidate
=
commonServiceImpl
.
getgroupsum
(
map
,
"value"
,
"day.keyword"
,
ESMoonPowerGeneration
.
class
);
Map
<
String
,
Double
>
mapdta
=
new
HashMap
<>();
DecimalFormat
format2
=
new
DecimalFormat
(
"#.0000"
);
for
(
Terms
.
Bucket
bucket
:
lidate
)
{
Aggregations
aggregation
=
bucket
.
getAggregations
();
List
<
Aggregation
>
listdata
=
Objects
.
nonNull
(
aggregation
)?
aggregation
.
asList
():
null
;
for
(
Aggregation
agg
:
listdata
)
{
ParsedSum
parsedSum
=(
ParsedSum
)
agg
;
mapdta
.
put
(
bucket
.
getKeyAsString
(),
Double
.
valueOf
(
format2
.
format
(
parsedSum
.
getValue
())));
}
}
//组装数据
List
<
String
>
list
=
yueReport
();
for
(
String
s
:
list
)
{
if
(
mapdta
!=
null
&&
mapdta
.
containsKey
(
s
)){
listdate
.
add
(
mapdta
.
get
(
s
));
}
else
{
listdate
.
add
(
0
d
);
}
}
Map
<
String
,
Object
>
mapjn
=
new
HashMap
<>();
mapjn
.
put
(
"seriesData"
,
listdate
);
mapjn
.
put
(
"axisData"
,
list
);
try
{
System
.
out
.
println
(
JSON
.
toJSONString
(
mapjn
));
emqKeeper
.
getMqttClient
().
publish
(
"topic_yfd"
,
JSON
.
toJSONString
(
mapjn
).
getBytes
(),
0
,
false
);
}
catch
(
MqttException
e
)
{
e
.
printStackTrace
();
}
return
mapjn
;
}
//区域月发电量趋势
//获取区域月日发电量
@Scheduled
(
cron
=
"0/10 * * * * ?"
)
public
void
sendQYFDLMqttyfd
(){
List
<
StationCacheInfoDto
>
listStationCacheInfoDto
=
commonServiceImpl
.
getListStationCacheInfoDto
();
Map
<
String
,
List
<
StationCacheInfoDto
>>
belongAreaList
=
listStationCacheInfoDto
.
stream
().
collect
(
Collectors
.
groupingBy
(
StationCacheInfoDto:
:
getBelongArea
));
for
(
String
s
:
belongAreaList
.
keySet
())
{
List
<
String
>
ids
=
belongAreaList
.
get
(
s
).
stream
().
map
(
StationCacheInfoDto:
:
getFanGatewayId
).
collect
(
Collectors
.
toList
());
gettimedateqyyfd
(
new
Date
(),
ids
,
s
);
}
}
public
Map
<
String
,
Object
>
gettimedateqyyfd
(
Date
date
,
List
<
String
>
gatewayId
,
String
areaCode
){
SimpleDateFormat
myFmt2
=
new
SimpleDateFormat
(
"yyyy"
);
String
monthy
=
myFmt2
.
format
(
date
);
List
<
Double
>
listdate
=
new
ArrayList
<>();
List
<
String
>
value
=
new
ArrayList
<>();
value
.
add
(
YFD
);
Map
<
String
,
List
<
String
>>
map
=
new
HashMap
<>();
map
.
put
(
"equipmentIndexName.keyword"
,
value
);
map
.
put
(
"gatewayId.keyword"
,
gatewayId
);
List
<
String
>
value1
=
new
ArrayList
<>();
value1
.
add
(
monthy
);
map
.
put
(
"year.keyword"
,
value1
);
List
<?
extends
Terms
.
Bucket
>
lidate
=
commonServiceImpl
.
getgroupsum
(
map
,
"value"
,
"day.keyword"
,
ESMoonPowerGeneration
.
class
);
Map
<
String
,
Double
>
mapdta
=
new
HashMap
<>();
DecimalFormat
format2
=
new
DecimalFormat
(
"#.0000"
);
for
(
Terms
.
Bucket
bucket
:
lidate
)
{
Aggregations
aggregation
=
bucket
.
getAggregations
();
List
<
Aggregation
>
listdata
=
Objects
.
nonNull
(
aggregation
)?
aggregation
.
asList
():
null
;
for
(
Aggregation
agg
:
listdata
)
{
ParsedSum
parsedSum
=(
ParsedSum
)
agg
;
mapdta
.
put
(
bucket
.
getKeyAsString
(),
Double
.
valueOf
(
format2
.
format
(
parsedSum
.
getValue
())));
}
}
//组装数据
List
<
String
>
list
=
yueReport
();
for
(
String
s
:
list
)
{
if
(
mapdta
!=
null
&&
mapdta
.
containsKey
(
s
)){
listdate
.
add
(
mapdta
.
get
(
s
));
}
else
{
listdate
.
add
(
0
d
);
}
}
Map
<
String
,
Object
>
mapjn
=
new
HashMap
<>();
mapjn
.
put
(
"seriesData"
,
listdate
);
mapjn
.
put
(
"axisData"
,
list
);
try
{
System
.
out
.
println
(
JSON
.
toJSONString
(
mapjn
));
emqKeeper
.
getMqttClient
().
publish
(
"qyyfd/fdqs/"
+
areaCode
,
JSON
.
toJSONString
(
mapjn
).
getBytes
(),
0
,
false
);
}
catch
(
MqttException
e
)
{
e
.
printStackTrace
();
}
return
mapjn
;
}
//全国发电完成趋势
@Scheduled
(
cron
=
"0/10 * * * * ?"
)
public
Map
<
String
,
Object
>
gettimedateyfdqs
(
){
SimpleDateFormat
myFmt2
=
new
SimpleDateFormat
(
"yyyy"
);
String
monthy
=
myFmt2
.
format
(
new
Date
());
List
<
Double
>
listdate
=
new
ArrayList
<>();
List
<
String
>
value
=
new
ArrayList
<>();
value
.
add
(
YFD
);
Map
<
String
,
List
<
String
>>
map
=
new
HashMap
<>();
map
.
put
(
"equipmentIndexName.keyword"
,
value
);
List
<
String
>
value1
=
new
ArrayList
<>();
value1
.
add
(
monthy
);
map
.
put
(
"year.keyword"
,
value1
);
List
<?
extends
Terms
.
Bucket
>
lidate
=
commonServiceImpl
.
getgroupsum
(
map
,
"value"
,
"day.keyword"
,
ESMoonPowerGeneration
.
class
);
Map
<
String
,
Double
>
mapdta
=
new
HashMap
<>();
DecimalFormat
format2
=
new
DecimalFormat
(
"#.0000"
);
for
(
Terms
.
Bucket
bucket
:
lidate
)
{
Aggregations
aggregation
=
bucket
.
getAggregations
();
List
<
Aggregation
>
listdata
=
Objects
.
nonNull
(
aggregation
)?
aggregation
.
asList
():
null
;
for
(
Aggregation
agg
:
listdata
)
{
ParsedSum
parsedSum
=(
ParsedSum
)
agg
;
mapdta
.
put
(
bucket
.
getKeyAsString
(),
Double
.
valueOf
(
format2
.
format
(
parsedSum
.
getValue
())));
}
}
//计划完成量
Map
<
String
,
Double
>
mapwc
=
new
HashMap
<>();
QueryWrapper
<
StationPlan
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
select
(
" monthly ,sum(value) value "
);
wrapper
.
eq
(
"year"
,
monthy
);
wrapper
.
groupBy
(
"monthly"
);
List
<
Map
<
String
,
Object
>>
list1
=
StationPlanMapper
.
selectMaps
(
wrapper
);
for
(
Map
<
String
,
Object
>
stringObjectMap
:
list1
)
{
mapwc
.
put
(
stringObjectMap
.
get
(
"monthly"
).
toString
(),
Double
.
valueOf
(
stringObjectMap
.
get
(
"value"
).
toString
()));
}
//组装数据
List
<
String
>
list
=
yueReport
();
for
(
String
s
:
list
)
{
if
(
mapdta
!=
null
&&
mapdta
.
containsKey
(
s
)){
if
(
mapwc
!=
null
&&
mapwc
.
containsKey
(
s
)){
listdate
.
add
(
Double
.
valueOf
(
format2
.
format
(
mapdta
.
get
(
s
)/
mapwc
.
get
(
s
)*
100
)));
}
else
{
listdate
.
add
(
0
d
);
}
}
else
{
listdate
.
add
(
0
d
);
}
}
Map
<
String
,
Object
>
mapjn
=
new
HashMap
<>();
mapjn
.
put
(
"seriesData"
,
listdate
);
mapjn
.
put
(
"axisData"
,
list
);
try
{
System
.
out
.
println
(
JSON
.
toJSONString
(
mapjn
));
emqKeeper
.
getMqttClient
().
publish
(
"topic_yfdqs"
,
JSON
.
toJSONString
(
mapjn
).
getBytes
(),
0
,
false
);
}
catch
(
MqttException
e
)
{
e
.
printStackTrace
();
}
return
mapjn
;
}
//区域发电完成趋势
@Scheduled
(
cron
=
"0/10 * * * * ?"
)
public
void
sendQYFDLMqttyfdqs
(){
List
<
StationCacheInfoDto
>
listStationCacheInfoDto
=
commonServiceImpl
.
getListStationCacheInfoDto
();
Map
<
String
,
List
<
StationCacheInfoDto
>>
belongAreaList
=
listStationCacheInfoDto
.
stream
().
collect
(
Collectors
.
groupingBy
(
StationCacheInfoDto:
:
getBelongArea
));
for
(
String
s
:
belongAreaList
.
keySet
())
{
List
<
String
>
ids
=
belongAreaList
.
get
(
s
).
stream
().
map
(
StationCacheInfoDto:
:
getFanGatewayId
).
collect
(
Collectors
.
toList
());
List
<
String
>
idsStationId
=
belongAreaList
.
get
(
s
).
stream
().
map
(
StationCacheInfoDto:
:
getStationId
).
collect
(
Collectors
.
toList
());
gettimedateqyyfdqs
(
new
Date
(),
ids
,
s
,
idsStationId
);
}
}
public
Map
<
String
,
Object
>
gettimedateqyyfdqs
(
Date
date
,
List
<
String
>
gatewayId
,
String
areaCode
,
List
<
String
>
idsStationId
){
SimpleDateFormat
myFmt2
=
new
SimpleDateFormat
(
"yyyy"
);
String
monthy
=
myFmt2
.
format
(
date
);
List
<
Double
>
listdate
=
new
ArrayList
<>();
List
<
String
>
value
=
new
ArrayList
<>();
value
.
add
(
YFD
);
Map
<
String
,
List
<
String
>>
map
=
new
HashMap
<>();
map
.
put
(
"equipmentIndexName.keyword"
,
value
);
map
.
put
(
"gatewayId.keyword"
,
gatewayId
);
List
<
String
>
value1
=
new
ArrayList
<>();
value1
.
add
(
monthy
);
map
.
put
(
"year.keyword"
,
value1
);
List
<?
extends
Terms
.
Bucket
>
lidate
=
commonServiceImpl
.
getgroupsum
(
map
,
"value"
,
"day.keyword"
,
ESMoonPowerGeneration
.
class
);
Map
<
String
,
Double
>
mapdta
=
new
HashMap
<>();
DecimalFormat
format2
=
new
DecimalFormat
(
"#.0000"
);
for
(
Terms
.
Bucket
bucket
:
lidate
)
{
Aggregations
aggregation
=
bucket
.
getAggregations
();
List
<
Aggregation
>
listdata
=
Objects
.
nonNull
(
aggregation
)?
aggregation
.
asList
():
null
;
for
(
Aggregation
agg
:
listdata
)
{
ParsedSum
parsedSum
=(
ParsedSum
)
agg
;
mapdta
.
put
(
bucket
.
getKeyAsString
(),
Double
.
valueOf
(
format2
.
format
(
parsedSum
.
getValue
())));
}
}
//计划完成量
Map
<
String
,
Double
>
mapwc
=
new
HashMap
<>();
QueryWrapper
<
StationPlan
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
select
(
" monthly ,sum(value) value "
);
wrapper
.
eq
(
"year"
,
monthy
);
wrapper
.
in
(
"station_basic_id"
,
idsStationId
);
wrapper
.
groupBy
(
"monthly"
);
List
<
Map
<
String
,
Object
>>
list1
=
StationPlanMapper
.
selectMaps
(
wrapper
);
for
(
Map
<
String
,
Object
>
stringObjectMap
:
list1
)
{
mapwc
.
put
(
stringObjectMap
.
get
(
"monthly"
).
toString
(),
Double
.
valueOf
(
stringObjectMap
.
get
(
"value"
).
toString
()));
}
//组装数据
List
<
String
>
list
=
yueReport
();
for
(
String
s
:
list
)
{
if
(
mapdta
!=
null
&&
mapdta
.
containsKey
(
s
)){
if
(
mapwc
!=
null
&&
mapwc
.
containsKey
(
s
)){
listdate
.
add
(
Double
.
valueOf
(
format2
.
format
(
mapdta
.
get
(
s
)/
mapwc
.
get
(
s
)*
100
)));
}
else
{
listdate
.
add
(
0
d
);
}
}
else
{
listdate
.
add
(
0
d
);
}
}
Map
<
String
,
Object
>
mapjn
=
new
HashMap
<>();
mapjn
.
put
(
"seriesData"
,
listdate
);
mapjn
.
put
(
"axisData"
,
list
);
try
{
System
.
out
.
println
(
JSON
.
toJSONString
(
mapjn
));
emqKeeper
.
getMqttClient
().
publish
(
"qyyfdqs/fdqs/"
+
areaCode
,
JSON
.
toJSONString
(
mapjn
).
getBytes
(),
0
,
false
);
}
catch
(
MqttException
e
)
{
e
.
printStackTrace
();
}
return
mapjn
;
}
//每个场站 曲线定时刷新
@Scheduled
(
cron
=
"0/10 * * * * ?"
)
public
void
getDetailsWindSpeedAlldata
(){
List
<
StationBasic
>
stationBasicList
=
stationBasicMapper
.
selectList
(
new
QueryWrapper
<
StationBasic
>().
isNotNull
(
"belong_area"
).
isNotNull
(
"fan_gateway_id"
));
for
(
StationBasic
stationBasic
:
stationBasicList
)
{
monitoringServiceImpl
.
getDetailsWindSpeedAlldata
(
stationBasic
);
}
}
//全国场站功率和曲线
@Scheduled
(
cron
=
"0/10 * * * * ?"
)
public
void
getDetailsWindSpeedAlldataqgsh
(){
getDetailsWindSpeedAlldataqg
();
}
public
Map
<
String
,
Object
>
getDetailsWindSpeedAlldataqg
()
{
List
<
StationBasic
>
stationBasicListfd
=
stationBasicMapper
.
selectList
(
new
QueryWrapper
<
StationBasic
>().
isNotNull
(
"belong_area"
).
isNotNull
(
"fan_gateway_id"
).
eq
(
"station_type"
,
"FDZ"
));
List
<
StationBasic
>
stationBasicListgf
=
stationBasicMapper
.
selectList
(
new
QueryWrapper
<
StationBasic
>().
isNotNull
(
"belong_area"
).
isNotNull
(
"fan_gateway_id"
).
eq
(
"station_type"
,
"JZSGFDZ"
));
@Scheduled
(
cron
=
"0/10 * * * * ?"
)
public
Map
<
String
,
Object
>
gettimedateyfd
()
{
SimpleDateFormat
myFmt2
=
new
SimpleDateFormat
(
"yyyy"
);
String
monthy
=
myFmt2
.
format
(
new
Date
());
List
<
Double
>
listdate
=
new
ArrayList
<>();
List
<
String
>
value
=
new
ArrayList
<>();
value
.
add
(
YFD
);
Map
<
String
,
List
<
String
>>
map
=
new
HashMap
<>();
map
.
put
(
"equipmentIndexName.keyword"
,
value
);
List
<
String
>
value1
=
new
ArrayList
<>();
value1
.
add
(
monthy
);
map
.
put
(
"year.keyword"
,
value1
);
List
<?
extends
Terms
.
Bucket
>
lidate
=
commonServiceImpl
.
getgroupsum
(
map
,
"value"
,
"day.keyword"
,
ESMoonPowerGeneration
.
class
);
Map
<
String
,
Double
>
mapdta
=
new
HashMap
<>();
DecimalFormat
format2
=
new
DecimalFormat
(
"#.0000"
);
for
(
Terms
.
Bucket
bucket
:
lidate
)
{
Aggregations
aggregation
=
bucket
.
getAggregations
();
List
<
Aggregation
>
listdata
=
Objects
.
nonNull
(
aggregation
)
?
aggregation
.
asList
()
:
null
;
for
(
Aggregation
agg
:
listdata
)
{
ParsedSum
parsedSum
=
(
ParsedSum
)
agg
;
mapdta
.
put
(
bucket
.
getKeyAsString
(),
Double
.
valueOf
(
format2
.
format
(
parsedSum
.
getValue
())));
}
}
// 组装数据
List
<
String
>
list
=
yueReport
();
for
(
String
s
:
list
)
{
if
(
mapdta
!=
null
&&
mapdta
.
containsKey
(
s
))
{
listdate
.
add
(
mapdta
.
get
(
s
));
}
else
{
listdate
.
add
(
0
d
);
}
}
Map
<
String
,
Object
>
mapjn
=
new
HashMap
<>();
mapjn
.
put
(
"seriesData"
,
listdate
);
mapjn
.
put
(
"axisData"
,
list
);
try
{
System
.
out
.
println
(
JSON
.
toJSONString
(
mapjn
));
emqKeeper
.
getMqttClient
().
publish
(
"topic_yfd"
,
JSON
.
toJSONString
(
mapjn
).
getBytes
(),
0
,
false
);
}
catch
(
MqttException
e
)
{
e
.
printStackTrace
();
}
return
mapjn
;
}
// 区域月发电量趋势
// 获取区域月日发电量
@Scheduled
(
cron
=
"0/10 * * * * ?"
)
public
void
sendQYFDLMqttyfd
()
{
List
<
StationCacheInfoDto
>
listStationCacheInfoDto
=
commonServiceImpl
.
getListStationCacheInfoDto
();
Map
<
String
,
List
<
StationCacheInfoDto
>>
belongAreaList
=
listStationCacheInfoDto
.
stream
()
.
collect
(
Collectors
.
groupingBy
(
StationCacheInfoDto:
:
getBelongArea
));
for
(
String
s
:
belongAreaList
.
keySet
())
{
List
<
String
>
ids
=
belongAreaList
.
get
(
s
).
stream
().
map
(
StationCacheInfoDto:
:
getFanGatewayId
)
.
collect
(
Collectors
.
toList
());
gettimedateqyyfd
(
new
Date
(),
ids
,
s
);
}
}
public
Map
<
String
,
Object
>
gettimedateqyyfd
(
Date
date
,
List
<
String
>
gatewayId
,
String
areaCode
)
{
SimpleDateFormat
myFmt2
=
new
SimpleDateFormat
(
"yyyy"
);
String
monthy
=
myFmt2
.
format
(
date
);
List
<
Double
>
listdate
=
new
ArrayList
<>();
List
<
String
>
value
=
new
ArrayList
<>();
value
.
add
(
YFD
);
Map
<
String
,
List
<
String
>>
map
=
new
HashMap
<>();
map
.
put
(
"equipmentIndexName.keyword"
,
value
);
map
.
put
(
"gatewayId.keyword"
,
gatewayId
);
List
<
String
>
value1
=
new
ArrayList
<>();
value1
.
add
(
monthy
);
map
.
put
(
"year.keyword"
,
value1
);
List
<?
extends
Terms
.
Bucket
>
lidate
=
commonServiceImpl
.
getgroupsum
(
map
,
"value"
,
"day.keyword"
,
ESMoonPowerGeneration
.
class
);
Map
<
String
,
Double
>
mapdta
=
new
HashMap
<>();
DecimalFormat
format2
=
new
DecimalFormat
(
"#.0000"
);
for
(
Terms
.
Bucket
bucket
:
lidate
)
{
Aggregations
aggregation
=
bucket
.
getAggregations
();
List
<
Aggregation
>
listdata
=
Objects
.
nonNull
(
aggregation
)
?
aggregation
.
asList
()
:
null
;
for
(
Aggregation
agg
:
listdata
)
{
ParsedSum
parsedSum
=
(
ParsedSum
)
agg
;
mapdta
.
put
(
bucket
.
getKeyAsString
(),
Double
.
valueOf
(
format2
.
format
(
parsedSum
.
getValue
())));
}
}
// 组装数据
List
<
String
>
list
=
yueReport
();
for
(
String
s
:
list
)
{
if
(
mapdta
!=
null
&&
mapdta
.
containsKey
(
s
))
{
listdate
.
add
(
mapdta
.
get
(
s
));
}
else
{
listdate
.
add
(
0
d
);
}
}
Map
<
String
,
Object
>
mapjn
=
new
HashMap
<>();
mapjn
.
put
(
"seriesData"
,
listdate
);
mapjn
.
put
(
"axisData"
,
list
);
try
{
System
.
out
.
println
(
JSON
.
toJSONString
(
mapjn
));
emqKeeper
.
getMqttClient
().
publish
(
"qyyfd/fdqs/"
+
areaCode
,
JSON
.
toJSONString
(
mapjn
).
getBytes
(),
0
,
false
);
}
catch
(
MqttException
e
)
{
e
.
printStackTrace
();
}
return
mapjn
;
}
// 全国发电完成趋势
@Scheduled
(
cron
=
"0/10 * * * * ?"
)
public
Map
<
String
,
Object
>
gettimedateyfdqs
()
{
SimpleDateFormat
myFmt2
=
new
SimpleDateFormat
(
"yyyy"
);
String
monthy
=
myFmt2
.
format
(
new
Date
());
List
<
Double
>
listdate
=
new
ArrayList
<>();
List
<
String
>
value
=
new
ArrayList
<>();
value
.
add
(
YFD
);
Map
<
String
,
List
<
String
>>
map
=
new
HashMap
<>();
map
.
put
(
"equipmentIndexName.keyword"
,
value
);
List
<
String
>
value1
=
new
ArrayList
<>();
value1
.
add
(
monthy
);
map
.
put
(
"year.keyword"
,
value1
);
List
<?
extends
Terms
.
Bucket
>
lidate
=
commonServiceImpl
.
getgroupsum
(
map
,
"value"
,
"day.keyword"
,
ESMoonPowerGeneration
.
class
);
Map
<
String
,
Double
>
mapdta
=
new
HashMap
<>();
DecimalFormat
format2
=
new
DecimalFormat
(
"#.0000"
);
for
(
Terms
.
Bucket
bucket
:
lidate
)
{
Aggregations
aggregation
=
bucket
.
getAggregations
();
List
<
Aggregation
>
listdata
=
Objects
.
nonNull
(
aggregation
)
?
aggregation
.
asList
()
:
null
;
for
(
Aggregation
agg
:
listdata
)
{
ParsedSum
parsedSum
=
(
ParsedSum
)
agg
;
mapdta
.
put
(
bucket
.
getKeyAsString
(),
Double
.
valueOf
(
format2
.
format
(
parsedSum
.
getValue
())));
}
}
// 计划完成量
Map
<
String
,
Double
>
mapwc
=
new
HashMap
<>();
QueryWrapper
<
StationPlan
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
select
(
" monthly ,sum(value) value "
);
wrapper
.
eq
(
"year"
,
monthy
);
wrapper
.
groupBy
(
"monthly"
);
List
<
Map
<
String
,
Object
>>
list1
=
StationPlanMapper
.
selectMaps
(
wrapper
);
for
(
Map
<
String
,
Object
>
stringObjectMap
:
list1
)
{
mapwc
.
put
(
stringObjectMap
.
get
(
"monthly"
).
toString
(),
Double
.
valueOf
(
stringObjectMap
.
get
(
"value"
).
toString
()));
}
// 组装数据
List
<
String
>
list
=
yueReport
();
for
(
String
s
:
list
)
{
if
(
mapdta
!=
null
&&
mapdta
.
containsKey
(
s
))
{
if
(
mapwc
!=
null
&&
mapwc
.
containsKey
(
s
))
{
listdate
.
add
(
Double
.
valueOf
(
format2
.
format
(
mapdta
.
get
(
s
)
/
mapwc
.
get
(
s
)
*
100
)));
}
else
{
listdate
.
add
(
0
d
);
}
}
else
{
listdate
.
add
(
0
d
);
}
}
Map
<
String
,
Object
>
mapjn
=
new
HashMap
<>();
mapjn
.
put
(
"seriesData"
,
listdate
);
mapjn
.
put
(
"axisData"
,
list
);
try
{
System
.
out
.
println
(
JSON
.
toJSONString
(
mapjn
));
emqKeeper
.
getMqttClient
().
publish
(
"topic_yfdqs"
,
JSON
.
toJSONString
(
mapjn
).
getBytes
(),
0
,
false
);
}
catch
(
MqttException
e
)
{
e
.
printStackTrace
();
}
return
mapjn
;
}
// 区域发电完成趋势
@Scheduled
(
cron
=
"0/10 * * * * ?"
)
public
void
sendQYFDLMqttyfdqs
()
{
List
<
StationCacheInfoDto
>
listStationCacheInfoDto
=
commonServiceImpl
.
getListStationCacheInfoDto
();
Map
<
String
,
List
<
StationCacheInfoDto
>>
belongAreaList
=
listStationCacheInfoDto
.
stream
()
.
collect
(
Collectors
.
groupingBy
(
StationCacheInfoDto:
:
getBelongArea
));
for
(
String
s
:
belongAreaList
.
keySet
())
{
List
<
String
>
ids
=
belongAreaList
.
get
(
s
).
stream
().
map
(
StationCacheInfoDto:
:
getFanGatewayId
)
.
collect
(
Collectors
.
toList
());
List
<
String
>
idsStationId
=
belongAreaList
.
get
(
s
).
stream
().
map
(
StationCacheInfoDto:
:
getStationId
)
.
collect
(
Collectors
.
toList
());
gettimedateqyyfdqs
(
new
Date
(),
ids
,
s
,
idsStationId
);
}
}
public
Map
<
String
,
Object
>
gettimedateqyyfdqs
(
Date
date
,
List
<
String
>
gatewayId
,
String
areaCode
,
List
<
String
>
idsStationId
)
{
SimpleDateFormat
myFmt2
=
new
SimpleDateFormat
(
"yyyy"
);
String
monthy
=
myFmt2
.
format
(
date
);
List
<
Double
>
listdate
=
new
ArrayList
<>();
List
<
String
>
value
=
new
ArrayList
<>();
value
.
add
(
YFD
);
Map
<
String
,
List
<
String
>>
map
=
new
HashMap
<>();
map
.
put
(
"equipmentIndexName.keyword"
,
value
);
map
.
put
(
"gatewayId.keyword"
,
gatewayId
);
List
<
String
>
value1
=
new
ArrayList
<>();
value1
.
add
(
monthy
);
map
.
put
(
"year.keyword"
,
value1
);
List
<?
extends
Terms
.
Bucket
>
lidate
=
commonServiceImpl
.
getgroupsum
(
map
,
"value"
,
"day.keyword"
,
ESMoonPowerGeneration
.
class
);
Map
<
String
,
Double
>
mapdta
=
new
HashMap
<>();
DecimalFormat
format2
=
new
DecimalFormat
(
"#.0000"
);
for
(
Terms
.
Bucket
bucket
:
lidate
)
{
Aggregations
aggregation
=
bucket
.
getAggregations
();
List
<
Aggregation
>
listdata
=
Objects
.
nonNull
(
aggregation
)
?
aggregation
.
asList
()
:
null
;
for
(
Aggregation
agg
:
listdata
)
{
ParsedSum
parsedSum
=
(
ParsedSum
)
agg
;
mapdta
.
put
(
bucket
.
getKeyAsString
(),
Double
.
valueOf
(
format2
.
format
(
parsedSum
.
getValue
())));
}
}
// 计划完成量
Map
<
String
,
Double
>
mapwc
=
new
HashMap
<>();
QueryWrapper
<
StationPlan
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
select
(
" monthly ,sum(value) value "
);
wrapper
.
eq
(
"year"
,
monthy
);
wrapper
.
in
(
"station_basic_id"
,
idsStationId
);
wrapper
.
groupBy
(
"monthly"
);
List
<
Map
<
String
,
Object
>>
list1
=
StationPlanMapper
.
selectMaps
(
wrapper
);
for
(
Map
<
String
,
Object
>
stringObjectMap
:
list1
)
{
mapwc
.
put
(
stringObjectMap
.
get
(
"monthly"
).
toString
(),
Double
.
valueOf
(
stringObjectMap
.
get
(
"value"
).
toString
()));
}
// 组装数据
List
<
String
>
list
=
yueReport
();
for
(
String
s
:
list
)
{
if
(
mapdta
!=
null
&&
mapdta
.
containsKey
(
s
))
{
if
(
mapwc
!=
null
&&
mapwc
.
containsKey
(
s
))
{
listdate
.
add
(
Double
.
valueOf
(
format2
.
format
(
mapdta
.
get
(
s
)
/
mapwc
.
get
(
s
)
*
100
)));
}
else
{
listdate
.
add
(
0
d
);
}
}
else
{
listdate
.
add
(
0
d
);
}
}
Map
<
String
,
Object
>
mapjn
=
new
HashMap
<>();
mapjn
.
put
(
"seriesData"
,
listdate
);
mapjn
.
put
(
"axisData"
,
list
);
try
{
System
.
out
.
println
(
JSON
.
toJSONString
(
mapjn
));
emqKeeper
.
getMqttClient
().
publish
(
"qyyfdqs/fdqs/"
+
areaCode
,
JSON
.
toJSONString
(
mapjn
).
getBytes
(),
0
,
false
);
}
catch
(
MqttException
e
)
{
e
.
printStackTrace
();
}
return
mapjn
;
}
// 每个场站 曲线定时刷新
@Scheduled
(
cron
=
"0/10 * * * * ?"
)
public
void
getDetailsWindSpeedAlldata
()
{
List
<
StationBasic
>
stationBasicList
=
stationBasicMapper
.
selectList
(
new
QueryWrapper
<
StationBasic
>().
isNotNull
(
"belong_area"
).
isNotNull
(
"fan_gateway_id"
));
for
(
StationBasic
stationBasic
:
stationBasicList
)
{
monitoringServiceImpl
.
getDetailsWindSpeedAlldata
(
stationBasic
);
}
}
// 全国场站功率和曲线
@Scheduled
(
cron
=
"0/10 * * * * ?"
)
public
void
getDetailsWindSpeedAlldataqgsh
()
{
getDetailsWindSpeedAlldataqg
();
}
public
Map
<
String
,
Object
>
getDetailsWindSpeedAlldataqg
()
{
List
<
StationBasic
>
stationBasicListfd
=
stationBasicMapper
.
selectList
(
new
QueryWrapper
<
StationBasic
>()
.
isNotNull
(
"belong_area"
).
isNotNull
(
"fan_gateway_id"
).
eq
(
"station_type"
,
"FDZ"
));
List
<
StationBasic
>
stationBasicListgf
=
stationBasicMapper
.
selectList
(
new
QueryWrapper
<
StationBasic
>()
.
isNotNull
(
"belong_area"
).
isNotNull
(
"fan_gateway_id"
).
eq
(
"station_type"
,
"JZSGFDZ"
));
// List<String> fdGatewayId = stationBasicListfd.stream().map(StationBasic::getBoosterGatewayId).collect(Collectors.joining(","));
// List<String> gfGatewayId = stationBasicListgf.stream().map(StationBasic::getBoosterGatewayId).collect(Collectors.toList());
String
fdGatewayIds
=
stationBasicListfd
.
stream
().
map
(
stationBasic
->
"'"
+
stationBasic
.
getBoosterGatewayId
()+
"'"
).
collect
(
Collectors
.
joining
(
","
));
String
gfGatewayIds
=
stationBasicListgf
.
stream
().
map
(
stationBasic
->
"'"
+
stationBasic
.
getBoosterGatewayId
()+
"'"
).
collect
(
Collectors
.
joining
(
","
));
List
<
StationBasic
>
stationBasicListAll
=
new
ArrayList
<>();
stationBasicListAll
.
addAll
(
stationBasicListfd
);
stationBasicListAll
.
addAll
(
stationBasicListgf
);
AtomicReference
<
Double
>
installedCapacity
=
new
AtomicReference
<>(
0.0
);
stationBasicListAll
.
forEach
(
stationBasic
->
{
installedCapacity
.
updateAndGet
(
v
->
v
+
getStationCaPACITYL
(
stationBasic
.
getStationNumber
()));
});
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
List
<
String
>
values
=
new
ArrayList
<>();
Map
<
Date
,
Double
>
groupMap
=
new
HashMap
<>();
List
<
String
>
time
=
new
ArrayList
<>();
Map
<
String
,
Object
>
activePowerInfo
=
new
HashMap
<>();
List
<
IndicatorData
>
activePowerListFD
=
new
ArrayList
<>();
List
<
IndicatorData
>
activePowerListGF
=
new
ArrayList
<>();
String
fdGatewayIds
=
stationBasicListfd
.
stream
()
.
map
(
stationBasic
->
"'"
+
stationBasic
.
getBoosterGatewayId
()
+
"'"
).
collect
(
Collectors
.
joining
(
","
));
String
gfGatewayIds
=
stationBasicListgf
.
stream
()
.
map
(
stationBasic
->
"'"
+
stationBasic
.
getBoosterGatewayId
()
+
"'"
).
collect
(
Collectors
.
joining
(
","
));
List
<
StationBasic
>
stationBasicListAll
=
new
ArrayList
<>();
stationBasicListAll
.
addAll
(
stationBasicListfd
);
stationBasicListAll
.
addAll
(
stationBasicListgf
);
AtomicReference
<
Double
>
installedCapacity
=
new
AtomicReference
<>(
0.0
);
stationBasicListAll
.
forEach
(
stationBasic
->
{
installedCapacity
.
updateAndGet
(
v
->
v
+
getStationCaPACITYL
(
stationBasic
.
getStationNumber
()));
});
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
List
<
String
>
values
=
new
ArrayList
<>();
Map
<
Date
,
Double
>
groupMap
=
new
HashMap
<>();
List
<
String
>
time
=
new
ArrayList
<>();
Map
<
String
,
Object
>
activePowerInfo
=
new
HashMap
<>();
List
<
IndicatorData
>
activePowerListFD
=
new
ArrayList
<>();
List
<
IndicatorData
>
activePowerListGF
=
new
ArrayList
<>();
// String startTime = cn.hutool.core.date.DateUtil.today() + " 00:00:00";
// String endTime = cn.hutool.core.date.DateUtil.today() + " 23:59:59";
// Date currentDayStartTime = DateUtils.getCurrentDayStartTime(new Date());
...
...
@@ -900,87 +951,100 @@ public Map<String,Object> gettimedateyfd( ){
// String startTime = sdf.format(currentDayStartTime);
// String endTime= sdf.format(currentDayEndTime);
activePowerListFD
=
indicatorDataMapper
.
selectDataByequipmentIndexNameAndtimeqgNew
(
CommonConstans
.
xiazaoActivePowerPoint
,
fdGatewayIds
);
activePowerListGF
=
indicatorDataMapper
.
selectDataByequipmentIndexNameAndtimeqgNew
(
CommonConstans
.
taiheActivePowerPoint
,
gfGatewayIds
);
System
.
out
.
println
(
JSON
.
toJSONString
(
activePowerListFD
));
for
(
int
i
=
0
;
i
<
activePowerListFD
.
size
();
i
++)
{
IndicatorData
indicatorData
=
activePowerListFD
.
get
(
i
);
IndicatorData
indicatorData2
=
activePowerListGF
.
get
(
i
);
time
.
add
(
cn
.
hutool
.
core
.
date
.
DateUtil
.
format
(
indicatorData
.
getCreatedTime
(),
"HH:mm"
));
// Double vl= indicatorData.getValueF()+indicatorData2.getValueF() * CommonConstans.kwToMv;
Double
vl
=
Double
.
valueOf
(
String
.
format
(
CommonConstans
.
Twodecimalplaces
,
indicatorData
.
getValueF
()))+
Double
.
valueOf
(
String
.
format
(
CommonConstans
.
Twodecimalplaces
,
indicatorData2
.
getValueF
()
*
CommonConstans
.
kwToMv
));
values
.
add
(
String
.
format
(
CommonConstans
.
Twodecimalplaces
,
vl
));
}
String
max
=
String
.
format
(
CommonConstans
.
Twodecimalplaces
,
values
.
stream
().
mapToDouble
(
Double:
:
parseDouble
).
max
().
getAsDouble
());
String
min
=
String
.
format
(
CommonConstans
.
Twodecimalplaces
,
values
.
stream
().
mapToDouble
(
Double:
:
parseDouble
).
min
().
getAsDouble
());
String
mean
=
String
.
format
(
CommonConstans
.
Twodecimalplaces
,
values
.
stream
().
mapToDouble
(
Double:
:
parseDouble
).
average
().
getAsDouble
());
activePowerInfo
.
put
(
"mean"
,
mean
);
activePowerInfo
.
put
(
"max"
,
max
);
activePowerInfo
.
put
(
"min"
,
min
);
activePowerInfo
.
put
(
"maxTime"
,
time
.
get
(
values
.
lastIndexOf
(
max
)));
activePowerInfo
.
put
(
"minTime"
,
time
.
get
(
values
.
lastIndexOf
(
min
)));
activePowerInfo
.
put
(
"load"
,
String
.
format
(
CommonConstans
.
Twodecimalplaces
,
Double
.
valueOf
(
values
.
get
(
values
.
size
()
-
1
))
/
installedCapacity
.
get
()));
List
<
Map
<
String
,
Object
>>
seriesData
=
new
ArrayList
<>();
Map
<
String
,
Object
>
map3
=
new
HashMap
<>();
Map
<
String
,
Object
>
map1
=
new
HashMap
<>();
Map
<
String
,
Object
>
map2
=
new
HashMap
<>();
map1
.
put
(
"data"
,
values
);
seriesData
.
add
(
map1
);
map
.
put
(
"seriesData"
,
seriesData
);
map
.
put
(
"axisData"
,
time
);
System
.
out
.
println
(
JSON
.
toJSONString
(
map
));
try
{
emqKeeper
.
getMqttClient
().
publish
(
"all_Power_table"
,
JSON
.
toJSON
(
map
).
toString
().
getBytes
(
"UTF-8"
),
1
,
true
);
emqKeeper
.
getMqttClient
().
publish
(
"all_Power_info"
,
JSON
.
toJSON
(
activePowerInfo
).
toString
().
getBytes
(
"UTF-8"
),
1
,
true
);
}
catch
(
Exception
exception
)
{
exception
.
printStackTrace
();
}
return
map
;
}
//区域场站功率和曲线
@Scheduled
(
cron
=
"0/10 * * * * ?"
)
public
void
getDetailsWindqyqx
(){
List
<
StationBasic
>
stationBasicList
=
stationBasicMapper
.
selectList
(
new
QueryWrapper
<
StationBasic
>().
isNotNull
(
"belong_area"
).
isNotNull
(
"fan_gateway_id"
));
Map
<
String
,
List
<
StationBasic
>>
belongAreaList
=
stationBasicList
.
stream
().
collect
(
Collectors
.
groupingBy
(
StationBasic:
:
getBelongArea
));
for
(
String
s
:
belongAreaList
.
keySet
())
{
getDetailsWindqy
(
s
,
belongAreaList
.
get
(
s
));
}
}
public
Map
<
String
,
Object
>
getDetailsWindqy
(
String
s
,
List
<
StationBasic
>
listStationCacheInfoDto
)
{
List
<
StationBasic
>
stationBasicListfd
=
listStationCacheInfoDto
.
stream
().
filter
(
e
->
"FDZ"
.
equals
(
e
.
getStationType
())).
collect
(
Collectors
.
toList
());
List
<
StationBasic
>
stationBasicListgf
=
listStationCacheInfoDto
.
stream
().
filter
(
e
->
!
"FDZ"
.
equals
(
e
.
getStationType
())).
collect
(
Collectors
.
toList
());
activePowerListFD
=
indicatorDataMapper
.
selectDataByequipmentIndexNameAndtimeqgNew
(
CommonConstans
.
xiazaoActivePowerPoint
,
fdGatewayIds
);
activePowerListGF
=
indicatorDataMapper
.
selectDataByequipmentIndexNameAndtimeqgNew
(
CommonConstans
.
taiheActivePowerPoint
,
gfGatewayIds
);
System
.
out
.
println
(
JSON
.
toJSONString
(
activePowerListFD
));
for
(
int
i
=
0
;
i
<
activePowerListFD
.
size
();
i
++)
{
IndicatorData
indicatorData
=
activePowerListFD
.
get
(
i
);
IndicatorData
indicatorData2
=
activePowerListGF
.
get
(
i
);
time
.
add
(
cn
.
hutool
.
core
.
date
.
DateUtil
.
format
(
indicatorData
.
getCreatedTime
(),
"HH:mm"
));
// Double vl= indicatorData.getValueF()+indicatorData2.getValueF() *
// CommonConstans.kwToMv;
Double
vl
=
Double
.
valueOf
(
String
.
format
(
CommonConstans
.
Twodecimalplaces
,
indicatorData
.
getValueF
()))
+
Double
.
valueOf
(
String
.
format
(
CommonConstans
.
Twodecimalplaces
,
indicatorData2
.
getValueF
()
*
CommonConstans
.
kwToMv
));
values
.
add
(
String
.
format
(
CommonConstans
.
Twodecimalplaces
,
vl
));
}
String
max
=
String
.
format
(
CommonConstans
.
Twodecimalplaces
,
values
.
stream
().
mapToDouble
(
Double:
:
parseDouble
).
max
().
getAsDouble
());
String
min
=
String
.
format
(
CommonConstans
.
Twodecimalplaces
,
values
.
stream
().
mapToDouble
(
Double:
:
parseDouble
).
min
().
getAsDouble
());
String
mean
=
String
.
format
(
CommonConstans
.
Twodecimalplaces
,
values
.
stream
().
mapToDouble
(
Double:
:
parseDouble
).
average
().
getAsDouble
());
activePowerInfo
.
put
(
"mean"
,
mean
);
activePowerInfo
.
put
(
"max"
,
max
);
activePowerInfo
.
put
(
"min"
,
min
);
activePowerInfo
.
put
(
"maxTime"
,
time
.
get
(
values
.
lastIndexOf
(
max
)));
activePowerInfo
.
put
(
"minTime"
,
time
.
get
(
values
.
lastIndexOf
(
min
)));
activePowerInfo
.
put
(
"load"
,
String
.
format
(
CommonConstans
.
Twodecimalplaces
,
Double
.
valueOf
(
values
.
get
(
values
.
size
()
-
1
))
/
installedCapacity
.
get
()));
List
<
Map
<
String
,
Object
>>
seriesData
=
new
ArrayList
<>();
Map
<
String
,
Object
>
map3
=
new
HashMap
<>();
Map
<
String
,
Object
>
map1
=
new
HashMap
<>();
Map
<
String
,
Object
>
map2
=
new
HashMap
<>();
map1
.
put
(
"data"
,
values
);
seriesData
.
add
(
map1
);
map
.
put
(
"seriesData"
,
seriesData
);
map
.
put
(
"axisData"
,
time
);
System
.
out
.
println
(
JSON
.
toJSONString
(
map
));
try
{
emqKeeper
.
getMqttClient
().
publish
(
"all_Power_table"
,
JSON
.
toJSON
(
map
).
toString
().
getBytes
(
"UTF-8"
),
1
,
true
);
emqKeeper
.
getMqttClient
().
publish
(
"all_Power_info"
,
JSON
.
toJSON
(
activePowerInfo
).
toString
().
getBytes
(
"UTF-8"
),
1
,
true
);
}
catch
(
Exception
exception
)
{
exception
.
printStackTrace
();
}
return
map
;
}
// 区域场站功率和曲线
@Scheduled
(
cron
=
"0/10 * * * * ?"
)
public
void
getDetailsWindqyqx
()
{
List
<
StationBasic
>
stationBasicList
=
stationBasicMapper
.
selectList
(
new
QueryWrapper
<
StationBasic
>().
isNotNull
(
"belong_area"
).
isNotNull
(
"fan_gateway_id"
));
Map
<
String
,
List
<
StationBasic
>>
belongAreaList
=
stationBasicList
.
stream
()
.
collect
(
Collectors
.
groupingBy
(
StationBasic:
:
getBelongArea
));
for
(
String
s
:
belongAreaList
.
keySet
())
{
getDetailsWindqy
(
s
,
belongAreaList
.
get
(
s
));
}
}
public
Map
<
String
,
Object
>
getDetailsWindqy
(
String
s
,
List
<
StationBasic
>
listStationCacheInfoDto
)
{
List
<
StationBasic
>
stationBasicListfd
=
listStationCacheInfoDto
.
stream
()
.
filter
(
e
->
"FDZ"
.
equals
(
e
.
getStationType
())).
collect
(
Collectors
.
toList
());
List
<
StationBasic
>
stationBasicListgf
=
listStationCacheInfoDto
.
stream
()
.
filter
(
e
->
!
"FDZ"
.
equals
(
e
.
getStationType
())).
collect
(
Collectors
.
toList
());
// String fdGatewayIds="";
// String gfGatewayIds="";
// List<String> fdGatewayId = stationBasicListfd.stream().map(StationBasic::getBoosterGatewayId).collect(Collectors.toList());
// List<String> gfGatewayId = stationBasicListgf.stream().map(StationBasic::getBoosterGatewayId).collect(Collectors.toList());
String
fdGatewayIds
=
stationBasicListfd
.
stream
().
map
(
stationBasic
->
"'"
+
stationBasic
.
getBoosterGatewayId
()+
"'"
).
collect
(
Collectors
.
joining
(
","
));
String
gfGatewayIds
=
stationBasicListgf
.
stream
().
map
(
stationBasic
->
"'"
+
stationBasic
.
getBoosterGatewayId
()+
"'"
).
collect
(
Collectors
.
joining
(
","
));
List
<
StationBasic
>
stationBasicListAll
=
new
ArrayList
<>();
stationBasicListAll
.
addAll
(
stationBasicListfd
);
stationBasicListAll
.
addAll
(
stationBasicListgf
);
AtomicReference
<
Double
>
installedCapacity
=
new
AtomicReference
<>(
0.0
);
stationBasicListAll
.
forEach
(
stationBasic
->
{
installedCapacity
.
updateAndGet
(
v
->
v
+
getStationCaPACITYL
(
stationBasic
.
getStationNumber
()));
});
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
List
<
String
>
values
=
new
ArrayList
<>();
Map
<
Date
,
Double
>
groupMap
=
new
HashMap
<>();
List
<
String
>
time
=
new
ArrayList
<>();
Map
<
String
,
Object
>
activePowerInfo
=
new
HashMap
<>();
List
<
IndicatorData
>
activePowerListFD
=
new
ArrayList
<>();
List
<
IndicatorData
>
activePowerListGF
=
new
ArrayList
<>();
String
fdGatewayIds
=
stationBasicListfd
.
stream
()
.
map
(
stationBasic
->
"'"
+
stationBasic
.
getBoosterGatewayId
()
+
"'"
).
collect
(
Collectors
.
joining
(
","
));
String
gfGatewayIds
=
stationBasicListgf
.
stream
()
.
map
(
stationBasic
->
"'"
+
stationBasic
.
getBoosterGatewayId
()
+
"'"
).
collect
(
Collectors
.
joining
(
","
));
List
<
StationBasic
>
stationBasicListAll
=
new
ArrayList
<>();
stationBasicListAll
.
addAll
(
stationBasicListfd
);
stationBasicListAll
.
addAll
(
stationBasicListgf
);
AtomicReference
<
Double
>
installedCapacity
=
new
AtomicReference
<>(
0.0
);
stationBasicListAll
.
forEach
(
stationBasic
->
{
installedCapacity
.
updateAndGet
(
v
->
v
+
getStationCaPACITYL
(
stationBasic
.
getStationNumber
()));
});
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
List
<
String
>
values
=
new
ArrayList
<>();
Map
<
Date
,
Double
>
groupMap
=
new
HashMap
<>();
List
<
String
>
time
=
new
ArrayList
<>();
Map
<
String
,
Object
>
activePowerInfo
=
new
HashMap
<>();
List
<
IndicatorData
>
activePowerListFD
=
new
ArrayList
<>();
List
<
IndicatorData
>
activePowerListGF
=
new
ArrayList
<>();
// Date currentDayStartTime = DateUtils.getCurrentDayStartTime(new Date());
// Date currentDayEndTime = DateUtils.getCurrentDayEndTime(new Date());
// Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
...
...
@@ -989,167 +1053,159 @@ public Map<String,Object> gettimedateyfd( ){
// String startTime = sdf.format(currentDayStartTime);
// String endTime= sdf.format(currentDayEndTime);
// String startTime = DateUtils.convertDateToString(currentDayStartTime, DateUtils.DATE_TIME_PATTERN);
// String endTime = DateUtils.convertDateToString(currentDayEndTime, DateUtils.DATE_TIME_PATTERN);
activePowerListFD
=
indicatorDataMapper
.
selectDataByequipmentIndexNameAndtimeqgNew
(
CommonConstans
.
xiazaoActivePowerPoint
,
fdGatewayIds
);
activePowerListGF
=
indicatorDataMapper
.
selectDataByequipmentIndexNameAndtimeqgNew
(
CommonConstans
.
taiheActivePowerPoint
,
gfGatewayIds
);
System
.
out
.
println
(
JSON
.
toJSONString
(
activePowerListFD
));
for
(
int
i
=
0
;
i
<
activePowerListFD
.
size
();
i
++)
{
IndicatorData
indicatorData
=
activePowerListFD
.
get
(
i
);
IndicatorData
indicatorData2
=
activePowerListGF
.
get
(
i
);
time
.
add
(
cn
.
hutool
.
core
.
date
.
DateUtil
.
format
(
indicatorData
.
getCreatedTime
(),
"HH:mm"
));
// Double vl= indicatorData.getValueF()+indicatorData2.getValueF() * CommonConstans.kwToMv;
Double
vl
=
Double
.
valueOf
(
String
.
format
(
CommonConstans
.
Twodecimalplaces
,
indicatorData
.
getValueF
()))+
Double
.
valueOf
(
String
.
format
(
CommonConstans
.
Twodecimalplaces
,
indicatorData2
.
getValueF
()
*
CommonConstans
.
kwToMv
));
values
.
add
(
String
.
format
(
CommonConstans
.
Twodecimalplaces
,
vl
));
}
String
max
=
String
.
format
(
CommonConstans
.
Twodecimalplaces
,
values
.
stream
().
mapToDouble
(
Double:
:
parseDouble
).
max
().
getAsDouble
());
String
min
=
String
.
format
(
CommonConstans
.
Twodecimalplaces
,
values
.
stream
().
mapToDouble
(
Double:
:
parseDouble
).
min
().
getAsDouble
());
String
mean
=
String
.
format
(
CommonConstans
.
Twodecimalplaces
,
values
.
stream
().
mapToDouble
(
Double:
:
parseDouble
).
average
().
getAsDouble
());
activePowerInfo
.
put
(
"mean"
,
mean
);
activePowerInfo
.
put
(
"max"
,
max
);
activePowerInfo
.
put
(
"min"
,
min
);
activePowerInfo
.
put
(
"maxTime"
,
time
.
get
(
values
.
lastIndexOf
(
max
)));
activePowerInfo
.
put
(
"minTime"
,
time
.
get
(
values
.
lastIndexOf
(
min
)));
activePowerInfo
.
put
(
"load"
,
String
.
format
(
CommonConstans
.
Twodecimalplaces
,
Double
.
valueOf
(
values
.
get
(
values
.
size
()
-
1
))
/
installedCapacity
.
get
()));
List
<
Map
<
String
,
Object
>>
seriesData
=
new
ArrayList
<>();
Map
<
String
,
Object
>
map3
=
new
HashMap
<>();
Map
<
String
,
Object
>
map1
=
new
HashMap
<>();
Map
<
String
,
Object
>
map2
=
new
HashMap
<>();
map1
.
put
(
"data"
,
values
);
seriesData
.
add
(
map1
);
map
.
put
(
"seriesData"
,
seriesData
);
map
.
put
(
"axisData"
,
time
);
System
.
out
.
println
(
JSON
.
toJSONString
(
map
));
try
{
emqKeeper
.
getMqttClient
().
publish
(
s
+
"_Power_table"
,
JSON
.
toJSON
(
map
).
toString
().
getBytes
(
"UTF-8"
),
1
,
true
);
emqKeeper
.
getMqttClient
().
publish
(
s
+
"_Power_info"
,
JSON
.
toJSON
(
activePowerInfo
).
toString
().
getBytes
(
"UTF-8"
),
1
,
true
);
}
catch
(
Exception
exception
)
{
exception
.
printStackTrace
();
}
return
map
;
}
public
Map
<
String
,
Object
>
getDetailsWindSpeed
(
String
gatewayId
,
String
equipmentNumber
)
{
Date
currentDayStartTime
=
DateUtils
.
getCurrentDayStartTime
(
new
Date
());
Date
currentDayEndTime
=
DateUtils
.
getCurrentDayEndTime
(
new
Date
());
Calendar
calendar
=
Calendar
.
getInstance
(
TimeZone
.
getTimeZone
(
"UTC"
));
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd'T'HH:mm:ss'Z'"
);
sdf
.
setTimeZone
(
TimeZone
.
getTimeZone
(
"UTC"
));
String
startTime
=
sdf
.
format
(
currentDayStartTime
);
String
endTime
=
sdf
.
format
(
currentDayEndTime
);
List
<
IndicatorData
>
indicatorDataListWindSpeed
=
new
ArrayList
<>();
List
<
IndicatorData
>
indicatorDataListActivePower
=
new
ArrayList
<>();
indicatorDataListWindSpeed
=
indicatorDataMapper
.
selectDataByequipmentIndexNameAndtimeAndEquipmentNumber
(
"瞬时风速"
,
equipmentNumber
,
startTime
,
endTime
,
gatewayId
);
indicatorDataListActivePower
=
indicatorDataMapper
.
selectDataByequipmentIndexNameAndtimeAndEquipmentNumber
(
"有功功率"
,
equipmentNumber
,
startTime
,
endTime
,
gatewayId
);
List
<
String
>
windSpeeds
=
new
ArrayList
<>();
List
<
String
>
activePowers
=
new
ArrayList
<>();
List
<
String
>
axisData
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
indicatorDataListWindSpeed
.
size
();
i
++)
{
windSpeeds
.
add
(
indicatorDataListWindSpeed
.
get
(
i
).
getValue
());
activePowers
.
add
(
indicatorDataListActivePower
.
get
(
i
).
getValue
());
axisData
.
add
(
cn
.
hutool
.
core
.
date
.
DateUtil
.
format
(
indicatorDataListWindSpeed
.
get
(
i
).
getCreatedTime
(),
"HH:mm"
));
}
List
<
Map
<
String
,
Object
>>
seriesData
=
new
ArrayList
<>();
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
Map
<
String
,
Object
>
map1
=
new
HashMap
<>();
Map
<
String
,
Object
>
map2
=
new
HashMap
<>();
map1
.
put
(
"data"
,
windSpeeds
);
map2
.
put
(
"data"
,
activePowers
);
seriesData
.
add
(
map1
);
seriesData
.
add
(
map2
);
map
.
put
(
"seriesData"
,
seriesData
);
map
.
put
(
"axisData"
,
axisData
);
return
map
;
}
public
List
<
String
>
yueReport
()
{
List
<
String
>
list
=
new
ArrayList
<>();
for
(
int
i
=
1
;
i
<
13
;
i
++
)
{
list
.
add
(
String
.
valueOf
(
i
));
}
return
list
;
}
public
Double
getStationCaPACITYL
(
String
werks
)
{
Double
installCapacity
=
0.0
;
installCapacity
=
SjglZsjZsbtzServiceImpl
.
getStationCapactityByStationWerks
(
werks
);
return
ObjectUtils
.
isEmpty
(
installCapacity
)
?
0.00
:
installCapacity
;
}
public
List
<
String
>
dayReport
(
Date
month
)
{
List
<
String
>
list
=
new
ArrayList
<>();
Calendar
cal
=
Calendar
.
getInstance
();
cal
.
setTime
(
month
);
//month 为指定月份任意日期
int
year
=
cal
.
get
(
Calendar
.
YEAR
);
int
m
=
cal
.
get
(
Calendar
.
MONTH
)+
1
;
int
dayNumOfMonth
=
DateUtil
.
getDaysByYearMonth
(
year
,
m
);
cal
.
set
(
Calendar
.
DAY_OF_MONTH
,
1
);
// 从一号开始
for
(
int
i
=
0
;
i
<
dayNumOfMonth
;
i
++
)
{
list
.
add
(
String
.
valueOf
(
i
+
1
));
}
return
list
;
}
public
List
<
String
>
dayReportnq
(
Date
month
)
{
List
<
String
>
list
=
new
ArrayList
<>();
Calendar
cal
=
Calendar
.
getInstance
();
cal
.
setTime
(
month
);
//month 为指定月份任意日期
int
year
=
cal
.
get
(
Calendar
.
YEAR
);
int
m
=
cal
.
get
(
Calendar
.
MONTH
)+
1
;
int
dayNumOfMonth
=
DateUtil
.
getDaysByYearMonth
(
year
,
m
);
cal
.
set
(
Calendar
.
DAY_OF_MONTH
,
1
);
// 从一号开始
for
(
int
i
=
0
;
i
<
dayNumOfMonth
;
i
++
)
{
list
.
add
(
m
+
"-"
+
String
.
valueOf
(
i
+
1
));
}
try
{
emqKeeper
.
getMqttClient
().
publish
(
"topic"
,
JSON
.
toJSONString
(
list
).
getBytes
(),
0
,
false
);
}
catch
(
MqttException
e
)
{
e
.
printStackTrace
();
}
return
list
;
}
activePowerListFD
=
indicatorDataMapper
.
selectDataByequipmentIndexNameAndtimeqgNew
(
CommonConstans
.
xiazaoActivePowerPoint
,
fdGatewayIds
);
activePowerListGF
=
indicatorDataMapper
.
selectDataByequipmentIndexNameAndtimeqgNew
(
CommonConstans
.
taiheActivePowerPoint
,
gfGatewayIds
);
System
.
out
.
println
(
JSON
.
toJSONString
(
activePowerListFD
));
for
(
int
i
=
0
;
i
<
activePowerListFD
.
size
();
i
++)
{
IndicatorData
indicatorData
=
activePowerListFD
.
get
(
i
);
IndicatorData
indicatorData2
=
activePowerListGF
.
get
(
i
);
time
.
add
(
cn
.
hutool
.
core
.
date
.
DateUtil
.
format
(
indicatorData
.
getCreatedTime
(),
"HH:mm"
));
// Double vl= indicatorData.getValueF()+indicatorData2.getValueF() *
// CommonConstans.kwToMv;
Double
vl
=
Double
.
valueOf
(
String
.
format
(
CommonConstans
.
Twodecimalplaces
,
indicatorData
.
getValueF
()))
+
Double
.
valueOf
(
String
.
format
(
CommonConstans
.
Twodecimalplaces
,
indicatorData2
.
getValueF
()
*
CommonConstans
.
kwToMv
));
values
.
add
(
String
.
format
(
CommonConstans
.
Twodecimalplaces
,
vl
));
}
String
max
=
String
.
format
(
CommonConstans
.
Twodecimalplaces
,
values
.
stream
().
mapToDouble
(
Double:
:
parseDouble
).
max
().
getAsDouble
());
String
min
=
String
.
format
(
CommonConstans
.
Twodecimalplaces
,
values
.
stream
().
mapToDouble
(
Double:
:
parseDouble
).
min
().
getAsDouble
());
String
mean
=
String
.
format
(
CommonConstans
.
Twodecimalplaces
,
values
.
stream
().
mapToDouble
(
Double:
:
parseDouble
).
average
().
getAsDouble
());
activePowerInfo
.
put
(
"mean"
,
mean
);
activePowerInfo
.
put
(
"max"
,
max
);
activePowerInfo
.
put
(
"min"
,
min
);
activePowerInfo
.
put
(
"maxTime"
,
time
.
get
(
values
.
lastIndexOf
(
max
)));
activePowerInfo
.
put
(
"minTime"
,
time
.
get
(
values
.
lastIndexOf
(
min
)));
activePowerInfo
.
put
(
"load"
,
String
.
format
(
CommonConstans
.
Twodecimalplaces
,
Double
.
valueOf
(
values
.
get
(
values
.
size
()
-
1
))
/
installedCapacity
.
get
()));
List
<
Map
<
String
,
Object
>>
seriesData
=
new
ArrayList
<>();
Map
<
String
,
Object
>
map3
=
new
HashMap
<>();
Map
<
String
,
Object
>
map1
=
new
HashMap
<>();
Map
<
String
,
Object
>
map2
=
new
HashMap
<>();
map1
.
put
(
"data"
,
values
);
seriesData
.
add
(
map1
);
map
.
put
(
"seriesData"
,
seriesData
);
map
.
put
(
"axisData"
,
time
);
System
.
out
.
println
(
JSON
.
toJSONString
(
map
));
try
{
emqKeeper
.
getMqttClient
().
publish
(
s
+
"_Power_table"
,
JSON
.
toJSON
(
map
).
toString
().
getBytes
(
"UTF-8"
),
1
,
true
);
emqKeeper
.
getMqttClient
().
publish
(
s
+
"_Power_info"
,
JSON
.
toJSON
(
activePowerInfo
).
toString
().
getBytes
(
"UTF-8"
),
1
,
true
);
}
catch
(
Exception
exception
)
{
exception
.
printStackTrace
();
}
return
map
;
}
public
Map
<
String
,
Object
>
getDetailsWindSpeed
(
String
gatewayId
,
String
equipmentNumber
)
{
Date
currentDayStartTime
=
DateUtils
.
getCurrentDayStartTime
(
new
Date
());
Date
currentDayEndTime
=
DateUtils
.
getCurrentDayEndTime
(
new
Date
());
Calendar
calendar
=
Calendar
.
getInstance
(
TimeZone
.
getTimeZone
(
"UTC"
));
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd'T'HH:mm:ss'Z'"
);
sdf
.
setTimeZone
(
TimeZone
.
getTimeZone
(
"UTC"
));
String
startTime
=
sdf
.
format
(
currentDayStartTime
);
String
endTime
=
sdf
.
format
(
currentDayEndTime
);
List
<
IndicatorData
>
indicatorDataListWindSpeed
=
new
ArrayList
<>();
List
<
IndicatorData
>
indicatorDataListActivePower
=
new
ArrayList
<>();
indicatorDataListWindSpeed
=
indicatorDataMapper
.
selectDataByequipmentIndexNameAndtimeAndEquipmentNumber
(
"瞬时风速"
,
equipmentNumber
,
startTime
,
endTime
,
gatewayId
);
indicatorDataListActivePower
=
indicatorDataMapper
.
selectDataByequipmentIndexNameAndtimeAndEquipmentNumber
(
"有功功率"
,
equipmentNumber
,
startTime
,
endTime
,
gatewayId
);
List
<
String
>
windSpeeds
=
new
ArrayList
<>();
List
<
String
>
activePowers
=
new
ArrayList
<>();
List
<
String
>
axisData
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
indicatorDataListWindSpeed
.
size
();
i
++)
{
windSpeeds
.
add
(
indicatorDataListWindSpeed
.
get
(
i
).
getValue
());
activePowers
.
add
(
indicatorDataListActivePower
.
get
(
i
).
getValue
());
axisData
.
add
(
cn
.
hutool
.
core
.
date
.
DateUtil
.
format
(
indicatorDataListWindSpeed
.
get
(
i
).
getCreatedTime
(),
"HH:mm"
));
}
List
<
Map
<
String
,
Object
>>
seriesData
=
new
ArrayList
<>();
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
Map
<
String
,
Object
>
map1
=
new
HashMap
<>();
Map
<
String
,
Object
>
map2
=
new
HashMap
<>();
map1
.
put
(
"data"
,
windSpeeds
);
map2
.
put
(
"data"
,
activePowers
);
seriesData
.
add
(
map1
);
seriesData
.
add
(
map2
);
map
.
put
(
"seriesData"
,
seriesData
);
map
.
put
(
"axisData"
,
axisData
);
return
map
;
}
public
List
<
String
>
yueReport
()
{
List
<
String
>
list
=
new
ArrayList
<>();
for
(
int
i
=
1
;
i
<
13
;
i
++)
{
list
.
add
(
String
.
valueOf
(
i
));
}
return
list
;
}
public
Double
getStationCaPACITYL
(
String
werks
)
{
Double
installCapacity
=
0.0
;
installCapacity
=
SjglZsjZsbtzServiceImpl
.
getStationCapactityByStationWerks
(
werks
);
return
ObjectUtils
.
isEmpty
(
installCapacity
)
?
0.00
:
installCapacity
;
}
public
List
<
String
>
dayReport
(
Date
month
)
{
List
<
String
>
list
=
new
ArrayList
<>();
Calendar
cal
=
Calendar
.
getInstance
();
cal
.
setTime
(
month
);
// month 为指定月份任意日期
int
year
=
cal
.
get
(
Calendar
.
YEAR
);
int
m
=
cal
.
get
(
Calendar
.
MONTH
)
+
1
;
int
dayNumOfMonth
=
DateUtil
.
getDaysByYearMonth
(
year
,
m
);
cal
.
set
(
Calendar
.
DAY_OF_MONTH
,
1
);
// 从一号开始
for
(
int
i
=
0
;
i
<
dayNumOfMonth
;
i
++)
{
list
.
add
(
String
.
valueOf
(
i
+
1
));
}
return
list
;
}
public
List
<
String
>
dayReportnq
(
Date
month
)
{
List
<
String
>
list
=
new
ArrayList
<>();
Calendar
cal
=
Calendar
.
getInstance
();
cal
.
setTime
(
month
);
// month 为指定月份任意日期
int
year
=
cal
.
get
(
Calendar
.
YEAR
);
int
m
=
cal
.
get
(
Calendar
.
MONTH
)
+
1
;
int
dayNumOfMonth
=
DateUtil
.
getDaysByYearMonth
(
year
,
m
);
cal
.
set
(
Calendar
.
DAY_OF_MONTH
,
1
);
// 从一号开始
for
(
int
i
=
0
;
i
<
dayNumOfMonth
;
i
++)
{
list
.
add
(
m
+
"-"
+
String
.
valueOf
(
i
+
1
));
}
try
{
emqKeeper
.
getMqttClient
().
publish
(
"topic"
,
JSON
.
toJSONString
(
list
).
getBytes
(),
0
,
false
);
}
catch
(
MqttException
e
)
{
e
.
printStackTrace
();
}
return
list
;
}
}
\ No newline at end of file
amos-boot-system-jxiop/amos-boot-module-jxiop-bigscreen-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/service/impl/MonitoringServiceImpl.java
View file @
323ff25b
...
...
@@ -3,11 +3,14 @@ package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import
cn.hutool.core.date.DatePattern
;
import
cn.hutool.core.date.DateUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
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.*
;
import
com.yeejoin.amos.boot.module.jxiop.api.mapper.*
;
import
com.yeejoin.amos.boot.module.jxiop.api.util.Constants
;
import
com.yeejoin.amos.boot.module.jxiop.api.util.HttpRequestUtil
;
import
com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESEquipments
;
import
com.yeejoin.amos.boot.module.jxiop.biz.constants.CommonConstans
;
import
com.yeejoin.amos.boot.module.jxiop.biz.dto.*
;
...
...
@@ -26,6 +29,8 @@ import org.typroject.tyboot.component.emq.EmqKeeper;
import
com.yeejoin.amos.boot.biz.common.utils.DateUtils
;
import
java.math.BigDecimal
;
import
java.text.SimpleDateFormat
;
import
java.time.LocalDate
;
import
java.time.format.DateTimeFormatter
;
import
java.util.*
;
import
java.util.concurrent.atomic.AtomicReference
;
import
java.util.stream.Collectors
;
...
...
@@ -75,6 +80,9 @@ public class MonitoringServiceImpl {
// @Autowired
// InfluxdbUtil influxdbUtil;
@Autowired
private
HttpRequestUtil
httpRequestUtil
;
/**
* 根据场站编号获取该场站的装机容量
*
...
...
@@ -1054,27 +1062,23 @@ public class MonitoringServiceImpl {
stringHashMap9
.
put
(
"title"
,
String
.
format
(
CommonConstans
.
Fourdecimalplaces
,
powerOfDayFD
.
get
()
+
powerOfDayGF
.
get
()));
HashMap
<
String
,
String
>
resultMap
=
new
HashMap
<>();
resultMap
.
put
(
"Day"
,
String
.
format
(
CommonConstans
.
Fourdecimalplaces
,
powerOfDayFD
.
get
()
+
powerOfDayGF
.
get
()));
//
resultMap.put("Day", String.format(CommonConstans.Fourdecimalplaces, powerOfDayFD.get() + powerOfDayGF.get()));
list2
.
add
(
stringHashMap9
);
HashMap
<
String
,
String
>
stringHashMap10
=
new
HashMap
<>();
stringHashMap10
.
put
(
"title"
,
String
.
format
(
CommonConstans
.
Twodecimalplaces
,
powerOfMonthFD
.
get
()
+
powerOfMonthGF
.
get
()));
resultMap
.
put
(
"Moon"
,
String
.
format
(
CommonConstans
.
Fourdecimalplaces
,
powerOfMonthFD
.
get
()
+
powerOfMonthGF
.
get
()));
resultMap
.
put
(
"YJHWC"
,
String
.
format
(
CommonConstans
.
Twodecimalplaces
,
(
powerOfMonthFD
.
get
()
+
powerOfMonthGF
.
get
())
/
moonValue
*
100
));
//resultMap.put("Moon",String.format(CommonConstans.Fourdecimalplaces, powerOfMonthFD.get() + powerOfMonthGF.get()));
//resultMap.put("YJHWC", String.format(CommonConstans.Twodecimalplaces,(powerOfMonthFD.get() + powerOfMonthGF.get()) / moonValue * 100));
list2
.
add
(
stringHashMap10
);
HashMap
<
String
,
String
>
stringHashMap11
=
new
HashMap
<>();
stringHashMap11
.
put
(
"title"
,
String
.
format
(
CommonConstans
.
Fourdecimalplaces
,
powerOfAnnualFD
.
get
()
+
powerOfAnnualGF
.
get
()));
resultMap
.
put
(
"Year"
,
String
.
format
(
CommonConstans
.
Fourdecimalplaces
,
powerOfAnnualFD
.
get
()
+
powerOfAnnualGF
.
get
()));
//resultMap.put("Year",String.format(CommonConstans.Fourdecimalplaces, powerOfAnnualFD.get() + powerOfAnnualGF.get()));
list2
.
add
(
stringHashMap11
);
HashMap
<
String
,
String
>
stringHashMap12
=
new
HashMap
<>();
stringHashMap12
.
put
(
"title"
,
String
.
format
(
CommonConstans
.
Twodecimalplaces
,
(
powerOfAnnualFD
.
get
()
+
powerOfAnnualGF
.
get
())
/
yearValue
*
100
));
resultMap
.
put
(
"NJHWC"
,
String
.
format
(
CommonConstans
.
Twodecimalplaces
,
(
powerOfAnnualFD
.
get
()
+
powerOfAnnualGF
.
get
())
/
yearValue
*
100
));
//resultMap.put("NJHWC", String.format(CommonConstans.Twodecimalplaces,(powerOfAnnualFD.get() + powerOfAnnualGF.get()) / yearValue * 100));
list2
.
add
(
stringHashMap12
);
page2
.
setRecords
(
list2
);
Double
totalAnnual
=
(
powerOfAnnualFD
.
get
()
+
powerOfAnnualGF
.
get
());
...
...
@@ -1099,6 +1103,20 @@ public class MonitoringServiceImpl {
stringHashMap16
.
put
(
"unit"
,
"二氧化硫减排量(t)"
);
list3
.
add
(
stringHashMap16
);
page3
.
setRecords
(
list3
);
//改为部盾接口
String
requestUrl
=
Constants
.
BASE_URL
+
"?"
+
Constants
.
get_quota_info
;
LocalDate
currentDate
=
LocalDate
.
now
();
DateTimeFormatter
formatter
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd"
);
String
formattedDate
=
currentDate
.
format
(
formatter
);
JSONObject
data
=
httpRequestUtil
.
getResPonse
(
requestUrl
+
"&reporting_data="
+
formattedDate
,
Constants
.
REQUEST_GET
,
""
,
Constants
.
resovleRule_data
);
resultMap
.
put
(
"Day"
,
data
.
getString
(
"day_generating_capacity"
));
resultMap
.
put
(
"Moon"
,
data
.
getString
(
"month_generating_capacity"
));
resultMap
.
put
(
"Year"
,
data
.
getString
(
"year_generating_capacity"
));
resultMap
.
put
(
"YJHWC"
,
data
.
getString
(
"year_quota_rate"
).
replace
(
"%"
,
""
));
resultMap
.
put
(
"NJHWC"
,
data
.
getString
(
"month_quota_rate"
).
replace
(
"%"
,
""
));
try
{
emqKeeper
.
getMqttClient
().
publish
(
"bigscreen_zjrl_topic"
,
JSON
.
toJSON
(
page
).
toString
().
getBytes
(
"UTF-8"
),
1
,
true
);
...
...
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