Commit 8e11b9c9 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 4826402d ca37a2ae
...@@ -575,14 +575,14 @@ public class ContingencyAction implements CustomerAction { ...@@ -575,14 +575,14 @@ public class ContingencyAction implements CustomerAction {
log.error("======================================================================================="); log.error("=======================================================================================");
stopSnapshop(contingencyRo); stopSnapshop(contingencyRo);
instedParams(paramJSON, contingencyRo); String parameter = instedParams(paramJSON, contingencyRo);
SafteyPlanResult result = new SafteyPlanResult(); SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>(); Map<String, Object> tempmap1 = new HashMap<>();
tempmap1.put("key", actionName); tempmap1.put("key", actionName);
tempmap1.put("content",actionType); tempmap1.put("content",actionType);
tempmap1.put("parameter",paramJSON); tempmap1.put("parameter",parameter);
result.add(tempmap1); result.add(tempmap1);
this.sendcmd("maparea", paramObj, result); this.sendcmd("maparea", paramObj, result);
} }
......
...@@ -96,7 +96,6 @@ public class TimeLineController extends BaseController{ ...@@ -96,7 +96,6 @@ public class TimeLineController extends BaseController{
} }
@Permission @Permission
//@Authorization(ingore = true)
@ApiOperation(httpMethod = "get",value = "预案回放", notes = "预案回放") @ApiOperation(httpMethod = "get",value = "预案回放", notes = "预案回放")
@RequestMapping(value = "/fire/replay", produces = "application/json;charset=UTF-8", method = RequestMethod.GET) @RequestMapping(value = "/fire/replay", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse replay(@RequestParam("batchNo") String batchNo, public CommonResponse replay(@RequestParam("batchNo") String batchNo,
...@@ -104,6 +103,15 @@ public class TimeLineController extends BaseController{ ...@@ -104,6 +103,15 @@ public class TimeLineController extends BaseController{
ruleRunningSnapshotService.replayPlan(batchNo, randomNumber); ruleRunningSnapshotService.replayPlan(batchNo, randomNumber);
return CommonResponseUtil.success("SUCCESS"); return CommonResponseUtil.success("SUCCESS");
} }
@Permission
@ApiOperation(httpMethod = "get",value = "预案回放退出", notes = "预案回放退出")
@RequestMapping(value = "/fire/replay/exit", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse replayExit(@RequestParam("batchNo") String batchNo,
@RequestParam("randomNumber") String randomNumber) throws Exception{
ruleRunningSnapshotService.exitReplayPlan(batchNo, randomNumber);
return CommonResponseUtil.success("SUCCESS");
}
@Scheduled(cron = "*/2 * * * * ?") @Scheduled(cron = "*/2 * * * * ?")
public void runFireQueue() throws Exception public void runFireQueue() throws Exception
......
package com.yeejoin.amos.fas.business.service.impl; package com.yeejoin.amos.fas.business.service.impl;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
...@@ -16,6 +18,7 @@ import org.springframework.scheduling.annotation.Async; ...@@ -16,6 +18,7 @@ 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.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
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;
...@@ -23,10 +26,14 @@ import com.fasterxml.jackson.databind.ObjectMapper; ...@@ -23,10 +26,14 @@ 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.ContingencyRo; import com.yeejoin.amos.fas.business.action.model.ContingencyRo;
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.SafteyPlanResult;
import com.yeejoin.amos.fas.business.action.result.message.AbstractActionResultMessage;
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.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;
import com.yeejoin.amos.fas.business.service.model.ToipResponse;
/** /**
* *
...@@ -63,6 +70,8 @@ public class RuleRunigSnapshotServiceImpl ...@@ -63,6 +70,8 @@ public class RuleRunigSnapshotServiceImpl
@Autowired @Autowired
private WebMqttComponent webMqttComponent; private WebMqttComponent webMqttComponent;
private static String PACKAGEURL = "com.yeejoin.amos.fas.business.action.result.message.";
static { static {
objectMapper = new ObjectMapper(); objectMapper = new ObjectMapper();
} }
...@@ -151,13 +160,30 @@ public class RuleRunigSnapshotServiceImpl ...@@ -151,13 +160,30 @@ public class RuleRunigSnapshotServiceImpl
{ {
logger.info("开始回放:batchNo="+batchNo); logger.info("开始回放:batchNo="+batchNo);
logger.info("获取到动作记录个数:"+oldEntityList.size()); logger.info("获取到动作记录个数:"+oldEntityList.size());
redisTemplate.opsForValue().set("replay:" + batchNo +":" + randomNumber, true);
int count = 0; int count = 0;
for(RuleRuningSnapshot snapshot : oldEntityList) for(RuleRuningSnapshot snapshot : oldEntityList)
{ {
if(batchNo == null) if(batchNo == null)
return ; return ;
Object play = redisTemplate.opsForValue().get("replay:" + batchNo +":" + randomNumber);
if (ObjectUtils.isEmpty(play)) {
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
tempmap1.put("type", "event");
tempmap1.put("content", "stopPlan");
result.add(tempmap1);
Constructor<?> constructor = Class.forName(
PACKAGEURL + result.getClass().getSimpleName() + "Message")
.getConstructor(ActionResult.class);
AbstractActionResultMessage<?> action = (AbstractActionResultMessage<?>) constructor.newInstance(result);
ToipResponse toipResponse = action.buildResponse("message", batchNo, result.toJson());
webMqttComponent.publish(String.format("%s/%s/%s", snapshot.getPackageId(), "replay", randomNumber), toipResponse.toJsonStr());
return;
}
//延迟 //延迟
logger.info("开始执行第"+(++count)+"个动作."); logger.info("开始执行第"+(++count)+"个动作.");
logger.info("方法名:"+snapshot.getMethodClass()+"."+snapshot.getMethodName()); logger.info("方法名:"+snapshot.getMethodClass()+"."+snapshot.getMethodName());
...@@ -181,9 +207,16 @@ public class RuleRunigSnapshotServiceImpl ...@@ -181,9 +207,16 @@ public class RuleRunigSnapshotServiceImpl
{ {
logger.info("回放失败."); logger.info("回放失败.");
logger.error(e.getMessage(),e); logger.error(e.getMessage(),e);
} finally {
redisTemplate.delete("replay:" + batchNo +":" + randomNumber);
} }
} }
@Override
public void exitReplayPlan(String batchNo, String randomNumber) {
redisTemplate.delete("replay:" + batchNo +":" + randomNumber);
}
@Async @Async
public void replay(String batchNo) throws Exception public void replay(String batchNo) throws Exception
{ {
...@@ -281,4 +314,6 @@ public class RuleRunigSnapshotServiceImpl ...@@ -281,4 +314,6 @@ public class RuleRunigSnapshotServiceImpl
public static void setReplayBatchNoToNull() { public static void setReplayBatchNoToNull() {
RuleRunigSnapshotServiceImpl.replayBatchNo = null; RuleRunigSnapshotServiceImpl.replayBatchNo = null;
} }
} }
\ No newline at end of file
...@@ -17,4 +17,6 @@ public interface IRuleRunningSnapshotService ...@@ -17,4 +17,6 @@ public interface IRuleRunningSnapshotService
public void reacordPlan(String topic, String msgType, String msgBody, Object contingency); public void reacordPlan(String topic, String msgType, String msgBody, Object contingency);
public void replayPlan(String batchNo, String randomNumber) throws Exception; public void replayPlan(String batchNo, String randomNumber) throws Exception;
void exitReplayPlan(String batchNo, String randomNumber);
} }
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