diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java index 481a1e607d..c0767c1f37 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java @@ -254,11 +254,16 @@ public class TestCaseService { } private void checkCustomNumExist(TestCaseWithBLOBs testCase) { + String id = testCase.getId(); + TestCaseWithBLOBs testCaseWithBLOBs = testCaseMapper.selectByPrimaryKey(id); TestCaseExample example = new TestCaseExample(); - example.createCriteria() - .andCustomNumEqualTo(testCase.getCustomNum()) + TestCaseExample.Criteria criteria = example.createCriteria(); + criteria.andCustomNumEqualTo(testCase.getCustomNum()) .andProjectIdEqualTo(testCase.getProjectId()) .andIdNotEqualTo(testCase.getId()); + if (testCaseWithBLOBs != null && StringUtils.isNotBlank(testCaseWithBLOBs.getRefId())) { + criteria.andRefIdNotEqualTo(testCaseWithBLOBs.getRefId()); + } List list = testCaseMapper.selectByExample(example); if (CollectionUtils.isNotEmpty(list)) { MSException.throwException(Translator.get("custom_num_is_exist"));