Commit 14e73c87 authored by 高建强's avatar 高建强

item:应急处置解决动作执行实时性问题

parent 003b5213
...@@ -52,8 +52,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -52,8 +52,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.support.TransactionSynchronization; import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.typroject.tyboot.core.foundation.context.RequestContext;
...@@ -353,6 +352,7 @@ public class ContingencyAction implements CustomerAction { ...@@ -353,6 +352,7 @@ public class ContingencyAction implements CustomerAction {
* @param paramObj 预案对象 * @param paramObj 预案对象
*/ */
@RuleMethod(methodLabel = "执行记录", project = "换流站消防专项预案") @RuleMethod(methodLabel = "执行记录", project = "换流站消防专项预案")
@Transactional
public void messageRecord(@MethodParam(paramLabel = "消息内容") String content, @MethodParam(paramLabel = "对象") Object paramObj) { public void messageRecord(@MethodParam(paramLabel = "消息内容") String content, @MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj; ContingencyRo contingencyRo = (ContingencyRo) paramObj;
String batchNo = contingencyRo.getBatchNo(); String batchNo = contingencyRo.getBatchNo();
...@@ -372,36 +372,30 @@ public class ContingencyAction implements CustomerAction { ...@@ -372,36 +372,30 @@ public class ContingencyAction implements CustomerAction {
content = instedParams(content, contingencyRo); content = instedParams(content, contingencyRo);
iContingencyInstance.createInstanceRecord(contingencyRo.getBatchNo(), "", "DEFAULT", content, "MESSAGE", ""); iContingencyInstance.createInstanceRecord(contingencyRo.getBatchNo(), "", "DEFAULT", content, "MESSAGE", "");
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() { SafteyPlanResult result = new SafteyPlanResult();
@Override Map<String, Object> tempmap1 = new HashMap<>();
public void afterCommit() { try {
// 事物提交后业务逻辑 SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SafteyPlanResult result = new SafteyPlanResult(); List<ContingencyPlanInstance> list = iContingencyInstance.queryForTimeLine(contingencyRo.getBatchNo(), "MESSAGE");
Map<String, Object> tempmap1 = new HashMap<>(); ArrayList records = new ArrayList<>();
try { if (!ObjectUtils.isEmpty(list)) {
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); list.forEach(action -> {
List<ContingencyPlanInstance> list = iContingencyInstance.queryForTimeLine(contingencyRo.getBatchNo(), "MESSAGE"); HashMap map = new HashMap();
ArrayList records = new ArrayList<>(); map.put("time", sdf1.format(action.getCreateDate().getTime()));
if (!ObjectUtils.isEmpty(list)) { map.put("stepName", action.getContent());
list.forEach(action -> { records.add(map);
HashMap map = new HashMap(); });
map.put("time", sdf1.format(action.getCreateDate().getTime()));
map.put("stepName", action.getContent());
records.add(map);
});
}
tempmap1.put("content", records);
tempmap1.put("status", PlanRecordStatusEnum.OPERATION.getCode());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
result.add(tempmap1);
System.out.println("--------------------messageRecord----------------------" + result);
sendcmd("recordarea", paramObj, result);
sendweb("recordarea", paramObj, result);
} }
}); tempmap1.put("content", records);
tempmap1.put("status", PlanRecordStatusEnum.OPERATION.getCode());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
result.add(tempmap1);
System.out.println("--------------------messageRecord----------------------" + result);
sendcmd("recordarea", paramObj, result);
sendweb("recordarea", paramObj, 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