diff --git a/docker-compose.yml b/docker-compose.yml
index 3d4558a4..610c3858 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -1,7 +1,7 @@
version: '3'
services:
sonic-server-eureka:
- image: "sonicorg/sonic-server-eureka:v1.3.1-release"
+ image: "sonicorg/sonic-server-eureka:v1.3.2-beta"
hostname: sonic-server-eureka
environment:
- EUREKA_HOST=sonic-server-eureka
@@ -12,7 +12,7 @@ services:
ports:
- "9090:9090"
sonic-server-bus:
- image: "sonicorg/sonic-server-bus:v1.3.1-release"
+ image: "sonicorg/sonic-server-bus:v1.3.2-beta"
environment:
- PROFILE=prod
- EUREKA_URL=http://sonic:sonic@sonic-server-eureka:9090/eureka/
@@ -24,7 +24,7 @@ services:
depends_on:
- sonic-server-eureka
sonic-server-gateway:
- image: "sonicorg/sonic-server-gateway:v1.3.1-release"
+ image: "sonicorg/sonic-server-gateway:v1.3.2-beta"
environment:
- PROFILE=prod
- EUREKA_URL=http://sonic:sonic@sonic-server-eureka:9090/eureka/
@@ -38,7 +38,7 @@ services:
ports:
- "8094:8094"
sonic-server-controller:
- image: "sonicorg/sonic-server-controller:v1.3.1-release"
+ image: "sonicorg/sonic-server-controller:v1.3.2-beta"
environment:
- PROFILE=prod
- EUREKA_URL=http://sonic:sonic@sonic-server-eureka:9090/eureka/
@@ -51,7 +51,7 @@ services:
- sonic-server-eureka
- sonic-server-gateway
sonic-server-folder:
- image: "sonicorg/sonic-server-folder:v1.3.1-release"
+ image: "sonicorg/sonic-server-folder:v1.3.2-beta"
environment:
- PROFILE=prod
- EUREKA_URL=http://sonic:sonic@sonic-server-eureka:9090/eureka/
@@ -68,7 +68,7 @@ services:
- sonic-server-eureka
- sonic-server-gateway
sonic-server-task:
- image: "sonicorg/sonic-server-task:v1.3.1-release"
+ image: "sonicorg/sonic-server-task:v1.3.2-beta"
environment:
- PROFILE=prod
- EUREKA_URL=http://sonic:sonic@sonic-server-eureka:9090/eureka/
@@ -81,7 +81,7 @@ services:
- sonic-server-eureka
- sonic-server-gateway
sonic-server-transport:
- image: "sonicorg/sonic-server-transport:v1.3.1-release"
+ image: "sonicorg/sonic-server-transport:v1.3.2-beta"
environment:
- PROFILE=prod
- EUREKA_URL=http://sonic:sonic@sonic-server-eureka:9090/eureka/
diff --git a/docker-swarm.yml b/docker-swarm.yml
index d936f5fe..fb3db31b 100644
--- a/docker-swarm.yml
+++ b/docker-swarm.yml
@@ -1,7 +1,7 @@
version: '3'
services:
sonic-server-eureka:
- image: "sonicorg/sonic-server-eureka:v1.3.1-release"
+ image: "sonicorg/sonic-server-eureka:v1.3.2-beta"
hostname: sonic-server-eureka
environment:
- EUREKA_HOST=sonic-server-eureka # You should checkout sonic-server-eureka env to support more.
@@ -24,7 +24,7 @@ services:
delay: 20s
max_attempts: 6
sonic-server-bus:
- image: "sonicorg/sonic-server-bus:v1.3.1-release"
+ image: "sonicorg/sonic-server-bus:v1.3.2-beta"
environment:
- PROFILE=prod
- EUREKA_URL=http://sonic:sonic@sonic-server-eureka:9090/eureka/
@@ -48,7 +48,7 @@ services:
delay: 20s
max_attempts: 6
sonic-server-gateway:
- image: "sonicorg/sonic-server-gateway:v1.3.1-release"
+ image: "sonicorg/sonic-server-gateway:v1.3.2-beta"
environment:
- PROFILE=prod
- EUREKA_URL=http://sonic:sonic@sonic-server-eureka:9090/eureka/
@@ -74,7 +74,7 @@ services:
delay: 20s
max_attempts: 6
sonic-server-controller:
- image: "sonicorg/sonic-server-controller:v1.3.1-release"
+ image: "sonicorg/sonic-server-controller:v1.3.2-beta"
environment:
- PROFILE=prod
- EUREKA_URL=http://sonic:sonic@sonic-server-eureka:9090/eureka/
@@ -99,7 +99,7 @@ services:
delay: 20s
max_attempts: 6
sonic-server-folder:
- image: "sonicorg/sonic-server-folder:v1.3.1-release"
+ image: "sonicorg/sonic-server-folder:v1.3.2-beta"
environment:
- PROFILE=prod
- EUREKA_URL=http://sonic:sonic@sonic-server-eureka:9090/eureka/
@@ -128,7 +128,7 @@ services:
delay: 20s
max_attempts: 6
sonic-server-task:
- image: "sonicorg/sonic-server-task:v1.3.1-release"
+ image: "sonicorg/sonic-server-task:v1.3.2-beta"
environment:
- PROFILE=prod
- EUREKA_URL=http://sonic:sonic@sonic-server-eureka:9090/eureka/
@@ -153,7 +153,7 @@ services:
delay: 20s
max_attempts: 6
sonic-server-transport:
- image: "sonicorg/sonic-server-transport:v1.3.1-release"
+ image: "sonicorg/sonic-server-transport:v1.3.2-beta"
environment:
- PROFILE=prod
- EUREKA_URL=http://sonic:sonic@sonic-server-eureka:9090/eureka/
diff --git a/sonic-server-bus/pom.xml b/sonic-server-bus/pom.xml
index b0b3c755..f013ada7 100644
--- a/sonic-server-bus/pom.xml
+++ b/sonic-server-bus/pom.xml
@@ -10,7 +10,7 @@
4.0.0
sonic-server-bus
- 1.3.1-release
+ 1.3.2-beta
jar
diff --git a/sonic-server-controller/pom.xml b/sonic-server-controller/pom.xml
index e8a62509..1b914f75 100644
--- a/sonic-server-controller/pom.xml
+++ b/sonic-server-controller/pom.xml
@@ -10,7 +10,7 @@
4.0.0
sonic-server-controller
- 1.3.1-release
+ 1.3.2-beta
jar
diff --git a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/controller/StepsController.java b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/controller/StepsController.java
index ce2eeedf..0f2f177b 100644
--- a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/controller/StepsController.java
+++ b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/controller/StepsController.java
@@ -60,17 +60,17 @@ public RespModel> findByCaseIdOrderBySort(@RequestParam(name = "c
return new RespModel<>(RespEnum.SEARCH_OK, stepsService.findByCaseIdOrderBySort(caseId));
}
- @WebAspect
- @ApiOperation(value = "移出测试用例", notes = "将步骤从测试用例移出")
- @ApiImplicitParam(name = "id", value = "步骤id", dataTypeClass = Integer.class)
- @GetMapping("/resetCaseId")
- public RespModel resetCaseId(@RequestParam(name = "id") int id) {
- if (stepsService.resetCaseId(id)) {
- return new RespModel<>(2000, "移出测试用例成功!");
- } else {
- return new RespModel<>(RespEnum.ID_NOT_FOUND);
- }
- }
+// @WebAspect
+// @ApiOperation(value = "移出测试用例", notes = "将步骤从测试用例移出")
+// @ApiImplicitParam(name = "id", value = "步骤id", dataTypeClass = Integer.class)
+// @GetMapping("/resetCaseId")
+// public RespModel resetCaseId(@RequestParam(name = "id") int id) {
+// if (stepsService.resetCaseId(id)) {
+// return new RespModel<>(2000, "移出测试用例成功!");
+// } else {
+// return new RespModel<>(RespEnum.ID_NOT_FOUND);
+// }
+// }
@WebAspect
@ApiOperation(value = "删除操作步骤", notes = "将步骤删除,并且从所有公共步骤里移除")
diff --git a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/mapper/DevicesMapper.java b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/mapper/DevicesMapper.java
index 373f9965..da8a0700 100644
--- a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/mapper/DevicesMapper.java
+++ b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/mapper/DevicesMapper.java
@@ -25,7 +25,10 @@ public interface DevicesMapper extends BaseMapper {
@Select("select size from devices group by size")
List findSizeList();
- @Select("select d.* from test_suites_devices tsd inner join devices d on d.id = tsd.devices_id where tsd.test_suites_id = #{TestSuitesId}")
+ @Select("select d.* from test_suites_devices tsd " +
+ "inner join devices d on d.id = tsd.devices_id " +
+ "where tsd.test_suites_id = #{TestSuitesId} " +
+ "order by tsd.sort asc")
List listByTestSuitesId(@Param("TestSuitesId") int TestSuitesId);
Integer findTemper(@Param("ids") List ids);
diff --git a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/mapper/TestCasesMapper.java b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/mapper/TestCasesMapper.java
index f150b578..d6a7fa84 100644
--- a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/mapper/TestCasesMapper.java
+++ b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/mapper/TestCasesMapper.java
@@ -17,7 +17,8 @@
public interface TestCasesMapper extends BaseMapper {
@Select("select tc.* from test_suites_test_cases tstc " +
- "inner join test_cases tc on tc.id = tstc.test_cases_id " +
- "where tstc.test_suites_id = #{suiteId}")
+ "inner join test_cases tc on tc.id = tstc.test_cases_id " +
+ "where tstc.test_suites_id = #{suiteId} " +
+ "order by tstc.sort asc")
List listByTestSuitesId(@Param("suiteId") int suiteId);
}
diff --git a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/models/domain/Steps.java b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/models/domain/Steps.java
index f3bd4383..3805a65f 100644
--- a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/models/domain/Steps.java
+++ b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/models/domain/Steps.java
@@ -16,6 +16,7 @@
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
+import org.cloud.sonic.controller.models.enums.ConditionEnum;
import java.io.Serializable;
@@ -39,6 +40,10 @@ public class Steps implements Serializable, TypeConverter {
@IsAutoIncrement
private Integer id;
+ @TableField
+ @Column(value = "parent_id", defaultValue = "0", isNull = false, comment = "父级id,一般父级都是条件步骤")
+ private Integer parentId;
+
@TableField
@Column(value = "case_id", isNull = false, comment = "所属测试用例id")
@Index(value = "IDX_CASE_ID", columns = {"case_id"})
@@ -72,4 +77,11 @@ public class Steps implements Serializable, TypeConverter {
@TableField
@Column(type = MySqlTypeConstant.LONGTEXT, isNull = false, comment = "其它信息")
private String text;
+
+ /**
+ * @see ConditionEnum
+ */
+ @TableField
+ @Column(value = "condition_type", defaultValue = "0", isNull = false, comment = "条件类型")
+ private Integer conditionType;
}
diff --git a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/models/domain/TestSuitesDevices.java b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/models/domain/TestSuitesDevices.java
index 2b9feccf..fa040d52 100644
--- a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/models/domain/TestSuitesDevices.java
+++ b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/models/domain/TestSuitesDevices.java
@@ -40,4 +40,8 @@ public class TestSuitesDevices implements Serializable, TypeConverter {
@ApiModelProperty(value = "id", example = "1")
Integer id;
+ @ApiModelProperty(value = "父级id,一般父级都是条件步骤", example = "0")
+ Integer parentId;
+
@Positive
@ApiModelProperty(value = "项目id", required = true, example = "1")
Integer projectId;
@@ -60,6 +62,12 @@ public class StepsDTO implements Serializable, TypeConverter {
@ApiModelProperty(value = "异常处理类型", required = true, example = "1")
int error;
+ /**
+ * @see ConditionEnum
+ */
+ @ApiModelProperty(value = "步骤条件类型,0:非条件 1:if 2:else if 3:else 4:while", example = "0")
+ private Integer conditionType = 0;
+
@ApiModelProperty(value = "包含元素列表")
List elements;
@@ -69,4 +77,7 @@ public class StepsDTO implements Serializable, TypeConverter {
@ApiModelProperty(value = "所属测试用例")
TestCasesDTO testCasesDTO;
+
+ @ApiModelProperty(value = "子步骤")
+ List childSteps;
}
diff --git a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/models/dto/TestSuitesDevicesDTO.java b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/models/dto/TestSuitesDevicesDTO.java
index aa06dbf4..00a28e13 100644
--- a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/models/dto/TestSuitesDevicesDTO.java
+++ b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/models/dto/TestSuitesDevicesDTO.java
@@ -30,4 +30,6 @@ public class TestSuitesDevicesDTO implements Serializable, TypeConverter {
-
private Integer testSuitesId;
private Integer testCasesId;
+
+ private Integer sort;
}
diff --git a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/models/enums/ConditionEnum.java b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/models/enums/ConditionEnum.java
new file mode 100644
index 00000000..fb709f7a
--- /dev/null
+++ b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/models/enums/ConditionEnum.java
@@ -0,0 +1,53 @@
+package org.cloud.sonic.controller.models.enums;
+
+import java.io.Serializable;
+
+/**
+ * @author JayWenStar
+ * @date 2022/3/13 1:49 下午
+ */
+public enum ConditionEnum implements SonicEnum, Serializable {
+
+ /**
+ * 非条件
+ */
+ NONE(0, "none"),
+
+ /**
+ * if 条件
+ */
+ IF(1, "if"),
+
+ /**
+ * else if 条件
+ */
+ ELSE_IF(2, "else_if"),
+
+ /**
+ * else 条件
+ */
+ ELSE(3, "else"),
+
+ /**
+ * while 条件
+ */
+ WHILE(4, "while");
+
+ private final Integer value;
+
+ private final String name;
+
+ ConditionEnum(int value, String name) {
+ this.value = value;
+ this.name = name;
+ }
+
+ @Override
+ public Integer getValue() {
+ return value;
+ }
+
+ public String getName() {
+ return name;
+ }
+}
diff --git a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/models/enums/SonicEnum.java b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/models/enums/SonicEnum.java
new file mode 100644
index 00000000..f5dec005
--- /dev/null
+++ b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/models/enums/SonicEnum.java
@@ -0,0 +1,35 @@
+package org.cloud.sonic.controller.models.enums;
+
+import org.springframework.util.Assert;
+
+import java.util.stream.Stream;
+
+/**
+ * * 跟agent同步,后续优化
+ * @author JayWenStar
+ * @date 2022/3/13 1:55 下午
+ */
+public interface SonicEnum {
+
+ /**
+ * 获取枚举值
+ *
+ * @return enum value
+ */
+ T getValue();
+
+ /**
+ * 将value转成枚举
+ */
+ static & SonicEnum> E valueToEnum(Class enumType, T value) {
+ Assert.notNull(enumType, "enum type must not be null");
+ Assert.notNull(value, "value must not be null");
+ Assert.isTrue(enumType.isEnum(), "type must be an enum type");
+
+ return Stream.of(enumType.getEnumConstants())
+ .filter(item -> item.getValue().equals(value))
+ .findFirst()
+ .orElseThrow(() -> new IllegalArgumentException("unknown database value: " + value));
+ }
+
+}
diff --git a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/StepsService.java b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/StepsService.java
index 15886cdb..a06a1669 100644
--- a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/StepsService.java
+++ b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/StepsService.java
@@ -6,6 +6,7 @@
import org.cloud.sonic.controller.models.domain.Steps;
import org.cloud.sonic.controller.models.dto.StepsDTO;
import org.cloud.sonic.controller.models.http.StepSort;
+import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@@ -17,6 +18,17 @@
public interface StepsService extends IService {
List findByCaseIdOrderBySort(int caseId);
+ @Transactional
+ List handleSteps(List stepsDTOS);
+
+ /**
+ * 如果步骤是条件步骤,且子条件也可能是条件步骤,则递归填充条件步骤的子步骤,且所有步骤都会填充 {@link StepsDTO#elements} 属性
+ *
+ * @param stepsDTO 步骤对象(不需要填充)
+ */
+ @Transactional
+ void handleStep(StepsDTO stepsDTO);
+
boolean resetCaseId(int id);
boolean delete(int id);
diff --git a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/DevicesServiceImpl.java b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/DevicesServiceImpl.java
index 5e7979a6..e7ab60ad 100644
--- a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/DevicesServiceImpl.java
+++ b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/DevicesServiceImpl.java
@@ -39,10 +39,13 @@
@Service
public class DevicesServiceImpl extends SonicServiceImpl implements DevicesService {
- @Autowired private DevicesMapper devicesMapper;
+ @Autowired
+ private DevicesMapper devicesMapper;
- @Autowired private UsersService usersService;
- @Autowired private TestSuitesDevicesMapper testSuitesDevicesMapper;
+ @Autowired
+ private UsersService usersService;
+ @Autowired
+ private TestSuitesDevicesMapper testSuitesDevicesMapper;
@Override
public boolean saveDetail(DeviceDetailChange deviceDetailChange) {
@@ -148,6 +151,7 @@ public void deviceStatus(JSONObject jsonMsg) {
}
if (jsonMsg.getString("model") != null) {
newDevices.setName(jsonMsg.getString("model"));
+ newDevices.setChiName(getName(jsonMsg.getString("model")));
}
newDevices.setNickName("");
newDevices.setUser("");
@@ -172,6 +176,7 @@ public void deviceStatus(JSONObject jsonMsg) {
if (jsonMsg.getString("model") != null) {
if (!jsonMsg.getString("model").equals("未知")) {
devices.setModel(jsonMsg.getString("model"));
+ devices.setChiName(getName(jsonMsg.getString("model")));
}
}
if (jsonMsg.getString("version") != null) {
@@ -189,7 +194,9 @@ public void deviceStatus(JSONObject jsonMsg) {
if (jsonMsg.getString("manufacturer") != null) {
devices.setManufacturer(jsonMsg.getString("manufacturer"));
}
- devices.setStatus(jsonMsg.getString("status"));
+ if (jsonMsg.getString("status") != null) {
+ devices.setStatus(jsonMsg.getString("status"));
+ }
save(devices);
}
}
@@ -238,7 +245,7 @@ public void refreshDevicesTemper(JSONObject jsonObject) {
@Override
public Integer findTemper() {
return devicesMapper.findTemper(Arrays.asList(DeviceStatus.ONLINE
- ,DeviceStatus.DEBUGGING,DeviceStatus.TESTING));
+ , DeviceStatus.DEBUGGING, DeviceStatus.TESTING));
}
@Override
diff --git a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/PublicStepsServiceImpl.java b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/PublicStepsServiceImpl.java
index 7b719e97..27892255 100644
--- a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/PublicStepsServiceImpl.java
+++ b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/PublicStepsServiceImpl.java
@@ -12,6 +12,7 @@
import org.cloud.sonic.controller.models.dto.PublicStepsDTO;
import org.cloud.sonic.controller.models.dto.StepsDTO;
import org.cloud.sonic.controller.services.PublicStepsService;
+import org.cloud.sonic.controller.services.StepsService;
import org.cloud.sonic.controller.services.impl.base.SonicServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -34,6 +35,7 @@ public class PublicStepsServiceImpl extends SonicServiceImpl findByProjectId(int projectId, Page StepsDTO
Map> stepsDTOMap = publicStepsMapper.listStepsByPublicStepsIds(publicStepsIdSet)
.stream().collect(Collectors.groupingBy(StepsDTO::getPublicStepsId));
- Set stepIdSet = new HashSet<>();
- stepsDTOMap.values().forEach(vList -> {
- vList.forEach(e -> stepIdSet.add(e.getId()));
- });
-
- // stepsId -> elementDTO
- Map> elementDTOMap = new HashMap<>();
- if (!stepIdSet.isEmpty()) {
- elementDTOMap = elementsMapper.listElementsByStepsIds(stepIdSet)
- .stream().collect(Collectors.groupingBy(ElementsDTO::getStepsId));
- }
- // 将element填充到step
- Map> finalElementDTOMap = elementDTOMap;
- stepsDTOMap.forEach((k, v) -> {
- v.forEach(e -> e.setElements(finalElementDTOMap.get(e.getId())));
- });
// 将step填充到public step
- publicStepsDTOList.forEach(e -> e.setSteps(stepsDTOMap.get(e.getId())));
+ publicStepsDTOList.forEach(
+ e -> e.setSteps(stepsService.handleSteps(stepsDTOMap.get(e.getId())))
+ );
return CommentPage.convertFrom(page, publicStepsDTOList);
}
@@ -123,9 +111,7 @@ public PublicStepsDTO findById(int id) {
List steps = stepsMapper.listByPublicStepsId(publicSteps.getId())
.stream().map(TypeConverter::convertTo).collect(Collectors.toList());
- for (StepsDTO step : steps) {
- step.setElements(elementsMapper.listElementsByStepsId(step.getId()));
- }
+ stepsService.handleSteps(steps);
PublicStepsDTO publicStepsDTO = publicSteps.convertTo().setSteps(steps);
return publicStepsDTO.setSteps(steps);
diff --git a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/StepsServiceImpl.java b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/StepsServiceImpl.java
index 0af3a687..f41c4a0b 100644
--- a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/StepsServiceImpl.java
+++ b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/StepsServiceImpl.java
@@ -12,12 +12,14 @@
import org.cloud.sonic.controller.models.domain.StepsElements;
import org.cloud.sonic.controller.models.dto.ElementsDTO;
import org.cloud.sonic.controller.models.dto.StepsDTO;
+import org.cloud.sonic.controller.models.enums.ConditionEnum;
import org.cloud.sonic.controller.models.http.StepSort;
import org.cloud.sonic.controller.services.StepsService;
import org.cloud.sonic.controller.services.impl.base.SonicServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
import java.util.List;
import java.util.stream.Collectors;
@@ -36,19 +38,56 @@ public class StepsServiceImpl extends SonicServiceImpl imple
@Autowired private PublicStepsStepsMapper publicStepsStepsMapper;
@Autowired private StepsElementsMapper stepsElementsMapper;
+ @Transactional
@Override
public List findByCaseIdOrderBySort(int caseId) {
- List stepsDTOList = lambdaQuery().eq(Steps::getCaseId, caseId)
+ // 取出用例下所有无父级的步骤
+ List stepsDTOList = lambdaQuery()
+ .eq(Steps::getCaseId, caseId)
+ .eq(Steps::getParentId, 0)
.orderByAsc(Steps::getSort)
.list()
// 转换成DTO
.stream().map(TypeConverter::convertTo).collect(Collectors.toList());
- // 填充elements
- stepsDTOList.forEach(e -> e.setElements(elementsMapper.listElementsByStepsId(e.getId())));
+
+ // 遍历父级步骤,如果是条件步骤,则取出子步骤集合
+ handleSteps(stepsDTOList);
+
return stepsDTOList;
}
+ @Transactional
+ @Override
+ public List handleSteps(List stepsDTOS) {
+ if (CollectionUtils.isEmpty(stepsDTOS)) {
+ return stepsDTOS;
+ }
+ for (StepsDTO stepsDTO : stepsDTOS) {
+ handleStep(stepsDTO);
+ }
+ return stepsDTOS;
+ }
+
+ @Transactional
+ @Override
+ public void handleStep(StepsDTO stepsDTO) {
+ if (stepsDTO == null) {
+ return;
+ }
+ stepsDTO.setElements(elementsMapper.listElementsByStepsId(stepsDTO.getId()));
+ // 如果是条件步骤
+ if (!stepsDTO.getConditionType().equals(ConditionEnum.NONE.getValue())) {
+ List childSteps = lambdaQuery()
+ .eq(Steps::getParentId, stepsDTO.getId())
+ .orderByAsc(Steps::getSort)
+ .list()
+ // 转换成DTO
+ .stream().map(TypeConverter::convertTo).collect(Collectors.toList());
+ stepsDTO.setChildSteps(handleSteps(childSteps));
+ }
+ }
+
@Override
public boolean resetCaseId(int id) {
if (existsById(id)) {
@@ -106,9 +145,8 @@ public void saveStep(StepsDTO stepsDTO) {
@Transactional
@Override
public StepsDTO findById(int id) {
-
StepsDTO stepsDTO = baseMapper.selectById(id).convertTo();
- stepsDTO.setElements(elementsMapper.listElementsByStepsId(stepsDTO.getId()));
+ handleStep(stepsDTO);
return stepsDTO;
}
@@ -145,15 +183,13 @@ public CommentPage findByProjectIdAndPlatform(int projectId, int platf
Page page = lambdaQuery().eq(Steps::getProjectId, projectId)
.eq(Steps::getPlatform, platform)
+ .eq(Steps::getParentId, 0)
.orderByDesc(Steps::getId)
.page(pageable);
List stepsDTOList = page.getRecords()
.stream().map(TypeConverter::convertTo).collect(Collectors.toList());
-
- for (StepsDTO stepsDTO : stepsDTOList) {
- stepsDTO.setElements(elementsMapper.listElementsByStepsId(stepsDTO.getId()));
- }
+ handleSteps(stepsDTOList);
return CommentPage.convertFrom(page, stepsDTOList);
}
diff --git a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/TestSuitesServiceImpl.java b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/TestSuitesServiceImpl.java
index 8089617e..4a40930b 100644
--- a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/TestSuitesServiceImpl.java
+++ b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/TestSuitesServiceImpl.java
@@ -355,16 +355,22 @@ public void saveTestSuites(TestSuitesDTO testSuitesDTO) {
);
// 保存testcase映射
- for (TestCasesDTO testCase : testCases) {
+ for (int i = 0; i < testCases.size(); i++) {
testSuitesTestCasesMapper.insert(
- new TestSuitesTestCases().setTestSuitesId(suiteId).setTestCasesId(testCase.getId())
+ new TestSuitesTestCases()
+ .setTestSuitesId(suiteId)
+ .setTestCasesId(testCases.get(i).getId())
+ .setSort(i + 1)
);
}
// 保存devices映射
- for (DevicesDTO device : devices) {
+ for (int i = 0; i < devices.size(); i++) {
testSuitesDevicesMapper.insert(
- new TestSuitesDevices().setTestSuitesId(suiteId).setDevicesId(device.getId())
+ new TestSuitesDevices()
+ .setTestSuitesId(suiteId)
+ .setDevicesId(devices.get(i).getId())
+ .setSort(i + 1)
);
}
}
diff --git a/sonic-server-eureka/pom.xml b/sonic-server-eureka/pom.xml
index fe256a4a..eb025d6f 100644
--- a/sonic-server-eureka/pom.xml
+++ b/sonic-server-eureka/pom.xml
@@ -10,7 +10,7 @@
4.0.0
sonic-server-eureka
- 1.3.1-release
+ 1.3.2-beta
jar
diff --git a/sonic-server-folder/pom.xml b/sonic-server-folder/pom.xml
index 81e3ba10..32efd4a8 100644
--- a/sonic-server-folder/pom.xml
+++ b/sonic-server-folder/pom.xml
@@ -10,7 +10,7 @@
4.0.0
sonic-server-folder
- 1.3.1-release
+ 1.3.2-beta
jar
diff --git a/sonic-server-gateway/pom.xml b/sonic-server-gateway/pom.xml
index f54b5983..5a0c267b 100644
--- a/sonic-server-gateway/pom.xml
+++ b/sonic-server-gateway/pom.xml
@@ -10,7 +10,7 @@
4.0.0
sonic-server-gateway
- 1.3.1-release
+ 1.3.2-beta
jar
diff --git a/sonic-server-task/pom.xml b/sonic-server-task/pom.xml
index d5e3c3ec..fdbda728 100644
--- a/sonic-server-task/pom.xml
+++ b/sonic-server-task/pom.xml
@@ -10,7 +10,7 @@
4.0.0
sonic-server-task
- 1.3.1-release
+ 1.3.2-beta
jar
diff --git a/sonic-server-transport/pom.xml b/sonic-server-transport/pom.xml
index 2566aff5..5c353362 100644
--- a/sonic-server-transport/pom.xml
+++ b/sonic-server-transport/pom.xml
@@ -10,7 +10,7 @@
4.0.0
sonic-server-transport
- 1.3.1-release
+ 1.3.2-beta
jar
diff --git a/sonic-server-transport/src/main/java/org/cloud/sonic/transport/controller/ExchangeController.java b/sonic-server-transport/src/main/java/org/cloud/sonic/transport/controller/ExchangeController.java
index 6cd3f2aa..46fade24 100644
--- a/sonic-server-transport/src/main/java/org/cloud/sonic/transport/controller/ExchangeController.java
+++ b/sonic-server-transport/src/main/java/org/cloud/sonic/transport/controller/ExchangeController.java
@@ -39,6 +39,21 @@ public RespModel reboot(@RequestParam(name = "id") int id) {
}
}
+ @WebAspect
+ @GetMapping("/stop")
+ public RespModel stop(@RequestParam(name = "id") int id) {
+ RespModel agent = controllerFeignClient.findAgentById(id);
+ if (agent.getCode() == 2000) {
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put("msg", "stop");
+ LinkedHashMap a = (LinkedHashMap) agent.getData();
+ NettyServer.getMap().get(a.get("id")).writeAndFlush(jsonObject.toJSONString());
+ return new RespModel<>(2000, "发送成功!");
+ } else {
+ return agent;
+ }
+ }
+
@WebAspect
@PostMapping("/sendTestData")
public RespModel sendTestData(@RequestBody JSONObject jsonObject) {