fix:执行计划

1.执行记录详情的组装逻辑修改,将产品部分的改动修改到当前分支
master
李杰应 2024-11-08 18:20:41 +08:00
parent e5d1e6e68b
commit 09798b8d51
1 changed files with 55 additions and 10 deletions

View File

@ -911,6 +911,24 @@ public class AtuPlanTaskApiServiceImpl extends AbstractExcelService<AtuPlanTask>
TaskCaseStepDetailDto detailDto) {
// 获取脚本执行结果信息
Map<String, StepExecuteResult> stepResultMap = new HashMap<>();
JSONArray commands = scriptJson.getJSONArray(MsgConstant.COMMANDS);
Map<String, String> groupMap = new HashMap<>();
for (Object command : commands) {
cn.hutool.json.JSONObject commandJson = JSONUtil.parseObj(command);
String commandName = commandJson.getStr(MsgConstant.COMMAND);
if ("group".equalsIgnoreCase(commandName)) {
String groupStepId = commandJson.getStr(MsgConstant.ID);
Object children = commandJson.get(MsgConstant.CHILDREN);
cn.hutool.json.JSONArray childrenArray = JSONUtil.parseArray(children);
for (Object child : childrenArray) {
cn.hutool.json.JSONObject childJson = JSONUtil.parseObj(child);
String childId = childJson.getStr(MsgConstant.ID);
groupMap.put(childId, groupStepId);
}
}
}
String stepId = "";
if (StrUtil.isNotEmpty(execResultFile)) {
// 读取结果文件信息
@ -928,7 +946,8 @@ public class AtuPlanTaskApiServiceImpl extends AbstractExcelService<AtuPlanTask>
continue;
}
StepExecuteResult stepExecuteResult = JSONUtil.toBean(line, StepExecuteResult.class);
processStepResult(stepExecuteResult, stepResultMap, "");
String groupId = groupMap.get(stepExecuteResult.getStepId());
processStepResult(stepExecuteResult, stepResultMap, groupId);
if (stepExecuteResult.getStepId() != null && stepExecuteResult.getStepId().startsWith("3e9da7b7c")) { // 用于只输出对应异常数据的详情,可以删除判断,每一个查询进行输出,日志增多而已
stepId = stepExecuteResult.getStepId();
stepResultMap.forEach((key, value) -> {
@ -948,7 +967,7 @@ public class AtuPlanTaskApiServiceImpl extends AbstractExcelService<AtuPlanTask>
}
}
JSONArray commands = JSONUtil.parseArray(scriptJson.get(MsgConstant.COMMANDS));
commands.forEach(one -> checkGroup(stepResultMap, one));
List<TaskCaseStepDetailDto> resultList = processStepData(commands, stepResultMap, scriptJson, detailDto, 0, false, false, "");
if (StringUtils.isNotBlank(stepId)) {
for (TaskCaseStepDetailDto dto : resultList) { // 用于只输出对应异常数据的详情,可以删除判断,每一个查询进行输出,日志增多而已
@ -958,6 +977,30 @@ public class AtuPlanTaskApiServiceImpl extends AbstractExcelService<AtuPlanTask>
return resultList;
}
private void checkGroup(Map<String, StepExecuteResult> stepResultMap, Object command) {
cn.hutool.json.JSONObject commandJson = JSONUtil.parseObj(command);
String commandStr = commandJson.getStr(MsgConstant.COMMAND);
String groupStepId = commandJson.getStr(MsgConstant.ID);
if ("group".equalsIgnoreCase(commandStr)) {
Object children = commandJson.get(MsgConstant.CHILDREN);
if (null != children) {
cn.hutool.json.JSONArray childrenArray = JSONUtil.parseArray(children);
childrenArray.forEach(child -> {
cn.hutool.json.JSONObject childJson = JSONUtil.parseObj(child);
String childId = childJson.getStr(MsgConstant.ID);
StepExecuteResult stepExecuteResult = stepResultMap.get(String.format("%s.%s", groupStepId, childId));
if (null != stepExecuteResult && stepExecuteResult.isExecuted()) {
StepExecuteResult groupResult = new StepExecuteResult();
groupResult.setExecuted(true);
groupResult.setStepId(groupStepId);
stepResultMap.put(groupStepId, groupResult);
}
});
}
}
}
/**
*
*
@ -1092,14 +1135,16 @@ public class AtuPlanTaskApiServiceImpl extends AbstractExcelService<AtuPlanTask>
stepDetailDto.setExecResult(childSuccess);
stepDetailDto.setExecuted(childExecuted);
// 处理子步骤
if (PlanConstant.GROUP_COMMAND.equals(commandStr)) {
// 分区步骤结果特殊处理分区下的步骤执行结果不在分区步骤的childResult中
stepDetailDto.setStepList(processStepData(commandJson.getJSONArray(MsgConstant.CHILDREN), stepResultMap,
scriptJson, stepDetailDto, num, childSuccess, childExecuted, ""));
} else {
stepDetailDto.setStepList(processStepData(commandJson.getJSONArray(MsgConstant.CHILDREN), stepResultMap,
scriptJson, stepDetailDto, num, childSuccess, childExecuted, stepId));
}
// if (PlanConstant.GROUP_COMMAND.equals(commandStr)) {
// // 分区步骤结果特殊处理分区下的步骤执行结果不在分区步骤的childResult中
// stepDetailDto.setStepList(processStepData(commandJson.getJSONArray(MsgConstant.CHILDREN), stepResultMap,
// scriptJson, stepDetailDto, num, childSuccess, childExecuted, ""));
// } else {
// stepDetailDto.setStepList(processStepData(commandJson.getJSONArray(MsgConstant.CHILDREN), stepResultMap,
// scriptJson, stepDetailDto, num, childSuccess, childExecuted, stepId));
// }
stepDetailDto.setStepList(processStepData(commandJson.getJSONArray(MsgConstant.CHILDREN), stepResultMap,
scriptJson, stepDetailDto, num, childSuccess, childExecuted, stepId));
// 判断是否内部组件
if (ObjectUtil.equal(PlanConstant.INTERNAL_COMPONENT_LIB, componentLib)) {
if (ObjectUtil.equal(PlanConstant.INTERFACE_STEP_TYPE, stepType) ||