Commit 4826402d authored by zhengjiangtao's avatar zhengjiangtao

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
......@@ -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();
}
......@@ -532,7 +544,7 @@ public class ContingencyAction implements CustomerAction {
/**
* 地图动作推送
* 地图动作推送
*
* @param actionName 动作名称标识
* @param paramObj 预案对象
......@@ -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);
}
......
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());
}
}
......@@ -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);
......
......@@ -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);
......
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;
}
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;
}
}
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);
}
}
......@@ -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 {
......
......@@ -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,7 +43,9 @@ public class TimeLineController extends BaseController{
@Autowired
private RedisTemplate redisTemplate;
@Autowired
private IRuleRunningSnapshotService ruleRunningSnapshotService;
@Permission
//@Authorization(ingore = true)
@ApiOperation(httpMethod = "GET",value = "根据批次号查询时间轴", notes = "根据批次号查询时间轴")
......@@ -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\": [" +
......
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>{
}
......@@ -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;
......@@ -76,6 +80,9 @@ public class ContingencyInstanceImpl /*extends GenericManagerImpl<ContingencyPla
@Autowired
private RuleTrigger ruleTrigger;
@Value("${spring.application.name}")
private String serviceName;
/* public ContingencyInstanceImpl(IContingencyPlanInstanceRepository repository) {
super(repository);
......@@ -83,6 +90,9 @@ public class ContingencyInstanceImpl /*extends GenericManagerImpl<ContingencyPla
}*/
@Autowired
ContingencyAction contingencyAction;
@Autowired
private ContingencyLogPublisher contingencyLogPublisher;
/**
* 创建预案执行记录
*
......@@ -193,27 +203,30 @@ 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 {
......@@ -237,7 +250,7 @@ public class ContingencyInstanceImpl /*extends GenericManagerImpl<ContingencyPla
}
throw new Exception("请勿重复操作.");
}
if ("CONFIRM".equals(buttonState)) {
if (code.equals(operate.getCode())) {
......
......@@ -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();
......
......@@ -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,15 +103,87 @@ 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
{
......
......@@ -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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment