mirror of
https://github.com/slhaf/Partner.git
synced 2026-05-12 08:43:02 +08:00
refactor(ActionExecutor): update type of history field in ActionData
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
package work.slhaf.partner.core.action.entity;
|
package work.slhaf.partner.core.action.entity;
|
||||||
|
|
||||||
import cn.hutool.json.JSONObject;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import work.slhaf.partner.module.modules.action.dispatcher.executor.entity.HistoryAction;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ public abstract class ActionData {
|
|||||||
* 行动结果
|
* 行动结果
|
||||||
*/
|
*/
|
||||||
protected String result;
|
protected String result;
|
||||||
protected List<JSONObject> history = new ArrayList<>();
|
protected Map<Integer, List<HistoryAction>> history = new HashMap<>();
|
||||||
/**
|
/**
|
||||||
* 修复上下文
|
* 修复上下文
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -112,6 +112,7 @@ public class ActionExecutor extends AgentRunningSubModule<ActionExecutorInput, V
|
|||||||
|
|
||||||
private Runnable buildMataActionTask(MetaAction metaAction, PhaserRecord phaserRecord, String userId) {
|
private Runnable buildMataActionTask(MetaAction metaAction, PhaserRecord phaserRecord, String userId) {
|
||||||
return () -> {
|
return () -> {
|
||||||
|
val actionKey = metaAction.getKey();
|
||||||
try {
|
try {
|
||||||
val result = metaAction.getResult();
|
val result = metaAction.getResult();
|
||||||
do {
|
do {
|
||||||
@@ -124,6 +125,13 @@ public class ActionExecutor extends AgentRunningSubModule<ActionExecutorInput, V
|
|||||||
if (extractorResult.isOk()) {
|
if (extractorResult.isOk()) {
|
||||||
metaAction.setParams(extractorResult.getParams());
|
metaAction.setParams(extractorResult.getParams());
|
||||||
runnerClient.submit(metaAction);
|
runnerClient.submit(metaAction);
|
||||||
|
val historyAction = new HistoryAction();
|
||||||
|
historyAction.setActionKey(actionKey);
|
||||||
|
historyAction.setDescription(actionCapability.loadMetaActionInfo(actionKey).getDescription());
|
||||||
|
historyAction.setResult(metaAction.getResult().getData());
|
||||||
|
actionData.getHistory()
|
||||||
|
.computeIfAbsent(actionData.getExecutingStage(), integer -> new ArrayList<>())
|
||||||
|
.add(historyAction);
|
||||||
} else {
|
} else {
|
||||||
val repairerInput = assemblyHelper.buildRepairerInput(historyActionResults, metaAction, userId);
|
val repairerInput = assemblyHelper.buildRepairerInput(historyActionResults, metaAction, userId);
|
||||||
val repairerResult = actionRepairer.execute(repairerInput);
|
val repairerResult = actionRepairer.execute(repairerInput);
|
||||||
@@ -150,7 +158,7 @@ public class ActionExecutor extends AgentRunningSubModule<ActionExecutorInput, V
|
|||||||
// 内部的行动池已经足以承担这个功能,但这也就意味着行动池或许需要考虑特殊的序列化形式避免内存占用过高,
|
// 内部的行动池已经足以承担这个功能,但这也就意味着行动池或许需要考虑特殊的序列化形式避免内存占用过高,
|
||||||
// 同时也需要在某些模块执行时加上行动结果的挑取作为输入内容
|
// 同时也需要在某些模块执行时加上行动结果的挑取作为输入内容
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Action executing failed: {}", metaAction.getKey(), e);
|
log.error("Action executing failed: {}", actionKey, e);
|
||||||
} finally {
|
} finally {
|
||||||
phaserRecord.phaser().arriveAndDeregister();
|
phaserRecord.phaser().arriveAndDeregister();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user