通过导出用例步骤生成的Excel,再进行导入Excel用例步骤优化

This commit is contained in:
李凤阳 2022-01-13 23:20:02 +08:00
parent 097b29dd92
commit 9e8f4e34b1
2 changed files with 68 additions and 50 deletions

View File

@ -1,8 +1,10 @@
package com.luckyframe.project.testmanagmt.projectCase.controller;
import com.luckyframe.common.utils.poi.ExcelUtil;
import com.luckyframe.project.testmanagmt.projectCase.domain.ProjectCaseSteps;
import com.luckyframe.project.testmanagmt.projectCase.service.IProjectCaseService;
import com.luckyframe.project.testmanagmt.projectCase.service.IProjectCaseStepsService;
import com.luckyframe.project.testmanagmt.projectCaseModule.domain.ProjectCaseModule;
import com.luckyframe.rc.ReadTxt;
import com.luckyframe.rc.Readfile;
import com.luckyframe.rc.entity.ElementAction;
@ -39,8 +41,23 @@ public class RecordController {
* StepType默认类型 0 HTTP接口 1 Web UI 2 API驱动 3移动端
*/
@PostMapping(value = "/insert",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public ResponseEntity insertRecord(@RequestParam("file") MultipartFile file,@RequestParam("projectId") int ProjectId,@RequestParam("caseId") int CaseId,@RequestParam("stepType") int StepType) throws IOException {
public ResponseEntity insertRecord(@RequestParam("file") MultipartFile file,@RequestParam("projectId") int ProjectId,@RequestParam("caseId") int CaseId,@RequestParam("stepType") int StepType) throws Exception {
log.info("StepType:"+StepType);
if (file.getOriginalFilename().toLowerCase().endsWith(".xlsx")){
ExcelUtil<ProjectCaseSteps> util = new ExcelUtil<>(ProjectCaseSteps.class);
List<ProjectCaseSteps> caseStepsList = util.importExcel(file.getInputStream());
int stepSerialNumber=1;
log.info("开始插入步骤");
for(ProjectCaseSteps projectCaseSteps:caseStepsList){
projectCaseSteps.setProjectId(ProjectId);
projectCaseSteps.setCaseId(CaseId);
projectCaseSteps.setStepSerialNumber(stepSerialNumber);
projectCaseSteps.setCreateTime(new Date());
log.info(""+stepSerialNumber+"步骤为:\n"+projectCaseSteps);
projectCaseStepsService.insertProjectCaseSteps(projectCaseSteps);
stepSerialNumber++;
}
}else {
if (StepType==3){
//解析app自动化测试录制的脚本
ReadTxt readTxt = new ReadTxt();
@ -97,6 +114,8 @@ public class RecordController {
stepSerialNumber++;
}
}
}
return ResponseEntity.ok().build();
}

View File

@ -17,7 +17,6 @@ public class ProjectCaseSteps extends BaseEntity
private static final long serialVersionUID = 1L;
/** 步骤ID */
@Excel(name = "步骤ID")
private Integer stepId;
/** 用例ID */
@Excel(name = "用例ID")