diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanFunctionalCaseService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanFunctionalCaseService.java index 06709f537c..0ef648dbcb 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanFunctionalCaseService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanFunctionalCaseService.java @@ -615,23 +615,22 @@ public class TestPlanFunctionalCaseService extends TestPlanResourceService { String historyStepStr = new String(testPlanCaseExecuteHistory.getSteps(), StandardCharsets.UTF_8); if (StringUtils.isNotBlank(historyStepStr)) { List historySteps = JSON.parseArray(historyStepStr, FunctionalCaseStepDTO.class); + Map historyStepMap = historySteps.stream().collect(Collectors.toMap(FunctionalCaseStepDTO::getId, t -> t)); newCaseSteps.forEach(newCaseStep -> { - historySteps.forEach(historyStep -> { - setHistoryInfo(newCaseStep, historyStep); - }); + setHistoryInfo(newCaseStep, historyStepMap); }); } } } - private static void setHistoryInfo(FunctionalCaseStepDTO newCaseStep, FunctionalCaseStepDTO historyStep) { - if (StringUtils.equals(historyStep.getDesc(), newCaseStep.getDesc()) && StringUtils.equals(historyStep.getResult(), newCaseStep.getResult())) { + private static void setHistoryInfo(FunctionalCaseStepDTO newCaseStep, Map historyStepMap) { + FunctionalCaseStepDTO historyStep = historyStepMap.get(newCaseStep.getId()); + if (historyStep != null && StringUtils.equals(historyStep.getDesc(), newCaseStep.getDesc()) && StringUtils.equals(historyStep.getResult(), newCaseStep.getResult())) { newCaseStep.setExecuteResult(historyStep.getExecuteResult()); newCaseStep.setActualResult(historyStep.getActualResult()); } } - public void editFunctionalCase(TestPlanCaseEditRequest request, String userId) { TestPlanFunctionalCase planFunctionalCase = testPlanFunctionalCaseMapper.selectByPrimaryKey(request.getId()); TestPlanFunctionalCase functionalCase = new TestPlanFunctionalCase();