Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
项目统一框架
amos-boot-biz
Commits
b2360eb6
Commit
b2360eb6
authored
Apr 08, 2024
by
caotao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.大屏监盘全国运行指标数据接口数据源重新调整。
2.大屏监盘区域运行指标数据接口数据源重新调整。
parent
b188f137
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
155 additions
and
7 deletions
+155
-7
CommonConstans.java
.../amos/boot/module/jxiop/biz/constants/CommonConstans.java
+1
-0
MonitorServiceImpl.java
...oot/module/jxiop/biz/service/impl/MonitorServiceImpl.java
+153
-6
MonitoringServiceImpl.java
.../module/jxiop/biz/service/impl/MonitoringServiceImpl.java
+1
-1
No files found.
amos-boot-system-jxiop/amos-boot-module-jxiop-bigscreen-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/constants/CommonConstans.java
View file @
b2360eb6
...
@@ -132,6 +132,7 @@ public class CommonConstans {
...
@@ -132,6 +132,7 @@ public class CommonConstans {
public
static
final
String
YEAR_GEN_HOURS
=
"年利用小时数"
;
public
static
final
String
YEAR_GEN_HOURS
=
"年利用小时数"
;
public
static
final
String
WIND_SPEED_THIRTY_SECONDS
=
"30秒平均风速"
;
public
static
final
String
WIND_SPEED_THIRTY_SECONDS
=
"30秒平均风速"
;
public
static
final
String
TOTAL_RADIATION
=
"辐照度"
;
public
static
final
String
TOTAL_RADIATION
=
"辐照度"
;
public
static
final
String
TOTAL_RADIATION_SUM
=
"累计辐照度"
;
public
static
final
String
ACTIVE_POWER
=
"有功功率"
;
public
static
final
String
ACTIVE_POWER
=
"有功功率"
;
...
...
amos-boot-system-jxiop/amos-boot-module-jxiop-bigscreen-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/service/impl/MonitorServiceImpl.java
View file @
b2360eb6
package
com
.
yeejoin
.
amos
.
boot
.
module
.
jxiop
.
biz
.
service
.
impl
;
package
com
.
yeejoin
.
amos
.
boot
.
module
.
jxiop
.
biz
.
service
.
impl
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
...
@@ -10,6 +9,7 @@ import com.yeejoin.amos.boot.module.jxiop.api.dto.*;
...
@@ -10,6 +9,7 @@ import com.yeejoin.amos.boot.module.jxiop.api.dto.*;
import
com.yeejoin.amos.boot.module.jxiop.api.entity.MapRegion
;
import
com.yeejoin.amos.boot.module.jxiop.api.entity.MapRegion
;
import
com.yeejoin.amos.boot.module.jxiop.api.entity.Region
;
import
com.yeejoin.amos.boot.module.jxiop.api.entity.Region
;
import
com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic
;
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.MapRegionMapper
;
import
com.yeejoin.amos.boot.module.jxiop.api.mapper.MapRegionMapper
;
import
com.yeejoin.amos.boot.module.jxiop.api.mapper.RegionMapper
;
import
com.yeejoin.amos.boot.module.jxiop.api.mapper.RegionMapper
;
import
com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper
;
import
com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper
;
...
@@ -17,16 +17,25 @@ import com.yeejoin.amos.boot.module.jxiop.api.util.Constants;
...
@@ -17,16 +17,25 @@ 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.api.util.HttpRequestUtil
;
import
com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESEquipments
;
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.constants.CommonConstans
;
import
com.yeejoin.amos.boot.module.jxiop.biz.dto.CoreValuesDto
;
import
com.yeejoin.amos.boot.module.jxiop.biz.dto.SeriesData
;
import
com.yeejoin.amos.boot.module.jxiop.biz.dto.SeriesData
;
import
com.yeejoin.amos.boot.module.jxiop.biz.dto.StationCacheInfoDto
;
import
com.yeejoin.amos.boot.module.jxiop.biz.dto.StationCacheInfoDto
;
import
com.yeejoin.amos.boot.module.jxiop.biz.service.CoreCommonService
;
import
com.yeejoin.amos.boot.module.jxiop.biz.service.MonitorService
;
import
com.yeejoin.amos.boot.module.jxiop.biz.service.MonitorService
;
import
lombok.RequiredArgsConstructor
;
import
lombok.RequiredArgsConstructor
;
import
org.eclipse.paho.client.mqttv3.MqttException
;
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.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
import
org.typroject.tyboot.component.emq.EmqKeeper
;
import
org.typroject.tyboot.component.emq.EmqKeeper
;
import
org.typroject.tyboot.core.restful.utils.ResponseHelper
;
import
java.math.BigDecimal
;
import
java.text.DecimalFormat
;
import
java.time.LocalDate
;
import
java.time.LocalDate
;
import
java.util.*
;
import
java.util.*
;
import
java.util.concurrent.atomic.AtomicReference
;
import
java.util.concurrent.atomic.AtomicReference
;
...
@@ -40,6 +49,7 @@ public class MonitorServiceImpl implements MonitorService {
...
@@ -40,6 +49,7 @@ public class MonitorServiceImpl implements MonitorService {
private
final
StationBasicMapper
stationBasicMapper
;
private
final
StationBasicMapper
stationBasicMapper
;
private
final
EmqKeeper
emqKeeper
;
private
final
EmqKeeper
emqKeeper
;
private
final
HttpRequestUtil
httpRequestUtil
;
private
final
HttpRequestUtil
httpRequestUtil
;
private
final
CoreCommonService
coreCommonService
;
@Override
@Override
public
IPage
<
Map
<
String
,
Object
>>
operationData
(
String
areaCode
)
{
public
IPage
<
Map
<
String
,
Object
>>
operationData
(
String
areaCode
)
{
...
@@ -361,17 +371,17 @@ public class MonitorServiceImpl implements MonitorService {
...
@@ -361,17 +371,17 @@ public class MonitorServiceImpl implements MonitorService {
}
}
List
<
Map
<
String
,
Object
>>
dayDataFan
=
new
ArrayList
<>();
List
<
Map
<
String
,
Object
>>
dayDataFan
=
new
ArrayList
<>();
List
<
Map
<
String
,
Object
>>
dayDataPV
=
new
ArrayList
<>();
List
<
Map
<
String
,
Object
>>
dayDataPV
=
new
ArrayList
<>();
fanList
.
stream
().
forEach
(
fan
->{
fanList
.
stream
().
forEach
(
fan
->
{
Map
<
String
,
Object
>
dayMap
=
new
HashMap
<>();
Map
<
String
,
Object
>
dayMap
=
new
HashMap
<>();
dayMap
.
put
(
"name"
,
fan
.
getStation_name
());
dayMap
.
put
(
"name"
,
fan
.
getStation_name
());
dayMap
.
put
(
"value"
,
fan
.
getGenValue
());
dayMap
.
put
(
"value"
,
fan
.
getGenValue
());
dayDataFan
.
add
(
dayMap
);
dayDataFan
.
add
(
dayMap
);
});
});
pvList
.
stream
().
forEach
(
pv
->{
pvList
.
stream
().
forEach
(
pv
->
{
Map
<
String
,
Object
>
dayMap
=
new
HashMap
<>();
Map
<
String
,
Object
>
dayMap
=
new
HashMap
<>();
dayMap
.
put
(
"name"
,
pv
.
getStation_name
());
dayMap
.
put
(
"name"
,
pv
.
getStation_name
());
dayMap
.
put
(
"value"
,
pv
.
getGenValue
());
dayMap
.
put
(
"value"
,
pv
.
getGenValue
());
dayDataPV
.
add
(
dayMap
);
dayDataPV
.
add
(
dayMap
);
});
});
Page
<
Map
<
String
,
Object
>>
socialContributionDtoPage
=
new
Page
<
Map
<
String
,
Object
>>();
Page
<
Map
<
String
,
Object
>>
socialContributionDtoPage
=
new
Page
<
Map
<
String
,
Object
>>();
...
@@ -385,4 +395,141 @@ public class MonitorServiceImpl implements MonitorService {
...
@@ -385,4 +395,141 @@ public class MonitorServiceImpl implements MonitorService {
}
}
return
socialContributionDtoPage
;
return
socialContributionDtoPage
;
}
}
/**
* 获取qg数据并将其发布到MQTT服务器
* <p>
* 该方法无需参数,主要执行以下操作:
* 1. 初始化一个包含特定键值对的map,用于存储数据;
* 2. 通过调用coreCommonService获取一些核心数值;
* 3. 从特定URL获取资源,并解析响应数据;
* 4. 更新map中的数据;
* 5. 将map数据转换为JSON字符串,通过MQTT客户端发布到指定的主题。
*
* @return 返回一个包含各种指标数据的map,其中键为指标名称,值为指标数值。
*/
public
Map
<
String
,
Double
>
getqg
()
{
// 初始化存储数据的map,设置默认值为0
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
<
CoreValuesDto
>
coreValuesDtos
=
new
ArrayList
<>();
coreValuesDtos
=
coreCommonService
.
getValuesByStationNamesAndPointsNames
(
null
,
null
);
// 构建请求URL并发起HTTP GET请求,获取相关数据
String
requestUrl
=
Constants
.
BASE_URL
+
"?"
+
Constants
.
get_area_item_url
;
List
<
BuDunGenDto
>
buDunGenDtos
=
httpRequestUtil
.
getResPonse
(
requestUrl
,
Constants
.
REQUEST_GET
,
""
,
Constants
.
resovleRule_data
,
BuDunGenDto
.
class
);
// 如果有获取到数据,则更新map中的相应数据
if
(
buDunGenDtos
.
size
()
>
0
)
{
BuDunGenDto
buDunGenDto
=
buDunGenDtos
.
get
(
0
);
mapdta
.
put
(
"RSD"
,
keepFourdecimalPlaces
(
buDunGenDto
.
getDay
()));
mapdta
.
put
(
"YFD"
,
keepFourdecimalPlaces
(
buDunGenDto
.
getMonth
()));
mapdta
.
put
(
"NFD"
,
keepFourdecimalPlaces
(
buDunGenDto
.
getYear
()));
mapdta
.
put
(
"YJHWC"
,
keepTwodecimalPlaces
(
buDunGenDto
.
getMonth_complete
()));
mapdta
.
put
(
"NJHWC"
,
keepTwodecimalPlaces
(
buDunGenDto
.
getYear_complete
()));
}
// 更新map中剩余的数据项
mapdta
.
put
(
"SS"
,
keepTwodecimalPlaces
(
coreCommonService
.
getAverageOfByPointName
(
coreValuesDtos
,
CommonConstans
.
WIND_SPEED_THIRTY_SECONDS
)));
mapdta
.
put
(
"ZFS"
,
keepTwodecimalPlaces
(
coreCommonService
.
getAverageOfByPointName
(
coreValuesDtos
,
CommonConstans
.
TOTAL_RADIATION
)));
mapdta
.
put
(
"ZFSLJ"
,
keepTwodecimalPlaces
(
coreCommonService
.
getAverageOfByPointName
(
coreValuesDtos
,
CommonConstans
.
TOTAL_RADIATION_SUM
)));
// 将数据发布到MQTT主题
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
<
CoreValuesDto
>
coreValuesDtos
=
coreCommonService
.
getValuesByStationNamesAndPointsNames
(
null
,
null
);
List
<
StationCacheInfoDto
>
stationCacheInfoDtoList
=
getListStationCacheInfoDto
();
List
<
MapRegion
>
mapRegionList
=
mapRegionMapper
.
selectList
(
new
QueryWrapper
<
MapRegion
>().
isNotNull
(
"name"
));
mapRegionList
.
forEach
(
mapRegion
->{
if
(!
ObjectUtils
.
isEmpty
(
mapRegion
.
getName
()))
{
List
<
StationCacheInfoDto
>
stationCacheInfoDtoListTemp
=
stationCacheInfoDtoList
.
stream
().
filter
(
stationCacheInfoDto
->
stationCacheInfoDto
.
getAreaCode
().
equals
(
mapRegion
.
getAreaCode
())
&&
stationCacheInfoDto
.
getStationCoreName
()
!=
null
&&
stationCacheInfoDto
.
getBoosterCoreName
()
!=
null
).
collect
(
Collectors
.
toList
());
List
<
String
>
stationNames
=
new
ArrayList
<>();
stationNames
.
addAll
(
stationCacheInfoDtoList
.
stream
().
map
(
StationCacheInfoDto:
:
getStationCoreName
).
collect
(
Collectors
.
toList
()));
stationNames
.
addAll
(
stationCacheInfoDtoList
.
stream
().
map
(
StationCacheInfoDto:
:
getBoosterCoreName
).
collect
(
Collectors
.
toList
()));
List
<
CoreValuesDto
>
coreValuesDtosTemp
=
coreValuesDtos
.
stream
().
filter
(
coreValuesDto
->
stationNames
.
contains
(
coreValuesDto
.
getName
())).
collect
(
Collectors
.
toList
());
getqy
(
mapRegion
,
coreValuesDtosTemp
);
}
});
}
/**
* 区域
**/
public
Map
<
String
,
Double
>
getqy
(
MapRegion
mapRegion
,
List
<
CoreValuesDto
>
coreValuesDtos
)
{
String
areaCode
=
!
mapRegion
.
getName
().
contains
(
Constants
.
areaChinese
)
?
mapRegion
.
getName
()
+
Constants
.
areaChinese
:
mapRegion
.
getName
();
// 初始化存储数据的map,设置默认值为0
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
);
// 构建请求URL并发起HTTP GET请求,获取相关数据
String
requestUrl
=
Constants
.
BASE_URL
+
"?"
+
Constants
.
get_area_item_url
;
List
<
BuDunGenDto
>
buDunGenDtos
=
httpRequestUtil
.
getResPonse
(
requestUrl
,
Constants
.
REQUEST_GET
,
""
,
Constants
.
resovleRule_data
,
BuDunGenDto
.
class
);
// 如果有获取到数据,则更新map中的相应数据
if
(
buDunGenDtos
.
size
()
>
0
)
{
BuDunGenDto
buDunGenDto
=
buDunGenDtos
.
get
(
0
);
mapdta
.
put
(
"RSD"
,
keepFourdecimalPlaces
(
buDunGenDto
.
getDay
()));
mapdta
.
put
(
"YFD"
,
keepFourdecimalPlaces
(
buDunGenDto
.
getMonth
()));
mapdta
.
put
(
"NFD"
,
keepFourdecimalPlaces
(
buDunGenDto
.
getYear
()));
mapdta
.
put
(
"YJHWC"
,
keepTwodecimalPlaces
(
buDunGenDto
.
getMonth_complete
()));
mapdta
.
put
(
"NJHWC"
,
keepTwodecimalPlaces
(
buDunGenDto
.
getYear_complete
()));
}
// 更新map中剩余的数据项
mapdta
.
put
(
"SS"
,
keepTwodecimalPlaces
(
coreCommonService
.
getAverageOfByPointName
(
coreValuesDtos
,
CommonConstans
.
WIND_SPEED_THIRTY_SECONDS
)));
mapdta
.
put
(
"ZFS"
,
keepTwodecimalPlaces
(
coreCommonService
.
getAverageOfByPointName
(
coreValuesDtos
,
CommonConstans
.
TOTAL_RADIATION
)));
mapdta
.
put
(
"ZFSLJ"
,
keepTwodecimalPlaces
(
coreCommonService
.
getAverageOfByPointName
(
coreValuesDtos
,
CommonConstans
.
TOTAL_RADIATION_SUM
)));
try
{
System
.
out
.
println
(
JSON
.
toJSONString
(
mapdta
));
emqKeeper
.
getMqttClient
().
publish
(
"qyyxzb/"
+
mapRegion
.
getAreaCode
(),
JSON
.
toJSONString
(
mapdta
).
getBytes
(),
1
,
true
);
}
catch
(
MqttException
e
)
{
e
.
printStackTrace
();
}
return
mapdta
;
}
/**
* 保留四位小数的函数
*
* @param param 输入的双精度浮点数
* @return 经过四舍五入保留四位小数的双精度浮点数
*/
public
Double
keepFourdecimalPlaces
(
Double
param
)
{
// 使用String.format方法格式化浮点数,保留四位小数
return
Double
.
valueOf
(
String
.
format
(
"%.4f"
,
param
));
}
/**
* 保留两位小数的函数
*
* @param param 输入的双精度浮点数
* @return 经过四舍五入保留两位小数的双精度浮点数
*/
public
Double
keepTwodecimalPlaces
(
Double
param
)
{
// 使用String.format方法格式化浮点数,保留两位小数
return
Double
.
valueOf
(
String
.
format
(
"%.2f"
,
param
));
}
}
}
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 @
b2360eb6
...
@@ -117,7 +117,7 @@ public class MonitoringServiceImpl {
...
@@ -117,7 +117,7 @@ public class MonitoringServiceImpl {
map
.
put
(
"value"
,
value
+
"m/s"
);
map
.
put
(
"value"
,
value
+
"m/s"
);
}
else
{
}
else
{
value
=
String
.
format
(
"%.2f"
,
value
=
String
.
format
(
"%.2f"
,
coreCommonService
.
getAverageOfByPointName
(
coreValuesDtoList
,
"WTX-801_25_WTX-801_总辐射"
));
coreCommonService
.
getAverageOfByPointName
(
coreValuesDtoList
,
CommonConstans
.
TOTAL_RADIATION
));
map
.
put
(
"name"
,
"风速/辐照度"
);
map
.
put
(
"name"
,
"风速/辐照度"
);
map
.
put
(
"value"
,
value
+
"W/㎡"
);
map
.
put
(
"value"
,
value
+
"W/㎡"
);
}
}
...
...
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