Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
YeeAmosFireAutoSysRoot
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
station
YeeAmosFireAutoSysRoot
Commits
ee8e7742
Commit
ee8e7742
authored
Sep 04, 2020
by
高东东
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
*)添加预案回放
parent
c760876f
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
271 additions
and
35 deletions
+271
-35
ContingencyAction.java
...m/yeejoin/amos/fas/business/action/ContingencyAction.java
+22
-3
ContingencyLogListener.java
...join/amos/fas/business/action/ContingencyLogListener.java
+21
-0
RiskSituationAction.java
...yeejoin/amos/fas/business/action/RiskSituationAction.java
+2
-1
SimpleTipAction.java
...com/yeejoin/amos/fas/business/action/SimpleTipAction.java
+2
-1
ContingencyEvent.java
...join/amos/fas/business/action/model/ContingencyEvent.java
+21
-0
StationEnum.java
.../com/yeejoin/amos/fas/business/action/mq/StationEnum.java
+32
-0
ContingencyLogPublisher.java
...mos/fas/business/action/util/ContingencyLogPublisher.java
+18
-0
RiskSourceController.java
...in/amos/fas/business/controller/RiskSourceController.java
+2
-2
TimeLineController.java
...join/amos/fas/business/controller/TimeLineController.java
+12
-0
IRuleRuningSnapshotDao.java
...s/fas/business/dao/repository/IRuleRuningSnapshotDao.java
+10
-0
ContingencyInstanceImpl.java
...os/fas/business/service/impl/ContingencyInstanceImpl.java
+30
-17
RiskSourceServiceImpl.java
...amos/fas/business/service/impl/RiskSourceServiceImpl.java
+3
-2
RuleRunigSnapshotServiceImpl.java
...s/business/service/impl/RuleRunigSnapshotServiceImpl.java
+94
-9
IRuleRunningSnapshotService.java
...s/business/service/intfc/IRuleRunningSnapshotService.java
+2
-0
No files found.
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/action/ContingencyAction.java
View file @
ee8e7742
...
@@ -31,13 +31,16 @@ import com.fasterxml.jackson.databind.ObjectMapper;
...
@@ -31,13 +31,16 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import
com.yeejoin.amos.component.rule.MethodParam
;
import
com.yeejoin.amos.component.rule.MethodParam
;
import
com.yeejoin.amos.component.rule.RuleActionBean
;
import
com.yeejoin.amos.component.rule.RuleActionBean
;
import
com.yeejoin.amos.component.rule.RuleMethod
;
import
com.yeejoin.amos.component.rule.RuleMethod
;
import
com.yeejoin.amos.fas.business.action.model.ContingencyEvent
;
import
com.yeejoin.amos.fas.business.action.model.ContingencyRo
;
import
com.yeejoin.amos.fas.business.action.model.ContingencyRo
;
import
com.yeejoin.amos.fas.business.action.model.DeviceRo
;
import
com.yeejoin.amos.fas.business.action.model.DeviceRo
;
import
com.yeejoin.amos.fas.business.action.model.SetpEnum
;
import
com.yeejoin.amos.fas.business.action.model.SetpEnum
;
import
com.yeejoin.amos.fas.business.action.mq.StationEnum
;
import
com.yeejoin.amos.fas.business.action.mq.WebMqttComponent
;
import
com.yeejoin.amos.fas.business.action.mq.WebMqttComponent
;
import
com.yeejoin.amos.fas.business.action.result.ActionResult
;
import
com.yeejoin.amos.fas.business.action.result.ActionResult
;
import
com.yeejoin.amos.fas.business.action.result.SafteyPlanResult
;
import
com.yeejoin.amos.fas.business.action.result.SafteyPlanResult
;
import
com.yeejoin.amos.fas.business.action.result.message.AbstractActionResultMessage
;
import
com.yeejoin.amos.fas.business.action.result.message.AbstractActionResultMessage
;
import
com.yeejoin.amos.fas.business.action.util.ContingencyLogPublisher
;
import
com.yeejoin.amos.fas.business.action.util.StepComparator
;
import
com.yeejoin.amos.fas.business.action.util.StepComparator
;
import
com.yeejoin.amos.fas.business.feign.IDutyModeServer
;
import
com.yeejoin.amos.fas.business.feign.IDutyModeServer
;
import
com.yeejoin.amos.fas.business.feign.RemoteSecurityService
;
import
com.yeejoin.amos.fas.business.feign.RemoteSecurityService
;
...
@@ -75,7 +78,8 @@ public class ContingencyAction implements CustomerAction {
...
@@ -75,7 +78,8 @@ public class ContingencyAction implements CustomerAction {
@Autowired
@Autowired
private
FireStengthService
fireStrengthService
;
private
FireStengthService
fireStrengthService
;
@Autowired
private
ContingencyLogPublisher
contingencyLogPublisher
;
// private RestTemplate restTemplate = new RestTemplate();
// private RestTemplate restTemplate = new RestTemplate();
// @Value("${bussunis.domain}")
// @Value("${bussunis.domain}")
...
@@ -167,12 +171,20 @@ public class ContingencyAction implements CustomerAction {
...
@@ -167,12 +171,20 @@ public class ContingencyAction implements CustomerAction {
AbstractActionResultMessage
<?>
action
=
(
AbstractActionResultMessage
<?>)
constructor
.
newInstance
(
result
);
AbstractActionResultMessage
<?>
action
=
(
AbstractActionResultMessage
<?>)
constructor
.
newInstance
(
result
);
if
(
"mqtt"
.
equals
(
pushType
.
toLowerCase
()))
{
if
(
"mqtt"
.
equals
(
pushType
.
toLowerCase
()))
{
ToipResponse
toipResponse
=
action
.
buildResponse
(
msgType
,
contingency
,
result
.
toJson
());
ToipResponse
toipResponse
=
action
.
buildResponse
(
msgType
,
contingency
,
result
.
toJson
());
String
topic
=
String
.
format
(
"/%s/%s/%s"
,
serviceName
,
"yinan"
,
"plan"
);
String
topic
=
String
.
format
(
"/%s/%s/%s"
,
serviceName
,
StationEnum
.
YINAN
.
getCode
()
,
"plan"
);
log
.
info
(
String
.
format
(
"mqtt[%s]:【 %s 】"
,
topic
,
toipResponse
.
toJsonStr
()));
log
.
info
(
String
.
format
(
"mqtt[%s]:【 %s 】"
,
topic
,
toipResponse
.
toJsonStr
()));
webMqttComponent
.
publish
(
topic
,
toipResponse
.
toJsonStr
());
webMqttComponent
.
publish
(
topic
,
toipResponse
.
toJsonStr
());
ContingencyEvent
event
=
new
ContingencyEvent
(
this
);
event
.
setMsgBody
(
toipResponse
.
toJsonStr
());
event
.
setTopic
(
topic
);
event
.
setMsgType
(
msgType
);
event
.
setContingency
(
contingency
);
contingencyLogPublisher
.
publish
(
event
);
}
else
if
(
"websocket"
.
equals
(
pushType
.
toLowerCase
())){
}
else
if
(
"websocket"
.
equals
(
pushType
.
toLowerCase
())){
action
.
execute
(
msgType
,
contingency
);
action
.
execute
(
msgType
,
contingency
);
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
@@ -738,9 +750,16 @@ public class ContingencyAction implements CustomerAction {
...
@@ -738,9 +750,16 @@ public class ContingencyAction implements CustomerAction {
AbstractActionResultMessage
<?>
action
=
(
AbstractActionResultMessage
<?>)
constructor
.
newInstance
(
result
);
AbstractActionResultMessage
<?>
action
=
(
AbstractActionResultMessage
<?>)
constructor
.
newInstance
(
result
);
if
(
"mqtt"
.
equals
(
pushType
.
toLowerCase
()))
{
if
(
"mqtt"
.
equals
(
pushType
.
toLowerCase
()))
{
ToipResponse
toipResponse
=
action
.
buildResponse
(
msgType
,
deviceRo
,
result
.
toJson
());
ToipResponse
toipResponse
=
action
.
buildResponse
(
msgType
,
deviceRo
,
result
.
toJson
());
String
topic
=
String
.
format
(
"/%s/%s/%s"
,
serviceName
,
"yinan"
,
"plan"
);
String
topic
=
String
.
format
(
"/%s/%s/%s"
,
serviceName
,
StationEnum
.
YINAN
.
getCode
()
,
"plan"
);
log
.
info
(
String
.
format
(
"mqtt[%s]:【 %s 】"
,
topic
,
toipResponse
.
toJsonStr
()));
log
.
info
(
String
.
format
(
"mqtt[%s]:【 %s 】"
,
topic
,
toipResponse
.
toJsonStr
()));
webMqttComponent
.
publish
(
topic
,
toipResponse
.
toJsonStr
());
webMqttComponent
.
publish
(
topic
,
toipResponse
.
toJsonStr
());
ContingencyEvent
event
=
new
ContingencyEvent
(
this
);
event
.
setMsgBody
(
toipResponse
.
toJsonStr
());
event
.
setTopic
(
topic
);
event
.
setMsgType
(
msgType
);
event
.
setContingency
(
deviceRo
);
contingencyLogPublisher
.
publish
(
event
);
}
else
if
(
"websocket"
.
equals
(
pushType
.
toLowerCase
())){
}
else
if
(
"websocket"
.
equals
(
pushType
.
toLowerCase
())){
action
.
execute
(
msgType
,
deviceRo
);
action
.
execute
(
msgType
,
deviceRo
);
}
}
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/action/ContingencyLogListener.java
0 → 100644
View file @
ee8e7742
package
com
.
yeejoin
.
amos
.
fas
.
business
.
action
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.stereotype.Component
;
import
com.yeejoin.amos.fas.business.action.model.ContingencyEvent
;
import
com.yeejoin.amos.fas.business.service.intfc.IRuleRunningSnapshotService
;
@Component
public
class
ContingencyLogListener
implements
ApplicationListener
<
ContingencyEvent
>{
@Autowired
IRuleRunningSnapshotService
ruleRunningSnapshotService
;
@Override
public
void
onApplicationEvent
(
ContingencyEvent
event
)
{
ruleRunningSnapshotService
.
reacordPlan
(
event
.
getTopic
(),
event
.
getMsgType
(),
event
.
getMsgBody
(),
event
.
getContingency
());
}
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/action/RiskSituationAction.java
View file @
ee8e7742
...
@@ -11,6 +11,7 @@ import org.springframework.stereotype.Component;
...
@@ -11,6 +11,7 @@ import org.springframework.stereotype.Component;
import
com.yeejoin.amos.component.rule.MethodParam
;
import
com.yeejoin.amos.component.rule.MethodParam
;
import
com.yeejoin.amos.component.rule.RuleActionBean
;
import
com.yeejoin.amos.component.rule.RuleActionBean
;
import
com.yeejoin.amos.component.rule.RuleMethod
;
import
com.yeejoin.amos.component.rule.RuleMethod
;
import
com.yeejoin.amos.fas.business.action.mq.StationEnum
;
import
com.yeejoin.amos.fas.business.action.mq.WebMqttComponent
;
import
com.yeejoin.amos.fas.business.action.mq.WebMqttComponent
;
import
com.yeejoin.amos.fas.business.action.result.ActionResult
;
import
com.yeejoin.amos.fas.business.action.result.ActionResult
;
import
com.yeejoin.amos.fas.business.action.result.BubbleTipResult
;
import
com.yeejoin.amos.fas.business.action.result.BubbleTipResult
;
...
@@ -69,7 +70,7 @@ public class RiskSituationAction implements CustomerAction
...
@@ -69,7 +70,7 @@ public class RiskSituationAction implements CustomerAction
String
msgType
=
"bubbleTip"
;
String
msgType
=
"bubbleTip"
;
if
(
"mqtt"
.
equals
(
pushType
.
toLowerCase
()))
{
if
(
"mqtt"
.
equals
(
pushType
.
toLowerCase
()))
{
ToipResponse
toipResponse
=
action
.
buildResponse
(
msgType
,
bizobj
,
result
);
ToipResponse
toipResponse
=
action
.
buildResponse
(
msgType
,
bizobj
,
result
);
String
topic
=
String
.
format
(
"/%s/%s/%s"
,
serviceName
,
"yinan"
,
"rule"
);
String
topic
=
String
.
format
(
"/%s/%s/%s"
,
serviceName
,
StationEnum
.
YINAN
.
getCode
()
,
"rule"
);
webMqttComponent
.
publish
(
topic
,
toipResponse
.
toJsonStr
());
webMqttComponent
.
publish
(
topic
,
toipResponse
.
toJsonStr
());
}
else
{
}
else
{
Object
obj
=
action
.
execute
(
msgType
,
bizobj
);
Object
obj
=
action
.
execute
(
msgType
,
bizobj
);
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/action/SimpleTipAction.java
View file @
ee8e7742
...
@@ -12,6 +12,7 @@ import org.springframework.stereotype.Component;
...
@@ -12,6 +12,7 @@ import org.springframework.stereotype.Component;
import
com.yeejoin.amos.fas.business.action.el.ELEvaluationContext
;
import
com.yeejoin.amos.fas.business.action.el.ELEvaluationContext
;
import
com.yeejoin.amos.fas.business.action.model.RiskSourceRuleRo
;
import
com.yeejoin.amos.fas.business.action.model.RiskSourceRuleRo
;
import
com.yeejoin.amos.fas.business.action.mq.StationEnum
;
import
com.yeejoin.amos.fas.business.action.mq.WebMqttComponent
;
import
com.yeejoin.amos.fas.business.action.mq.WebMqttComponent
;
import
com.yeejoin.amos.fas.business.action.result.AbstractActionResult
;
import
com.yeejoin.amos.fas.business.action.result.AbstractActionResult
;
import
com.yeejoin.amos.fas.business.action.result.ActionResult
;
import
com.yeejoin.amos.fas.business.action.result.ActionResult
;
...
@@ -77,7 +78,7 @@ public class SimpleTipAction implements CustomerAction
...
@@ -77,7 +78,7 @@ public class SimpleTipAction implements CustomerAction
String
msgType
=
"message"
;
String
msgType
=
"message"
;
if
(
"mqtt"
.
equals
(
pushType
.
toLowerCase
()))
{
if
(
"mqtt"
.
equals
(
pushType
.
toLowerCase
()))
{
ToipResponse
toipResponse
=
action
.
buildResponse
(
msgType
,
bizobj
,
result
);
ToipResponse
toipResponse
=
action
.
buildResponse
(
msgType
,
bizobj
,
result
);
String
topic
=
String
.
format
(
"/%s/%s/%s"
,
serviceName
,
"yinan"
,
"rule"
);
String
topic
=
String
.
format
(
"/%s/%s/%s"
,
serviceName
,
StationEnum
.
YINAN
.
getCode
()
,
"rule"
);
webMqttComponent
.
publish
(
topic
,
toipResponse
.
toJsonStr
());
webMqttComponent
.
publish
(
topic
,
toipResponse
.
toJsonStr
());
}
else
{
}
else
{
action
.
execute
(
msgType
,
bizobj
);
action
.
execute
(
msgType
,
bizobj
);
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/action/model/ContingencyEvent.java
0 → 100644
View file @
ee8e7742
package
com
.
yeejoin
.
amos
.
fas
.
business
.
action
.
model
;
import
org.springframework.context.ApplicationEvent
;
import
lombok.Data
;
@Data
public
class
ContingencyEvent
extends
ApplicationEvent
{
public
ContingencyEvent
(
Object
source
)
{
super
(
source
);
}
/**
*
*/
private
static
final
long
serialVersionUID
=
-
5239150129698935970L
;
private
String
topic
;
private
String
msgType
;
private
String
msgBody
;
private
Object
contingency
;
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/action/mq/StationEnum.java
0 → 100644
View file @
ee8e7742
package
com
.
yeejoin
.
amos
.
fas
.
business
.
action
.
mq
;
public
enum
StationEnum
{
YINAN
(
"yinan"
,
"沂南站"
);
String
code
;
String
desc
;
private
StationEnum
(
String
code
,
String
desc
)
{
this
.
desc
=
desc
;
this
.
code
=
code
;
}
public
String
getDesc
()
{
return
desc
;
}
public
void
setDesc
(
String
desc
)
{
this
.
desc
=
desc
;
}
public
String
getCode
()
{
return
code
;
}
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/action/util/ContingencyLogPublisher.java
0 → 100644
View file @
ee8e7742
package
com
.
yeejoin
.
amos
.
fas
.
business
.
action
.
util
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.stereotype.Component
;
import
com.yeejoin.amos.fas.business.action.model.ContingencyEvent
;
@Component
public
class
ContingencyLogPublisher
{
@Autowired
//注入ApplicationContext用来发布事件
ApplicationContext
applicationContext
;
//使用ApplicationContext的publishEvent方法来发布
public
void
publish
(
ContingencyEvent
msg
){
applicationContext
.
publishEvent
(
msg
);
}
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/controller/RiskSourceController.java
View file @
ee8e7742
...
@@ -599,7 +599,7 @@ public class RiskSourceController extends BaseController {
...
@@ -599,7 +599,7 @@ public class RiskSourceController extends BaseController {
return
CommonResponseUtil
.
success
(
riskSourceService
.
processFireEqumtData
(
deviceData
));
return
CommonResponseUtil
.
success
(
riskSourceService
.
processFireEqumtData
(
deviceData
));
}
}
@Permission
//
@Permission
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"上传消防设备数据"
,
notes
=
"上传消防设备数据"
)
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"上传消防设备数据"
,
notes
=
"上传消防设备数据"
)
@RequestMapping
(
value
=
"/data/fireqeuiment/soe"
,
produces
=
"application/json;charset=UTF-8"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/data/fireqeuiment/soe"
,
produces
=
"application/json;charset=UTF-8"
,
method
=
RequestMethod
.
POST
)
public
CommonResponse
postFireEqumentData
(
@RequestBody
AlarmParam
alarm
)
throws
Exception
{
public
CommonResponse
postFireEqumentData
(
@RequestBody
AlarmParam
alarm
)
throws
Exception
{
...
@@ -608,7 +608,7 @@ public class RiskSourceController extends BaseController {
...
@@ -608,7 +608,7 @@ public class RiskSourceController extends BaseController {
return
CommonResponseUtil
.
success
();
return
CommonResponseUtil
.
success
();
}
}
@Permission
//
@Permission
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"上传消防设备数据"
,
notes
=
"上传消防设备数据"
)
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"上传消防设备数据"
,
notes
=
"上传消防设备数据"
)
@RequestMapping
(
value
=
"/data/fireqeuiment/all"
,
produces
=
"application/json;charset=UTF-8"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/data/fireqeuiment/all"
,
produces
=
"application/json;charset=UTF-8"
,
method
=
RequestMethod
.
POST
)
public
CommonResponse
postFireEqumentData
(
@RequestBody
List
<
AlarmParam
>
deviceDatas
)
throws
Exception
{
public
CommonResponse
postFireEqumentData
(
@RequestBody
List
<
AlarmParam
>
deviceDatas
)
throws
Exception
{
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/controller/TimeLineController.java
View file @
ee8e7742
...
@@ -4,6 +4,7 @@ package com.yeejoin.amos.fas.business.controller;
...
@@ -4,6 +4,7 @@ package com.yeejoin.amos.fas.business.controller;
import
com.yeejoin.amos.fas.business.service.impl.RiskSourceServiceImpl
;
import
com.yeejoin.amos.fas.business.service.impl.RiskSourceServiceImpl
;
import
com.yeejoin.amos.fas.business.service.intfc.IContingencyInstance
;
import
com.yeejoin.amos.fas.business.service.intfc.IContingencyInstance
;
import
com.yeejoin.amos.fas.business.service.intfc.IContingencyOriginalDataService
;
import
com.yeejoin.amos.fas.business.service.intfc.IContingencyOriginalDataService
;
import
com.yeejoin.amos.fas.business.service.intfc.IRuleRunningSnapshotService
;
import
com.yeejoin.amos.fas.config.Permission
;
import
com.yeejoin.amos.fas.config.Permission
;
import
com.yeejoin.amos.fas.core.common.request.CommonPageable
;
import
com.yeejoin.amos.fas.core.common.request.CommonPageable
;
import
com.yeejoin.amos.fas.core.common.request.CommonRequest
;
import
com.yeejoin.amos.fas.core.common.request.CommonRequest
;
...
@@ -42,6 +43,8 @@ public class TimeLineController extends BaseController{
...
@@ -42,6 +43,8 @@ public class TimeLineController extends BaseController{
@Autowired
@Autowired
private
RedisTemplate
redisTemplate
;
private
RedisTemplate
redisTemplate
;
@Autowired
private
IRuleRunningSnapshotService
ruleRunningSnapshotService
;
@Permission
@Permission
//@Authorization(ingore = true)
//@Authorization(ingore = true)
...
@@ -92,6 +95,15 @@ public class TimeLineController extends BaseController{
...
@@ -92,6 +95,15 @@ public class TimeLineController extends BaseController{
return
CommonResponseUtil
.
success
(
"SUCCESS"
);
return
CommonResponseUtil
.
success
(
"SUCCESS"
);
}
}
@Permission
//@Authorization(ingore = true)
@ApiOperation
(
httpMethod
=
"get"
,
value
=
"预案回放"
,
notes
=
"预案回放"
)
@RequestMapping
(
value
=
"/fire/replay"
,
produces
=
"application/json;charset=UTF-8"
,
method
=
RequestMethod
.
GET
)
public
CommonResponse
replay
(
@RequestParam
(
"batchNo"
)
String
batchNo
,
@RequestParam
(
"randomNumber"
)
String
randomNumber
)
throws
Exception
{
ruleRunningSnapshotService
.
replayPlan
(
batchNo
,
randomNumber
);
return
CommonResponseUtil
.
success
(
"SUCCESS"
);
}
@Scheduled
(
cron
=
"*/2 * * * * ?"
)
@Scheduled
(
cron
=
"*/2 * * * * ?"
)
public
void
runFireQueue
()
throws
Exception
public
void
runFireQueue
()
throws
Exception
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/dao/repository/IRuleRuningSnapshotDao.java
0 → 100644
View file @
ee8e7742
package
com
.
yeejoin
.
amos
.
fas
.
business
.
dao
.
repository
;
import
org.springframework.stereotype.Repository
;
import
com.yeejoin.amos.fas.business.service.model.RuleRuningSnapshot
;
@Repository
public
interface
IRuleRuningSnapshotDao
extends
BaseDao
<
RuleRuningSnapshot
,
String
>{
}
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/impl/ContingencyInstanceImpl.java
View file @
ee8e7742
...
@@ -21,12 +21,16 @@ import org.springframework.util.CollectionUtils;
...
@@ -21,12 +21,16 @@ import org.springframework.util.CollectionUtils;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.web.client.RestTemplate
;
import
org.springframework.web.client.RestTemplate
;
import
com.alibaba.fastjson.JSONObject
;
import
com.yeejoin.amos.component.rule.RuleTrigger
;
import
com.yeejoin.amos.component.rule.RuleTrigger
;
import
com.yeejoin.amos.fas.business.action.ContingencyAction
;
import
com.yeejoin.amos.fas.business.action.ContingencyAction
;
import
com.yeejoin.amos.fas.business.action.model.ContingencyEvent
;
import
com.yeejoin.amos.fas.business.action.model.ContingencyRo
;
import
com.yeejoin.amos.fas.business.action.model.ContingencyRo
;
import
com.yeejoin.amos.fas.business.action.model.SetpEnum
;
import
com.yeejoin.amos.fas.business.action.model.SetpEnum
;
import
com.yeejoin.amos.fas.business.action.mq.StationEnum
;
import
com.yeejoin.amos.fas.business.action.result.BubbleTipResult
;
import
com.yeejoin.amos.fas.business.action.result.BubbleTipResult
;
import
com.yeejoin.amos.fas.business.action.result.SafteyPlanResult
;
import
com.yeejoin.amos.fas.business.action.result.SafteyPlanResult
;
import
com.yeejoin.amos.fas.business.action.util.ContingencyLogPublisher
;
import
com.yeejoin.amos.fas.business.dao.mapper.FireEquipPointMapper
;
import
com.yeejoin.amos.fas.business.dao.mapper.FireEquipPointMapper
;
import
com.yeejoin.amos.fas.business.dao.mapper.ImpAndFireEquipMapper
;
import
com.yeejoin.amos.fas.business.dao.mapper.ImpAndFireEquipMapper
;
import
com.yeejoin.amos.fas.business.dao.repository.IContingencyOriginalDataDao
;
import
com.yeejoin.amos.fas.business.dao.repository.IContingencyOriginalDataDao
;
...
@@ -77,12 +81,18 @@ public class ContingencyInstanceImpl /*extends GenericManagerImpl<ContingencyPla
...
@@ -77,12 +81,18 @@ public class ContingencyInstanceImpl /*extends GenericManagerImpl<ContingencyPla
@Autowired
@Autowired
private
RuleTrigger
ruleTrigger
;
private
RuleTrigger
ruleTrigger
;
@Value
(
"${spring.application.name}"
)
private
String
serviceName
;
/* public ContingencyInstanceImpl(IContingencyPlanInstanceRepository repository) {
/* public ContingencyInstanceImpl(IContingencyPlanInstanceRepository repository) {
super(repository);
super(repository);
this.repository = repository;
this.repository = repository;
}*/
}*/
@Autowired
@Autowired
ContingencyAction
contingencyAction
;
ContingencyAction
contingencyAction
;
@Autowired
private
ContingencyLogPublisher
contingencyLogPublisher
;
/**
/**
* 创建预案执行记录
* 创建预案执行记录
*
*
...
@@ -193,28 +203,31 @@ public class ContingencyInstanceImpl /*extends GenericManagerImpl<ContingencyPla
...
@@ -193,28 +203,31 @@ public class ContingencyInstanceImpl /*extends GenericManagerImpl<ContingencyPla
ruleTrigger
.
publish
(
contingencyRo
,
equipment
.
getReservePlan
(),
ArrayUtils
.
toArray
(
equipment
.
getName
()));
ruleTrigger
.
publish
(
contingencyRo
,
equipment
.
getReservePlan
(),
ArrayUtils
.
toArray
(
equipment
.
getName
()));
publisherPlanLog
(
stepCode
,
buttonCode
,
batchNo
);
// 刷新记录区
// SimpleDateFormat sdf = new SimpleDateFormat("YYYY/MM/DD HH:mm:ss");
// List<ContingencyPlanInstance> list = iContingencyInstance.queryForTimeLine(contingencyRo.getBatchNo(), "MESSAGE");
// SafteyPlanResult result1 = new SafteyPlanResult();
// Map<String, Object> tempmap2 = new HashMap<>();
// ArrayList records = new ArrayList<>();
// if (ObjectUtils.isEmpty(list)) {
// list.forEach(action -> {
// HashMap map = new HashMap();
// map.put("time", sdf.format(action.getCreateDate()));
// map.put("stepName", action.getContent());
// });
// }
// tempmap2.put("content", records);
// result1.add(tempmap2);
// contingencyAction.sendcmd("recordarea", contingencyRo, result1);
}
else
{
}
else
{
throw
new
Exception
(
"数据异常,请联系管理员."
);
throw
new
Exception
(
"数据异常,请联系管理员."
);
}
}
}
}
private
void
publisherPlanLog
(
String
stepCode
,
String
buttonCode
,
String
batchNo
)
{
ContingencyEvent
event
=
new
ContingencyEvent
(
this
);
JSONObject
json
=
new
JSONObject
();
JSONObject
msgContext
=
new
JSONObject
();
JSONObject
content
=
new
JSONObject
();
content
.
put
(
"stepCode"
,
stepCode
);
content
.
put
(
"buttonCode"
,
buttonCode
);
msgContext
.
put
(
"type"
,
"clickEvent"
);
msgContext
.
put
(
"content"
,
content
);
json
.
put
(
"msgType"
,
"message"
);
json
.
put
(
"msgContext"
,
msgContext
);
event
.
setMsgBody
(
json
.
toJSONString
());
String
topic
=
String
.
format
(
"/%s/%s/%s"
,
serviceName
,
StationEnum
.
YINAN
.
getCode
(),
"plan"
);
event
.
setTopic
(
topic
);
event
.
setMsgType
(
"clickEvent"
);
event
.
setContingency
(
batchNo
);
contingencyLogPublisher
.
publish
(
event
);
}
public
void
setButtonExecuted
(
String
batchNo
,
String
contingencyPlanId
,
String
code
,
String
buttonState
)
throws
Exception
{
public
void
setButtonExecuted
(
String
batchNo
,
String
contingencyPlanId
,
String
code
,
String
buttonState
)
throws
Exception
{
ObjectMapper
objectMapper
=
new
ObjectMapper
();
ObjectMapper
objectMapper
=
new
ObjectMapper
();
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/impl/RiskSourceServiceImpl.java
View file @
ee8e7742
...
@@ -55,6 +55,7 @@ import com.yeejoin.amos.fas.business.action.model.FireEquimentDataRo;
...
@@ -55,6 +55,7 @@ import com.yeejoin.amos.fas.business.action.model.FireEquimentDataRo;
import
com.yeejoin.amos.fas.business.action.model.ProtalDataRo
;
import
com.yeejoin.amos.fas.business.action.model.ProtalDataRo
;
import
com.yeejoin.amos.fas.business.action.model.RiskSourceRuleRo
;
import
com.yeejoin.amos.fas.business.action.model.RiskSourceRuleRo
;
import
com.yeejoin.amos.fas.business.action.model.SetpEnum
;
import
com.yeejoin.amos.fas.business.action.model.SetpEnum
;
import
com.yeejoin.amos.fas.business.action.mq.StationEnum
;
import
com.yeejoin.amos.fas.business.action.mq.WebMqttComponent
;
import
com.yeejoin.amos.fas.business.action.mq.WebMqttComponent
;
import
com.yeejoin.amos.fas.business.bo.BindRegionBo
;
import
com.yeejoin.amos.fas.business.bo.BindRegionBo
;
import
com.yeejoin.amos.fas.business.bo.JpushMsgBo
;
import
com.yeejoin.amos.fas.business.bo.JpushMsgBo
;
...
@@ -996,7 +997,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
...
@@ -996,7 +997,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
iDataRefreshService
.
sendRefreshDataWithArea
(
View3dRefreshAreaEum
.
monitor_data
.
getCode
(),
content
);
iDataRefreshService
.
sendRefreshDataWithArea
(
View3dRefreshAreaEum
.
monitor_data
.
getCode
(),
content
);
}
}
}
}
// String topic = String.format("/%s/%s/%s", serviceName,
"yinan"
,"telesignaling");
// String topic = String.format("/%s/%s/%s", serviceName,
StationEnum.YINAN.getCode()
,"telesignaling");
// webMqttComponent.publish(topic, JSON.toJSONString(deviceData));
// webMqttComponent.publish(topic, JSON.toJSONString(deviceData));
List
<
AlarmParam
>
list
=
new
ArrayList
<>();
List
<
AlarmParam
>
list
=
new
ArrayList
<>();
...
@@ -1106,7 +1107,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
...
@@ -1106,7 +1107,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
try
{
try
{
redisTemplate
.
opsForHash
().
put
(
"Analogue"
,
data
.
getPointCode
(),
data
);
redisTemplate
.
opsForHash
().
put
(
"Analogue"
,
data
.
getPointCode
(),
data
);
// remoteWebSocketServer.sendMessage("plan", JSON.toJSONString(data));
// remoteWebSocketServer.sendMessage("plan", JSON.toJSONString(data));
String
topic
=
String
.
format
(
"/%s/%s/%s"
,
serviceName
,
"yinan"
,
"analogue"
);
String
topic
=
String
.
format
(
"/%s/%s/%s"
,
serviceName
,
StationEnum
.
YINAN
.
getCode
()
,
"analogue"
);
webMqttComponent
.
publish
(
topic
,
JSON
.
toJSONString
(
data
));
webMqttComponent
.
publish
(
topic
,
JSON
.
toJSONString
(
data
));
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/impl/RuleRunigSnapshotServiceImpl.java
View file @
ee8e7742
...
@@ -4,21 +4,27 @@ import java.lang.reflect.Method;
...
@@ -4,21 +4,27 @@ import java.lang.reflect.Method;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.UUID
;
import
java.util.UUID
;
import
javax.annotation.Resource
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
import
org.typroject.tyboot.core.foundation.context.SpringContextHelper
;
import
org.typroject.tyboot.core.foundation.context.SpringContextHelper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.yeejoin.amos.fas.business.action.CustomerAction
;
import
com.yeejoin.amos.fas.business.action.CustomerAction
;
import
com.yeejoin.amos.fas.business.action.model.BasicsRo
;
import
com.yeejoin.amos.fas.business.action.model.ContingencyRo
;
import
com.yeejoin.amos.fas.business.action.mq.WebMqttComponent
;
import
com.yeejoin.amos.fas.business.dao.mapper.RuleRuningSnapshotMapper
;
import
com.yeejoin.amos.fas.business.dao.mapper.RuleRuningSnapshotMapper
;
import
com.yeejoin.amos.fas.business.dao.repository.IRuleRuningSnapshotDao
;
import
com.yeejoin.amos.fas.business.service.intfc.IRuleRunningSnapshotService
;
import
com.yeejoin.amos.fas.business.service.intfc.IRuleRunningSnapshotService
;
import
com.yeejoin.amos.fas.business.service.model.RuleRuningSnapshot
;
import
com.yeejoin.amos.fas.business.service.model.RuleRuningSnapshot
;
...
@@ -39,15 +45,24 @@ public class RuleRunigSnapshotServiceImpl
...
@@ -39,15 +45,24 @@ public class RuleRunigSnapshotServiceImpl
{
{
//IRuleRuningSnapshotRepository repository;
//IRuleRuningSnapshotRepository repository;
@Autowired
private
RuleRuningSnapshotMapper
ruleRuningSnapshotMapper
;
private
RuleRuningSnapshotMapper
ruleRuningSnapshotMapper
;
@Resource
IRuleRuningSnapshotDao
ruleRuningSnapshotDao
;
private
static
String
replayBatchNo
=
null
;
private
static
String
replayBatchNo
=
null
;
static
ObjectMapper
objectMapper
;
static
ObjectMapper
objectMapper
;
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
RuleRunigSnapshotServiceImpl
.
class
);
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
RuleRunigSnapshotServiceImpl
.
class
);
@Autowired
private
RedisTemplate
redisTemplate
;
@Autowired
private
WebMqttComponent
webMqttComponent
;
static
{
static
{
objectMapper
=
new
ObjectMapper
();
objectMapper
=
new
ObjectMapper
();
}
}
...
@@ -67,20 +82,20 @@ public class RuleRunigSnapshotServiceImpl
...
@@ -67,20 +82,20 @@ public class RuleRunigSnapshotServiceImpl
* @param paramsAndTypes
* @param paramsAndTypes
* @param matchedObj
* @param matchedObj
*/
*/
public
void
process
(
Object
bean
,
String
methodName
,
String
paramsAndTypes
,
Object
matchedObj
)
public
void
process
(
Object
bean
,
String
methodName
,
String
paramsAndTypes
,
String
batchNo
)
{
{
if
(
bean
instanceof
CustomerAction
)
if
(
bean
instanceof
CustomerAction
)
{
{
Set
set
=
(
Set
)
matchedObj
;
//
Set set = (Set) matchedObj;
BasicsRo
fireEquimentDataRo
=
(
BasicsRo
)
set
.
iterator
().
next
();
//
BasicsRo fireEquimentDataRo = (BasicsRo) set.iterator().next();
RuleRuningSnapshot
ruleRuningSnapshot
=
new
RuleRuningSnapshot
();
RuleRuningSnapshot
ruleRuningSnapshot
=
new
RuleRuningSnapshot
();
ruleRuningSnapshot
.
setId
(
UUID
.
randomUUID
().
toString
());
ruleRuningSnapshot
.
setId
(
UUID
.
randomUUID
().
toString
());
ruleRuningSnapshot
.
setMethodClass
(
bean
.
getClass
().
getName
());
ruleRuningSnapshot
.
setMethodClass
(
bean
.
getClass
().
getName
());
ruleRuningSnapshot
.
setMethodName
(
methodName
);
ruleRuningSnapshot
.
setMethodName
(
methodName
);
ruleRuningSnapshot
.
setMethodParam
(
paramsAndTypes
);
ruleRuningSnapshot
.
setMethodParam
(
paramsAndTypes
);
ruleRuningSnapshot
.
setBatchNo
(
fireEquimentDataRo
.
getBatchNo
()
);
ruleRuningSnapshot
.
setBatchNo
(
batchNo
);
//ruleRuningSnapshot.setPackageId(fireEquimentDataRo.getPackageId());
//ruleRuningSnapshot.setPackageId(fireEquimentDataRo.getPackageId());
//ruleRuningSnapshot.setEquipmentId(String.valueOf(fireEquimentDataRo.getId()));
//ruleRuningSnapshot.setEquipmentId(String.valueOf(fireEquimentDataRo.getId()));
...
@@ -88,14 +103,84 @@ public class RuleRunigSnapshotServiceImpl
...
@@ -88,14 +103,84 @@ public class RuleRunigSnapshotServiceImpl
ruleRuningSnapshot
.
setCreateTime
(
now
);
ruleRuningSnapshot
.
setCreateTime
(
now
);
ruleRuningSnapshot
.
setCreateMillisecond
(
String
.
valueOf
(
now
.
getTime
()));
ruleRuningSnapshot
.
setCreateMillisecond
(
String
.
valueOf
(
now
.
getTime
()));
ruleRuningSnapshot
.
setPreviousInterval
(
0L
);
ruleRuningSnapshot
.
setPreviousInterval
(
0L
);
RuleRuningSnapshot
oldEntity
=
ruleRuningSnapshotMapper
.
querForObject
(
fireEquimentDataRo
.
getBatchNo
()
);
RuleRuningSnapshot
oldEntity
=
ruleRuningSnapshotMapper
.
querForObject
(
batchNo
);
if
(
oldEntity
!=
null
)
if
(
oldEntity
!=
null
)
ruleRuningSnapshot
.
setPreviousInterval
(
now
.
getTime
()
-
Long
.
parseLong
(
oldEntity
.
getCreateMillisecond
()));
ruleRuningSnapshot
.
setPreviousInterval
(
now
.
getTime
()
-
Long
.
parseLong
(
oldEntity
.
getCreateMillisecond
()));
//repository.save(ruleRuningSnapshot);
//repository.save(ruleRuningSnapshot);
ruleRuningSnapshotMapper
.
save
(
ruleRuningSnapshot
);
ruleRuningSnapshotDao
.
save
(
ruleRuningSnapshot
);
}
}
}
@Transactional
public
void
reacordPlan
(
String
topic
,
String
msgType
,
String
msgBody
,
Object
contingency
)
{
String
batchNo
=
null
;
if
(
contingency
instanceof
ContingencyRo
)
{
batchNo
=
((
ContingencyRo
)
contingency
).
getBatchNo
();
}
else
{
batchNo
=
(
String
)
redisTemplate
.
opsForValue
().
get
(
RiskSourceServiceImpl
.
cacheKeyForCanBeRunning
());
}
RuleRuningSnapshot
ruleRuningSnapshot
=
new
RuleRuningSnapshot
();
ruleRuningSnapshot
.
setId
(
UUID
.
randomUUID
().
toString
());
ruleRuningSnapshot
.
setMethodClass
(
"com.yeejoin.amos.fas.business.action.ContingencyAction"
);
ruleRuningSnapshot
.
setPackageId
(
topic
);
ruleRuningSnapshot
.
setMethodName
(
msgType
);
ruleRuningSnapshot
.
setMethodParam
(
msgBody
);
ruleRuningSnapshot
.
setBatchNo
(
batchNo
);
Date
now
=
new
Date
();
ruleRuningSnapshot
.
setCreateTime
(
now
);
ruleRuningSnapshot
.
setCreateMillisecond
(
String
.
valueOf
(
now
.
getTime
()));
ruleRuningSnapshot
.
setPreviousInterval
(
0L
);
RuleRuningSnapshot
oldEntity
=
ruleRuningSnapshotMapper
.
querForObject
(
batchNo
);
if
(
oldEntity
!=
null
)
ruleRuningSnapshot
.
setPreviousInterval
(
now
.
getTime
()
-
Long
.
parseLong
(
oldEntity
.
getCreateMillisecond
()));
ruleRuningSnapshotDao
.
save
(
ruleRuningSnapshot
);
}
@Async
public
void
replayPlan
(
String
batchNo
,
String
randomNumber
)
throws
Exception
{
try
{
List
<
RuleRuningSnapshot
>
oldEntityList
=
ruleRuningSnapshotMapper
.
querForObjectList
(
batchNo
);
if
(!
CollectionUtils
.
isEmpty
(
oldEntityList
))
{
logger
.
info
(
"开始回放:batchNo="
+
batchNo
);
logger
.
info
(
"获取到动作记录个数:"
+
oldEntityList
.
size
());
int
count
=
0
;
for
(
RuleRuningSnapshot
snapshot
:
oldEntityList
)
{
if
(
batchNo
==
null
)
return
;
//延迟
logger
.
info
(
"开始执行第"
+(++
count
)+
"个动作."
);
logger
.
info
(
"方法名:"
+
snapshot
.
getMethodClass
()+
"."
+
snapshot
.
getMethodName
());
logger
.
info
(
"需要延迟"
+
snapshot
.
getPreviousInterval
()+
"毫秒......."
);
Thread
.
sleep
(
snapshot
.
getPreviousInterval
());
try
{
webMqttComponent
.
publish
(
String
.
format
(
"%s/%s/%s"
,
snapshot
.
getPackageId
(),
"replay"
,
randomNumber
)
,
snapshot
.
getMethodParam
());
logger
.
info
(
"第"
+(
count
)+
"个动作执行成功."
);
}
catch
(
Exception
e
)
{
logger
.
info
(
"第"
+(
count
)+
"个动作执行失败."
);
e
.
printStackTrace
();
logger
.
error
(
e
.
getMessage
(),
e
);
}
}
}
}
}
catch
(
Exception
e
)
{
logger
.
info
(
"回放失败."
);
logger
.
error
(
e
.
getMessage
(),
e
);
}
}
@Async
@Async
public
void
replay
(
String
batchNo
)
throws
Exception
public
void
replay
(
String
batchNo
)
throws
Exception
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/intfc/IRuleRunningSnapshotService.java
View file @
ee8e7742
...
@@ -14,5 +14,7 @@ public interface IRuleRunningSnapshotService
...
@@ -14,5 +14,7 @@ public interface IRuleRunningSnapshotService
void
replay
(
String
batchNo
)
throws
Exception
;
void
replay
(
String
batchNo
)
throws
Exception
;
public
void
reacordPlan
(
String
topic
,
String
msgType
,
String
msgBody
,
Object
contingency
);
public
void
replayPlan
(
String
batchNo
,
String
randomNumber
)
throws
Exception
;
}
}
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