|
@@ -1,6 +1,7 @@
|
|
package com.mooctest.crowd.site.controller;
|
|
package com.mooctest.crowd.site.controller;
|
|
|
|
|
|
import com.alibaba.druid.util.StringUtils;
|
|
import com.alibaba.druid.util.StringUtils;
|
|
|
|
+import com.mooctest.crowd.domain.domainobject.CrowdTestTask;
|
|
import com.mooctest.crowd.domain.domainobject.Defect;
|
|
import com.mooctest.crowd.domain.domainobject.Defect;
|
|
import com.mooctest.crowd.domain.domainobject.TestCase;
|
|
import com.mooctest.crowd.domain.domainobject.TestCase;
|
|
import com.mooctest.crowd.domain.env.TestCaseExamStatus;
|
|
import com.mooctest.crowd.domain.env.TestCaseExamStatus;
|
|
@@ -15,17 +16,28 @@ import com.mooctest.crowd.site.data.dto.TestCaseExamCommand;
|
|
import com.mooctest.crowd.site.data.dto.TestCaseSearchDTO;
|
|
import com.mooctest.crowd.site.data.dto.TestCaseSearchDTO;
|
|
import com.mooctest.crowd.site.data.response.ResponseVO;
|
|
import com.mooctest.crowd.site.data.response.ResponseVO;
|
|
import com.mooctest.crowd.site.data.response.ServerCode;
|
|
import com.mooctest.crowd.site.data.response.ServerCode;
|
|
|
|
+import com.mooctest.crowd.site.service.CrowdTaskService;
|
|
import com.mooctest.crowd.site.service.DefectService;
|
|
import com.mooctest.crowd.site.service.DefectService;
|
|
import com.mooctest.crowd.site.service.TestCaseService;
|
|
import com.mooctest.crowd.site.service.TestCaseService;
|
|
|
|
+import com.mooctest.crowd.site.service.UserService;
|
|
import com.mooctest.crowd.site.util.RequestUtils;
|
|
import com.mooctest.crowd.site.util.RequestUtils;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
|
|
+import org.apache.http.client.utils.DateUtils;
|
|
|
|
+import org.apache.logging.log4j.util.Strings;
|
|
|
|
+import org.apache.poi.ss.usermodel.*;
|
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
|
+import java.io.ByteArrayOutputStream;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
|
+import java.io.OutputStream;
|
|
|
|
+import java.net.URLEncoder;
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
@RestController
|
|
@RestController
|
|
@RequestMapping("/api/testcase")
|
|
@RequestMapping("/api/testcase")
|
|
@@ -35,6 +47,10 @@ public class TestCaseController {
|
|
private TestCaseService testCaseService;
|
|
private TestCaseService testCaseService;
|
|
@Autowired
|
|
@Autowired
|
|
private DefectService defectService;
|
|
private DefectService defectService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private UserService userService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private CrowdTaskService crowdTaskService;
|
|
|
|
|
|
@PostMapping(value = "/")
|
|
@PostMapping(value = "/")
|
|
@LoginRequired
|
|
@LoginRequired
|
|
@@ -139,4 +155,396 @@ public class TestCaseController {
|
|
defectService.importDefects(file.getBytes(), taskCode, userId);
|
|
defectService.importDefects(file.getBytes(), taskCode, userId);
|
|
return new ResponseVO(ServerCode.SUCCESS);
|
|
return new ResponseVO(ServerCode.SUCCESS);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @PostMapping(value = "/examallvalid/{taskCode}/{designerId}")
|
|
|
|
+ @LoginRequired
|
|
|
|
+ public ResponseVO examAllValid(HttpServletRequest request, @PathVariable("taskCode") String taskCode, @PathVariable("designerId") Long designerId) {
|
|
|
|
+ Long examerId = RequestUtils.getUserId(request);
|
|
|
|
+ testCaseService.examAllValidByTaskCodeAndDesignerId(taskCode, designerId, examerId);
|
|
|
|
+ return new ResponseVO(ServerCode.SUCCESS);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping(value = "/export/{taskCode}")
|
|
|
|
+ @LoginRequired
|
|
|
|
+ public void export(HttpServletRequest request, HttpServletResponse response, @PathVariable("taskCode") String taskCode) throws IOException {
|
|
|
|
+ Workbook wb = new XSSFWorkbook();
|
|
|
|
+ Long userId = RequestUtils.getUserId(request);
|
|
|
|
+ createTestCaseSheet(wb, userId, taskCode);
|
|
|
|
+ createDefectSheet(wb, userId, taskCode);
|
|
|
|
+ CrowdTestTask task = crowdTaskService.getByTaskCode(taskCode);
|
|
|
|
+ response.setHeader("Content-Disposition", String.format("attachment;filename=%s.xlsx",
|
|
|
|
+ URLEncoder.encode(task.getName(), "utf-8")));
|
|
|
|
+ response.setContentType("application/octet-stream");
|
|
|
|
+ OutputStream os = response.getOutputStream();
|
|
|
|
+ wb.write(os);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void createTestCaseSheet (Workbook wb, Long userId, String taskCode) {
|
|
|
|
+ List<TestCase> testCases = testCaseService.findAllByTaskCode(userId, taskCode);
|
|
|
|
+ Sheet sheet = wb.createSheet("测试用例");
|
|
|
|
+ int i = 0;
|
|
|
|
+ Row row = sheet.createRow(i++);
|
|
|
|
+ row.setHeightInPoints(row.getHeightInPoints() * (short)2);
|
|
|
|
+ CellStyle baseStyle = wb.createCellStyle();
|
|
|
|
+ baseStyle.setAlignment(HorizontalAlignment.CENTER);
|
|
|
|
+ baseStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
|
|
+ baseStyle.setBorderBottom(BorderStyle.THIN);
|
|
|
|
+ baseStyle.setBorderLeft(BorderStyle.THIN);
|
|
|
|
+ baseStyle.setBorderRight(BorderStyle.THIN);
|
|
|
|
+ baseStyle.setBorderTop(BorderStyle.THIN);
|
|
|
|
+ baseStyle.setWrapText(true);
|
|
|
|
+
|
|
|
|
+ Font headerFont = wb.createFont();
|
|
|
|
+ headerFont.setFontHeightInPoints((short)10);
|
|
|
|
+ headerFont.setFontName("宋体");
|
|
|
|
+ headerFont.setBold(true);
|
|
|
|
+
|
|
|
|
+ Font contentFont = wb.createFont();
|
|
|
|
+ contentFont.setFontHeightInPoints((short)10);
|
|
|
|
+ contentFont.setFontName("宋体");
|
|
|
|
+
|
|
|
|
+ CellStyle headerStyle = wb.createCellStyle();
|
|
|
|
+ headerStyle.cloneStyleFrom(baseStyle);
|
|
|
|
+ headerStyle.setAlignment(HorizontalAlignment.CENTER);
|
|
|
|
+ headerStyle.setFont(headerFont);
|
|
|
|
+
|
|
|
|
+ Cell cell0 = row.createCell(0);
|
|
|
|
+ Cell cell1 = row.createCell(1);
|
|
|
|
+ Cell cell2 = row.createCell(2);
|
|
|
|
+ Cell cell3 = row.createCell(3);
|
|
|
|
+ Cell cell4 = row.createCell(4);
|
|
|
|
+ Cell cell5 = row.createCell(5);
|
|
|
|
+ Cell cell6 = row.createCell(6);
|
|
|
|
+ Cell cell7 = row.createCell(7);
|
|
|
|
+ Cell cell8 = row.createCell(8);
|
|
|
|
+ Cell cell9 = row.createCell(9);
|
|
|
|
+ Cell cell10 = row.createCell(10);
|
|
|
|
+ Cell cell11 = row.createCell(11);
|
|
|
|
+ Cell cell12 = row.createCell(12);
|
|
|
|
+ Cell cell13 = row.createCell(13);
|
|
|
|
+ Cell cell14 = row.createCell(14);
|
|
|
|
+ Cell cell15 = row.createCell(15);
|
|
|
|
+ Cell cell16 = row.createCell(16);
|
|
|
|
+ Cell cell17 = row.createCell(17);
|
|
|
|
+
|
|
|
|
+ cell0.setCellStyle(headerStyle);
|
|
|
|
+ cell0.setCellValue("用例编号");
|
|
|
|
+
|
|
|
|
+ cell1.setCellStyle(headerStyle);
|
|
|
|
+ cell1.setCellValue("关联用例编号");
|
|
|
|
+
|
|
|
|
+ cell2.setCellStyle(headerStyle);
|
|
|
|
+ cell2.setCellValue("关联需求");
|
|
|
|
+ sheet.setColumnWidth(2, sheet.getColumnWidth(2) * 3);
|
|
|
|
+
|
|
|
|
+ cell3.setCellStyle(headerStyle);
|
|
|
|
+ cell3.setCellValue("用例名称");
|
|
|
|
+ sheet.setColumnWidth(3, sheet.getColumnWidth(3) * 2);
|
|
|
|
+
|
|
|
|
+ cell4.setCellStyle(headerStyle);
|
|
|
|
+ cell4.setCellValue("优先级");
|
|
|
|
+
|
|
|
|
+ cell5.setCellStyle(headerStyle);
|
|
|
|
+ cell5.setCellValue("用例描述");
|
|
|
|
+ sheet.setColumnWidth(5, sheet.getColumnWidth(5) * 4);
|
|
|
|
+
|
|
|
|
+ cell6.setCellStyle(headerStyle);
|
|
|
|
+ cell6.setCellValue("前置条件");
|
|
|
|
+ sheet.setColumnWidth(6, sheet.getColumnWidth(6) * 3);
|
|
|
|
+
|
|
|
|
+ cell7.setCellStyle(headerStyle);
|
|
|
|
+ cell7.setCellValue("环境配置");
|
|
|
|
+ sheet.setColumnWidth(7, sheet.getColumnWidth(7) * 3);
|
|
|
|
+
|
|
|
|
+ cell8.setCellStyle(headerStyle);
|
|
|
|
+ cell8.setCellValue("操作步骤");
|
|
|
|
+ sheet.setColumnWidth(8, sheet.getColumnWidth(8) * 3);
|
|
|
|
+
|
|
|
|
+ cell9.setCellStyle(headerStyle);
|
|
|
|
+ cell9.setCellValue("输入数据");
|
|
|
|
+ sheet.setColumnWidth(9, sheet.getColumnWidth(9) * 3);
|
|
|
|
+
|
|
|
|
+ cell10.setCellStyle(headerStyle);
|
|
|
|
+ cell10.setCellValue("预期结果");
|
|
|
|
+ sheet.setColumnWidth(10, sheet.getColumnWidth(10) * 3);
|
|
|
|
+
|
|
|
|
+ cell11.setCellStyle(headerStyle);
|
|
|
|
+ cell11.setCellValue("评判标准");
|
|
|
|
+ sheet.setColumnWidth(11, sheet.getColumnWidth(11) * 3);
|
|
|
|
+
|
|
|
|
+ cell12.setCellStyle(headerStyle);
|
|
|
|
+ cell12.setCellValue("其他说明");
|
|
|
|
+ sheet.setColumnWidth(12, sheet.getColumnWidth(12) * 3);
|
|
|
|
+
|
|
|
|
+ cell13.setCellStyle(headerStyle);
|
|
|
|
+ cell13.setCellValue("设计人员");
|
|
|
|
+ sheet.setColumnWidth(13, sheet.getColumnWidth(13) * 2);
|
|
|
|
+
|
|
|
|
+ cell14.setCellStyle(headerStyle);
|
|
|
|
+ cell14.setCellValue("设计时间");
|
|
|
|
+ sheet.setColumnWidth(14, sheet.getColumnWidth(14) * 2);
|
|
|
|
+
|
|
|
|
+ cell15.setCellStyle(headerStyle);
|
|
|
|
+ cell15.setCellValue("测试结果");
|
|
|
|
+ sheet.setColumnWidth(15, sheet.getColumnWidth(15) * 3);
|
|
|
|
+
|
|
|
|
+ cell16.setCellStyle(headerStyle);
|
|
|
|
+ cell16.setCellValue("测试结论");
|
|
|
|
+
|
|
|
|
+ cell17.setCellStyle(headerStyle);
|
|
|
|
+ cell17.setCellValue("附件");
|
|
|
|
+ sheet.setColumnWidth(17, sheet.getColumnWidth(17) * 4);
|
|
|
|
+
|
|
|
|
+ CellStyle contentStyle = wb.createCellStyle();
|
|
|
|
+ contentStyle.cloneStyleFrom(baseStyle);
|
|
|
|
+ contentStyle.setAlignment(HorizontalAlignment.CENTER);
|
|
|
|
+ contentStyle.setFont(contentFont);
|
|
|
|
+ Map<Long, String> userIdNameMap = new HashMap();
|
|
|
|
+
|
|
|
|
+ for(TestCase testCase: testCases) {
|
|
|
|
+ if (!userIdNameMap.containsKey(testCase.getDesignerId())) {
|
|
|
|
+ String realname = userService.getById(testCase.getDesignerId()).getName();
|
|
|
|
+ userIdNameMap.put(testCase.getDesignerId(), realname);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ row = sheet.createRow(i++);
|
|
|
|
+ cell0 = row.createCell(0);
|
|
|
|
+ cell0.setCellStyle(contentStyle);
|
|
|
|
+ cell1 = row.createCell(1);
|
|
|
|
+ cell1.setCellStyle(contentStyle);
|
|
|
|
+ cell2 = row.createCell(2);
|
|
|
|
+ cell2.setCellStyle(contentStyle);
|
|
|
|
+ cell3 = row.createCell(3);
|
|
|
|
+ CellStyle cellStyle = wb.createCellStyle();
|
|
|
|
+ cellStyle.cloneStyleFrom(contentStyle);
|
|
|
|
+ cellStyle.setAlignment(HorizontalAlignment.LEFT);
|
|
|
|
+ cell3.setCellStyle(cellStyle);
|
|
|
|
+ cell4 = row.createCell(4);
|
|
|
|
+ cell4.setCellStyle(cellStyle);
|
|
|
|
+ cell5 = row.createCell(5);
|
|
|
|
+ cell5.setCellStyle(cellStyle);
|
|
|
|
+ cell6 = row.createCell(6);
|
|
|
|
+ cell6.setCellStyle(cellStyle);
|
|
|
|
+ cell7 = row.createCell(7);
|
|
|
|
+ cell7.setCellStyle(contentStyle);
|
|
|
|
+ cell8 = row.createCell(8);
|
|
|
|
+ cell8.setCellStyle(contentStyle);
|
|
|
|
+ cell9 = row.createCell(9);
|
|
|
|
+ cell9.setCellStyle(contentStyle);
|
|
|
|
+ cell10 = row.createCell(10);
|
|
|
|
+ cell10.setCellStyle(contentStyle);
|
|
|
|
+ cell11 = row.createCell(11);
|
|
|
|
+ cell11.setCellStyle(contentStyle);
|
|
|
|
+ cell12 = row.createCell(12);
|
|
|
|
+ cell12.setCellStyle(contentStyle);
|
|
|
|
+ cell13 = row.createCell(13);
|
|
|
|
+ cell13.setCellStyle(contentStyle);
|
|
|
|
+ cell14 = row.createCell(14);
|
|
|
|
+ cell14.setCellStyle(contentStyle);
|
|
|
|
+ cell15 = row.createCell(15);
|
|
|
|
+ cell15.setCellStyle(contentStyle);
|
|
|
|
+ cell16 = row.createCell(16);
|
|
|
|
+ cell16.setCellStyle(contentStyle);
|
|
|
|
+ cell17 = row.createCell(17);
|
|
|
|
+ cell17.setCellStyle(contentStyle);
|
|
|
|
+
|
|
|
|
+ cell0.setCellValue(testCase.getCode());
|
|
|
|
+ cell1.setCellValue(testCase.getAssociatedCode() == null ? "" : testCase.getAssociatedCode());
|
|
|
|
+ cell2.setCellValue(testCase.getDemand() == null ? "" : testCase.getDemand());
|
|
|
|
+ cell3.setCellValue(testCase.getName());
|
|
|
|
+ cell4.setCellValue(testCase.getPriority().getName());
|
|
|
|
+ cell5.setCellValue(testCase.getDescr() == null ? "" : testCase.getDescr());
|
|
|
|
+ cell6.setCellValue(testCase.getPreconditions() == null ? "" : testCase.getPreconditions());
|
|
|
|
+ cell7.setCellValue(testCase.getEnvConfig() == null ? "" : testCase.getEnvConfig());
|
|
|
|
+ cell8.setCellValue(testCase.getOpeSteps() == null ? "" : testCase.getOpeSteps());
|
|
|
|
+ cell9.setCellValue(testCase.getInputDatas() == null ? "" : testCase.getInputDatas());
|
|
|
|
+ cell10.setCellValue(testCase.getExpectedResult() == null ? "" : testCase.getExpectedResult());
|
|
|
|
+ cell11.setCellValue(testCase.getEvaCriteria() == null ? "" : testCase.getEvaCriteria());
|
|
|
|
+ cell12.setCellValue(testCase.getOthers() == null ? "" : testCase.getOthers());
|
|
|
|
+ cell13.setCellValue(userIdNameMap.get(testCase.getDesignerId()));
|
|
|
|
+ cell14.setCellValue(DateUtils.formatDate(new Date(testCase.getDesignTime().getTime()), "yyyy-MM-dd"));
|
|
|
|
+ cell15.setCellValue(testCase.getTestResult() == null ? "" : testCase.getTestResult());
|
|
|
|
+ cell16.setCellValue(testCase.getTestStatus().getName());
|
|
|
|
+ List<String> files = new ArrayList();
|
|
|
|
+ files.addAll(testCase.getFiles());
|
|
|
|
+ files.addAll(testCase.getScreenshots());
|
|
|
|
+ cell17.setCellValue(Strings.join(files, '、'));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void createDefectSheet (Workbook wb, Long userId, String taskCode) {
|
|
|
|
+ List<Defect> defects = defectService.findAllByTaskCode(userId, taskCode);
|
|
|
|
+ Sheet sheet = wb.createSheet("缺陷记录");
|
|
|
|
+ int i = 0;
|
|
|
|
+ Row row = sheet.createRow(i++);
|
|
|
|
+ row.setHeightInPoints(row.getHeightInPoints() * (short)2);
|
|
|
|
+ CellStyle baseStyle = wb.createCellStyle();
|
|
|
|
+ baseStyle.setAlignment(HorizontalAlignment.CENTER);
|
|
|
|
+ baseStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
|
|
+ baseStyle.setBorderBottom(BorderStyle.THIN);
|
|
|
|
+ baseStyle.setBorderLeft(BorderStyle.THIN);
|
|
|
|
+ baseStyle.setBorderRight(BorderStyle.THIN);
|
|
|
|
+ baseStyle.setBorderTop(BorderStyle.THIN);
|
|
|
|
+ baseStyle.setWrapText(true);
|
|
|
|
+
|
|
|
|
+ Font headerFont = wb.createFont();
|
|
|
|
+ headerFont.setFontHeightInPoints((short)10);
|
|
|
|
+ headerFont.setFontName("宋体");
|
|
|
|
+ headerFont.setBold(true);
|
|
|
|
+
|
|
|
|
+ Font contentFont = wb.createFont();
|
|
|
|
+ contentFont.setFontHeightInPoints((short)10);
|
|
|
|
+ contentFont.setFontName("宋体");
|
|
|
|
+
|
|
|
|
+ CellStyle headerStyle = wb.createCellStyle();
|
|
|
|
+ headerStyle.cloneStyleFrom(baseStyle);
|
|
|
|
+ headerStyle.setAlignment(HorizontalAlignment.CENTER);
|
|
|
|
+ headerStyle.setFont(headerFont);
|
|
|
|
+
|
|
|
|
+ Cell cell0 = row.createCell(0);
|
|
|
|
+ Cell cell1 = row.createCell(1);
|
|
|
|
+ Cell cell2 = row.createCell(2);
|
|
|
|
+ Cell cell3 = row.createCell(3);
|
|
|
|
+ Cell cell4 = row.createCell(4);
|
|
|
|
+ Cell cell5 = row.createCell(5);
|
|
|
|
+ Cell cell6 = row.createCell(6);
|
|
|
|
+ Cell cell7 = row.createCell(7);
|
|
|
|
+ Cell cell8 = row.createCell(8);
|
|
|
|
+ Cell cell9 = row.createCell(9);
|
|
|
|
+ Cell cell10 = row.createCell(10);
|
|
|
|
+ Cell cell11 = row.createCell(11);
|
|
|
|
+ Cell cell12 = row.createCell(12);
|
|
|
|
+ Cell cell13 = row.createCell(13);
|
|
|
|
+ Cell cell14 = row.createCell(14);
|
|
|
|
+ Cell cell15 = row.createCell(15);
|
|
|
|
+
|
|
|
|
+ cell0.setCellStyle(headerStyle);
|
|
|
|
+ cell0.setCellValue("缺陷编号");
|
|
|
|
+
|
|
|
|
+ cell1.setCellStyle(headerStyle);
|
|
|
|
+ cell1.setCellValue("用例编号");
|
|
|
|
+
|
|
|
|
+ cell2.setCellStyle(headerStyle);
|
|
|
|
+ cell2.setCellValue("缺陷描述");
|
|
|
|
+ sheet.setColumnWidth(2, sheet.getColumnWidth(2) * 3);
|
|
|
|
+
|
|
|
|
+ cell3.setCellStyle(headerStyle);
|
|
|
|
+ cell3.setCellValue("严重程度");
|
|
|
|
+
|
|
|
|
+ cell4.setCellStyle(headerStyle);
|
|
|
|
+ cell4.setCellValue("优先级");
|
|
|
|
+
|
|
|
|
+ cell5.setCellStyle(headerStyle);
|
|
|
|
+ cell5.setCellValue("问题类型");
|
|
|
|
+
|
|
|
|
+ cell6.setCellStyle(headerStyle);
|
|
|
|
+ cell6.setCellValue("前置条件");
|
|
|
|
+ sheet.setColumnWidth(6, sheet.getColumnWidth(6) * 3);
|
|
|
|
+
|
|
|
|
+ cell7.setCellStyle(headerStyle);
|
|
|
|
+ cell7.setCellValue("环境配置");
|
|
|
|
+ sheet.setColumnWidth(7, sheet.getColumnWidth(7) * 3);
|
|
|
|
+
|
|
|
|
+ cell8.setCellStyle(headerStyle);
|
|
|
|
+ cell8.setCellValue("操作步骤");
|
|
|
|
+ sheet.setColumnWidth(8, sheet.getColumnWidth(8) * 3);
|
|
|
|
+
|
|
|
|
+ cell9.setCellStyle(headerStyle);
|
|
|
|
+ cell9.setCellValue("输入数据");
|
|
|
|
+ sheet.setColumnWidth(9, sheet.getColumnWidth(9) * 3);
|
|
|
|
+
|
|
|
|
+ cell10.setCellStyle(headerStyle);
|
|
|
|
+ cell10.setCellValue("预期结果");
|
|
|
|
+ sheet.setColumnWidth(10, sheet.getColumnWidth(10) * 3);
|
|
|
|
+
|
|
|
|
+ cell11.setCellStyle(headerStyle);
|
|
|
|
+ cell11.setCellValue("实际结果");
|
|
|
|
+ sheet.setColumnWidth(11, sheet.getColumnWidth(11) * 3);
|
|
|
|
+
|
|
|
|
+ cell12.setCellStyle(headerStyle);
|
|
|
|
+ cell12.setCellValue("其他说明");
|
|
|
|
+ sheet.setColumnWidth(12, sheet.getColumnWidth(12) * 3);
|
|
|
|
+
|
|
|
|
+ cell13.setCellStyle(headerStyle);
|
|
|
|
+ cell13.setCellValue("提交人员");
|
|
|
|
+ sheet.setColumnWidth(13, sheet.getColumnWidth(13) * 2);
|
|
|
|
+
|
|
|
|
+ cell14.setCellStyle(headerStyle);
|
|
|
|
+ cell14.setCellValue("提交时间");
|
|
|
|
+ sheet.setColumnWidth(14, sheet.getColumnWidth(14) * 2);
|
|
|
|
+
|
|
|
|
+ cell15.setCellStyle(headerStyle);
|
|
|
|
+ cell15.setCellValue("附件");
|
|
|
|
+ sheet.setColumnWidth(15, sheet.getColumnWidth(15) * 4);
|
|
|
|
+
|
|
|
|
+ CellStyle contentStyle = wb.createCellStyle();
|
|
|
|
+ contentStyle.cloneStyleFrom(baseStyle);
|
|
|
|
+ contentStyle.setAlignment(HorizontalAlignment.CENTER);
|
|
|
|
+ contentStyle.setFont(contentFont);
|
|
|
|
+ Map<Long, String> userIdNameMap = new HashMap();
|
|
|
|
+
|
|
|
|
+ for(Defect defect: defects) {
|
|
|
|
+ if (!userIdNameMap.containsKey(defect.getCommiterId())) {
|
|
|
|
+ String realname = userService.getById(defect.getCommiterId()).getName();
|
|
|
|
+ userIdNameMap.put(defect.getCommiterId(), realname);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ row = sheet.createRow(i++);
|
|
|
|
+ cell0 = row.createCell(0);
|
|
|
|
+ cell0.setCellStyle(contentStyle);
|
|
|
|
+ cell1 = row.createCell(1);
|
|
|
|
+ cell1.setCellStyle(contentStyle);
|
|
|
|
+ cell2 = row.createCell(2);
|
|
|
|
+ cell2.setCellStyle(contentStyle);
|
|
|
|
+ cell3 = row.createCell(3);
|
|
|
|
+ CellStyle cellStyle = wb.createCellStyle();
|
|
|
|
+ cellStyle.cloneStyleFrom(contentStyle);
|
|
|
|
+ cellStyle.setAlignment(HorizontalAlignment.LEFT);
|
|
|
|
+ cell3.setCellStyle(cellStyle);
|
|
|
|
+ cell4 = row.createCell(4);
|
|
|
|
+ cell4.setCellStyle(cellStyle);
|
|
|
|
+ cell5 = row.createCell(5);
|
|
|
|
+ cell5.setCellStyle(cellStyle);
|
|
|
|
+ cell6 = row.createCell(6);
|
|
|
|
+ cell6.setCellStyle(cellStyle);
|
|
|
|
+ cell7 = row.createCell(7);
|
|
|
|
+ cell7.setCellStyle(contentStyle);
|
|
|
|
+ cell8 = row.createCell(8);
|
|
|
|
+ cell8.setCellStyle(contentStyle);
|
|
|
|
+ cell9 = row.createCell(9);
|
|
|
|
+ cell9.setCellStyle(contentStyle);
|
|
|
|
+ cell10 = row.createCell(10);
|
|
|
|
+ cell10.setCellStyle(contentStyle);
|
|
|
|
+ cell11 = row.createCell(11);
|
|
|
|
+ cell11.setCellStyle(contentStyle);
|
|
|
|
+ cell12 = row.createCell(12);
|
|
|
|
+ cell12.setCellStyle(contentStyle);
|
|
|
|
+ cell13 = row.createCell(13);
|
|
|
|
+ cell13.setCellStyle(contentStyle);
|
|
|
|
+ cell14 = row.createCell(14);
|
|
|
|
+ cell14.setCellStyle(contentStyle);
|
|
|
|
+ cell15 = row.createCell(15);
|
|
|
|
+ cell15.setCellStyle(contentStyle);
|
|
|
|
+
|
|
|
|
+ cell0.setCellValue(defect.getCode());
|
|
|
|
+ cell1.setCellValue(defect.getTestCaseCode());
|
|
|
|
+ cell2.setCellValue(defect.getDescr());
|
|
|
|
+ cell3.setCellValue(defect.getSeriousness().getName());
|
|
|
|
+ cell4.setCellValue(defect.getPriority().getName());
|
|
|
|
+ cell5.setCellValue(defect.getDefectType().getName());
|
|
|
|
+ cell6.setCellValue(defect.getPreconditions() == null ? "" : defect.getPreconditions());
|
|
|
|
+ cell7.setCellValue(defect.getEnvConfig() == null ? "" : defect.getEnvConfig());
|
|
|
|
+ cell8.setCellValue(defect.getOpeSteps() == null ? "" : defect.getOpeSteps());
|
|
|
|
+ cell9.setCellValue(defect.getInputDatas() == null ? "" : defect.getInputDatas());
|
|
|
|
+ cell10.setCellValue(defect.getExpectedResult() == null ? "" : defect.getExpectedResult());
|
|
|
|
+ cell11.setCellValue(defect.getTestResult());
|
|
|
|
+ cell12.setCellValue(defect.getOthers() == null ? "" : defect.getOthers());
|
|
|
|
+ cell13.setCellValue(userIdNameMap.get(defect.getCommiterId()));
|
|
|
|
+ cell14.setCellValue(DateUtils.formatDate(new Date(defect.getCommitTime().getTime()), "yyyy-MM-dd"));
|
|
|
|
+ List<String> files = new ArrayList();
|
|
|
|
+ files.addAll(defect.getFiles());
|
|
|
|
+ files.addAll(defect.getScreenshots());
|
|
|
|
+ cell15.setCellValue(Strings.join(files, '、'));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|