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
4826402d
Commit
4826402d
authored
Sep 10, 2020
by
zhengjiangtao
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev_upgrade_rule' of…
Merge branch 'dev_upgrade_rule' of
http://172.16.10.76/station/YeeAmosFireAutoSysRoot
into dev_upgrade_rule
parents
19d6b508
b90e5484
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
294 additions
and
45 deletions
+294
-45
ContingencyAction.java
...m/yeejoin/amos/fas/business/action/ContingencyAction.java
+43
-4
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
-9
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
+96
-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 @
4826402d
...
...
@@ -31,13 +31,16 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import
com.yeejoin.amos.component.rule.MethodParam
;
import
com.yeejoin.amos.component.rule.RuleActionBean
;
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.DeviceRo
;
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.result.ActionResult
;
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.util.ContingencyLogPublisher
;
import
com.yeejoin.amos.fas.business.action.util.StepComparator
;
import
com.yeejoin.amos.fas.business.feign.IDutyModeServer
;
import
com.yeejoin.amos.fas.business.feign.RemoteSecurityService
;
...
...
@@ -75,7 +78,8 @@ public class ContingencyAction implements CustomerAction {
@Autowired
private
FireStengthService
fireStrengthService
;
@Autowired
private
ContingencyLogPublisher
contingencyLogPublisher
;
// private RestTemplate restTemplate = new RestTemplate();
// @Value("${bussunis.domain}")
...
...
@@ -167,12 +171,20 @@ public class ContingencyAction implements CustomerAction {
AbstractActionResultMessage
<?>
action
=
(
AbstractActionResultMessage
<?>)
constructor
.
newInstance
(
result
);
if
(
"mqtt"
.
equals
(
pushType
.
toLowerCase
()))
{
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
()));
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
())){
action
.
execute
(
msgType
,
contingency
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
...
...
@@ -544,7 +556,6 @@ public class ContingencyAction implements CustomerAction {
log
.
error
(
"======================================================================================="
);
stopSnapshop
(
contingencyRo
);
SafteyPlanResult
result
=
new
SafteyPlanResult
();
Map
<
String
,
Object
>
tempmap1
=
new
HashMap
<>();
...
...
@@ -554,6 +565,27 @@ public class ContingencyAction implements CustomerAction {
this
.
sendcmd
(
"maparea"
,
paramObj
,
result
);
}
@RuleMethod
(
methodLabel
=
"地图动画"
,
project
=
"青海换流站消防预案"
)
public
void
mapCartoonAction
(
@MethodParam
(
paramLabel
=
"动作名称标识"
)
String
actionName
,
@MethodParam
(
paramLabel
=
"动作类型"
)
String
actionType
,
@MethodParam
(
paramLabel
=
"动作类型参数"
)
String
paramJSON
,
@MethodParam
(
paramLabel
=
"对象"
)
Object
paramObj
)
{
ContingencyRo
contingencyRo
=
(
ContingencyRo
)
paramObj
;
log
.
error
(
"======================================================================================="
);
stopSnapshop
(
contingencyRo
);
instedParams
(
paramJSON
,
contingencyRo
);
SafteyPlanResult
result
=
new
SafteyPlanResult
();
Map
<
String
,
Object
>
tempmap1
=
new
HashMap
<>();
tempmap1
.
put
(
"key"
,
actionName
);
tempmap1
.
put
(
"content"
,
actionType
);
tempmap1
.
put
(
"parameter"
,
paramJSON
);
result
.
add
(
tempmap1
);
this
.
sendcmd
(
"maparea"
,
paramObj
,
result
);
}
/**
* 顶部消息提示
...
...
@@ -738,9 +770,16 @@ public class ContingencyAction implements CustomerAction {
AbstractActionResultMessage
<?>
action
=
(
AbstractActionResultMessage
<?>)
constructor
.
newInstance
(
result
);
if
(
"mqtt"
.
equals
(
pushType
.
toLowerCase
()))
{
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
()));
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
())){
action
.
execute
(
msgType
,
deviceRo
);
}
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/action/ContingencyLogListener.java
0 → 100644
View file @
4826402d
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 @
4826402d
...
...
@@ -11,6 +11,7 @@ import org.springframework.stereotype.Component;
import
com.yeejoin.amos.component.rule.MethodParam
;
import
com.yeejoin.amos.component.rule.RuleActionBean
;
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.result.ActionResult
;
import
com.yeejoin.amos.fas.business.action.result.BubbleTipResult
;
...
...
@@ -69,7 +70,7 @@ public class RiskSituationAction implements CustomerAction
String
msgType
=
"bubbleTip"
;
if
(
"mqtt"
.
equals
(
pushType
.
toLowerCase
()))
{
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
());
}
else
{
Object
obj
=
action
.
execute
(
msgType
,
bizobj
);
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/action/SimpleTipAction.java
View file @
4826402d
...
...
@@ -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.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.result.AbstractActionResult
;
import
com.yeejoin.amos.fas.business.action.result.ActionResult
;
...
...
@@ -77,7 +78,7 @@ public class SimpleTipAction implements CustomerAction
String
msgType
=
"message"
;
if
(
"mqtt"
.
equals
(
pushType
.
toLowerCase
()))
{
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
());
}
else
{
action
.
execute
(
msgType
,
bizobj
);
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/action/model/ContingencyEvent.java
0 → 100644
View file @
4826402d
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 @
4826402d
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 @
4826402d
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 @
4826402d
...
...
@@ -599,7 +599,7 @@ public class RiskSourceController extends BaseController {
return
CommonResponseUtil
.
success
(
riskSourceService
.
processFireEqumtData
(
deviceData
));
}
@Permission
//
@Permission
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"上传消防设备数据"
,
notes
=
"上传消防设备数据"
)
@RequestMapping
(
value
=
"/data/fireqeuiment/soe"
,
produces
=
"application/json;charset=UTF-8"
,
method
=
RequestMethod
.
POST
)
public
CommonResponse
postFireEqumentData
(
@RequestBody
AlarmParam
alarm
)
throws
Exception
{
...
...
@@ -608,7 +608,7 @@ public class RiskSourceController extends BaseController {
return
CommonResponseUtil
.
success
();
}
@Permission
//
@Permission
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"上传消防设备数据"
,
notes
=
"上传消防设备数据"
)
@RequestMapping
(
value
=
"/data/fireqeuiment/all"
,
produces
=
"application/json;charset=UTF-8"
,
method
=
RequestMethod
.
POST
)
public
CommonResponse
postFireEqumentData
(
@RequestBody
List
<
AlarmParam
>
deviceDatas
)
throws
Exception
{
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/controller/TimeLineController.java
View file @
4826402d
...
...
@@ -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.intfc.IContingencyInstance
;
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.core.common.request.CommonPageable
;
import
com.yeejoin.amos.fas.core.common.request.CommonRequest
;
...
...
@@ -42,6 +43,8 @@ public class TimeLineController extends BaseController{
@Autowired
private
RedisTemplate
redisTemplate
;
@Autowired
private
IRuleRunningSnapshotService
ruleRunningSnapshotService
;
@Permission
//@Authorization(ingore = true)
...
...
@@ -92,6 +95,15 @@ public class TimeLineController extends BaseController{
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 * * * * ?"
)
public
void
runFireQueue
()
throws
Exception
...
...
@@ -165,15 +177,6 @@ public class TimeLineController extends BaseController{
}
String
operate
=
"{"
+
" \"type\": \"button\","
+
" \"operate\": ["
+
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/dao/repository/IRuleRuningSnapshotDao.java
0 → 100644
View file @
4826402d
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 @
4826402d
...
...
@@ -21,12 +21,16 @@ import org.springframework.util.CollectionUtils;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.web.client.RestTemplate
;
import
com.alibaba.fastjson.JSONObject
;
import
com.yeejoin.amos.component.rule.RuleTrigger
;
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.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.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.ImpAndFireEquipMapper
;
import
com.yeejoin.amos.fas.business.dao.repository.IContingencyOriginalDataDao
;
...
...
@@ -77,12 +81,18 @@ public class ContingencyInstanceImpl /*extends GenericManagerImpl<ContingencyPla
@Autowired
private
RuleTrigger
ruleTrigger
;
@Value
(
"${spring.application.name}"
)
private
String
serviceName
;
/* public ContingencyInstanceImpl(IContingencyPlanInstanceRepository repository) {
super(repository);
this.repository = repository;
}*/
@Autowired
ContingencyAction
contingencyAction
;
@Autowired
private
ContingencyLogPublisher
contingencyLogPublisher
;
/**
* 创建预案执行记录
*
...
...
@@ -193,28 +203,31 @@ public class ContingencyInstanceImpl /*extends GenericManagerImpl<ContingencyPla
ruleTrigger
.
publish
(
contingencyRo
,
equipment
.
getReservePlan
(),
ArrayUtils
.
toArray
(
equipment
.
getName
()));
// 刷新记录区
// 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);
publisherPlanLog
(
stepCode
,
buttonCode
,
batchNo
);
}
else
{
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
{
ObjectMapper
objectMapper
=
new
ObjectMapper
();
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/impl/RiskSourceServiceImpl.java
View file @
4826402d
...
...
@@ -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.RiskSourceRuleRo
;
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.bo.BindRegionBo
;
import
com.yeejoin.amos.fas.business.bo.JpushMsgBo
;
...
...
@@ -996,7 +997,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
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));
List
<
AlarmParam
>
list
=
new
ArrayList
<>();
...
...
@@ -1106,7 +1107,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
try
{
redisTemplate
.
opsForHash
().
put
(
"Analogue"
,
data
.
getPointCode
(),
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
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/impl/RuleRunigSnapshotServiceImpl.java
View file @
4826402d
...
...
@@ -4,21 +4,27 @@ import java.lang.reflect.Method;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.UUID
;
import
javax.annotation.Resource
;
import
org.slf4j.Logger
;
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.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.StringUtils
;
import
org.typroject.tyboot.core.foundation.context.SpringContextHelper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
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.repository.IRuleRuningSnapshotDao
;
import
com.yeejoin.amos.fas.business.service.intfc.IRuleRunningSnapshotService
;
import
com.yeejoin.amos.fas.business.service.model.RuleRuningSnapshot
;
...
...
@@ -39,15 +45,24 @@ public class RuleRunigSnapshotServiceImpl
{
//IRuleRuningSnapshotRepository repository;
@Autowired
private
RuleRuningSnapshotMapper
ruleRuningSnapshotMapper
;
@Resource
IRuleRuningSnapshotDao
ruleRuningSnapshotDao
;
private
static
String
replayBatchNo
=
null
;
static
ObjectMapper
objectMapper
;
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
RuleRunigSnapshotServiceImpl
.
class
);
@Autowired
private
RedisTemplate
redisTemplate
;
@Autowired
private
WebMqttComponent
webMqttComponent
;
static
{
objectMapper
=
new
ObjectMapper
();
}
...
...
@@ -67,20 +82,20 @@ public class RuleRunigSnapshotServiceImpl
* @param paramsAndTypes
* @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
)
{
Set
set
=
(
Set
)
matchedObj
;
BasicsRo
fireEquimentDataRo
=
(
BasicsRo
)
set
.
iterator
().
next
();
//
Set set = (Set) matchedObj;
//
BasicsRo fireEquimentDataRo = (BasicsRo) set.iterator().next();
RuleRuningSnapshot
ruleRuningSnapshot
=
new
RuleRuningSnapshot
();
ruleRuningSnapshot
.
setId
(
UUID
.
randomUUID
().
toString
());
ruleRuningSnapshot
.
setMethodClass
(
bean
.
getClass
().
getName
());
ruleRuningSnapshot
.
setMethodName
(
methodName
);
ruleRuningSnapshot
.
setMethodParam
(
paramsAndTypes
);
ruleRuningSnapshot
.
setBatchNo
(
fireEquimentDataRo
.
getBatchNo
()
);
ruleRuningSnapshot
.
setBatchNo
(
batchNo
);
//ruleRuningSnapshot.setPackageId(fireEquimentDataRo.getPackageId());
//ruleRuningSnapshot.setEquipmentId(String.valueOf(fireEquimentDataRo.getId()));
...
...
@@ -88,14 +103,86 @@ public class RuleRunigSnapshotServiceImpl
ruleRuningSnapshot
.
setCreateTime
(
now
);
ruleRuningSnapshot
.
setCreateMillisecond
(
String
.
valueOf
(
now
.
getTime
()));
ruleRuningSnapshot
.
setPreviousInterval
(
0L
);
RuleRuningSnapshot
oldEntity
=
ruleRuningSnapshotMapper
.
querForObject
(
fireEquimentDataRo
.
getBatchNo
()
);
RuleRuningSnapshot
oldEntity
=
ruleRuningSnapshotMapper
.
querForObject
(
batchNo
);
if
(
oldEntity
!=
null
)
ruleRuningSnapshot
.
setPreviousInterval
(
now
.
getTime
()
-
Long
.
parseLong
(
oldEntity
.
getCreateMillisecond
()));
//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
if
(
contingency
instanceof
String
)
{
batchNo
=
contingency
.
toString
();
}
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
public
void
replay
(
String
batchNo
)
throws
Exception
...
...
YeeAmosFireAutoSysService/src/main/java/com/yeejoin/amos/fas/business/service/intfc/IRuleRunningSnapshotService.java
View file @
4826402d
...
...
@@ -14,5 +14,7 @@ public interface IRuleRunningSnapshotService
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