|
@@ -1,20 +1,16 @@
|
|
|
package cn.cslg.report.service.business;
|
|
|
|
|
|
-import cn.cslg.report.common.model.dto.invalidReReport.InvalidReasonDTO;
|
|
|
import cn.cslg.report.common.model.dto.invalidReReport.InvalidReasonFieldValueDTO;
|
|
|
import cn.cslg.report.common.model.vo.PersonnelVO;
|
|
|
-import cn.cslg.report.common.model.vo.invalidReReport.ExportInvalidReasonVO;
|
|
|
+
|
|
|
import cn.cslg.report.common.model.vo.invalidReReport.QueryInvalidReasonVO;
|
|
|
-import cn.cslg.report.common.utils.CacheUtils;
|
|
|
-import cn.cslg.report.common.utils.FileUtils;
|
|
|
-import cn.cslg.report.common.utils.Response;
|
|
|
+import cn.cslg.report.common.utils.*;
|
|
|
import cn.cslg.report.common.utils.SecurityUtils.LoginUtils;
|
|
|
-import cn.cslg.report.common.utils.WordUtil;
|
|
|
+import cn.cslg.report.entity.Report;
|
|
|
import cn.cslg.report.entity.ReportDocument;
|
|
|
import cn.cslg.report.entity.invalidReReport.InvalidReasonField;
|
|
|
import cn.cslg.report.service.business.InvalidReReport.InvalidReasonFieldService;
|
|
|
import cn.cslg.report.service.business.InvalidReReport.InvalidReasonService;
|
|
|
-import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.deepoove.poi.XWPFTemplate;
|
|
@@ -22,9 +18,6 @@ import com.deepoove.poi.config.Configure;
|
|
|
import com.deepoove.poi.config.ConfigureBuilder;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
-import org.apache.poi.ss.usermodel.*;
|
|
|
-import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.apache.poi.xwpf.usermodel.*;
|
|
|
import org.ddr.poi.html.HtmlRenderPolicy;
|
|
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.*;
|
|
@@ -39,6 +32,8 @@ import java.math.BigInteger;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
+import static cn.cslg.report.common.utils.StringUtils.join;
|
|
|
+
|
|
|
/**
|
|
|
* 导出无效理由实现类
|
|
|
*
|
|
@@ -54,11 +49,15 @@ public class ExportArgumentsScenariosService {
|
|
|
private final FileUtils fileUtils;
|
|
|
private final CacheUtils cacheUtils;
|
|
|
private final LoginUtils loginUtils;
|
|
|
+ private final ReportService reportService;
|
|
|
public String ExportToWord(Integer reportId) throws IOException {
|
|
|
+
|
|
|
+ //根据报告id查询报告
|
|
|
+ Report report =reportService.getById(reportId);
|
|
|
String templeName = IdUtil.simpleUUID() + ".docx";
|
|
|
String directoryName = fileUtils.createDirectory();
|
|
|
//富文本栏位计数器
|
|
|
- int nameCount=0;
|
|
|
+ int nameCount = 0;
|
|
|
Map<String, Object> map1 = new HashMap<>();
|
|
|
XWPFDocument doc = new XWPFDocument();
|
|
|
doc.createStyles();
|
|
@@ -91,20 +90,24 @@ public class ExportArgumentsScenariosService {
|
|
|
//根据无效类型排序,方便合并单元格
|
|
|
queryInvalidReasonVOS.sort(Comparator.comparing(QueryInvalidReasonVO::getInvalidName));
|
|
|
//设置标题
|
|
|
- WordUtil.setParagraph(doc, "标题", "宋体", 16, 10, true, ParagraphAlignment.CENTER);
|
|
|
+ WordUtil.setParagraph(doc, report.getName()+"无效理由", "宋体", 16, 10, true, ParagraphAlignment.CENTER);
|
|
|
//设置副标题
|
|
|
- WordUtil.setParagraph(doc,"生成时间:"+new Date().toString() , "宋体", 10, 10, true, ParagraphAlignment.RIGHT);
|
|
|
+ WordUtil.setParagraph(doc, "生成时间:" + new Date().toString(), "宋体", 10, 10, true, ParagraphAlignment.RIGHT);
|
|
|
int colTotalCount = fields.size() + 5;
|
|
|
//总条数
|
|
|
int dataCount = queryInvalidReasonVOS.size();
|
|
|
//创建表格
|
|
|
XWPFTable xTable = doc.createTable(1, colTotalCount);
|
|
|
+ CTTblPr tblPr =xTable.getCTTbl().addNewTblPr();
|
|
|
+ tblPr.addNewJc().setVal(STJc.CENTER);
|
|
|
//设置边框
|
|
|
WordUtil.setTableBolder(xTable, 10, "000000");
|
|
|
// 创建表头数据
|
|
|
for (int j = 0; j < colTotalCount; j++) {
|
|
|
- WordUtil.setCellText(xTable.getRow(0).getCell(j), nameList.get(j), 200, "宋体", 10, true);
|
|
|
+ WordUtil.setCellText(xTable.getRow(0).getCell(j), nameList.get(j), 1200, "宋体", 10, true);
|
|
|
}
|
|
|
+ //记录对比文件文件内容map
|
|
|
+ Map<Integer,String> fileMap = new TreeMap<>();
|
|
|
//记录合并数据map
|
|
|
Map<Integer, Integer> map = new HashMap<>();
|
|
|
// 创建表格内容
|
|
@@ -119,15 +122,12 @@ public class ExportArgumentsScenariosService {
|
|
|
}
|
|
|
List<InvalidReasonFieldValueDTO> fieldValueDTOS = queryInvalidReasonVO.getFields();
|
|
|
XWPFTableRow row = xTable.insertNewTableRow(i2 + 1);
|
|
|
- row.setHeight(300);
|
|
|
for (int j = 0; j < colTotalCount; j++) {
|
|
|
XWPFTableCell cell = row.createCell();
|
|
|
XWPFRun run;
|
|
|
- run = WordUtil.setTableCellStyle(cell, ParagraphAlignment.CENTER, "微软雅黑", 9, false);
|
|
|
- String aa=run.getStyle();
|
|
|
- System.out.println(aa);
|
|
|
+ run = WordUtil.setTableCellStyle(cell, "1200", ParagraphAlignment.CENTER, "微软雅黑", 9, false);
|
|
|
if (j == 0) {
|
|
|
- run.setText(String.valueOf(i2));
|
|
|
+ run.setText(String.valueOf(i2 + 1));
|
|
|
} else if (j == 1) {
|
|
|
if (name == 0) {
|
|
|
run.setText("权利要求不清楚");
|
|
@@ -143,9 +143,11 @@ public class ExportArgumentsScenariosService {
|
|
|
if (content == -1) {
|
|
|
run.setText("说明书");
|
|
|
} else {
|
|
|
- run.setText("权要" + content);
|
|
|
+ run.setText("权要" + (content + 1));
|
|
|
}
|
|
|
- } else if (j == 3) {
|
|
|
+ }
|
|
|
+ //
|
|
|
+ else if (j == 3) {
|
|
|
if (name == 0 || name == 1) {
|
|
|
run.setText(queryInvalidReasonVO.getProofStr());
|
|
|
} else {
|
|
@@ -153,33 +155,58 @@ public class ExportArgumentsScenariosService {
|
|
|
List<QueryInvalidReasonVO.proofGroupIn> proofGroupIns = queryInvalidReasonVO.getProofGroups();
|
|
|
for (int t = 0; t < proofGroupIns.size(); t++) {
|
|
|
List<QueryInvalidReasonVO.proofIn> proofIns = proofGroupIns.get(t).getProofs();
|
|
|
- List<Integer> strs = proofIns.stream().map(QueryInvalidReasonVO.proofIn::getSort).collect(Collectors.toList());
|
|
|
- for (int i = 0; i < strs.size(); i++) {
|
|
|
+ for (int i = 0; i < proofIns.size(); i++) {
|
|
|
+ QueryInvalidReasonVO.proofIn proofIn =proofIns.get(i);
|
|
|
+ //生成对比文件组合名称
|
|
|
if (t == 0 && i == 0) {
|
|
|
- stringBuilder.append("D" + strs.get(i));
|
|
|
+ stringBuilder.append("D" +proofIn.getSort());
|
|
|
|
|
|
} else if (t != 0 && i == 0) {
|
|
|
- stringBuilder.append(" D" + strs.get(i));
|
|
|
+ stringBuilder.append(" D" + proofIn.getSort());
|
|
|
} else {
|
|
|
- stringBuilder.append("+D" + strs.get(i));
|
|
|
+ stringBuilder.append("+D" + proofIn.getSort());
|
|
|
+ }
|
|
|
+ //记录对比文件名称字典
|
|
|
+ if(fileMap.get(proofIn.getSort())==null){
|
|
|
+ fileMap.put(proofIn.getSort(),proofIn.getFileName());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
run.setText(stringBuilder.toString());
|
|
|
}
|
|
|
} else if (j == 4) {
|
|
|
- map1.put("argument"+nameCount,queryInvalidReasonVO.getArgumentStr());
|
|
|
- run.setText("{{argument"+nameCount+"}}");
|
|
|
- nameCount=nameCount+1;
|
|
|
+ map1.put("argument" + nameCount, queryInvalidReasonVO.getArgumentStr());
|
|
|
+ run.setText("{{argument" + nameCount + "}}");
|
|
|
+ nameCount = nameCount + 1;
|
|
|
} else {
|
|
|
InvalidReasonField field = fields.get(j - 5);
|
|
|
InvalidReasonFieldValueDTO valueDTO = fieldValueDTOS.stream().filter(item -> item.getFieldId().equals(field.getId())).findFirst().orElse(new InvalidReasonFieldValueDTO());
|
|
|
- map1.put(valueDTO.getFieldKey()+nameCount,valueDTO.getFieldValue());
|
|
|
- run.setText("{{"+valueDTO.getFieldKey()+nameCount+"}}");
|
|
|
- nameCount=nameCount+1;
|
|
|
+ map1.put(valueDTO.getFieldKey() + nameCount, valueDTO.getFieldValue());
|
|
|
+ run.setText("{{" + valueDTO.getFieldKey() + nameCount + "}}");
|
|
|
+ nameCount = nameCount + 1;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ //添加文件说明行
|
|
|
+ XWPFTableRow row = xTable.insertNewTableRow(dataCount + 1);
|
|
|
+ XWPFTableCell cell = row.createCell();
|
|
|
+ XWPFRun run;
|
|
|
+ run = WordUtil.setTableCellStyle(cell, "1200", ParagraphAlignment.CENTER, "微软雅黑", 9, false);
|
|
|
+ List<String> fileNames =new ArrayList<>();
|
|
|
+ for(Integer key:fileMap.keySet()){
|
|
|
+ fileNames.add("D"+key+"是"+ fileMap.get(key));
|
|
|
+ }
|
|
|
+ String fileText = StringUtils.join(fileNames, ",");
|
|
|
+ run.setText(fileText);
|
|
|
+ for(Integer p=0;p<colTotalCount-1;p++){
|
|
|
+ XWPFTableCell cellTem = row.createCell();
|
|
|
+ XWPFRun runTem;
|
|
|
+ runTem = WordUtil.setTableCellStyle(cellTem, "1200", ParagraphAlignment.CENTER, "微软雅黑", 9, false);
|
|
|
+ }
|
|
|
+ WordUtil.mergeCellsHorizontal(xTable,dataCount + 1,0,colTotalCount-1);
|
|
|
//记录合并起始位置
|
|
|
Integer t = 1;
|
|
|
for (int i : map.keySet()) {
|
|
@@ -194,13 +221,12 @@ public class ExportArgumentsScenariosService {
|
|
|
doc.close();
|
|
|
HtmlRenderPolicy htmlRenderPolicy = new HtmlRenderPolicy();
|
|
|
// 将bz设置为行循环绑定的数据源的key,即key是bz的value会在模板中的{{bz}}处进行解析
|
|
|
- ConfigureBuilder configureBuilder= Configure.builder();
|
|
|
- for (String key:map1.keySet())
|
|
|
- {
|
|
|
- configureBuilder=configureBuilder.bind(key,htmlRenderPolicy);
|
|
|
+ ConfigureBuilder configureBuilder = Configure.builder();
|
|
|
+ for (String key : map1.keySet()) {
|
|
|
+ configureBuilder = configureBuilder.bind(key, htmlRenderPolicy);
|
|
|
}
|
|
|
- Configure configure=configureBuilder.build();
|
|
|
- XWPFTemplate template = XWPFTemplate.compile("D:\\RMS\\output.docx", configure).render(map1);
|
|
|
+ Configure configure = configureBuilder.build();
|
|
|
+ XWPFTemplate template = XWPFTemplate.compile(templePath, configure).render(map1);
|
|
|
String fileName = IdUtil.simpleUUID() + ".docx";
|
|
|
String outPath = fileUtils.getSavePath(directoryName) + fileName;
|
|
|
template.writeToFile(outPath);
|