1
This commit is contained in:
7
pom.xml
7
pom.xml
@@ -67,6 +67,11 @@
|
||||
<artifactId>poi</artifactId>
|
||||
<version>4.1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.draco1023</groupId>
|
||||
<artifactId>poi-tl-ext</artifactId>
|
||||
<version>0.4.24</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
@@ -92,7 +97,7 @@
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.47</version>
|
||||
<version>1.2.83</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
|
||||
@@ -231,19 +231,19 @@ public class XWPFHelperTable {
|
||||
/**
|
||||
* @Description: 设置表格总宽度与水平对齐方式
|
||||
*/
|
||||
public void setTableWidthAndHAlign(XWPFTable table, String width,
|
||||
STJc.Enum enumValue) {
|
||||
CTTblPr tblPr = getTableCTTblPr(table);
|
||||
// 表格宽度
|
||||
CTTblWidth tblWidth = tblPr.isSetTblW() ? tblPr.getTblW() : tblPr.addNewTblW();
|
||||
if (enumValue != null) {
|
||||
CTJc cTJc = tblPr.addNewJc();
|
||||
cTJc.setVal(enumValue);
|
||||
}
|
||||
// 设置宽度
|
||||
tblWidth.setW(new BigInteger(width));
|
||||
tblWidth.setType(STTblWidth.DXA);
|
||||
}
|
||||
// public void setTableWidthAndHAlign(XWPFTable table, String width,
|
||||
// STJc.Enum enumValue) {
|
||||
// CTTblPr tblPr = getTableCTTblPr(table);
|
||||
// // 表格宽度
|
||||
// CTTblWidth tblWidth = tblPr.isSetTblW() ? tblPr.getTblW() : tblPr.addNewTblW();
|
||||
// if (enumValue != null) {
|
||||
// CTJc cTJc = tblPr.addNewJc();
|
||||
// cTJc.setVal(enumValue);
|
||||
// }
|
||||
// // 设置宽度
|
||||
// tblWidth.setW(new BigInteger(width));
|
||||
// tblWidth.setType(STTblWidth.DXA);
|
||||
// }
|
||||
|
||||
/**
|
||||
* @Description: 得到Table的CTTblPr,不存在则新建
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.openxml4j.util.ZipSecureFile;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
import org.apache.poi.xwpf.usermodel.*;
|
||||
import org.ddr.poi.html.HtmlRenderPolicy;
|
||||
import org.freehep.graphicsio.emf.EMFHeader;
|
||||
import org.freehep.graphicsio.emf.EMFInputStream;
|
||||
import org.freehep.graphicsio.emf.EMFRenderer;
|
||||
@@ -211,11 +212,13 @@ public class TypesetController {
|
||||
@ApiOperation(value = "读取文件")
|
||||
@PostMapping("readdoc")
|
||||
public ReturnValue myDocReader(String filename) {
|
||||
System.out.println(filename);
|
||||
ArrayList al = new ArrayList();
|
||||
try {
|
||||
File file = new File(this.BASE_DIR + filename);
|
||||
FileInputStream fis = new FileInputStream(file);
|
||||
XWPFDocument xdoc = new XWPFDocument(fis);
|
||||
|
||||
List<XWPFParagraph> list = xdoc.getParagraphs();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
String cache = "";
|
||||
@@ -746,6 +749,7 @@ public class TypesetController {
|
||||
HashMap hashMap = new HashMap();
|
||||
Style style = new Style();
|
||||
style.setColor("0070C0");
|
||||
style.setVertAlign("superscript");
|
||||
TextRenderData textRenderData = new TextRenderData(m.get("k"), style);
|
||||
hashMap.put("k",textRenderData);
|
||||
hashMap.put("c",m.get("content"));
|
||||
@@ -774,15 +778,24 @@ public class TypesetController {
|
||||
map.put("abbreviation", typesetInfo.getAbbreviation());
|
||||
map.put("citation", (typesetInfo.getLittle_author() + ". " + typesetInfo.getInfo_title() + ". " + typesetInfo.getJabbr() + ". " + typesetInfo.getStage() + ". doi: 10.53388/" + typesetInfo.getDoi() + ".").replace("<b>", "").replace("</b>", "").replace("<i>", "").replace("</i>", ""));
|
||||
map.put("exeditor", typesetInfo.getUserAccount());
|
||||
if(typesetInfo.isHas_more()){
|
||||
MyParagraphRenderData hasmore_prd = crowStrNew("<blue><sup>#</sup></blue>These authors contributed equally to this work and are co-first authors for this paper.", tableDatas, imageDatas);
|
||||
map.put("hasmore",hasmore_prd);
|
||||
}
|
||||
map.put("received_date", typesetInfo.getReceived_date());
|
||||
map.put("accept_date", typesetInfo.getAccepted_date());
|
||||
ParagraphRenderData accept_p = new ParagraphRenderData();
|
||||
accept_p.addText(new TextRenderData("XXX",doi_s));
|
||||
// map.put("accept_date", typesetInfo.getAccepted_date());
|
||||
map.put("accept_date",accept_p);
|
||||
ParagraphRenderData od_p = new ParagraphRenderData();
|
||||
od_p.addText(new TextRenderData("input online_date", doi_s));
|
||||
map.put("online_date", od_p);
|
||||
map.put("ye", typesetInfo.getStage().substring(0, 4));
|
||||
ParagraphRenderData abstract_p = new ParagraphRenderData();
|
||||
abstract_p.addText(new TextRenderData(typesetInfo.getAbstractText()));
|
||||
// ParagraphRenderData abstract_p = new ParagraphRenderData();
|
||||
// abstract_p.addText(new TextRenderData(typesetInfo.getAbstractText()));
|
||||
MyParagraphRenderData abstract_p = crowStrNew(typesetInfo.getAbstractText(), tableDatas, imageDatas);
|
||||
map.put("abstract",abstract_p);
|
||||
// map.put("abstract",typesetInfo.getAbstractText());
|
||||
map.put("keywords", typesetInfo.getKeywords().replace("<b>", "").replace("</b>", ""));
|
||||
|
||||
//主体部分
|
||||
@@ -867,10 +880,22 @@ public class TypesetController {
|
||||
mainArr.add(hashMap1);
|
||||
otherNum++;
|
||||
}else{
|
||||
if(s.contains("<tr>")){
|
||||
HashMap hashMap = new HashMap();
|
||||
ParagraphRenderData paragraphRenderData = crowStrNew("",typesetInfo.getTables(),typesetInfo.getImages());
|
||||
hashMap.put("content",paragraphRenderData);
|
||||
mainArr.add(hashMap);
|
||||
}
|
||||
Map cache = new HashMap();
|
||||
MyParagraphRenderData capd = crowStrNew(s,typesetInfo.getTables(),typesetInfo.getImages());
|
||||
cache.put("content", capd);
|
||||
mainArr.add(cache);
|
||||
if(s.contains("<tr>")){
|
||||
HashMap hashMap = new HashMap();
|
||||
ParagraphRenderData paragraphRenderData = crowStrNew("",typesetInfo.getTables(),typesetInfo.getImages());
|
||||
hashMap.put("content",paragraphRenderData);
|
||||
mainArr.add(hashMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
map.put("main", mainArr);
|
||||
@@ -951,6 +976,7 @@ public class TypesetController {
|
||||
Configure config = Configure.builder().bind("content", new MyContentPolicy()).bind("data",new MyContentPolicy())
|
||||
.bind("abstract", new ParagraphRenderPolicy()).bind("author", new ParagraphRenderPolicy())
|
||||
.bind("doi", new ParagraphRenderPolicy()).bind("online_date", new ParagraphRenderPolicy())
|
||||
.bind("accept_date",new ParagraphRenderPolicy()).bind("hasmore",new ParagraphRenderPolicy())
|
||||
.bind("peer", new ParagraphRenderPolicy())
|
||||
.build();
|
||||
XWPFTemplate template = XWPFTemplate.compile(this.BASE_DIR + myTemplate, config).render(map);
|
||||
@@ -1723,14 +1749,24 @@ public class TypesetController {
|
||||
if(s.isEmpty()){
|
||||
p.addText(s);
|
||||
}else{
|
||||
textRenderCreate(s,p);
|
||||
}
|
||||
if(s.contains("<tr>")) {
|
||||
ParagraphStyle paragraphStyle = new ParagraphStyle();
|
||||
paragraphStyle.setAlign(ParagraphAlignment.CENTER);
|
||||
paragraphStyle.setBackgroundColor("DEEBF7");
|
||||
paragraphStyle.setSpacing(1.1);
|
||||
p.setParagraphStyle(paragraphStyle);
|
||||
if(s.contains("<tr>")){
|
||||
textRenderCreate(s,p);
|
||||
ParagraphStyle paragraphStyle = new ParagraphStyle();
|
||||
paragraphStyle.setAlign(ParagraphAlignment.CENTER);
|
||||
paragraphStyle.setBackgroundColor("DEEBF7");
|
||||
paragraphStyle.setSpacing(1.1);
|
||||
p.setParagraphStyle(paragraphStyle);
|
||||
}else{
|
||||
if(s.contains("<nbsp/>")){
|
||||
s = s.replace("<nbsp/>","");
|
||||
ParagraphStyle paragraphStyle = new ParagraphStyle();
|
||||
paragraphStyle.setIndentFirstLineChars(Double.valueOf("1"));
|
||||
p.setParagraphStyle(paragraphStyle);
|
||||
}
|
||||
|
||||
|
||||
textRenderCreate(s,p);
|
||||
}
|
||||
}
|
||||
return p;
|
||||
|
||||
|
||||
@@ -73,6 +73,9 @@ public class TypesetInfo implements Serializable {
|
||||
|
||||
private String author_str;
|
||||
|
||||
//有多个第一作者
|
||||
private boolean has_more;
|
||||
|
||||
|
||||
private List<Map<String,String>> authorAddressList;
|
||||
|
||||
@@ -361,6 +364,18 @@ public class TypesetInfo implements Serializable {
|
||||
this.abbreviation = abbreviation;
|
||||
}
|
||||
|
||||
public boolean isHas_more() {
|
||||
return has_more;
|
||||
}
|
||||
|
||||
public void setHas_more(boolean has_more) {
|
||||
this.has_more = has_more;
|
||||
}
|
||||
|
||||
public void setTables(Map<Integer, Map<String, String>> tables) {
|
||||
this.tables = tables;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TypesetInfo{" +
|
||||
@@ -393,6 +408,8 @@ public class TypesetInfo implements Serializable {
|
||||
", refers='" + refers + '\'' +
|
||||
", info_state=" + info_state +
|
||||
", userAccount='" + userAccount + '\'' +
|
||||
", author_str='" + author_str + '\'' +
|
||||
", has_more=" + has_more +
|
||||
", authorAddressList=" + authorAddressList +
|
||||
", images=" + images +
|
||||
", tables=" + tables +
|
||||
|
||||
Reference in New Issue
Block a user