Merge pull request '修改测试用例导出内容排序' (#940) from zwz into master
This commit is contained in:
commit
c750f1b26e
|
@ -1,6 +1,7 @@
|
||||||
package com.microservices.pms.project.service.impl;
|
package com.microservices.pms.project.service.impl;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.microservices.common.core.constant.SecurityConstants;
|
||||||
import com.microservices.common.core.exception.ServiceException;
|
import com.microservices.common.core.exception.ServiceException;
|
||||||
import com.microservices.common.core.utils.DateUtils;
|
import com.microservices.common.core.utils.DateUtils;
|
||||||
import com.microservices.common.core.utils.JSONUtils;
|
import com.microservices.common.core.utils.JSONUtils;
|
||||||
|
@ -31,7 +32,9 @@ import com.microservices.pms.project.service.IPmsProjectTestcaseStepService;
|
||||||
import com.microservices.pms.project.service.IPmsProjectTestcaseTypeService;
|
import com.microservices.pms.project.service.IPmsProjectTestcaseTypeService;
|
||||||
import com.microservices.pms.utils.PmsConstants;
|
import com.microservices.pms.utils.PmsConstants;
|
||||||
import com.microservices.pms.utils.PmsUtils;
|
import com.microservices.pms.utils.PmsUtils;
|
||||||
|
import com.microservices.system.api.RemoteUserService;
|
||||||
import com.microservices.system.api.domain.SysUser;
|
import com.microservices.system.api.domain.SysUser;
|
||||||
|
import com.microservices.system.api.utils.FeignUtils;
|
||||||
import org.apache.poi.xwpf.usermodel.*;
|
import org.apache.poi.xwpf.usermodel.*;
|
||||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.*;
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.*;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -45,6 +48,7 @@ import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
|
import java.time.DateTimeException;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
|
@ -85,6 +89,8 @@ public class PmsProjectTestcaseServiceImpl implements IPmsProjectTestcaseService
|
||||||
private IPmsProductRequirementService pmsProductRequirementService;
|
private IPmsProductRequirementService pmsProductRequirementService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private PmsProjectTestcaseStepMapper pmsProjectTestcaseStepMapper;
|
private PmsProjectTestcaseStepMapper pmsProjectTestcaseStepMapper;
|
||||||
|
@Autowired
|
||||||
|
private RemoteUserService remoteUserService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询测试用例管理
|
* 查询测试用例管理
|
||||||
|
@ -789,12 +795,16 @@ public class PmsProjectTestcaseServiceImpl implements IPmsProjectTestcaseService
|
||||||
autoWrap(xwpfTable.getRow(i + 9).getCell(4), 62,expected.get(i),false,false);
|
autoWrap(xwpfTable.getRow(i + 9).getCell(4), 62,expected.get(i),false,false);
|
||||||
}
|
}
|
||||||
if(pendingOutputData.getUpdate_time()!=null ){
|
if(pendingOutputData.getUpdate_time()!=null ){
|
||||||
autoWrap(xwpfTable.getRow(i + 9).getCell(2),62, pendingOutputData.getUpdate_by(), false,false);
|
String nikeName = Objects.requireNonNull(FeignUtils.getReturnData(remoteUserService.getSysUserByUserName(pendingOutputData.getUpdate_by(), SecurityConstants.INNER))).getNickName();
|
||||||
|
autoWrap(xwpfTable.getRow(i + 9).getCell(2),62, nikeName, false,false);
|
||||||
autoWrap(xwpfTable.getRow(i + 9).getCell(6),62, String.format("%1$tY-%1$tm-%1$td",pendingOutputData.getUpdate_time()), false,false);
|
autoWrap(xwpfTable.getRow(i + 9).getCell(6),62, String.format("%1$tY-%1$tm-%1$td",pendingOutputData.getUpdate_time()), false,false);
|
||||||
} else{
|
} else{
|
||||||
if(pendingOutputData.getCreate_time()!=null ){
|
if(pendingOutputData.getCreate_time()!=null ){
|
||||||
autoWrap(xwpfTable.getRow(i + 9).getCell(2),62, pendingOutputData.getCreate_by(), false,false);
|
String nikeName = Objects.requireNonNull(FeignUtils.getReturnData(remoteUserService.getSysUserByUserName(pendingOutputData.getCreate_by(), SecurityConstants.INNER))).getNickName();
|
||||||
|
autoWrap(xwpfTable.getRow(i + 9).getCell(2),62, nikeName, false,false);
|
||||||
autoWrap(xwpfTable.getRow(i + 9).getCell(6),62, String.format("%1$tY-%1$tm-%1$td",pendingOutputData.getCreate_time()), false,false);
|
autoWrap(xwpfTable.getRow(i + 9).getCell(6),62, String.format("%1$tY-%1$tm-%1$td",pendingOutputData.getCreate_time()), false,false);
|
||||||
|
}else{
|
||||||
|
autoWrap(xwpfTable.getRow(i + 10).getCell(6),62, "2025-01-01", false,false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -803,9 +813,12 @@ public class PmsProjectTestcaseServiceImpl implements IPmsProjectTestcaseService
|
||||||
|
|
||||||
private void creatTableTemplate(XWPFDocument xwpfDocument,PendingOutputDataVo pendingOutputData) {
|
private void creatTableTemplate(XWPFDocument xwpfDocument,PendingOutputDataVo pendingOutputData) {
|
||||||
//获取此用例步骤数
|
//获取此用例步骤数
|
||||||
int stepNumber = pendingOutputData.getContent_list().size();
|
int stepNumber = 1;
|
||||||
|
if (pendingOutputData.getId() != null){
|
||||||
|
stepNumber = pendingOutputData.getContent_list().size();
|
||||||
|
}
|
||||||
// 创建表格 - 宽度设置为所有列宽度之和
|
// 创建表格 - 宽度设置为所有列宽度之和
|
||||||
XWPFTable table = xwpfDocument.createTable(stepNumber + 13, 9);
|
XWPFTable table = xwpfDocument.createTable(stepNumber + 14, 9);
|
||||||
|
|
||||||
// 不显示表格最后行
|
// 不显示表格最后行
|
||||||
hideTableRow(table);
|
hideTableRow(table);
|
||||||
|
@ -909,10 +922,10 @@ public class PmsProjectTestcaseServiceImpl implements IPmsProjectTestcaseService
|
||||||
XWPFParagraph titleParagraph = doc.createParagraph();
|
XWPFParagraph titleParagraph = doc.createParagraph();
|
||||||
titleParagraph.setAlignment(ParagraphAlignment.CENTER);
|
titleParagraph.setAlignment(ParagraphAlignment.CENTER);
|
||||||
XWPFRun run = titleParagraph.createRun();
|
XWPFRun run = titleParagraph.createRun();
|
||||||
run.setText("表");
|
run.setText("表" + chapter + " - ");
|
||||||
// 设置标题样式
|
// 设置标题样式
|
||||||
run.setFontFamily("Times New Roman");
|
run.setFontFamily("Times New Roman");
|
||||||
run.setFontFamily("宋体", XWPFRun.FontCharRange.eastAsia);
|
run.setFontFamily("黑体", XWPFRun.FontCharRange.eastAsia);
|
||||||
run.setFontSize(12);
|
run.setFontSize(12);
|
||||||
CTRPr rPr0 = run.getCTR().isSetRPr() ? run.getCTR().getRPr() : run.getCTR().addNewRPr();
|
CTRPr rPr0 = run.getCTR().isSetRPr() ? run.getCTR().getRPr() : run.getCTR().addNewRPr();
|
||||||
rPr0.addNewSz().setVal(BigInteger.valueOf(21));
|
rPr0.addNewSz().setVal(BigInteger.valueOf(21));
|
||||||
|
@ -925,14 +938,14 @@ public class PmsProjectTestcaseServiceImpl implements IPmsProjectTestcaseService
|
||||||
|
|
||||||
// 创建域代码
|
// 创建域代码
|
||||||
XWPFRun codeRun = titleParagraph.createRun();
|
XWPFRun codeRun = titleParagraph.createRun();
|
||||||
String domainCode = " SEQ Table \\* ARABIC \\s " + chapter;
|
String domainCode = " SEQ Table \\* ARABIC \\s "; //+ chapter;
|
||||||
codeRun.setText(domainCode);
|
codeRun.setText(domainCode);
|
||||||
// 设置字体大小,可根据需要调整
|
// 设置字体大小,可根据需要调整
|
||||||
CTRPr rPr1 = codeRun.getCTR().isSetRPr() ? codeRun.getCTR().getRPr() : codeRun.getCTR().addNewRPr();
|
CTRPr rPr1 = codeRun.getCTR().isSetRPr() ? codeRun.getCTR().getRPr() : codeRun.getCTR().addNewRPr();
|
||||||
rPr1.addNewSz().setVal(BigInteger.valueOf(21));
|
rPr1.addNewSz().setVal(BigInteger.valueOf(21));
|
||||||
rPr1.addNewSzCs().setVal(BigInteger.valueOf(21));
|
rPr1.addNewSzCs().setVal(BigInteger.valueOf(21));
|
||||||
codeRun.setFontFamily("Times New Roman");
|
codeRun.setFontFamily("Times New Roman");
|
||||||
codeRun.setFontFamily("宋体", XWPFRun.FontCharRange.eastAsia);
|
codeRun.setFontFamily("黑体", XWPFRun.FontCharRange.eastAsia);
|
||||||
|
|
||||||
// 创建域分隔字符
|
// 创建域分隔字符
|
||||||
XWPFRun sepRun = titleParagraph.createRun();
|
XWPFRun sepRun = titleParagraph.createRun();
|
||||||
|
@ -945,13 +958,13 @@ public class PmsProjectTestcaseServiceImpl implements IPmsProjectTestcaseService
|
||||||
|
|
||||||
// 创建域结果
|
// 创建域结果
|
||||||
XWPFRun resultRun = titleParagraph.createRun();
|
XWPFRun resultRun = titleParagraph.createRun();
|
||||||
resultRun.setText(chapter + " - " + tableCount);
|
resultRun.setText(String.valueOf(tableCount));
|
||||||
// 设置字体大小,可根据需要调整
|
// 设置字体大小,可根据需要调整
|
||||||
CTRPr rPr3 = resultRun.getCTR().isSetRPr() ? resultRun.getCTR().getRPr() : resultRun.getCTR().addNewRPr();
|
CTRPr rPr3 = resultRun.getCTR().isSetRPr() ? resultRun.getCTR().getRPr() : resultRun.getCTR().addNewRPr();
|
||||||
rPr3.addNewSz().setVal(BigInteger.valueOf(21));
|
rPr3.addNewSz().setVal(BigInteger.valueOf(21));
|
||||||
rPr3.addNewSzCs().setVal(BigInteger.valueOf(21));
|
rPr3.addNewSzCs().setVal(BigInteger.valueOf(21));
|
||||||
resultRun.setFontFamily("Times New Roman");
|
resultRun.setFontFamily("Times New Roman");
|
||||||
resultRun.setFontFamily("宋体", XWPFRun.FontCharRange.eastAsia);
|
resultRun.setFontFamily("黑体", XWPFRun.FontCharRange.eastAsia);
|
||||||
|
|
||||||
// 创建域结束字符
|
// 创建域结束字符
|
||||||
XWPFRun endRun = titleParagraph.createRun();
|
XWPFRun endRun = titleParagraph.createRun();
|
||||||
|
@ -965,7 +978,7 @@ public class PmsProjectTestcaseServiceImpl implements IPmsProjectTestcaseService
|
||||||
rPr4.addNewSz().setVal(BigInteger.valueOf(21));
|
rPr4.addNewSz().setVal(BigInteger.valueOf(21));
|
||||||
rPr4.addNewSzCs().setVal(BigInteger.valueOf(21));
|
rPr4.addNewSzCs().setVal(BigInteger.valueOf(21));
|
||||||
titlerun.setFontFamily("Times New Roman");
|
titlerun.setFontFamily("Times New Roman");
|
||||||
titlerun.setFontFamily("宋体", XWPFRun.FontCharRange.eastAsia);
|
titlerun.setFontFamily("黑体", XWPFRun.FontCharRange.eastAsia);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1614,9 +1627,13 @@ public class PmsProjectTestcaseServiceImpl implements IPmsProjectTestcaseService
|
||||||
testcaseStep.setExpectedResult(getTableCellValue(tableRows, i, 2));
|
testcaseStep.setExpectedResult(getTableCellValue(tableRows, i, 2));
|
||||||
testcaseSteps.add(testcaseStep);
|
testcaseSteps.add(testcaseStep);
|
||||||
} else {
|
} else {
|
||||||
testcase.setCreateBy(getTableCellValue(tableRows, i, 1));
|
testcase.setCreateBy(SecurityUtils.getUsername());
|
||||||
Date date = stringToDateUsingDateTimeFormatter(getTableCellValue(tableRows, i , 3), "yyyy-MM-dd");
|
try{
|
||||||
testcase.setCreateTime(date);
|
Date date = stringToDateUsingDateTimeFormatter(getTableCellValue(tableRows, i , 3), "yyyy-MM-dd");
|
||||||
|
testcase.setCreateTime(date);
|
||||||
|
} catch (DateTimeException e) {
|
||||||
|
throw new ServiceException("日期解析失败,请按模板格式填写设计日期");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue