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
4f8cd398
Commit
4f8cd398
authored
Nov 03, 2023
by
chenzhao
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'developer' of
http://39.98.45.134:8090/moa/amos-boot-biz
into developer
parents
deaee427
db2eabb5
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
722 additions
and
132 deletions
+722
-132
TestController.java
...amos/boot/module/jxiop/biz/controller/TestController.java
+6
-5
CommonServiceImpl.java
...boot/module/jxiop/biz/service/impl/CommonServiceImpl.java
+168
-99
TdengineTimeServiceImpl.java
...odule/jxiop/biz/service/impl/TdengineTimeServiceImpl.java
+251
-28
FanHealthIndexMapper.java
...boot/module/jxiop/biz/tdMapper2/FanHealthIndexMapper.java
+37
-0
PvHealthIndexMapper.java
.../boot/module/jxiop/biz/tdMapper2/PvHealthIndexMapper.java
+20
-0
FanHealthIndex.xml
...iz/src/main/resources/mapper/tdengine2/FanHealthIndex.xml
+120
-0
PvHealthIndex.xml
...biz/src/main/resources/mapper/tdengine2/PvHealthIndex.xml
+120
-0
No files found.
amos-boot-system-jxiop/amos-boot-module-jxiop-analyse-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/controller/TestController.java
View file @
4f8cd398
...
@@ -13,11 +13,13 @@ import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndex;
...
@@ -13,11 +13,13 @@ import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndex;
import
com.yeejoin.amos.boot.module.jxiop.biz.tdmapper.IndicatorDataMapper
;
import
com.yeejoin.amos.boot.module.jxiop.biz.tdmapper.IndicatorDataMapper
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.ibatis.annotations.Param
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
org.typroject.tyboot.core.foundation.enumeration.UserType
;
import
org.typroject.tyboot.core.foundation.enumeration.UserType
;
import
org.typroject.tyboot.core.restful.doc.TycloudOperation
;
import
org.typroject.tyboot.core.restful.doc.TycloudOperation
;
import
java.text.ParseException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
...
@@ -46,11 +48,11 @@ public class TestController extends BaseController {
...
@@ -46,11 +48,11 @@ public class TestController extends BaseController {
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"test2"
,
notes
=
"test1"
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"test2"
,
notes
=
"test1"
)
@GetMapping
(
"/test2"
)
@GetMapping
(
"/test2"
)
public
void
test2
()
{
public
void
test2
(
@RequestParam
(
value
=
"startTime"
)
String
startTime
,
@Param
(
"recDate"
)
String
recDate
)
{
// List<FanHealthIndex> infoListByGroupByCD = fanHealthIndexMapper.getInfoListByGroupByCdFan(startTime, recDate);
// commonService.healthWarningMinuteByFJ();
// commonService.healthWarningMinuteByFJ();
commonService
.
healthWarningMinuteByPv
();
//
commonService.healthWarningMinuteByPv();
// return infoListByGroupByCD;
}
}
@Autowired
@Autowired
...
@@ -64,7 +66,6 @@ public class TestController extends BaseController {
...
@@ -64,7 +66,6 @@ public class TestController extends BaseController {
@PostMapping
(
"/saveTest"
)
@PostMapping
(
"/saveTest"
)
public
void
saveTest
()
{
public
void
saveTest
()
{
tdengineTimeService
.
insertHourData
();
// QueryWrapper<FanHealthIndex> fanHealthIndexQueryWrapper = new QueryWrapper<>();
// QueryWrapper<FanHealthIndex> fanHealthIndexQueryWrapper = new QueryWrapper<>();
// List<FanHealthIndex> fanHealthIndices = fanHealthIndexMapper.selectList(fanHealthIndexQueryWrapper);
// List<FanHealthIndex> fanHealthIndices = fanHealthIndexMapper.selectList(fanHealthIndexQueryWrapper);
//
//
...
...
amos-boot-system-jxiop/amos-boot-module-jxiop-analyse-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/service/impl/CommonServiceImpl.java
View file @
4f8cd398
...
@@ -152,6 +152,10 @@ public class CommonServiceImpl {
...
@@ -152,6 +152,10 @@ public class CommonServiceImpl {
@Autowired
@Autowired
private
PvHealthIndexMapper
pvHealthIndexMapper
;
private
PvHealthIndexMapper
pvHealthIndexMapper
;
@Autowired
private
TdengineTimeServiceImpl
tdengineTimeService
;
/**
/**
* @return
* @return
* @deprecated 获取工况变量列表风机
* @deprecated 获取工况变量列表风机
...
@@ -1282,9 +1286,7 @@ public class CommonServiceImpl {
...
@@ -1282,9 +1286,7 @@ public class CommonServiceImpl {
queryBuilder
.
should
(
QueryBuilders
.
wildcardQuery
(
key
,
shouldQuerCondtion
.
get
(
key
)));
queryBuilder
.
should
(
QueryBuilders
.
wildcardQuery
(
key
,
shouldQuerCondtion
.
get
(
key
)));
}
}
}
}
Query
query
=
new
NativeSearchQueryBuilder
()
Query
query
=
new
NativeSearchQueryBuilder
().
withQuery
(
queryBuilder
).
build
();
.
withQuery
(
queryBuilder
)
.
build
();
query
.
setTrackTotalHits
(
true
);
query
.
setTrackTotalHits
(
true
);
SearchHits
search
=
elasticsearchTemplate
.
search
(
query
,
tClass
);
SearchHits
search
=
elasticsearchTemplate
.
search
(
query
,
tClass
);
if
(
search
.
hasSearchHits
())
{
if
(
search
.
hasSearchHits
())
{
...
@@ -1448,8 +1450,8 @@ public class CommonServiceImpl {
...
@@ -1448,8 +1450,8 @@ public class CommonServiceImpl {
}
}
// @Scheduled(cron = "0 0/10 * * * ?")
// @Scheduled(cron = "0 0/10 * * * ?")
@Async
(
"async"
)
//
@Async("async")
public
void
healthWarningMinuteByFan
()
{
public
void
healthWarningMinuteByFan
()
{
if
(!
openHealth
)
{
if
(!
openHealth
)
{
...
@@ -1457,7 +1459,7 @@ public class CommonServiceImpl {
...
@@ -1457,7 +1459,7 @@ public class CommonServiceImpl {
}
}
String
format
=
DateUtil
.
format
(
new
Date
(),
"yyyy-MM-dd HH:mm:00"
);
String
format
=
DateUtil
.
format
(
new
Date
(),
"yyyy-MM-dd HH:mm:00"
);
Date
time
=
DateUtil
.
parse
(
format
,
"yyyy-MM-dd HH:mm:00"
);
Date
time
=
DateUtil
.
parse
(
format
,
"yyyy-MM-dd HH:mm:00"
);
logger
.
info
(
"风机---------------------健康指数时间----"
+
time
);
logger
.
info
(
"风机---------------------健康指数时间----"
+
time
);
Calendar
calendar
=
Calendar
.
getInstance
();
Calendar
calendar
=
Calendar
.
getInstance
();
List
<
IdxBizFanPointProcessVariableClassificationDto
>
data
=
idxBizFanPointProcessVariableClassificationMapper
.
getInfluxDBData
();
List
<
IdxBizFanPointProcessVariableClassificationDto
>
data
=
idxBizFanPointProcessVariableClassificationMapper
.
getInfluxDBData
();
Map
<
String
,
List
<
IdxBizFanPointProcessVariableClassificationDto
>>
maps
=
data
.
stream
().
collect
(
Collectors
.
groupingBy
(
IdxBizFanPointProcessVariableClassificationDto:
:
getGatewayId
));
Map
<
String
,
List
<
IdxBizFanPointProcessVariableClassificationDto
>>
maps
=
data
.
stream
().
collect
(
Collectors
.
groupingBy
(
IdxBizFanPointProcessVariableClassificationDto:
:
getGatewayId
));
...
@@ -1508,11 +1510,16 @@ public class CommonServiceImpl {
...
@@ -1508,11 +1510,16 @@ public class CommonServiceImpl {
// // TODO: handle exception
// // TODO: handle exception
// }
// }
// }
// }
Map
<
String
,
Float
>
indicatorDataListAllMap
=
indicatorDataListAll
.
stream
().
collect
(
Collectors
.
toMap
(
indicatorData
->
indicatorData
.
getAddress
()
+
"_"
+
indicatorData
.
getGatewayId
(),
IndicatorData:
:
getValueF
));
Map
<
String
,
Float
>
indicatorDataListAllMap
=
indicatorDataListAll
.
stream
().
collect
(
Collectors
.
toMap
(
indicatorData
->
indicatorData
.
getAddress
()
+
"_"
+
indicatorData
.
getGatewayId
(),
IndicatorData:
:
getValueF
));
//将测点id与值处理成map
HashMap
<
String
,
Double
>
idxBizFanPointProcessVariableClassificationDtoIdValueMap
=
new
HashMap
<>();
for
(
IdxBizFanPointProcessVariableClassificationDto
datum
:
data
)
{
for
(
IdxBizFanPointProcessVariableClassificationDto
datum
:
data
)
{
Double
currentValue
=
Double
.
valueOf
(
indicatorDataListAllMap
.
get
(
datum
.
getIndexAddress
()
+
"_"
+
datum
.
getGatewayId
()));
Double
currentValue
=
Double
.
valueOf
(
indicatorDataListAllMap
.
get
(
datum
.
getIndexAddress
()
+
"_"
+
datum
.
getGatewayId
()));
if
(!
ObjectUtils
.
isEmpty
(
currentValue
))
{
if
(!
ObjectUtils
.
isEmpty
(
currentValue
))
{
datum
.
setCurrentValue
(
currentValue
);
datum
.
setCurrentValue
(
currentValue
);
idxBizFanPointProcessVariableClassificationDtoIdValueMap
.
put
(
datum
.
getSequenceNbr
(),
currentValue
);
}
else
{
idxBizFanPointProcessVariableClassificationDtoIdValueMap
.
put
(
datum
.
getSequenceNbr
(),
0.0
);
}
}
// for (ESEquipments equipment : equipments) {
// for (ESEquipments equipment : equipments) {
// if (equipment.getAddress().equals(datum.getIndexAddress()) && equipment.getGatewayId().equals(datum.getGatewayId())) {
// if (equipment.getAddress().equals(datum.getIndexAddress()) && equipment.getGatewayId().equals(datum.getGatewayId())) {
...
@@ -1541,31 +1548,53 @@ public class CommonServiceImpl {
...
@@ -1541,31 +1548,53 @@ public class CommonServiceImpl {
List
<
String
>
ProcessPoint2Id
=
new
ArrayList
<>();
List
<
String
>
ProcessPoint2Id
=
new
ArrayList
<>();
List
<
String
>
ProcessPoint3Id
=
new
ArrayList
<>();
List
<
String
>
ProcessPoint3Id
=
new
ArrayList
<>();
List
<
String
>
analysisVariableIds
=
new
ArrayList
<>();
List
<
String
>
analysisVariableIds
=
new
ArrayList
<>();
idxBizUhefs
.
forEach
(
idxBizFanPointVarCentralValue
->
{
if
(
ObjectUtils
.
isEmpty
(
idxBizFanPointVarCentralValue
.
getProcess1Min
()))
{
idxBizFanPointVarCentralValue
.
setProcess1Min
(
Double
.
NEGATIVE_INFINITY
);
}
if
(
ObjectUtils
.
isEmpty
(
idxBizFanPointVarCentralValue
.
getProcess2Min
()))
{
idxBizFanPointVarCentralValue
.
setProcess2Min
(
Double
.
NEGATIVE_INFINITY
);
}
if
(
ObjectUtils
.
isEmpty
(
idxBizFanPointVarCentralValue
.
getProcess3Min
()))
{
idxBizFanPointVarCentralValue
.
setProcess3Min
(
Double
.
NEGATIVE_INFINITY
);
}
if
(
ObjectUtils
.
isEmpty
(
idxBizFanPointVarCentralValue
.
getProcess1Max
()))
{
idxBizFanPointVarCentralValue
.
setProcess1Max
(
Double
.
POSITIVE_INFINITY
);
}
if
(
ObjectUtils
.
isEmpty
(
idxBizFanPointVarCentralValue
.
getPorcess2Max
()))
{
idxBizFanPointVarCentralValue
.
setPorcess2Max
(
Double
.
POSITIVE_INFINITY
);
}
if
(
ObjectUtils
.
isEmpty
(
idxBizFanPointVarCentralValue
.
getProcess3Max
()))
{
idxBizFanPointVarCentralValue
.
setProcess3Max
(
Double
.
POSITIVE_INFINITY
);
}
});
for
(
IdxBizFanPointVarCentralValue
idxBizUhef
:
idxBizUhefs
)
{
for
(
IdxBizFanPointVarCentralValue
idxBizUhef
:
idxBizUhefs
)
{
double
value1
=
0.00
;
double
value1
=
0.00
;
double
value2
=
0.00
;
double
value2
=
0.00
;
double
value3
=
0.00
;
double
value3
=
0.00
;
double
value4
=
0.00
;
double
value4
=
0.00
;
for
(
IdxBizFanPointProcessVariableClassificationDto
datum
:
data
)
{
// for (IdxBizFanPointProcessVariableClassificationDto datum : data) {
if
(
idxBizUhef
.
getProcessPoint1Id
().
equals
(
datum
.
getSequenceNbr
()))
{
// if (idxBizUhef.getProcessPoint1Id().equals(datum.getSequenceNbr())) {
value1
=
datum
.
getCurrentValue
()
==
null
?
0.0
:
datum
.
getCurrentValue
();
// value1 = datum.getCurrentValue() == null ? 0.0 : datum.getCurrentValue();
}
// }
if
(
idxBizUhef
.
getProcessPoint2Id
().
equals
(
datum
.
getSequenceNbr
()))
{
// if (idxBizUhef.getProcessPoint2Id().equals(datum.getSequenceNbr())) {
value2
=
datum
.
getCurrentValue
()
==
null
?
0.0
:
datum
.
getCurrentValue
();
// value2 = datum.getCurrentValue() == null ? 0.0 : datum.getCurrentValue();
}
// }
if
(
idxBizUhef
.
getProcessPoint3Id
().
equals
(
datum
.
getSequenceNbr
()))
{
// if (idxBizUhef.getProcessPoint3Id().equals(datum.getSequenceNbr())) {
value3
=
datum
.
getCurrentValue
()
==
null
?
0.0
:
datum
.
getCurrentValue
();
// value3 = datum.getCurrentValue() == null ? 0.0 : datum.getCurrentValue();
}
// }
if
(
idxBizUhef
.
getAnalysisPointId
().
equals
(
datum
.
getSequenceNbr
()))
{
// if (idxBizUhef.getAnalysisPointId().equals(datum.getSequenceNbr())) {
value4
=
datum
.
getCurrentValue
()
==
null
?
0.0
:
datum
.
getCurrentValue
();
// value4 = datum.getCurrentValue() == null ? 0.0 : datum.getCurrentValue();
}
// }
}
// }
value1
=
idxBizFanPointProcessVariableClassificationDtoIdValueMap
.
get
(
idxBizUhef
.
getProcessPoint1Id
());
value2
=
idxBizFanPointProcessVariableClassificationDtoIdValueMap
.
get
(
idxBizUhef
.
getProcessPoint2Id
());
if
((
null
==
idxBizUhef
.
getProcess1Min
()
||
idxBizUhef
.
getProcess1Min
()
<=
value1
)
&&
(
null
==
idxBizUhef
.
getProcess1Max
()
||
value1
<=
idxBizUhef
.
getProcess1Max
())
value3
=
idxBizFanPointProcessVariableClassificationDtoIdValueMap
.
get
(
idxBizUhef
.
getProcessPoint3Id
());
&&
(
null
==
idxBizUhef
.
getProcess2Min
()
||
idxBizUhef
.
getProcess2Min
()
<=
value2
)
&&
(
null
==
idxBizUhef
.
getPorcess2Max
()
||
value2
<=
idxBizUhef
.
getPorcess2Max
())
value4
=
idxBizFanPointProcessVariableClassificationDtoIdValueMap
.
get
(
idxBizUhef
.
getAnalysisPointId
());
&&
(
null
==
idxBizUhef
.
getProcess3Min
()
||
idxBizUhef
.
getProcess3Min
()
<=
value3
)
&&
(
null
==
idxBizUhef
.
getProcess3Max
()
||
value3
<=
idxBizUhef
.
getProcess3Max
()))
{
if
(
idxBizUhef
.
getProcess1Min
()
<=
value1
&&
value1
<=
idxBizUhef
.
getProcess1Max
()
&&
idxBizUhef
.
getProcess2Min
()
<=
value2
&&
value2
<=
idxBizUhef
.
getPorcess2Max
()
&&
idxBizUhef
.
getProcess3Min
()
<=
value3
&&
value3
<=
idxBizUhef
.
getProcess3Max
())
{
if
(!
analysisVariableIdList
.
contains
(
idxBizUhef
.
getAnalysisPointId
()))
{
if
(!
analysisVariableIdList
.
contains
(
idxBizUhef
.
getAnalysisPointId
()))
{
analysisVariableList
.
add
(
value4
);
analysisVariableList
.
add
(
value4
);
analysisVariable
.
add
(
value4
);
analysisVariable
.
add
(
value4
);
...
@@ -1597,16 +1626,7 @@ public class CommonServiceImpl {
...
@@ -1597,16 +1626,7 @@ public class CommonServiceImpl {
requestMap
.
put
(
"analysisVariableId"
,
analysisVariableIdList
);
requestMap
.
put
(
"analysisVariableId"
,
analysisVariableIdList
);
Table
healthData
=
Table
.
create
(
"healthData"
);
Table
healthData
=
Table
.
create
(
"healthData"
);
healthData
.
addColumns
(
DoubleColumn
.
create
(
"analysisVariable"
,
analysisVariable
),
healthData
.
addColumns
(
DoubleColumn
.
create
(
"analysisVariable"
,
analysisVariable
),
DoubleColumn
.
create
(
"stdDev"
,
stdDev
),
DoubleColumn
.
create
(
"centerValue"
,
centerValue
),
StringColumn
.
create
(
"ProcessPoint1Id"
,
ProcessPoint1Id
),
DoubleColumn
.
create
(
"ProcessPoint1"
,
ProcessPoint1
),
StringColumn
.
create
(
"ProcessPoint2Id"
,
ProcessPoint2Id
),
DoubleColumn
.
create
(
"ProcessPoint2"
,
ProcessPoint2
),
StringColumn
.
create
(
"ProcessPoint3Id"
,
ProcessPoint3Id
),
DoubleColumn
.
create
(
"ProcessPoint3"
,
ProcessPoint3
),
StringColumn
.
create
(
"analysisVariableId"
,
analysisVariableIds
));
DoubleColumn
.
create
(
"stdDev"
,
stdDev
),
DoubleColumn
.
create
(
"centerValue"
,
centerValue
),
StringColumn
.
create
(
"ProcessPoint1Id"
,
ProcessPoint1Id
),
DoubleColumn
.
create
(
"ProcessPoint1"
,
ProcessPoint1
),
StringColumn
.
create
(
"ProcessPoint2Id"
,
ProcessPoint2Id
),
DoubleColumn
.
create
(
"ProcessPoint2"
,
ProcessPoint2
),
StringColumn
.
create
(
"ProcessPoint3Id"
,
ProcessPoint3Id
),
DoubleColumn
.
create
(
"ProcessPoint3"
,
ProcessPoint3
),
StringColumn
.
create
(
"analysisVariableId"
,
analysisVariableIds
));
logger
.
info
(
"------------------------------------------开始调用健康指数计算算法开始----------------------------------------"
);
logger
.
info
(
"------------------------------------------开始调用健康指数计算算法开始----------------------------------------"
);
String
response
=
HttpUtil
.
createPost
(
baseUrlZSFX
).
body
(
JSON
.
toJSONString
(
requestMap
)).
execute
().
body
();
String
response
=
HttpUtil
.
createPost
(
baseUrlZSFX
).
body
(
JSON
.
toJSONString
(
requestMap
)).
execute
().
body
();
...
@@ -1620,8 +1640,7 @@ public class CommonServiceImpl {
...
@@ -1620,8 +1640,7 @@ public class CommonServiceImpl {
List
<
Double
>
scoreValue
=
JSONObject
.
parseArray
(
scoreValueArray
.
toJSONString
(),
Double
.
class
);
List
<
Double
>
scoreValue
=
JSONObject
.
parseArray
(
scoreValueArray
.
toJSONString
(),
Double
.
class
);
List
<
Double
>
indexValue
=
JSONObject
.
parseArray
(
indexValueArray
.
toJSONString
(),
Double
.
class
);
List
<
Double
>
indexValue
=
JSONObject
.
parseArray
(
indexValueArray
.
toJSONString
(),
Double
.
class
);
// Table resultTable = Table.create("healthData");
// Table resultTable = Table.create("healthData");
healthData
.
addColumns
(
StringColumn
.
create
(
"analysisVariableIdResult"
,
jsonArrayToStringList
),
healthData
.
addColumns
(
StringColumn
.
create
(
"analysisVariableIdResult"
,
jsonArrayToStringList
),
DoubleColumn
.
create
(
"indexValue"
,
indexValue
),
DoubleColumn
.
create
(
"scoreValue"
,
scoreValue
));
DoubleColumn
.
create
(
"indexValue"
,
indexValue
),
DoubleColumn
.
create
(
"scoreValue"
,
scoreValue
));
System
.
out
.
println
(
healthData
.
print
());
System
.
out
.
println
(
healthData
.
print
());
try
{
try
{
healthData
.
write
().
csv
(
new
Date
().
getTime
()
+
"fj.csv"
);
healthData
.
write
().
csv
(
new
Date
().
getTime
()
+
"fj.csv"
);
...
@@ -1634,7 +1653,6 @@ public class CommonServiceImpl {
...
@@ -1634,7 +1653,6 @@ public class CommonServiceImpl {
queryWrapper
.
in
(
IdxBizFanPointProcessVariableClassification:
:
getSequenceNbr
,
jsonArrayToStringList
);
queryWrapper
.
in
(
IdxBizFanPointProcessVariableClassification:
:
getSequenceNbr
,
jsonArrayToStringList
);
List
<
IdxBizFanPointProcessVariableClassification
>
list
=
idxBizFanPointProcessVariableClassificationMapper
.
selectList
(
queryWrapper
);
List
<
IdxBizFanPointProcessVariableClassification
>
list
=
idxBizFanPointProcessVariableClassificationMapper
.
selectList
(
queryWrapper
);
List
<
IdxBizFanHealthIndex
>
idxBizFanHealthIndexs
=
new
ArrayList
<>();
List
<
IdxBizFanHealthIndex
>
idxBizFanHealthIndexs
=
new
ArrayList
<>();
Set
<
String
>
stations
=
list
.
stream
().
map
(
IdxBizFanPointProcessVariableClassification:
:
getStation
).
collect
(
Collectors
.
toSet
());
Set
<
String
>
stations
=
list
.
stream
().
map
(
IdxBizFanPointProcessVariableClassification:
:
getStation
).
collect
(
Collectors
.
toSet
());
LambdaQueryWrapper
<
IdxBizFanHealthLevel
>
query
=
new
LambdaQueryWrapper
<>();
LambdaQueryWrapper
<
IdxBizFanHealthLevel
>
query
=
new
LambdaQueryWrapper
<>();
...
@@ -1655,8 +1673,7 @@ public class CommonServiceImpl {
...
@@ -1655,8 +1673,7 @@ public class CommonServiceImpl {
idxBizFanHealthIndex
.
setWeigth
(
1.0
);
idxBizFanHealthIndex
.
setWeigth
(
1.0
);
//获取健康指数对应等级
//获取健康指数对应等级
for
(
IdxBizFanHealthLevel
idxBizFanHealthLevel
:
idxBizFanHealthLevels
)
{
for
(
IdxBizFanHealthLevel
idxBizFanHealthLevel
:
idxBizFanHealthLevels
)
{
if
(
indexValueArray
.
getDoubleValue
(
i
)
<=
idxBizFanHealthLevel
.
getGroupUpperLimit
()
if
(
indexValueArray
.
getDoubleValue
(
i
)
<=
idxBizFanHealthLevel
.
getGroupUpperLimit
()
&&
indexValueArray
.
getDoubleValue
(
i
)
>=
idxBizFanHealthLevel
.
getGroupLowerLimit
())
{
&&
indexValueArray
.
getDoubleValue
(
i
)
>=
idxBizFanHealthLevel
.
getGroupLowerLimit
())
{
idxBizFanHealthIndex
.
setHealthLevel
(
idxBizFanHealthLevel
.
getHealthLevel
());
idxBizFanHealthIndex
.
setHealthLevel
(
idxBizFanHealthLevel
.
getHealthLevel
());
}
}
...
@@ -1688,17 +1705,9 @@ public class CommonServiceImpl {
...
@@ -1688,17 +1705,9 @@ public class CommonServiceImpl {
}
}
}
}
idxBizFanHealthIndexService
.
saveBatch
(
idxBizFanHealthIndexs
);
idxBizFanHealthIndexService
.
saveBatch
(
idxBizFanHealthIndexs
);
// 按时刻相关数据插入TDEngine 【异步】
insertFanDataTDEngine
(
fanHealthIndices1
,
format
);
ArrayList
<
FanHealthIndex
>
newList
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
fanHealthIndices1
.
size
();
i
++)
{
//分批次处理
newList
.
add
(
fanHealthIndices1
.
get
(
i
));
//循环将数据填入载体list
if
(
500
==
newList
.
size
()
||
i
==
fanHealthIndices1
.
size
()
-
1
)
{
//载体list达到要求,进行批量操作
//调用批量插入
fanHealthIndexMapper
.
saveBatchHealthIndexList
(
newList
,
"fan_health_index_moment"
);
newList
.
clear
();
//每次批量操作后,清空载体list,等待下次的数据填入
}
}
}
}
try
{
try
{
...
@@ -1715,16 +1724,43 @@ public class CommonServiceImpl {
...
@@ -1715,16 +1724,43 @@ public class CommonServiceImpl {
}
}
/**
* 风电按时刻相关数据插入
* @param fanHealthIndices
*/
@Async
public
void
insertFanDataTDEngine
(
ArrayList
<
FanHealthIndex
>
fanHealthIndices
,
String
recDate
)
{
// 按时刻 - 测点插入
ArrayList
<
FanHealthIndex
>
newList
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
fanHealthIndices
.
size
();
i
++)
{
//分批次处理
newList
.
add
(
fanHealthIndices
.
get
(
i
));
//循环将数据填入载体list
if
(
500
==
newList
.
size
()
||
i
==
fanHealthIndices
.
size
()
-
1
)
{
//载体list达到要求,进行批量操作
//调用批量插入
fanHealthIndexMapper
.
saveBatchHealthIndexList
(
newList
,
"fan_health_index_moment"
);
newList
.
clear
();
//每次批量操作后,清空载体list,等待下次的数据填入
}
}
// 按时刻 子系统、设备、场站、区域 插入数据
try
{
tdengineTimeService
.
insertMomentData
(
recDate
);
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
}
// @Scheduled(cron = "0 0/10 * * * ?")
// @Scheduled(cron = "0 0/10 * * * ?")
@Async
(
"async"
)
//
@Async("async")
public
void
healthWarningMinuteByPv
()
{
public
void
healthWarningMinuteByPv
()
{
if
(!
openHealth
)
{
if
(!
openHealth
)
{
return
;
return
;
}
}
Calendar
calendar
=
Calendar
.
getInstance
();
Calendar
calendar
=
Calendar
.
getInstance
();
String
format
=
DateUtil
.
format
(
new
Date
(),
"yyyy-MM-dd HH:m
m
:00"
);
String
format
=
DateUtil
.
format
(
new
Date
(),
"yyyy-MM-dd HH:m
0
:00"
);
Date
time
=
DateUtil
.
parse
(
format
,
"yyyy-MM-dd HH:m
m
:00"
);
Date
time
=
DateUtil
.
parse
(
format
,
"yyyy-MM-dd HH:m
0
:00"
);
logger
.
info
(
"光伏---------------------健康指数时间----"
+
time
);
logger
.
info
(
"光伏---------------------健康指数时间----"
+
time
);
List
<
IdxBizPvPointProcessVariableClassificationDto
>
data
=
idxBizPvPointProcessVariableClassificationMapper
.
getInfluxDBData
();
List
<
IdxBizPvPointProcessVariableClassificationDto
>
data
=
idxBizPvPointProcessVariableClassificationMapper
.
getInfluxDBData
();
Map
<
String
,
List
<
IdxBizPvPointProcessVariableClassificationDto
>>
maps
=
data
.
stream
().
collect
(
Collectors
.
groupingBy
(
IdxBizPvPointProcessVariableClassificationDto:
:
getGatewayId
));
Map
<
String
,
List
<
IdxBizPvPointProcessVariableClassificationDto
>>
maps
=
data
.
stream
().
collect
(
Collectors
.
groupingBy
(
IdxBizPvPointProcessVariableClassificationDto:
:
getGatewayId
));
// BoolQueryBuilder boolMustAll = QueryBuilders.boolQuery();
// BoolQueryBuilder boolMustAll = QueryBuilders.boolQuery();
...
@@ -1757,13 +1793,17 @@ public class CommonServiceImpl {
...
@@ -1757,13 +1793,17 @@ public class CommonServiceImpl {
// } catch (Exception e) {
// } catch (Exception e) {
// // TODO: handle exception
// // TODO: handle exception
// }
// }
Map
<
String
,
Float
>
indicatorDataListAllMap
=
indicatorDataListAll
.
stream
().
collect
(
Collectors
.
toMap
(
indicatorData
->
indicatorData
.
getAddress
()
+
"_"
+
indicatorData
.
getGatewayId
(),
IndicatorData:
:
getValueF
));
Map
<
String
,
Float
>
indicatorDataListAllMap
=
indicatorDataListAll
.
stream
().
collect
(
Collectors
.
toMap
(
indicatorData
->
indicatorData
.
getAddress
()
+
"_"
+
indicatorData
.
getGatewayId
(),
IndicatorData:
:
getValueF
));
HashMap
<
String
,
Double
>
idxBizPvPointProcessVariableClassificationDtoIdValueMap
=
new
HashMap
<>();
for
(
IdxBizPvPointProcessVariableClassificationDto
datum
:
data
)
{
for
(
IdxBizPvPointProcessVariableClassificationDto
datum
:
data
)
{
// for (ESEquipments equipment : equipments) {
// for (ESEquipments equipment : equipments) {
// if (equipment.getAddress().equals(datum.getIndexAddress()) && equipment.getGatewayId().equals(datum.getGatewayId())) {
// if (equipment.getAddress().equals(datum.getIndexAddress()) && equipment.getGatewayId().equals(datum.getGatewayId())) {
Double
currentValue
=
Double
.
valueOf
(
indicatorDataListAllMap
.
get
(
datum
.
getIndexAddress
()
+
"_"
+
datum
.
getGatewayId
()));
Double
currentValue
=
Double
.
valueOf
(
indicatorDataListAllMap
.
get
(
datum
.
getIndexAddress
()
+
"_"
+
datum
.
getGatewayId
()));
if
(!
ObjectUtils
.
isEmpty
(
currentValue
))
{
if
(!
ObjectUtils
.
isEmpty
(
currentValue
))
{
datum
.
setCurrentValue
(
currentValue
);
datum
.
setCurrentValue
(
currentValue
);
idxBizPvPointProcessVariableClassificationDtoIdValueMap
.
put
(
datum
.
getSequenceNbr
(),
currentValue
);
}
else
{
idxBizPvPointProcessVariableClassificationDtoIdValueMap
.
put
(
datum
.
getSequenceNbr
(),
0.0
);
}
}
// }
// }
// }
// }
...
@@ -1788,29 +1828,50 @@ public class CommonServiceImpl {
...
@@ -1788,29 +1828,50 @@ public class CommonServiceImpl {
List
<
String
>
ProcessPoint2Id
=
new
ArrayList
<>();
List
<
String
>
ProcessPoint2Id
=
new
ArrayList
<>();
List
<
String
>
ProcessPoint3Id
=
new
ArrayList
<>();
List
<
String
>
ProcessPoint3Id
=
new
ArrayList
<>();
List
<
String
>
analysisVariableIds
=
new
ArrayList
<>();
List
<
String
>
analysisVariableIds
=
new
ArrayList
<>();
idxBizUhefs
.
forEach
(
idxBizPvPointVarCentralValue
->
{
if
(
ObjectUtils
.
isEmpty
(
idxBizPvPointVarCentralValue
.
getProcess1Min
()))
{
idxBizPvPointVarCentralValue
.
setProcess1Min
(
Double
.
NEGATIVE_INFINITY
);
}
if
(
ObjectUtils
.
isEmpty
(
idxBizPvPointVarCentralValue
.
getProcess2Min
()))
{
idxBizPvPointVarCentralValue
.
setProcess2Min
(
Double
.
NEGATIVE_INFINITY
);
}
if
(
ObjectUtils
.
isEmpty
(
idxBizPvPointVarCentralValue
.
getProcess3Min
()))
{
idxBizPvPointVarCentralValue
.
setProcess3Min
(
Double
.
NEGATIVE_INFINITY
);
}
if
(
ObjectUtils
.
isEmpty
(
idxBizPvPointVarCentralValue
.
getProcess1Max
()))
{
idxBizPvPointVarCentralValue
.
setProcess1Max
(
Double
.
POSITIVE_INFINITY
);
}
if
(
ObjectUtils
.
isEmpty
(
idxBizPvPointVarCentralValue
.
getProcess2Max
()))
{
idxBizPvPointVarCentralValue
.
setProcess2Max
(
Double
.
POSITIVE_INFINITY
);
}
if
(
ObjectUtils
.
isEmpty
(
idxBizPvPointVarCentralValue
.
getProcess3Max
()))
{
idxBizPvPointVarCentralValue
.
setProcess3Max
(
Double
.
POSITIVE_INFINITY
);
}
});
for
(
IdxBizPvPointVarCentralValue
idxBizUhef
:
idxBizUhefs
)
{
for
(
IdxBizPvPointVarCentralValue
idxBizUhef
:
idxBizUhefs
)
{
double
value1
=
0.00
;
double
value1
=
0.00
;
double
value2
=
0.00
;
double
value2
=
0.00
;
double
value3
=
0.00
;
double
value3
=
0.00
;
double
value4
=
0.00
;
double
value4
=
0.00
;
for
(
IdxBizPvPointProcessVariableClassificationDto
datum
:
data
)
{
// for (IdxBizPvPointProcessVariableClassificationDto datum : data) {
if
(
idxBizUhef
.
getProcessPoint1Id
().
equals
(
datum
.
getSequenceNbr
()))
{
// if (idxBizUhef.getProcessPoint1Id().equals(datum.getSequenceNbr())) {
value1
=
datum
.
getCurrentValue
();
// value1 = datum.getCurrentValue();
}
// }
if
(
idxBizUhef
.
getProcessPoint2Id
().
equals
(
datum
.
getSequenceNbr
()))
{
// if (idxBizUhef.getProcessPoint2Id().equals(datum.getSequenceNbr())) {
value2
=
datum
.
getCurrentValue
();
// value2 = datum.getCurrentValue();
}
// }
if
(
idxBizUhef
.
getProcessPoint3Id
().
equals
(
datum
.
getSequenceNbr
()))
{
// if (idxBizUhef.getProcessPoint3Id().equals(datum.getSequenceNbr())) {
value3
=
datum
.
getCurrentValue
();
// value3 = datum.getCurrentValue();
}
// }
if
(
idxBizUhef
.
getAnalysisPointId
().
equals
(
datum
.
getSequenceNbr
()))
{
// if (idxBizUhef.getAnalysisPointId().equals(datum.getSequenceNbr())) {
value4
=
datum
.
getCurrentValue
();
// value4 = datum.getCurrentValue();
}
// }
}
// }
if
((
null
==
idxBizUhef
.
getProcess1Min
()
||
idxBizUhef
.
getProcess1Min
()
<=
value1
)
&&
(
null
==
idxBizUhef
.
getProcess1Max
()
||
value1
<=
idxBizUhef
.
getProcess1Max
())
value1
=
idxBizPvPointProcessVariableClassificationDtoIdValueMap
.
get
(
idxBizUhef
.
getProcessPoint1Id
());
&&
(
null
==
idxBizUhef
.
getProcess2Min
()
||
idxBizUhef
.
getProcess2Min
()
<=
value2
)
&&
(
null
==
idxBizUhef
.
getProcess2Max
()
||
value2
<=
idxBizUhef
.
getProcess2Max
())
value2
=
idxBizPvPointProcessVariableClassificationDtoIdValueMap
.
get
(
idxBizUhef
.
getProcessPoint2Id
());
&&
(
null
==
idxBizUhef
.
getProcess3Min
()
||
idxBizUhef
.
getProcess3Min
()
<=
value3
)
&&
(
null
==
idxBizUhef
.
getProcess3Max
()
||
value3
<=
idxBizUhef
.
getProcess3Max
()))
{
value3
=
idxBizPvPointProcessVariableClassificationDtoIdValueMap
.
get
(
idxBizUhef
.
getProcessPoint3Id
());
value4
=
idxBizPvPointProcessVariableClassificationDtoIdValueMap
.
get
(
idxBizUhef
.
getAnalysisPointId
());
if
(
idxBizUhef
.
getProcess1Min
()
<=
value1
&&
value1
<=
idxBizUhef
.
getProcess1Max
()
&&
idxBizUhef
.
getProcess2Min
()
<=
value2
&&
value2
<=
idxBizUhef
.
getProcess2Max
()
&&
idxBizUhef
.
getProcess3Min
()
<=
value3
&&
value3
<=
idxBizUhef
.
getProcess3Max
())
{
if
(!
analysisVariableIdList
.
contains
(
idxBizUhef
.
getAnalysisPointId
()))
{
if
(!
analysisVariableIdList
.
contains
(
idxBizUhef
.
getAnalysisPointId
()))
{
analysisVariableList
.
add
(
value4
);
analysisVariableList
.
add
(
value4
);
analysisVariable
.
add
(
value4
);
analysisVariable
.
add
(
value4
);
...
@@ -1842,16 +1903,7 @@ public class CommonServiceImpl {
...
@@ -1842,16 +1903,7 @@ public class CommonServiceImpl {
requestMap
.
put
(
"analysisVariableId"
,
analysisVariableIdList
);
requestMap
.
put
(
"analysisVariableId"
,
analysisVariableIdList
);
Table
healthData
=
Table
.
create
(
"healthData"
);
Table
healthData
=
Table
.
create
(
"healthData"
);
healthData
.
addColumns
(
DoubleColumn
.
create
(
"analysisVariable"
,
analysisVariable
),
healthData
.
addColumns
(
DoubleColumn
.
create
(
"analysisVariable"
,
analysisVariable
),
DoubleColumn
.
create
(
"stdDev"
,
stdDev
),
DoubleColumn
.
create
(
"centerValue"
,
centerValue
),
StringColumn
.
create
(
"ProcessPoint1Id"
,
ProcessPoint1Id
),
DoubleColumn
.
create
(
"ProcessPoint1"
,
ProcessPoint1
),
StringColumn
.
create
(
"ProcessPoint2Id"
,
ProcessPoint2Id
),
DoubleColumn
.
create
(
"ProcessPoint2"
,
ProcessPoint2
),
StringColumn
.
create
(
"ProcessPoint3Id"
,
ProcessPoint3Id
),
DoubleColumn
.
create
(
"ProcessPoint3"
,
ProcessPoint3
),
StringColumn
.
create
(
"analysisVariableId"
,
analysisVariableIds
));
DoubleColumn
.
create
(
"stdDev"
,
stdDev
),
DoubleColumn
.
create
(
"centerValue"
,
centerValue
),
StringColumn
.
create
(
"ProcessPoint1Id"
,
ProcessPoint1Id
),
DoubleColumn
.
create
(
"ProcessPoint1"
,
ProcessPoint1
),
StringColumn
.
create
(
"ProcessPoint2Id"
,
ProcessPoint2Id
),
DoubleColumn
.
create
(
"ProcessPoint2"
,
ProcessPoint2
),
StringColumn
.
create
(
"ProcessPoint3Id"
,
ProcessPoint3Id
),
DoubleColumn
.
create
(
"ProcessPoint3"
,
ProcessPoint3
),
StringColumn
.
create
(
"analysisVariableId"
,
analysisVariableIds
));
logger
.
info
(
"------------------------------------------开始调用健康指数计算算法开始----------------------------------------"
);
logger
.
info
(
"------------------------------------------开始调用健康指数计算算法开始----------------------------------------"
);
String
response
=
HttpUtil
.
createPost
(
baseUrlZSFX
).
body
(
JSON
.
toJSONString
(
requestMap
)).
execute
().
body
();
String
response
=
HttpUtil
.
createPost
(
baseUrlZSFX
).
body
(
JSON
.
toJSONString
(
requestMap
)).
execute
().
body
();
JSONObject
jsonObject
=
JSON
.
parseObject
(
response
);
JSONObject
jsonObject
=
JSON
.
parseObject
(
response
);
...
@@ -1863,8 +1915,7 @@ public class CommonServiceImpl {
...
@@ -1863,8 +1915,7 @@ public class CommonServiceImpl {
List
<
Double
>
scoreValue
=
JSONObject
.
parseArray
(
scoreValueArray
.
toJSONString
(),
Double
.
class
);
List
<
Double
>
scoreValue
=
JSONObject
.
parseArray
(
scoreValueArray
.
toJSONString
(),
Double
.
class
);
List
<
Double
>
indexValue
=
JSONObject
.
parseArray
(
indexValueArray
.
toJSONString
(),
Double
.
class
);
List
<
Double
>
indexValue
=
JSONObject
.
parseArray
(
indexValueArray
.
toJSONString
(),
Double
.
class
);
// Table resultTable = Table.create("healthData");
// Table resultTable = Table.create("healthData");
healthData
.
addColumns
(
StringColumn
.
create
(
"analysisVariableIdResult"
,
jsonArrayToStringList
),
healthData
.
addColumns
(
StringColumn
.
create
(
"analysisVariableIdResult"
,
jsonArrayToStringList
),
DoubleColumn
.
create
(
"indexValue"
,
indexValue
),
DoubleColumn
.
create
(
"scoreValue"
,
scoreValue
));
DoubleColumn
.
create
(
"indexValue"
,
indexValue
),
DoubleColumn
.
create
(
"scoreValue"
,
scoreValue
));
System
.
out
.
println
(
healthData
.
print
());
System
.
out
.
println
(
healthData
.
print
());
try
{
try
{
healthData
.
write
().
csv
(
new
Date
().
getTime
()
+
"gf.csv"
);
healthData
.
write
().
csv
(
new
Date
().
getTime
()
+
"gf.csv"
);
...
@@ -1901,8 +1952,7 @@ public class CommonServiceImpl {
...
@@ -1901,8 +1952,7 @@ public class CommonServiceImpl {
//获取健康指数对应等级
//获取健康指数对应等级
for
(
IdxBizPvHealthLevel
idxBizFanHealthLevel
:
idxBizFanHealthLevels
)
{
for
(
IdxBizPvHealthLevel
idxBizFanHealthLevel
:
idxBizFanHealthLevels
)
{
if
(
indexValueArray
.
getDoubleValue
(
i
)
<=
idxBizFanHealthLevel
.
getGroupUpperLimit
()
if
(
indexValueArray
.
getDoubleValue
(
i
)
<=
idxBizFanHealthLevel
.
getGroupUpperLimit
()
&&
indexValueArray
.
getDoubleValue
(
i
)
>=
idxBizFanHealthLevel
.
getGroupLowerLimit
())
{
&&
indexValueArray
.
getDoubleValue
(
i
)
>=
idxBizFanHealthLevel
.
getGroupLowerLimit
())
{
idxBizPvHealthIndex
.
setHealthLevel
(
idxBizFanHealthLevel
.
getHealthLevel
());
idxBizPvHealthIndex
.
setHealthLevel
(
idxBizFanHealthLevel
.
getHealthLevel
());
}
}
...
@@ -1927,16 +1977,8 @@ public class CommonServiceImpl {
...
@@ -1927,16 +1977,8 @@ public class CommonServiceImpl {
}
}
}
}
idxBizPvHealthIndexService
.
saveBatch
(
idxBizPvHealthIndexs
);
idxBizPvHealthIndexService
.
saveBatch
(
idxBizPvHealthIndexs
);
ArrayList
<
PvHealthIndex
>
newList
=
new
ArrayList
<>();
//按时刻 - 相关数据插入
for
(
int
i
=
0
;
i
<
fanHealthIndices1
.
size
();
i
++)
{
insertPvDataTDEngine
(
fanHealthIndices1
,
format
);
//分批次处理
newList
.
add
(
fanHealthIndices1
.
get
(
i
));
//循环将数据填入载体list
if
(
500
==
newList
.
size
()
||
i
==
fanHealthIndices1
.
size
()
-
1
)
{
//载体list达到要求,进行批量操作
//调用批量插入
pvHealthIndexMapper
.
saveBatchHealthIndexList
(
newList
,
"pv_health_index_moment"
);
newList
.
clear
();
//每次批量操作后,清空载体list,等待下次的数据填入
}
}
}
}
try
{
try
{
logger
.
info
(
"--------------------response: "
+
response
);
logger
.
info
(
"--------------------response: "
+
response
);
...
@@ -1948,4 +1990,31 @@ public class CommonServiceImpl {
...
@@ -1948,4 +1990,31 @@ public class CommonServiceImpl {
}
}
/**
* 光伏按时刻相关数据插入
* @param pvHealthIndices
*/
@Async
public
void
insertPvDataTDEngine
(
ArrayList
<
PvHealthIndex
>
pvHealthIndices
,
String
recDate
)
{
// 按时刻 - 测点插入
ArrayList
<
PvHealthIndex
>
newList
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
pvHealthIndices
.
size
();
i
++)
{
//分批次处理
newList
.
add
(
pvHealthIndices
.
get
(
i
));
//循环将数据填入载体list
if
(
500
==
newList
.
size
()
||
i
==
pvHealthIndices
.
size
()
-
1
)
{
//载体list达到要求,进行批量操作
//调用批量插入
pvHealthIndexMapper
.
saveBatchHealthIndexList
(
newList
,
"pv_health_index_moment"
);
newList
.
clear
();
//每次批量操作后,清空载体list,等待下次的数据填入
}
}
// 按时刻 设备、子阵、场站、区域 插入数据
try
{
tdengineTimeService
.
insertMomentDataPv
(
recDate
);
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
}
}
}
amos-boot-system-jxiop/amos-boot-module-jxiop-analyse-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/service/impl/TdengineTimeServiceImpl.java
View file @
4f8cd398
package
com
.
yeejoin
.
amos
.
boot
.
module
.
jxiop
.
biz
.
service
.
impl
;
package
com
.
yeejoin
.
amos
.
boot
.
module
.
jxiop
.
biz
.
service
.
impl
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.date.DateUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.yeejoin.amos.boot.biz.common.utils.DateUtils
;
import
com.yeejoin.amos.boot.biz.common.utils.DateUtils
;
import
com.yeejoin.amos.boot.module.jxiop.
api.dto.BizMessage
;
import
com.yeejoin.amos.boot.module.jxiop.
biz.entity.IdxBizFanHealthLevel
;
import
com.yeejoin.amos.boot.module.jxiop.
api.dto.RiskBizInfoVo
;
import
com.yeejoin.amos.boot.module.jxiop.
biz.entity.IdxBizPvHealthLevel
;
import
com.yeejoin.amos.boot.module.jxiop.
api.dto.RiskDynamicDetailsVo
;
import
com.yeejoin.amos.boot.module.jxiop.
biz.mapper2.IdxBizFanHealthLevelMapper
;
import
com.yeejoin.amos.boot.module.jxiop.
api.entity.StationBasic
;
import
com.yeejoin.amos.boot.module.jxiop.
biz.mapper2.IdxBizPvHealthLevelMapper
;
import
com.yeejoin.amos.boot.module.jxiop.biz.
entity.IdxBizFanWarningRecord
;
import
com.yeejoin.amos.boot.module.jxiop.biz.
tdMapper2.FanHealthIndexMapper
;
import
com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.
FanHealthIndexMoment
Mapper
;
import
com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.
PvHealthIndex
Mapper
;
import
com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndex
;
import
com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndex
;
import
com.yeejoin.amos.boot.module.jxiop.biz.tdengine.
FanHealthIndexMoment
;
import
com.yeejoin.amos.boot.module.jxiop.biz.tdengine.
PvHealthIndex
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.eclipse.paho.client.mqttv3.MqttException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.
nio.charset.StandardCharsets
;
import
java.
text.ParseException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
...
@@ -33,23 +30,249 @@ import java.util.List;
...
@@ -33,23 +30,249 @@ import java.util.List;
public
class
TdengineTimeServiceImpl
{
public
class
TdengineTimeServiceImpl
{
@Autowired
@Autowired
private
FanHealthIndexMomentMapper
fanHealthIndexMomentMapper
;
private
FanHealthIndexMapper
fanHealthIndexMapper
;
@Autowired
private
PvHealthIndexMapper
pvHealthIndexMapper
;
@Autowired
private
IdxBizFanHealthLevelMapper
idxBizFanHealthLevelMapper
;
@Autowired
private
IdxBizPvHealthLevelMapper
idxBizPvHealthLevelMapper
;
/**
/**
* 风电 - 按
小时生成测点
数据
* 风电 - 按
时刻生成子系统、设备、场站、区域
数据
*/
*/
@Async
public
void
insertMomentData
(
String
recDate
)
throws
ParseException
{
public
void
insertHourData
()
{
//s 489分钟 为 8小时 + 19分钟
QueryWrapper
<
FanHealthIndexMoment
>
fanHealthLambda
=
new
QueryWrapper
<>();
String
startTime
=
DateUtils
.
dateFormat
(
DateUtils
.
dateAddMinutes
(
new
Date
(),
-
489
),
DateUtils
.
DATE_TIME_PATTERN
);
fanHealthLambda
.
select
(
"*, FORMAT(AVG(HEALTH_INDEX),2) as avgHealthIndex"
);
// 子系统
fanHealthLambda
.
lambda
().
ge
(
FanHealthIndexMoment:
:
getRecDate
,
DateUtils
.
dateAddHours
(
new
Date
(),
-
1
));
List
<
IdxBizFanHealthLevel
>
levelListZxt
=
idxBizFanHealthLevelMapper
.
selectList
(
new
LambdaQueryWrapper
<
IdxBizFanHealthLevel
>().
eq
(
IdxBizFanHealthLevel:
:
getAnalysisObjType
,
"子系统"
).
last
(
"limit 4"
));
fanHealthLambda
.
lambda
().
eq
(
FanHealthIndexMoment:
:
getAnalysisObjType
,
"测点"
);
List
<
FanHealthIndex
>
fanHealthIndicesZxt
=
fanHealthIndexMapper
.
getInfoListByGroupByZxtFan
(
startTime
,
"fan_health_index_moment"
,
"测点"
);
fanHealthLambda
.
lambda
().
groupBy
saveBatchFan
(
fanHealthIndicesZxt
,
"fan_health_index_moment"
,
recDate
,
"按时刻"
,
levelListZxt
);
(
FanHealthIndexMoment:
:
getGatewayId
,
// 设备
FanHealthIndexMoment:
:
getIndexAddress
List
<
IdxBizFanHealthLevel
>
levelListSb
=
idxBizFanHealthLevelMapper
.
selectList
(
new
LambdaQueryWrapper
<
IdxBizFanHealthLevel
>().
eq
(
IdxBizFanHealthLevel:
:
getAnalysisObjType
,
"设备"
).
last
(
"limit 4"
));
);
List
<
FanHealthIndex
>
fanHealthIndicesSb
=
fanHealthIndexMapper
.
getInfoListByGroupBySbFan
(
startTime
,
"fan_health_index_moment"
,
"子系统"
);
List
<
FanHealthIndexMoment
>
fanHealthIndexMoments
=
fanHealthIndexMomentMapper
.
selectList
(
fanHealthLambda
);
saveBatchFan
(
fanHealthIndicesSb
,
"fan_health_index_moment"
,
recDate
,
"按时刻"
,
levelListSb
);
fanHealthIndexMoments
.
forEach
(
item
->
{
// 场站
List
<
IdxBizFanHealthLevel
>
levelListCz
=
idxBizFanHealthLevelMapper
.
selectList
(
new
LambdaQueryWrapper
<
IdxBizFanHealthLevel
>().
eq
(
IdxBizFanHealthLevel:
:
getAnalysisObjType
,
"场站"
).
last
(
"limit 4"
));
});
List
<
FanHealthIndex
>
fanHealthIndicesCz
=
fanHealthIndexMapper
.
getInfoListByGroupByCzFan
(
startTime
,
"fan_health_index_moment"
,
"设备"
);
saveBatchFan
(
fanHealthIndicesCz
,
"fan_health_index_moment"
,
recDate
,
"按时刻"
,
levelListCz
);
// 区域
List
<
IdxBizFanHealthLevel
>
levelListQy
=
idxBizFanHealthLevelMapper
.
selectList
(
new
LambdaQueryWrapper
<
IdxBizFanHealthLevel
>().
eq
(
IdxBizFanHealthLevel:
:
getAnalysisObjType
,
"片区"
).
last
(
"limit 4"
));
List
<
FanHealthIndex
>
fanHealthIndicesQy
=
fanHealthIndexMapper
.
getInfoListByGroupByQyFan
(
startTime
,
"fan_health_index_moment"
,
"场站"
);
saveBatchFan
(
fanHealthIndicesQy
,
"fan_health_index_moment"
,
recDate
,
"按时刻"
,
levelListQy
);
}
/**
* 风电 - 按小时生成测点、子系统、设备、场站、区域 数据
*/
@Scheduled
(
cron
=
"0 0 0/1 * * ? "
)
public
void
insertHourData
()
throws
ParseException
{
String
recDate
=
DateUtil
.
format
(
new
Date
(),
"yyyy-MM-dd HH:00:00"
);
// 8小时 + 59分钟
String
startTime
=
DateUtils
.
dateFormat
(
DateUtils
.
dateAddMinutes
(
new
Date
(),
-
541
),
DateUtils
.
DATE_TIME_PATTERN
);
// 测点
List
<
IdxBizFanHealthLevel
>
levelList
=
idxBizFanHealthLevelMapper
.
selectList
(
new
LambdaQueryWrapper
<
IdxBizFanHealthLevel
>().
eq
(
IdxBizFanHealthLevel:
:
getAnalysisObjType
,
"测点"
).
last
(
"limit 4"
));
List
<
FanHealthIndex
>
fanHealthIndices
=
fanHealthIndexMapper
.
getInfoListByGroupByCdFan
(
startTime
,
"fan_health_index_moment"
,
"测点"
);
saveBatchFan
(
fanHealthIndices
,
"fan_health_index_hour"
,
recDate
,
"按小时"
,
levelList
);
// 子系统
List
<
IdxBizFanHealthLevel
>
levelListZxt
=
idxBizFanHealthLevelMapper
.
selectList
(
new
LambdaQueryWrapper
<
IdxBizFanHealthLevel
>().
eq
(
IdxBizFanHealthLevel:
:
getAnalysisObjType
,
"子系统"
).
last
(
"limit 4"
));
List
<
FanHealthIndex
>
fanHealthIndicesZxt
=
fanHealthIndexMapper
.
getInfoListByGroupByZxtFan
(
startTime
,
"fan_health_index_moment"
,
"测点"
);
saveBatchFan
(
fanHealthIndicesZxt
,
"fan_health_index_hour"
,
recDate
,
"按小时"
,
levelListZxt
);
// 设备
List
<
IdxBizFanHealthLevel
>
levelListSb
=
idxBizFanHealthLevelMapper
.
selectList
(
new
LambdaQueryWrapper
<
IdxBizFanHealthLevel
>().
eq
(
IdxBizFanHealthLevel:
:
getAnalysisObjType
,
"设备"
).
last
(
"limit 4"
));
List
<
FanHealthIndex
>
fanHealthIndicesSb
=
fanHealthIndexMapper
.
getInfoListByGroupBySbFan
(
startTime
,
"fan_health_index_moment"
,
"子系统"
);
saveBatchFan
(
fanHealthIndicesSb
,
"fan_health_index_hour"
,
recDate
,
"按小时"
,
levelListSb
);
// 场站
List
<
IdxBizFanHealthLevel
>
levelListCz
=
idxBizFanHealthLevelMapper
.
selectList
(
new
LambdaQueryWrapper
<
IdxBizFanHealthLevel
>().
eq
(
IdxBizFanHealthLevel:
:
getAnalysisObjType
,
"场站"
).
last
(
"limit 4"
));
List
<
FanHealthIndex
>
fanHealthIndicesCz
=
fanHealthIndexMapper
.
getInfoListByGroupByCzFan
(
startTime
,
"fan_health_index_moment"
,
"设备"
);
saveBatchFan
(
fanHealthIndicesCz
,
"fan_health_index_hour"
,
recDate
,
"按小时"
,
levelListCz
);
// 区域
List
<
IdxBizFanHealthLevel
>
levelListQy
=
idxBizFanHealthLevelMapper
.
selectList
(
new
LambdaQueryWrapper
<
IdxBizFanHealthLevel
>().
eq
(
IdxBizFanHealthLevel:
:
getAnalysisObjType
,
"片区"
).
last
(
"limit 4"
));
List
<
FanHealthIndex
>
fanHealthIndicesQy
=
fanHealthIndexMapper
.
getInfoListByGroupByQyFan
(
startTime
,
"fan_health_index_moment"
,
"场站"
);
saveBatchFan
(
fanHealthIndicesQy
,
"fan_health_index_hour"
,
recDate
,
"按小时"
,
levelListQy
);
}
/**
* 风电 - 按天生成测点、子系统、设备、场站、区域 数据
*/
@Scheduled
(
cron
=
"0 0 0 1/1 * ? "
)
public
void
insertDayData
()
throws
ParseException
{
String
recDate
=
DateUtil
.
format
(
new
Date
(),
"yyyy-MM-dd 00:00:00"
);
String
startTime
=
DateUtils
.
dateFormat
(
DateUtils
.
dateAddHours
(
new
Date
(),
-
32
),
DateUtils
.
DATE_TIME_PATTERN
);
List
<
IdxBizFanHealthLevel
>
levelList
=
idxBizFanHealthLevelMapper
.
selectList
(
new
LambdaQueryWrapper
<
IdxBizFanHealthLevel
>().
eq
(
IdxBizFanHealthLevel:
:
getAnalysisObjType
,
"测点"
).
last
(
"limit 4"
));
List
<
FanHealthIndex
>
fanHealthIndices
=
fanHealthIndexMapper
.
getInfoListByGroupByCdFan
(
startTime
,
"fan_health_index_hour"
,
"测点"
);
saveBatchFan
(
fanHealthIndices
,
"fan_health_index_day"
,
recDate
,
"按天"
,
levelList
);
// 子系统
List
<
IdxBizFanHealthLevel
>
levelListZxt
=
idxBizFanHealthLevelMapper
.
selectList
(
new
LambdaQueryWrapper
<
IdxBizFanHealthLevel
>().
eq
(
IdxBizFanHealthLevel:
:
getAnalysisObjType
,
"子系统"
).
last
(
"limit 4"
));
List
<
FanHealthIndex
>
fanHealthIndicesZxt
=
fanHealthIndexMapper
.
getInfoListByGroupByZxtFan
(
startTime
,
"fan_health_index_hour"
,
"测点"
);
saveBatchFan
(
fanHealthIndicesZxt
,
"fan_health_index_day"
,
recDate
,
"按天"
,
levelListZxt
);
// 设备
List
<
IdxBizFanHealthLevel
>
levelListSb
=
idxBizFanHealthLevelMapper
.
selectList
(
new
LambdaQueryWrapper
<
IdxBizFanHealthLevel
>().
eq
(
IdxBizFanHealthLevel:
:
getAnalysisObjType
,
"设备"
).
last
(
"limit 4"
));
List
<
FanHealthIndex
>
fanHealthIndicesSb
=
fanHealthIndexMapper
.
getInfoListByGroupBySbFan
(
startTime
,
"fan_health_index_hour"
,
"子系统"
);
saveBatchFan
(
fanHealthIndicesSb
,
"fan_health_index_day"
,
recDate
,
"按天"
,
levelListSb
);
// 场站
List
<
IdxBizFanHealthLevel
>
levelListCz
=
idxBizFanHealthLevelMapper
.
selectList
(
new
LambdaQueryWrapper
<
IdxBizFanHealthLevel
>().
eq
(
IdxBizFanHealthLevel:
:
getAnalysisObjType
,
"场站"
).
last
(
"limit 4"
));
List
<
FanHealthIndex
>
fanHealthIndicesCz
=
fanHealthIndexMapper
.
getInfoListByGroupByCzFan
(
startTime
,
"fan_health_index_hour"
,
"设备"
);
saveBatchFan
(
fanHealthIndicesCz
,
"fan_health_index_day"
,
recDate
,
"按天"
,
levelListCz
);
// 区域
List
<
IdxBizFanHealthLevel
>
levelListQy
=
idxBizFanHealthLevelMapper
.
selectList
(
new
LambdaQueryWrapper
<
IdxBizFanHealthLevel
>().
eq
(
IdxBizFanHealthLevel:
:
getAnalysisObjType
,
"片区"
).
last
(
"limit 4"
));
List
<
FanHealthIndex
>
fanHealthIndicesQy
=
fanHealthIndexMapper
.
getInfoListByGroupByQyFan
(
startTime
,
"fan_health_index_hour"
,
"场站"
);
saveBatchFan
(
fanHealthIndicesQy
,
"fan_health_index_day"
,
recDate
,
"按天"
,
levelListQy
);
}
private
String
getHealthLevelByScore
(
List
<
IdxBizFanHealthLevel
>
levelList
,
Double
healthIndex
)
{
String
levelDesc
=
"安全"
;
for
(
IdxBizFanHealthLevel
item
:
levelList
)
{
if
(
item
.
getGroupUpperLimit
()
>=
healthIndex
&&
item
.
getGroupLowerLimit
()
<
healthIndex
)
{
levelDesc
=
item
.
getHealthLevel
();
break
;
}
}
return
levelDesc
;
}
private
void
saveBatchFan
(
List
<
FanHealthIndex
>
fanHealthIndices
,
String
tableName
,
String
recDate
,
String
analysisType
,
List
<
IdxBizFanHealthLevel
>
levelList
)
{
ArrayList
<
FanHealthIndex
>
newList
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
fanHealthIndices
.
size
();
i
++)
{
FanHealthIndex
fanHealthIndex
=
fanHealthIndices
.
get
(
i
);
fanHealthIndex
.
setRecDate
(
recDate
);
fanHealthIndex
.
setAnalysisTime
(
recDate
);
fanHealthIndex
.
setAnalysisType
(
analysisType
);
fanHealthIndex
.
setHealthLevel
(
getHealthLevelByScore
(
levelList
,
fanHealthIndex
.
getHealthIndex
()));
//分批次处理
newList
.
add
(
fanHealthIndex
);
//循环将数据填入载体list
if
(
500
==
newList
.
size
()
||
i
==
fanHealthIndices
.
size
()
-
1
)
{
//载体list达到要求,进行批量操作
//调用批量插入
fanHealthIndexMapper
.
saveBatchHealthIndexList
(
newList
,
tableName
);
newList
.
clear
();
//每次批量操作后,清空载体list,等待下次的数据填入
}
}
}
/**
* 光伏 - 按时刻生成设备、子阵、场站和片区数据
*/
public
void
insertMomentDataPv
(
String
recDate
)
throws
ParseException
{
String
startTime
=
DateUtils
.
dateFormat
(
DateUtils
.
dateAddMinutes
(
new
Date
(),
-
489
),
DateUtils
.
DATE_TIME_PATTERN
);
// 设备
List
<
IdxBizPvHealthLevel
>
levelListSb
=
idxBizPvHealthLevelMapper
.
selectList
(
new
LambdaQueryWrapper
<
IdxBizPvHealthLevel
>().
eq
(
IdxBizPvHealthLevel:
:
getAnalysisObjType
,
"设备"
).
last
(
"limit 4"
));
List
<
PvHealthIndex
>
fanHealthIndicesSb
=
pvHealthIndexMapper
.
getInfoListByGroupBySbPv
(
startTime
,
"pv_health_index_moment"
,
"测点"
);
saveBatchPv
(
fanHealthIndicesSb
,
"pv_health_index_moment"
,
recDate
,
"按时刻"
,
levelListSb
);
// 子阵
List
<
IdxBizPvHealthLevel
>
levelListZz
=
idxBizPvHealthLevelMapper
.
selectList
(
new
LambdaQueryWrapper
<
IdxBizPvHealthLevel
>().
eq
(
IdxBizPvHealthLevel:
:
getAnalysisObjType
,
"子阵"
).
last
(
"limit 4"
));
List
<
PvHealthIndex
>
fanHealthIndicesZz
=
pvHealthIndexMapper
.
getInfoListByGroupByZzPv
(
startTime
,
"pv_health_index_moment"
,
"设备"
);
saveBatchPv
(
fanHealthIndicesZz
,
"pv_health_index_moment"
,
recDate
,
"按时刻"
,
levelListZz
);
// 场站
List
<
IdxBizPvHealthLevel
>
levelListCz
=
idxBizPvHealthLevelMapper
.
selectList
(
new
LambdaQueryWrapper
<
IdxBizPvHealthLevel
>().
eq
(
IdxBizPvHealthLevel:
:
getAnalysisObjType
,
"场站"
).
last
(
"limit 4"
));
List
<
PvHealthIndex
>
fanHealthIndicesCz
=
pvHealthIndexMapper
.
getInfoListByGroupByCzPv
(
startTime
,
"pv_health_index_moment"
,
"子阵"
);
saveBatchPv
(
fanHealthIndicesCz
,
"pv_health_index_moment"
,
recDate
,
"按时刻"
,
levelListCz
);
// 片区
List
<
IdxBizPvHealthLevel
>
levelListQy
=
idxBizPvHealthLevelMapper
.
selectList
(
new
LambdaQueryWrapper
<
IdxBizPvHealthLevel
>().
eq
(
IdxBizPvHealthLevel:
:
getAnalysisObjType
,
"片区"
).
last
(
"limit 4"
));
List
<
PvHealthIndex
>
fanHealthIndicesQy
=
pvHealthIndexMapper
.
getInfoListByGroupByQyPv
(
startTime
,
"pv_health_index_moment"
,
"场站"
);
saveBatchPv
(
fanHealthIndicesQy
,
"pv_health_index_moment"
,
recDate
,
"按时刻"
,
levelListQy
);
}
/**
* 光伏 - 按小时生成 测点、设备、子阵、场站和片区数据
*/
@Scheduled
(
cron
=
"0 0 0/1 * * ? "
)
public
void
insertHourDataPv
()
throws
ParseException
{
String
recDate
=
DateUtil
.
format
(
new
Date
(),
"yyyy-MM-dd HH:00:00"
);
// 8小时 + 59分钟
String
startTime
=
DateUtils
.
dateFormat
(
DateUtils
.
dateAddMinutes
(
new
Date
(),
-
541
),
DateUtils
.
DATE_TIME_PATTERN
);
// 测点
List
<
IdxBizPvHealthLevel
>
levelList
=
idxBizPvHealthLevelMapper
.
selectList
(
new
LambdaQueryWrapper
<
IdxBizPvHealthLevel
>().
eq
(
IdxBizPvHealthLevel:
:
getAnalysisObjType
,
"测点"
).
last
(
"limit 4"
));
List
<
PvHealthIndex
>
fanHealthIndices
=
pvHealthIndexMapper
.
getInfoListByGroupByCdPv
(
startTime
,
"pv_health_index_moment"
,
"测点"
);
saveBatchPv
(
fanHealthIndices
,
"pv_health_index_hour"
,
recDate
,
"按小时"
,
levelList
);
// 设备
List
<
IdxBizPvHealthLevel
>
levelListSb
=
idxBizPvHealthLevelMapper
.
selectList
(
new
LambdaQueryWrapper
<
IdxBizPvHealthLevel
>().
eq
(
IdxBizPvHealthLevel:
:
getAnalysisObjType
,
"设备"
).
last
(
"limit 4"
));
List
<
PvHealthIndex
>
fanHealthIndicesSb
=
pvHealthIndexMapper
.
getInfoListByGroupBySbPv
(
startTime
,
"pv_health_index_moment"
,
"测点"
);
saveBatchPv
(
fanHealthIndicesSb
,
"pv_health_index_hour"
,
recDate
,
"按小时"
,
levelListSb
);
// 子阵
List
<
IdxBizPvHealthLevel
>
levelListZz
=
idxBizPvHealthLevelMapper
.
selectList
(
new
LambdaQueryWrapper
<
IdxBizPvHealthLevel
>().
eq
(
IdxBizPvHealthLevel:
:
getAnalysisObjType
,
"子阵"
).
last
(
"limit 4"
));
List
<
PvHealthIndex
>
fanHealthIndicesZz
=
pvHealthIndexMapper
.
getInfoListByGroupByZzPv
(
startTime
,
"pv_health_index_moment"
,
"设备"
);
saveBatchPv
(
fanHealthIndicesZz
,
"pv_health_index_hour"
,
recDate
,
"按小时"
,
levelListZz
);
// 场站
List
<
IdxBizPvHealthLevel
>
levelListCz
=
idxBizPvHealthLevelMapper
.
selectList
(
new
LambdaQueryWrapper
<
IdxBizPvHealthLevel
>().
eq
(
IdxBizPvHealthLevel:
:
getAnalysisObjType
,
"场站"
).
last
(
"limit 4"
));
List
<
PvHealthIndex
>
fanHealthIndicesCz
=
pvHealthIndexMapper
.
getInfoListByGroupByCzPv
(
startTime
,
"pv_health_index_moment"
,
"子阵"
);
saveBatchPv
(
fanHealthIndicesCz
,
"pv_health_index_hour"
,
recDate
,
"按小时"
,
levelListCz
);
// 片区
List
<
IdxBizPvHealthLevel
>
levelListQy
=
idxBizPvHealthLevelMapper
.
selectList
(
new
LambdaQueryWrapper
<
IdxBizPvHealthLevel
>().
eq
(
IdxBizPvHealthLevel:
:
getAnalysisObjType
,
"片区"
).
last
(
"limit 4"
));
List
<
PvHealthIndex
>
fanHealthIndicesQy
=
pvHealthIndexMapper
.
getInfoListByGroupByQyPv
(
startTime
,
"pv_health_index_moment"
,
"场站"
);
saveBatchPv
(
fanHealthIndicesQy
,
"pv_health_index_hour"
,
recDate
,
"按小时"
,
levelListQy
);
}
/**
* 光伏 - 按天生成 测点、设备、子阵、场站和片区数据
*/
@Scheduled
(
cron
=
"0 0 0 1/1 * ? "
)
public
void
insertDayDataPv
()
throws
ParseException
{
String
recDate
=
DateUtil
.
format
(
new
Date
(),
"yyyy-MM-dd 00:00:00"
);
List
<
IdxBizPvHealthLevel
>
levelList
=
idxBizPvHealthLevelMapper
.
selectList
(
new
LambdaQueryWrapper
<
IdxBizPvHealthLevel
>().
eq
(
IdxBizPvHealthLevel:
:
getAnalysisObjType
,
"测点"
).
last
(
"limit 4"
));
String
startTime
=
DateUtils
.
dateFormat
(
DateUtils
.
dateAddHours
(
new
Date
(),
-
32
),
DateUtils
.
DATE_TIME_PATTERN
);
List
<
PvHealthIndex
>
fanHealthIndices
=
pvHealthIndexMapper
.
getInfoListByGroupByCdPv
(
startTime
,
"pv_health_index_hour"
,
"测点"
);
saveBatchPv
(
fanHealthIndices
,
"pv_health_index_day"
,
recDate
,
"按天"
,
levelList
);
// 设备
List
<
IdxBizPvHealthLevel
>
levelListSb
=
idxBizPvHealthLevelMapper
.
selectList
(
new
LambdaQueryWrapper
<
IdxBizPvHealthLevel
>().
eq
(
IdxBizPvHealthLevel:
:
getAnalysisObjType
,
"设备"
).
last
(
"limit 4"
));
List
<
PvHealthIndex
>
fanHealthIndicesSb
=
pvHealthIndexMapper
.
getInfoListByGroupBySbPv
(
startTime
,
"pv_health_index_hour"
,
"测点"
);
saveBatchPv
(
fanHealthIndicesSb
,
"pv_health_index_hour"
,
recDate
,
"按天"
,
levelListSb
);
// 子阵
List
<
IdxBizPvHealthLevel
>
levelListZz
=
idxBizPvHealthLevelMapper
.
selectList
(
new
LambdaQueryWrapper
<
IdxBizPvHealthLevel
>().
eq
(
IdxBizPvHealthLevel:
:
getAnalysisObjType
,
"子阵"
).
last
(
"limit 4"
));
List
<
PvHealthIndex
>
fanHealthIndicesZz
=
pvHealthIndexMapper
.
getInfoListByGroupByZzPv
(
startTime
,
"pv_health_index_hour"
,
"设备"
);
saveBatchPv
(
fanHealthIndicesZz
,
"pv_health_index_hour"
,
recDate
,
"按天"
,
levelListZz
);
// 场站
List
<
IdxBizPvHealthLevel
>
levelListCz
=
idxBizPvHealthLevelMapper
.
selectList
(
new
LambdaQueryWrapper
<
IdxBizPvHealthLevel
>().
eq
(
IdxBizPvHealthLevel:
:
getAnalysisObjType
,
"场站"
).
last
(
"limit 4"
));
List
<
PvHealthIndex
>
fanHealthIndicesCz
=
pvHealthIndexMapper
.
getInfoListByGroupByCzPv
(
startTime
,
"pv_health_index_hour"
,
"子阵"
);
saveBatchPv
(
fanHealthIndicesCz
,
"pv_health_index_hour"
,
recDate
,
"按天"
,
levelListCz
);
// 片区
List
<
IdxBizPvHealthLevel
>
levelListQy
=
idxBizPvHealthLevelMapper
.
selectList
(
new
LambdaQueryWrapper
<
IdxBizPvHealthLevel
>().
eq
(
IdxBizPvHealthLevel:
:
getAnalysisObjType
,
"片区"
).
last
(
"limit 4"
));
List
<
PvHealthIndex
>
fanHealthIndicesQy
=
pvHealthIndexMapper
.
getInfoListByGroupByQyPv
(
startTime
,
"pv_health_index_hour"
,
"场站"
);
saveBatchPv
(
fanHealthIndicesQy
,
"pv_health_index_hour"
,
recDate
,
"按天"
,
levelListQy
);
}
private
String
getHealthLevelByScorePv
(
List
<
IdxBizPvHealthLevel
>
levelList
,
Double
healthIndex
)
{
String
levelDesc
=
"安全"
;
for
(
IdxBizPvHealthLevel
item
:
levelList
)
{
if
(
item
.
getGroupUpperLimit
()
>=
healthIndex
&&
item
.
getGroupLowerLimit
()
<
healthIndex
)
{
levelDesc
=
item
.
getHealthLevel
();
break
;
}
}
return
levelDesc
;
}
private
void
saveBatchPv
(
List
<
PvHealthIndex
>
pvHealthIndices
,
String
tableName
,
String
recDate
,
String
analysisType
,
List
<
IdxBizPvHealthLevel
>
levelList
)
{
ArrayList
<
PvHealthIndex
>
newList
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
pvHealthIndices
.
size
();
i
++)
{
PvHealthIndex
item
=
pvHealthIndices
.
get
(
i
);
item
.
setRecDate
(
recDate
);
item
.
setAnalysisTime
(
recDate
);
item
.
setAnalysisType
(
analysisType
);
item
.
setHealthLevel
(
getHealthLevelByScorePv
(
levelList
,
item
.
getHealthIndex
()));
//分批次处理
newList
.
add
(
item
);
//循环将数据填入载体list
if
(
500
==
newList
.
size
()
||
i
==
pvHealthIndices
.
size
()
-
1
)
{
//载体list达到要求,进行批量操作
//调用批量插入
pvHealthIndexMapper
.
saveBatchHealthIndexList
(
newList
,
tableName
);
newList
.
clear
();
//每次批量操作后,清空载体list,等待下次的数据填入
}
}
}
}
}
}
amos-boot-system-jxiop/amos-boot-module-jxiop-analyse-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/tdMapper2/FanHealthIndexMapper.java
View file @
4f8cd398
...
@@ -25,4 +25,41 @@ public interface FanHealthIndexMapper extends BaseMapper<FanHealthIndex> {
...
@@ -25,4 +25,41 @@ public interface FanHealthIndexMapper extends BaseMapper<FanHealthIndex> {
List
<
FanHealthIndexDay
>
selectData
(
@Param
(
"healthLevel"
)
String
healthLevel
,
@Param
(
"area"
)
String
area
,
@Param
(
"equipmentName"
)
String
equipmentName
,
@Param
(
"subSystem"
)
String
subSystem
,
@Param
(
"analysisType"
)
String
analysisType
,
@Param
(
"analysisObjType"
)
String
analysisObjType
,
@Param
(
"station"
)
String
station
,
@Param
(
"pointName"
)
String
pointName
,
@Param
(
"indexAddress"
)
String
indexAddress
,
@Param
(
"startTimeTop"
)
String
startTimeTop
,
@Param
(
"endTimeTop"
)
String
endTimeTop
);
List
<
FanHealthIndexDay
>
selectData
(
@Param
(
"healthLevel"
)
String
healthLevel
,
@Param
(
"area"
)
String
area
,
@Param
(
"equipmentName"
)
String
equipmentName
,
@Param
(
"subSystem"
)
String
subSystem
,
@Param
(
"analysisType"
)
String
analysisType
,
@Param
(
"analysisObjType"
)
String
analysisObjType
,
@Param
(
"station"
)
String
station
,
@Param
(
"pointName"
)
String
pointName
,
@Param
(
"indexAddress"
)
String
indexAddress
,
@Param
(
"startTimeTop"
)
String
startTimeTop
,
@Param
(
"endTimeTop"
)
String
endTimeTop
);
int
saveBatchHealthIndexList
(
@Param
(
"list"
)
List
<
FanHealthIndex
>
list
,
@Param
(
"tableName"
)
String
tableName
);
int
saveBatchHealthIndexList
(
@Param
(
"list"
)
List
<
FanHealthIndex
>
list
,
@Param
(
"tableName"
)
String
tableName
);
/**
* 测点
*
* @return
*/
List
<
FanHealthIndex
>
getInfoListByGroupByCdFan
(
@Param
(
"startTime"
)
String
startTime
,
@Param
(
"tableName"
)
String
tableName
,
@Param
(
"analysisObjectType"
)
String
analysisObjectType
);
/**
* 子系统
*/
List
<
FanHealthIndex
>
getInfoListByGroupByZxtFan
(
@Param
(
"startTime"
)
String
startTime
,
@Param
(
"tableName"
)
String
tableName
,
@Param
(
"analysisObjectType"
)
String
analysisObjectType
);
/**
* 设备
*/
List
<
FanHealthIndex
>
getInfoListByGroupBySbFan
(
@Param
(
"startTime"
)
String
startTime
,
@Param
(
"tableName"
)
String
tableName
,
@Param
(
"analysisObjectType"
)
String
analysisObjectType
);
/**
* 场站
*/
List
<
FanHealthIndex
>
getInfoListByGroupByCzFan
(
@Param
(
"startTime"
)
String
startTime
,
@Param
(
"tableName"
)
String
tableName
,
@Param
(
"analysisObjectType"
)
String
analysisObjectType
);
/**
* 区域
*/
List
<
FanHealthIndex
>
getInfoListByGroupByQyFan
(
@Param
(
"startTime"
)
String
startTime
,
@Param
(
"tableName"
)
String
tableName
,
@Param
(
"analysisObjectType"
)
String
analysisObjectType
);
}
}
amos-boot-system-jxiop/amos-boot-module-jxiop-analyse-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/tdMapper2/PvHealthIndexMapper.java
View file @
4f8cd398
...
@@ -3,6 +3,7 @@ package com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2;
...
@@ -3,6 +3,7 @@ package com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanHealthIndex
;
import
com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanHealthIndex
;
import
com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvHealthIndex
;
import
com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvHealthIndex
;
import
com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndex
;
import
com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndexDay
;
import
com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndexDay
;
import
com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvHealthIndex
;
import
com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvHealthIndex
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
...
@@ -28,4 +29,23 @@ public interface PvHealthIndexMapper extends BaseMapper<PvHealthIndex> {
...
@@ -28,4 +29,23 @@ public interface PvHealthIndexMapper extends BaseMapper<PvHealthIndex> {
int
saveBatchHealthIndexList
(
@Param
(
"list"
)
List
<
PvHealthIndex
>
list
,
@Param
(
"tableName"
)
String
tableName
);
int
saveBatchHealthIndexList
(
@Param
(
"list"
)
List
<
PvHealthIndex
>
list
,
@Param
(
"tableName"
)
String
tableName
);
List
<
PvHealthIndex
>
getInfoListByGroupByCdPv
(
@Param
(
"startTime"
)
String
startTime
,
@Param
(
"tableName"
)
String
tableName
,
@Param
(
"analysisObjectType"
)
String
analysisObjectType
);
List
<
PvHealthIndex
>
getInfoListByGroupBySbPv
(
@Param
(
"startTime"
)
String
startTime
,
@Param
(
"tableName"
)
String
tableName
,
@Param
(
"analysisObjectType"
)
String
analysisObjectType
);
List
<
PvHealthIndex
>
getInfoListByGroupByZzPv
(
@Param
(
"startTime"
)
String
startTime
,
@Param
(
"tableName"
)
String
tableName
,
@Param
(
"analysisObjectType"
)
String
analysisObjectType
);
List
<
PvHealthIndex
>
getInfoListByGroupByCzPv
(
@Param
(
"startTime"
)
String
startTime
,
@Param
(
"tableName"
)
String
tableName
,
@Param
(
"analysisObjectType"
)
String
analysisObjectType
);
List
<
PvHealthIndex
>
getInfoListByGroupByQyPv
(
@Param
(
"startTime"
)
String
startTime
,
@Param
(
"tableName"
)
String
tableName
,
@Param
(
"analysisObjectType"
)
String
analysisObjectType
);
}
}
amos-boot-system-jxiop/amos-boot-module-jxiop-analyse-biz/src/main/resources/mapper/tdengine2/FanHealthIndex.xml
View file @
4f8cd398
...
@@ -32,4 +32,124 @@
...
@@ -32,4 +32,124 @@
)
)
</foreach>
</foreach>
</insert>
</insert>
<select
id=
"getInfoListByGroupByCdFan"
resultType=
"com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndex"
>
select
index_address,
gateway_id ,
station,
analysis_obj_type,
analysis_obj_seq,
weight,
area,
sub_system,
number,
equipment_name,
avg(anomaly) as anomaly,
point_name,
kks,
AVG(health_index) as health_index
from
#{tableName}
where
analysis_obj_type = #{analysisObjectType}
and ts > #{startTime}
group by
gateway_id,
index_address,
station,
analysis_obj_type,
analysis_obj_seq,
weight,
area,
sub_system,
number,
equipment_name,
point_name,
kks
</select>
<select
id=
"getInfoListByGroupByZxtFan"
resultType=
"com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndex"
>
select
gateway_id ,
station,
'子系统' as analysis_obj_type,
area,
sub_system,
equipment_name,
avg(anomaly) as anomaly,
AVG(health_index) as health_index
from
#{tableName}
where
analysis_obj_type = #{analysisObjectType}
and ts > #{startTime}
group by
gateway_id,
station,
analysis_obj_type,
area,
sub_system,
equipment_name
</select>
<select
id=
"getInfoListByGroupBySbFan"
resultType=
"com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndex"
>
select
gateway_id ,
station,
'设备' as analysis_obj_type,
area,
number,
equipment_name,
avg(anomaly) as anomaly,
AVG(health_index) as health_index
from
#{tableName}
where
analysis_obj_type = #{analysisObjectType}
and ts > #{startTime}
group by
gateway_id,
station,
analysis_obj_type,
area,
number,
equipment_name
</select>
<select
id=
"getInfoListByGroupByCzFan"
resultType=
"com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndex"
>
select
gateway_id,
station,
'场站' as analysis_obj_type,
area,
avg(anomaly) as anomaly,
AVG(health_index) as health_index
from
#{tableName}
where
analysis_obj_type = #{analysisObjectType}
and ts > #{startTime}
group by
gateway_id,
station,
analysis_obj_type,
area
</select>
<select
id=
"getInfoListByGroupByQyFan"
resultType=
"com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndex"
>
select
'片区' as analysis_obj_type,
area,
avg(anomaly) as anomaly,
AVG(health_index) as health_index
from
#{tableName}
where
analysis_obj_type = #{analysisObjectType}
and ts > #{startTime}
group by
analysis_obj_type,
area
</select>
</mapper>
</mapper>
amos-boot-system-jxiop/amos-boot-module-jxiop-analyse-biz/src/main/resources/mapper/tdengine2/PvHealthIndex.xml
View file @
4f8cd398
...
@@ -66,4 +66,124 @@
...
@@ -66,4 +66,124 @@
)
)
</foreach>
</foreach>
</insert>
</insert>
<select
id=
"getInfoListByGroupByCdPv"
resultType=
"com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvHealthIndex"
>
select
index_address,
gateway_id ,
station,
'测点' as analysis_obj_type,
analysis_obj_seq,
weight,
area,
subarray,
manufacturer,
equipment_name,
avg(anomaly) as anomaly,
point_name,
device_type,
kks,
AVG(health_index) as health_index
from
#{tableName}
where
analysis_obj_type = #{analysisObjectType}
and ts > #{startTime}
group by
gateway_id,
index_address,
station,
analysis_obj_type,
analysis_obj_seq,
weight,
area,
subarray,
manufacturer,
equipment_name,
point_name,
device_type,
kks
</select>
<select
id=
"getInfoListByGroupBySbPv"
resultType=
"com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvHealthIndex"
>
select
gateway_id ,
station,
'设备' as analysis_obj_type,
area,
subarray,
equipment_name,
avg(anomaly) as anomaly,
AVG(health_index) as health_index
from
#{tableName}
where
analysis_obj_type = #{analysisObjectType}
and ts > #{startTime}
group by
gateway_id,
station,
analysis_obj_type,
area,
subarray,
equipment_name
</select>
<select
id=
"getInfoListByGroupByZzPv"
resultType=
"com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvHealthIndex"
>
select
gateway_id ,
station,
'子阵' as analysis_obj_type,
area,
subarray,
avg(anomaly) as anomaly,
AVG(health_index) as health_index
from
#{tableName}
where
analysis_obj_type = #{analysisObjectType}
and ts > #{startTime}
group by
gateway_id,
station,
analysis_obj_type,
area,
subarray
</select>
<select
id=
"getInfoListByGroupByCzPv"
resultType=
"com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvHealthIndex"
>
select
gateway_id ,
station,
'场站' as analysis_obj_type,
area,
avg(anomaly) as anomaly,
AVG(health_index) as health_index
from
#{tableName}
where
analysis_obj_type = #{analysisObjectType}
and ts > #{startTime}
group by
gateway_id,
station,
analysis_obj_type,
area
</select>
<select
id=
"getInfoListByGroupByQyPv"
resultType=
"com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvHealthIndex"
>
select
'片区' as analysis_obj_type,
area,
avg(anomaly) as anomaly,
AVG(health_index) as health_index
from
#{tableName}
where
analysis_obj_type = #{analysisObjectType}
and ts > #{startTime}
group by
analysis_obj_type,
area
</select>
</mapper>
</mapper>
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