Commit 3234ff09 authored by KeYong's avatar KeYong

更新

parent 6a489e5e
package com.yeejoin.amos.fas.business.event;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.yeejoin.amos.fas.business.action.ContingencyAction;
import com.yeejoin.amos.fas.business.action.model.ContingencyRo;
import com.yeejoin.amos.fas.business.action.mq.WebMqttComponent;
......@@ -19,6 +20,8 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionSynchronization;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import org.springframework.util.CollectionUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext;
......@@ -80,6 +83,7 @@ public class BizContingencyHandler implements EventHandler{
ContingencyAction contingencyAction;
@Override
@Transactional
public void handler(ContingecyExecEvent event) throws Exception {
/**
......@@ -117,7 +121,6 @@ public class BizContingencyHandler implements EventHandler{
event.getPlanExecute().getButtonCode(),
event.getPlanExecute().getConfirm(),
RequestContext.getLoginId());
} catch (Exception e) {
throw e;
} finally {
......@@ -201,6 +204,25 @@ public class BizContingencyHandler implements EventHandler{
}
}
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
String planStep = "";
if (redisTemplate.hasKey("planStep")) {
planStep = Objects.requireNonNull(redisTemplate.opsForValue().get("planStep")).toString();
} else {
planStep = planStepService.getPlanStep();
}
JSONArray objects = JSON.parseArray(planStep);
String topic = String.format("/%s/%s/%s", serviceName, stationName, "plan");
Map<String, Object> result = new HashMap<>();
result.put("contingency", new ContingencyRo());
result.put("msgContext", Collections.EMPTY_MAP);
result.put("msgType", "getStepList");
result.put("planStep", objects);
webMqttComponent.publish(topic, JSON.toJSONString(result));
}
});
}
......
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