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
9a511b95
Commit
9a511b95
authored
Oct 18, 2023
by
tangwei
Browse files
Options
Browse Files
Download
Plain Diff
解决冲突
parents
667d7fd7
11f51182
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
736 additions
and
175 deletions
+736
-175
BigScreenAnalyseController.java
...dule/jxiop/biz/controller/BigScreenAnalyseController.java
+13
-0
WarningRecordStatusMessage.java
...oot/module/jxiop/biz/emqx/WarningRecordStatusMessage.java
+2
-2
WarningRecordStatusMessage2.java
...ot/module/jxiop/biz/emqx/WarningRecordStatusMessage2.java
+3
-3
HealthStatusIndicatorServiceImpl.java
...op/biz/service/impl/HealthStatusIndicatorServiceImpl.java
+61
-18
IdxBizFanHealthIndexMapper.xml
...n/resources/mapper/cluster/IdxBizFanHealthIndexMapper.xml
+5
-5
PersonQrCodeController.java
...t/module/jxiop/biz/controller/PersonQrCodeController.java
+5
-5
SjglZsjZsbtzMapper.xml
.../src/main/resources/mapper/cluster/SjglZsjZsbtzMapper.xml
+3
-3
EquipmentsJxiopDocMysql.java
...boot/module/jxiop/api/entity/EquipmentsJxiopDocMysql.java
+76
-0
EquipmentsJxiopDocMysqlMapper.java
...odule/jxiop/api/mapper/EquipmentsJxiopDocMysqlMapper.java
+7
-0
DemoController.java
...amos/boot/module/jxiop/biz/controller/DemoController.java
+167
-131
EquipmentsJxiopDocMysql.java
...boot/module/jxiop/biz/entity/EquipmentsJxiopDocMysql.java
+76
-0
EsEntity.java
...m/yeejoin/amos/boot/module/jxiop/biz/entity/EsEntity.java
+31
-0
MonitorFanIndicatorImpl.java
...odule/jxiop/biz/service/impl/MonitorFanIndicatorImpl.java
+39
-8
ElasticSearchUtil.java
...n/amos/boot/module/jxiop/biz/utils/ElasticSearchUtil.java
+248
-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/BigScreenAnalyseController.java
View file @
9a511b95
...
...
@@ -977,4 +977,17 @@ public class BigScreenAnalyseController extends BaseController {
}
return
ResponseHelper
.
buildResponse
(
maps
);
}
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
value
=
"风电-场站风速"
)
@GetMapping
(
"/getFanWindSpeedInfo"
)
public
ResponseModel
<
Map
<
String
,
String
>>
getFanWindSpeedInfo
(
@RequestParam
(
"stationId"
)
String
stationId
)
throws
Exception
{
if
(
StrUtil
.
isNotEmpty
(
stationId
))
{
StationBasic
stationBasic
=
stationBasicMapper
.
selectById
(
stationId
);
stationId
=
stationBasic
.
getFanGatewayId
();
}
return
ResponseHelper
.
buildResponse
(
null
);
}
}
amos-boot-system-jxiop/amos-boot-module-jxiop-analyse-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/emqx/WarningRecordStatusMessage.java
View file @
9a511b95
...
...
@@ -71,14 +71,14 @@ public class WarningRecordStatusMessage extends EmqxListener {
public
void
jxIopUpdate
(
JSONObject
analysisResult
)
{
log
.
info
(
"修改预警状态信息:{}"
,
analysisResult
);
if
(
ObjectUtils
.
isNotEmpty
(
analysisResult
)
&&
analysisResult
.
get
(
"warningObjectType"
).
toString
().
equals
(
"
pv
"
))
{
if
(
ObjectUtils
.
isNotEmpty
(
analysisResult
)
&&
analysisResult
.
get
(
"warningObjectType"
).
toString
().
equals
(
"
fan
"
))
{
LambdaUpdateWrapper
<
IdxBizFanWarningRecord
>
lambda
=
new
LambdaUpdateWrapper
<>();
lambda
.
set
(
IdxBizFanWarningRecord:
:
getDisposotionState
,
"已处置"
);
lambda
.
set
(
IdxBizFanWarningRecord:
:
getStatus
,
"1"
);
lambda
.
set
(
IdxBizFanWarningRecord:
:
getDisposotionDate
,
new
Date
());
lambda
.
eq
(
IdxBizFanWarningRecord:
:
getSequenceNbr
,
analysisResult
.
get
(
"objectId"
));
idxBizFanWarningRecordService
.
update
(
lambda
);
}
else
if
(
ObjectUtils
.
isNotEmpty
(
analysisResult
)
&&
analysisResult
.
get
(
"warningObjectType"
).
toString
().
equals
(
"
fan
"
))
{
}
else
if
(
ObjectUtils
.
isNotEmpty
(
analysisResult
)
&&
analysisResult
.
get
(
"warningObjectType"
).
toString
().
equals
(
"
pv
"
))
{
LambdaUpdateWrapper
<
IdxBizPvWarningRecord
>
lambda
=
new
LambdaUpdateWrapper
<>();
lambda
.
set
(
IdxBizPvWarningRecord:
:
getDisposotionState
,
"已处置"
);
lambda
.
set
(
IdxBizPvWarningRecord:
:
getStatus
,
"1"
);
...
...
amos-boot-system-jxiop/amos-boot-module-jxiop-analyse-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/emqx/WarningRecordStatusMessage2.java
View file @
9a511b95
...
...
@@ -77,7 +77,7 @@ public class WarningRecordStatusMessage2 extends EmqxListener {
public
void
jxIopUpdate
(
JSONObject
analysisResult
)
{
log
.
info
(
"修改预警状态信息:{}"
,
analysisResult
);
if
(
ObjectUtils
.
isNotEmpty
(
analysisResult
)
&&
analysisResult
.
get
(
"warningObjectType"
).
toString
().
equals
(
"
pv
"
))
{
if
(
ObjectUtils
.
isNotEmpty
(
analysisResult
)
&&
analysisResult
.
get
(
"warningObjectType"
).
toString
().
equals
(
"
fan
"
))
{
LambdaUpdateWrapper
<
IdxBizFanWarningRecord
>
lambda
=
new
LambdaUpdateWrapper
<>();
lambda
.
set
(
IdxBizFanWarningRecord:
:
getDisposotionState
,
"已处置"
);
lambda
.
set
(
IdxBizFanWarningRecord:
:
getStatus
,
"1"
);
...
...
@@ -85,13 +85,13 @@ public class WarningRecordStatusMessage2 extends EmqxListener {
List
<
String
>
traceIds
=
(
List
<
String
>)
analysisResult
.
get
(
"traceIds"
);
lambda
.
in
(
IdxBizFanWarningRecord:
:
getSequenceNbr
,
traceIds
);
idxBizFanWarningRecordService
.
update
(
lambda
);
}
else
if
(
ObjectUtils
.
isNotEmpty
(
analysisResult
)
&&
analysisResult
.
get
(
"warningObjectType"
).
toString
().
equals
(
"
fan
"
))
{
}
else
if
(
ObjectUtils
.
isNotEmpty
(
analysisResult
)
&&
analysisResult
.
get
(
"warningObjectType"
).
toString
().
equals
(
"
pv
"
))
{
LambdaUpdateWrapper
<
IdxBizPvWarningRecord
>
lambda
=
new
LambdaUpdateWrapper
<>();
lambda
.
set
(
IdxBizPvWarningRecord:
:
getDisposotionState
,
"已处置"
);
lambda
.
set
(
IdxBizPvWarningRecord:
:
getStatus
,
"1"
);
lambda
.
set
(
IdxBizPvWarningRecord:
:
getDisposotionDate
,
new
Date
());
List
<
String
>
traceIds
=
(
List
<
String
>)
analysisResult
.
get
(
"traceIds"
);
lambda
.
eq
(
IdxBizPvWarningRecord:
:
getSequenceNbr
,
traceIds
);
lambda
.
in
(
IdxBizPvWarningRecord:
:
getSequenceNbr
,
traceIds
);
idxBizPvWarningRecordService
.
update
(
lambda
);
}
}
...
...
amos-boot-system-jxiop/amos-boot-module-jxiop-analyse-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/service/impl/HealthStatusIndicatorServiceImpl.java
View file @
9a511b95
...
...
@@ -12,6 +12,7 @@ import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper;
import
com.yeejoin.amos.boot.module.jxiop.biz.Enum.WarningNameEnum
;
import
com.yeejoin.amos.boot.module.jxiop.biz.entity.*
;
import
com.yeejoin.amos.boot.module.jxiop.biz.mapper2.*
;
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.Value
;
...
...
@@ -28,6 +29,7 @@ import java.util.*;
import
java.util.stream.Collectors
;
@EnableScheduling
@Service
@Slf4j
public
class
HealthStatusIndicatorServiceImpl
{
// @Value("${healthValue_Warn}")
...
...
@@ -130,7 +132,15 @@ public class HealthStatusIndicatorServiceImpl {
Map
<
String
,
Map
<
String
,
List
<
IdxBizPvHealthIndex
>>>
gateWayMaps
=
healthIndices
.
stream
().
collect
(
Collectors
.
groupingBy
(
IdxBizPvHealthIndex:
:
getGatewayId
,
Collectors
.
groupingBy
(
IdxBizPvHealthIndex:
:
getIndexAddress
)));
List
<
IdxBizPvWarningRecord
>
idxBizPvWarningRecordList
=
new
ArrayList
<>();
HashMap
<
String
,
StationBasic
>
stationMap
=
new
HashMap
<>();
for
(
String
gateWayId
:
gateWayMaps
.
keySet
())
{
LambdaQueryWrapper
<
StationBasic
>
basicLambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
basicLambdaQueryWrapper
.
eq
(
StationBasic:
:
getFanGatewayId
,
gateWayId
);
basicLambdaQueryWrapper
.
last
(
"limit 1"
);
StationBasic
stationBasic
=
stationBasicMapper
.
selectOne
(
basicLambdaQueryWrapper
);
stationMap
.
put
(
gateWayId
,
stationBasic
);
Map
<
String
,
List
<
IdxBizPvHealthIndex
>>
healthDataMaps
=
gateWayMaps
.
get
(
gateWayId
);
for
(
String
address
:
healthDataMaps
.
keySet
())
{
List
<
IdxBizPvHealthIndex
>
idxBizPvHealthIndices
=
healthDataMaps
.
get
(
address
);
...
...
@@ -225,7 +235,7 @@ public class HealthStatusIndicatorServiceImpl {
}
idxBizPvWarningRecordService
.
saveBatch
(
idxBizPvWarningRecordList
);
// 触发风险模型生成预警处置模块的预警记录
fetchDataPv
(
idxBizPvWarningRecordList
);
fetchDataPv
(
idxBizPvWarningRecordList
,
stationMap
);
}
...
...
@@ -261,7 +271,15 @@ public class HealthStatusIndicatorServiceImpl {
Map
<
String
,
Map
<
String
,
List
<
IdxBizPvHealthIndex
>>>
gateWayMaps
=
healthIndices
.
stream
().
collect
(
Collectors
.
groupingBy
(
IdxBizPvHealthIndex:
:
getGatewayId
,
Collectors
.
groupingBy
(
IdxBizPvHealthIndex:
:
getIndexAddress
)));
List
<
IdxBizPvWarningRecord
>
idxBizPvWarningRecordList
=
new
ArrayList
<>();
HashMap
<
String
,
StationBasic
>
stationMap
=
new
HashMap
<>();
for
(
String
gateWayId
:
gateWayMaps
.
keySet
())
{
LambdaQueryWrapper
<
StationBasic
>
basicLambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
basicLambdaQueryWrapper
.
eq
(
StationBasic:
:
getFanGatewayId
,
gateWayId
);
basicLambdaQueryWrapper
.
last
(
"limit 1"
);
StationBasic
stationBasic
=
stationBasicMapper
.
selectOne
(
basicLambdaQueryWrapper
);
stationMap
.
put
(
gateWayId
,
stationBasic
);
Map
<
String
,
List
<
IdxBizPvHealthIndex
>>
healthDataMaps
=
gateWayMaps
.
get
(
gateWayId
);
for
(
String
address
:
healthDataMaps
.
keySet
())
{
List
<
IdxBizPvHealthIndex
>
idxBizPvHealthIndices
=
healthDataMaps
.
get
(
address
);
...
...
@@ -359,7 +377,7 @@ public class HealthStatusIndicatorServiceImpl {
}
idxBizPvWarningRecordService
.
saveBatch
(
idxBizPvWarningRecordList
);
// 触发风险模型生成预警处置模块的预警记录
fetchDataPv
(
idxBizPvWarningRecordList
);
fetchDataPv
(
idxBizPvWarningRecordList
,
stationMap
);
}
/***
...
...
@@ -394,7 +412,15 @@ public class HealthStatusIndicatorServiceImpl {
List
<
IdxBizPvWarningRuleSet
>
idxBizPvWarningRules
=
idxBizPvWarningRuleSetMapper
.
selectList
(
queryWrapper
);
Map
<
String
,
Map
<
String
,
List
<
IdxBizPvHealthIndex
>>>
gateWayMaps
=
healthIndices
.
stream
().
collect
(
Collectors
.
groupingBy
(
IdxBizPvHealthIndex:
:
getGatewayId
,
Collectors
.
groupingBy
(
IdxBizPvHealthIndex:
:
getIndexAddress
)));
List
<
IdxBizPvWarningRecord
>
idxBizPvWarningRecordList
=
new
ArrayList
<>();
HashMap
<
String
,
StationBasic
>
stationMap
=
new
HashMap
<>();
for
(
String
gateWayId
:
gateWayMaps
.
keySet
())
{
LambdaQueryWrapper
<
StationBasic
>
basicLambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
basicLambdaQueryWrapper
.
eq
(
StationBasic:
:
getFanGatewayId
,
gateWayId
);
basicLambdaQueryWrapper
.
last
(
"limit 1"
);
StationBasic
stationBasic
=
stationBasicMapper
.
selectOne
(
basicLambdaQueryWrapper
);
stationMap
.
put
(
gateWayId
,
stationBasic
);
Map
<
String
,
List
<
IdxBizPvHealthIndex
>>
healthDataMaps
=
gateWayMaps
.
get
(
gateWayId
);
for
(
String
address
:
healthDataMaps
.
keySet
())
{
List
<
IdxBizPvHealthIndex
>
idxBizPvHealthIndices
=
healthDataMaps
.
get
(
address
);
...
...
@@ -488,7 +514,7 @@ public class HealthStatusIndicatorServiceImpl {
}
idxBizPvWarningRecordService
.
saveBatch
(
idxBizPvWarningRecordList
);
// 触发风险模型生成预警处置模块的预警记录
fetchDataPv
(
idxBizPvWarningRecordList
);
fetchDataPv
(
idxBizPvWarningRecordList
,
stationMap
);
}
...
...
@@ -519,7 +545,14 @@ public class HealthStatusIndicatorServiceImpl {
Map
<
String
,
Map
<
String
,
List
<
IdxBizFanHealthIndex
>>>
gateWayMaps
=
healthIndices
.
stream
().
collect
(
Collectors
.
groupingBy
(
IdxBizFanHealthIndex:
:
getGatewayId
,
Collectors
.
groupingBy
(
IdxBizFanHealthIndex:
:
getIndexAddress
)));
List
<
IdxBizFanWarningRecord
>
idxBizFanWarningRecordList
=
new
ArrayList
<>();
HashMap
<
String
,
StationBasic
>
stationMap
=
new
HashMap
<>();
for
(
String
gateWayId
:
gateWayMaps
.
keySet
())
{
LambdaQueryWrapper
<
StationBasic
>
basicLambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
basicLambdaQueryWrapper
.
eq
(
StationBasic:
:
getFanGatewayId
,
gateWayId
);
basicLambdaQueryWrapper
.
last
(
"limit 1"
);
StationBasic
stationBasic
=
stationBasicMapper
.
selectOne
(
basicLambdaQueryWrapper
);
stationMap
.
put
(
gateWayId
,
stationBasic
);
Map
<
String
,
List
<
IdxBizFanHealthIndex
>>
healthDataMaps
=
gateWayMaps
.
get
(
gateWayId
);
for
(
String
address
:
healthDataMaps
.
keySet
())
{
List
<
IdxBizFanHealthIndex
>
idxBizFanHealthIndices
=
healthDataMaps
.
get
(
address
);
...
...
@@ -620,7 +653,7 @@ public class HealthStatusIndicatorServiceImpl {
}
idxBizFanWarningRecordService
.
saveBatch
(
idxBizFanWarningRecordList
);
// 触发风险模型生成预警处置模块的预警记录
fetchDataFan
(
idxBizFanWarningRecordList
);
fetchDataFan
(
idxBizFanWarningRecordList
,
stationMap
);
}
/***
...
...
@@ -655,7 +688,15 @@ public class HealthStatusIndicatorServiceImpl {
Map
<
String
,
Map
<
String
,
List
<
IdxBizFanHealthIndex
>>>
gateWayMaps
=
healthIndices
.
stream
().
collect
(
Collectors
.
groupingBy
(
IdxBizFanHealthIndex:
:
getGatewayId
,
Collectors
.
groupingBy
(
IdxBizFanHealthIndex:
:
getIndexAddress
)));
List
<
IdxBizFanWarningRecord
>
idxBizFanWarningRecordList
=
new
ArrayList
<>();
HashMap
<
String
,
StationBasic
>
stationMap
=
new
HashMap
<>();
for
(
String
gateWayId
:
gateWayMaps
.
keySet
())
{
LambdaQueryWrapper
<
StationBasic
>
basicLambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
basicLambdaQueryWrapper
.
eq
(
StationBasic:
:
getFanGatewayId
,
gateWayId
);
basicLambdaQueryWrapper
.
last
(
"limit 1"
);
StationBasic
stationBasic
=
stationBasicMapper
.
selectOne
(
basicLambdaQueryWrapper
);
stationMap
.
put
(
gateWayId
,
stationBasic
);
Map
<
String
,
List
<
IdxBizFanHealthIndex
>>
healthDataMaps
=
gateWayMaps
.
get
(
gateWayId
);
for
(
String
address
:
healthDataMaps
.
keySet
())
{
List
<
IdxBizFanHealthIndex
>
idxBizFanHealthIndices
=
healthDataMaps
.
get
(
address
);
...
...
@@ -749,7 +790,7 @@ public class HealthStatusIndicatorServiceImpl {
}
idxBizFanWarningRecordService
.
saveBatch
(
idxBizFanWarningRecordList
);
// 触发风险模型生成预警处置模块的预警记录
fetchDataFan
(
idxBizFanWarningRecordList
);
fetchDataFan
(
idxBizFanWarningRecordList
,
stationMap
);
}
/***
...
...
@@ -784,7 +825,15 @@ public class HealthStatusIndicatorServiceImpl {
Map
<
String
,
Map
<
String
,
List
<
IdxBizFanHealthIndex
>>>
gateWayMaps
=
healthIndices
.
stream
().
collect
(
Collectors
.
groupingBy
(
IdxBizFanHealthIndex:
:
getGatewayId
,
Collectors
.
groupingBy
(
IdxBizFanHealthIndex:
:
getIndexAddress
)));
List
<
IdxBizFanWarningRecord
>
idxBizFanWarningRecordList
=
new
ArrayList
<>();
HashMap
<
String
,
StationBasic
>
stationMap
=
new
HashMap
<>();
for
(
String
gateWayId
:
gateWayMaps
.
keySet
())
{
LambdaQueryWrapper
<
StationBasic
>
basicLambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
basicLambdaQueryWrapper
.
eq
(
StationBasic:
:
getFanGatewayId
,
gateWayId
);
basicLambdaQueryWrapper
.
last
(
"limit 1"
);
StationBasic
stationBasic
=
stationBasicMapper
.
selectOne
(
basicLambdaQueryWrapper
);
stationMap
.
put
(
gateWayId
,
stationBasic
);
Map
<
String
,
List
<
IdxBizFanHealthIndex
>>
healthDataMaps
=
gateWayMaps
.
get
(
gateWayId
);
for
(
String
address
:
healthDataMaps
.
keySet
())
{
List
<
IdxBizFanHealthIndex
>
idxBizFanHealthIndices
=
healthDataMaps
.
get
(
address
);
...
...
@@ -882,7 +931,7 @@ public class HealthStatusIndicatorServiceImpl {
idxBizFanWarningRecordService
.
saveBatch
(
idxBizFanWarningRecordList
);
// 触发风险模型生成预警处置模块的预警记录
fetchDataFan
(
idxBizFanWarningRecordList
);
fetchDataFan
(
idxBizFanWarningRecordList
,
stationMap
);
}
...
...
@@ -892,7 +941,8 @@ public class HealthStatusIndicatorServiceImpl {
* @return
*/
@Async
public
void
fetchDataPv
(
List
<
IdxBizPvWarningRecord
>
idxBizPvWarningRecords
)
{
public
void
fetchDataPv
(
List
<
IdxBizPvWarningRecord
>
idxBizPvWarningRecords
,
HashMap
<
String
,
StationBasic
>
stationMap
)
{
log
.
info
(
"===开始触发风险预警模型===数量为:{}"
,
idxBizPvWarningRecords
.
size
());
idxBizPvWarningRecords
.
stream
().
forEach
(
idxBizPvWarningRecord
->
{
BizMessage
bizMessage
=
new
BizMessage
();
bizMessage
.
setIndexKey
(
INDEX_KEY_PV
);
...
...
@@ -901,11 +951,7 @@ public class HealthStatusIndicatorServiceImpl {
RiskBizInfoVo
riskBizInfoVo
=
new
RiskBizInfoVo
();
riskBizInfoVo
.
setWarningObjectName
(
idxBizPvWarningRecord
.
getEquipmentName
());
riskBizInfoVo
.
setWarningObjectCode
(
idxBizPvWarningRecord
.
getSequenceNbr
());
LambdaQueryWrapper
<
StationBasic
>
basicLambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
basicLambdaQueryWrapper
.
eq
(
StationBasic:
:
getFanGatewayId
,
idxBizPvWarningRecord
.
getGatewayId
());
basicLambdaQueryWrapper
.
last
(
"limit 1"
);
StationBasic
stationBasic
=
stationBasicMapper
.
selectOne
(
basicLambdaQueryWrapper
);
riskBizInfoVo
.
setSourceAttribution
(
stationBasic
.
getProjectOrgCode
());
riskBizInfoVo
.
setSourceAttribution
(
stationMap
.
get
(
idxBizPvWarningRecord
.
getGatewayId
()).
getProjectOrgCode
());
riskBizInfoVo
.
setSourceAttributionDesc
(
idxBizPvWarningRecord
.
getStation
());
riskBizInfoVo
.
setWarningObjectType
(
"pv"
);
List
<
RiskDynamicDetailsVo
>
detailsVos
=
new
ArrayList
<>();
...
...
@@ -929,7 +975,8 @@ public class HealthStatusIndicatorServiceImpl {
* @return
*/
@Async
public
void
fetchDataFan
(
List
<
IdxBizFanWarningRecord
>
idxBizFanWarningRecords
)
{
public
void
fetchDataFan
(
List
<
IdxBizFanWarningRecord
>
idxBizFanWarningRecords
,
HashMap
<
String
,
StationBasic
>
stationMap
)
{
log
.
info
(
"===开始触发风险预警模型===数量为:{}"
,
idxBizFanWarningRecords
.
size
());
idxBizFanWarningRecords
.
stream
().
forEach
(
idxBizFanWarningRecord
->
{
BizMessage
bizMessage
=
new
BizMessage
();
bizMessage
.
setIndexKey
(
String
.
format
(
INDEX_KEY_FAN
,
idxBizFanWarningRecord
.
getNumber
()));
...
...
@@ -938,11 +985,7 @@ public class HealthStatusIndicatorServiceImpl {
RiskBizInfoVo
riskBizInfoVo
=
new
RiskBizInfoVo
();
riskBizInfoVo
.
setWarningObjectName
(
idxBizFanWarningRecord
.
getEquipmentName
());
riskBizInfoVo
.
setWarningObjectCode
(
idxBizFanWarningRecord
.
getSequenceNbr
());
LambdaQueryWrapper
<
StationBasic
>
basicLambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
basicLambdaQueryWrapper
.
eq
(
StationBasic:
:
getFanGatewayId
,
idxBizFanWarningRecord
.
getGatewayId
());
basicLambdaQueryWrapper
.
last
(
"limit 1"
);
StationBasic
stationBasic
=
stationBasicMapper
.
selectOne
(
basicLambdaQueryWrapper
);
riskBizInfoVo
.
setSourceAttribution
(
stationBasic
.
getProjectOrgCode
());
riskBizInfoVo
.
setSourceAttribution
(
stationMap
.
get
(
idxBizFanWarningRecord
.
getGatewayId
()).
getProjectOrgCode
());
riskBizInfoVo
.
setSourceAttributionDesc
(
idxBizFanWarningRecord
.
getStation
());
riskBizInfoVo
.
setWarningObjectType
(
"fan"
);
List
<
RiskDynamicDetailsVo
>
detailsVos
=
new
ArrayList
<>();
...
...
amos-boot-system-jxiop/amos-boot-module-jxiop-analyse-biz/src/main/resources/mapper/cluster/IdxBizFanHealthIndexMapper.xml
View file @
9a511b95
...
...
@@ -4,7 +4,7 @@
<select
id=
"getHealthScoreInfo"
resultType=
"java.math.BigDecimal"
>
SELECT
avg( a.avgHealthIndex
) AS healthIndex
round(avg( a.avgHealthIndex ), 2
) AS healthIndex
FROM
(
SELECT
...
...
@@ -57,7 +57,7 @@
<select
id=
"getHealthScoreInfoByStation"
resultType=
"java.math.BigDecimal"
>
SELECT
IFNULL( HEALTH_INDEX , 100
) AS healthIndex
round(IFNULL( HEALTH_INDEX , 100 ), 2
) AS healthIndex
FROM
${tableName}
<where>
...
...
@@ -211,7 +211,7 @@
WARNING_NAME
) a
ORDER BY
a.allNum
DESC
a.allNum
desc
</select>
...
...
@@ -307,7 +307,7 @@
warningName
having pointName IS NOT NULL
AND pointName != ''
order by num
de
sc
order by num
a
sc
</select>
<select
id=
"getAllEquipAlarmInfoAnalysisByArea"
resultType=
"java.util.Map"
>
...
...
@@ -349,7 +349,7 @@
WHERE
a.pointName IS NOT NULL
AND a.pointName != ''
order by a.num
desc
order by a.num
ASC
</select>
<select
id=
"getSubSystemInfo"
resultType=
"java.util.Map"
>
...
...
amos-boot-system-jxiop/amos-boot-module-jxiop-bigscreen-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/controller/PersonQrCodeController.java
View file @
9a511b95
...
...
@@ -165,10 +165,10 @@ public class PersonQrCodeController extends BaseController {
}
else
if
(
"job"
.
equals
(
dataType
))
{
countAll
=
sjglZsjZsbtzMapper
.
getJobYardByPageCount
(
parentCode
,
null
,
null
,
null
);
}
result
.
put
(
"red
ToGreen
Percent"
,
getPercent
(
new
BigDecimal
(
red
),
new
BigDecimal
(
countAll
)));
result
.
put
(
"redPercent"
,
getPercent
(
new
BigDecimal
(
redToGreen
),
new
BigDecimal
(
countAll
)));
result
.
put
(
"yellow
ToGreen
Percent"
,
getPercent
(
new
BigDecimal
(
yellow
),
new
BigDecimal
(
countAll
)));
result
.
put
(
"yellowPercent"
,
getPercent
(
new
BigDecimal
(
yellowToGreen
),
new
BigDecimal
(
countAll
)));
result
.
put
(
"redPercent"
,
getPercent
(
new
BigDecimal
(
red
),
new
BigDecimal
(
countAll
)));
result
.
put
(
"red
ToGreen
Percent"
,
getPercent
(
new
BigDecimal
(
redToGreen
),
new
BigDecimal
(
countAll
)));
result
.
put
(
"yellowPercent"
,
getPercent
(
new
BigDecimal
(
yellow
),
new
BigDecimal
(
countAll
)));
result
.
put
(
"yellow
ToGreen
Percent"
,
getPercent
(
new
BigDecimal
(
yellowToGreen
),
new
BigDecimal
(
countAll
)));
return
ResponseHelper
.
buildResponse
(
result
);
}
return
ResponseHelper
.
buildResponse
(
null
);
...
...
@@ -217,7 +217,7 @@ public class PersonQrCodeController extends BaseController {
* @return 百分比
*/
private
double
getPercent
(
BigDecimal
numerator
,
BigDecimal
denominator
)
{
BigDecimal
multiply
=
numerator
.
divide
(
denominator
.
compareTo
(
BigDecimal
.
ZERO
)
!=
0
?
denominator
:
new
BigDecimal
(
1
),
4
,
BigDecimal
.
ROUND_
DOWN
).
multiply
(
new
BigDecimal
(
100
));
BigDecimal
multiply
=
numerator
.
divide
(
denominator
.
compareTo
(
BigDecimal
.
ZERO
)
!=
0
?
denominator
:
new
BigDecimal
(
1
),
4
,
BigDecimal
.
ROUND_
HALF_UP
).
multiply
(
new
BigDecimal
(
100
));
return
Math
.
abs
(
multiply
.
doubleValue
());
}
...
...
amos-boot-system-jxiop/amos-boot-module-jxiop-bigscreen-biz/src/main/resources/mapper/cluster/SjglZsjZsbtzMapper.xml
View file @
9a511b95
...
...
@@ -101,8 +101,8 @@
ifnull(a.SBMC, '') as objectName ,
ifnull(a.QRCODE_COLOR, '') AS qrCodeColor,
ifnull(b.COMPANY_NAME, '') AS stationName,
ifnull(a.UPDATE_
TIME
, '') as recDate,
SBBM as objectId
ifnull(a.UPDATE_
STAMP
, '') as recDate,
a.
SBBM as objectId
FROM
sjgl_zsj_zsbtz a
INNER JOIN privilege_company b ON a.WERKS = b.COMPANY_CODE and b.IS_DELETED = false AND b.`LEVEL` = 'station'
...
...
@@ -120,7 +120,7 @@
AND a.QRCODE_COLOR != #{ne}
</if>
</where>
ORDER BY a.
CREATE_TIME
DESC
ORDER BY a.
UPDATE_STAMP
DESC
limit #{current},#{size}
</select>
...
...
amos-boot-system-jxiop/amos-boot-module-jxiop-monitor-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/api/entity/EquipmentsJxiopDocMysql.java
0 → 100644
View file @
9a511b95
package
com
.
yeejoin
.
amos
.
boot
.
module
.
jxiop
.
api
.
entity
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
io.github.classgraph.json.Id
;
import
lombok.Data
;
import
lombok.experimental.Accessors
;
import
java.util.Date
;
/**
* CREATE TABLE `equipments_jxiop_doc_mysql` (
* `id` varchar(50) NOT NULL,
* `address` varchar(50) DEFAULT NULL,
* `equipment_specific_name` varchar(255) DEFAULT NULL,
* `gateway_id` varchar(50) DEFAULT NULL,
* `is_alarm` varchar(20) DEFAULT NULL,
* `created_time` date DEFAULT NULL,
* `unit` varchar(50) DEFAULT NULL,
* `value` varchar(50) DEFAULT NULL,
* `value_F` float DEFAULT NULL,
* `value_label` varchar(255) DEFAULT NULL,
* `trace_id` varchar(50) DEFAULT NULL,
* `equipment_index_name` varchar(255) DEFAULT NULL,
* `equipment_number` varchar(50) DEFAULT NULL,
* `front_module` varchar(200) DEFAULT NULL,
* `system_type` varchar(200) DEFAULT NULL,
* `picture_name` varchar(255) DEFAULT NULL,
* `display_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
* `data_type` varchar(50) DEFAULT NULL,
* PRIMARY KEY (`id`)
* ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
*/
@Data
@Accessors
(
chain
=
true
)
@TableName
(
"equipments_jxiop_doc_mysql"
)
public
class
EquipmentsJxiopDocMysql
{
@Id
private
String
id
;
@TableField
(
"address"
)
private
String
address
;
@TableField
(
"data_type"
)
private
String
dataType
;
@TableField
(
"equipment_specific_name"
)
private
String
equipmentSpecificName
;
@TableField
(
"gateway_id"
)
private
String
gatewayId
;
@TableField
(
"is_alarm"
)
private
String
isAlarm
;
@TableField
(
"created_time"
)
private
Date
createdTime
;
@TableField
(
"unit"
)
private
String
unit
;
@TableField
(
"value"
)
private
String
value
;
@TableField
(
"value_F"
)
private
Float
valueF
;
@TableField
(
"value_label"
)
private
String
valueLabel
;
@TableField
(
"trace_id"
)
private
String
traceId
;
@TableField
(
"equipment_index_name"
)
private
String
equipmentIndexName
;
@TableField
(
"equipment_number"
)
private
String
equipmentNumber
;
@TableField
(
"front_module"
)
private
String
frontModule
;
@TableField
(
"system_type"
)
private
String
systemType
;
@TableField
(
"picture_name"
)
private
String
pictureName
;
@TableField
(
"display_name"
)
private
String
displayName
;
}
amos-boot-system-jxiop/amos-boot-module-jxiop-monitor-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/api/mapper/EquipmentsJxiopDocMysqlMapper.java
0 → 100644
View file @
9a511b95
package
com
.
yeejoin
.
amos
.
boot
.
module
.
jxiop
.
api
.
mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.yeejoin.amos.boot.module.jxiop.biz.entity.EquipmentsJxiopDocMysql
;
public
interface
EquipmentsJxiopDocMysqlMapper
extends
BaseMapper
<
EquipmentsJxiopDocMysql
>
{
}
amos-boot-system-jxiop/amos-boot-module-jxiop-monitor-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/controller/DemoController.java
View file @
9a511b95
...
...
@@ -2,20 +2,24 @@ package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.yeejoin.amos.boot.biz.common.controller.BaseController
;
import
com.yeejoin.amos.boot.module.jxiop.api.entity.MonitorFanIndicator
;
import
com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic
;
import
com.yeejoin.amos.boot.module.jxiop.api.mapper.EquipmentsJxiopDocMysqlMapper
;
import
com.yeejoin.amos.boot.module.jxiop.api.mapper.MonitorFanIndicatorMapper
;
import
com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESEquipments
;
import
com.yeejoin.amos.boot.module.jxiop.biz.dto.IndicatorsDto
;
import
com.yeejoin.amos.boot.module.jxiop.biz.dto.QueryDto
;
import
com.yeejoin.amos.boot.module.jxiop.biz.dto.StationCacheInfoDto
;
import
com.yeejoin.amos.boot.module.jxiop.biz.entity.EquipmentsJxiopDocMysql
;
import
com.yeejoin.amos.boot.module.jxiop.biz.entity.Test
;
import
com.yeejoin.amos.boot.module.jxiop.biz.repository.ESEquipmentsRepository
;
import
com.yeejoin.amos.boot.module.jxiop.biz.service.impl.*
;
//import com.yeejoin.amos.boot.module.jxiop.biz.utils.InfluxDButils;
//import com.yeejoin.amos.component.influxdb.InfluxDbConnection;
import
com.yeejoin.amos.boot.module.jxiop.biz.utils.ElasticSearchUtil
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
...
...
@@ -32,12 +36,15 @@ import org.elasticsearch.search.aggregations.metrics.ParsedSum;
import
org.elasticsearch.search.aggregations.metrics.SumAggregationBuilder
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate
;
import
org.springframework.data.elasticsearch.core.SearchHits
;
import
org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder
;
import
org.springframework.data.elasticsearch.core.query.Query
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.web.bind.annotation.*
;
import
org.typroject.tyboot.component.emq.EmqKeeper
;
import
org.typroject.tyboot.core.foundation.enumeration.UserType
;
...
...
@@ -55,53 +62,48 @@ import java.util.concurrent.TimeUnit;
@Api
(
tags
=
"Demo-test"
)
@RequestMapping
(
value
=
"/demo"
)
public
class
DemoController
extends
BaseController
{
Logger
logger
=
LoggerFactory
.
getLogger
(
DemoController
.
class
);
@Autowired
StationBasicServiceImpl
stationBasicServiceimpl
;
@Autowired
TestServiceImpl
testServiceimpl
;
// @Autowired
// LargeScreenImpl largeScreenImpl;
private
final
String
ss
=
"瞬时风速"
;
private
final
String
zfs
=
"WTX-801_25_WTX-801_总辐射"
;
private
final
String
zfslj
=
"WTX-801_25_WTX-801_总辐射累计"
;
// @Resource
// InfluxDbConnection influxDbConnection;
// @Autowired
// @Autowired
// InfluxDButils influxDButils;
private
final
String
dayvalue
=
"日发电量"
;
private
final
String
moonValue
=
"月发电量"
;
private
final
String
yearValue
=
"年发电量"
;
private
final
String
dayDateFormat
=
"yyyy-MM-dd"
;
private
final
String
moonDateFormat
=
"yyyy-MM"
;
private
final
String
yearDateFormat
=
"yyyy"
;
// @Autowired
// PowerGenerationImpl powerGenerationImpl;
private
final
String
dayType
=
"day"
;
private
final
String
moonType
=
"moon"
;
private
final
String
yearType
=
"year"
;
Logger
logger
=
LoggerFactory
.
getLogger
(
DemoController
.
class
);
@Autowired
EmqKeeper
emqKeeper
;
StationBasicServiceImpl
stationBasicServiceimpl
;
@Autowired
private
MonitorFanIndicatorMapper
monitorFanIndicatorregionMapper
;
TestServiceImpl
testServiceimpl
;
@Autowired
private
ElasticsearchRestTemplate
elasticsearchTemplate
;
EmqKeeper
emqKeeper
;
@Autowired
ESEquipmentsRepository
equipmentsRepository
;
ESEquipmentsRepository
equipmentsRepository
;
@Autowired
CommonServiceImpl
commonServiceImpl
;
// @Autowired
// PowerGenerationImpl powerGenerationImpl;
// @Autowired
// LargeScreenImpl largeScreenImpl;
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
dayvalue
=
"日发电量"
;
private
final
String
moonValue
=
"月发电量"
;
private
final
String
yearValue
=
"年发电量"
;
private
final
String
dayDateFormat
=
"yyyy-MM-dd"
;
private
final
String
moonDateFormat
=
"yyyy-MM"
;
private
final
String
yearDateFormat
=
"yyyy"
;
private
final
String
dayType
=
"day"
;
private
final
String
moonType
=
"moon"
;
private
final
String
yearType
=
"year"
;
@Autowired
ElasticSearchUtil
elasticSearchUtil
;
@Autowired
private
MonitorFanIndicatorMapper
monitorFanIndicatorregionMapper
;
@Autowired
private
ElasticsearchRestTemplate
elasticsearchTemplate
;
@Autowired
private
EquipmentsJxiopDocMysqlMapper
equipmentsJxiopDocMysqlMapper
;
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
value
=
"手动更新场站缓存信息接口"
)
...
...
@@ -111,15 +113,13 @@ public class DemoController extends BaseController {
try
{
}
catch
(
Exception
e
)
{
updateResult
=
"更新场站信息缓存成功"
;
updateResult
=
"更新场站信息缓存成功"
;
throw
new
RuntimeException
(
e
);
}
return
updateResult
;
}
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
value
=
"demo测试prodcutcion 库"
)
@GetMapping
(
"/test"
)
...
...
@@ -151,12 +151,12 @@ public class DemoController extends BaseController {
@GetMapping
(
"doc/test4"
)
public
ResponseModel
<
Integer
>
demoTest3
()
{
//数据说明 夏造风电、泰和光伏、夏造升压站、泰和升压站
String
[]
strings
=
{
"1668801435891929089"
,
"1669524885619085313"
,
"1668801570352926721"
,
"1669525017559306241"
};
String
[]
strings
=
{
"1668801435891929089"
,
"1669524885619085313"
,
"1668801570352926721"
,
"1669525017559306241"
};
// String [] strings = {"1669524885619085313"};
// Object o=this.monitorFanIndicatorImpl.getIndicatoralueAvage("1668801435891929089","60秒平均风速");
// System.out.println(o.toString());
elasticsearchTemplate
.
deleteIndex
(
ESEquipments
.
class
);
int
num
=
0
;
int
num
=
0
;
for
(
int
i
=
0
;
i
<
strings
.
length
;
i
++)
{
QueryWrapper
<
MonitorFanIndicator
>
QueryWrapper
=
new
QueryWrapper
<>();
// 夏造风电
...
...
@@ -166,29 +166,29 @@ public class DemoController extends BaseController {
long
DATE
=
new
Date
().
getTime
();
System
.
out
.
println
(
DATE
);
List
<
MonitorFanIndicator
>
list
=
monitorFanIndicatorregionMapper
.
selectList
(
QueryWrapper
);
num
=
num
+
list
.
size
();
List
<
ESEquipments
>
listit
=
new
ArrayList
<>();
num
=
num
+
list
.
size
();
List
<
ESEquipments
>
listit
=
new
ArrayList
<>();
for
(
MonitorFanIndicator
monitorFanIndicator
:
list
)
{
ESEquipments
eSEquipments
=
new
ESEquipments
(
ESEquipments
eSEquipments
=
new
ESEquipments
(
null
,
monitorFanIndicator
.
getAddressGateway
(),
monitorFanIndicator
.
getIndexAddress
(),
monitorFanIndicator
.
getDataType
(),
monitorFanIndicator
.
getFanCode
(),
monitorFanIndicator
.
getGateway
(),
monitorFanIndicator
.
getIsAlarm
(),
new
Date
(),
monitorFanIndicator
.
getUnit
(),
""
,
""
,
""
,
monitorFanIndicator
.
getIndicator
(),
monitorFanIndicator
.
getEquipmentNumber
(),
monitorFanIndicator
.
getFrontModule
(),
monitorFanIndicator
.
getSystemType
(),
monitorFanIndicator
.
getPictureName
(),
monitorFanIndicator
.
getEquipmentNumber
());
monitorFanIndicator
.
getAddressGateway
(),
monitorFanIndicator
.
getIndexAddress
(),
monitorFanIndicator
.
getDataType
(),
monitorFanIndicator
.
getFanCode
(),
monitorFanIndicator
.
getGateway
(),
monitorFanIndicator
.
getIsAlarm
(),
new
Date
(),
monitorFanIndicator
.
getUnit
(),
""
,
""
,
""
,
monitorFanIndicator
.
getIndicator
(),
monitorFanIndicator
.
getEquipmentNumber
(),
monitorFanIndicator
.
getFrontModule
(),
monitorFanIndicator
.
getSystemType
(),
monitorFanIndicator
.
getPictureName
(),
monitorFanIndicator
.
getEquipmentNumber
());
listit
.
add
(
eSEquipments
);
...
...
@@ -223,6 +223,51 @@ public class DemoController extends BaseController {
}
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
value
=
"从ES获取数据反向插入mysql"
)
@GetMapping
(
"doc/getDatafromEsToMysql"
)
public
void
getDatafromEsToMysql
()
{
try
{
List
<
ESEquipments
>
result
=
elasticSearchUtil
.
searchResponse
(
"jxiop_equipments"
,
null
,
hit
->
JSONObject
.
parseObject
(
hit
.
getSourceAsString
(),
ESEquipments
.
class
));
result
.
forEach
(
esEquipments
->
{
EquipmentsJxiopDocMysql
equipmentsJxiopDocMysql
=
new
EquipmentsJxiopDocMysql
();
BeanUtils
.
copyProperties
(
esEquipments
,
equipmentsJxiopDocMysql
);
if
(
ObjectUtils
.
isEmpty
(
equipmentsJxiopDocMysqlMapper
.
selectList
(
new
QueryWrapper
<
EquipmentsJxiopDocMysql
>().
eq
(
"id"
,
equipmentsJxiopDocMysql
.
getId
())))){
equipmentsJxiopDocMysqlMapper
.
insert
(
equipmentsJxiopDocMysql
);
}
else
{
equipmentsJxiopDocMysqlMapper
.
updateById
(
equipmentsJxiopDocMysql
);
}
});
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
}
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
value
=
"从Mysql同步数据到ES"
)
@GetMapping
(
"doc/getDatafromMySqlToES"
)
public
void
getDatafromMySqlToES
()
{
List
<
EquipmentsJxiopDocMysql
>
equipmentsJxiopDocMysqlList
=
equipmentsJxiopDocMysqlMapper
.
selectList
(
new
QueryWrapper
<
EquipmentsJxiopDocMysql
>().
like
(
"front_module"
,
"泰和功率预测"
));
equipmentsJxiopDocMysqlList
.
forEach
(
equipmentsJxiopDocMysql
->
{
ESEquipments
esEquipments
=
equipmentsRepository
.
findById
(
equipmentsJxiopDocMysql
.
getId
()).
get
();
//更新显示名称
esEquipments
.
setDisplayName
(
equipmentsJxiopDocMysql
.
getDisplayName
());
//更新排序号
esEquipments
.
setTraceId
(
equipmentsJxiopDocMysql
.
getTraceId
());
//更新单位
esEquipments
.
setUnit
(
equipmentsJxiopDocMysql
.
getUnit
());
//更新frontModule
esEquipments
.
setFrontModule
(
equipmentsJxiopDocMysql
.
getFrontModule
());
//更新systemType
esEquipments
.
setSystemType
(
equipmentsJxiopDocMysql
.
getSystemType
());
//更新图片名称
// esEquipments.setPictureName(equipmentsJxiopDocMysql.getPictureName());
equipmentsRepository
.
save
(
esEquipments
);
});
}
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
value
=
"测试消息发送"
)
@GetMapping
(
"/test5"
)
public
void
demoTest4
()
{
...
...
@@ -243,12 +288,12 @@ public class DemoController extends BaseController {
@GetMapping
(
"/test6"
)
public
ResponseModel
<
Integer
>
demoTest5
()
{
//数据说明 夏造风电、泰和光伏、夏造升压站、泰和升压站
String
[]
strings
=
{
"1668801570352926721"
,
"1669525017559306241"
};
String
[]
strings
=
{
"1668801570352926721"
,
"1669525017559306241"
};
// String [] strings = {"1669525017559306241"};
// Object o=this.monitorFanIndicatorImpl.getIndicatoralueAvage("1668801435891929089","60秒平均风速");
// System.out.println(o.toString());
int
num
=
0
;
int
num
=
0
;
for
(
int
i
=
0
;
i
<
strings
.
length
;
i
++)
{
QueryWrapper
<
MonitorFanIndicator
>
QueryWrapper
=
new
QueryWrapper
<>();
// 夏造风电
...
...
@@ -258,13 +303,13 @@ public class DemoController extends BaseController {
long
DATE
=
new
Date
().
getTime
();
System
.
out
.
println
(
DATE
);
List
<
MonitorFanIndicator
>
list
=
monitorFanIndicatorregionMapper
.
selectList
(
QueryWrapper
);
num
=
num
+
list
.
size
();
num
=
num
+
list
.
size
();
List
<
ESEquipments
>
listit
=
new
ArrayList
<>();
List
<
ESEquipments
>
listit
=
new
ArrayList
<>();
for
(
MonitorFanIndicator
monitorFanIndicator
:
list
)
{
ESEquipments
eSEquipments
=
new
ESEquipments
(
ESEquipments
eSEquipments
=
new
ESEquipments
(
null
,
monitorFanIndicator
.
getAddressGateway
(),
monitorFanIndicator
.
getIndexAddress
(),
...
...
@@ -275,23 +320,18 @@ public class DemoController extends BaseController {
new
Date
(),
monitorFanIndicator
.
getUnit
(),
""
,
""
,
""
,
""
,
monitorFanIndicator
.
getIndicator
(),
monitorFanIndicator
.
getEquipmentNumber
(),
monitorFanIndicator
.
getFrontModule
(),
monitorFanIndicator
.
getSystemType
(),
monitorFanIndicator
.
getPictureName
(),
monitorFanIndicator
.
getEquipmentNumber
()
);
monitorFanIndicator
.
getEquipmentNumber
());
listit
.
add
(
eSEquipments
);
// Map<String, String> tag = new HashMap<>();
// Map<String, Object> maps2 = new HashMap<>();
//
...
...
@@ -330,6 +370,7 @@ public class DemoController extends BaseController {
return
ResponseHelper
.
buildResponse
(
hashMap
);
}
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
value
=
"测试求和"
)
@GetMapping
(
"/test8"
)
...
...
@@ -347,6 +388,7 @@ public class DemoController extends BaseController {
return
ResponseHelper
.
buildResponse
(
search
);
}
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
value
=
"测试平均数"
)
@GetMapping
(
"/test9"
)
...
...
@@ -374,14 +416,13 @@ public class DemoController extends BaseController {
QueryBuilder
queryBuilder
=
QueryBuilders
.
matchQuery
(
"equipmentIndexName"
,
"年发电量"
);
// 如果只对一个字段进行分组写一个就好
TermsAggregationBuilder
tb1
=
AggregationBuilders
.
terms
(
"group_gatewayId"
).
field
(
"gatewayId.keyword"
);
//gatewayId 是分组字段名,group_gatewayId是查询结果的别名
// TermsAggregationBuilder tb2 = AggregationBuilders.terms("group_equipmentNumber").field("equipmentNumber.keyword");//equipmentNumber 是分组字段名,group_equipmentNumber是查询结果的别名
SumAggregationBuilder
sb
=
AggregationBuilders
.
sum
(
"sum_valueDouble"
).
field
(
"valueF"
);
//valueF是求和字段名称,sun_valueDouble是结果别名
// 注意顺序,决定先通过谁分组
tb1
.
subAggregation
(
sb
);
// 通过typeId字段分组统计总数
tb1
.
subAggregation
(
sb
);
// 通过typeId字段分组统计总数
// tb2.subAggregation(sb); // 通过houseId字段分组统计总数
// tb1.subAggregation(tb2); // 合并
...
...
@@ -403,19 +444,20 @@ public class DemoController extends BaseController {
@GetMapping
(
"/test11"
)
public
Map
demoTest11
()
{
List
<
QueryDto
>
queryDto
=
new
ArrayList
<>();
QueryDto
ff1
=
new
QueryDto
(
"gatewayId.keyword"
,
"1668801435891929089"
);
QueryDto
ff2
=
new
QueryDto
(
"equipmentIndexName.keyword"
,
"有功功率"
);
List
<
QueryDto
>
queryDto
=
new
ArrayList
<>();
QueryDto
ff1
=
new
QueryDto
(
"gatewayId.keyword"
,
"1668801435891929089"
);
QueryDto
ff2
=
new
QueryDto
(
"equipmentIndexName.keyword"
,
"有功功率"
);
queryDto
.
add
(
ff1
);
queryDto
.
add
(
ff2
);
Double
avg
=
commonServiceImpl
.
getavg
(
queryDto
,
"valueF"
,
ESEquipments
.
class
);
Double
sum
=
commonServiceImpl
.
getsum
(
queryDto
,
"valueF"
,
ESEquipments
.
class
);
Double
avg
=
commonServiceImpl
.
getavg
(
queryDto
,
"valueF"
,
ESEquipments
.
class
);
Double
sum
=
commonServiceImpl
.
getsum
(
queryDto
,
"valueF"
,
ESEquipments
.
class
);
Map
<
String
,
Double
>
map
=
new
HashMap
();
map
.
put
(
"1668801435891929089_avg"
,
avg
);
map
.
put
(
"1668801435891929089_sum"
,
sum
);
Map
<
String
,
Double
>
map
=
new
HashMap
();
map
.
put
(
"1668801435891929089_avg"
,
avg
);
map
.
put
(
"1668801435891929089_sum"
,
sum
);
return
map
;
}
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
value
=
"取缓存数据"
)
@GetMapping
(
"/test12"
)
...
...
@@ -424,34 +466,31 @@ public class DemoController extends BaseController {
}
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
value
=
"分组平均数"
)
@GetMapping
(
"/test13"
)
public
Map
demoTest13
()
{
List
<
String
>
value
=
new
ArrayList
<>();
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
);
Map
<
String
,
List
<
String
>>
map
=
new
HashMap
<>();
map
.
put
(
"equipmentIndexName.keyword"
,
value
);
// List<String> value1=new ArrayList<>();
// value1.add("1668801435891929089");
// map.put("gatewayId.keyword",value1);
List
<?
extends
Terms
.
Bucket
>
lidate
=
commonServiceImpl
.
getgroupavg
(
map
,
"valueF"
,
"equipmentIndexName.keyword"
,
ESEquipments
.
class
);
List
<?
extends
Terms
.
Bucket
>
lidate
=
commonServiceImpl
.
getgroupavg
(
map
,
"valueF"
,
"equipmentIndexName.keyword"
,
ESEquipments
.
class
);
Map
<
String
,
Object
>
mapdta
=
new
HashMap
<>();
Map
<
String
,
Object
>
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
;
Aggregations
aggregation
=
bucket
.
getAggregations
();
List
<
Aggregation
>
listdata
=
Objects
.
nonNull
(
aggregation
)
?
aggregation
.
asList
()
:
null
;
for
(
Aggregation
agg
:
listdata
)
{
ParsedAvg
parsedAvg
=(
ParsedAvg
)
agg
;
ParsedAvg
parsedAvg
=
(
ParsedAvg
)
agg
;
mapdta
.
put
(
bucket
.
getKeyAsString
(),
format2
.
format
(
parsedAvg
.
getValue
()));
}
}
...
...
@@ -459,31 +498,30 @@ public class DemoController extends BaseController {
}
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
value
=
"分组求和数"
)
@GetMapping
(
"/test14"
)
public
Map
demoTest14
()
{
List
<
String
>
value
=
new
ArrayList
<>();
List
<
String
>
value
=
new
ArrayList
<>();
value
.
add
(
"年发电量"
);
Map
<
String
,
List
<
String
>>
map
=
new
HashMap
<>();
map
.
put
(
"equipmentIndexName.keyword"
,
value
);
List
<
String
>
value1
=
new
ArrayList
<>();
value1
.
add
(
"1668801435891929089"
);
map
.
put
(
"gatewayId.keyword"
,
value1
);
Map
<
String
,
List
<
String
>>
map
=
new
HashMap
<>();
map
.
put
(
"equipmentIndexName.keyword"
,
value
);
List
<
String
>
value1
=
new
ArrayList
<>();
value1
.
add
(
"1668801435891929089"
);
map
.
put
(
"gatewayId.keyword"
,
value1
);
List
<?
extends
Terms
.
Bucket
>
lidate
=
commonServiceImpl
.
getgroupsum
(
map
,
"valueF"
,
"equipmentIndexName.keyword"
,
ESEquipments
.
class
);
List
<?
extends
Terms
.
Bucket
>
lidate
=
commonServiceImpl
.
getgroupsum
(
map
,
"valueF"
,
"equipmentIndexName.keyword"
,
ESEquipments
.
class
);
Map
<
String
,
Object
>
mapdta
=
new
HashMap
<>();
Map
<
String
,
Object
>
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
;
Aggregations
aggregation
=
bucket
.
getAggregations
();
List
<
Aggregation
>
listdata
=
Objects
.
nonNull
(
aggregation
)
?
aggregation
.
asList
()
:
null
;
for
(
Aggregation
agg
:
listdata
)
{
ParsedSum
parsedSum
=(
ParsedSum
)
agg
;
ParsedSum
parsedSum
=
(
ParsedSum
)
agg
;
mapdta
.
put
(
bucket
.
getKeyAsString
(),
format2
.
format
(
parsedSum
.
getValue
()));
}
}
...
...
@@ -532,47 +570,47 @@ public class DemoController extends BaseController {
@GetMapping
(
"/test17"
)
public
ResponseModel
<
Integer
>
demoTest17
()
{
//数据说明 夏造风电、泰和光伏、夏造升压站、泰和升压站
String
[]
strings
=
{
"1668801570352926721"
,
"1669525017559306241"
};
String
[]
strings
=
{
"1668801570352926721"
,
"1669525017559306241"
};
// Object o=this.monitorFanIndicatorImpl.getIndicatoralueAvage("1668801435891929089","60秒平均风速");
// System.out.println(o.toString());
int
num
=
0
;
int
num
=
0
;
for
(
int
i
=
0
;
i
<
strings
.
length
;
i
++)
{
QueryWrapper
<
MonitorFanIndicator
>
QueryWrapper
=
new
QueryWrapper
<>();
// 夏造风电
// QueryWrapper.eq("gateway", "1668801435891929089");
// 泰和光伏
QueryWrapper
.
eq
(
"gateway"
,
strings
[
i
]);
QueryWrapper
.
eq
(
"front_module"
,
"电量表计"
);
QueryWrapper
.
eq
(
"system_type"
,
"模拟量"
);
QueryWrapper
.
eq
(
"front_module"
,
"电量表计"
);
QueryWrapper
.
eq
(
"system_type"
,
"模拟量"
);
long
DATE
=
new
Date
().
getTime
();
System
.
out
.
println
(
DATE
);
List
<
MonitorFanIndicator
>
list
=
monitorFanIndicatorregionMapper
.
selectList
(
QueryWrapper
);
num
=
num
+
list
.
size
();
num
=
num
+
list
.
size
();
List
<
ESEquipments
>
listit
=
new
ArrayList
<>();
List
<
ESEquipments
>
listit
=
new
ArrayList
<>();
for
(
MonitorFanIndicator
monitorFanIndicator
:
list
)
{
Map
<
String
,
String
>
tag
=
new
HashMap
<>();
Map
<
String
,
Object
>
maps2
=
new
HashMap
<>();
tag
.
put
(
"equipmentsIdx"
,
monitorFanIndicator
.
getAddressGateway
());
// maps2.put("address", monitorFanIndicator.getIndexAddress());
// maps2.put("dataType", monitorFanIndicator.getDataType());
// maps2.put("equipmentSpecificName", monitorFanIndicator.getFanCode());
// maps2.put("gatewayId", monitorFanIndicator.getGateway());
// maps2.put("isAlarm", monitorFanIndicator.getIsAlarm());
// maps2.put("createdTime", "2023-07-05 18:30:26");
// maps2.put("unit", monitorFanIndicator.getUnit());
// maps2.put("value", "");
// maps2.put("traceId", "");
// maps2.put("equipmentIndexName", monitorFanIndicator.getIndicator());
// maps2.put("equipmentNumber", monitorFanIndicator.getEquipmentNumber());
maps2
.
put
(
"frontModule"
,
"模拟量"
);
// maps2.put("systemType", monitorFanIndicator.getSystemType());
// maps2.put("pictureName", monitorFanIndicator.getPictureName());
// maps2.put("address", monitorFanIndicator.getIndexAddress());
// maps2.put("dataType", monitorFanIndicator.getDataType());
// maps2.put("equipmentSpecificName", monitorFanIndicator.getFanCode());
// maps2.put("gatewayId", monitorFanIndicator.getGateway());
// maps2.put("isAlarm", monitorFanIndicator.getIsAlarm());
// maps2.put("createdTime", "2023-07-05 18:30:26");
// maps2.put("unit", monitorFanIndicator.getUnit());
// maps2.put("value", "");
// maps2.put("traceId", "");
// maps2.put("equipmentIndexName", monitorFanIndicator.getIndicator());
// maps2.put("equipmentNumber", monitorFanIndicator.getEquipmentNumber());
maps2
.
put
(
"frontModule"
,
"模拟量"
);
// maps2.put("systemType", monitorFanIndicator.getSystemType());
// maps2.put("pictureName", monitorFanIndicator.getPictureName());
//升压站的字段显示名称
// maps2.put("displayName", monitorFanIndicator.getEquipmentNumber());
// maps2.put("displayName", monitorFanIndicator.getEquipmentNumber());
// influxDbConnection.insert("indicators_" + monitorFanIndicator.getGateway(), tag, maps2,1688558007051L, TimeUnit.MILLISECONDS);
}
}
...
...
@@ -580,8 +618,6 @@ public class DemoController extends BaseController {
}
// @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
// @ApiOperation(value = "分组求和数")
// @GetMapping("/test18")
...
...
@@ -619,9 +655,9 @@ public class DemoController extends BaseController {
@ApiOperation
(
value
=
"es获取数据"
)
@GetMapping
(
"/test19"
)
public
void
test19
()
{
Map
<
String
,
List
<
String
>>
queryConditon
=
new
HashMap
<>();
queryConditon
.
put
(
"equipmentIndexName.keyword"
,
Arrays
.
asList
(
"日发电量"
,
"月发电量"
,
"年发电量"
));
commonServiceImpl
.
getListDataByCondtions
(
queryConditon
,
null
,
ESEquipments
.
class
);
Map
<
String
,
List
<
String
>>
queryConditon
=
new
HashMap
<>();
queryConditon
.
put
(
"equipmentIndexName.keyword"
,
Arrays
.
asList
(
"日发电量"
,
"月发电量"
,
"年发电量"
));
commonServiceImpl
.
getListDataByCondtions
(
queryConditon
,
null
,
ESEquipments
.
class
);
}
}
amos-boot-system-jxiop/amos-boot-module-jxiop-monitor-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/entity/EquipmentsJxiopDocMysql.java
0 → 100644
View file @
9a511b95
package
com
.
yeejoin
.
amos
.
boot
.
module
.
jxiop
.
biz
.
entity
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
io.github.classgraph.json.Id
;
import
lombok.Data
;
import
lombok.experimental.Accessors
;
import
java.util.Date
;
/**
* CREATE TABLE `equipments_jxiop_doc_mysql` (
* `id` varchar(50) NOT NULL,
* `address` varchar(50) DEFAULT NULL,
* `equipment_specific_name` varchar(255) DEFAULT NULL,
* `gateway_id` varchar(50) DEFAULT NULL,
* `is_alarm` varchar(20) DEFAULT NULL,
* `created_time` date DEFAULT NULL,
* `unit` varchar(50) DEFAULT NULL,
* `value` varchar(50) DEFAULT NULL,
* `value_F` float DEFAULT NULL,
* `value_label` varchar(255) DEFAULT NULL,
* `trace_id` varchar(50) DEFAULT NULL,
* `equipment_index_name` varchar(255) DEFAULT NULL,
* `equipment_number` varchar(50) DEFAULT NULL,
* `front_module` varchar(200) DEFAULT NULL,
* `system_type` varchar(200) DEFAULT NULL,
* `picture_name` varchar(255) DEFAULT NULL,
* `display_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
* `data_type` varchar(50) DEFAULT NULL,
* PRIMARY KEY (`id`)
* ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
*/
@Data
@Accessors
(
chain
=
true
)
@TableName
(
"equipments_jxiop_doc_mysql"
)
public
class
EquipmentsJxiopDocMysql
{
@Id
private
String
id
;
@TableField
(
"address"
)
private
String
address
;
@TableField
(
"data_type"
)
private
String
dataType
;
@TableField
(
"equipment_specific_name"
)
private
String
equipmentSpecificName
;
@TableField
(
"gateway_id"
)
private
String
gatewayId
;
@TableField
(
"is_alarm"
)
private
String
isAlarm
;
@TableField
(
"created_time"
)
private
Date
createdTime
;
@TableField
(
"unit"
)
private
String
unit
;
@TableField
(
"value"
)
private
String
value
;
@TableField
(
"value_F"
)
private
Float
valueF
;
@TableField
(
"value_label"
)
private
String
valueLabel
;
@TableField
(
"trace_id"
)
private
String
traceId
;
@TableField
(
"equipment_index_name"
)
private
String
equipmentIndexName
;
@TableField
(
"equipment_number"
)
private
String
equipmentNumber
;
@TableField
(
"front_module"
)
private
String
frontModule
;
@TableField
(
"system_type"
)
private
String
systemType
;
@TableField
(
"picture_name"
)
private
String
pictureName
;
@TableField
(
"display_name"
)
private
String
displayName
;
}
amos-boot-system-jxiop/amos-boot-module-jxiop-monitor-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/entity/EsEntity.java
0 → 100644
View file @
9a511b95
package
com
.
yeejoin
.
amos
.
boot
.
module
.
jxiop
.
biz
.
entity
;
import
lombok.Getter
;
/**
*
* @author LiuLin
* @date 2023年10月11日 09:31
*/
@Getter
public
final
class
EsEntity
<
T
>
{
private
String
id
;
private
T
data
;
public
EsEntity
()
{
}
public
EsEntity
(
String
id
,
T
data
)
{
this
.
data
=
data
;
this
.
id
=
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
public
void
setData
(
T
data
)
{
this
.
data
=
data
;
}
}
amos-boot-system-jxiop/amos-boot-module-jxiop-monitor-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/service/impl/MonitorFanIndicatorImpl.java
View file @
9a511b95
...
...
@@ -46,6 +46,7 @@ import org.springframework.util.ObjectUtils;
import
org.typroject.tyboot.component.emq.EmqKeeper
;
import
org.typroject.tyboot.core.foundation.utils.ValidationUtil
;
import
javax.ws.rs.HEAD
;
import
java.io.File
;
import
java.io.IOException
;
import
java.nio.charset.StandardCharsets
;
...
...
@@ -847,16 +848,26 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
}
else
{
likeMap
.
put
(
CommonConstans
.
QueryStringSystemType
,
systemType
);
}
List
<
ESEquipments
>
indicatorsDtoList
=
commonServiceImpl
.
getListDataByCondtionsAndLike
(
queryCondtion
,
null
,
ESEquipments
.
class
,
likeMap
);
// List<ESEquipments> indicatorsDtoList = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class, likeMap);
Integer
traceIdCount
=
indicatorsDtoList
.
stream
().
filter
(
esEquipments
->
!
StringUtils
.
isEmpty
(
esEquipments
.
getTraceId
())).
collect
(
Collectors
.
toList
()).
size
();
List
<
Map
<
String
,
Object
>>
statusMaps
=
new
ArrayList
<>();
for
(
ESEquipments
listDatum
:
indicatorsDtoList
)
{
Map
<
String
,
Object
>
statusMap
=
new
HashMap
<>();
statusMap
.
put
(
"traceId"
,
listDatum
.
getTraceId
());
String
data
=
listDatum
.
getDisplayName
();
if
(
StringUtils
.
isEmpty
(
data
)
||
(!
ObjectUtils
.
isEmpty
(
listDatum
.
getEquipmentNumber
())
&&
data
.
equals
(
listDatum
.
getEquipmentNumber
())))
{
data
=
listDatum
.
getEquipmentIndexName
();
}
statusMap
.
put
(
"displayName"
,
listDatum
.
getDisplayName
());
statusMap
.
put
(
"equipmentIndexName"
,
listDatum
.
getEquipmentIndexName
());
statusMap
.
put
(
"unit"
,
listDatum
.
getUnit
());
statusMap
.
put
(
"value"
,
listDatum
.
getValue
());
statusMap
.
put
(
"addres"
,
listDatum
.
getAddress
());
statusMap
.
put
(
"id"
,
listDatum
.
getId
());
statusMap
.
put
(
"data"
,
data
);
statusMap
.
put
(
"state"
,
listDatum
.
getValue
().
equals
(
"false"
)
?
0
:
1
);
statusMap
.
put
(
"status"
,
listDatum
.
getValue
().
equals
(
"false"
)
?
0
:
1
);
...
...
@@ -866,7 +877,16 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
}
statusMaps
.
add
(
statusMap
);
}
statusMaps
.
sort
(
Comparator
.
comparingLong
(
o
->
Long
.
parseLong
(
o
.
get
(
"addres"
).
toString
())));
Collator
instance
=
Collator
.
getInstance
(
Locale
.
CHINA
);
String
sortField
;
if
(
traceIdCount
==
statusMaps
.
size
()){
sortField
=
"traceId"
;
}
else
{
sortField
=
"addres"
;
}
Collections
.
sort
(
statusMaps
,
(
e1
,
e2
)
->
{
return
instance
.
compare
(
e1
.
get
(
sortField
),
e2
.
get
(
sortField
));
});
return
statusMaps
;
}
...
...
@@ -880,8 +900,15 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
List
<
ESEquipments
>
esEquipmentsList
=
commonServiceImpl
.
getListDataByCondtionsAndLike
(
queryCondtion
,
null
,
ESEquipments
.
class
,
likeMap
);
List
<
ESEquipments
>
listData
=
esEquipmentsList
.
stream
().
filter
(
esEquipments
->
!
esEquipments
.
getDisplayName
().
equals
(
""
)).
collect
(
Collectors
.
toList
());
List
<
Map
<
String
,
Object
>>
statusMaps
=
new
ArrayList
<>();
Integer
traceIdCount
=
listData
.
stream
().
filter
(
esEquipments
->
!
StringUtils
.
isEmpty
(
esEquipments
.
getTraceId
())).
collect
(
Collectors
.
toList
()).
size
();
for
(
ESEquipments
listDatum
:
listData
)
{
Map
<
String
,
Object
>
statusMap
=
new
HashMap
<>();
statusMap
.
put
(
"traceId"
,
listDatum
.
getTraceId
());
statusMap
.
put
(
"displayName"
,
listDatum
.
getDisplayName
());
statusMap
.
put
(
"equipmentIndexName"
,
listDatum
.
getEquipmentIndexName
());
statusMap
.
put
(
"unit"
,
listDatum
.
getUnit
());
statusMap
.
put
(
"value"
,
listDatum
.
getValue
());
statusMap
.
put
(
"id"
,
listDatum
.
getId
());
if
(
StringUtils
.
isEmpty
(
listDatum
.
getValue
()))
{
statusMap
.
put
(
"title"
,
0.00
+
(
StringUtils
.
isNotEmpty
(
listDatum
.
getUnit
())
?
listDatum
.
getUnit
()
:
""
));
}
else
{
...
...
@@ -890,14 +917,16 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
statusMap
.
put
(
"title1"
,
listDatum
.
getDisplayName
());
statusMaps
.
add
(
statusMap
);
}
Collator
instance
=
Collator
.
getInstance
(
Locale
.
CHINA
);
String
sortField
;
if
(
traceIdCount
==
statusMaps
.
size
()){
sortField
=
"traceId"
;
}
else
{
sortField
=
"title1"
;
}
Collections
.
sort
(
statusMaps
,
(
e1
,
e2
)
->
{
return
instance
.
compare
(
e1
.
get
(
"title1"
),
e2
.
get
(
"title1"
));
return
instance
.
compare
(
e1
.
get
(
sortField
),
e2
.
get
(
sortField
));
});
return
statusMaps
;
}
...
...
@@ -2213,8 +2242,10 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
c
=
-
c
;
}
double
pcv
=
c
/
avageValue
;
pcv
=
Double
.
valueOf
(
String
.
format
(
CommonConstans
.
Twodecimalplaces
,
pcv
));
resultMap
.
put
(
"pcv"
,
pcv
);
pcv
=
pcv
*
100
;
pcv
=
Math
.
round
(
pcv
);
//pcv = Double.valueOf(String.format(CommonConstans.Twodecimalplaces, pcv));
resultMap
.
put
(
"pcv"
,
(
int
)
pcv
+
"%"
);
resultList
.
add
(
resultMap
);
}
}
...
...
amos-boot-system-jxiop/amos-boot-module-jxiop-monitor-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/utils/ElasticSearchUtil.java
0 → 100644
View file @
9a511b95
package
com
.
yeejoin
.
amos
.
boot
.
module
.
jxiop
.
biz
.
utils
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.yeejoin.amos.boot.module.jxiop.biz.entity.EsEntity
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.ArrayUtils
;
import
org.elasticsearch.action.ActionListener
;
import
org.elasticsearch.action.DocWriteResponse
;
import
org.elasticsearch.action.bulk.BulkRequest
;
import
org.elasticsearch.action.bulk.BulkResponse
;
import
org.elasticsearch.action.index.IndexRequest
;
import
org.elasticsearch.action.search.ClearScrollRequest
;
import
org.elasticsearch.action.search.SearchRequest
;
import
org.elasticsearch.action.search.SearchResponse
;
import
org.elasticsearch.action.search.SearchScrollRequest
;
import
org.elasticsearch.action.support.WriteRequest
;
import
org.elasticsearch.action.update.UpdateRequest
;
import
org.elasticsearch.action.update.UpdateResponse
;
import
org.elasticsearch.client.RequestOptions
;
import
org.elasticsearch.client.RestHighLevelClient
;
import
org.elasticsearch.common.xcontent.XContentType
;
import
org.elasticsearch.core.TimeValue
;
import
org.elasticsearch.index.query.QueryBuilder
;
import
org.elasticsearch.search.Scroll
;
import
org.elasticsearch.search.SearchHit
;
import
org.elasticsearch.search.builder.SearchSourceBuilder
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.function.Function
;
/**
* @author LiuLin
* @date 2023年08月08日 16:30
*/
@Slf4j
@Component
public
class
ElasticSearchUtil
{
private
static
final
long
SCROLL_TIMEOUT
=
180000
;
private
static
final
int
SIZE
=
1000
;
@Autowired
private
RestHighLevelClient
restHighLevelClient
;
/**
* ES修改数据
*
* @param indexName 索引名称
* @param id 主键
* @param paramJson 参数JSON
* @return
*/
public
boolean
updateData
(
String
indexName
,
String
id
,
String
paramJson
)
{
log
.
info
(
"更新ES数据,value:{}"
,
id
);
UpdateRequest
updateRequest
=
new
UpdateRequest
(
indexName
,
id
);
//如果修改索引中不存在则进行新增
updateRequest
.
docAsUpsert
(
true
);
//立即刷新数据
updateRequest
.
setRefreshPolicy
(
WriteRequest
.
RefreshPolicy
.
IMMEDIATE
);
updateRequest
.
doc
(
paramJson
,
XContentType
.
JSON
);
try
{
UpdateResponse
updateResponse
=
restHighLevelClient
.
update
(
updateRequest
,
RequestOptions
.
DEFAULT
);
//log.info("索引[{}],主键:【{}】操作结果:[{}]", indexName, id, updateResponse.getResult());
if
(
DocWriteResponse
.
Result
.
CREATED
.
equals
(
updateResponse
.
getResult
()))
{
log
.
info
(
"索引:【{}】,主键:【{}】新增成功"
,
indexName
,
id
);
return
true
;
}
else
if
(
DocWriteResponse
.
Result
.
UPDATED
.
equals
(
updateResponse
.
getResult
()))
{
log
.
info
(
"索引:【{}】,主键:【{}】修改成功"
,
indexName
,
id
);
return
true
;
}
else
if
(
DocWriteResponse
.
Result
.
NOOP
.
equals
(
updateResponse
.
getResult
()))
{
log
.
info
(
"索引:[{}],主键:[{}]无变化"
,
indexName
,
id
);
return
true
;
}
}
catch
(
IOException
e
)
{
log
.
error
(
"索引:[{}],主键:【{}】"
,
indexName
,
id
,
e
);
return
false
;
}
return
false
;
}
/**
* 单条更新
*
* @param indexName
* @param id
* @param data
* @return
* @throws IOException
*/
public
boolean
updateData
(
String
indexName
,
String
id
,
Object
data
)
throws
IOException
{
UpdateRequest
updateRequest
=
new
UpdateRequest
(
indexName
,
id
);
//准备文档
String
jsonString
=
JSONObject
.
toJSONString
(
data
);
Map
jsonMap
=
JSONObject
.
parseObject
(
jsonString
,
Map
.
class
);
updateRequest
.
doc
(
jsonMap
);
updateRequest
.
timeout
(
TimeValue
.
timeValueSeconds
(
1
));
updateRequest
.
setRefreshPolicy
(
WriteRequest
.
RefreshPolicy
.
WAIT_UNTIL
);
//数据为存储而不是更新
UpdateResponse
update
=
restHighLevelClient
.
update
(
updateRequest
,
RequestOptions
.
DEFAULT
);
return
update
.
getGetResult
().
equals
(
DocWriteResponse
.
Result
.
UPDATED
);
}
/**
* 必须传递ids集合
*
* @param indexName
* @param idList
* @param map
* @return
*/
public
boolean
update
(
String
indexName
,
List
<
String
>
idList
,
Map
map
)
{
// 创建批量请求
BulkRequest
bulkRequest
=
new
BulkRequest
();
for
(
String
id
:
idList
)
{
UpdateRequest
updateRequest
=
new
UpdateRequest
(
indexName
,
id
).
doc
(
map
);
bulkRequest
.
add
(
updateRequest
);
}
try
{
bulkRequest
.
setRefreshPolicy
(
WriteRequest
.
RefreshPolicy
.
IMMEDIATE
);
BulkResponse
bulk
=
restHighLevelClient
.
bulk
(
bulkRequest
,
RequestOptions
.
DEFAULT
);
return
bulk
.
hasFailures
();
}
catch
(
IOException
e
)
{
return
false
;
}
}
/**
* Description: 批量修改数据
*
* @param index index
* @param list 更新列表
* @author LiuLin
*/
public
<
T
>
void
updateBatch
(
String
index
,
List
<
EsEntity
<
T
>>
list
)
{
BulkRequest
request
=
new
BulkRequest
();
list
.
forEach
(
item
->
request
.
add
(
new
UpdateRequest
(
index
,
item
.
getId
())
.
doc
(
JSON
.
toJSONString
(
item
.
getData
()),
XContentType
.
JSON
)));
try
{
restHighLevelClient
.
bulk
(
request
,
RequestOptions
.
DEFAULT
);
list
.
forEach
(
s
->
log
.
info
(
"===========索引:【{}】,主键:【{}】修改成功"
,
index
,
s
.
getId
()));
}
catch
(
Exception
e
)
{
log
.
error
(
"索引:[{}]"
,
index
,
e
);
}
}
/**
* Description: 批量插入数据
*
* @param index index
* @param list 插入列表
* @author LiuLin
*/
public
<
T
>
void
insertBatch
(
String
index
,
List
<
EsEntity
<
T
>>
list
)
{
BulkRequest
request
=
new
BulkRequest
();
list
.
forEach
(
item
->
request
.
add
(
new
IndexRequest
(
index
).
id
(
item
.
getId
())
.
source
(
JSON
.
toJSONString
(
item
.
getData
()),
XContentType
.
JSON
)));
try
{
restHighLevelClient
.
bulk
(
request
,
RequestOptions
.
DEFAULT
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
}
/**
* ES异步修改数据
*
* @param indexName 索引名称
* @param id 主键
* @param paramJson 参数JSON
*/
public
void
updateDataAsync
(
String
indexName
,
String
id
,
String
paramJson
)
throws
IOException
{
UpdateRequest
updateRequest
=
new
UpdateRequest
(
indexName
,
id
);
updateRequest
.
docAsUpsert
(
true
);
updateRequest
.
setRefreshPolicy
(
WriteRequest
.
RefreshPolicy
.
IMMEDIATE
);
updateRequest
.
doc
(
paramJson
,
XContentType
.
JSON
);
restHighLevelClient
.
updateAsync
(
updateRequest
,
RequestOptions
.
DEFAULT
,
new
ActionListener
<
UpdateResponse
>()
{
@Override
public
void
onResponse
(
UpdateResponse
updateResponse
)
{
if
(
DocWriteResponse
.
Result
.
UPDATED
.
equals
(
updateResponse
.
getResult
()))
{
log
.
info
(
"索引:【{}】,主键:【{}】修改成功"
,
indexName
,
id
);
}
}
@Override
public
void
onFailure
(
Exception
e
)
{
log
.
error
(
"索引:[{}],主键:【{}】"
,
indexName
,
id
,
e
);
}
});
}
/**
* 构建SearchResponse
*
* @param indices 索引
* @param query queryBuilder
* @param fun 返回函数
* @param <T> 返回类型
* @return List, 可以使用fun转换为T结果
* @throws Exception e
*/
public
<
T
>
List
<
T
>
searchResponse
(
String
indices
,
QueryBuilder
query
,
Function
<
SearchHit
,
T
>
fun
)
throws
Exception
{
SearchRequest
request
=
new
SearchRequest
(
indices
);
Scroll
scroll
=
new
Scroll
(
TimeValue
.
timeValueMillis
(
SCROLL_TIMEOUT
));
SearchSourceBuilder
sourceBuilder
=
new
SearchSourceBuilder
();
sourceBuilder
.
query
(
query
);
sourceBuilder
.
size
(
SIZE
);
request
.
scroll
(
scroll
);
request
.
source
(
sourceBuilder
);
List
<
String
>
scrollIdList
=
new
ArrayList
<>();
List
<
T
>
result
=
new
ArrayList
<>();
SearchResponse
searchResponse
=
restHighLevelClient
.
search
(
request
,
RequestOptions
.
DEFAULT
);
String
scrollId
=
searchResponse
.
getScrollId
();
SearchHit
[]
hits
=
searchResponse
.
getHits
().
getHits
();
scrollIdList
.
add
(
scrollId
);
try
{
while
(
ArrayUtils
.
isNotEmpty
(
hits
))
{
for
(
SearchHit
hit
:
hits
)
{
result
.
add
(
fun
.
apply
(
hit
));
}
if
(
hits
.
length
<
SIZE
)
{
break
;
}
SearchScrollRequest
searchScrollRequest
=
new
SearchScrollRequest
(
scrollId
);
searchScrollRequest
.
scroll
(
scroll
);
SearchResponse
searchScrollResponse
=
restHighLevelClient
.
scroll
(
searchScrollRequest
,
RequestOptions
.
DEFAULT
);
scrollId
=
searchScrollResponse
.
getScrollId
();
hits
=
searchScrollResponse
.
getHits
().
getHits
();
scrollIdList
.
add
(
scrollId
);
}
}
finally
{
ClearScrollRequest
clearScrollRequest
=
new
ClearScrollRequest
();
clearScrollRequest
.
setScrollIds
(
scrollIdList
);
restHighLevelClient
.
clearScroll
(
clearScrollRequest
,
RequestOptions
.
DEFAULT
);
}
return
result
;
}
}
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