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
7c32611a
Commit
7c32611a
authored
Jun 01, 2022
by
maoying
Browse files
Options
Browse Files
Download
Plain Diff
合并developer分支代码优化设备消息处理代码
parents
beb9f47e
66a7ad19
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
1553 additions
and
1007 deletions
+1553
-1007
DateUtils.java
...ava/com/yeejoin/amos/boot/biz/common/utils/DateUtils.java
+28
-0
JcSituationDetail.java
...in/amos/boot/module/jcs/api/entity/JcSituationDetail.java
+32
-0
JcSituationDetailMapper.java
...s/boot/module/jcs/api/mapper/JcSituationDetailMapper.java
+7
-0
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
+952
-982
PowerTransferCompanyController.java
...le/jcs/biz/controller/PowerTransferCompanyController.java
+47
-0
AlertSubmittedServiceImpl.java
...odule/jcs/biz/service/impl/AlertSubmittedServiceImpl.java
+20
-4
PlanTaskServiceImpl.java
...upervision/business/service/impl/PlanTaskServiceImpl.java
+21
-15
jcs-1.0.0.0.xml
...ystem-jcs/src/main/resources/db/changelog/jcs-1.0.0.0.xml
+22
-0
LatentDangerMapper.xml
...anger/src/main/resources/db/mapper/LatentDangerMapper.xml
+2
-2
TaskDto.java
...com/yeejoin/amos/boot/module/tzs/flc/api/dto/TaskDto.java
+51
-0
Task.java
...com/yeejoin/amos/boot/module/tzs/flc/api/entity/Task.java
+79
-0
TaskStatusEnum.java
...in/amos/boot/module/tzs/flc/api/enums/TaskStatusEnum.java
+23
-0
TaskMapper.java
...ejoin/amos/boot/module/tzs/flc/api/mapper/TaskMapper.java
+14
-0
ITaskService.java
...in/amos/boot/module/tzs/flc/api/service/ITaskService.java
+12
-0
TaskMapper.xml
...t-module-tzs-api/src/main/resources/mapper/TaskMapper.xml
+5
-0
TaskController.java
...os/boot/module/tzs/flc/biz/controller/TaskController.java
+142
-0
TaskServiceImpl.java
...boot/module/tzs/flc/biz/service/impl/TaskServiceImpl.java
+93
-0
No files found.
amos-boot-biz-common/src/main/java/com/yeejoin/amos/boot/biz/common/utils/DateUtils.java
View file @
7c32611a
...
...
@@ -774,6 +774,34 @@ public class DateUtils {
}
/**
* 获得本天的开始时间,即2012-01-01 00:00:00
*
* @return
*/
public
static
Date
getCurrentDayStartTime
(
Date
date
)
{
try
{
date
=
shortSdf
.
parse
(
shortSdf
.
format
(
date
)
+
" 00:00:00"
);
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
return
date
;
}
/**
* 获得本天的结束时间,即2012-01-01 23:59:59
*
* @return
*/
public
static
Date
getCurrentDayEndTime
(
Date
date
)
{
try
{
date
=
longSdf
.
parse
(
shortSdf
.
format
(
date
)
+
" 23:59:59"
);
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
return
date
;
}
/**
* 获取指定时间所在周的第一天日期
*
* @param date
...
...
amos-boot-module/amos-boot-module-api/amos-boot-module-jcs-api/src/main/java/com/yeejoin/amos/boot/module/jcs/api/entity/JcSituationDetail.java
0 → 100644
View file @
7c32611a
package
com
.
yeejoin
.
amos
.
boot
.
module
.
jcs
.
api
.
entity
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.yeejoin.amos.boot.biz.common.entity.BaseEntity
;
import
com.yeejoin.amos.boot.module.common.api.dto.AttachmentDto
;
import
com.yeejoin.amos.boot.module.common.api.entity.SourceFile
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
import
java.util.List
;
import
java.util.Map
;
@Data
@EqualsAndHashCode
(
callSuper
=
true
)
@Accessors
(
chain
=
true
)
@TableName
(
"jc_situation_detail"
)
@ApiModel
(
value
=
"AlertCalled对象"
,
description
=
"警情接警记录"
)
public
class
JcSituationDetail
extends
BaseEntity
{
@ApiModelProperty
(
value
=
"报送内容"
)
private
String
info
;
@ApiModelProperty
(
value
=
"类型"
)
private
String
infoType
=
"指令下发"
;
@ApiModelProperty
(
value
=
"警情ID"
)
private
Long
alertCalledId
;
}
amos-boot-module/amos-boot-module-api/amos-boot-module-jcs-api/src/main/java/com/yeejoin/amos/boot/module/jcs/api/mapper/JcSituationDetailMapper.java
0 → 100644
View file @
7c32611a
package
com
.
yeejoin
.
amos
.
boot
.
module
.
jcs
.
api
.
mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.yeejoin.amos.boot.module.jcs.api.entity.JcSituationDetail
;
public
interface
JcSituationDetailMapper
extends
BaseMapper
<
JcSituationDetail
>
{
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/IEquipmentSpecificSerivce.java
View file @
7c32611a
...
...
@@ -181,7 +181,7 @@ public interface IEquipmentSpecificSerivce extends IService<EquipmentSpecific> {
*
* @param indexs
*/
void
updateEquipmentSpecIndexRealtimeData
(
List
<
EquipmentSpecificIndex
>
indexs
);
void
updateEquipmentSpecIndexRealtimeData
(
EquipmentSpecificIndex
index
);
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 @
7c32611a
...
...
@@ -1631,10 +1631,9 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM
}
@Override
public
void
updateEquipmentSpecIndexRealtimeData
(
List
<
EquipmentSpecificIndex
>
indexs
)
{
public
void
updateEquipmentSpecIndexRealtimeData
(
EquipmentSpecificIndex
index
)
{
// TODO Auto-generated method stub
if
(!
ObjectUtils
.
isEmpty
(
indexs
))
{
EquipmentSpecificIndex
index
=
indexs
.
get
(
0
);
if
(!
ObjectUtils
.
isEmpty
(
index
))
{
EquipmentSpecific
es
=
equipmentSpecificMapper
.
selectById
(
index
.
getEquipmentSpecificId
());
es
.
setRealtimeIotEsIndexId
(
index
.
getId
());
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 @
7c32611a
...
...
@@ -77,7 +77,6 @@ import com.yeejoin.equipmanage.service.IEquipmentIndexService;
import
com.yeejoin.equipmanage.service.IEquipmentService
;
import
com.yeejoin.equipmanage.service.IEquipmentSpecificAlarmLogService
;
import
com.yeejoin.equipmanage.service.IEquipmentSpecificAlarmService
;
import
com.yeejoin.equipmanage.service.IEquipmentSpecificIndexSerivce
;
import
com.yeejoin.equipmanage.service.IEquipmentSpecificIndexService
;
import
com.yeejoin.equipmanage.service.IEquipmentSpecificSerivce
;
import
com.yeejoin.equipmanage.service.IFireFightingSystemService
;
...
...
@@ -94,1010 +93,981 @@ import lombok.extern.slf4j.Slf4j;
/**
* @author keyong
* @title: MqttReceiveServiceImpl
* <pre>
* @description: 增量数据处理
* </pre>
*
* <pre>
* @description: 增量数据处理
* </pre>
*
* @date 2020/11/3 13:39
*/
@Slf4j
@Service
public
class
MqttReceiveServiceImpl
implements
MqttReceiveService
{
private
static
Map
<
String
,
TemperatureAlarmDto
>
temperatureMap
=
new
HashMap
<>();
private
static
Map
<
String
,
TemperatureAlarmDto
>
temperatureMap
=
new
HashMap
<>();
@Autowired
IEquipmentSpecificIndexService
equipmentSpecificIndexService
;
@Autowired
IEquipmentSpecificIndexService
equipmentSpecificIndexService
;
@Autowired
ICarPropertyService
carPropertyService
;
@Autowired
ICarPropertyService
carPropertyService
;
@Autowired
IEquipmentSpecificAlarmService
equipmentSpecificAlarmService
;
@Autowired
IEquipmentSpecificAlarmService
equipmentSpecificAlarmService
;
@Autowired
IEquipmentSpecificAlarmLogService
equipmentSpecificAlarmLogService
;
@Autowired
IEquipmentSpecificAlarmLogService
equipmentSpecificAlarmLogService
;
@Autowired
EquipmentSpecificAlarmMapper
equipmentSpecificAlarmMapper
;
@Autowired
EquipmentSpecificAlarmLogMapper
equipmentSpecificAlarmLogMapper
;
@Autowired
EquipmentSpecificAlarmMapper
equipmentSpecificAlarmMapper
;
@Autowired
@Lazy
IEquipmentIndexService
equipmentIndexService
;
@Autowired
EquipmentSpecificAlarmLogMapper
equipmentSpecificAlarmLogMapper
;
@Autowired
EquipmentSpecificIndexMapper
equipmentSpecificIndexMapper
;
@Autowired
@Lazy
IEquipmentIndexService
equipmentIndexService
;
@Autowired
EquipmentSpecificMapper
equipmentSpecific
Mapper
;
@Autowired
EquipmentSpecificIndexMapper
equipmentSpecificIndex
Mapper
;
@Autowired
FireFightingSystemMapper
FireFightingSystem
Mapper
;
@Autowired
EquipmentSpecificMapper
equipmentSpecific
Mapper
;
@Autowired
IFireFightingSystemService
fireFightingSystemService
;
@Autowired
FireFightingSystemMapper
FireFightingSystemMapper
;
@Autowired
MqttSendGateway
mqttSendGateway
;
@Autowired
IFireFightingSystemService
fireFightingSystemService
;
@Autowired
private
RedisUtils
redisUtils
;
@Autowired
MqttSendGateway
mqttSendGateway
;
@Autowired
CarMapper
carMapper
;
@Autowired
private
RedisUtils
redisUtils
;
@Autowired
IMainIotMonitorSerivce
iMainIotMonitorSerivce
;
@Autowired
CarMapper
carMapper
;
@Autowired
private
IEquipmentSpecificIndexSerivce
equipmentSpecificIndex
Serivce
;
@Autowired
IMainIotMonitorSerivce
iMainIotMonitor
Serivce
;
@Autowired
private
ISyncDataService
syncDataService
;
@Autowired
private
ISyncDataService
syncDataService
;
@Autowired
private
IEquipmentAlarmReportDayService
iEquipmentAlarmReportDayService
;
@Autowired
private
IEquipmentAlarmReportDayService
iEquipmentAlarmReportDayService
;
@Autowired
private
IEquipmentSpecificSerivce
iEquipmentSpecificSerivce
;
@Autowired
FireFightingSystemMapper
fireFightingSystemMapper
;
@Autowired
private
SystemctlFeign
systemctlFeign
;
@Autowired
private
RemoteSecurityService
remoteSecurityService
;
@Autowired
private
TopographyService
topographyService
;
@Autowired
private
IEquipmentService
equipmentService
;
@Value
(
"${equipManage.name}"
)
private
String
serverName
;
@Value
(
"${mqtt.vehicle.topic}"
)
private
String
carTopic
;
@Value
(
"${equip.point.equipmentdata.topic}"
)
private
String
canvasTopic
;
@Value
(
"${equip.index.topic}"
)
private
String
indexTopic
;
@Value
(
"${spring.redis.expire.time}"
)
private
long
redisExpireTime
;
@Value
(
"${systemctl.sync.switch}"
)
private
Boolean
syncSwitch
;
@Value
(
"${systemctl.amos.switch}"
)
private
Boolean
amosSwitch
;
@Value
(
"${isSendApp}"
)
private
Boolean
isSendApp
;
private
final
static
Map
staticMap
=
new
HashMap
();
private
static
Boolean
bool
=
Boolean
.
FALSE
;
static
{
staticMap
.
put
(
"FireCar_GDLongitude"
,
"0"
);
staticMap
.
put
(
"FireCar_GDLatitude"
,
"0"
);
staticMap
.
put
(
"FireCar_Speed"
,
"0"
);
staticMap
.
put
(
"FireCar_Power"
,
"0"
);
staticMap
.
put
(
"FireCar_CourseOverGround"
,
"0"
);
staticMap
.
put
(
"time"
,
System
.
currentTimeMillis
());
staticMap
.
put
(
"FireCar_Start"
,
"false"
);
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
handlerMqttIncrementMessage
(
String
topic
,
String
message
)
{
TopicEntityVo
topicEntity
=
new
TopicEntityVo
();
topicEntity
.
setTopic
(
topic
);
topicEntity
.
setMessage
(
message
);
int
endIndex
=
topic
.
lastIndexOf
(
"/"
);
String
iotCode
=
topic
.
substring
(
0
,
endIndex
).
replace
(
"/"
,
""
);
topicEntity
.
setIotCode
(
iotCode
);
List
<
EquipmentSpecificVo
>
eqIotCodeList
=
null
;
if
(
iotCode
!=
null
&&!
iotCode
.
startsWith
(
"20210003"
)&&!
iotCode
.
startsWith
(
"20210004"
)&&!
iotCode
.
startsWith
(
"20210005"
)){
eqIotCodeList
=
iEquipmentSpecificSerivce
.
getEquipAndCarIotcodeByIotcode
(
iotCode
);
}
else
{
log
.
info
(
"不是装备物联code!"
,
iotCode
);
return
;
}
if
(
eqIotCodeList
.
isEmpty
())
{
log
.
info
(
"该数据{}不存在!"
,
iotCode
);
return
;
}
if
(
eqIotCodeList
.
size
()
>
1
)
{
log
.
info
(
"有重复的{}数据!"
,
iotCode
);
}
EquipmentSpecificVo
vo
=
eqIotCodeList
.
get
(
0
);
topicEntity
.
setType
(
vo
.
getType
());
topicEntity
.
setCode
(
vo
.
getCode
());
JSONObject
json
=
JSONObject
.
parseObject
(
message
);
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
());
iotDataVO
.
setValue
(
entry
.
getValue
());
iotDatalist
.
add
(
iotDataVO
);
}
if
(
ObjectUtils
.
isEmpty
(
iotDatalist
))
{
return
;
}
log
.
info
(
String
.
format
(
"收到mqtt消息:%s"
,
message
));
realTimeDateProcessing
(
topicEntity
,
iotDatalist
);
}
/**
* 物联数据处理
* @param topicEntity
* @param iotDatalist
*/
public
void
realTimeDateProcessing
(
TopicEntityVo
topicEntity
,
List
<
IotDataVO
>
iotDatalist
){
String
iotCode
=
topicEntity
.
getIotCode
();
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
);
if
(
ObjectUtils
.
isEmpty
(
carProperties
)){
return
;
}
carRealTimeDate
(
iotDatalist
,
carProperties
);
}
}
public
static
List
<
EquipmentSpecificAlarmLog
>
upAlarmLogStatus
(
String
iotCode
,
String
equipmentSpecificIndexKey
,
IEquipmentSpecificAlarmLogService
equipmentSpecificAlarmLogService
)
{
LambdaQueryWrapper
<
EquipmentSpecificAlarmLog
>
queryWrapper
=
new
LambdaQueryWrapper
();
queryWrapper
.
eq
(
EquipmentSpecificAlarmLog:
:
getIotCode
,
iotCode
);
queryWrapper
.
eq
(
EquipmentSpecificAlarmLog:
:
getEquipmentSpecificIndexKey
,
equipmentSpecificIndexKey
);
queryWrapper
.
ne
(
EquipmentSpecificAlarmLog:
:
getStatus
,
AlarmStatusEnum
.
HF
.
getCode
());
List
<
EquipmentSpecificAlarmLog
>
logs
=
equipmentSpecificAlarmLogService
.
getBaseMapper
().
selectList
(
queryWrapper
);
logs
.
forEach
(
x
->
{
x
.
setCleanTime
(
new
Date
());
x
.
setStatus
(
AlarmStatusEnum
.
HF
.
getCode
());
});
if
(!
logs
.
isEmpty
())
{
equipmentSpecificAlarmLogService
.
updateBatchById
(
logs
);
}
return
logs
;
}
public
void
publishDataToCanvas
(
List
<
EquipmentSpecificIndex
>
indexList
)
{
if
(!
ObjectUtils
.
isEmpty
(
indexList
))
{
TransactionSynchronizationManager
.
registerSynchronization
(
new
TransactionSynchronization
()
{
@Override
public
void
afterCommit
()
{
EquipmentSpecificIndex
index
=
indexList
.
stream
().
filter
(
x
->
x
.
getUpdateDate
()
!=
null
)
.
sorted
(
Comparator
.
comparing
(
EquipmentSpecificIndex:
:
getUpdateDate
).
reversed
())
.
collect
(
Collectors
.
toList
()).
get
(
0
);
EquipmentStateVo
equipmentStateVo
=
new
EquipmentStateVo
();
equipmentStateVo
.
setEquipName
(
index
.
getEquipmentSpecificName
());
equipmentStateVo
.
setOrgCode
(
index
.
getOrgCode
());
equipmentStateVo
.
setSpecificId
(
index
.
getEquipmentSpecificId
());
equipmentStateVo
.
setEquipCode
(
index
.
getQrCode
());
equipmentStateVo
.
setEquipIotCode
(
index
.
getIotCode
());
equipmentStateVo
.
setStatus
(
""
);
equipmentStateVo
.
setColor
(
index
.
getEmergencyLevelColor
());
// 添加性能指标项
//flag 无意义 getSpeIndex 方法其他地方共用 做了额外封装 为0时走原逻辑
int
flag
=
0
;
equipmentStateVo
.
setSpeindexList
(
fireFightingSystemService
.
getSpeIndex
(
index
.
getEquipmentSpecificId
(),
flag
));
Map
<
String
,
Object
>
topicObject
=
new
HashMap
<>();
topicObject
.
put
(
"equipCode"
,
equipmentStateVo
.
getEquipCode
());
if
(
TrueOrFalseEnum
.
real
.
value
.
toUpperCase
().
equals
(
index
.
getValue
().
toUpperCase
()))
{
topicObject
.
put
(
"color"
,
equipmentStateVo
.
getColor
());
}
else
{
topicObject
.
put
(
"color"
,
""
);
}
Map
<
String
,
Object
>
map
=
JSON
.
parseObject
(
JSON
.
toJSONString
(
equipmentStateVo
));
map
.
put
(
canvasTopic
,
topicObject
);
// 发送数据至画布
mqttSendGateway
.
sendToMqtt
(
canvasTopic
,
JSON
.
toJSONString
(
map
));
}
});
}
}
void
syncSystemctlMsg
(
EquipmentSpecificAlarmLog
equipmentSpecificAlarmLog
)
{
try
{
MessageModel
model
=
new
MessageModel
();
String
alarmReason
=
ValidationUtil
.
isEmpty
(
equipmentSpecificAlarmLog
.
getAlarmReason
())
?
""
:
equipmentSpecificAlarmLog
.
getAlarmReason
();
if
(
alarmReason
.
contains
(
":"
))
{
String
[]
split
=
alarmReason
.
split
(
":"
);
alarmReason
=
split
[
1
];
}
model
.
setTitle
(
equipmentSpecificAlarmLog
.
getEquipmentSpecificIndexName
());
String
body
=
String
.
format
(
"警情类型:%s;报警设备:%s;报警位置:%s;报警原因:%s;报警时间:%s"
,
equipmentSpecificAlarmLog
.
getEquipmentSpecificIndexName
(),
equipmentSpecificAlarmLog
.
getEquipmentSpecificName
(),
equipmentSpecificAlarmLog
.
getLocation
(),
alarmReason
,
DateUtils
.
date2LongStr
(
equipmentSpecificAlarmLog
.
getCreateDate
()));
model
.
setBody
(
body
);
model
.
setMsgType
(
"iotMonitor"
);
if
(
isSendApp
)
{
model
.
setIsSendApp
(
true
);
model
.
setTerminal
(
"APP/WEB"
);
}
else
{
model
.
setIsSendApp
(
false
);
model
.
setTerminal
(
"WEB"
);
}
model
.
setIsSendWeb
(
true
);
model
.
setCategory
(
1
);
model
.
setRelationId
(
String
.
valueOf
(
equipmentSpecificAlarmLog
.
getId
()));
Token
token
=
remoteSecurityService
.
getServerToken
();
systemctlFeign
.
create
(
token
.
getAppKey
(),
token
.
getProduct
(),
token
.
getToke
(),
model
);
log
.
info
(
String
.
format
(
"调用平台消息服务成功:%s"
,
JSON
.
toJSONString
(
model
)));
}
catch
(
Exception
e
)
{
// e.printStackTrace();
log
.
error
(
"告警消息同步平台失败:syncSystemctlMsg,===>>>"
+
e
.
getMessage
());
}
}
public
List
<
EquipmentSpecificAlarm
>
addIndexAlarmRecord
(
EquipmentSpecificIndex
equipmentSpcIndex
,
List
<
IotDataVO
>
iotDatalist
)
{
// 处理火眼视频异常
EquipmentSpecificIndex
equipmentSpecificIndex
=
handleTemperatureAlarm
(
equipmentSpcIndex
,
iotDatalist
);
List
<
EquipmentSpecificAlarm
>
equipmentSpecificAlarms
=
new
ArrayList
<>();
EquipmentSpecificAlarm
equipmentSpecificAlarm
=
new
EquipmentSpecificAlarm
();
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
()))
{
List
<
EquipmentSpecificAlarm
>
indexAlarms
=
equipmentSpecificAlarmMapper
.
findEquipmentSpecificAlarmByEquipmentSpecificIdAndEquipmentIndexIdAndStatusIstrue
(
equipmentSpecificIndex
.
getEquipmentSpecificId
(),
equipmentSpecificIndex
.
getEquipmentIndexId
());
// NB设备告警
if
(
verifyNB
(
equipmentSpecificIndex
.
getNameKey
()))
{
return
getNbEquipAlarmList
(
indexAlarms
,
equipmentSpecificIndex
,
equipmentSpecificAlarm
);
}
// 报警表新增信息
if
(
ObjectUtils
.
isEmpty
(
indexAlarms
)
&&
(
TrueOrFalseEnum
.
real
.
value
.
equals
(
equipmentSpecificIndex
.
getValue
())))
{
addEquipmentSpecificAlarm
(
equipmentSpecificAlarms
,
equipmentSpecificIndex
,
equipmentSpecificAlarm
);
}
else
{
// 报警表更新信息
indexAlarms
.
forEach
(
action
->
{
if
(
TrueOrFalseEnum
.
real
.
value
.
equals
(
equipmentSpecificIndex
.
getValue
()))
{
// 报警,修改发生频率
action
.
setFrequency
((
action
.
getFrequency
()
+
1
));
}
else
{
// 报警恢复,修改数据为恢复状态
action
.
setRecoveryDate
(
new
Date
());
action
.
setEquipmentSpecificIndexValue
(
TrueOrFalseEnum
.
fake
.
value
);
action
.
setStatus
(
AlarmStatusEnum
.
HF
.
getCode
());
}
action
.
setUpdateDate
(
new
Date
());
// 更新所在系统,设备可能编辑过,更新所在系统、装备名称、装备定义code
action
.
setSystemIds
(
equipmentSpcIndex
.
getSystemId
());
action
.
setSystemCodes
(
this
.
getSystemCodeBySpeId
(
equipmentSpcIndex
.
getSystemId
()));
action
.
setEquipmentSpecificName
(
equipmentSpcIndex
.
getEquipmentSpecificName
());
action
.
setEquipmentCode
(
equipmentSpcIndex
.
getEquipmentCode
());
// 冗余字段,alarm_log表更新时使用
action
.
setEquipmentSpecificCode
(
equipmentSpcIndex
.
getEquipmentSpecificCode
());
equipmentSpecificAlarms
.
add
(
action
);
});
}
}
return
equipmentSpecificAlarms
;
}
private
String
getSystemCodeBySpeId
(
String
sysIds
)
{
if
(
StringUtil
.
isNotEmpty
(
sysIds
))
{
List
<
FireFightingSystemEntity
>
sys
=
fireFightingSystemMapper
.
getFightingSysByIds
(
sysIds
.
split
(
","
));
return
sys
.
stream
().
map
(
FireFightingSystemEntity:
:
getCode
).
collect
(
Collectors
.
joining
(
","
));
}
else
{
return
null
;
}
}
private
EquipmentAlarmReportDay
addEquipAlarmReportRecord
(
EquipmentSpecificIndex
equipmentSpecificIndex
)
{
EquipmentAlarmReportDay
equipmentAlarmReportDay
=
new
EquipmentAlarmReportDay
();
equipmentAlarmReportDay
.
setOrgCode
(
equipmentSpecificIndex
.
getOrgCode
());
equipmentAlarmReportDay
.
setReportDate
(
new
Date
());
equipmentAlarmReportDay
.
setUpdateDate
(
new
Date
());
equipmentAlarmReportDay
.
setSystemIds
(
equipmentSpecificIndex
.
getSystemId
());
equipmentAlarmReportDay
.
setLastReportDate
(
new
Date
());
equipmentAlarmReportDay
.
setEquipmentSpecificId
(
equipmentSpecificIndex
.
getEquipmentSpecificId
());
equipmentAlarmReportDay
.
setEquipmentSpecificName
(
equipmentSpecificIndex
.
getEquipmentSpecificName
());
equipmentAlarmReportDay
.
setEquipmentDetailId
(
equipmentSpecificIndex
.
getEquipmentDetailId
());
equipmentAlarmReportDay
.
setEquipmentId
(
equipmentSpecificIndex
.
getEquipmentId
());
equipmentAlarmReportDay
.
setEquipmentCode
(
equipmentSpecificIndex
.
getEquipmentCode
());
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
());
equipmentAlarmReportDay
.
setIndexType
(
equipmentSpecificIndex
.
getNameKey
());
equipmentAlarmReportDay
.
setValue
(
equipmentSpecificIndex
.
getValue
());
equipmentAlarmReportDay
.
setIsAlarm
(
equipmentSpecificIndex
.
getIsAlarm
());
return
equipmentAlarmReportDay
;
}
private
EquipmentSpecificAlarmLog
addEquipAlarmLogRecord
(
EquipmentSpecificAlarm
equipmentSpecificAlarm
)
{
EquipmentSpecificAlarmLog
equipmentSpecificAlarmLog
=
new
EquipmentSpecificAlarmLog
();
BeanUtils
.
copyProperties
(
equipmentSpecificAlarm
,
equipmentSpecificAlarmLog
);
equipmentSpecificAlarmLog
.
setId
(
null
);
equipmentSpecificAlarmLog
.
setCreateDate
(
new
Date
());
equipmentSpecificAlarmLog
.
setEquipmentSpecificAlarmId
(
equipmentSpecificAlarm
.
getId
());
boolean
bool
=
equipmentSpecificAlarmLogService
.
save
(
equipmentSpecificAlarmLog
);
// 同步告警消息给平台
if
(
amosSwitch
&&
bool
)
{
EquipmentSpecificAlarmLog
alarmLog
=
equipmentSpecificAlarmLogService
.
getById
(
equipmentSpecificAlarmLog
.
getId
());
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
syncSystemctlMsg
(
alarmLog
);
}
}).
start
();
}
return
equipmentSpecificAlarmLog
;
}
/**
* 添加告警
*
* @param equipmentSpecificAlarms
* @param equipmentSpecificIndex
* @return
*/
private
List
<
EquipmentSpecificAlarm
>
addEquipmentSpecificAlarm
(
List
<
EquipmentSpecificAlarm
>
equipmentSpecificAlarms
,
EquipmentSpecificIndex
equipmentSpecificIndex
,
EquipmentSpecificAlarm
equipmentSpecificAlarm
)
{
BeanUtils
.
copyProperties
(
equipmentSpecificIndex
,
equipmentSpecificAlarm
);
equipmentSpecificAlarm
.
setId
(
null
);
equipmentSpecificAlarm
.
setFrequency
(
1
);
equipmentSpecificAlarm
.
setStatus
(
AlarmStatusEnum
.
BJ
.
getCode
());
equipmentSpecificAlarm
.
setEquipmentSpecificIndexKey
(
equipmentSpecificIndex
.
getNameKey
());
equipmentSpecificAlarm
.
setEquipmentSpecificIndexValue
(
equipmentSpecificIndex
.
getValue
());
equipmentSpecificAlarm
.
setEquipmentSpecificIndexLabel
(
equipmentSpecificIndex
.
getValueLabel
());
equipmentSpecificAlarm
.
setType
(
equipmentSpecificIndex
.
getTypeCode
());
equipmentSpecificAlarm
.
setCreateDate
(
new
Date
());
equipmentSpecificAlarm
.
setUpdateDate
(
new
Date
());
equipmentSpecificAlarm
.
setEquipmentCode
(
equipmentSpecificIndex
.
getEquipmentCode
());
equipmentSpecificAlarm
.
setEquipmentId
(
equipmentSpecificIndex
.
getEquipmentId
());
equipmentSpecificAlarm
.
setEquipmentDetailId
(
equipmentSpecificIndex
.
getEquipmentDetailId
());
equipmentSpecificAlarm
.
setEquipmentSpecificCode
(
equipmentSpecificIndex
.
getEquipmentSpecificCode
());
equipmentSpecificAlarm
.
setEmergencyLevel
(
equipmentSpecificIndex
.
getEmergencyLevel
());
equipmentSpecificAlarm
.
setEmergencyLevelColor
(
equipmentSpecificIndex
.
getEmergencyLevelColor
());
equipmentSpecificAlarm
.
setEmergencyLevelDescribe
(
equipmentSpecificIndex
.
getEmergencyLevelDescribe
());
equipmentSpecificAlarms
.
add
(
equipmentSpecificAlarm
);
return
equipmentSpecificAlarms
;
}
// 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
))
{
return
equipmentSpecificAlarmList
;
}
else
{
equipmentSpecificAlarmList
.
clear
();
}
}
else
{
indexAlarms
.
forEach
(
action
->
{
// 状态为正常或报警解除
if
(
checkStateIsNormal
(
action
,
equipmentSpecificIndex
))
{
//修改报警数据为正常
action
.
setRecoveryDate
(
new
Date
());
action
.
setStatus
(
AlarmStatusEnum
.
HF
.
getCode
());
// 修改之前数据为已处理
action
.
setResolveResult
(
action
.
getAlamReason
());
action
.
setConfirmUserName
(
"系统"
);
action
.
setConfirmType
(
action
.
getType
());
equipmentSpecificAlarmLogService
.
updateAlarmLogByIotCodeAndIndexKey
(
action
);
}
else
{
action
.
setFrequency
((
action
.
getFrequency
()
+
1
));
}
// 更新所在系统,设备可能编辑过
action
.
setSystemIds
(
equipmentSpecificIndex
.
getSystemId
());
action
.
setSystemCodes
(
this
.
getSystemCodeBySpeId
(
equipmentSpecificIndex
.
getSystemId
()));
action
.
setUpdateDate
(
new
Date
());
equipmentSpecificAlarmList
.
add
(
action
);
});
}
return
equipmentSpecificAlarmList
;
}
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
()))
{
if
(!
StringUtil
.
isNotEmpty
(
gisVo
.
getValue
())
||
"0"
.
equals
(
gisVo
.
getValue
()))
{
flag
=
false
;
continue
;
}
}
if
(
CarForGisEnum
.
WD
.
getNameKey
().
equals
(
gisVo
.
getNameKey
())
||
"0"
.
equals
(
gisVo
.
getValue
()))
{
if
(!
StringUtil
.
isNotEmpty
(
gisVo
.
getValue
()))
{
flag
=
false
;
continue
;
}
}
}
if
(
list1
.
size
()
==
0
||
list2
.
size
()
==
0
)
{
flag
=
false
;
}
return
flag
;
}
/**
* 接收到的IOT数据为火眼存储到Map中
*/
private
void
iotDataListToCacheMap
(
List
<
IotDataVO
>
iotDatalist
)
{
List
<
IotDataVO
>
iotDataVOs
=
iotDatalist
.
stream
().
filter
(
x
->
"alarmLevel"
.
equals
(
x
.
getKey
())
||
"alarmType"
.
equals
(
x
.
getKey
())
||
"temperature"
.
equals
(
x
.
getKey
())
||
"ruleTemperature"
.
equals
(
x
.
getKey
())
||
"thermometryUnit"
.
equals
(
x
.
getKey
())
||
"alarmRule"
.
equals
(
x
.
getKey
())).
collect
(
Collectors
.
toList
());
if
(
iotDataVOs
.
size
()
>
0
)
{
Map
<
String
,
Object
>
map
=
iotDatalist
.
stream
().
collect
(
Collectors
.
toMap
(
IotDataVO:
:
getKey
,
IotDataVO:
:
getValue
));
putTemperatureMap
(
map
.
get
(
"traceId"
).
toString
(),
map
);
}
}
/**
* 处理火眼逻辑合并为一条告警
*/
private
EquipmentSpecificIndex
handleTemperatureAlarm
(
EquipmentSpecificIndex
equipmentSpecificIndex
,
List
<
IotDataVO
>
iotDatalist
)
{
List
<
IotDataVO
>
collect
=
iotDatalist
.
stream
().
filter
(
x
->
"traceId"
.
equals
(
x
.
getKey
())).
collect
(
Collectors
.
toList
());
if
(
collect
.
size
()
>
0
&&
temperatureMapIsEmpty
(
String
.
valueOf
(
collect
.
get
(
0
).
getValue
())))
{
String
traceId
=
String
.
valueOf
(
collect
.
get
(
0
).
getValue
());
TemperatureAlarmDto
dto
=
temperatureMap
.
get
(
traceId
);
equipmentSpecificIndex
.
setEquipmentSpecificIndexName
(
AlarmTypeEnum
.
getTypeByCode
(
AlarmTypeEnum
.
GZGJ
.
getCode
()));
equipmentSpecificIndex
.
setNameKey
(
AlarmTypeEnum
.
GZGJ
.
getCode
());
equipmentSpecificIndex
.
setAlamReason
(
TemperatureAlarm
.
getAlarmContent
(
dto
.
getAlarmLevel
(),
dto
.
getAlarmType
(),
dto
.
getAlarmRule
(),
dto
.
getRuleTemperature
(),
dto
.
getTemperature
(),
dto
.
getThermometryUnit
()));
equipmentSpecificIndex
.
setValue
(
"true"
);
equipmentSpecificIndex
.
setIsAlarm
(
1
);
temperatureMap
.
remove
(
traceId
);
}
return
equipmentSpecificIndex
;
}
/**
* temperatureMap存储数据
*/
private
void
putTemperatureMap
(
String
traceId
,
Map
<
String
,
Object
>
map
)
{
TemperatureAlarmDto
cacheTemperatureAlarmDto
=
temperatureMap
.
get
(
traceId
);
if
(
ValidationUtil
.
isEmpty
(
cacheTemperatureAlarmDto
))
{
cacheTemperatureAlarmDto
=
new
TemperatureAlarmDto
();
}
TemperatureAlarmDto
newMap
=
JSON
.
parseObject
(
JSON
.
toJSONString
(
map
),
TemperatureAlarmDto
.
class
);
BeanUtil
.
copyPropertiesIgnoreNull
(
newMap
,
cacheTemperatureAlarmDto
);
temperatureMap
.
put
(
traceId
,
cacheTemperatureAlarmDto
);
}
private
boolean
temperatureMapIsEmpty
(
String
traceId
)
{
TemperatureAlarmDto
dto
=
temperatureMap
.
get
(
traceId
);
if
(!
ValidationUtil
.
isEmpty
(
dto
)
&&
!
ValidationUtil
.
isEmpty
(
dto
.
getAlarmLevel
())
&&
!
ValidationUtil
.
isEmpty
(
dto
.
getAlarmType
())
&&
!
ValidationUtil
.
isEmpty
(
dto
.
getAlarmRule
())
&&
!
ValidationUtil
.
isEmpty
(
dto
.
getRuleTemperature
())
&&
!
ValidationUtil
.
isEmpty
(
dto
.
getTemperature
())
&&
!
ValidationUtil
.
isEmpty
(
dto
.
getThermometryUnit
()))
{
return
true
;
}
return
false
;
}
/**
* 判断是否为NB物联监测设备参数
*
* @param nameKey
* @return
*/
private
boolean
verifyNB
(
String
nameKey
)
{
return
nameKey
.
startsWith
(
"NB_"
);
}
/**
* 判断状态为正常或报警解除
*/
private
boolean
checkStateIsNormal
(
EquipmentSpecificAlarm
equipmentSpecificAlarm
,
EquipmentSpecificIndex
equipmentSpecificIndex
)
{
String
enumKey
=
String
.
format
(
"%s_%s"
,
equipmentSpecificAlarm
.
getEquipmentSpecificIndexKey
(),
equipmentSpecificIndex
.
getValue
());
equipmentSpecificAlarm
.
setAlamReason
(
equipmentSpecificAlarm
.
getEquipmentSpecificIndexName
().
replace
(
"NB_"
,
""
)
+
":"
+
NBalarmEnum
.
getDescByKey
(
enumKey
));
boolean
flag
=
false
;
if
(!
ValidationUtil
.
isEmpty
(
equipmentSpecificAlarm
.
getType
())
&&
!
ValidationUtil
.
isEmpty
(
equipmentSpecificAlarm
.
getIotCode
())
&&
!
ValidationUtil
.
isEmpty
(
equipmentSpecificAlarm
.
getEquipmentSpecificIndexKey
())
&&
(
NBalarmEnum
.
NB_liquid_level_state_0
.
getKey
().
equals
(
enumKey
)
||
NBalarmEnum
.
NB_error_code_0
.
getKey
().
equals
(
enumKey
)
||
NBalarmEnum
.
NB_battery_state_0
.
getKey
().
equals
(
enumKey
)
||
NBalarmEnum
.
NB_hydraulic_state_0
.
getKey
().
equals
(
enumKey
)
||
NBalarmEnum
.
NB_hydraulic_state_2
.
getKey
().
equals
(
enumKey
)
||
NBalarmEnum
.
NB_hydraulic_state_4
.
getKey
().
equals
(
enumKey
)
||
NBalarmEnum
.
NB_alarm_status_4
.
getKey
().
equals
(
enumKey
)))
{
flag
=
true
;
}
return
flag
;
}
/**
* 装备实时数据处理
* @param iotDatalist
* @param indexList
* @param topicEntity
*/
private
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
<>();
// 存储温度数据至内存中(火眼)
iotDataListToCacheMap
(
iotDatalist
);
iotDatalist
.
forEach
(
iotDataVO
->
{
for
(
EquipmentSpecificIndex
equipmentSpecificIndex
:
indexList
)
{
if
(!
ObjectUtils
.
isEmpty
(
equipmentSpecificIndex
.
getNameKey
())
&&
equipmentSpecificIndex
.
getNameKey
().
toLowerCase
().
equals
(
iotDataVO
.
getKey
().
toLowerCase
()))
{
EquipmentSpecificIndex
equipmentSpeIndex
=
new
EquipmentSpecificIndex
();
BeanUtils
.
copyProperties
(
equipmentSpecificIndex
,
equipmentSpeIndex
);
String
value
=
iotDataVO
.
getValue
().
toString
();
equipmentSpeIndex
.
setValue
(
value
);
equipmentSpeIndex
.
setValueLabel
(
valueTranslate
(
value
,
equipmentSpecificIndex
.
getValueEnum
()));
equipmentSpeIndex
.
setUpdateDate
(
new
Date
());
equipmentSpecificIndexService
.
updateById
(
equipmentSpeIndex
);
equipmentSpecificIndexList
.
add
(
equipmentSpeIndex
);
indexStateList
.
add
(
createIndexStateVo
(
equipmentSpeIndex
));
// 向预控系统发送消息
sendEquipSpecIndexToAutosysTopic
(
equipmentSpeIndex
);
// 添加指标报告
saveEquipmentAlarmReportDay
(
equipmentSpeIndex
);
//火眼数据构造告警指标逻辑
equipmentSpecificIndex
=
handleTemperatureAlarm
(
equipmentSpeIndex
,
iotDatalist
);
//指标告警处理
if
(
equipmentSpecificIndex
.
getIsAlarm
()
!=
null
&&
1
==
equipmentSpecificIndex
.
getIsAlarm
()){
equipmentSpecificAlarms
.
addAll
(
createIndexAlarmRecord
(
equipmentSpecificIndex
));
}
}
}
});
// 首页性能指标数据订阅
mqttSendGateway
.
sendToMqtt
(
indexTopic
,
JSON
.
toJSONString
(
indexStateList
));
//组态大屏消息推送,设备表实时指标修改
intePageSysDataRefresh
(
equipmentSpecificIndexList
,
topicEntity
);
//数字换流站同步指标修改
syncSpecificIndexsToGS
(
equipmentSpecificIndexList
);
// 报警数据保存
saveOrUpdateEquipAlarm
(
equipmentSpecificAlarms
);
//则更新拓扑节点数据及告警状态
updateNodeDateByEquipId
(
equipmentSpecificIndexList
);
//向画布推送
publishDataToCanvas
(
equipmentSpecificIndexList
);
}
public
void
saveOrUpdateEquipAlarm
(
List
<
EquipmentSpecificAlarm
>
equipmentSpecificAlarms
){
if
(
ObjectUtils
.
isEmpty
(
equipmentSpecificAlarms
)){
return
;
}
equipmentSpecificAlarmService
.
saveOrUpdateBatch
(
equipmentSpecificAlarms
);
List
<
EquipmentSpecificAlarmLog
>
equipmentAlarmLogs
=
new
ArrayList
<>();
equipmentSpecificAlarms
.
forEach
(
action
->{
if
(
AlarmStatusEnum
.
BJ
.
getCode
()
==
action
.
getStatus
())
{
equipmentAlarmLogs
.
add
(
addEquipAlarmLogRecord
(
action
));
if
(
ValidationUtil
.
isEmpty
(
action
.
getAlamContent
()))
{
action
.
setAlamContent
(
action
.
getEquipmentSpecificName
()
+
action
.
getEquipmentSpecificIndexName
());
}
// 刷新跑马灯消息
mqttSendGateway
.
sendToMqtt
(
TopicEnum
.
EQDQR
.
getTopic
(),
JSONArray
.
toJSON
(
action
).
toString
());
}
else
{
equipmentAlarmLogs
.
addAll
(
upAlarmLogStatus
(
action
.
getIotCode
(),
action
.
getEquipmentSpecificIndexKey
(),
equipmentSpecificAlarmLogService
));
// 刷新跑马灯消息
mqttSendGateway
.
sendToMqtt
(
TopicEnum
.
EQYQR
.
getTopic
(),
JSONArray
.
toJSON
(
action
).
toString
());
bool
=
Boolean
.
TRUE
;
}
});
TransactionSynchronizationManager
.
registerSynchronization
(
new
TransactionSynchronization
()
{
@Override
public
void
afterCommit
()
{
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"seqNo"
,
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
).
toLowerCase
());
mqttSendGateway
.
sendToMqtt
(
TopicEnum
.
ALARM_LOG_INSERT
.
getTopic
(),
jsonObject
.
toString
());
mqttSendGateway
.
sendToMqtt
(
TopicEnum
.
EQZXDT
.
getTopic
(),
""
);
// 数字换流站数据处理(高斯库同步及南瑞告警推送)
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
(!
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
();
BeanUtils
.
copyProperties
(
x
,
fireEquipmentFaultAlarm
);
return
fireEquipmentFaultAlarm
;
}).
collect
(
Collectors
.
toList
());
syncDataService
.
syncCreatedFireEquiptFaultAlarm
(
faultAlarms
);
}
else
if
(
"SHIELD"
.
equalsIgnoreCase
(
key
))
{
List
<
FireEquipmentDefectAlarm
>
defectAlarms
=
list
.
stream
().
map
(
x
->
{
FireEquipmentDefectAlarm
fireEquipmentFaultAlarm
=
new
FireEquipmentDefectAlarm
();
BeanUtils
.
copyProperties
(
x
,
fireEquipmentFaultAlarm
);
return
fireEquipmentFaultAlarm
;
}).
collect
(
Collectors
.
toList
());
syncDataService
.
syncCreatedFireEquipDefectAlarm
(
defectAlarms
);
}
}
}
}
// 向南瑞平台推送报警消息
if
(!
bool
){
syncDataService
.
syncCreatedSendAlarm
(
equipmentAlarmLogs
);
}
}
}
});
}
/**
* 组装数字换流站平台告警数据
* @param
* @return
*/
private
List
<
FireEquipmentFireAlarm
>
createFireEquipmentFireAlarmVo
(
List
<
EquipmentSpecificAlarmLog
>
equipmentAlarmLogs
){
Map
<
String
,
String
>
stationInfo
=
equipmentSpecificMapper
.
getStationInfo
().
get
(
0
);
List
<
FireEquipmentFireAlarm
>
alarmList
=
new
ArrayList
<>();
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
()));
alarm
.
setFieldName
(
StringUtil
.
toNotEmptyString
(
action
.
getEquipmentSpecificIndexName
()));
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
());
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
;
}
/**
* 高斯库同步指标修改
* @param equipmentSpecificIndexList
*/
private
void
syncSpecificIndexsToGS
(
List
<
EquipmentSpecificIndex
>
equipmentSpecificIndexList
){
if
(!
ObjectUtils
.
isEmpty
(
equipmentSpecificIndexList
)
&&
syncSwitch
)
{
// 数据同步
List
<
EquipmentIndexVO
>
fireEquipMeasurementCollect
=
new
ArrayList
<>();
equipmentSpecificIndexList
.
forEach
(
action
->{
EquipmentIndexVO
equipmentIndexVO
=
new
EquipmentIndexVO
();
BeanUtils
.
copyProperties
(
action
,
equipmentIndexVO
);
fireEquipMeasurementCollect
.
add
(
equipmentIndexVO
);
});
if
(
0
<
fireEquipMeasurementCollect
.
size
())
{
syncDataService
.
syncCreatedFireEquipMeasurement
(
fireEquipMeasurementCollect
);
}
}
}
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
());
return
indexStateVo
;
}
public
List
<
EquipmentSpecificAlarm
>
createIndexAlarmRecord
(
EquipmentSpecificIndex
equipmentSpcIndex
)
{
// 处理火眼视频异常
List
<
EquipmentSpecificAlarm
>
equipmentSpecificAlarms
=
new
ArrayList
<>();
EquipmentSpecificAlarm
equipmentSpecificAlarm
=
new
EquipmentSpecificAlarm
();
equipmentSpecificAlarm
.
setSystemIds
(
equipmentSpcIndex
.
getSystemId
());
equipmentSpecificAlarm
.
setSystemCodes
(
this
.
getSystemCodeBySpeId
(
equipmentSpcIndex
.
getSystemId
()));
List
<
EquipmentSpecificAlarm
>
indexAlarms
=
equipmentSpecificAlarmMapper
.
findEquipmentSpecificAlarmByEquipmentSpecificIdAndEquipmentIndexIdAndStatusIstrue
(
equipmentSpcIndex
.
getEquipmentSpecificId
()
,
equipmentSpcIndex
.
getEquipmentIndexId
());
// NB设备告警
if
(
verifyNB
(
equipmentSpcIndex
.
getNameKey
()))
{
return
getNbEquipAlarmList
(
indexAlarms
,
equipmentSpcIndex
,
equipmentSpecificAlarm
);
}
// 报警表新增信息
if
(
ObjectUtils
.
isEmpty
(
indexAlarms
)
&&
(
TrueOrFalseEnum
.
real
.
value
.
equals
(
equipmentSpcIndex
.
getValue
())))
{
equipmentSpecificAlarms
=
addEquipmentSpecificAlarm
(
equipmentSpecificAlarms
,
equipmentSpcIndex
,
equipmentSpecificAlarm
);
}
else
{
// 报警表更新信息
for
(
EquipmentSpecificAlarm
action
:
indexAlarms
)
{
if
(
TrueOrFalseEnum
.
real
.
value
.
equals
(
equipmentSpcIndex
.
getValue
()))
{
// 报警,修改发生频率
action
.
setFrequency
((
action
.
getFrequency
()
+
1
));
}
else
{
// 报警恢复,修改数据为恢复状态
action
.
setRecoveryDate
(
new
Date
());
action
.
setEquipmentSpecificIndexValue
(
TrueOrFalseEnum
.
fake
.
value
);
action
.
setStatus
(
AlarmStatusEnum
.
HF
.
getCode
());
}
action
.
setUpdateDate
(
new
Date
());
// 更新所在系统,设备可能编辑过,更新所在系统、装备名称、装备定义code
action
.
setSystemIds
(
equipmentSpcIndex
.
getSystemId
());
action
.
setSystemCodes
(
this
.
getSystemCodeBySpeId
(
equipmentSpcIndex
.
getSystemId
()));
action
.
setEquipmentSpecificName
(
equipmentSpcIndex
.
getEquipmentSpecificName
());
action
.
setEquipmentCode
(
equipmentSpcIndex
.
getEquipmentCode
());
// 冗余字段,alarm_log表更新时使用
action
.
setEquipmentSpecificCode
(
equipmentSpcIndex
.
getEquipmentSpecificCode
());
equipmentSpecificAlarms
.
add
(
action
);
};
}
return
equipmentSpecificAlarms
;
}
/**
* 发送数据至换流站
* @param
*/
private
void
sendEquipSpecIndexToAutosysTopic
(
EquipmentSpecificIndex
equipmentSpeIndex
){
TransactionSynchronizationManager
.
registerSynchronization
(
new
TransactionSynchronization
()
{
@Override
public
void
afterCommit
()
{
String
topic
=
""
;
if
(
TrueOrFalseEnum
.
real
.
value
.
equals
(
equipmentSpeIndex
.
getValue
())
&&
EquipmentRiskTypeEnum
.
HZGJ
.
getCode
().
equals
(
equipmentSpeIndex
.
getTypeCode
()))
{
equipmentSpeIndex
.
setType
(
EquipmentRiskTypeEnum
.
HZGJ
.
getCode
());
topic
=
String
.
format
(
"%s.%s%s"
,
serverName
,
"equipment/"
,
RiskLeverForAutoSys
.
BJ
.
getCode
());
}
else
if
(
TrueOrFalseEnum
.
real
.
value
.
equals
(
equipmentSpeIndex
.
getValue
())
&&
EquipmentRiskTypeEnum
.
GZ
.
getCode
().
equals
(
equipmentSpeIndex
.
getTypeCode
()))
{
equipmentSpeIndex
.
setType
(
EquipmentRiskTypeEnum
.
GZ
.
getCode
());
topic
=
String
.
format
(
"%s.%s%s"
,
serverName
,
"equipment/"
,
RiskLeverForAutoSys
.
GZ
.
getCode
());
}
else
{
equipmentSpeIndex
.
setType
(
EquipmentRiskTypeEnum
.
QT
.
getCode
());
topic
=
String
.
format
(
"%s.%s%s"
,
serverName
,
"equipment/"
,
RiskLeverForAutoSys
.
JC
.
getCode
());
}
TopicEntityVo
topicEntityVo
=
new
TopicEntityVo
();
topicEntityVo
.
setIotCode
(
equipmentSpeIndex
.
getIotCode
());
topicEntityVo
.
setTopic
(
topic
);
topicEntityVo
.
setMessage
(
JSON
.
toJSONString
(
equipmentSpeIndex
));
mqttSendGateway
.
sendToMqtt
(
topic
,
JSON
.
toJSONString
(
topicEntityVo
));
}
});
}
/**
* 组态大屏消息推送,设备表实时指标修改
* @param equipmentSpecificIndexList
* @param topicEntity
*/
public
void
intePageSysDataRefresh
(
List
<
EquipmentSpecificIndex
>
equipmentSpecificIndexList
,
TopicEntityVo
topicEntity
){
//TODO 数字化换流站组态屏数据推送,需要在事务提交之后,否侧事务隔离查询不出数据
TransactionSynchronizationManager
.
registerSynchronization
(
new
TransactionSynchronization
()
{
@Override
public
void
afterCommit
()
{
mqttSendGateway
.
sendToMqtt
(
TopicEnum
.
EQXXTJ
.
getTopic
(),
""
);
iEquipmentSpecificSerivce
.
integrationPageSysDataRefresh
(
topicEntity
.
getCode
());
iEquipmentSpecificSerivce
.
updateEquipmentSpecIndexRealtimeData
(
equipmentSpecificIndexList
);
}
});
}
/**
* 更新数据报表表
* @param equipmentSpecificIndex
*/
private
void
saveEquipmentAlarmReportDay
(
EquipmentSpecificIndex
equipmentSpecificIndex
){
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
())
.
eq
(
EquipmentAlarmReportDay:
:
getEquipmentSpecificId
,
equipmentAlarmReportDay
.
getEquipmentSpecificId
());
List
<
EquipmentAlarmReportDay
>
reportDayList
=
iEquipmentAlarmReportDayService
.
list
(
wrapper
);
if
(
reportDayList
.
isEmpty
())
{
equipmentAlarmReportDay
.
setReportDate
(
new
Date
());
equipmentAlarmReportDay
.
setFrequency
(
1
);
iEquipmentAlarmReportDayService
.
save
(
equipmentAlarmReportDay
);
}
else
{
EquipmentAlarmReportDay
reportDay
=
reportDayList
.
get
(
0
);
reportDay
.
setLastReportDate
(
new
Date
());
reportDay
.
setValue
(
equipmentAlarmReportDay
.
getValue
());
reportDay
.
setFrequency
(
reportDay
.
getFrequency
()
+
1
);
reportDay
.
setIndexTrueNum
(
reportDay
.
getIndexTrueNum
()
==
null
?
equipmentAlarmReportDay
.
getIndexTrueNum
()
:
reportDay
.
getIndexTrueNum
()
+
equipmentAlarmReportDay
.
getIndexTrueNum
());
iEquipmentAlarmReportDayService
.
updateById
(
reportDay
);
}
}
private
String
valueTranslate
(
String
value
,
String
enumStr
){
if
(
ObjectUtils
.
isEmpty
(
enumStr
)){
return
""
;
}
try
{
JSONArray
jsonArray
=
JSONArray
.
parseArray
(
enumStr
);
for
(
int
i
=
0
;
i
<
jsonArray
.
size
();
i
++)
{
JSONObject
jsonObject
=
jsonArray
.
getJSONObject
(
i
);
if
(
jsonObject
.
get
(
"key"
).
equals
(
value
))
{
return
jsonObject
.
getString
(
"label"
);
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
""
;
}
private
void
carRealTimeDate
(
List
<
IotDataVO
>
iotDatalist
,
List
<
CarProperty
>
carProperties
){
List
<
CarProperty
>
carIndexsList
=
new
ArrayList
<>();
iotDatalist
.
forEach
(
iotDataVO
->{
// 对指标key为labels的数据处理
if
(
EquipmentIndexLabelsEnum
.
labels
.
name
.
equals
(
iotDataVO
.
getKey
()))
{
StringBuilder
sb
=
new
StringBuilder
(
"equipmentOnCar_"
);
EquipmentIndexLabelsVo
labelsVo
=
new
EquipmentIndexLabelsVo
();
Object
obj
=
iotDataVO
.
getValue
();
if
(
obj
instanceof
JSONArray
)
{
List
<
String
>
labelList
=
(
List
<
String
>)
obj
;
labelList
.
forEach
(
code
->
{
String
key
=
sb
.
append
(
code
).
toString
();
labelsVo
.
setEquipmentIotCode
(
code
);
labelsVo
.
setTime
(
new
Date
());
redisUtils
.
set
(
key
,
com
.
alibaba
.
fastjson
.
JSONObject
.
toJSONString
(
labelsVo
),
redisExpireTime
);
});
}
}
List
<
CarPropertyVo
>
carPropertyVos
=
new
ArrayList
<>();
carProperties
.
forEach
(
carProperty
->{
if
(
iotDataVO
.
getKey
().
equals
(
carProperty
.
getNameKey
()))
{
carProperty
.
setValue
(
iotDataVO
.
getValue
().
toString
());
carProperty
.
setUpdateDate
(
new
Date
());
carPropertyVos
.
add
(
carPropertyToCarPropertyVo
(
carProperty
));
carIndexsList
.
add
(
carProperty
);
}
});
boolean
updateBatchById
=
carPropertyService
.
updateBatchById
(
carIndexsList
);
if
(
updateBatchById
){
carTransactionSynch
(
carProperties
,
carPropertyVos
);
}
});
}
/**
* 车辆数据推送及同步
* @param carProperties
* @param carPropertyVos
*/
public
void
carTransactionSynch
(
List
<
CarProperty
>
carProperties
,
List
<
CarPropertyVo
>
carPropertyVos
){
//TODO 数字化换流站组态屏数据推送,需要在事务提交之后,否侧事务隔离查询不出数据
TransactionSynchronizationManager
.
registerSynchronization
(
new
TransactionSynchronization
()
{
@Override
public
void
afterCommit
()
{
List
<
CarIndexGisVo
>
list
=
createCarIndexGisVo
(
carProperties
);
mqttSendGateway
.
sendToMqtt
(
TopicEnum
.
CARZXDT
.
getTopic
(),
""
);
boolean
flag
=
ifSendToGis
(
list
);
if
(
flag
)
{
mqttSendGateway
.
sendToMqtt
(
carTopic
,
JSON
.
toJSONString
(
list
));
}
if
(
syncSwitch
)
{
syncDataService
.
syncCreatedFireVehicleMeasurement
(
carPropertyVos
);
}
}
});
}
private
CarPropertyVo
carPropertyToCarPropertyVo
(
CarProperty
property
){
CarPropertyVo
carPropertyVo
=
new
CarPropertyVo
();
carPropertyVo
.
setCarId
(
property
.
getCarId
());
carPropertyVo
.
setCreateDate
(
property
.
getCreateDate
());
carPropertyVo
.
setId
(
property
.
getId
());
carPropertyVo
.
setIsIot
(
1
);
carPropertyVo
.
setMRid
(
property
.
getEquipmentIndexId
().
toString
());
carPropertyVo
.
setName
(
property
.
getEquipmentIndexName
());
carPropertyVo
.
setNameKey
(
property
.
getEquipmentIndexKey
());
carPropertyVo
.
setSort
(
1
);
carPropertyVo
.
setUnit
(
property
.
getUnitName
());
carPropertyVo
.
setValue
(
property
.
getValue
());
return
carPropertyVo
;
}
private
List
<
CarIndexGisVo
>
createCarIndexGisVo
(
List
<
CarProperty
>
carProperties
){
List
<
CarIndexGisVo
>
list
=
new
ArrayList
<>();
long
id
=
0
l
;
String
iotCode
=
""
;
for
(
CarProperty
action
:
carProperties
){
CarIndexGisVo
v
=
new
CarIndexGisVo
();
id
=
action
.
getCarId
();
iotCode
=
action
.
getIotCode
();
v
.
setId
(
action
.
getCarId
());
v
.
setIotCode
(
action
.
getIotCode
());
v
.
setNameKey
(
action
.
getEquipmentIndexKey
());
v
.
setValue
(
ObjectUtils
.
isEmpty
(
action
.
getValue
())?
"0"
:
action
.
getValue
());
list
.
add
(
v
);
}
CarIndexGisVo
time
=
new
CarIndexGisVo
();
time
.
setId
(
id
);
time
.
setIotCode
(
iotCode
);
time
.
setNameKey
(
CarForGisEnum
.
SJ
.
getNameKey
());
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
);
}
}
}
@Autowired
private
IEquipmentSpecificSerivce
iEquipmentSpecificSerivce
;
@Autowired
FireFightingSystemMapper
fireFightingSystemMapper
;
@Autowired
private
SystemctlFeign
systemctlFeign
;
@Autowired
private
RemoteSecurityService
remoteSecurityService
;
@Autowired
private
TopographyService
topographyService
;
@Autowired
private
IEquipmentService
equipmentService
;
@Value
(
"${equipManage.name}"
)
private
String
serverName
;
@Value
(
"${mqtt.vehicle.topic}"
)
private
String
carTopic
;
@Value
(
"${equip.point.equipmentdata.topic}"
)
private
String
canvasTopic
;
@Value
(
"${equip.index.topic}"
)
private
String
indexTopic
;
@Value
(
"${spring.redis.expire.time}"
)
private
long
redisExpireTime
;
@Value
(
"${systemctl.sync.switch}"
)
private
Boolean
syncSwitch
;
@Value
(
"${systemctl.amos.switch}"
)
private
Boolean
amosSwitch
;
@Value
(
"${isSendApp}"
)
private
Boolean
isSendApp
;
private
static
Boolean
bool
=
Boolean
.
FALSE
;
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
handlerMqttIncrementMessage
(
String
topic
,
String
message
)
{
TopicEntityVo
topicEntity
=
new
TopicEntityVo
();
topicEntity
.
setTopic
(
topic
);
topicEntity
.
setMessage
(
message
);
int
endIndex
=
topic
.
lastIndexOf
(
"/"
);
String
iotCode
=
topic
.
substring
(
0
,
endIndex
).
replace
(
"/"
,
""
);
topicEntity
.
setIotCode
(
iotCode
);
List
<
EquipmentSpecificVo
>
eqIotCodeList
=
iEquipmentSpecificSerivce
.
getEquipAndCarIotcodeByIotcode
(
iotCode
);
if
(
eqIotCodeList
.
isEmpty
())
{
log
.
info
(
"该数据{}不存在!"
,
iotCode
);
return
;
}
if
(
eqIotCodeList
.
size
()
>
1
)
{
log
.
info
(
"有重复的{}数据!"
,
iotCode
);
}
EquipmentSpecificVo
vo
=
eqIotCodeList
.
get
(
0
);
topicEntity
.
setType
(
vo
.
getType
());
topicEntity
.
setCode
(
vo
.
getCode
());
JSONObject
json
=
JSONObject
.
parseObject
(
message
);
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
());
iotDataVO
.
setValue
(
entry
.
getValue
());
iotDatalist
.
add
(
iotDataVO
);
}
if
(
ObjectUtils
.
isEmpty
(
iotDatalist
))
{
return
;
}
log
.
info
(
String
.
format
(
"收到mqtt消息:%s"
,
message
));
realTimeDateProcessing
(
topicEntity
,
iotDatalist
);
}
/**
* 物联数据处理
*
* @param topicEntity
* @param iotDatalist
*/
public
void
realTimeDateProcessing
(
TopicEntityVo
topicEntity
,
List
<
IotDataVO
>
iotDatalist
)
{
String
iotCode
=
topicEntity
.
getIotCode
();
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
);
if
(
ObjectUtils
.
isEmpty
(
carProperties
))
{
return
;
}
carRealTimeDate
(
iotDatalist
,
carProperties
);
}
}
/**
* 装备实时数据处理
*
* @param iotDatalist
* @param indexList
* @param topicEntity
*/
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
<>();
// 存储温度数据至内存中(火眼)
iotDataListToCacheMap
(
iotDatalist
);
iotDatalist
.
forEach
(
iotDataVO
->
{
for
(
EquipmentSpecificIndex
equipmentSpecificIndex
:
indexList
)
{
if
(!
ObjectUtils
.
isEmpty
(
equipmentSpecificIndex
.
getNameKey
())
&&
equipmentSpecificIndex
.
getNameKey
().
toLowerCase
().
equals
(
iotDataVO
.
getKey
().
toLowerCase
()))
{
EquipmentSpecificIndex
equipmentSpeIndex
=
new
EquipmentSpecificIndex
();
BeanUtils
.
copyProperties
(
equipmentSpecificIndex
,
equipmentSpeIndex
);
String
value
=
iotDataVO
.
getValue
().
toString
();
equipmentSpeIndex
.
setValue
(
value
);
equipmentSpeIndex
.
setValueLabel
(
valueTranslate
(
value
,
equipmentSpecificIndex
.
getValueEnum
()));
equipmentSpeIndex
.
setUpdateDate
(
new
Date
());
equipmentSpecificIndexService
.
updateById
(
equipmentSpeIndex
);
// 更新设备表指标状态
iEquipmentSpecificSerivce
.
updateEquipmentSpecIndexRealtimeData
(
equipmentSpeIndex
);
equipmentSpecificIndexList
.
add
(
equipmentSpeIndex
);
indexStateList
.
add
(
createIndexStateVo
(
equipmentSpeIndex
));
// 添加指标报告
saveEquipmentAlarmReportDay
(
equipmentSpeIndex
);
// 火眼数据构造告警指标逻辑
equipmentSpecificIndex
=
handleTemperatureAlarm
(
equipmentSpeIndex
,
iotDatalist
);
// 指标告警处理
if
(
equipmentSpecificIndex
.
getIsAlarm
()
!=
null
&&
1
==
equipmentSpecificIndex
.
getIsAlarm
())
{
equipmentSpecificAlarms
.
addAll
(
createIndexAlarmRecord
(
equipmentSpecificIndex
));
}
}
}
});
// 报警数据保存
List
<
EquipmentSpecificAlarmLog
>
alarmLogs
=
saveOrUpdateEquipAlarm
(
equipmentSpecificAlarms
);
// 需要在事务提交之后,否侧事务隔离查询不出数据
TransactionSynchronizationManager
.
registerSynchronization
(
new
TransactionSynchronization
()
{
@Override
public
void
afterCommit
()
{
// 向预控系统发送消息
sendEquipSpecIndexToAutosysTopic
(
equipmentSpecificIndexList
);
// 首页性能指标数据订阅
mqttSendGateway
.
sendToMqtt
(
indexTopic
,
JSON
.
toJSONString
(
indexStateList
));
// 组态大屏消息推送,设备表实时指标修改
intePageSysDataRefresh
(
equipmentSpecificIndexList
,
topicEntity
);
// 数字换流站同步指标修改
syncSpecificIndexsToGS
(
equipmentSpecificIndexList
);
// 则更新拓扑节点数据及告警状态
updateNodeDateByEquipId
(
equipmentSpecificIndexList
);
// 向画布推送
publishDataToCanvas
(
equipmentSpecificIndexList
);
// 向其他系统推送报警
equipmentAlarmLogsToOtherSystems
(
alarmLogs
);
}
});
}
public
void
carRealTimeDate
(
List
<
IotDataVO
>
iotDatalist
,
List
<
CarProperty
>
carProperties
)
{
List
<
CarProperty
>
carIndexsList
=
new
ArrayList
<>();
iotDatalist
.
forEach
(
iotDataVO
->
{
// 对指标key为labels的数据处理
if
(
EquipmentIndexLabelsEnum
.
labels
.
name
.
equals
(
iotDataVO
.
getKey
()))
{
StringBuilder
sb
=
new
StringBuilder
(
"equipmentOnCar_"
);
EquipmentIndexLabelsVo
labelsVo
=
new
EquipmentIndexLabelsVo
();
Object
obj
=
iotDataVO
.
getValue
();
if
(
obj
instanceof
JSONArray
)
{
List
<
String
>
labelList
=
(
List
<
String
>)
obj
;
labelList
.
forEach
(
code
->
{
String
key
=
sb
.
append
(
code
).
toString
();
labelsVo
.
setEquipmentIotCode
(
code
);
labelsVo
.
setTime
(
new
Date
());
redisUtils
.
set
(
key
,
com
.
alibaba
.
fastjson
.
JSONObject
.
toJSONString
(
labelsVo
),
redisExpireTime
);
});
}
}
List
<
CarPropertyVo
>
carPropertyVos
=
new
ArrayList
<>();
carProperties
.
forEach
(
carProperty
->
{
if
(
iotDataVO
.
getKey
().
equals
(
carProperty
.
getNameKey
()))
{
carProperty
.
setValue
(
iotDataVO
.
getValue
().
toString
());
carProperty
.
setUpdateDate
(
new
Date
());
carPropertyVos
.
add
(
carPropertyToCarPropertyVo
(
carProperty
));
carIndexsList
.
add
(
carProperty
);
}
});
boolean
updateBatchById
=
carPropertyService
.
updateBatchById
(
carIndexsList
);
if
(
updateBatchById
)
{
carTransactionSynch
(
carProperties
,
carPropertyVos
);
}
});
}
public
static
List
<
EquipmentSpecificAlarmLog
>
upAlarmLogStatus
(
String
iotCode
,
String
equipmentSpecificIndexKey
,
IEquipmentSpecificAlarmLogService
equipmentSpecificAlarmLogService
)
{
LambdaQueryWrapper
<
EquipmentSpecificAlarmLog
>
queryWrapper
=
new
LambdaQueryWrapper
();
queryWrapper
.
eq
(
EquipmentSpecificAlarmLog:
:
getIotCode
,
iotCode
);
queryWrapper
.
eq
(
EquipmentSpecificAlarmLog:
:
getEquipmentSpecificIndexKey
,
equipmentSpecificIndexKey
);
queryWrapper
.
ne
(
EquipmentSpecificAlarmLog:
:
getStatus
,
AlarmStatusEnum
.
HF
.
getCode
());
List
<
EquipmentSpecificAlarmLog
>
logs
=
equipmentSpecificAlarmLogService
.
getBaseMapper
()
.
selectList
(
queryWrapper
);
logs
.
forEach
(
x
->
{
x
.
setCleanTime
(
new
Date
());
x
.
setStatus
(
AlarmStatusEnum
.
HF
.
getCode
());
});
if
(!
logs
.
isEmpty
())
{
equipmentSpecificAlarmLogService
.
updateBatchById
(
logs
);
}
return
logs
;
}
/**
* 画布数据消息推送
*
* @param indexList
*/
public
void
publishDataToCanvas
(
List
<
EquipmentSpecificIndex
>
indexList
)
{
if
(!
ObjectUtils
.
isEmpty
(
indexList
))
{
EquipmentSpecificIndex
index
=
indexList
.
stream
().
filter
(
x
->
x
.
getUpdateDate
()
!=
null
)
.
sorted
(
Comparator
.
comparing
(
EquipmentSpecificIndex:
:
getUpdateDate
).
reversed
())
.
collect
(
Collectors
.
toList
()).
get
(
0
);
EquipmentStateVo
equipmentStateVo
=
new
EquipmentStateVo
();
equipmentStateVo
.
setEquipName
(
index
.
getEquipmentSpecificName
());
equipmentStateVo
.
setOrgCode
(
index
.
getOrgCode
());
equipmentStateVo
.
setSpecificId
(
index
.
getEquipmentSpecificId
());
equipmentStateVo
.
setEquipCode
(
index
.
getQrCode
());
equipmentStateVo
.
setEquipIotCode
(
index
.
getIotCode
());
equipmentStateVo
.
setStatus
(
""
);
equipmentStateVo
.
setColor
(
index
.
getEmergencyLevelColor
());
// 添加性能指标项
//flag 无意义 getSpeIndex 方法其他地方共用 做了额外封装 为0时走原逻辑
int
flag
=
0
;
equipmentStateVo
.
setSpeindexList
(
fireFightingSystemService
.
getSpeIndex
(
index
.
getEquipmentSpecificId
(),
flag
));
Map
<
String
,
Object
>
topicObject
=
new
HashMap
<>();
topicObject
.
put
(
"equipCode"
,
equipmentStateVo
.
getEquipCode
());
if
(
TrueOrFalseEnum
.
real
.
value
.
toUpperCase
().
equals
(
index
.
getValue
().
toUpperCase
()))
{
topicObject
.
put
(
"color"
,
equipmentStateVo
.
getColor
());
}
else
{
topicObject
.
put
(
"color"
,
""
);
}
Map
<
String
,
Object
>
map
=
JSON
.
parseObject
(
JSON
.
toJSONString
(
equipmentStateVo
));
map
.
put
(
canvasTopic
,
topicObject
);
// 发送数据至画布
mqttSendGateway
.
sendToMqtt
(
canvasTopic
,
JSON
.
toJSONString
(
map
));
}
}
/**
* 报警消息推送amos平台
*
* @param equipmentSpecificAlarmLog
*/
void
syncSystemctlMsg
(
EquipmentSpecificAlarmLog
equipmentSpecificAlarmLog
)
{
try
{
MessageModel
model
=
new
MessageModel
();
String
alarmReason
=
ValidationUtil
.
isEmpty
(
equipmentSpecificAlarmLog
.
getAlarmReason
())
?
""
:
equipmentSpecificAlarmLog
.
getAlarmReason
();
if
(
alarmReason
.
contains
(
":"
))
{
String
[]
split
=
alarmReason
.
split
(
":"
);
alarmReason
=
split
[
1
];
}
model
.
setTitle
(
equipmentSpecificAlarmLog
.
getEquipmentSpecificIndexName
());
String
body
=
String
.
format
(
"警情类型:%s;报警设备:%s;报警位置:%s;报警原因:%s;报警时间:%s"
,
equipmentSpecificAlarmLog
.
getEquipmentSpecificIndexName
(),
equipmentSpecificAlarmLog
.
getEquipmentSpecificName
(),
equipmentSpecificAlarmLog
.
getLocation
(),
alarmReason
,
DateUtils
.
date2LongStr
(
equipmentSpecificAlarmLog
.
getCreateDate
()));
model
.
setBody
(
body
);
model
.
setMsgType
(
"iotMonitor"
);
if
(
isSendApp
)
{
model
.
setIsSendApp
(
true
);
model
.
setTerminal
(
"APP/WEB"
);
}
else
{
model
.
setIsSendApp
(
false
);
model
.
setTerminal
(
"WEB"
);
}
model
.
setIsSendWeb
(
true
);
model
.
setCategory
(
1
);
model
.
setRelationId
(
String
.
valueOf
(
equipmentSpecificAlarmLog
.
getId
()));
Token
token
=
remoteSecurityService
.
getServerToken
();
systemctlFeign
.
create
(
token
.
getAppKey
(),
token
.
getProduct
(),
token
.
getToke
(),
model
);
log
.
info
(
String
.
format
(
"调用平台消息服务成功:%s"
,
JSON
.
toJSONString
(
model
)));
}
catch
(
Exception
e
)
{
// e.printStackTrace();
log
.
error
(
"告警消息同步平台失败:syncSystemctlMsg,===>>>"
+
e
.
getMessage
());
}
}
private
String
getSystemCodeBySpeId
(
String
sysIds
)
{
if
(
StringUtil
.
isNotEmpty
(
sysIds
))
{
List
<
FireFightingSystemEntity
>
sys
=
fireFightingSystemMapper
.
getFightingSysByIds
(
sysIds
.
split
(
","
));
return
sys
.
stream
().
map
(
FireFightingSystemEntity:
:
getCode
).
collect
(
Collectors
.
joining
(
","
));
}
else
{
return
null
;
}
}
private
EquipmentAlarmReportDay
addEquipAlarmReportRecord
(
EquipmentSpecificIndex
equipmentSpecificIndex
)
{
EquipmentAlarmReportDay
equipmentAlarmReportDay
=
new
EquipmentAlarmReportDay
();
equipmentAlarmReportDay
.
setOrgCode
(
equipmentSpecificIndex
.
getOrgCode
());
equipmentAlarmReportDay
.
setReportDate
(
new
Date
());
equipmentAlarmReportDay
.
setUpdateDate
(
new
Date
());
equipmentAlarmReportDay
.
setSystemIds
(
equipmentSpecificIndex
.
getSystemId
());
equipmentAlarmReportDay
.
setLastReportDate
(
new
Date
());
equipmentAlarmReportDay
.
setEquipmentSpecificId
(
equipmentSpecificIndex
.
getEquipmentSpecificId
());
equipmentAlarmReportDay
.
setEquipmentSpecificName
(
equipmentSpecificIndex
.
getEquipmentSpecificName
());
equipmentAlarmReportDay
.
setEquipmentDetailId
(
equipmentSpecificIndex
.
getEquipmentDetailId
());
equipmentAlarmReportDay
.
setEquipmentId
(
equipmentSpecificIndex
.
getEquipmentId
());
equipmentAlarmReportDay
.
setEquipmentCode
(
equipmentSpecificIndex
.
getEquipmentCode
());
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
());
equipmentAlarmReportDay
.
setIndexType
(
equipmentSpecificIndex
.
getNameKey
());
equipmentAlarmReportDay
.
setValue
(
equipmentSpecificIndex
.
getValue
());
equipmentAlarmReportDay
.
setIsAlarm
(
equipmentSpecificIndex
.
getIsAlarm
());
return
equipmentAlarmReportDay
;
}
private
EquipmentSpecificAlarmLog
addEquipAlarmLogRecord
(
EquipmentSpecificAlarm
equipmentSpecificAlarm
)
{
EquipmentSpecificAlarmLog
equipmentSpecificAlarmLog
=
new
EquipmentSpecificAlarmLog
();
BeanUtils
.
copyProperties
(
equipmentSpecificAlarm
,
equipmentSpecificAlarmLog
);
equipmentSpecificAlarmLog
.
setId
(
null
);
equipmentSpecificAlarmLog
.
setCreateDate
(
new
Date
());
equipmentSpecificAlarmLog
.
setEquipmentSpecificAlarmId
(
equipmentSpecificAlarm
.
getId
());
boolean
bool
=
equipmentSpecificAlarmLogService
.
save
(
equipmentSpecificAlarmLog
);
// 同步告警消息给平台
if
(
amosSwitch
&&
bool
)
{
EquipmentSpecificAlarmLog
alarmLog
=
equipmentSpecificAlarmLogService
.
getById
(
equipmentSpecificAlarmLog
.
getId
());
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
syncSystemctlMsg
(
alarmLog
);
}
}).
start
();
}
return
equipmentSpecificAlarmLog
;
}
/**
* 添加告警
*
* @param equipmentSpecificAlarms
* @param equipmentSpecificIndex
* @return
*/
private
List
<
EquipmentSpecificAlarm
>
addEquipmentSpecificAlarm
(
List
<
EquipmentSpecificAlarm
>
equipmentSpecificAlarms
,
EquipmentSpecificIndex
equipmentSpecificIndex
,
EquipmentSpecificAlarm
equipmentSpecificAlarm
)
{
BeanUtils
.
copyProperties
(
equipmentSpecificIndex
,
equipmentSpecificAlarm
);
equipmentSpecificAlarm
.
setId
(
null
);
equipmentSpecificAlarm
.
setFrequency
(
1
);
equipmentSpecificAlarm
.
setStatus
(
AlarmStatusEnum
.
BJ
.
getCode
());
equipmentSpecificAlarm
.
setEquipmentSpecificIndexKey
(
equipmentSpecificIndex
.
getNameKey
());
equipmentSpecificAlarm
.
setEquipmentSpecificIndexValue
(
equipmentSpecificIndex
.
getValue
());
equipmentSpecificAlarm
.
setEquipmentSpecificIndexLabel
(
equipmentSpecificIndex
.
getValueLabel
());
equipmentSpecificAlarm
.
setType
(
equipmentSpecificIndex
.
getTypeCode
());
equipmentSpecificAlarm
.
setCreateDate
(
new
Date
());
equipmentSpecificAlarm
.
setUpdateDate
(
new
Date
());
equipmentSpecificAlarm
.
setEquipmentCode
(
equipmentSpecificIndex
.
getEquipmentCode
());
equipmentSpecificAlarm
.
setEquipmentId
(
equipmentSpecificIndex
.
getEquipmentId
());
equipmentSpecificAlarm
.
setEquipmentDetailId
(
equipmentSpecificIndex
.
getEquipmentDetailId
());
equipmentSpecificAlarm
.
setEquipmentSpecificCode
(
equipmentSpecificIndex
.
getEquipmentSpecificCode
());
equipmentSpecificAlarm
.
setEmergencyLevel
(
equipmentSpecificIndex
.
getEmergencyLevel
());
equipmentSpecificAlarm
.
setEmergencyLevelColor
(
equipmentSpecificIndex
.
getEmergencyLevelColor
());
equipmentSpecificAlarm
.
setEmergencyLevelDescribe
(
equipmentSpecificIndex
.
getEmergencyLevelDescribe
());
equipmentSpecificAlarms
.
add
(
equipmentSpecificAlarm
);
return
equipmentSpecificAlarms
;
}
// 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
))
{
return
equipmentSpecificAlarmList
;
}
else
{
equipmentSpecificAlarmList
.
clear
();
}
}
else
{
indexAlarms
.
forEach
(
action
->
{
// 状态为正常或报警解除
if
(
checkStateIsNormal
(
action
,
equipmentSpecificIndex
))
{
// 修改报警数据为正常
action
.
setRecoveryDate
(
new
Date
());
action
.
setStatus
(
AlarmStatusEnum
.
HF
.
getCode
());
// 修改之前数据为已处理
action
.
setResolveResult
(
action
.
getAlamReason
());
action
.
setConfirmUserName
(
"系统"
);
action
.
setConfirmType
(
action
.
getType
());
equipmentSpecificAlarmLogService
.
updateAlarmLogByIotCodeAndIndexKey
(
action
);
}
else
{
action
.
setFrequency
((
action
.
getFrequency
()
+
1
));
}
// 更新所在系统,设备可能编辑过
action
.
setSystemIds
(
equipmentSpecificIndex
.
getSystemId
());
action
.
setSystemCodes
(
this
.
getSystemCodeBySpeId
(
equipmentSpecificIndex
.
getSystemId
()));
action
.
setUpdateDate
(
new
Date
());
equipmentSpecificAlarmList
.
add
(
action
);
});
}
return
equipmentSpecificAlarmList
;
}
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
()))
{
if
(!
StringUtil
.
isNotEmpty
(
gisVo
.
getValue
())
||
"0"
.
equals
(
gisVo
.
getValue
()))
{
flag
=
false
;
continue
;
}
}
if
(
CarForGisEnum
.
WD
.
getNameKey
().
equals
(
gisVo
.
getNameKey
())
||
"0"
.
equals
(
gisVo
.
getValue
()))
{
if
(!
StringUtil
.
isNotEmpty
(
gisVo
.
getValue
()))
{
flag
=
false
;
continue
;
}
}
}
if
(
list1
.
size
()
==
0
||
list2
.
size
()
==
0
)
{
flag
=
false
;
}
return
flag
;
}
/**
* 接收到的IOT数据为火眼存储到Map中
*/
private
void
iotDataListToCacheMap
(
List
<
IotDataVO
>
iotDatalist
)
{
List
<
IotDataVO
>
iotDataVOs
=
iotDatalist
.
stream
()
.
filter
(
x
->
"alarmLevel"
.
equals
(
x
.
getKey
())
||
"alarmType"
.
equals
(
x
.
getKey
())
||
"temperature"
.
equals
(
x
.
getKey
())
||
"ruleTemperature"
.
equals
(
x
.
getKey
())
||
"thermometryUnit"
.
equals
(
x
.
getKey
())
||
"alarmRule"
.
equals
(
x
.
getKey
()))
.
collect
(
Collectors
.
toList
());
if
(
iotDataVOs
.
size
()
>
0
)
{
Map
<
String
,
Object
>
map
=
iotDatalist
.
stream
()
.
collect
(
Collectors
.
toMap
(
IotDataVO:
:
getKey
,
IotDataVO:
:
getValue
));
putTemperatureMap
(
map
.
get
(
"traceId"
).
toString
(),
map
);
}
}
/**
* 处理火眼逻辑合并为一条告警
*/
private
EquipmentSpecificIndex
handleTemperatureAlarm
(
EquipmentSpecificIndex
equipmentSpecificIndex
,
List
<
IotDataVO
>
iotDatalist
)
{
List
<
IotDataVO
>
collect
=
iotDatalist
.
stream
().
filter
(
x
->
"traceId"
.
equals
(
x
.
getKey
()))
.
collect
(
Collectors
.
toList
());
if
(
collect
.
size
()
>
0
&&
temperatureMapIsEmpty
(
String
.
valueOf
(
collect
.
get
(
0
).
getValue
())))
{
String
traceId
=
String
.
valueOf
(
collect
.
get
(
0
).
getValue
());
TemperatureAlarmDto
dto
=
temperatureMap
.
get
(
traceId
);
equipmentSpecificIndex
.
setEquipmentSpecificIndexName
(
AlarmTypeEnum
.
getTypeByCode
(
AlarmTypeEnum
.
GZGJ
.
getCode
()));
equipmentSpecificIndex
.
setNameKey
(
AlarmTypeEnum
.
GZGJ
.
getCode
());
equipmentSpecificIndex
.
setAlamReason
(
TemperatureAlarm
.
getAlarmContent
(
dto
.
getAlarmLevel
(),
dto
.
getAlarmType
(),
dto
.
getAlarmRule
(),
dto
.
getRuleTemperature
(),
dto
.
getTemperature
(),
dto
.
getThermometryUnit
()));
equipmentSpecificIndex
.
setValue
(
"true"
);
equipmentSpecificIndex
.
setIsAlarm
(
1
);
temperatureMap
.
remove
(
traceId
);
}
return
equipmentSpecificIndex
;
}
/**
* temperatureMap存储数据
*/
private
void
putTemperatureMap
(
String
traceId
,
Map
<
String
,
Object
>
map
)
{
TemperatureAlarmDto
cacheTemperatureAlarmDto
=
temperatureMap
.
get
(
traceId
);
if
(
ValidationUtil
.
isEmpty
(
cacheTemperatureAlarmDto
))
{
cacheTemperatureAlarmDto
=
new
TemperatureAlarmDto
();
}
TemperatureAlarmDto
newMap
=
JSON
.
parseObject
(
JSON
.
toJSONString
(
map
),
TemperatureAlarmDto
.
class
);
BeanUtil
.
copyPropertiesIgnoreNull
(
newMap
,
cacheTemperatureAlarmDto
);
temperatureMap
.
put
(
traceId
,
cacheTemperatureAlarmDto
);
}
private
boolean
temperatureMapIsEmpty
(
String
traceId
)
{
TemperatureAlarmDto
dto
=
temperatureMap
.
get
(
traceId
);
if
(!
ValidationUtil
.
isEmpty
(
dto
)
&&
!
ValidationUtil
.
isEmpty
(
dto
.
getAlarmLevel
())
&&
!
ValidationUtil
.
isEmpty
(
dto
.
getAlarmType
())
&&
!
ValidationUtil
.
isEmpty
(
dto
.
getAlarmRule
())
&&
!
ValidationUtil
.
isEmpty
(
dto
.
getRuleTemperature
())
&&
!
ValidationUtil
.
isEmpty
(
dto
.
getTemperature
())
&&
!
ValidationUtil
.
isEmpty
(
dto
.
getThermometryUnit
()))
{
return
true
;
}
return
false
;
}
/**
* 判断是否为NB物联监测设备参数
*
* @param nameKey
* @return
*/
private
boolean
verifyNB
(
String
nameKey
)
{
return
nameKey
.
startsWith
(
"NB_"
);
}
/**
* 判断状态为正常或报警解除
*/
private
boolean
checkStateIsNormal
(
EquipmentSpecificAlarm
equipmentSpecificAlarm
,
EquipmentSpecificIndex
equipmentSpecificIndex
)
{
String
enumKey
=
String
.
format
(
"%s_%s"
,
equipmentSpecificAlarm
.
getEquipmentSpecificIndexKey
(),
equipmentSpecificIndex
.
getValue
());
equipmentSpecificAlarm
.
setAlamReason
(
equipmentSpecificAlarm
.
getEquipmentSpecificIndexName
().
replace
(
"NB_"
,
""
)
+
":"
+
NBalarmEnum
.
getDescByKey
(
enumKey
));
boolean
flag
=
false
;
if
(!
ValidationUtil
.
isEmpty
(
equipmentSpecificAlarm
.
getType
())
&&
!
ValidationUtil
.
isEmpty
(
equipmentSpecificAlarm
.
getIotCode
())
&&
!
ValidationUtil
.
isEmpty
(
equipmentSpecificAlarm
.
getEquipmentSpecificIndexKey
())
&&
(
NBalarmEnum
.
NB_liquid_level_state_0
.
getKey
().
equals
(
enumKey
)
||
NBalarmEnum
.
NB_error_code_0
.
getKey
().
equals
(
enumKey
)
||
NBalarmEnum
.
NB_battery_state_0
.
getKey
().
equals
(
enumKey
)
||
NBalarmEnum
.
NB_hydraulic_state_0
.
getKey
().
equals
(
enumKey
)
||
NBalarmEnum
.
NB_hydraulic_state_2
.
getKey
().
equals
(
enumKey
)
||
NBalarmEnum
.
NB_hydraulic_state_4
.
getKey
().
equals
(
enumKey
)
||
NBalarmEnum
.
NB_alarm_status_4
.
getKey
().
equals
(
enumKey
)))
{
flag
=
true
;
}
return
flag
;
}
public
List
<
EquipmentSpecificAlarmLog
>
saveOrUpdateEquipAlarm
(
List
<
EquipmentSpecificAlarm
>
equipmentSpecificAlarms
)
{
List
<
EquipmentSpecificAlarmLog
>
equipmentAlarmLogs
=
new
ArrayList
<>();
if
(
ObjectUtils
.
isEmpty
(
equipmentSpecificAlarms
))
{
return
equipmentAlarmLogs
;
}
equipmentSpecificAlarmService
.
saveOrUpdateBatch
(
equipmentSpecificAlarms
);
equipmentSpecificAlarms
.
forEach
(
action
->
{
if
(
AlarmStatusEnum
.
BJ
.
getCode
()
==
action
.
getStatus
())
{
equipmentAlarmLogs
.
add
(
addEquipAlarmLogRecord
(
action
));
if
(
ValidationUtil
.
isEmpty
(
action
.
getAlamContent
()))
{
action
.
setAlamContent
(
action
.
getEquipmentSpecificName
()
+
action
.
getEquipmentSpecificIndexName
());
}
mqttSendGateway
.
sendToMqtt
(
TopicEnum
.
EQDQR
.
getTopic
(),
JSONArray
.
toJSON
(
action
).
toString
());
}
else
{
equipmentAlarmLogs
.
addAll
(
upAlarmLogStatus
(
action
.
getIotCode
(),
action
.
getEquipmentSpecificIndexKey
(),
equipmentSpecificAlarmLogService
));
mqttSendGateway
.
sendToMqtt
(
TopicEnum
.
EQYQR
.
getTopic
(),
JSONArray
.
toJSON
(
action
).
toString
());
bool
=
Boolean
.
TRUE
;
}
});
return
equipmentAlarmLogs
;
}
/**
* 报警日志同步其他系统
*
* @param equipmentAlarmLogs
*/
public
void
equipmentAlarmLogsToOtherSystems
(
List
<
EquipmentSpecificAlarmLog
>
equipmentAlarmLogs
)
{
if
(
ObjectUtils
.
isEmpty
(
equipmentAlarmLogs
))
{
return
;
}
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"seqNo"
,
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
).
toLowerCase
());
mqttSendGateway
.
sendToMqtt
(
TopicEnum
.
ALARM_LOG_INSERT
.
getTopic
(),
jsonObject
.
toString
());
mqttSendGateway
.
sendToMqtt
(
TopicEnum
.
EQZXDT
.
getTopic
(),
""
);
// 数字换流站数据处理(高斯库同步及南瑞告警推送)
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
(!
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
();
BeanUtils
.
copyProperties
(
x
,
fireEquipmentFaultAlarm
);
return
fireEquipmentFaultAlarm
;
}).
collect
(
Collectors
.
toList
());
syncDataService
.
syncCreatedFireEquiptFaultAlarm
(
faultAlarms
);
}
else
if
(
"SHIELD"
.
equalsIgnoreCase
(
key
))
{
List
<
FireEquipmentDefectAlarm
>
defectAlarms
=
list
.
stream
().
map
(
x
->
{
FireEquipmentDefectAlarm
fireEquipmentFaultAlarm
=
new
FireEquipmentDefectAlarm
();
BeanUtils
.
copyProperties
(
x
,
fireEquipmentFaultAlarm
);
return
fireEquipmentFaultAlarm
;
}).
collect
(
Collectors
.
toList
());
syncDataService
.
syncCreatedFireEquipDefectAlarm
(
defectAlarms
);
}
}
}
}
// 向南瑞平台推送报警消息
if
(!
bool
)
{
syncDataService
.
syncCreatedSendAlarm
(
equipmentAlarmLogs
);
}
}
}
/**
* 组装数字换流站平台告警数据
*
* @param
* @return
*/
private
List
<
FireEquipmentFireAlarm
>
createFireEquipmentFireAlarmVo
(
List
<
EquipmentSpecificAlarmLog
>
equipmentAlarmLogs
)
{
Map
<
String
,
String
>
stationInfo
=
equipmentSpecificMapper
.
getStationInfo
().
get
(
0
);
List
<
FireEquipmentFireAlarm
>
alarmList
=
new
ArrayList
<>();
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
()));
alarm
.
setFieldName
(
StringUtil
.
toNotEmptyString
(
action
.
getEquipmentSpecificIndexName
()));
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
());
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
;
}
/**
* 高斯库同步指标修改
*
* @param equipmentSpecificIndexList
*/
private
void
syncSpecificIndexsToGS
(
List
<
EquipmentSpecificIndex
>
equipmentSpecificIndexList
)
{
if
(!
ObjectUtils
.
isEmpty
(
equipmentSpecificIndexList
)
&&
syncSwitch
)
{
// 数据同步
List
<
EquipmentIndexVO
>
fireEquipMeasurementCollect
=
new
ArrayList
<>();
equipmentSpecificIndexList
.
forEach
(
action
->
{
EquipmentIndexVO
equipmentIndexVO
=
new
EquipmentIndexVO
();
BeanUtils
.
copyProperties
(
action
,
equipmentIndexVO
);
fireEquipMeasurementCollect
.
add
(
equipmentIndexVO
);
});
if
(
0
<
fireEquipMeasurementCollect
.
size
())
{
syncDataService
.
syncCreatedFireEquipMeasurement
(
fireEquipMeasurementCollect
);
}
}
}
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
());
return
indexStateVo
;
}
public
List
<
EquipmentSpecificAlarm
>
createIndexAlarmRecord
(
EquipmentSpecificIndex
equipmentSpcIndex
)
{
// 处理火眼视频异常
List
<
EquipmentSpecificAlarm
>
equipmentSpecificAlarms
=
new
ArrayList
<>();
EquipmentSpecificAlarm
equipmentSpecificAlarm
=
new
EquipmentSpecificAlarm
();
equipmentSpecificAlarm
.
setSystemIds
(
equipmentSpcIndex
.
getSystemId
());
equipmentSpecificAlarm
.
setSystemCodes
(
this
.
getSystemCodeBySpeId
(
equipmentSpcIndex
.
getSystemId
()));
List
<
EquipmentSpecificAlarm
>
indexAlarms
=
equipmentSpecificAlarmMapper
.
findEquipmentSpecificAlarmByEquipmentSpecificIdAndEquipmentIndexIdAndStatusIstrue
(
equipmentSpcIndex
.
getEquipmentSpecificId
(),
equipmentSpcIndex
.
getEquipmentIndexId
());
// NB设备告警
if
(
verifyNB
(
equipmentSpcIndex
.
getNameKey
()))
{
return
getNbEquipAlarmList
(
indexAlarms
,
equipmentSpcIndex
,
equipmentSpecificAlarm
);
}
// 报警表新增信息
if
(
ObjectUtils
.
isEmpty
(
indexAlarms
)
&&
(
TrueOrFalseEnum
.
real
.
value
.
equals
(
equipmentSpcIndex
.
getValue
())))
{
addEquipmentSpecificAlarm
(
equipmentSpecificAlarms
,
equipmentSpcIndex
,
equipmentSpecificAlarm
);
}
else
{
// 报警表更新信息
indexAlarms
.
forEach
(
action
->
{
if
(
TrueOrFalseEnum
.
real
.
value
.
equals
(
equipmentSpcIndex
.
getValue
()))
{
// 报警,修改发生频率
action
.
setFrequency
((
action
.
getFrequency
()
+
1
));
}
else
{
// 报警恢复,修改数据为恢复状态
action
.
setRecoveryDate
(
new
Date
());
action
.
setEquipmentSpecificIndexValue
(
TrueOrFalseEnum
.
fake
.
value
);
action
.
setStatus
(
AlarmStatusEnum
.
HF
.
getCode
());
}
action
.
setUpdateDate
(
new
Date
());
// 更新所在系统,设备可能编辑过,更新所在系统、装备名称、装备定义code
action
.
setSystemIds
(
equipmentSpcIndex
.
getSystemId
());
action
.
setSystemCodes
(
this
.
getSystemCodeBySpeId
(
equipmentSpcIndex
.
getSystemId
()));
action
.
setEquipmentSpecificName
(
equipmentSpcIndex
.
getEquipmentSpecificName
());
action
.
setEquipmentCode
(
equipmentSpcIndex
.
getEquipmentCode
());
// 冗余字段,alarm_log表更新时使用
action
.
setEquipmentSpecificCode
(
equipmentSpcIndex
.
getEquipmentSpecificCode
());
action
.
setBuildId
(
equipmentSpcIndex
.
getBuildId
());
equipmentSpecificAlarms
.
add
(
action
);
});
}
return
equipmentSpecificAlarms
;
}
/**
* 发送数据至换流站
*
* @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
()))
{
equipmentSpeIndex
.
setType
(
EquipmentRiskTypeEnum
.
HZGJ
.
getCode
());
topic
=
String
.
format
(
"%s.%s%s"
,
serverName
,
"equipment/"
,
RiskLeverForAutoSys
.
BJ
.
getCode
());
}
else
if
(
TrueOrFalseEnum
.
real
.
value
.
equals
(
equipmentSpeIndex
.
getValue
())
&&
EquipmentRiskTypeEnum
.
GZ
.
getCode
().
equals
(
equipmentSpeIndex
.
getTypeCode
()))
{
equipmentSpeIndex
.
setType
(
EquipmentRiskTypeEnum
.
GZ
.
getCode
());
topic
=
String
.
format
(
"%s.%s%s"
,
serverName
,
"equipment/"
,
RiskLeverForAutoSys
.
GZ
.
getCode
());
}
else
{
equipmentSpeIndex
.
setType
(
EquipmentRiskTypeEnum
.
QT
.
getCode
());
topic
=
String
.
format
(
"%s.%s%s"
,
serverName
,
"equipment/"
,
RiskLeverForAutoSys
.
JC
.
getCode
());
}
TopicEntityVo
topicEntityVo
=
new
TopicEntityVo
();
topicEntityVo
.
setIotCode
(
equipmentSpeIndex
.
getIotCode
());
topicEntityVo
.
setTopic
(
topic
);
topicEntityVo
.
setMessage
(
JSON
.
toJSONString
(
equipmentSpeIndex
));
mqttSendGateway
.
sendToMqtt
(
topic
,
JSON
.
toJSONString
(
topicEntityVo
));
});
}
/**
* 组态大屏消息推送
*
* @param equipmentSpecificIndexList
* @param topicEntity
*/
public
void
intePageSysDataRefresh
(
List
<
EquipmentSpecificIndex
>
equipmentSpecificIndexList
,
TopicEntityVo
topicEntity
)
{
mqttSendGateway
.
sendToMqtt
(
TopicEnum
.
EQXXTJ
.
getTopic
(),
""
);
iEquipmentSpecificSerivce
.
integrationPageSysDataRefresh
(
topicEntity
.
getCode
());
}
/**
* 更新数据报表表
*
* @param equipmentSpecificIndex
*/
private
void
saveEquipmentAlarmReportDay
(
EquipmentSpecificIndex
equipmentSpecificIndex
)
{
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
())
.
eq
(
EquipmentAlarmReportDay:
:
getEquipmentSpecificId
,
equipmentAlarmReportDay
.
getEquipmentSpecificId
());
List
<
EquipmentAlarmReportDay
>
reportDayList
=
iEquipmentAlarmReportDayService
.
list
(
wrapper
);
if
(
reportDayList
.
isEmpty
())
{
equipmentAlarmReportDay
.
setReportDate
(
new
Date
());
equipmentAlarmReportDay
.
setFrequency
(
1
);
iEquipmentAlarmReportDayService
.
save
(
equipmentAlarmReportDay
);
}
else
{
EquipmentAlarmReportDay
reportDay
=
reportDayList
.
get
(
0
);
reportDay
.
setLastReportDate
(
new
Date
());
reportDay
.
setValue
(
equipmentAlarmReportDay
.
getValue
());
reportDay
.
setFrequency
(
reportDay
.
getFrequency
()
+
1
);
reportDay
.
setIndexTrueNum
(
reportDay
.
getIndexTrueNum
()
==
null
?
equipmentAlarmReportDay
.
getIndexTrueNum
()
:
reportDay
.
getIndexTrueNum
()
+
equipmentAlarmReportDay
.
getIndexTrueNum
());
iEquipmentAlarmReportDayService
.
updateById
(
reportDay
);
}
}
private
String
valueTranslate
(
String
value
,
String
enumStr
)
{
if
(
ObjectUtils
.
isEmpty
(
enumStr
))
{
return
""
;
}
try
{
JSONArray
jsonArray
=
JSONArray
.
parseArray
(
enumStr
);
for
(
int
i
=
0
;
i
<
jsonArray
.
size
();
i
++)
{
JSONObject
jsonObject
=
jsonArray
.
getJSONObject
(
i
);
if
(
jsonObject
.
get
(
"key"
).
equals
(
value
))
{
return
jsonObject
.
getString
(
"label"
);
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
""
;
}
/**
* 车辆数据推送及同步
*
* @param carProperties
* @param carPropertyVos
*/
public
void
carTransactionSynch
(
List
<
CarProperty
>
carProperties
,
List
<
CarPropertyVo
>
carPropertyVos
)
{
// TODO 数字化换流站组态屏数据推送,需要在事务提交之后,否侧事务隔离查询不出数据
TransactionSynchronizationManager
.
registerSynchronization
(
new
TransactionSynchronization
()
{
@Override
public
void
afterCommit
()
{
List
<
CarIndexGisVo
>
list
=
createCarIndexGisVo
(
carProperties
);
mqttSendGateway
.
sendToMqtt
(
TopicEnum
.
CARZXDT
.
getTopic
(),
""
);
boolean
flag
=
ifSendToGis
(
list
);
if
(
flag
)
{
mqttSendGateway
.
sendToMqtt
(
carTopic
,
JSON
.
toJSONString
(
list
));
}
if
(
syncSwitch
)
{
syncDataService
.
syncCreatedFireVehicleMeasurement
(
carPropertyVos
);
}
}
});
}
private
CarPropertyVo
carPropertyToCarPropertyVo
(
CarProperty
property
)
{
CarPropertyVo
carPropertyVo
=
new
CarPropertyVo
();
carPropertyVo
.
setCarId
(
property
.
getCarId
());
carPropertyVo
.
setCreateDate
(
property
.
getCreateDate
());
carPropertyVo
.
setId
(
property
.
getId
());
carPropertyVo
.
setIsIot
(
1
);
carPropertyVo
.
setMRid
(
property
.
getEquipmentIndexId
().
toString
());
carPropertyVo
.
setName
(
property
.
getEquipmentIndexName
());
carPropertyVo
.
setNameKey
(
property
.
getEquipmentIndexKey
());
carPropertyVo
.
setSort
(
1
);
carPropertyVo
.
setUnit
(
property
.
getUnitName
());
carPropertyVo
.
setValue
(
property
.
getValue
());
return
carPropertyVo
;
}
private
List
<
CarIndexGisVo
>
createCarIndexGisVo
(
List
<
CarProperty
>
carProperties
)
{
List
<
CarIndexGisVo
>
list
=
new
ArrayList
<>();
long
id
=
0
l
;
String
iotCode
=
""
;
for
(
CarProperty
action
:
carProperties
)
{
CarIndexGisVo
v
=
new
CarIndexGisVo
();
id
=
action
.
getCarId
();
iotCode
=
action
.
getIotCode
();
v
.
setId
(
action
.
getCarId
());
v
.
setIotCode
(
action
.
getIotCode
());
v
.
setNameKey
(
action
.
getEquipmentIndexKey
());
v
.
setValue
(
ObjectUtils
.
isEmpty
(
action
.
getValue
())
?
"0"
:
action
.
getValue
());
list
.
add
(
v
);
}
CarIndexGisVo
time
=
new
CarIndexGisVo
();
time
.
setId
(
id
);
time
.
setIotCode
(
iotCode
);
time
.
setNameKey
(
CarForGisEnum
.
SJ
.
getNameKey
());
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
);
}
}
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-jcs-biz/src/main/java/com/yeejoin/amos/boot/module/jcs/biz/controller/PowerTransferCompanyController.java
View file @
7c32611a
package
com
.
yeejoin
.
amos
.
boot
.
module
.
jcs
.
biz
.
controller
;
import
java.util.Arrays
;
import
java.util.Objects
;
import
com.yeejoin.amos.boot.module.common.biz.service.impl.SourceFileServiceImpl
;
import
com.yeejoin.amos.boot.module.jcs.api.entity.JcSituationDetail
;
import
com.yeejoin.amos.boot.module.jcs.api.mapper.JcSituationDetailMapper
;
import
com.yeejoin.amos.component.rule.config.RuleConfig
;
import
org.apache.commons.lang3.StringUtils
;
import
org.eclipse.paho.client.mqttv3.MqttException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.typroject.tyboot.component.emq.EmqKeeper
;
import
org.typroject.tyboot.core.foundation.enumeration.UserType
;
import
org.typroject.tyboot.core.restful.doc.TycloudOperation
;
...
...
@@ -22,6 +30,9 @@ import com.yeejoin.amos.boot.module.jcs.biz.service.impl.PowerTransferCompanySer
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.typroject.tyboot.core.restful.exception.instance.BadRequest
;
import
org.typroject.tyboot.core.restful.utils.ResponseHelper
;
import
org.typroject.tyboot.core.restful.utils.ResponseModel
;
/**
...
...
@@ -38,6 +49,18 @@ public class PowerTransferCompanyController extends BaseController {
@Autowired
PowerTransferCompanyServiceImpl
powerTransferCompanyService
;
@Autowired
SourceFileServiceImpl
sourceFileService
;
@Autowired
JcSituationDetailMapper
jcSituationDetailMapper
;
@Autowired
private
EmqKeeper
emqKeeper
;
@Value
(
"${mqtt.topic.command.power.deployment}"
)
private
String
topic
;
/**
* 新增调派单位
*
...
...
@@ -139,5 +162,29 @@ public class PowerTransferCompanyController extends BaseController {
page
=
powerTransferCompanyService
.
page
(
pageBean
,
powerTransferCompanyQueryWrapper
);
return
page
;
}
/**
* 新增文字信息图片信息
*
* @return 返回结果
*/
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@RequestMapping
(
value
=
"/jcSituationDetail/save"
,
method
=
RequestMethod
.
POST
)
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"新增文字信息图片信息"
,
notes
=
"新增文字信息图片信息"
)
public
ResponseModel
<
Boolean
>
saveJcSituationDetail
(
@RequestBody
JcSituationDetail
jcSituationDetail
)
throws
MqttException
{
if
(
Objects
.
isNull
(
jcSituationDetail
.
getAlertCalledId
()))
{
throw
new
BadRequest
(
"警情ID不能为空"
);
}
jcSituationDetailMapper
.
insert
(
jcSituationDetail
);
// if (ObjectUtils.isNotEmpty(jcSituationDetail.getAttachments())) {
// sourceFileService.saveAttachments(jcSituationDetail.getSequenceNbr(), jcSituationDetail.getAttachments());
// }
// 自定义指令信息消息推送
// 定义指令信息消息推送 页面发送mqtt 默认发送 String 类型 0, 新警情 1 警情状态变化
emqKeeper
.
getMqttClient
().
publish
(
topic
,
"0"
.
getBytes
(),
RuleConfig
.
DEFAULT_QOS
,
false
);
return
ResponseHelper
.
buildResponse
(
Boolean
.
TRUE
);
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-jcs-biz/src/main/java/com/yeejoin/amos/boot/module/jcs/biz/service/impl/AlertSubmittedServiceImpl.java
View file @
7c32611a
...
...
@@ -32,6 +32,9 @@ import java.util.stream.IntStream;
import
com.yeejoin.amos.boot.module.command.api.dto.FrontlineLiaisonDto
;
import
com.yeejoin.amos.boot.module.command.biz.service.impl.FrontlineLiaisonServiceImpl
;
import
com.yeejoin.amos.boot.module.common.api.service.ISourceFileService
;
import
com.yeejoin.amos.boot.module.jcs.api.entity.*
;
import
com.yeejoin.amos.boot.module.jcs.api.mapper.JcSituationDetailMapper
;
import
org.apache.commons.lang3.ObjectUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.poi.xwpf.usermodel.XWPFTable
;
...
...
@@ -113,10 +116,6 @@ import com.yeejoin.amos.boot.module.jcs.api.dto.SchedulingReportingDto;
import
com.yeejoin.amos.boot.module.jcs.api.dto.TemplateDto
;
import
com.yeejoin.amos.boot.module.jcs.api.dto.TemplateExtendDto
;
import
com.yeejoin.amos.boot.module.jcs.api.dto.VoiceRecordFileDto
;
import
com.yeejoin.amos.boot.module.jcs.api.entity.AlertCalled
;
import
com.yeejoin.amos.boot.module.jcs.api.entity.AlertSubmitted
;
import
com.yeejoin.amos.boot.module.jcs.api.entity.AlertSubmittedObject
;
import
com.yeejoin.amos.boot.module.jcs.api.entity.Template
;
import
com.yeejoin.amos.boot.module.jcs.api.enums.AlertBusinessTypeEnum
;
import
com.yeejoin.amos.boot.module.jcs.api.enums.AlertSchedulingTypeEnum
;
import
com.yeejoin.amos.boot.module.jcs.api.enums.AlertStageEnums
;
...
...
@@ -214,6 +213,9 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
private
FrontlineLiaisonServiceImpl
frontlineLiaisonServiceImpl
;
@Autowired
JcSituationDetailMapper
jcSituationDetailMapper
;
@Value
(
"${mqtt.topic.command.alert.noticeJa}"
)
private
String
topicJa
;
...
...
@@ -1434,6 +1436,20 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
listInstructionsZHDto
.
add
(
instruct
);
});
//增加自定义指令信息:实战指挥需求【1575】
LambdaQueryWrapper
<
JcSituationDetail
>
qw
=
new
LambdaQueryWrapper
();
qw
.
eq
(
JcSituationDetail:
:
getAlertCalledId
,
id
);
List
<
JcSituationDetail
>
jcSituationDetailList
=
jcSituationDetailMapper
.
selectList
(
qw
);
jcSituationDetailList
.
stream
().
forEach
(
item
->
{
InstructionsZHDto
instructionsZHDto
=
new
InstructionsZHDto
();
instructionsZHDto
.
setSequenceNbr
(
item
.
getSequenceNbr
());
instructionsZHDto
.
setType
(
item
.
getInfoType
());
instructionsZHDto
.
setContent
(
item
.
getInfo
());
instructionsZHDto
.
setSubmissionTime
(
item
.
getRecDate
());
listInstructionsZHDto
.
add
(
instructionsZHDto
);
});
// ;
//排序时间倒序
/* Bug 2613 修改排序 按照发送时间排序 2021-09-01 陈召 开始*/
Collections
.
sort
(
listInstructionsZHDto
,
new
Comparator
<
InstructionsZHDto
>()
{
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-supervision-biz/src/main/java/com/yeejoin/amos/supervision/business/service/impl/PlanTaskServiceImpl.java
View file @
7c32611a
...
...
@@ -378,22 +378,9 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
continue
;
paramMap
.
clear
();
paramMap
.
put
(
"id"
,
plan
.
getId
());
// 2.1计划数据合法性校验
Boolean
fileFlag
=
PlanTaskUtil
.
checkMustFile
(
plan
);
if
(!
fileFlag
)
{
paramMap
.
put
(
"next_gen_date"
,
tomorrow
);
planMapper
.
updPlanStatusOrGenDate
(
paramMap
);
// 更新为明天
continue
;
}
// 2.2.计算生成数据的日期区间
CalDateVo
vo
=
PlanTaskUtil
.
reGenPlanTaskData
(
plan
,
tomorrow
,
tomorrow
);
// 计划未开始,则更新生成时间为明天
if
(
null
==
vo
)
{
paramMap
.
put
(
"next_gen_date"
,
tomorrow
);
planMapper
.
updPlanStatusOrGenDate
(
paramMap
);
// 更新为明天
continue
;
}
// 计划已过期,则更新status = 7,已完成
if
(!
vo
.
getIsGenData
())
{
int
num
=
0
;
...
...
@@ -413,9 +400,28 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
paramMap
.
put
(
"status"
,
PlanStatusEnum
.
COMPLETED
.
getValue
());
}
}
if
(
plan
.
getIsFixedDate
().
equals
(
"2"
)){
paramMap
.
put
(
"status"
,
PlanStatusEnum
.
OUT_TIME
.
getValue
());
planMapper
.
updPlanStatusOrGenDate
(
paramMap
);
continue
;
}
planMapper
.
updPlanStatusOrGenDate
(
paramMap
);
continue
;
}
// 2.1计划数据合法性校验
Boolean
fileFlag
=
PlanTaskUtil
.
checkMustFile
(
plan
);
if
(!
fileFlag
)
{
paramMap
.
put
(
"next_gen_date"
,
tomorrow
);
planMapper
.
updPlanStatusOrGenDate
(
paramMap
);
// 更新为明天
continue
;
}
// 计划未开始,则更新生成时间为明天
if
(
null
==
vo
)
{
paramMap
.
put
(
"next_gen_date"
,
tomorrow
);
planMapper
.
updPlanStatusOrGenDate
(
paramMap
);
// 更新为明天
continue
;
}
// 2.3.执行数据生成(具体时间 + 人员)
List
<
HashMap
<
String
,
Object
>>
list
=
genAllExeDate
(
plan
,
vo
,
XJConstant
.
SCHED_FLAG
);
...
...
@@ -757,7 +763,7 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
ReginParams
reginParam
=
JSON
.
parseObject
(
redisUtils
.
get
(
RedisKey
.
buildReginKey
(
RequestContext
.
getExeUserId
(),
RequestContext
.
getToken
())).
toString
(),
ReginParams
.
class
);
params
.
put
(
"loginUserId"
,
reginParam
.
getPersonIdentity
().
getPersonSeq
());
//
params.put("loginUserId", reginParam.getPersonIdentity().getPersonSeq());
long
total
=
planTaskMapper
.
getPlanTasksCount
(
params
);
if
(
total
==
0
)
{
return
new
PageImpl
<>(
content
,
pageParam
,
total
);
...
...
amos-boot-system-jcs/src/main/resources/db/changelog/jcs-1.0.0.0.xml
View file @
7c32611a
...
...
@@ -3122,5 +3122,27 @@
</sql>
</changeSet>
<changeSet
author=
"zs"
id=
"2022-05-31-01"
>
<preConditions
onFail=
"MARK_RAN"
>
<not>
<tableExists
tableName=
"jc_situation_detail"
/>
</not>
</preConditions>
<comment>
增加自定义指令表
</comment>
<sql>
CREATE TABLE `jc_situation_detail` (
`sequence_nbr` bigint(20) NOT NULL AUTO_INCREMENT,
`info` longtext COMMENT '内容图片信息',
`alert_called_id` bigint(20) DEFAULT NULL COMMENT '警情ID',
`rec_date` datetime DEFAULT NULL COMMENT '时间',
`rec_user_id` varchar(19) DEFAULT NULL COMMENT '发送人',
`rec_user_name` varchar(15) DEFAULT NULL COMMENT '发送人名称',
`is_delete` bit(1) NOT NULL COMMENT '是否删除',
`info_type` varchar(255) DEFAULT NULL COMMENT '消息类型',
PRIMARY KEY (`sequence_nbr`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
</sql>
</changeSet>
</databaseChangeLog>
amos-boot-system-latentdanger/src/main/resources/db/mapper/LatentDangerMapper.xml
View file @
7c32611a
...
...
@@ -1041,8 +1041,8 @@
<if
test=
"key == 'endDeadline' and value != null and value != ''"
>
and a.reform_limit_date
<![CDATA[ <= ]]>
#{value}
</if>
<if
test=
"key == 'point
Name
' and value != null and value != ''"
>
and a.biz_info like concat('%"point
Name
":"', #{value}, '"%')
<if
test=
"key == 'point
Id
' and value != null and value != ''"
>
and a.biz_info like concat('%"point
Id
":"', #{value}, '"%')
</if>
</foreach>
</where>
...
...
amos-boot-system-tzs/amos-boot-module-tzs-api/src/main/java/com/yeejoin/amos/boot/module/tzs/flc/api/dto/TaskDto.java
0 → 100644
View file @
7c32611a
package
com
.
yeejoin
.
amos
.
boot
.
module
.
tzs
.
flc
.
api
.
dto
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
com.yeejoin.amos.boot.biz.common.dto.BaseDto
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
java.util.Date
;
/**
* 任务表
*
* @author system_generator
* @date 2022-05-31
*/
@Data
@EqualsAndHashCode
(
callSuper
=
true
)
@ApiModel
(
value
=
"TaskDto"
,
description
=
"任务表"
)
public
class
TaskDto
extends
BaseDto
{
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
value
=
"任务名称"
)
private
String
name
;
@ApiModelProperty
(
value
=
"内容"
)
private
String
content
;
@ApiModelProperty
(
value
=
"描述"
)
private
String
description
;
@ApiModelProperty
(
value
=
"状态【0:待填报,1:待签收,2:已完成】"
)
private
Integer
status
=
0
;
@ApiModelProperty
(
value
=
"用户ID"
)
private
String
userId
;
@ApiModelProperty
(
value
=
"创建时间"
)
private
Date
createDate
;
@ApiModelProperty
(
value
=
"对接公司编码"
)
private
String
appId
;
@ApiModelProperty
(
value
=
"单位ID"
)
private
String
deptId
;
@ApiModelProperty
(
value
=
"单位名称"
)
private
String
deptName
;
}
amos-boot-system-tzs/amos-boot-module-tzs-api/src/main/java/com/yeejoin/amos/boot/module/tzs/flc/api/entity/Task.java
0 → 100644
View file @
7c32611a
package
com
.
yeejoin
.
amos
.
boot
.
module
.
tzs
.
flc
.
api
.
entity
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.yeejoin.amos.boot.biz.common.entity.BaseEntity
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
import
java.util.Date
;
/**
* 任务表
*
* @author system_generator
* @date 2022-05-31
*/
@Data
@EqualsAndHashCode
(
callSuper
=
true
)
@Accessors
(
chain
=
true
)
@TableName
(
"tz_task"
)
public
class
Task
extends
BaseEntity
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* 任务名称
*/
@TableField
(
"name"
)
private
String
name
;
/**
* 内容
*/
@TableField
(
"content"
)
private
String
content
;
/**
* 描述
*/
@TableField
(
"description"
)
private
String
description
;
/**
* 状态【0:待填报,1:待签收,2:已完成】
*/
@TableField
(
"status"
)
private
Integer
status
;
/**
* 用户ID
*/
@TableField
(
"user_id"
)
private
String
userId
;
/**
* 创建时间
*/
@TableField
(
"create_date"
)
private
Date
createDate
;
/**
* 对接公司编码
*/
@TableField
(
"app_id"
)
private
String
appId
;
/**
* 单位ID
*/
@TableField
(
"dept_id"
)
private
String
deptId
;
/**
* 单位名称
*/
@TableField
(
"dept_name"
)
private
String
deptName
;
}
amos-boot-system-tzs/amos-boot-module-tzs-api/src/main/java/com/yeejoin/amos/boot/module/tzs/flc/api/enums/TaskStatusEnum.java
0 → 100644
View file @
7c32611a
package
com
.
yeejoin
.
amos
.
boot
.
module
.
tzs
.
flc
.
api
.
enums
;
import
lombok.Getter
;
/**
* 任务状态枚举
*/
@Getter
public
enum
TaskStatusEnum
{
待填报
(
0
,
"待填报"
),
待签收
(
1
,
"待签收"
),
已完成
(
2
,
"已完成"
);
private
Integer
key
;
private
String
desc
;
TaskStatusEnum
(
Integer
key
,
String
desc
)
{
this
.
key
=
key
;
this
.
desc
=
desc
;
}
}
amos-boot-system-tzs/amos-boot-module-tzs-api/src/main/java/com/yeejoin/amos/boot/module/tzs/flc/api/mapper/TaskMapper.java
0 → 100644
View file @
7c32611a
package
com
.
yeejoin
.
amos
.
boot
.
module
.
tzs
.
flc
.
api
.
mapper
;
import
com.yeejoin.amos.boot.module.tzs.flc.api.entity.Task
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
/**
* 任务表 Mapper 接口
*
* @author system_generator
* @date 2022-05-31
*/
public
interface
TaskMapper
extends
BaseMapper
<
Task
>
{
}
amos-boot-system-tzs/amos-boot-module-tzs-api/src/main/java/com/yeejoin/amos/boot/module/tzs/flc/api/service/ITaskService.java
0 → 100644
View file @
7c32611a
package
com
.
yeejoin
.
amos
.
boot
.
module
.
tzs
.
flc
.
api
.
service
;
/**
* 任务表接口类
*
* @author system_generator
* @date 2022-05-31
*/
public
interface
ITaskService
{
}
amos-boot-system-tzs/amos-boot-module-tzs-api/src/main/resources/mapper/TaskMapper.xml
0 → 100644
View file @
7c32611a
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.yeejoin.amos.boot.module.tzs.flc.api.mapper.TaskMapper"
>
</mapper>
amos-boot-system-tzs/amos-boot-module-tzs-biz/src/main/java/com/yeejoin/amos/boot/module/tzs/flc/biz/controller/TaskController.java
0 → 100644
View file @
7c32611a
package
com
.
yeejoin
.
amos
.
boot
.
module
.
tzs
.
flc
.
biz
.
controller
;
import
com.alibaba.fastjson.JSONObject
;
import
com.yeejoin.amos.boot.module.tzs.flc.api.enums.TaskStatusEnum
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.Api
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.yeejoin.amos.boot.biz.common.controller.BaseController
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
com.yeejoin.amos.boot.module.tzs.flc.biz.service.impl.TaskServiceImpl
;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
import
org.typroject.tyboot.core.restful.utils.ResponseHelper
;
import
org.typroject.tyboot.core.restful.utils.ResponseModel
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
javax.servlet.http.HttpServletRequest
;
import
org.springframework.web.bind.annotation.*
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.yeejoin.amos.boot.module.tzs.flc.api.dto.TaskDto
;
import
org.typroject.tyboot.core.restful.doc.TycloudOperation
;
import
org.typroject.tyboot.core.foundation.enumeration.UserType
;
/**
* 任务表
*
* @author system_generator
* @date 2022-05-31
*/
@RestController
@Api
(
tags
=
"任务表Api"
)
@RequestMapping
(
value
=
"/task"
)
public
class
TaskController
extends
BaseController
{
@Autowired
TaskServiceImpl
taskServiceImpl
;
/**
* 新增任务表
*
* @return
*/
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@PostMapping
(
value
=
"/save"
)
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"新增任务表"
,
notes
=
"新增任务表"
)
public
ResponseModel
<
TaskDto
>
save
(
@RequestBody
TaskDto
model
)
{
model
.
setCreateDate
(
new
Date
());
model
.
setUserId
(
RequestContext
.
getExeUserId
());
model
=
taskServiceImpl
.
createWithModel
(
model
);
return
ResponseHelper
.
buildResponse
(
model
);
}
/**
* 根据sequenceNbr更新
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@PutMapping
(
value
=
"/{sequenceNbr}"
)
@ApiOperation
(
httpMethod
=
"PUT"
,
value
=
"根据sequenceNbr更新任务表"
,
notes
=
"根据sequenceNbr更新任务表"
)
public
ResponseModel
<
TaskDto
>
updateBySequenceNbrTask
(
@RequestBody
TaskDto
model
,
@PathVariable
(
value
=
"sequenceNbr"
)
Long
sequenceNbr
)
{
model
.
setSequenceNbr
(
sequenceNbr
);
return
ResponseHelper
.
buildResponse
(
taskServiceImpl
.
updateWithModel
(
model
));
}
/**
* 根据sequenceNbr删除
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@DeleteMapping
(
value
=
"/{sequenceNbr}"
)
@ApiOperation
(
httpMethod
=
"DELETE"
,
value
=
"根据sequenceNbr删除任务表"
,
notes
=
"根据sequenceNbr删除任务表"
)
public
ResponseModel
deleteBySequenceNbr
(
HttpServletRequest
request
,
@PathVariable
(
value
=
"sequenceNbr"
)
Long
sequenceNbr
)
{
taskServiceImpl
.
deleteById
(
sequenceNbr
);
return
ResponseHelper
.
buildResponse
(
null
);
}
/**
* 根据sequenceNbr查询
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@GetMapping
(
value
=
"/{sequenceNbr}"
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"根据sequenceNbr查询单个任务表"
,
notes
=
"根据sequenceNbr查询单个任务表"
)
public
ResponseModel
<
TaskDto
>
selectOne
(
@PathVariable
Long
sequenceNbr
)
{
return
ResponseHelper
.
buildResponse
(
taskServiceImpl
.
queryBySeq
(
sequenceNbr
));
}
/**
* 列表分页查询
*
* @param current 当前页
* @param current 每页大小
* @param status TODO(uncomplete: 待办,complete:已办)
* @return
*/
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@GetMapping
(
value
=
"/page"
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"任务表分页查询"
,
notes
=
"任务表分页查询"
)
public
ResponseModel
<
Page
<
TaskDto
>>
queryForPage
(
@RequestParam
(
value
=
"current"
)
int
current
,
@RequestParam
(
value
=
"size"
)
int
size
,
@RequestParam
(
value
=
"status"
,
required
=
false
)
String
status
)
{
Page
<
TaskDto
>
page
=
new
Page
<
TaskDto
>();
page
.
setCurrent
(
current
);
page
.
setSize
(
size
);
return
ResponseHelper
.
buildResponse
(
taskServiceImpl
.
queryForTaskPageByStatus
(
page
,
RequestContext
.
getExeUserId
(),
status
));
}
/**
* 统计任务数量
*
* @return
*/
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"任务数量查询"
,
notes
=
"任务数量查询"
)
@GetMapping
(
value
=
"/queryCount"
)
public
ResponseModel
<
JSONObject
>
queryCountForMap
()
{
return
ResponseHelper
.
buildResponse
(
taskServiceImpl
.
queryCountForMap
(
RequestContext
.
getExeUserId
()));
}
/**
* 列表全部数据查询
*
* @return
*/
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"任务表列表全部数据查询"
,
notes
=
"任务表列表全部数据查询"
)
@GetMapping
(
value
=
"/list"
)
public
ResponseModel
<
List
<
TaskDto
>>
selectForList
()
{
return
ResponseHelper
.
buildResponse
(
taskServiceImpl
.
queryForTaskList
());
}
}
amos-boot-system-tzs/amos-boot-module-tzs-biz/src/main/java/com/yeejoin/amos/boot/module/tzs/flc/biz/service/impl/TaskServiceImpl.java
0 → 100644
View file @
7c32611a
package
com
.
yeejoin
.
amos
.
boot
.
module
.
tzs
.
flc
.
biz
.
service
.
impl
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.yeejoin.amos.boot.biz.common.utils.DateUtils
;
import
com.yeejoin.amos.boot.module.tzs.flc.api.dto.TaskDto
;
import
com.yeejoin.amos.boot.module.tzs.flc.api.entity.Task
;
import
com.yeejoin.amos.boot.module.tzs.flc.api.enums.TaskStatusEnum
;
import
com.yeejoin.amos.boot.module.tzs.flc.api.mapper.TaskMapper
;
import
com.yeejoin.amos.boot.module.tzs.flc.api.service.ITaskService
;
import
org.springframework.stereotype.Component
;
import
org.typroject.tyboot.core.rdbms.annotation.Condition
;
import
org.typroject.tyboot.core.rdbms.annotation.Operator
;
import
org.typroject.tyboot.core.rdbms.service.BaseService
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
/**
* 任务表服务实现类
*
* @author system_generator
* @date 2022-05-31
*/
@Component
public
class
TaskServiceImpl
extends
BaseService
<
TaskDto
,
Task
,
TaskMapper
>
implements
ITaskService
{
public
void
deleteById
(
Long
sequenceNbr
)
{
TaskDto
taskDto
=
this
.
queryBySeq
(
sequenceNbr
);
taskDto
.
setIsDelete
(
true
);
this
.
updateWithModel
(
taskDto
);
}
public
Page
<
TaskDto
>
queryForTaskPageByStatus
(
Page
<
TaskDto
>
page
,
String
userId
,
String
status
)
{
List
<
Integer
>
statusList
=
getStatus
(
status
);
return
this
.
queryForTaskPage
(
page
,
userId
,
statusList
);
}
public
JSONObject
queryCountForMap
(
String
userId
){
Date
[]
recDate
=
new
Date
[
2
];
Date
now
=
DateUtils
.
getDateNow
();
recDate
[
0
]
=
DateUtils
.
getCurrentDayStartTime
(
now
);
recDate
[
1
]
=
DateUtils
.
getCurrentDayEndTime
(
now
);
// 我的任务
Integer
myTaskCount
=
this
.
queryForCount
(
userId
,
null
,
null
);
// 今日待办
List
<
Integer
>
statusList
=
getStatus
(
"uncomplete"
);
Integer
todyUnCompletedTaskCount
=
this
.
queryForCount
(
userId
,
recDate
,
statusList
);
// 未完结业务
Integer
unCompletedTaskCount
=
this
.
queryForCount
(
userId
,
null
,
statusList
);
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"myTask"
,
myTaskCount
);
jsonObject
.
put
(
"todyUnCompletedTask"
,
todyUnCompletedTaskCount
);
jsonObject
.
put
(
"unCompletedTask"
,
unCompletedTaskCount
);
return
jsonObject
;
}
/**
* 分页查询
*/
public
Page
<
TaskDto
>
queryForTaskPage
(
Page
<
TaskDto
>
page
,
String
userId
,
@Condition
(
Operator
.
in
)
List
<
Integer
>
status
)
{
return
this
.
queryForPage
(
page
,
null
,
false
,
userId
,
status
);
}
/**
* 列表查询 示例
*/
public
List
<
TaskDto
>
queryForTaskList
()
{
return
this
.
queryForList
(
""
,
false
);
}
/**
* 列表查询 示例
*/
public
Integer
queryForCount
(
String
userId
,
@Condition
(
Operator
.
between
)
Date
[]
recDate
,
@Condition
(
Operator
.
in
)
List
<
Integer
>
status
)
{
return
this
.
queryCount
(
userId
,
recDate
,
status
);
}
private
List
<
Integer
>
getStatus
(
String
status
)
{
List
<
Integer
>
statusList
=
new
ArrayList
<>();
if
(
"uncomplete"
.
equals
(
status
))
{
statusList
.
add
(
TaskStatusEnum
.
待填报
.
getKey
());
statusList
.
add
(
TaskStatusEnum
.
待签收
.
getKey
());
}
else
if
(
"complete"
.
equals
(
status
))
{
statusList
.
add
(
TaskStatusEnum
.
已完成
.
getKey
());
}
return
statusList
;
}
}
\ No newline at end of file
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