1.解决pq公共方法查询监测点信息,母线,终端等信息
2.解决device模块swagger页面出不来问题 3.技术监督变电站台账接口增加 4.监测点试运行报告增加,间谐波电压和暂态列表
This commit is contained in:
@@ -26,7 +26,7 @@ public class WordUtil2 {
|
||||
private final FileStorageUtil fileStorageUtil;
|
||||
|
||||
|
||||
public void getWord(String path, Map<String, Object> params, String fileName, HttpServletResponse response)
|
||||
public void getWord(String path, Map<String, Object> params, String fileName,List<List<String[]>> tableList, HttpServletResponse response)
|
||||
throws Exception {
|
||||
path = ClearPathUtil.cleanString(path);
|
||||
InputStream inStream = null;
|
||||
@@ -35,7 +35,12 @@ public class WordUtil2 {
|
||||
try {
|
||||
inStream = new ClassPathResource(path).getInputStream();;
|
||||
doc = new CustomXWPFDocument(inStream);
|
||||
this.replaceInTable(doc, params); // 替换表格里面的变量
|
||||
if(CollUtil.isNotEmpty(tableList)){
|
||||
this.replaceInTable(doc, params,tableList);
|
||||
}else{
|
||||
this.replaceInTable(doc, params);
|
||||
}
|
||||
// 替换表格里面的变量
|
||||
this.replaceInPara(doc, params); // 替换文本里面的变量
|
||||
} catch (IOException e) {
|
||||
getError("获取报告模板异常,原因为:" + e);
|
||||
@@ -96,7 +101,7 @@ public class WordUtil2 {
|
||||
|
||||
|
||||
|
||||
public String getReportFileUrl(String path,String fileName, Map<String, Object> params)
|
||||
public String getReportFileUrl(String path,String fileName,List<List<String[]>> tableList, Map<String, Object> params)
|
||||
throws Exception {
|
||||
path = ClearPathUtil.cleanString(path);
|
||||
InputStream inStream = null,in = null;
|
||||
@@ -105,9 +110,12 @@ public class WordUtil2 {
|
||||
try {
|
||||
inStream = new ClassPathResource(path).getInputStream();;
|
||||
doc = new CustomXWPFDocument(inStream);
|
||||
this.replaceInTable(doc, params); // 替换表格里面的变量
|
||||
if(CollUtil.isNotEmpty(tableList)){
|
||||
this.replaceInTable(doc, params,tableList);
|
||||
}else{
|
||||
this.replaceInTable(doc, params);
|
||||
}
|
||||
this.replaceInPara(doc, params); // 替换文本里面的变量
|
||||
|
||||
//临时缓冲区
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
doc.write(out);
|
||||
@@ -299,9 +307,14 @@ public class WordUtil2 {
|
||||
XWPFTableRow row = table.createRow();
|
||||
List<XWPFTableCell> cells = row.getTableCells();
|
||||
for (int j = 0; j < cells.size(); j++) {
|
||||
XWPFTableCell cell = cells.get(j);
|
||||
String s = tableList.get(i)[j];
|
||||
cell.setText(s);
|
||||
XWPFTableCell cell = cells.get(j);
|
||||
cell.removeParagraph(0);
|
||||
XWPFParagraph paragraph = cell.addParagraph();
|
||||
paragraph.setAlignment(ParagraphAlignment.CENTER);
|
||||
// 在段落中添加文本
|
||||
XWPFRun run = paragraph.createRun();
|
||||
run.setText(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -325,7 +338,7 @@ public class WordUtil2 {
|
||||
table = iterator.next();
|
||||
if (table.getRows().size() > 1) {
|
||||
// 判断表格是需要替换还是需要插入,判断逻辑有$为替换,表格无$为插入
|
||||
if (this.matcher(table.getText()).find()) {
|
||||
if (this.matcher(table.getText()).find()||this.matcherS(table.getText()).find()) {
|
||||
rows = table.getRows();
|
||||
for (XWPFTableRow row : rows) {
|
||||
cells = row.getTableCells();
|
||||
@@ -334,8 +347,10 @@ public class WordUtil2 {
|
||||
processParagraphs(paragraphListTable, params, doc);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
insertTable(table, tableList.get(num)); // 插入数据
|
||||
}else {
|
||||
if (CollUtil.isNotEmpty(tableList.get(num))){
|
||||
insertTable(table, tableList.get(num)); // 插入数据
|
||||
}
|
||||
num++;
|
||||
}
|
||||
}
|
||||
@@ -353,6 +368,11 @@ public class WordUtil2 {
|
||||
Matcher matcher = pattern.matcher(str);
|
||||
return matcher;
|
||||
}
|
||||
private Matcher matcherS(String str) {
|
||||
Pattern pattern = Pattern.compile("\\$(.*?)\\$");
|
||||
Matcher matcher = pattern.matcher(str);
|
||||
return matcher;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据图片类型,取得对应的图片类型代码
|
||||
|
||||
Reference in New Issue
Block a user