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
c47788d1
Commit
c47788d1
authored
Jun 01, 2022
by
maoying
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调整设备实时消息处理代码
parent
73d45681
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
958 additions
and
977 deletions
+958
-977
IEquipmentSpecificSerivce.java
...eejoin/equipmanage/service/IEquipmentSpecificSerivce.java
+1
-1
EquipmentSpecificSerivceImpl.java
...quipmanage/service/impl/EquipmentSpecificSerivceImpl.java
+2
-3
MqttReceiveServiceImpl.java
...join/equipmanage/service/impl/MqttReceiveServiceImpl.java
+955
-973
No files found.
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/IEquipmentSpecificSerivce.java
View file @
c47788d1
...
@@ -181,7 +181,7 @@ public interface IEquipmentSpecificSerivce extends IService<EquipmentSpecific> {
...
@@ -181,7 +181,7 @@ public interface IEquipmentSpecificSerivce extends IService<EquipmentSpecific> {
*
*
* @param indexs
* @param indexs
*/
*/
void
updateEquipmentSpecIndexRealtimeData
(
List
<
EquipmentSpecificIndex
>
indexs
);
void
updateEquipmentSpecIndexRealtimeData
(
EquipmentSpecificIndex
index
);
List
<
EquipmentSpecificVo
>
getEquipAndCarIotcodeByIotcode
(
String
iotCode
);
List
<
EquipmentSpecificVo
>
getEquipAndCarIotcodeByIotcode
(
String
iotCode
);
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/impl/EquipmentSpecificSerivceImpl.java
View file @
c47788d1
...
@@ -1615,10 +1615,9 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM
...
@@ -1615,10 +1615,9 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM
}
}
@Override
@Override
public
void
updateEquipmentSpecIndexRealtimeData
(
List
<
EquipmentSpecificIndex
>
indexs
)
{
public
void
updateEquipmentSpecIndexRealtimeData
(
EquipmentSpecificIndex
index
)
{
// TODO Auto-generated method stub
// TODO Auto-generated method stub
if
(!
ObjectUtils
.
isEmpty
(
indexs
))
{
if
(!
ObjectUtils
.
isEmpty
(
index
))
{
EquipmentSpecificIndex
index
=
indexs
.
get
(
0
);
EquipmentSpecific
es
=
equipmentSpecificMapper
.
selectById
(
index
.
getEquipmentSpecificId
());
EquipmentSpecific
es
=
equipmentSpecificMapper
.
selectById
(
index
.
getEquipmentSpecificId
());
es
.
setRealtimeIotEsIndexId
(
index
.
getId
());
es
.
setRealtimeIotEsIndexId
(
index
.
getId
());
es
.
setRealtimeIotIndexKey
(
index
.
getNameKey
());
es
.
setRealtimeIotIndexKey
(
index
.
getNameKey
());
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/impl/MqttReceiveServiceImpl.java
View file @
c47788d1
...
@@ -77,7 +77,6 @@ import com.yeejoin.equipmanage.service.IEquipmentIndexService;
...
@@ -77,7 +77,6 @@ import com.yeejoin.equipmanage.service.IEquipmentIndexService;
import
com.yeejoin.equipmanage.service.IEquipmentService
;
import
com.yeejoin.equipmanage.service.IEquipmentService
;
import
com.yeejoin.equipmanage.service.IEquipmentSpecificAlarmLogService
;
import
com.yeejoin.equipmanage.service.IEquipmentSpecificAlarmLogService
;
import
com.yeejoin.equipmanage.service.IEquipmentSpecificAlarmService
;
import
com.yeejoin.equipmanage.service.IEquipmentSpecificAlarmService
;
import
com.yeejoin.equipmanage.service.IEquipmentSpecificIndexSerivce
;
import
com.yeejoin.equipmanage.service.IEquipmentSpecificIndexService
;
import
com.yeejoin.equipmanage.service.IEquipmentSpecificIndexService
;
import
com.yeejoin.equipmanage.service.IEquipmentSpecificSerivce
;
import
com.yeejoin.equipmanage.service.IEquipmentSpecificSerivce
;
import
com.yeejoin.equipmanage.service.IFireFightingSystemService
;
import
com.yeejoin.equipmanage.service.IFireFightingSystemService
;
...
@@ -94,996 +93,979 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -94,996 +93,979 @@ import lombok.extern.slf4j.Slf4j;
/**
/**
* @author keyong
* @author keyong
* @title: MqttReceiveServiceImpl
* @title: MqttReceiveServiceImpl
* <pre>
*
* @description: 增量数据处理
* <pre>
* </pre>
* @description: 增量数据处理
* </pre>
*
* @date 2020/11/3 13:39
* @date 2020/11/3 13:39
*/
*/
@Slf4j
@Slf4j
@Service
@Service
public
class
MqttReceiveServiceImpl
implements
MqttReceiveService
{
public
class
MqttReceiveServiceImpl
implements
MqttReceiveService
{
private
static
Map
<
String
,
TemperatureAlarmDto
>
temperatureMap
=
new
HashMap
<>();
private
static
Map
<
String
,
TemperatureAlarmDto
>
temperatureMap
=
new
HashMap
<>();
@Autowired
@Autowired
IEquipmentSpecificIndexService
equipmentSpecificIndexService
;
IEquipmentSpecificIndexService
equipmentSpecificIndexService
;
@Autowired
@Autowired
ICarPropertyService
carPropertyService
;
ICarPropertyService
carPropertyService
;
@Autowired
@Autowired
IEquipmentSpecificAlarmService
equipmentSpecificAlarmService
;
IEquipmentSpecificAlarmService
equipmentSpecificAlarmService
;
@Autowired
@Autowired
IEquipmentSpecificAlarmLogService
equipmentSpecificAlarmLogService
;
IEquipmentSpecificAlarmLogService
equipmentSpecificAlarmLogService
;
@Autowired
@Autowired
EquipmentSpecificAlarmMapper
equipmentSpecificAlarmMapper
;
EquipmentSpecificAlarmMapper
equipmentSpecificAlarmMapper
;
@Autowired
EquipmentSpecificAlarmLogMapper
equipmentSpecificAlarmLogMapper
;
@Autowired
@Autowired
@Lazy
EquipmentSpecificAlarmLogMapper
equipmentSpecificAlarmLogMapper
;
IEquipmentIndexService
equipmentIndexService
;
@Autowired
@Autowired
EquipmentSpecificIndexMapper
equipmentSpecificIndexMapper
;
@Lazy
IEquipmentIndexService
equipmentIndexService
;
@Autowired
@Autowired
EquipmentSpecificMapper
equipmentSpecific
Mapper
;
EquipmentSpecificIndexMapper
equipmentSpecificIndex
Mapper
;
@Autowired
@Autowired
FireFightingSystemMapper
FireFightingSystem
Mapper
;
EquipmentSpecificMapper
equipmentSpecific
Mapper
;
@Autowired
@Autowired
IFireFightingSystemService
fireFightingSystemService
;
FireFightingSystemMapper
FireFightingSystemMapper
;
@Autowired
@Autowired
MqttSendGateway
mqttSendGateway
;
IFireFightingSystemService
fireFightingSystemService
;
@Autowired
@Autowired
private
RedisUtils
redisUtils
;
MqttSendGateway
mqttSendGateway
;
@Autowired
@Autowired
CarMapper
carMapper
;
private
RedisUtils
redisUtils
;
@Autowired
@Autowired
IMainIotMonitorSerivce
iMainIotMonitorSerivce
;
CarMapper
carMapper
;
@Autowired
@Autowired
private
IEquipmentSpecificIndexSerivce
equipmentSpecificIndexSerivce
;
IMainIotMonitorSerivce
iMainIotMonitorSerivce
;
@Autowired
@Autowired
private
ISyncDataService
syncDataService
;
private
ISyncDataService
syncDataService
;
@Autowired
@Autowired
private
IEquipmentAlarmReportDayService
iEquipmentAlarmReportDayService
;
private
IEquipmentAlarmReportDayService
iEquipmentAlarmReportDayService
;
@Autowired
@Autowired
private
IEquipmentSpecificSerivce
iEquipmentSpecificSerivce
;
private
IEquipmentSpecificSerivce
iEquipmentSpecificSerivce
;
@Autowired
@Autowired
FireFightingSystemMapper
fireFightingSystemMapper
;
FireFightingSystemMapper
fireFightingSystemMapper
;
@Autowired
@Autowired
private
SystemctlFeign
systemctlFeign
;
private
SystemctlFeign
systemctlFeign
;
@Autowired
@Autowired
private
RemoteSecurityService
remoteSecurityService
;
private
RemoteSecurityService
remoteSecurityService
;
@Autowired
@Autowired
private
TopographyService
topographyService
;
private
TopographyService
topographyService
;
@Autowired
@Autowired
private
IEquipmentService
equipmentService
;
private
IEquipmentService
equipmentService
;
@Value
(
"${equipManage.name}"
)
@Value
(
"${equipManage.name}"
)
private
String
serverName
;
private
String
serverName
;
@Value
(
"${mqtt.vehicle.topic}"
)
@Value
(
"${mqtt.vehicle.topic}"
)
private
String
carTopic
;
private
String
carTopic
;
@Value
(
"${equip.point.equipmentdata.topic}"
)
@Value
(
"${equip.point.equipmentdata.topic}"
)
private
String
canvasTopic
;
private
String
canvasTopic
;
@Value
(
"${equip.index.topic}"
)
@Value
(
"${equip.index.topic}"
)
private
String
indexTopic
;
private
String
indexTopic
;
@Value
(
"${spring.redis.expire.time}"
)
@Value
(
"${spring.redis.expire.time}"
)
private
long
redisExpireTime
;
private
long
redisExpireTime
;
@Value
(
"${systemctl.sync.switch}"
)
@Value
(
"${systemctl.sync.switch}"
)
private
Boolean
syncSwitch
;
private
Boolean
syncSwitch
;
@Value
(
"${systemctl.amos.switch}"
)
@Value
(
"${systemctl.amos.switch}"
)
private
Boolean
amosSwitch
;
private
Boolean
amosSwitch
;
@Value
(
"${isSendApp}"
)
@Value
(
"${isSendApp}"
)
private
Boolean
isSendApp
;
private
Boolean
isSendApp
;
private
static
Boolean
bool
=
Boolean
.
FALSE
;
private
final
static
Map
staticMap
=
new
HashMap
();
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
private
static
Boolean
bool
=
Boolean
.
FALSE
;
public
void
handlerMqttIncrementMessage
(
String
topic
,
String
message
)
{
static
{
TopicEntityVo
topicEntity
=
new
TopicEntityVo
();
staticMap
.
put
(
"FireCar_GDLongitude"
,
"0"
);
topicEntity
.
setTopic
(
topic
);
staticMap
.
put
(
"FireCar_GDLatitude"
,
"0"
);
topicEntity
.
setMessage
(
message
);
staticMap
.
put
(
"FireCar_Speed"
,
"0"
);
int
endIndex
=
topic
.
lastIndexOf
(
"/"
);
staticMap
.
put
(
"FireCar_Power"
,
"0"
);
String
iotCode
=
topic
.
substring
(
0
,
endIndex
).
replace
(
"/"
,
""
);
staticMap
.
put
(
"FireCar_CourseOverGround"
,
"0"
);
topicEntity
.
setIotCode
(
iotCode
);
staticMap
.
put
(
"time"
,
System
.
currentTimeMillis
());
List
<
EquipmentSpecificVo
>
eqIotCodeList
=
iEquipmentSpecificSerivce
.
getEquipAndCarIotcodeByIotcode
(
iotCode
);
staticMap
.
put
(
"FireCar_Start"
,
"false"
);
if
(
eqIotCodeList
.
isEmpty
())
{
}
log
.
info
(
"该数据{}不存在!"
,
iotCode
);
return
;
@Override
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
if
(
eqIotCodeList
.
size
()
>
1
)
{
public
void
handlerMqttIncrementMessage
(
String
topic
,
String
message
)
{
log
.
info
(
"有重复的{}数据!"
,
iotCode
);
}
TopicEntityVo
topicEntity
=
new
TopicEntityVo
();
EquipmentSpecificVo
vo
=
eqIotCodeList
.
get
(
0
);
topicEntity
.
setTopic
(
topic
);
topicEntity
.
setType
(
vo
.
getType
());
topicEntity
.
setMessage
(
message
);
topicEntity
.
setCode
(
vo
.
getCode
());
int
endIndex
=
topic
.
lastIndexOf
(
"/"
);
String
iotCode
=
topic
.
substring
(
0
,
endIndex
).
replace
(
"/"
,
""
);
JSONObject
json
=
JSONObject
.
parseObject
(
message
);
topicEntity
.
setIotCode
(
iotCode
);
Iterator
it
=
json
.
entrySet
().
iterator
();
List
<
EquipmentSpecificVo
>
eqIotCodeList
=
iEquipmentSpecificSerivce
.
getEquipAndCarIotcodeByIotcode
(
iotCode
);
List
<
IotDataVO
>
iotDatalist
=
new
ArrayList
<
IotDataVO
>();
if
(
eqIotCodeList
.
isEmpty
())
{
while
(
it
.
hasNext
())
{
log
.
info
(
"该数据{}不存在!"
,
iotCode
);
IotDataVO
iotDataVO
=
new
IotDataVO
();
return
;
Map
.
Entry
<
String
,
Object
>
entry
=
(
Map
.
Entry
<
String
,
Object
>)
it
.
next
();
}
iotDataVO
.
setKey
(
entry
.
getKey
());
if
(
eqIotCodeList
.
size
()
>
1
)
{
iotDataVO
.
setValue
(
entry
.
getValue
());
log
.
info
(
"有重复的{}数据!"
,
iotCode
);
iotDatalist
.
add
(
iotDataVO
);
}
}
EquipmentSpecificVo
vo
=
eqIotCodeList
.
get
(
0
);
if
(
ObjectUtils
.
isEmpty
(
iotDatalist
))
{
topicEntity
.
setType
(
vo
.
getType
());
return
;
topicEntity
.
setCode
(
vo
.
getCode
());
}
log
.
info
(
String
.
format
(
"收到mqtt消息:%s"
,
message
));
JSONObject
json
=
JSONObject
.
parseObject
(
message
);
realTimeDateProcessing
(
topicEntity
,
iotDatalist
);
Iterator
it
=
json
.
entrySet
().
iterator
();
}
List
<
IotDataVO
>
iotDatalist
=
new
ArrayList
<
IotDataVO
>();
while
(
it
.
hasNext
())
{
/**
IotDataVO
iotDataVO
=
new
IotDataVO
();
* 物联数据处理
Map
.
Entry
<
String
,
Object
>
entry
=
(
Map
.
Entry
<
String
,
Object
>)
it
.
next
();
*
iotDataVO
.
setKey
(
entry
.
getKey
());
* @param topicEntity
iotDataVO
.
setValue
(
entry
.
getValue
());
* @param iotDatalist
iotDatalist
.
add
(
iotDataVO
);
*/
}
public
void
realTimeDateProcessing
(
TopicEntityVo
topicEntity
,
List
<
IotDataVO
>
iotDatalist
)
{
if
(
ObjectUtils
.
isEmpty
(
iotDatalist
))
{
String
iotCode
=
topicEntity
.
getIotCode
();
return
;
}
if
(
EquipAndCarEnum
.
equip
.
type
.
equals
(
topicEntity
.
getType
()))
{
log
.
info
(
String
.
format
(
"收到mqtt消息:%s"
,
message
));
List
<
EquipmentSpecificIndex
>
indexList
=
equipmentSpecificIndexService
realTimeDateProcessing
(
topicEntity
,
iotDatalist
);
.
getEquipmentSpeIndexBySpeIotCode
(
iotCode
);
}
if
(
ObjectUtils
.
isEmpty
(
indexList
))
{
return
;
/**
}
* 物联数据处理
equipRealTimeDate
(
iotDatalist
,
indexList
,
topicEntity
);
* @param topicEntity
}
else
{
* @param iotDatalist
List
<
CarProperty
>
carProperties
=
carPropertyService
.
getCarPropListByIotCode
(
iotCode
);
*/
if
(
ObjectUtils
.
isEmpty
(
carProperties
))
{
public
void
realTimeDateProcessing
(
TopicEntityVo
topicEntity
,
List
<
IotDataVO
>
iotDatalist
){
return
;
String
iotCode
=
topicEntity
.
getIotCode
();
}
carRealTimeDate
(
iotDatalist
,
carProperties
);
if
(
EquipAndCarEnum
.
equip
.
type
.
equals
(
topicEntity
.
getType
())){
}
List
<
EquipmentSpecificIndex
>
indexList
=
equipmentSpecificIndexService
.
getEquipmentSpeIndexBySpeIotCode
(
iotCode
);
if
(
ObjectUtils
.
isEmpty
(
indexList
)){
}
return
;
}
/**
equipRealTimeDate
(
iotDatalist
,
indexList
,
topicEntity
);
* 装备实时数据处理
}
else
{
*
List
<
CarProperty
>
carProperties
=
carPropertyService
.
getCarPropListByIotCode
(
iotCode
);
* @param iotDatalist
if
(
ObjectUtils
.
isEmpty
(
carProperties
)){
* @param indexList
return
;
* @param topicEntity
}
*/
carRealTimeDate
(
iotDatalist
,
carProperties
);
public
void
equipRealTimeDate
(
List
<
IotDataVO
>
iotDatalist
,
List
<
EquipmentSpecificIndex
>
indexList
,
}
TopicEntityVo
topicEntity
)
{
List
<
EquipmentSpecificIndex
>
equipmentSpecificIndexList
=
new
ArrayList
<>();
}
List
<
EquipmentSpecificAlarm
>
equipmentSpecificAlarms
=
new
ArrayList
<>();
List
<
IndexStateVo
>
indexStateList
=
new
ArrayList
<>();
// 存储温度数据至内存中(火眼)
public
static
List
<
EquipmentSpecificAlarmLog
>
upAlarmLogStatus
(
String
iotCode
,
String
equipmentSpecificIndexKey
,
IEquipmentSpecificAlarmLogService
equipmentSpecificAlarmLogService
)
{
iotDataListToCacheMap
(
iotDatalist
);
LambdaQueryWrapper
<
EquipmentSpecificAlarmLog
>
queryWrapper
=
new
LambdaQueryWrapper
();
iotDatalist
.
forEach
(
iotDataVO
->
{
queryWrapper
.
eq
(
EquipmentSpecificAlarmLog:
:
getIotCode
,
iotCode
);
for
(
EquipmentSpecificIndex
equipmentSpecificIndex
:
indexList
)
{
queryWrapper
.
eq
(
EquipmentSpecificAlarmLog:
:
getEquipmentSpecificIndexKey
,
equipmentSpecificIndexKey
);
if
(!
ObjectUtils
.
isEmpty
(
equipmentSpecificIndex
.
getNameKey
())
queryWrapper
.
ne
(
EquipmentSpecificAlarmLog:
:
getStatus
,
AlarmStatusEnum
.
HF
.
getCode
());
&&
equipmentSpecificIndex
.
getNameKey
().
toLowerCase
().
equals
(
iotDataVO
.
getKey
().
toLowerCase
()))
{
List
<
EquipmentSpecificAlarmLog
>
logs
=
equipmentSpecificAlarmLogService
.
getBaseMapper
().
selectList
(
queryWrapper
);
EquipmentSpecificIndex
equipmentSpeIndex
=
new
EquipmentSpecificIndex
();
logs
.
forEach
(
x
->
{
BeanUtils
.
copyProperties
(
equipmentSpecificIndex
,
equipmentSpeIndex
);
x
.
setCleanTime
(
new
Date
());
String
value
=
iotDataVO
.
getValue
().
toString
();
x
.
setStatus
(
AlarmStatusEnum
.
HF
.
getCode
());
equipmentSpeIndex
.
setValue
(
value
);
});
equipmentSpeIndex
.
setValueLabel
(
valueTranslate
(
value
,
equipmentSpecificIndex
.
getValueEnum
()));
if
(!
logs
.
isEmpty
())
{
equipmentSpeIndex
.
setUpdateDate
(
new
Date
());
equipmentSpecificAlarmLogService
.
updateBatchById
(
logs
);
equipmentSpecificIndexService
.
updateById
(
equipmentSpeIndex
);
}
return
logs
;
// 更新设备表指标状态
}
iEquipmentSpecificSerivce
.
updateEquipmentSpecIndexRealtimeData
(
equipmentSpeIndex
);
public
void
publishDataToCanvas
(
List
<
EquipmentSpecificIndex
>
indexList
)
{
equipmentSpecificIndexList
.
add
(
equipmentSpeIndex
);
if
(!
ObjectUtils
.
isEmpty
(
indexList
))
{
TransactionSynchronizationManager
.
registerSynchronization
(
new
TransactionSynchronization
()
{
indexStateList
.
add
(
createIndexStateVo
(
equipmentSpeIndex
));
@Override
public
void
afterCommit
()
{
// 添加指标报告
EquipmentSpecificIndex
index
=
indexList
.
stream
().
filter
(
x
->
x
.
getUpdateDate
()
!=
null
)
saveEquipmentAlarmReportDay
(
equipmentSpeIndex
);
.
sorted
(
Comparator
.
comparing
(
EquipmentSpecificIndex:
:
getUpdateDate
).
reversed
())
.
collect
(
Collectors
.
toList
()).
get
(
0
);
// 火眼数据构造告警指标逻辑
EquipmentStateVo
equipmentStateVo
=
new
EquipmentStateVo
();
equipmentSpecificIndex
=
handleTemperatureAlarm
(
equipmentSpeIndex
,
iotDatalist
);
equipmentStateVo
.
setEquipName
(
index
.
getEquipmentSpecificName
());
equipmentStateVo
.
setOrgCode
(
index
.
getOrgCode
());
// 指标告警处理
equipmentStateVo
.
setSpecificId
(
index
.
getEquipmentSpecificId
());
if
(
equipmentSpecificIndex
.
getIsAlarm
()
!=
null
&&
1
==
equipmentSpecificIndex
.
getIsAlarm
())
{
equipmentStateVo
.
setEquipCode
(
index
.
getQrCode
());
equipmentSpecificAlarms
.
addAll
(
createIndexAlarmRecord
(
equipmentSpecificIndex
));
equipmentStateVo
.
setEquipIotCode
(
index
.
getIotCode
());
}
equipmentStateVo
.
setStatus
(
""
);
}
equipmentStateVo
.
setColor
(
index
.
getEmergencyLevelColor
());
}
// 添加性能指标项
});
equipmentStateVo
.
setSpeindexList
(
fireFightingSystemService
.
getSpeIndex
(
index
.
getEquipmentSpecificId
()));
Map
<
String
,
Object
>
topicObject
=
new
HashMap
<>();
// 报警数据保存
topicObject
.
put
(
"equipCode"
,
equipmentStateVo
.
getEquipCode
());
List
<
EquipmentSpecificAlarmLog
>
alarmLogs
=
saveOrUpdateEquipAlarm
(
equipmentSpecificAlarms
);
if
(
TrueOrFalseEnum
.
real
.
value
.
toUpperCase
().
equals
(
index
.
getValue
().
toUpperCase
()))
{
topicObject
.
put
(
"color"
,
equipmentStateVo
.
getColor
());
// 需要在事务提交之后,否侧事务隔离查询不出数据
}
else
{
TransactionSynchronizationManager
.
registerSynchronization
(
new
TransactionSynchronization
()
{
topicObject
.
put
(
"color"
,
""
);
@Override
}
public
void
afterCommit
()
{
Map
<
String
,
Object
>
map
=
JSON
.
parseObject
(
JSON
.
toJSONString
(
equipmentStateVo
));
// 向预控系统发送消息
map
.
put
(
canvasTopic
,
topicObject
);
sendEquipSpecIndexToAutosysTopic
(
equipmentSpecificIndexList
);
// 发送数据至画布
// 首页性能指标数据订阅
mqttSendGateway
.
sendToMqtt
(
canvasTopic
,
JSON
.
toJSONString
(
map
));
mqttSendGateway
.
sendToMqtt
(
indexTopic
,
JSON
.
toJSONString
(
indexStateList
));
}
});
// 组态大屏消息推送,设备表实时指标修改
}
intePageSysDataRefresh
(
equipmentSpecificIndexList
,
topicEntity
);
}
// 数字换流站同步指标修改
void
syncSystemctlMsg
(
EquipmentSpecificAlarmLog
equipmentSpecificAlarmLog
)
{
syncSpecificIndexsToGS
(
equipmentSpecificIndexList
);
try
{
MessageModel
model
=
new
MessageModel
();
// 则更新拓扑节点数据及告警状态
String
alarmReason
=
ValidationUtil
.
isEmpty
(
equipmentSpecificAlarmLog
.
getAlarmReason
())
?
""
:
equipmentSpecificAlarmLog
.
getAlarmReason
();
updateNodeDateByEquipId
(
equipmentSpecificIndexList
);
if
(
alarmReason
.
contains
(
":"
))
{
String
[]
split
=
alarmReason
.
split
(
":"
);
// 向画布推送
alarmReason
=
split
[
1
];
publishDataToCanvas
(
equipmentSpecificIndexList
);
}
model
.
setTitle
(
equipmentSpecificAlarmLog
.
getEquipmentSpecificIndexName
());
// 向其他系统推送报警
String
body
=
String
.
format
(
"警情类型:%s;报警设备:%s;报警位置:%s;报警原因:%s;报警时间:%s"
,
equipmentAlarmLogsToOtherSystems
(
alarmLogs
);
equipmentSpecificAlarmLog
.
getEquipmentSpecificIndexName
(),
equipmentSpecificAlarmLog
.
getEquipmentSpecificName
(),
}
equipmentSpecificAlarmLog
.
getLocation
(),
alarmReason
,
});
DateUtils
.
date2LongStr
(
equipmentSpecificAlarmLog
.
getCreateDate
()));
}
model
.
setBody
(
body
);
model
.
setMsgType
(
"iotMonitor"
);
public
void
carRealTimeDate
(
List
<
IotDataVO
>
iotDatalist
,
List
<
CarProperty
>
carProperties
)
{
if
(
isSendApp
)
{
List
<
CarProperty
>
carIndexsList
=
new
ArrayList
<>();
model
.
setIsSendApp
(
true
);
iotDatalist
.
forEach
(
iotDataVO
->
{
model
.
setTerminal
(
"APP/WEB"
);
// 对指标key为labels的数据处理
}
else
{
if
(
EquipmentIndexLabelsEnum
.
labels
.
name
.
equals
(
iotDataVO
.
getKey
()))
{
model
.
setIsSendApp
(
false
);
StringBuilder
sb
=
new
StringBuilder
(
"equipmentOnCar_"
);
model
.
setTerminal
(
"WEB"
);
EquipmentIndexLabelsVo
labelsVo
=
new
EquipmentIndexLabelsVo
();
}
Object
obj
=
iotDataVO
.
getValue
();
model
.
setIsSendWeb
(
true
);
if
(
obj
instanceof
JSONArray
)
{
model
.
setCategory
(
1
);
List
<
String
>
labelList
=
(
List
<
String
>)
obj
;
model
.
setRelationId
(
String
.
valueOf
(
equipmentSpecificAlarmLog
.
getId
()));
labelList
.
forEach
(
code
->
{
Token
token
=
remoteSecurityService
.
getServerToken
();
String
key
=
sb
.
append
(
code
).
toString
();
systemctlFeign
.
create
(
token
.
getAppKey
(),
token
.
getProduct
(),
token
.
getToke
(),
model
);
labelsVo
.
setEquipmentIotCode
(
code
);
log
.
info
(
String
.
format
(
"调用平台消息服务成功:%s"
,
JSON
.
toJSONString
(
model
)));
labelsVo
.
setTime
(
new
Date
());
}
catch
(
Exception
e
)
{
redisUtils
.
set
(
key
,
com
.
alibaba
.
fastjson
.
JSONObject
.
toJSONString
(
labelsVo
),
redisExpireTime
);
// e.printStackTrace();
});
log
.
error
(
"告警消息同步平台失败:syncSystemctlMsg,===>>>"
+
e
.
getMessage
());
}
}
}
}
List
<
CarPropertyVo
>
carPropertyVos
=
new
ArrayList
<>();
carProperties
.
forEach
(
carProperty
->
{
public
List
<
EquipmentSpecificAlarm
>
addIndexAlarmRecord
(
EquipmentSpecificIndex
equipmentSpcIndex
,
List
<
IotDataVO
>
iotDatalist
)
{
if
(
iotDataVO
.
getKey
().
equals
(
carProperty
.
getNameKey
()))
{
// 处理火眼视频异常
carProperty
.
setValue
(
iotDataVO
.
getValue
().
toString
());
EquipmentSpecificIndex
equipmentSpecificIndex
=
handleTemperatureAlarm
(
equipmentSpcIndex
,
iotDatalist
);
carProperty
.
setUpdateDate
(
new
Date
());
List
<
EquipmentSpecificAlarm
>
equipmentSpecificAlarms
=
new
ArrayList
<>();
carPropertyVos
.
add
(
carPropertyToCarPropertyVo
(
carProperty
));
EquipmentSpecificAlarm
equipmentSpecificAlarm
=
new
EquipmentSpecificAlarm
();
carIndexsList
.
add
(
carProperty
);
equipmentSpecificAlarm
.
setSystemIds
(
equipmentSpcIndex
.
getSystemId
());
}
equipmentSpecificAlarm
.
setSystemCodes
(
this
.
getSystemCodeBySpeId
(
equipmentSpcIndex
.
getSystemId
()));
});
if
(
EquipmentRiskTypeEnum
.
GZ
.
getCode
().
equals
(
equipmentSpecificIndex
.
getTypeCode
())
||
EquipmentRiskTypeEnum
.
HZGJ
.
getCode
().
equals
(
equipmentSpecificIndex
.
getTypeCode
())
||
EquipmentRiskTypeEnum
.
PB
.
getCode
().
equals
(
equipmentSpecificIndex
.
getTypeCode
()))
{
boolean
updateBatchById
=
carPropertyService
.
updateBatchById
(
carIndexsList
);
List
<
EquipmentSpecificAlarm
>
indexAlarms
=
equipmentSpecificAlarmMapper
.
findEquipmentSpecificAlarmByEquipmentSpecificIdAndEquipmentIndexIdAndStatusIstrue
(
equipmentSpecificIndex
.
getEquipmentSpecificId
(),
equipmentSpecificIndex
.
getEquipmentIndexId
());
// NB设备告警
if
(
updateBatchById
)
{
if
(
verifyNB
(
equipmentSpecificIndex
.
getNameKey
()))
{
carTransactionSynch
(
carProperties
,
carPropertyVos
);
return
getNbEquipAlarmList
(
indexAlarms
,
equipmentSpecificIndex
,
equipmentSpecificAlarm
);
}
}
});
// 报警表新增信息
}
if
(
ObjectUtils
.
isEmpty
(
indexAlarms
)
&&
(
TrueOrFalseEnum
.
real
.
value
.
equals
(
equipmentSpecificIndex
.
getValue
())))
{
addEquipmentSpecificAlarm
(
equipmentSpecificAlarms
,
equipmentSpecificIndex
,
equipmentSpecificAlarm
);
public
static
List
<
EquipmentSpecificAlarmLog
>
upAlarmLogStatus
(
String
iotCode
,
String
equipmentSpecificIndexKey
,
}
else
{
IEquipmentSpecificAlarmLogService
equipmentSpecificAlarmLogService
)
{
// 报警表更新信息
LambdaQueryWrapper
<
EquipmentSpecificAlarmLog
>
queryWrapper
=
new
LambdaQueryWrapper
();
indexAlarms
.
forEach
(
action
->
{
queryWrapper
.
eq
(
EquipmentSpecificAlarmLog:
:
getIotCode
,
iotCode
);
if
(
TrueOrFalseEnum
.
real
.
value
.
equals
(
equipmentSpecificIndex
.
getValue
()))
{
queryWrapper
.
eq
(
EquipmentSpecificAlarmLog:
:
getEquipmentSpecificIndexKey
,
equipmentSpecificIndexKey
);
// 报警,修改发生频率
queryWrapper
.
ne
(
EquipmentSpecificAlarmLog:
:
getStatus
,
AlarmStatusEnum
.
HF
.
getCode
());
action
.
setFrequency
((
action
.
getFrequency
()
+
1
));
List
<
EquipmentSpecificAlarmLog
>
logs
=
equipmentSpecificAlarmLogService
.
getBaseMapper
()
}
else
{
.
selectList
(
queryWrapper
);
// 报警恢复,修改数据为恢复状态
logs
.
forEach
(
x
->
{
action
.
setRecoveryDate
(
new
Date
());
x
.
setCleanTime
(
new
Date
());
action
.
setEquipmentSpecificIndexValue
(
TrueOrFalseEnum
.
fake
.
value
);
x
.
setStatus
(
AlarmStatusEnum
.
HF
.
getCode
());
action
.
setStatus
(
AlarmStatusEnum
.
HF
.
getCode
());
});
}
if
(!
logs
.
isEmpty
())
{
action
.
setUpdateDate
(
new
Date
());
equipmentSpecificAlarmLogService
.
updateBatchById
(
logs
);
// 更新所在系统,设备可能编辑过,更新所在系统、装备名称、装备定义code
}
action
.
setSystemIds
(
equipmentSpcIndex
.
getSystemId
());
return
logs
;
action
.
setSystemCodes
(
this
.
getSystemCodeBySpeId
(
equipmentSpcIndex
.
getSystemId
()));
}
action
.
setEquipmentSpecificName
(
equipmentSpcIndex
.
getEquipmentSpecificName
());
action
.
setEquipmentCode
(
equipmentSpcIndex
.
getEquipmentCode
());
/**
// 冗余字段,alarm_log表更新时使用
* 画布数据消息推送
action
.
setEquipmentSpecificCode
(
equipmentSpcIndex
.
getEquipmentSpecificCode
());
*
equipmentSpecificAlarms
.
add
(
action
);
* @param indexList
});
*/
}
public
void
publishDataToCanvas
(
List
<
EquipmentSpecificIndex
>
indexList
)
{
}
if
(!
ObjectUtils
.
isEmpty
(
indexList
))
{
EquipmentSpecificIndex
index
=
indexList
.
stream
().
filter
(
x
->
x
.
getUpdateDate
()
!=
null
)
return
equipmentSpecificAlarms
;
.
sorted
(
Comparator
.
comparing
(
EquipmentSpecificIndex:
:
getUpdateDate
).
reversed
())
}
.
collect
(
Collectors
.
toList
()).
get
(
0
);
EquipmentStateVo
equipmentStateVo
=
new
EquipmentStateVo
();
private
String
getSystemCodeBySpeId
(
String
sysIds
)
{
equipmentStateVo
.
setEquipName
(
index
.
getEquipmentSpecificName
());
if
(
StringUtil
.
isNotEmpty
(
sysIds
))
{
equipmentStateVo
.
setOrgCode
(
index
.
getOrgCode
());
List
<
FireFightingSystemEntity
>
sys
=
fireFightingSystemMapper
.
getFightingSysByIds
(
sysIds
.
split
(
","
));
equipmentStateVo
.
setSpecificId
(
index
.
getEquipmentSpecificId
());
return
sys
.
stream
().
map
(
FireFightingSystemEntity:
:
getCode
).
collect
(
Collectors
.
joining
(
","
));
equipmentStateVo
.
setEquipCode
(
index
.
getQrCode
());
}
else
{
equipmentStateVo
.
setEquipIotCode
(
index
.
getIotCode
());
return
null
;
equipmentStateVo
.
setStatus
(
""
);
}
equipmentStateVo
.
setColor
(
index
.
getEmergencyLevelColor
());
}
// 添加性能指标项
equipmentStateVo
.
setSpeindexList
(
fireFightingSystemService
.
getSpeIndex
(
index
.
getEquipmentSpecificId
()));
private
EquipmentAlarmReportDay
addEquipAlarmReportRecord
(
EquipmentSpecificIndex
equipmentSpecificIndex
)
{
Map
<
String
,
Object
>
topicObject
=
new
HashMap
<>();
EquipmentAlarmReportDay
equipmentAlarmReportDay
=
new
EquipmentAlarmReportDay
();
topicObject
.
put
(
"equipCode"
,
equipmentStateVo
.
getEquipCode
());
equipmentAlarmReportDay
.
setOrgCode
(
equipmentSpecificIndex
.
getOrgCode
());
if
(
TrueOrFalseEnum
.
real
.
value
.
toUpperCase
().
equals
(
index
.
getValue
().
toUpperCase
()))
{
equipmentAlarmReportDay
.
setReportDate
(
new
Date
());
topicObject
.
put
(
"color"
,
equipmentStateVo
.
getColor
());
equipmentAlarmReportDay
.
setUpdateDate
(
new
Date
());
}
else
{
equipmentAlarmReportDay
.
setSystemIds
(
equipmentSpecificIndex
.
getSystemId
());
topicObject
.
put
(
"color"
,
""
);
equipmentAlarmReportDay
.
setLastReportDate
(
new
Date
());
}
equipmentAlarmReportDay
.
setEquipmentSpecificId
(
equipmentSpecificIndex
.
getEquipmentSpecificId
());
Map
<
String
,
Object
>
map
=
JSON
.
parseObject
(
JSON
.
toJSONString
(
equipmentStateVo
));
equipmentAlarmReportDay
.
setEquipmentSpecificName
(
equipmentSpecificIndex
.
getEquipmentSpecificName
());
map
.
put
(
canvasTopic
,
topicObject
);
equipmentAlarmReportDay
.
setEquipmentDetailId
(
equipmentSpecificIndex
.
getEquipmentDetailId
());
equipmentAlarmReportDay
.
setEquipmentId
(
equipmentSpecificIndex
.
getEquipmentId
());
// 发送数据至画布
equipmentAlarmReportDay
.
setEquipmentCode
(
equipmentSpecificIndex
.
getEquipmentCode
());
mqttSendGateway
.
sendToMqtt
(
canvasTopic
,
JSON
.
toJSONString
(
map
));
equipmentAlarmReportDay
.
setIndexTrueNum
(
TrueOrFalseEnum
.
real
.
value
.
equals
(
equipmentSpecificIndex
.
getValue
())
?
1L
:
0L
);
}
equipmentAlarmReportDay
.
setAlarmType
(
equipmentSpecificIndex
.
getTypeCode
());
}
equipmentAlarmReportDay
.
setAlarmTypeName
(
equipmentSpecificIndex
.
getTypeName
());
equipmentAlarmReportDay
.
setIndexId
(
equipmentSpecificIndex
.
getEquipmentIndexId
());
/**
equipmentAlarmReportDay
.
setIndexName
(
equipmentSpecificIndex
.
getEquipmentSpecificIndexName
());
* 报警消息推送amos平台
equipmentAlarmReportDay
.
setIndexType
(
equipmentSpecificIndex
.
getNameKey
());
*
equipmentAlarmReportDay
.
setValue
(
equipmentSpecificIndex
.
getValue
());
* @param equipmentSpecificAlarmLog
equipmentAlarmReportDay
.
setIsAlarm
(
equipmentSpecificIndex
.
getIsAlarm
());
*/
return
equipmentAlarmReportDay
;
void
syncSystemctlMsg
(
EquipmentSpecificAlarmLog
equipmentSpecificAlarmLog
)
{
}
try
{
MessageModel
model
=
new
MessageModel
();
private
EquipmentSpecificAlarmLog
addEquipAlarmLogRecord
(
EquipmentSpecificAlarm
equipmentSpecificAlarm
)
{
String
alarmReason
=
ValidationUtil
.
isEmpty
(
equipmentSpecificAlarmLog
.
getAlarmReason
())
?
""
EquipmentSpecificAlarmLog
equipmentSpecificAlarmLog
=
new
EquipmentSpecificAlarmLog
();
:
equipmentSpecificAlarmLog
.
getAlarmReason
();
BeanUtils
.
copyProperties
(
equipmentSpecificAlarm
,
equipmentSpecificAlarmLog
);
if
(
alarmReason
.
contains
(
":"
))
{
equipmentSpecificAlarmLog
.
setId
(
null
);
String
[]
split
=
alarmReason
.
split
(
":"
);
equipmentSpecificAlarmLog
.
setCreateDate
(
new
Date
());
alarmReason
=
split
[
1
];
equipmentSpecificAlarmLog
.
setEquipmentSpecificAlarmId
(
equipmentSpecificAlarm
.
getId
());
}
boolean
bool
=
equipmentSpecificAlarmLogService
.
save
(
equipmentSpecificAlarmLog
);
model
.
setTitle
(
equipmentSpecificAlarmLog
.
getEquipmentSpecificIndexName
());
// 同步告警消息给平台
String
body
=
String
.
format
(
"警情类型:%s;报警设备:%s;报警位置:%s;报警原因:%s;报警时间:%s"
,
if
(
amosSwitch
&&
bool
)
{
equipmentSpecificAlarmLog
.
getEquipmentSpecificIndexName
(),
EquipmentSpecificAlarmLog
alarmLog
=
equipmentSpecificAlarmLogService
.
getById
(
equipmentSpecificAlarmLog
.
getId
());
equipmentSpecificAlarmLog
.
getEquipmentSpecificName
(),
equipmentSpecificAlarmLog
.
getLocation
(),
new
Thread
(
new
Runnable
()
{
alarmReason
,
DateUtils
.
date2LongStr
(
equipmentSpecificAlarmLog
.
getCreateDate
()));
@Override
model
.
setBody
(
body
);
public
void
run
()
{
model
.
setMsgType
(
"iotMonitor"
);
syncSystemctlMsg
(
alarmLog
);
if
(
isSendApp
)
{
}
model
.
setIsSendApp
(
true
);
}).
start
();
model
.
setTerminal
(
"APP/WEB"
);
}
}
else
{
return
equipmentSpecificAlarmLog
;
model
.
setIsSendApp
(
false
);
}
model
.
setTerminal
(
"WEB"
);
}
/**
model
.
setIsSendWeb
(
true
);
* 添加告警
model
.
setCategory
(
1
);
*
model
.
setRelationId
(
String
.
valueOf
(
equipmentSpecificAlarmLog
.
getId
()));
* @param equipmentSpecificAlarms
Token
token
=
remoteSecurityService
.
getServerToken
();
* @param equipmentSpecificIndex
systemctlFeign
.
create
(
token
.
getAppKey
(),
token
.
getProduct
(),
token
.
getToke
(),
model
);
* @return
log
.
info
(
String
.
format
(
"调用平台消息服务成功:%s"
,
JSON
.
toJSONString
(
model
)));
*/
}
catch
(
Exception
e
)
{
private
List
<
EquipmentSpecificAlarm
>
addEquipmentSpecificAlarm
(
List
<
EquipmentSpecificAlarm
>
equipmentSpecificAlarms
,
EquipmentSpecificIndex
equipmentSpecificIndex
,
EquipmentSpecificAlarm
equipmentSpecificAlarm
)
{
// e.printStackTrace();
BeanUtils
.
copyProperties
(
equipmentSpecificIndex
,
equipmentSpecificAlarm
);
log
.
error
(
"告警消息同步平台失败:syncSystemctlMsg,===>>>"
+
e
.
getMessage
());
equipmentSpecificAlarm
.
setId
(
null
);
}
equipmentSpecificAlarm
.
setFrequency
(
1
);
}
equipmentSpecificAlarm
.
setStatus
(
AlarmStatusEnum
.
BJ
.
getCode
());
equipmentSpecificAlarm
.
setEquipmentSpecificIndexKey
(
equipmentSpecificIndex
.
getNameKey
());
private
String
getSystemCodeBySpeId
(
String
sysIds
)
{
equipmentSpecificAlarm
.
setEquipmentSpecificIndexValue
(
equipmentSpecificIndex
.
getValue
());
if
(
StringUtil
.
isNotEmpty
(
sysIds
))
{
equipmentSpecificAlarm
.
setEquipmentSpecificIndexLabel
(
equipmentSpecificIndex
.
getValueLabel
());
List
<
FireFightingSystemEntity
>
sys
=
fireFightingSystemMapper
.
getFightingSysByIds
(
sysIds
.
split
(
","
));
equipmentSpecificAlarm
.
setType
(
equipmentSpecificIndex
.
getTypeCode
());
return
sys
.
stream
().
map
(
FireFightingSystemEntity:
:
getCode
).
collect
(
Collectors
.
joining
(
","
));
equipmentSpecificAlarm
.
setCreateDate
(
new
Date
());
}
else
{
equipmentSpecificAlarm
.
setUpdateDate
(
new
Date
());
return
null
;
equipmentSpecificAlarm
.
setEquipmentCode
(
equipmentSpecificIndex
.
getEquipmentCode
());
}
equipmentSpecificAlarm
.
setEquipmentId
(
equipmentSpecificIndex
.
getEquipmentId
());
}
equipmentSpecificAlarm
.
setEquipmentDetailId
(
equipmentSpecificIndex
.
getEquipmentDetailId
());
equipmentSpecificAlarm
.
setEquipmentSpecificCode
(
equipmentSpecificIndex
.
getEquipmentSpecificCode
());
private
EquipmentAlarmReportDay
addEquipAlarmReportRecord
(
EquipmentSpecificIndex
equipmentSpecificIndex
)
{
equipmentSpecificAlarm
.
setEmergencyLevel
(
equipmentSpecificIndex
.
getEmergencyLevel
());
EquipmentAlarmReportDay
equipmentAlarmReportDay
=
new
EquipmentAlarmReportDay
();
equipmentSpecificAlarm
.
setEmergencyLevelColor
(
equipmentSpecificIndex
.
getEmergencyLevelColor
());
equipmentAlarmReportDay
.
setOrgCode
(
equipmentSpecificIndex
.
getOrgCode
());
equipmentSpecificAlarm
.
setEmergencyLevelDescribe
(
equipmentSpecificIndex
.
getEmergencyLevelDescribe
());
equipmentAlarmReportDay
.
setReportDate
(
new
Date
());
equipmentSpecificAlarms
.
add
(
equipmentSpecificAlarm
);
equipmentAlarmReportDay
.
setUpdateDate
(
new
Date
());
return
equipmentSpecificAlarms
;
equipmentAlarmReportDay
.
setSystemIds
(
equipmentSpecificIndex
.
getSystemId
());
}
equipmentAlarmReportDay
.
setLastReportDate
(
new
Date
());
equipmentAlarmReportDay
.
setEquipmentSpecificId
(
equipmentSpecificIndex
.
getEquipmentSpecificId
());
// NB装备告警
equipmentAlarmReportDay
.
setEquipmentSpecificName
(
equipmentSpecificIndex
.
getEquipmentSpecificName
());
private
List
<
EquipmentSpecificAlarm
>
getNbEquipAlarmList
(
List
<
EquipmentSpecificAlarm
>
indexAlarms
,
EquipmentSpecificIndex
equipmentSpecificIndex
,
EquipmentSpecificAlarm
equipmentSpecificAlarm
)
{
equipmentAlarmReportDay
.
setEquipmentDetailId
(
equipmentSpecificIndex
.
getEquipmentDetailId
());
List
<
EquipmentSpecificAlarm
>
equipmentSpecificAlarmList
=
new
ArrayList
<>();
equipmentAlarmReportDay
.
setEquipmentId
(
equipmentSpecificIndex
.
getEquipmentId
());
if
(
ValidationUtil
.
isEmpty
(
indexAlarms
))
{
// 告警表为空,新增告警数据
equipmentAlarmReportDay
.
setEquipmentCode
(
equipmentSpecificIndex
.
getEquipmentCode
());
addEquipmentSpecificAlarm
(
equipmentSpecificAlarmList
,
equipmentSpecificIndex
,
equipmentSpecificAlarm
);
equipmentAlarmReportDay
if
(!
checkStateIsNormal
(
equipmentSpecificAlarm
,
equipmentSpecificIndex
))
{
.
setIndexTrueNum
(
TrueOrFalseEnum
.
real
.
value
.
equals
(
equipmentSpecificIndex
.
getValue
())
?
1L
:
0L
);
return
equipmentSpecificAlarmList
;
equipmentAlarmReportDay
.
setAlarmType
(
equipmentSpecificIndex
.
getTypeCode
());
}
else
{
equipmentAlarmReportDay
.
setAlarmTypeName
(
equipmentSpecificIndex
.
getTypeName
());
equipmentSpecificAlarmList
.
clear
();
equipmentAlarmReportDay
.
setIndexId
(
equipmentSpecificIndex
.
getEquipmentIndexId
());
}
equipmentAlarmReportDay
.
setIndexName
(
equipmentSpecificIndex
.
getEquipmentSpecificIndexName
());
}
else
{
equipmentAlarmReportDay
.
setIndexType
(
equipmentSpecificIndex
.
getNameKey
());
indexAlarms
.
forEach
(
action
->
{
equipmentAlarmReportDay
.
setValue
(
equipmentSpecificIndex
.
getValue
());
// 状态为正常或报警解除
equipmentAlarmReportDay
.
setIsAlarm
(
equipmentSpecificIndex
.
getIsAlarm
());
if
(
checkStateIsNormal
(
action
,
equipmentSpecificIndex
))
{
return
equipmentAlarmReportDay
;
//修改报警数据为正常
}
action
.
setRecoveryDate
(
new
Date
());
action
.
setStatus
(
AlarmStatusEnum
.
HF
.
getCode
());
private
EquipmentSpecificAlarmLog
addEquipAlarmLogRecord
(
EquipmentSpecificAlarm
equipmentSpecificAlarm
)
{
// 修改之前数据为已处理
EquipmentSpecificAlarmLog
equipmentSpecificAlarmLog
=
new
EquipmentSpecificAlarmLog
();
action
.
setResolveResult
(
action
.
getAlamReason
());
BeanUtils
.
copyProperties
(
equipmentSpecificAlarm
,
equipmentSpecificAlarmLog
);
action
.
setConfirmUserName
(
"系统"
);
equipmentSpecificAlarmLog
.
setId
(
null
);
action
.
setConfirmType
(
action
.
getType
());
equipmentSpecificAlarmLog
.
setCreateDate
(
new
Date
());
equipmentSpecificAlarmLogService
.
updateAlarmLogByIotCodeAndIndexKey
(
action
);
equipmentSpecificAlarmLog
.
setEquipmentSpecificAlarmId
(
equipmentSpecificAlarm
.
getId
());
}
else
{
boolean
bool
=
equipmentSpecificAlarmLogService
.
save
(
equipmentSpecificAlarmLog
);
action
.
setFrequency
((
action
.
getFrequency
()
+
1
));
// 同步告警消息给平台
}
if
(
amosSwitch
&&
bool
)
{
// 更新所在系统,设备可能编辑过
EquipmentSpecificAlarmLog
alarmLog
=
equipmentSpecificAlarmLogService
action
.
setSystemIds
(
equipmentSpecificIndex
.
getSystemId
());
.
getById
(
equipmentSpecificAlarmLog
.
getId
());
action
.
setSystemCodes
(
this
.
getSystemCodeBySpeId
(
equipmentSpecificIndex
.
getSystemId
()));
new
Thread
(
new
Runnable
()
{
action
.
setUpdateDate
(
new
Date
());
@Override
equipmentSpecificAlarmList
.
add
(
action
);
public
void
run
()
{
});
syncSystemctlMsg
(
alarmLog
);
}
}
return
equipmentSpecificAlarmList
;
}).
start
();
}
}
return
equipmentSpecificAlarmLog
;
private
boolean
ifSendToGis
(
List
<
CarIndexGisVo
>
list
)
{
}
boolean
flag
=
true
;
List
<
CarIndexGisVo
>
list1
=
list
.
stream
().
filter
(
x
->
CarForGisEnum
.
JD
.
getNameKey
().
equals
(
x
.
getNameKey
())).
collect
(
Collectors
.
toList
());
/**
List
<
CarIndexGisVo
>
list2
=
list
.
stream
().
filter
(
x
->
CarForGisEnum
.
WD
.
getNameKey
().
equals
(
x
.
getNameKey
())).
collect
(
Collectors
.
toList
());
* 添加告警
for
(
CarIndexGisVo
gisVo
:
list
)
{
*
if
(
CarForGisEnum
.
JD
.
getNameKey
().
equals
(
gisVo
.
getNameKey
()))
{
* @param equipmentSpecificAlarms
if
(!
StringUtil
.
isNotEmpty
(
gisVo
.
getValue
())
||
"0"
.
equals
(
gisVo
.
getValue
()))
{
* @param equipmentSpecificIndex
flag
=
false
;
* @return
continue
;
*/
}
private
List
<
EquipmentSpecificAlarm
>
addEquipmentSpecificAlarm
(
List
<
EquipmentSpecificAlarm
>
equipmentSpecificAlarms
,
}
EquipmentSpecificIndex
equipmentSpecificIndex
,
EquipmentSpecificAlarm
equipmentSpecificAlarm
)
{
if
(
CarForGisEnum
.
WD
.
getNameKey
().
equals
(
gisVo
.
getNameKey
())
||
"0"
.
equals
(
gisVo
.
getValue
()))
{
BeanUtils
.
copyProperties
(
equipmentSpecificIndex
,
equipmentSpecificAlarm
);
if
(!
StringUtil
.
isNotEmpty
(
gisVo
.
getValue
()))
{
equipmentSpecificAlarm
.
setId
(
null
);
flag
=
false
;
equipmentSpecificAlarm
.
setFrequency
(
1
);
continue
;
equipmentSpecificAlarm
.
setStatus
(
AlarmStatusEnum
.
BJ
.
getCode
());
}
equipmentSpecificAlarm
.
setEquipmentSpecificIndexKey
(
equipmentSpecificIndex
.
getNameKey
());
}
equipmentSpecificAlarm
.
setEquipmentSpecificIndexValue
(
equipmentSpecificIndex
.
getValue
());
}
equipmentSpecificAlarm
.
setEquipmentSpecificIndexLabel
(
equipmentSpecificIndex
.
getValueLabel
());
if
(
list1
.
size
()
==
0
||
list2
.
size
()
==
0
)
{
equipmentSpecificAlarm
.
setType
(
equipmentSpecificIndex
.
getTypeCode
());
flag
=
false
;
equipmentSpecificAlarm
.
setCreateDate
(
new
Date
());
}
equipmentSpecificAlarm
.
setUpdateDate
(
new
Date
());
return
flag
;
equipmentSpecificAlarm
.
setEquipmentCode
(
equipmentSpecificIndex
.
getEquipmentCode
());
}
equipmentSpecificAlarm
.
setEquipmentId
(
equipmentSpecificIndex
.
getEquipmentId
());
equipmentSpecificAlarm
.
setEquipmentDetailId
(
equipmentSpecificIndex
.
getEquipmentDetailId
());
/**
equipmentSpecificAlarm
.
setEquipmentSpecificCode
(
equipmentSpecificIndex
.
getEquipmentSpecificCode
());
* 接收到的IOT数据为火眼存储到Map中
equipmentSpecificAlarm
.
setEmergencyLevel
(
equipmentSpecificIndex
.
getEmergencyLevel
());
*/
equipmentSpecificAlarm
.
setEmergencyLevelColor
(
equipmentSpecificIndex
.
getEmergencyLevelColor
());
private
void
iotDataListToCacheMap
(
List
<
IotDataVO
>
iotDatalist
)
{
equipmentSpecificAlarm
.
setEmergencyLevelDescribe
(
equipmentSpecificIndex
.
getEmergencyLevelDescribe
());
List
<
IotDataVO
>
iotDataVOs
=
iotDatalist
.
stream
().
filter
(
x
->
"alarmLevel"
.
equals
(
x
.
getKey
())
||
"alarmType"
.
equals
(
x
.
getKey
())
||
"temperature"
.
equals
(
x
.
getKey
())
equipmentSpecificAlarms
.
add
(
equipmentSpecificAlarm
);
||
"ruleTemperature"
.
equals
(
x
.
getKey
())
||
"thermometryUnit"
.
equals
(
x
.
getKey
())
||
"alarmRule"
.
equals
(
x
.
getKey
())).
collect
(
Collectors
.
toList
());
return
equipmentSpecificAlarms
;
if
(
iotDataVOs
.
size
()
>
0
)
{
}
Map
<
String
,
Object
>
map
=
iotDatalist
.
stream
().
collect
(
Collectors
.
toMap
(
IotDataVO:
:
getKey
,
IotDataVO:
:
getValue
));
putTemperatureMap
(
map
.
get
(
"traceId"
).
toString
(),
map
);
// NB装备告警
}
private
List
<
EquipmentSpecificAlarm
>
getNbEquipAlarmList
(
List
<
EquipmentSpecificAlarm
>
indexAlarms
,
}
EquipmentSpecificIndex
equipmentSpecificIndex
,
EquipmentSpecificAlarm
equipmentSpecificAlarm
)
{
List
<
EquipmentSpecificAlarm
>
equipmentSpecificAlarmList
=
new
ArrayList
<>();
/**
if
(
ValidationUtil
.
isEmpty
(
indexAlarms
))
{
// 告警表为空,新增告警数据
* 处理火眼逻辑合并为一条告警
addEquipmentSpecificAlarm
(
equipmentSpecificAlarmList
,
equipmentSpecificIndex
,
equipmentSpecificAlarm
);
*/
if
(!
checkStateIsNormal
(
equipmentSpecificAlarm
,
equipmentSpecificIndex
))
{
private
EquipmentSpecificIndex
handleTemperatureAlarm
(
EquipmentSpecificIndex
equipmentSpecificIndex
,
List
<
IotDataVO
>
iotDatalist
)
{
return
equipmentSpecificAlarmList
;
List
<
IotDataVO
>
collect
=
iotDatalist
.
stream
().
filter
(
x
->
"traceId"
.
equals
(
x
.
getKey
())).
collect
(
Collectors
.
toList
());
}
else
{
if
(
collect
.
size
()
>
0
&&
temperatureMapIsEmpty
(
String
.
valueOf
(
collect
.
get
(
0
).
getValue
())))
{
equipmentSpecificAlarmList
.
clear
();
String
traceId
=
String
.
valueOf
(
collect
.
get
(
0
).
getValue
());
}
TemperatureAlarmDto
dto
=
temperatureMap
.
get
(
traceId
);
}
else
{
equipmentSpecificIndex
.
setEquipmentSpecificIndexName
(
AlarmTypeEnum
.
getTypeByCode
(
AlarmTypeEnum
.
GZGJ
.
getCode
()));
indexAlarms
.
forEach
(
action
->
{
equipmentSpecificIndex
.
setNameKey
(
AlarmTypeEnum
.
GZGJ
.
getCode
());
// 状态为正常或报警解除
equipmentSpecificIndex
.
setAlamReason
(
TemperatureAlarm
.
getAlarmContent
(
dto
.
getAlarmLevel
(),
dto
.
getAlarmType
(),
dto
.
getAlarmRule
(),
dto
.
getRuleTemperature
(),
dto
.
getTemperature
(),
dto
.
getThermometryUnit
()));
if
(
checkStateIsNormal
(
action
,
equipmentSpecificIndex
))
{
equipmentSpecificIndex
.
setValue
(
"true"
);
// 修改报警数据为正常
equipmentSpecificIndex
.
setIsAlarm
(
1
);
action
.
setRecoveryDate
(
new
Date
());
temperatureMap
.
remove
(
traceId
);
action
.
setStatus
(
AlarmStatusEnum
.
HF
.
getCode
());
}
// 修改之前数据为已处理
return
equipmentSpecificIndex
;
action
.
setResolveResult
(
action
.
getAlamReason
());
}
action
.
setConfirmUserName
(
"系统"
);
action
.
setConfirmType
(
action
.
getType
());
/**
equipmentSpecificAlarmLogService
.
updateAlarmLogByIotCodeAndIndexKey
(
action
);
* temperatureMap存储数据
}
else
{
*/
action
.
setFrequency
((
action
.
getFrequency
()
+
1
));
private
void
putTemperatureMap
(
String
traceId
,
Map
<
String
,
Object
>
map
)
{
}
TemperatureAlarmDto
cacheTemperatureAlarmDto
=
temperatureMap
.
get
(
traceId
);
// 更新所在系统,设备可能编辑过
if
(
ValidationUtil
.
isEmpty
(
cacheTemperatureAlarmDto
))
{
action
.
setSystemIds
(
equipmentSpecificIndex
.
getSystemId
());
cacheTemperatureAlarmDto
=
new
TemperatureAlarmDto
();
action
.
setSystemCodes
(
this
.
getSystemCodeBySpeId
(
equipmentSpecificIndex
.
getSystemId
()));
}
action
.
setUpdateDate
(
new
Date
());
TemperatureAlarmDto
newMap
=
JSON
.
parseObject
(
JSON
.
toJSONString
(
map
),
TemperatureAlarmDto
.
class
);
equipmentSpecificAlarmList
.
add
(
action
);
BeanUtil
.
copyPropertiesIgnoreNull
(
newMap
,
cacheTemperatureAlarmDto
);
});
temperatureMap
.
put
(
traceId
,
cacheTemperatureAlarmDto
);
}
}
return
equipmentSpecificAlarmList
;
}
private
boolean
temperatureMapIsEmpty
(
String
traceId
)
{
TemperatureAlarmDto
dto
=
temperatureMap
.
get
(
traceId
);
private
boolean
ifSendToGis
(
List
<
CarIndexGisVo
>
list
)
{
if
(!
ValidationUtil
.
isEmpty
(
dto
)
&&
!
ValidationUtil
.
isEmpty
(
dto
.
getAlarmLevel
())
&&
!
ValidationUtil
.
isEmpty
(
dto
.
getAlarmType
())
&&
!
ValidationUtil
.
isEmpty
(
dto
.
getAlarmRule
())
boolean
flag
=
true
;
&&
!
ValidationUtil
.
isEmpty
(
dto
.
getRuleTemperature
())
&&
!
ValidationUtil
.
isEmpty
(
dto
.
getTemperature
())
&&
!
ValidationUtil
.
isEmpty
(
dto
.
getThermometryUnit
()))
{
List
<
CarIndexGisVo
>
list1
=
list
.
stream
().
filter
(
x
->
CarForGisEnum
.
JD
.
getNameKey
().
equals
(
x
.
getNameKey
()))
return
true
;
.
collect
(
Collectors
.
toList
());
}
List
<
CarIndexGisVo
>
list2
=
list
.
stream
().
filter
(
x
->
CarForGisEnum
.
WD
.
getNameKey
().
equals
(
x
.
getNameKey
()))
return
false
;
.
collect
(
Collectors
.
toList
());
}
for
(
CarIndexGisVo
gisVo
:
list
)
{
if
(
CarForGisEnum
.
JD
.
getNameKey
().
equals
(
gisVo
.
getNameKey
()))
{
if
(!
StringUtil
.
isNotEmpty
(
gisVo
.
getValue
())
||
"0"
.
equals
(
gisVo
.
getValue
()))
{
/**
flag
=
false
;
* 判断是否为NB物联监测设备参数
continue
;
*
}
* @param nameKey
}
* @return
if
(
CarForGisEnum
.
WD
.
getNameKey
().
equals
(
gisVo
.
getNameKey
())
||
"0"
.
equals
(
gisVo
.
getValue
()))
{
*/
if
(!
StringUtil
.
isNotEmpty
(
gisVo
.
getValue
()))
{
private
boolean
verifyNB
(
String
nameKey
)
{
flag
=
false
;
return
nameKey
.
startsWith
(
"NB_"
);
continue
;
}
}
}
/**
}
* 判断状态为正常或报警解除
if
(
list1
.
size
()
==
0
||
list2
.
size
()
==
0
)
{
*/
flag
=
false
;
private
boolean
checkStateIsNormal
(
EquipmentSpecificAlarm
equipmentSpecificAlarm
,
EquipmentSpecificIndex
equipmentSpecificIndex
)
{
}
String
enumKey
=
String
.
format
(
"%s_%s"
,
equipmentSpecificAlarm
.
getEquipmentSpecificIndexKey
(),
equipmentSpecificIndex
.
getValue
());
return
flag
;
equipmentSpecificAlarm
.
setAlamReason
(
equipmentSpecificAlarm
.
getEquipmentSpecificIndexName
().
replace
(
"NB_"
,
""
)
}
+
":"
+
NBalarmEnum
.
getDescByKey
(
enumKey
));
boolean
flag
=
false
;
/**
if
(!
ValidationUtil
.
isEmpty
(
equipmentSpecificAlarm
.
getType
())
* 接收到的IOT数据为火眼存储到Map中
&&
!
ValidationUtil
.
isEmpty
(
equipmentSpecificAlarm
.
getIotCode
())
*/
&&
!
ValidationUtil
.
isEmpty
(
equipmentSpecificAlarm
.
getEquipmentSpecificIndexKey
())
private
void
iotDataListToCacheMap
(
List
<
IotDataVO
>
iotDatalist
)
{
&&
(
NBalarmEnum
.
NB_liquid_level_state_0
.
getKey
().
equals
(
enumKey
)
List
<
IotDataVO
>
iotDataVOs
=
iotDatalist
.
stream
()
||
NBalarmEnum
.
NB_error_code_0
.
getKey
().
equals
(
enumKey
)
.
filter
(
x
->
"alarmLevel"
.
equals
(
x
.
getKey
())
||
"alarmType"
.
equals
(
x
.
getKey
())
||
NBalarmEnum
.
NB_battery_state_0
.
getKey
().
equals
(
enumKey
)
||
"temperature"
.
equals
(
x
.
getKey
())
||
"ruleTemperature"
.
equals
(
x
.
getKey
())
||
NBalarmEnum
.
NB_hydraulic_state_0
.
getKey
().
equals
(
enumKey
)
||
"thermometryUnit"
.
equals
(
x
.
getKey
())
||
"alarmRule"
.
equals
(
x
.
getKey
()))
||
NBalarmEnum
.
NB_hydraulic_state_2
.
getKey
().
equals
(
enumKey
)
.
collect
(
Collectors
.
toList
());
||
NBalarmEnum
.
NB_hydraulic_state_4
.
getKey
().
equals
(
enumKey
)
if
(
iotDataVOs
.
size
()
>
0
)
{
||
NBalarmEnum
.
NB_alarm_status_4
.
getKey
().
equals
(
enumKey
)))
{
Map
<
String
,
Object
>
map
=
iotDatalist
.
stream
()
flag
=
true
;
.
collect
(
Collectors
.
toMap
(
IotDataVO:
:
getKey
,
IotDataVO:
:
getValue
));
}
putTemperatureMap
(
map
.
get
(
"traceId"
).
toString
(),
map
);
return
flag
;
}
}
}
/**
/**
* 处理火眼逻辑合并为一条告警
* 装备实时数据处理
*/
* @param iotDatalist
private
EquipmentSpecificIndex
handleTemperatureAlarm
(
EquipmentSpecificIndex
equipmentSpecificIndex
,
* @param indexList
List
<
IotDataVO
>
iotDatalist
)
{
* @param topicEntity
List
<
IotDataVO
>
collect
=
iotDatalist
.
stream
().
filter
(
x
->
"traceId"
.
equals
(
x
.
getKey
()))
*/
.
collect
(
Collectors
.
toList
());
private
void
equipRealTimeDate
(
List
<
IotDataVO
>
iotDatalist
,
List
<
EquipmentSpecificIndex
>
indexList
,
TopicEntityVo
topicEntity
){
if
(
collect
.
size
()
>
0
&&
temperatureMapIsEmpty
(
String
.
valueOf
(
collect
.
get
(
0
).
getValue
())))
{
List
<
EquipmentSpecificIndex
>
equipmentSpecificIndexList
=
new
ArrayList
<>();
String
traceId
=
String
.
valueOf
(
collect
.
get
(
0
).
getValue
());
List
<
EquipmentSpecificAlarm
>
equipmentSpecificAlarms
=
new
ArrayList
<>();
TemperatureAlarmDto
dto
=
temperatureMap
.
get
(
traceId
);
List
<
IndexStateVo
>
indexStateList
=
new
ArrayList
<>();
equipmentSpecificIndex
// 存储温度数据至内存中(火眼)
.
setEquipmentSpecificIndexName
(
AlarmTypeEnum
.
getTypeByCode
(
AlarmTypeEnum
.
GZGJ
.
getCode
()));
iotDataListToCacheMap
(
iotDatalist
);
equipmentSpecificIndex
.
setNameKey
(
AlarmTypeEnum
.
GZGJ
.
getCode
());
equipmentSpecificIndex
.
setAlamReason
(
iotDatalist
.
forEach
(
iotDataVO
->
{
TemperatureAlarm
.
getAlarmContent
(
dto
.
getAlarmLevel
(),
dto
.
getAlarmType
(),
dto
.
getAlarmRule
(),
for
(
EquipmentSpecificIndex
equipmentSpecificIndex
:
indexList
)
{
dto
.
getRuleTemperature
(),
dto
.
getTemperature
(),
dto
.
getThermometryUnit
()));
if
(!
ObjectUtils
.
isEmpty
(
equipmentSpecificIndex
.
getNameKey
())
equipmentSpecificIndex
.
setValue
(
"true"
);
&&
equipmentSpecificIndex
.
getNameKey
().
toLowerCase
().
equals
(
iotDataVO
.
getKey
().
toLowerCase
()))
{
equipmentSpecificIndex
.
setIsAlarm
(
1
);
EquipmentSpecificIndex
equipmentSpeIndex
=
new
EquipmentSpecificIndex
();
temperatureMap
.
remove
(
traceId
);
BeanUtils
.
copyProperties
(
equipmentSpecificIndex
,
equipmentSpeIndex
);
}
String
value
=
iotDataVO
.
getValue
().
toString
();
return
equipmentSpecificIndex
;
equipmentSpeIndex
.
setValue
(
value
);
}
equipmentSpeIndex
.
setValueLabel
(
valueTranslate
(
value
,
equipmentSpecificIndex
.
getValueEnum
()));
equipmentSpeIndex
.
setUpdateDate
(
new
Date
());
/**
equipmentSpecificIndexService
.
updateById
(
equipmentSpeIndex
);
* temperatureMap存储数据
*/
equipmentSpecificIndexList
.
add
(
equipmentSpeIndex
);
private
void
putTemperatureMap
(
String
traceId
,
Map
<
String
,
Object
>
map
)
{
TemperatureAlarmDto
cacheTemperatureAlarmDto
=
temperatureMap
.
get
(
traceId
);
indexStateList
.
add
(
createIndexStateVo
(
equipmentSpeIndex
));
if
(
ValidationUtil
.
isEmpty
(
cacheTemperatureAlarmDto
))
{
cacheTemperatureAlarmDto
=
new
TemperatureAlarmDto
();
// 向预控系统发送消息
}
sendEquipSpecIndexToAutosysTopic
(
equipmentSpeIndex
);
TemperatureAlarmDto
newMap
=
JSON
.
parseObject
(
JSON
.
toJSONString
(
map
),
TemperatureAlarmDto
.
class
);
BeanUtil
.
copyPropertiesIgnoreNull
(
newMap
,
cacheTemperatureAlarmDto
);
temperatureMap
.
put
(
traceId
,
cacheTemperatureAlarmDto
);
// 添加指标报告
}
saveEquipmentAlarmReportDay
(
equipmentSpeIndex
);
private
boolean
temperatureMapIsEmpty
(
String
traceId
)
{
//火眼数据构造告警指标逻辑
TemperatureAlarmDto
dto
=
temperatureMap
.
get
(
traceId
);
equipmentSpecificIndex
=
handleTemperatureAlarm
(
equipmentSpeIndex
,
iotDatalist
);
if
(!
ValidationUtil
.
isEmpty
(
dto
)
&&
!
ValidationUtil
.
isEmpty
(
dto
.
getAlarmLevel
())
&&
!
ValidationUtil
.
isEmpty
(
dto
.
getAlarmType
())
&&
!
ValidationUtil
.
isEmpty
(
dto
.
getAlarmRule
())
//指标告警处理
&&
!
ValidationUtil
.
isEmpty
(
dto
.
getRuleTemperature
())
&&
!
ValidationUtil
.
isEmpty
(
dto
.
getTemperature
())
if
(
equipmentSpecificIndex
.
getIsAlarm
()
!=
null
&&
1
==
equipmentSpecificIndex
.
getIsAlarm
()){
&&
!
ValidationUtil
.
isEmpty
(
dto
.
getThermometryUnit
()))
{
equipmentSpecificAlarms
.
addAll
(
createIndexAlarmRecord
(
equipmentSpecificIndex
));
return
true
;
}
}
return
false
;
}
}
}
});
/**
* 判断是否为NB物联监测设备参数
// 首页性能指标数据订阅
*
mqttSendGateway
.
sendToMqtt
(
indexTopic
,
JSON
.
toJSONString
(
indexStateList
));
* @param nameKey
* @return
//组态大屏消息推送,设备表实时指标修改
*/
intePageSysDataRefresh
(
equipmentSpecificIndexList
,
topicEntity
);
private
boolean
verifyNB
(
String
nameKey
)
{
return
nameKey
.
startsWith
(
"NB_"
);
//数字换流站同步指标修改
}
syncSpecificIndexsToGS
(
equipmentSpecificIndexList
);
/**
// 报警数据保存
* 判断状态为正常或报警解除
saveOrUpdateEquipAlarm
(
equipmentSpecificAlarms
);
*/
private
boolean
checkStateIsNormal
(
EquipmentSpecificAlarm
equipmentSpecificAlarm
,
//则更新拓扑节点数据及告警状态
EquipmentSpecificIndex
equipmentSpecificIndex
)
{
updateNodeDateByEquipId
(
equipmentSpecificIndexList
);
String
enumKey
=
String
.
format
(
"%s_%s"
,
equipmentSpecificAlarm
.
getEquipmentSpecificIndexKey
(),
equipmentSpecificIndex
.
getValue
());
//向画布推送
equipmentSpecificAlarm
.
setAlamReason
(
equipmentSpecificAlarm
.
getEquipmentSpecificIndexName
().
replace
(
"NB_"
,
""
)
publishDataToCanvas
(
equipmentSpecificIndexList
);
+
":"
+
NBalarmEnum
.
getDescByKey
(
enumKey
));
}
boolean
flag
=
false
;
if
(!
ValidationUtil
.
isEmpty
(
equipmentSpecificAlarm
.
getType
())
&&
!
ValidationUtil
.
isEmpty
(
equipmentSpecificAlarm
.
getIotCode
())
public
void
saveOrUpdateEquipAlarm
(
List
<
EquipmentSpecificAlarm
>
equipmentSpecificAlarms
){
&&
!
ValidationUtil
.
isEmpty
(
equipmentSpecificAlarm
.
getEquipmentSpecificIndexKey
())
if
(
ObjectUtils
.
isEmpty
(
equipmentSpecificAlarms
)){
&&
(
NBalarmEnum
.
NB_liquid_level_state_0
.
getKey
().
equals
(
enumKey
)
return
;
||
NBalarmEnum
.
NB_error_code_0
.
getKey
().
equals
(
enumKey
)
}
||
NBalarmEnum
.
NB_battery_state_0
.
getKey
().
equals
(
enumKey
)
equipmentSpecificAlarmService
.
saveOrUpdateBatch
(
equipmentSpecificAlarms
);
||
NBalarmEnum
.
NB_hydraulic_state_0
.
getKey
().
equals
(
enumKey
)
List
<
EquipmentSpecificAlarmLog
>
equipmentAlarmLogs
=
new
ArrayList
<>();
||
NBalarmEnum
.
NB_hydraulic_state_2
.
getKey
().
equals
(
enumKey
)
equipmentSpecificAlarms
.
forEach
(
action
->{
||
NBalarmEnum
.
NB_hydraulic_state_4
.
getKey
().
equals
(
enumKey
)
if
(
AlarmStatusEnum
.
BJ
.
getCode
()
==
action
.
getStatus
())
{
||
NBalarmEnum
.
NB_alarm_status_4
.
getKey
().
equals
(
enumKey
)))
{
equipmentAlarmLogs
.
add
(
addEquipAlarmLogRecord
(
action
));
flag
=
true
;
if
(
ValidationUtil
.
isEmpty
(
action
.
getAlamContent
()))
{
}
action
.
setAlamContent
(
action
.
getEquipmentSpecificName
()
+
action
.
getEquipmentSpecificIndexName
());
return
flag
;
}
}
mqttSendGateway
.
sendToMqtt
(
TopicEnum
.
EQDQR
.
getTopic
(),
JSONArray
.
toJSON
(
action
).
toString
());
}
else
{
public
List
<
EquipmentSpecificAlarmLog
>
saveOrUpdateEquipAlarm
(
equipmentAlarmLogs
.
addAll
(
upAlarmLogStatus
(
action
.
getIotCode
(),
action
.
getEquipmentSpecificIndexKey
(),
equipmentSpecificAlarmLogService
));
List
<
EquipmentSpecificAlarm
>
equipmentSpecificAlarms
)
{
mqttSendGateway
.
sendToMqtt
(
TopicEnum
.
EQYQR
.
getTopic
(),
JSONArray
.
toJSON
(
action
).
toString
());
List
<
EquipmentSpecificAlarmLog
>
equipmentAlarmLogs
=
new
ArrayList
<>();
bool
=
Boolean
.
TRUE
;
if
(
ObjectUtils
.
isEmpty
(
equipmentSpecificAlarms
))
{
}
return
equipmentAlarmLogs
;
}
});
equipmentSpecificAlarmService
.
saveOrUpdateBatch
(
equipmentSpecificAlarms
);
equipmentSpecificAlarms
.
forEach
(
action
->
{
TransactionSynchronizationManager
.
registerSynchronization
(
new
TransactionSynchronization
()
{
if
(
AlarmStatusEnum
.
BJ
.
getCode
()
==
action
.
getStatus
())
{
@Override
equipmentAlarmLogs
.
add
(
addEquipAlarmLogRecord
(
action
));
public
void
afterCommit
()
{
if
(
ValidationUtil
.
isEmpty
(
action
.
getAlamContent
()))
{
JSONObject
jsonObject
=
new
JSONObject
();
action
.
setAlamContent
(
action
.
getEquipmentSpecificName
()
+
action
.
getEquipmentSpecificIndexName
());
jsonObject
.
put
(
"seqNo"
,
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
).
toLowerCase
());
}
mqttSendGateway
.
sendToMqtt
(
TopicEnum
.
ALARM_LOG_INSERT
.
getTopic
(),
jsonObject
.
toString
());
mqttSendGateway
.
sendToMqtt
(
TopicEnum
.
EQDQR
.
getTopic
(),
JSONArray
.
toJSON
(
action
).
toString
());
mqttSendGateway
.
sendToMqtt
(
TopicEnum
.
EQZXDT
.
getTopic
(),
""
);
}
else
{
// 数字换流站数据处理(高斯库同步及南瑞告警推送)
equipmentAlarmLogs
.
addAll
(
upAlarmLogStatus
(
action
.
getIotCode
(),
action
.
getEquipmentSpecificIndexKey
(),
if
(
syncSwitch
)
{
equipmentSpecificAlarmLogService
));
List
<
FireEquipmentFireAlarm
>
alarmList
=
createFireEquipmentFireAlarmVo
(
equipmentAlarmLogs
);
mqttSendGateway
.
sendToMqtt
(
TopicEnum
.
EQYQR
.
getTopic
(),
JSONArray
.
toJSON
(
action
).
toString
());
if
(!
CollectionUtils
.
isEmpty
(
alarmList
))
{
bool
=
Boolean
.
TRUE
;
Map
<
String
,
List
<
FireEquipmentFireAlarm
>>
collect
=
alarmList
.
stream
().
collect
(
Collectors
.
groupingBy
(
FireEquipmentFireAlarm:
:
getType
));
}
for
(
String
key
:
collect
.
keySet
())
{
});
List
<
FireEquipmentFireAlarm
>
list
=
collect
.
get
(
key
);
return
equipmentAlarmLogs
;
if
(!
CollectionUtils
.
isEmpty
(
list
))
{
}
if
(
"FIREALARM"
.
equalsIgnoreCase
(
key
))
{
syncDataService
.
syncCreatedFireEquipAlarm
(
list
);
/**
}
else
if
(
"BREAKDOWN"
.
equalsIgnoreCase
(
key
))
{
* 报警日志同步其他系统
List
<
FireEquipmentFaultAlarm
>
faultAlarms
=
list
.
stream
().
map
(
x
->
{
*
FireEquipmentFaultAlarm
fireEquipmentFaultAlarm
=
new
FireEquipmentFaultAlarm
();
* @param equipmentAlarmLogs
BeanUtils
.
copyProperties
(
x
,
fireEquipmentFaultAlarm
);
*/
return
fireEquipmentFaultAlarm
;
public
void
equipmentAlarmLogsToOtherSystems
(
List
<
EquipmentSpecificAlarmLog
>
equipmentAlarmLogs
)
{
}).
collect
(
Collectors
.
toList
());
if
(
ObjectUtils
.
isEmpty
(
equipmentAlarmLogs
))
{
syncDataService
.
syncCreatedFireEquiptFaultAlarm
(
faultAlarms
);
return
;
}
else
if
(
"SHIELD"
.
equalsIgnoreCase
(
key
))
{
}
List
<
FireEquipmentDefectAlarm
>
defectAlarms
=
list
.
stream
().
map
(
x
->
{
JSONObject
jsonObject
=
new
JSONObject
();
FireEquipmentDefectAlarm
fireEquipmentFaultAlarm
=
new
FireEquipmentDefectAlarm
();
jsonObject
.
put
(
"seqNo"
,
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
).
toLowerCase
());
BeanUtils
.
copyProperties
(
x
,
fireEquipmentFaultAlarm
);
mqttSendGateway
.
sendToMqtt
(
TopicEnum
.
ALARM_LOG_INSERT
.
getTopic
(),
jsonObject
.
toString
());
return
fireEquipmentFaultAlarm
;
mqttSendGateway
.
sendToMqtt
(
TopicEnum
.
EQZXDT
.
getTopic
(),
""
);
}).
collect
(
Collectors
.
toList
());
// 数字换流站数据处理(高斯库同步及南瑞告警推送)
syncDataService
.
syncCreatedFireEquipDefectAlarm
(
defectAlarms
);
if
(
syncSwitch
)
{
}
List
<
FireEquipmentFireAlarm
>
alarmList
=
createFireEquipmentFireAlarmVo
(
equipmentAlarmLogs
);
}
if
(!
CollectionUtils
.
isEmpty
(
alarmList
))
{
}
Map
<
String
,
List
<
FireEquipmentFireAlarm
>>
collect
=
alarmList
.
stream
()
}
.
collect
(
Collectors
.
groupingBy
(
FireEquipmentFireAlarm:
:
getType
));
for
(
String
key
:
collect
.
keySet
())
{
// 向南瑞平台推送报警消息
List
<
FireEquipmentFireAlarm
>
list
=
collect
.
get
(
key
);
if
(!
bool
){
if
(!
CollectionUtils
.
isEmpty
(
list
))
{
syncDataService
.
syncCreatedSendAlarm
(
equipmentAlarmLogs
);
if
(
"FIREALARM"
.
equalsIgnoreCase
(
key
))
{
}
syncDataService
.
syncCreatedFireEquipAlarm
(
list
);
}
}
else
if
(
"BREAKDOWN"
.
equalsIgnoreCase
(
key
))
{
}
List
<
FireEquipmentFaultAlarm
>
faultAlarms
=
list
.
stream
().
map
(
x
->
{
});
FireEquipmentFaultAlarm
fireEquipmentFaultAlarm
=
new
FireEquipmentFaultAlarm
();
BeanUtils
.
copyProperties
(
x
,
fireEquipmentFaultAlarm
);
}
return
fireEquipmentFaultAlarm
;
}).
collect
(
Collectors
.
toList
());
/**
syncDataService
.
syncCreatedFireEquiptFaultAlarm
(
faultAlarms
);
* 组装数字换流站平台告警数据
}
else
if
(
"SHIELD"
.
equalsIgnoreCase
(
key
))
{
* @param
List
<
FireEquipmentDefectAlarm
>
defectAlarms
=
list
.
stream
().
map
(
x
->
{
* @return
FireEquipmentDefectAlarm
fireEquipmentFaultAlarm
=
new
FireEquipmentDefectAlarm
();
*/
BeanUtils
.
copyProperties
(
x
,
fireEquipmentFaultAlarm
);
private
List
<
FireEquipmentFireAlarm
>
createFireEquipmentFireAlarmVo
(
List
<
EquipmentSpecificAlarmLog
>
equipmentAlarmLogs
){
return
fireEquipmentFaultAlarm
;
Map
<
String
,
String
>
stationInfo
=
equipmentSpecificMapper
.
getStationInfo
().
get
(
0
);
}).
collect
(
Collectors
.
toList
());
List
<
FireEquipmentFireAlarm
>
alarmList
=
new
ArrayList
<>();
syncDataService
.
syncCreatedFireEquipDefectAlarm
(
defectAlarms
);
equipmentAlarmLogs
.
forEach
(
action
->{
}
FireEquipmentFireAlarm
alarm
=
new
FireEquipmentFireAlarm
();
}
BeanUtils
.
copyProperties
(
action
,
alarm
);
}
alarm
.
setAliasname
(
StringUtil
.
toNotEmptyString
(
action
.
getEquipmentSpecificIndexName
()));
}
alarm
.
setEquipmentMeasurementId
(
StringUtil
.
toNotEmptyString
(
action
.
getEquipmentIndexId
().
toString
()));
alarm
.
setEquipmentMeasurementMRid
(
StringUtil
.
toNotEmptyString
(
action
.
getEquipmentIndexId
().
toString
()));
// 向南瑞平台推送报警消息
alarm
.
setFieldLabel
(
StringUtil
.
toNotEmptyString
(
action
.
getEquipmentSpecificIndexKey
()));
if
(!
bool
)
{
alarm
.
setFieldName
(
StringUtil
.
toNotEmptyString
(
action
.
getEquipmentSpecificIndexName
()));
syncDataService
.
syncCreatedSendAlarm
(
equipmentAlarmLogs
);
alarm
.
setFireEquipmentId
(
StringUtil
.
toNotEmptyString
(
action
.
getEquipmentSpecificId
().
toString
()));
}
alarm
.
setFireEquipmentMRid
(
StringUtil
.
toNotEmptyString
(
action
.
getEquipmentSpecificCode
()));
}
alarm
.
setFireEquipmentName
(
StringUtil
.
toNotEmptyString
(
action
.
getEquipmentSpecificName
()));
}
alarm
.
setFrequency
(
1
);
alarm
.
setId
(
StringUtil
.
toNotEmptyString
(
action
.
getId
().
toString
()));
/**
alarm
.
setMrid
(
action
.
getId
().
toString
());
* 组装数字换流站平台告警数据
alarm
.
setName
(
action
.
getEquipmentSpecificIndexName
());
*
alarm
.
setRecoveryDate
(
action
.
getUpdateDate
());
* @param
alarm
.
setStationCode
(
StringUtil
.
toNotEmptyString
(
stationInfo
.
get
(
"stationCode"
)));
* @return
alarm
.
setStationName
(
StringUtil
.
toNotEmptyString
(
stationInfo
.
get
(
"stationName"
)));
*/
alarm
.
setValue
(
StringUtil
.
toNotEmptyString
(
action
.
getEquipmentSpecificIndexValue
()));
private
List
<
FireEquipmentFireAlarm
>
createFireEquipmentFireAlarmVo
(
alarmList
.
add
(
alarm
);
List
<
EquipmentSpecificAlarmLog
>
equipmentAlarmLogs
)
{
});
Map
<
String
,
String
>
stationInfo
=
equipmentSpecificMapper
.
getStationInfo
().
get
(
0
);
return
alarmList
;
List
<
FireEquipmentFireAlarm
>
alarmList
=
new
ArrayList
<>();
}
equipmentAlarmLogs
.
forEach
(
action
->
{
FireEquipmentFireAlarm
alarm
=
new
FireEquipmentFireAlarm
();
/**
BeanUtils
.
copyProperties
(
action
,
alarm
);
* 高斯库同步指标修改
alarm
.
setAliasname
(
StringUtil
.
toNotEmptyString
(
action
.
getEquipmentSpecificIndexName
()));
* @param equipmentSpecificIndexList
alarm
.
setEquipmentMeasurementId
(
StringUtil
.
toNotEmptyString
(
action
.
getEquipmentIndexId
().
toString
()));
*/
alarm
.
setEquipmentMeasurementMRid
(
StringUtil
.
toNotEmptyString
(
action
.
getEquipmentIndexId
().
toString
()));
private
void
syncSpecificIndexsToGS
(
List
<
EquipmentSpecificIndex
>
equipmentSpecificIndexList
){
alarm
.
setFieldLabel
(
StringUtil
.
toNotEmptyString
(
action
.
getEquipmentSpecificIndexKey
()));
if
(!
ObjectUtils
.
isEmpty
(
equipmentSpecificIndexList
)
&&
syncSwitch
)
{
alarm
.
setFieldName
(
StringUtil
.
toNotEmptyString
(
action
.
getEquipmentSpecificIndexName
()));
// 数据同步
alarm
.
setFireEquipmentId
(
StringUtil
.
toNotEmptyString
(
action
.
getEquipmentSpecificId
().
toString
()));
List
<
EquipmentIndexVO
>
fireEquipMeasurementCollect
=
new
ArrayList
<>();
alarm
.
setFireEquipmentMRid
(
StringUtil
.
toNotEmptyString
(
action
.
getEquipmentSpecificCode
()));
equipmentSpecificIndexList
.
forEach
(
action
->{
alarm
.
setFireEquipmentName
(
StringUtil
.
toNotEmptyString
(
action
.
getEquipmentSpecificName
()));
EquipmentIndexVO
equipmentIndexVO
=
new
EquipmentIndexVO
();
alarm
.
setFrequency
(
1
);
BeanUtils
.
copyProperties
(
action
,
equipmentIndexVO
);
alarm
.
setId
(
StringUtil
.
toNotEmptyString
(
action
.
getId
().
toString
()));
fireEquipMeasurementCollect
.
add
(
equipmentIndexVO
);
alarm
.
setMrid
(
action
.
getId
().
toString
());
});
alarm
.
setName
(
action
.
getEquipmentSpecificIndexName
());
if
(
0
<
fireEquipMeasurementCollect
.
size
())
{
alarm
.
setRecoveryDate
(
action
.
getUpdateDate
());
syncDataService
.
syncCreatedFireEquipMeasurement
(
fireEquipMeasurementCollect
);
alarm
.
setStationCode
(
StringUtil
.
toNotEmptyString
(
stationInfo
.
get
(
"stationCode"
)));
}
alarm
.
setStationName
(
StringUtil
.
toNotEmptyString
(
stationInfo
.
get
(
"stationName"
)));
}
alarm
.
setValue
(
StringUtil
.
toNotEmptyString
(
action
.
getEquipmentSpecificIndexValue
()));
}
alarmList
.
add
(
alarm
);
});
return
alarmList
;
private
IndexStateVo
createIndexStateVo
(
EquipmentSpecificIndex
equipmentSpecificIndex
){
}
IndexStateVo
indexStateVo
=
new
IndexStateVo
();
BeanUtils
.
copyProperties
(
equipmentSpecificIndex
,
indexStateVo
);
/**
indexStateVo
.
setId
(
equipmentSpecificIndex
.
getIotCode
()
+
"_"
+
equipmentSpecificIndex
.
getNameKey
());
* 高斯库同步指标修改
indexStateVo
.
setData
(
equipmentSpecificIndex
.
getValue
());
*
indexStateVo
.
setIndexKey
(
equipmentSpecificIndex
.
getNameKey
());
* @param equipmentSpecificIndexList
return
indexStateVo
;
*/
}
private
void
syncSpecificIndexsToGS
(
List
<
EquipmentSpecificIndex
>
equipmentSpecificIndexList
)
{
if
(!
ObjectUtils
.
isEmpty
(
equipmentSpecificIndexList
)
&&
syncSwitch
)
{
// 数据同步
public
List
<
EquipmentSpecificAlarm
>
createIndexAlarmRecord
(
EquipmentSpecificIndex
equipmentSpcIndex
)
{
List
<
EquipmentIndexVO
>
fireEquipMeasurementCollect
=
new
ArrayList
<>();
// 处理火眼视频异常
equipmentSpecificIndexList
.
forEach
(
action
->
{
List
<
EquipmentSpecificAlarm
>
equipmentSpecificAlarms
=
new
ArrayList
<>();
EquipmentIndexVO
equipmentIndexVO
=
new
EquipmentIndexVO
();
EquipmentSpecificAlarm
equipmentSpecificAlarm
=
new
EquipmentSpecificAlarm
();
BeanUtils
.
copyProperties
(
action
,
equipmentIndexVO
);
equipmentSpecificAlarm
.
setSystemIds
(
equipmentSpcIndex
.
getSystemId
());
fireEquipMeasurementCollect
.
add
(
equipmentIndexVO
);
equipmentSpecificAlarm
.
setSystemCodes
(
this
.
getSystemCodeBySpeId
(
equipmentSpcIndex
.
getSystemId
()));
});
List
<
EquipmentSpecificAlarm
>
indexAlarms
=
equipmentSpecificAlarmMapper
.
findEquipmentSpecificAlarmByEquipmentSpecificIdAndEquipmentIndexIdAndStatusIstrue
(
equipmentSpcIndex
.
getEquipmentSpecificId
()
if
(
0
<
fireEquipMeasurementCollect
.
size
())
{
,
equipmentSpcIndex
.
getEquipmentIndexId
());
syncDataService
.
syncCreatedFireEquipMeasurement
(
fireEquipMeasurementCollect
);
// NB设备告警
}
if
(
verifyNB
(
equipmentSpcIndex
.
getNameKey
()))
{
}
return
getNbEquipAlarmList
(
indexAlarms
,
equipmentSpcIndex
,
equipmentSpecificAlarm
);
}
}
// 报警表新增信息
private
IndexStateVo
createIndexStateVo
(
EquipmentSpecificIndex
equipmentSpecificIndex
)
{
if
(
ObjectUtils
.
isEmpty
(
indexAlarms
)
&&
(
TrueOrFalseEnum
.
real
.
value
.
equals
(
equipmentSpcIndex
.
getValue
())))
{
IndexStateVo
indexStateVo
=
new
IndexStateVo
();
addEquipmentSpecificAlarm
(
equipmentSpecificAlarms
,
equipmentSpcIndex
,
equipmentSpecificAlarm
);
BeanUtils
.
copyProperties
(
equipmentSpecificIndex
,
indexStateVo
);
}
else
{
indexStateVo
.
setId
(
equipmentSpecificIndex
.
getIotCode
()
+
"_"
+
equipmentSpecificIndex
.
getNameKey
());
// 报警表更新信息
indexStateVo
.
setData
(
equipmentSpecificIndex
.
getValue
());
indexAlarms
.
forEach
(
action
->
{
indexStateVo
.
setIndexKey
(
equipmentSpecificIndex
.
getNameKey
());
if
(
TrueOrFalseEnum
.
real
.
value
.
equals
(
equipmentSpcIndex
.
getValue
()))
{
return
indexStateVo
;
// 报警,修改发生频率
}
action
.
setFrequency
((
action
.
getFrequency
()
+
1
));
}
else
{
public
List
<
EquipmentSpecificAlarm
>
createIndexAlarmRecord
(
EquipmentSpecificIndex
equipmentSpcIndex
)
{
// 报警恢复,修改数据为恢复状态
// 处理火眼视频异常
action
.
setRecoveryDate
(
new
Date
());
List
<
EquipmentSpecificAlarm
>
equipmentSpecificAlarms
=
new
ArrayList
<>();
action
.
setEquipmentSpecificIndexValue
(
TrueOrFalseEnum
.
fake
.
value
);
EquipmentSpecificAlarm
equipmentSpecificAlarm
=
new
EquipmentSpecificAlarm
();
action
.
setStatus
(
AlarmStatusEnum
.
HF
.
getCode
());
equipmentSpecificAlarm
.
setSystemIds
(
equipmentSpcIndex
.
getSystemId
());
}
equipmentSpecificAlarm
.
setSystemCodes
(
this
.
getSystemCodeBySpeId
(
equipmentSpcIndex
.
getSystemId
()));
action
.
setUpdateDate
(
new
Date
());
List
<
EquipmentSpecificAlarm
>
indexAlarms
=
equipmentSpecificAlarmMapper
// 更新所在系统,设备可能编辑过,更新所在系统、装备名称、装备定义code
.
findEquipmentSpecificAlarmByEquipmentSpecificIdAndEquipmentIndexIdAndStatusIstrue
(
action
.
setSystemIds
(
equipmentSpcIndex
.
getSystemId
());
equipmentSpcIndex
.
getEquipmentSpecificId
(),
equipmentSpcIndex
.
getEquipmentIndexId
());
action
.
setSystemCodes
(
this
.
getSystemCodeBySpeId
(
equipmentSpcIndex
.
getSystemId
()));
// NB设备告警
action
.
setEquipmentSpecificName
(
equipmentSpcIndex
.
getEquipmentSpecificName
());
if
(
verifyNB
(
equipmentSpcIndex
.
getNameKey
()))
{
action
.
setEquipmentCode
(
equipmentSpcIndex
.
getEquipmentCode
());
return
getNbEquipAlarmList
(
indexAlarms
,
equipmentSpcIndex
,
equipmentSpecificAlarm
);
// 冗余字段,alarm_log表更新时使用
}
action
.
setEquipmentSpecificCode
(
equipmentSpcIndex
.
getEquipmentSpecificCode
());
// 报警表新增信息
equipmentSpecificAlarms
.
add
(
action
);
if
(
ObjectUtils
.
isEmpty
(
indexAlarms
)
&&
(
TrueOrFalseEnum
.
real
.
value
.
equals
(
equipmentSpcIndex
.
getValue
())))
{
});
addEquipmentSpecificAlarm
(
equipmentSpecificAlarms
,
equipmentSpcIndex
,
equipmentSpecificAlarm
);
}
}
else
{
// 报警表更新信息
return
equipmentSpecificAlarms
;
indexAlarms
.
forEach
(
action
->
{
}
if
(
TrueOrFalseEnum
.
real
.
value
.
equals
(
equipmentSpcIndex
.
getValue
()))
{
// 报警,修改发生频率
action
.
setFrequency
((
action
.
getFrequency
()
+
1
));
/**
}
else
{
* 发送数据至换流站
// 报警恢复,修改数据为恢复状态
* @param
action
.
setRecoveryDate
(
new
Date
());
*/
action
.
setEquipmentSpecificIndexValue
(
TrueOrFalseEnum
.
fake
.
value
);
private
void
sendEquipSpecIndexToAutosysTopic
(
EquipmentSpecificIndex
equipmentSpeIndex
){
action
.
setStatus
(
AlarmStatusEnum
.
HF
.
getCode
());
}
TransactionSynchronizationManager
.
registerSynchronization
(
new
TransactionSynchronization
()
{
action
.
setUpdateDate
(
new
Date
());
@Override
// 更新所在系统,设备可能编辑过,更新所在系统、装备名称、装备定义code
public
void
afterCommit
()
{
action
.
setSystemIds
(
equipmentSpcIndex
.
getSystemId
());
String
topic
=
""
;
action
.
setSystemCodes
(
this
.
getSystemCodeBySpeId
(
equipmentSpcIndex
.
getSystemId
()));
if
(
TrueOrFalseEnum
.
real
.
value
.
equals
(
equipmentSpeIndex
.
getValue
())
&&
EquipmentRiskTypeEnum
.
HZGJ
.
getCode
().
equals
(
equipmentSpeIndex
.
getTypeCode
()))
{
action
.
setEquipmentSpecificName
(
equipmentSpcIndex
.
getEquipmentSpecificName
());
equipmentSpeIndex
.
setType
(
EquipmentRiskTypeEnum
.
HZGJ
.
getCode
());
action
.
setEquipmentCode
(
equipmentSpcIndex
.
getEquipmentCode
());
topic
=
String
.
format
(
"%s.%s%s"
,
serverName
,
"equipment/"
,
RiskLeverForAutoSys
.
BJ
.
getCode
());
// 冗余字段,alarm_log表更新时使用
}
else
if
(
TrueOrFalseEnum
.
real
.
value
.
equals
(
equipmentSpeIndex
.
getValue
())
&&
EquipmentRiskTypeEnum
.
GZ
.
getCode
().
equals
(
equipmentSpeIndex
.
getTypeCode
()))
{
action
.
setEquipmentSpecificCode
(
equipmentSpcIndex
.
getEquipmentSpecificCode
());
equipmentSpeIndex
.
setType
(
EquipmentRiskTypeEnum
.
GZ
.
getCode
());
action
.
setBuildId
(
equipmentSpcIndex
.
getBuildId
());
topic
=
String
.
format
(
"%s.%s%s"
,
serverName
,
"equipment/"
,
RiskLeverForAutoSys
.
GZ
.
getCode
());
equipmentSpecificAlarms
.
add
(
action
);
}
else
{
});
equipmentSpeIndex
.
setType
(
EquipmentRiskTypeEnum
.
QT
.
getCode
());
}
topic
=
String
.
format
(
"%s.%s%s"
,
serverName
,
"equipment/"
,
RiskLeverForAutoSys
.
JC
.
getCode
());
}
return
equipmentSpecificAlarms
;
TopicEntityVo
topicEntityVo
=
new
TopicEntityVo
();
}
topicEntityVo
.
setIotCode
(
equipmentSpeIndex
.
getIotCode
());
topicEntityVo
.
setTopic
(
topic
);
/**
topicEntityVo
.
setMessage
(
JSON
.
toJSONString
(
equipmentSpeIndex
));
* 发送数据至换流站
mqttSendGateway
.
sendToMqtt
(
topic
,
JSON
.
toJSONString
(
topicEntityVo
));
*
}
* @param
});
*/
}
public
void
sendEquipSpecIndexToAutosysTopic
(
List
<
EquipmentSpecificIndex
>
equipmentSpeIndexs
)
{
equipmentSpeIndexs
.
forEach
(
equipmentSpeIndex
->
{
String
topic
=
""
;
/**
if
(
TrueOrFalseEnum
.
real
.
value
.
equals
(
equipmentSpeIndex
.
getValue
())
* 组态大屏消息推送,设备表实时指标修改
&&
EquipmentRiskTypeEnum
.
HZGJ
.
getCode
().
equals
(
equipmentSpeIndex
.
getTypeCode
()))
{
* @param equipmentSpecificIndexList
equipmentSpeIndex
.
setType
(
EquipmentRiskTypeEnum
.
HZGJ
.
getCode
());
* @param topicEntity
topic
=
String
.
format
(
"%s.%s%s"
,
serverName
,
"equipment/"
,
RiskLeverForAutoSys
.
BJ
.
getCode
());
*/
}
else
if
(
TrueOrFalseEnum
.
real
.
value
.
equals
(
equipmentSpeIndex
.
getValue
())
public
void
intePageSysDataRefresh
(
List
<
EquipmentSpecificIndex
>
equipmentSpecificIndexList
,
TopicEntityVo
topicEntity
){
&&
EquipmentRiskTypeEnum
.
GZ
.
getCode
().
equals
(
equipmentSpeIndex
.
getTypeCode
()))
{
//TODO 数字化换流站组态屏数据推送,需要在事务提交之后,否侧事务隔离查询不出数据
equipmentSpeIndex
.
setType
(
EquipmentRiskTypeEnum
.
GZ
.
getCode
());
TransactionSynchronizationManager
.
registerSynchronization
(
new
TransactionSynchronization
()
{
topic
=
String
.
format
(
"%s.%s%s"
,
serverName
,
"equipment/"
,
RiskLeverForAutoSys
.
GZ
.
getCode
());
@Override
}
else
{
public
void
afterCommit
()
{
equipmentSpeIndex
.
setType
(
EquipmentRiskTypeEnum
.
QT
.
getCode
());
mqttSendGateway
.
sendToMqtt
(
TopicEnum
.
EQXXTJ
.
getTopic
(),
""
);
topic
=
String
.
format
(
"%s.%s%s"
,
serverName
,
"equipment/"
,
RiskLeverForAutoSys
.
JC
.
getCode
());
iEquipmentSpecificSerivce
.
integrationPageSysDataRefresh
(
topicEntity
.
getCode
());
}
iEquipmentSpecificSerivce
.
updateEquipmentSpecIndexRealtimeData
(
equipmentSpecificIndexList
);
TopicEntityVo
topicEntityVo
=
new
TopicEntityVo
();
}
topicEntityVo
.
setIotCode
(
equipmentSpeIndex
.
getIotCode
());
});
topicEntityVo
.
setTopic
(
topic
);
}
topicEntityVo
.
setMessage
(
JSON
.
toJSONString
(
equipmentSpeIndex
));
mqttSendGateway
.
sendToMqtt
(
topic
,
JSON
.
toJSONString
(
topicEntityVo
));
/**
});
* 更新数据报表表
}
* @param equipmentSpecificIndex
*/
/**
private
void
saveEquipmentAlarmReportDay
(
EquipmentSpecificIndex
equipmentSpecificIndex
){
* 组态大屏消息推送
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
DateUtils
.
DATE_PATTERN
);
*
EquipmentAlarmReportDay
equipmentAlarmReportDay
=
addEquipAlarmReportRecord
(
equipmentSpecificIndex
);
* @param equipmentSpecificIndexList
LambdaQueryWrapper
<
EquipmentAlarmReportDay
>
wrapper
=
new
LambdaQueryWrapper
<>();
* @param topicEntity
wrapper
.
eq
(
EquipmentAlarmReportDay:
:
getReportDate
,
sdf
.
format
(
equipmentAlarmReportDay
.
getReportDate
())).
eq
(
EquipmentAlarmReportDay:
:
getIndexId
,
equipmentAlarmReportDay
.
getIndexId
())
*/
.
eq
(
EquipmentAlarmReportDay:
:
getEquipmentSpecificId
,
equipmentAlarmReportDay
.
getEquipmentSpecificId
());
public
void
intePageSysDataRefresh
(
List
<
EquipmentSpecificIndex
>
equipmentSpecificIndexList
,
List
<
EquipmentAlarmReportDay
>
reportDayList
=
iEquipmentAlarmReportDayService
.
list
(
wrapper
);
TopicEntityVo
topicEntity
)
{
if
(
reportDayList
.
isEmpty
())
{
mqttSendGateway
.
sendToMqtt
(
TopicEnum
.
EQXXTJ
.
getTopic
(),
""
);
equipmentAlarmReportDay
.
setReportDate
(
new
Date
());
iEquipmentSpecificSerivce
.
integrationPageSysDataRefresh
(
topicEntity
.
getCode
());
equipmentAlarmReportDay
.
setFrequency
(
1
);
}
iEquipmentAlarmReportDayService
.
save
(
equipmentAlarmReportDay
);
}
else
{
/**
EquipmentAlarmReportDay
reportDay
=
reportDayList
.
get
(
0
);
* 更新数据报表表
reportDay
.
setLastReportDate
(
new
Date
());
*
reportDay
.
setValue
(
equipmentAlarmReportDay
.
getValue
());
* @param equipmentSpecificIndex
reportDay
.
setFrequency
(
reportDay
.
getFrequency
()
+
1
);
*/
reportDay
.
setIndexTrueNum
(
reportDay
.
getIndexTrueNum
()
==
null
?
equipmentAlarmReportDay
.
getIndexTrueNum
()
:
reportDay
.
getIndexTrueNum
()
+
equipmentAlarmReportDay
.
getIndexTrueNum
());
private
void
saveEquipmentAlarmReportDay
(
EquipmentSpecificIndex
equipmentSpecificIndex
)
{
iEquipmentAlarmReportDayService
.
updateById
(
reportDay
);
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
DateUtils
.
DATE_PATTERN
);
}
EquipmentAlarmReportDay
equipmentAlarmReportDay
=
addEquipAlarmReportRecord
(
equipmentSpecificIndex
);
LambdaQueryWrapper
<
EquipmentAlarmReportDay
>
wrapper
=
new
LambdaQueryWrapper
<>();
}
wrapper
.
eq
(
EquipmentAlarmReportDay:
:
getReportDate
,
sdf
.
format
(
equipmentAlarmReportDay
.
getReportDate
()))
.
eq
(
EquipmentAlarmReportDay:
:
getIndexId
,
equipmentAlarmReportDay
.
getIndexId
())
private
String
valueTranslate
(
String
value
,
String
enumStr
){
.
eq
(
EquipmentAlarmReportDay:
:
getEquipmentSpecificId
,
equipmentAlarmReportDay
.
getEquipmentSpecificId
());
if
(
ObjectUtils
.
isEmpty
(
enumStr
)){
List
<
EquipmentAlarmReportDay
>
reportDayList
=
iEquipmentAlarmReportDayService
.
list
(
wrapper
);
return
""
;
if
(
reportDayList
.
isEmpty
())
{
}
equipmentAlarmReportDay
.
setReportDate
(
new
Date
());
try
{
equipmentAlarmReportDay
.
setFrequency
(
1
);
JSONArray
jsonArray
=
JSONArray
.
parseArray
(
enumStr
);
iEquipmentAlarmReportDayService
.
save
(
equipmentAlarmReportDay
);
for
(
int
i
=
0
;
i
<
jsonArray
.
size
();
i
++)
{
}
else
{
JSONObject
jsonObject
=
jsonArray
.
getJSONObject
(
i
);
EquipmentAlarmReportDay
reportDay
=
reportDayList
.
get
(
0
);
if
(
jsonObject
.
get
(
"key"
).
equals
(
value
))
{
reportDay
.
setLastReportDate
(
new
Date
());
return
jsonObject
.
getString
(
"label"
);
reportDay
.
setValue
(
equipmentAlarmReportDay
.
getValue
());
}
reportDay
.
setFrequency
(
reportDay
.
getFrequency
()
+
1
);
}
reportDay
.
setIndexTrueNum
(
reportDay
.
getIndexTrueNum
()
==
null
?
equipmentAlarmReportDay
.
getIndexTrueNum
()
}
catch
(
Exception
e
)
{
:
reportDay
.
getIndexTrueNum
()
+
equipmentAlarmReportDay
.
getIndexTrueNum
());
e
.
printStackTrace
();
iEquipmentAlarmReportDayService
.
updateById
(
reportDay
);
}
}
return
""
;
}
}
private
void
carRealTimeDate
(
List
<
IotDataVO
>
iotDatalist
,
List
<
CarProperty
>
carProperties
){
private
String
valueTranslate
(
String
value
,
String
enumStr
)
{
if
(
ObjectUtils
.
isEmpty
(
enumStr
))
{
return
""
;
List
<
CarProperty
>
carIndexsList
=
new
ArrayList
<>();
}
iotDatalist
.
forEach
(
iotDataVO
->{
try
{
// 对指标key为labels的数据处理
JSONArray
jsonArray
=
JSONArray
.
parseArray
(
enumStr
);
if
(
EquipmentIndexLabelsEnum
.
labels
.
name
.
equals
(
iotDataVO
.
getKey
()))
{
for
(
int
i
=
0
;
i
<
jsonArray
.
size
();
i
++)
{
StringBuilder
sb
=
new
StringBuilder
(
"equipmentOnCar_"
);
JSONObject
jsonObject
=
jsonArray
.
getJSONObject
(
i
);
EquipmentIndexLabelsVo
labelsVo
=
new
EquipmentIndexLabelsVo
();
if
(
jsonObject
.
get
(
"key"
).
equals
(
value
))
{
Object
obj
=
iotDataVO
.
getValue
();
return
jsonObject
.
getString
(
"label"
);
if
(
obj
instanceof
JSONArray
)
{
}
List
<
String
>
labelList
=
(
List
<
String
>)
obj
;
}
labelList
.
forEach
(
code
->
{
}
catch
(
Exception
e
)
{
String
key
=
sb
.
append
(
code
).
toString
();
e
.
printStackTrace
();
labelsVo
.
setEquipmentIotCode
(
code
);
}
labelsVo
.
setTime
(
new
Date
());
return
""
;
redisUtils
.
set
(
key
,
com
.
alibaba
.
fastjson
.
JSONObject
.
toJSONString
(
labelsVo
),
redisExpireTime
);
}
});
}
/**
}
* 车辆数据推送及同步
List
<
CarPropertyVo
>
carPropertyVos
=
new
ArrayList
<>();
*
carProperties
.
forEach
(
carProperty
->{
* @param carProperties
if
(
iotDataVO
.
getKey
().
equals
(
carProperty
.
getNameKey
()))
{
* @param carPropertyVos
carProperty
.
setValue
(
iotDataVO
.
getValue
().
toString
());
*/
carProperty
.
setUpdateDate
(
new
Date
());
public
void
carTransactionSynch
(
List
<
CarProperty
>
carProperties
,
List
<
CarPropertyVo
>
carPropertyVos
)
{
carPropertyVos
.
add
(
carPropertyToCarPropertyVo
(
carProperty
));
// TODO 数字化换流站组态屏数据推送,需要在事务提交之后,否侧事务隔离查询不出数据
carIndexsList
.
add
(
carProperty
);
TransactionSynchronizationManager
.
registerSynchronization
(
new
TransactionSynchronization
()
{
}
@Override
});
public
void
afterCommit
()
{
List
<
CarIndexGisVo
>
list
=
createCarIndexGisVo
(
carProperties
);
boolean
updateBatchById
=
carPropertyService
.
updateBatchById
(
carIndexsList
);
mqttSendGateway
.
sendToMqtt
(
TopicEnum
.
CARZXDT
.
getTopic
(),
""
);
boolean
flag
=
ifSendToGis
(
list
);
if
(
updateBatchById
){
if
(
flag
)
{
carTransactionSynch
(
carProperties
,
carPropertyVos
);
mqttSendGateway
.
sendToMqtt
(
carTopic
,
JSON
.
toJSONString
(
list
));
}
}
});
}
if
(
syncSwitch
)
{
syncDataService
.
syncCreatedFireVehicleMeasurement
(
carPropertyVos
);
/**
}
* 车辆数据推送及同步
}
* @param carProperties
});
* @param carPropertyVos
}
*/
public
void
carTransactionSynch
(
List
<
CarProperty
>
carProperties
,
List
<
CarPropertyVo
>
carPropertyVos
){
private
CarPropertyVo
carPropertyToCarPropertyVo
(
CarProperty
property
)
{
//TODO 数字化换流站组态屏数据推送,需要在事务提交之后,否侧事务隔离查询不出数据
CarPropertyVo
carPropertyVo
=
new
CarPropertyVo
();
TransactionSynchronizationManager
.
registerSynchronization
(
new
TransactionSynchronization
()
{
carPropertyVo
.
setCarId
(
property
.
getCarId
());
@Override
carPropertyVo
.
setCreateDate
(
property
.
getCreateDate
());
public
void
afterCommit
()
{
carPropertyVo
.
setId
(
property
.
getId
());
List
<
CarIndexGisVo
>
list
=
createCarIndexGisVo
(
carProperties
);
carPropertyVo
.
setIsIot
(
1
);
mqttSendGateway
.
sendToMqtt
(
TopicEnum
.
CARZXDT
.
getTopic
(),
""
);
carPropertyVo
.
setMRid
(
property
.
getEquipmentIndexId
().
toString
());
boolean
flag
=
ifSendToGis
(
list
);
carPropertyVo
.
setName
(
property
.
getEquipmentIndexName
());
if
(
flag
)
{
carPropertyVo
.
setNameKey
(
property
.
getEquipmentIndexKey
());
mqttSendGateway
.
sendToMqtt
(
carTopic
,
JSON
.
toJSONString
(
list
));
carPropertyVo
.
setSort
(
1
);
}
carPropertyVo
.
setUnit
(
property
.
getUnitName
());
carPropertyVo
.
setValue
(
property
.
getValue
());
if
(
syncSwitch
)
{
return
carPropertyVo
;
syncDataService
.
syncCreatedFireVehicleMeasurement
(
carPropertyVos
);
}
}
}
private
List
<
CarIndexGisVo
>
createCarIndexGisVo
(
List
<
CarProperty
>
carProperties
)
{
});
List
<
CarIndexGisVo
>
list
=
new
ArrayList
<>();
}
long
id
=
0
l
;
String
iotCode
=
""
;
private
CarPropertyVo
carPropertyToCarPropertyVo
(
CarProperty
property
){
for
(
CarProperty
action
:
carProperties
)
{
CarPropertyVo
carPropertyVo
=
new
CarPropertyVo
();
CarIndexGisVo
v
=
new
CarIndexGisVo
();
carPropertyVo
.
setCarId
(
property
.
getCarId
());
id
=
action
.
getCarId
();
carPropertyVo
.
setCreateDate
(
property
.
getCreateDate
());
iotCode
=
action
.
getIotCode
();
carPropertyVo
.
setId
(
property
.
getId
());
v
.
setId
(
action
.
getCarId
());
carPropertyVo
.
setIsIot
(
1
);
v
.
setIotCode
(
action
.
getIotCode
());
carPropertyVo
.
setMRid
(
property
.
getEquipmentIndexId
().
toString
());
v
.
setNameKey
(
action
.
getEquipmentIndexKey
());
carPropertyVo
.
setName
(
property
.
getEquipmentIndexName
());
v
.
setValue
(
ObjectUtils
.
isEmpty
(
action
.
getValue
())
?
"0"
:
action
.
getValue
());
carPropertyVo
.
setNameKey
(
property
.
getEquipmentIndexKey
());
list
.
add
(
v
);
carPropertyVo
.
setSort
(
1
);
}
carPropertyVo
.
setUnit
(
property
.
getUnitName
());
carPropertyVo
.
setValue
(
property
.
getValue
());
CarIndexGisVo
time
=
new
CarIndexGisVo
();
return
carPropertyVo
;
time
.
setId
(
id
);
}
time
.
setIotCode
(
iotCode
);
time
.
setNameKey
(
CarForGisEnum
.
SJ
.
getNameKey
());
private
List
<
CarIndexGisVo
>
createCarIndexGisVo
(
List
<
CarProperty
>
carProperties
){
time
.
setValue
(
String
.
valueOf
(
new
Date
().
getTime
()));
List
<
CarIndexGisVo
>
list
=
new
ArrayList
<>();
list
.
add
(
time
);
long
id
=
0
l
;
String
iotCode
=
""
;
return
list
;
for
(
CarProperty
action
:
carProperties
){
}
CarIndexGisVo
v
=
new
CarIndexGisVo
();
id
=
action
.
getCarId
();
/**
iotCode
=
action
.
getIotCode
();
* //若为物联设备,则更新拓扑节点数据及告警状态
v
.
setId
(
action
.
getCarId
());
*
v
.
setIotCode
(
action
.
getIotCode
());
* @param indexList
v
.
setNameKey
(
action
.
getEquipmentIndexKey
());
*/
v
.
setValue
(
ObjectUtils
.
isEmpty
(
action
.
getValue
())?
"0"
:
action
.
getValue
());
public
void
updateNodeDateByEquipId
(
List
<
EquipmentSpecificIndex
>
indexList
)
{
list
.
add
(
v
);
if
(!
ObjectUtils
.
isEmpty
(
indexList
))
{
}
EquipmentVo
equipmentVo
=
equipmentService
.
getEquipBySpecific
(
indexList
.
get
(
0
).
getEquipmentSpecificId
());
if
(
equipmentVo
.
getIsIot
().
equals
(
"1"
))
{
CarIndexGisVo
time
=
new
CarIndexGisVo
();
List
<
EquipmentSpecificAlarm
>
alarmList
=
equipmentSpecificAlarmService
.
getEquipListBySpecific
(
true
,
time
.
setId
(
id
);
indexList
.
get
(
0
).
getEquipmentSpecificId
());
time
.
setIotCode
(
iotCode
);
topographyService
.
updateNodeDateByEquipId
(
indexList
.
get
(
0
).
getEquipmentSpecificId
(),
indexList
,
time
.
setNameKey
(
CarForGisEnum
.
SJ
.
getNameKey
());
alarmList
);
time
.
setValue
(
String
.
valueOf
(
new
Date
().
getTime
()));
}
list
.
add
(
time
);
}
}
return
list
;
}
/**
* //若为物联设备,则更新拓扑节点数据及告警状态
* @param indexList
*/
public
void
updateNodeDateByEquipId
(
List
<
EquipmentSpecificIndex
>
indexList
){
if
(!
ObjectUtils
.
isEmpty
(
indexList
))
{
EquipmentVo
equipmentVo
=
equipmentService
.
getEquipBySpecific
(
indexList
.
get
(
0
).
getEquipmentSpecificId
());
if
(
equipmentVo
.
getIsIot
().
equals
(
"1"
))
{
List
<
EquipmentSpecificAlarm
>
alarmList
=
equipmentSpecificAlarmService
.
getEquipListBySpecific
(
true
,
indexList
.
get
(
0
).
getEquipmentSpecificId
());
topographyService
.
updateNodeDateByEquipId
(
indexList
.
get
(
0
).
getEquipmentSpecificId
(),
indexList
,
alarmList
);
}
}
}
}
}
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