1
This commit is contained in:
@@ -3,7 +3,8 @@ package com.example.ts_obj.bean;
|
||||
public enum ReturnCodeAndMsgEnum {
|
||||
Success(0, "ok"),
|
||||
No_Data(10001, "no data"),
|
||||
SYSTEM_ERROR(10004, "system error");
|
||||
SYSTEM_ERROR(10004, "system error"),
|
||||
SYSTEM_STOP(10005,"Service Stop");
|
||||
|
||||
private String msg;
|
||||
private int code;
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.example.ts_obj.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.example.ts_obj.Util.*;
|
||||
import com.example.ts_obj.entity.*;
|
||||
import com.spire.doc.*;
|
||||
import com.spire.doc.Document;
|
||||
import com.spire.doc.collections.CellCollection;
|
||||
@@ -18,10 +20,6 @@ import com.deepoove.poi.data.style.Style;
|
||||
import com.deepoove.poi.policy.ParagraphRenderPolicy;
|
||||
import com.example.ts_obj.bean.ReturnCodeAndMsgEnum;
|
||||
import com.example.ts_obj.bean.ReturnValue;
|
||||
import com.example.ts_obj.entity.Typeset;
|
||||
import com.example.ts_obj.entity.TypesetInfo;
|
||||
import com.example.ts_obj.entity.TypesetInfoReference;
|
||||
import com.example.ts_obj.entity.User;
|
||||
import com.example.ts_obj.service.TypesetService;
|
||||
import com.example.ts_obj.service.UserService;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -274,6 +272,27 @@ public class TypesetController {
|
||||
return new ReturnValue(ReturnCodeAndMsgEnum.Success, al);
|
||||
}
|
||||
|
||||
@PostMapping("/readPic")
|
||||
public ReturnValue readPicNum(String fileRoute, HttpServletRequest request, HttpServletResponse response){
|
||||
Integer num = 0;
|
||||
Integer table_num = 0;
|
||||
Map<String,Integer> m = new HashMap();
|
||||
try {
|
||||
InputStream inputStream = FileDownloadUtil.getInputStream(fileRoute);
|
||||
XWPFDocument xdoc = new XWPFDocument(inputStream);
|
||||
List<XWPFPictureData> allPictures = xdoc.getAllPictures();
|
||||
List<XWPFTable> tables = xdoc.getTables();
|
||||
num = allPictures.size();
|
||||
table_num =tables.size();
|
||||
m.put("pic",num);
|
||||
m.put("table",table_num);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return new ReturnValue(ReturnCodeAndMsgEnum.Success,m);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/mytest")
|
||||
public ReturnValue mytest(Long typesetId) {
|
||||
@@ -427,6 +446,39 @@ public class TypesetController {
|
||||
return new ReturnValue(ReturnCodeAndMsgEnum.Success, frag);
|
||||
}
|
||||
|
||||
@ApiOperation(value="ceshi")
|
||||
@PostMapping("/webtest")
|
||||
public ReturnValue webtest(@RequestBody TypesetInfo typesetInfo){
|
||||
JSONArray ja = (JSONArray) JSON.parse(typesetInfo.getRefers());
|
||||
List<ParagraphRenderData> refsl = new ArrayList<ParagraphRenderData>();
|
||||
for (Object tif : ja) {
|
||||
JSONObject a = (JSONObject) tif;
|
||||
System.out.println(a.getString("author"));
|
||||
// String tttt = String.valueOf(tif).replace("<b>", "").replace("</b>", "").replace("<i>", "").replace("</i>", "").trim().toUpperCase();
|
||||
// ParagraphRenderData chc_pd = new ParagraphRenderData();
|
||||
//
|
||||
// String tgh_title = String.valueOf(tif).replace("<b>", "").replace("</b>", "").replace("<i>", "").replace("</i>", "");
|
||||
//
|
||||
// String[] split = tgh_title.split("\n");
|
||||
//
|
||||
// Style chch = new Style();
|
||||
// chch.setFontFamily("Charis SIL");
|
||||
// chch.setFontSize(7.5);
|
||||
// chc_pd.addText(new TextRenderData(split[0], chch));
|
||||
//
|
||||
// if(split.length>1){
|
||||
// chc_pd.addText("\n");
|
||||
// Style lstitle = new Style();
|
||||
// lstitle.setFontFamily("Charis SIL");
|
||||
// lstitle.setFontSize(7.5);
|
||||
// lstitle.setColor("0082AA");
|
||||
// chc_pd.addText(new TextRenderData(split[1],lstitle));
|
||||
// }
|
||||
// refsl.add(chc_pd);
|
||||
}
|
||||
return new ReturnValue(ReturnCodeAndMsgEnum.Success);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "网上专用获取生成的docx")
|
||||
@PostMapping("/webGetDocx")
|
||||
public ReturnValue webGetDocx(@RequestBody TypesetInfo typesetInfo) throws IOException {
|
||||
@@ -436,8 +488,23 @@ public class TypesetController {
|
||||
map.put("type", typesetInfo.getInfo_type().toUpperCase());
|
||||
map.put("journaltitle", typesetInfo.getJournal());
|
||||
map.put("stage", typesetInfo.getStage());
|
||||
map.put("doi", typesetInfo.getDoi());
|
||||
//解决doi
|
||||
Style doi_s = new Style();
|
||||
doi_s.setColor("FF0000");
|
||||
ParagraphRenderData doi_p = new ParagraphRenderData();
|
||||
doi_p.addText(new TextRenderData("input doi",doi_s));
|
||||
map.put("doi", doi_p);
|
||||
// map.put("doi", typesetInfo.getDoi());
|
||||
map.put("topic", typesetInfo.getTopic());
|
||||
//peer
|
||||
ParagraphRenderData peer_p = new ParagraphRenderData();
|
||||
Style Italic_sty = new Style();
|
||||
Italic_sty.setItalic(true);
|
||||
peer_p.addText(new TextRenderData(typesetInfo.getJournal(),Italic_sty));
|
||||
peer_p.addText(" thanks all ");
|
||||
peer_p.addText(new TextRenderData("XXXXXXXXXXXXXXXX",doi_s));
|
||||
peer_p.addText("anonymous reviewers for their contribution to the peer review of this paper.");
|
||||
map.put("peer",peer_p);
|
||||
map.put("articletitle", typesetInfo.getInfo_title().replace("<b>", "").replace("</b>", "").replace("<i>", "").replace("</i>", ""));
|
||||
//解决作者小标问题
|
||||
String author = typesetInfo.getAuthor();
|
||||
@@ -457,7 +524,7 @@ public class TypesetController {
|
||||
author_p.addText(new TextRenderData(bu.replace("<i>", "").replace("</i>", ""), ca_sty));
|
||||
}
|
||||
if (i < s_author.length - 1) {
|
||||
author_p.addText(",");
|
||||
author_p.addText(", ");
|
||||
}
|
||||
}
|
||||
map.put("author", author_p);
|
||||
@@ -480,88 +547,35 @@ public class TypesetController {
|
||||
map.put("acknowledgment", map2);
|
||||
}
|
||||
map.put("abbreviation", typesetInfo.getAbbreviation());
|
||||
map.put("citation", (typesetInfo.getLittle_author() + ". " + typesetInfo.getInfo_title() + ". " + typesetInfo.getJabbr() + ". " + typesetInfo.getStage() + ". doi: " + typesetInfo.getDoi() + ".").replace("<b>", "").replace("</b>", "").replace("<i>", "").replace("</i>", ""));
|
||||
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());
|
||||
map.put("received_date", typesetInfo.getReceived_date());
|
||||
map.put("accept_date", typesetInfo.getAccepted_date());
|
||||
map.put("online_date", typesetInfo.getOnline_date());
|
||||
|
||||
ParagraphRenderData od_p = new ParagraphRenderData();
|
||||
od_p.addText(new TextRenderData("input online_date",doi_s));
|
||||
map.put("online_date", od_p);
|
||||
// map.put("online_date", typesetInfo.getOnline_date());
|
||||
map.put("ye", typesetInfo.getStage().substring(0, 4));
|
||||
map.put("abstract", this.crowStr(typesetInfo.getAbstractText()));
|
||||
|
||||
ParagraphRenderData abstract_p = new ParagraphRenderData();
|
||||
abstract_p.addText(new TextRenderData("input abstract",doi_s));
|
||||
map.put("abstract", abstract_p);
|
||||
// map.put("abstract", this.crowStr(typesetInfo.getAbstractText()));
|
||||
map.put("keywords", typesetInfo.getKeywords().replace("<b>", "").replace("</b>", ""));
|
||||
|
||||
InputStream inputStream = FileDownloadUtil.getInputStream(typesetInfo.getFilename());
|
||||
Document doc = new Document(inputStream);
|
||||
SectionCollection sections = doc.getSections();
|
||||
ArrayList<List> tablesList = new ArrayList<>();
|
||||
for (int i = 0; i < sections.getCount(); i++) {
|
||||
TableCollection tables = sections.get(i).getTables();
|
||||
for (int j = 0; j < tables.getCount(); j++) {
|
||||
ArrayList<Object> arrayList = new ArrayList<>();
|
||||
Table table = tables.get(j);
|
||||
//创建String List
|
||||
table.applyStyle(DefaultTableStyle.Table_Classic_1);
|
||||
List images = new ArrayList();
|
||||
//遍历表格中的行
|
||||
for (int l = 0; l < table.getRows().getCount(); l++) {
|
||||
ArrayList prList = new ArrayList();
|
||||
TableRow row = table.getRows().get(l);
|
||||
//遍历每行中的单元格
|
||||
for (int k = 0; k < row.getCells().getCount(); k++) {
|
||||
TableCell cell = row.getCells().get(k);
|
||||
//遍历单元格中的段落
|
||||
String myText = "";
|
||||
for (int n = 0; n < cell.getParagraphs().getCount(); n++) {
|
||||
Paragraph paragraph = cell.getParagraphs().get(n);
|
||||
myText += paragraph.getText();
|
||||
}
|
||||
prList.add(myText);
|
||||
}
|
||||
arrayList.add(prList);
|
||||
}
|
||||
tablesList.add(arrayList);
|
||||
}
|
||||
}
|
||||
int num = 0;
|
||||
int length = 0;
|
||||
if (tablesList.size() > 1) {
|
||||
for (List ls : tablesList
|
||||
) {
|
||||
List<Map> list = new ArrayList<>();
|
||||
LinkedHashMap<Object, Object> params = new LinkedHashMap<>();
|
||||
for (int i = 0; i < ls.size(); i++) {
|
||||
List o = (List) ls.get(i);
|
||||
List p = (List) ls.get(0);
|
||||
length = p.size();
|
||||
if (length != o.size()) {
|
||||
map.remove("table" + num);
|
||||
map.put("error", "table" + num + "格式错误");
|
||||
break;
|
||||
}
|
||||
if (i == 0) {
|
||||
for (int j = 0; j < o.size(); j++) {
|
||||
params.put(j, o.get(j));
|
||||
}
|
||||
list.add(params);
|
||||
} else {
|
||||
LinkedHashMap<Object, Object> hashMap = new LinkedHashMap<>();
|
||||
for (int j = 0; j < o.size(); j++) {
|
||||
String o1 = (String) o.get(j);
|
||||
hashMap.put(j, o1);
|
||||
}
|
||||
list.add(hashMap);
|
||||
}
|
||||
}
|
||||
num++;
|
||||
map.put("table" + num, list);
|
||||
}
|
||||
}
|
||||
Configure config = Configure.builder().bind("content", new ParagraphRenderPolicy())
|
||||
.bind("abstract", new ParagraphRenderPolicy()).bind("author", new ParagraphRenderPolicy())
|
||||
.bind("table1", new CustomTableRenderPolicy())
|
||||
.bind("table2", new CustomTableRenderPolicy()).bind("table3", new CustomTableRenderPolicy())
|
||||
.bind("table4", new CustomTableRenderPolicy()).bind("table5", new CustomTableRenderPolicy())
|
||||
.bind("table6", new CustomTableRenderPolicy()).bind("table7", new CustomTableRenderPolicy())
|
||||
.bind("table8", new CustomTableRenderPolicy()).bind("table9", new CustomTableRenderPolicy()).build();
|
||||
.bind("doi", new ParagraphRenderPolicy()).bind("online_date", new ParagraphRenderPolicy())
|
||||
.bind("peer", new ParagraphRenderPolicy())
|
||||
.build();
|
||||
// Configure config = Configure.builder().bind("content", new ParagraphRenderPolicy())
|
||||
// .bind("abstract", new ParagraphRenderPolicy()).bind("author", new ParagraphRenderPolicy())
|
||||
// .bind("table1", new CustomTableRenderPolicy())
|
||||
// .bind("table2", new CustomTableRenderPolicy()).bind("table3", new CustomTableRenderPolicy())
|
||||
// .bind("table4", new CustomTableRenderPolicy()).bind("table5", new CustomTableRenderPolicy())
|
||||
// .bind("table6", new CustomTableRenderPolicy()).bind("table7", new CustomTableRenderPolicy())
|
||||
// .bind("table8", new CustomTableRenderPolicy()).bind("table9", new CustomTableRenderPolicy()).build();
|
||||
String main = typesetInfo.getMainText();
|
||||
List<String> l = JSON.parseArray(main, String.class);
|
||||
ArrayList mainArr = new ArrayList();
|
||||
@@ -578,16 +592,46 @@ public class TypesetController {
|
||||
JSONArray ja = (JSONArray) JSON.parse(typesetInfo.getRefers());
|
||||
List<ParagraphRenderData> refsl = new ArrayList<ParagraphRenderData>();
|
||||
for (Object tif : ja) {
|
||||
String tttt = String.valueOf(tif).replace("<b>", "").replace("</b>", "").replace("<i>", "").replace("</i>", "").trim().toUpperCase();
|
||||
JSONObject a = (JSONObject) tif;
|
||||
// System.out.println(a.getString("author"));
|
||||
// String tttt = String.valueOf(tif).replace("<b>", "").replace("</b>", "").replace("<i>", "").replace("</i>", "").trim().toUpperCase();
|
||||
|
||||
if(!a.getString("title").isEmpty()){
|
||||
ParagraphRenderData chc_pdd = new ParagraphRenderData();
|
||||
Style chch = new Style();
|
||||
chch.setFontFamily("Charis SIL");
|
||||
chch.setFontSize(7.5);
|
||||
|
||||
Style cheche = new Style();
|
||||
cheche.setItalic(true);
|
||||
cheche.setFontFamily("Charis SIL");
|
||||
cheche.setFontSize(7.5);
|
||||
if(a.getString("is_ja").equals("0")){
|
||||
cheche.setColor("f98f36");
|
||||
}
|
||||
|
||||
Style lstitle = new Style();
|
||||
lstitle.setFontFamily("Charis SIL");
|
||||
lstitle.setFontSize(7.5);
|
||||
lstitle.setColor("0082AA");
|
||||
chc_pdd.addText(new TextRenderData(a.getString("author")+" ", chch));
|
||||
chc_pdd.addText(new TextRenderData(a.getString("title")+". ",chch));
|
||||
chc_pdd.addText(new TextRenderData(a.getString("joura")+" ",cheche));
|
||||
chc_pdd.addText(new TextRenderData(a.getString("dateno")+". Available at:",chch));
|
||||
chc_pdd.addText("\n");
|
||||
chc_pdd.addText(new TextRenderData(a.getString("doilink"),lstitle));
|
||||
refsl.add(chc_pdd);
|
||||
}else{
|
||||
ParagraphRenderData chc_pd = new ParagraphRenderData();
|
||||
|
||||
String tgh_title = String.valueOf(tif).replace("<b>", "").replace("</b>", "").replace("<i>", "").replace("</i>", "");
|
||||
|
||||
// String tgh_title = String.valueOf(tif).replace("<b>", "").replace("</b>", "").replace("<i>", "").replace("</i>", "");
|
||||
String tgh_title = a.getString("refer_frag").replace("<b>", "").replace("</b>", "").replace("<i>", "").replace("</i>", "");
|
||||
String[] split = tgh_title.split("\n");
|
||||
|
||||
Style chch = new Style();
|
||||
chch.setFontFamily("Charis SIL");
|
||||
chch.setFontSize(7.5);
|
||||
chch.setColor("f98f36");
|
||||
chc_pd.addText(new TextRenderData(split[0], chch));
|
||||
|
||||
if(split.length>1){
|
||||
@@ -599,6 +643,8 @@ public class TypesetController {
|
||||
chc_pd.addText(new TextRenderData(split[1],lstitle));
|
||||
}
|
||||
refsl.add(chc_pd);
|
||||
|
||||
}
|
||||
}
|
||||
map.put("refs", new NumberingRenderData(NumberingFormat.DECIMAL, refsl));
|
||||
|
||||
@@ -622,7 +668,8 @@ public class TypesetController {
|
||||
String goFileName = System.currentTimeMillis() + ".docx";
|
||||
template.writeAndClose(new FileOutputStream(dirpath + "/" + goFileName));
|
||||
String filePath = addPic1(typesetInfo.getFilename(), dirpath + "/" + goFileName);
|
||||
frag.put("file", filePath);
|
||||
// frag.put("file", filePath);
|
||||
frag.put("file",goFileName);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -1073,11 +1120,6 @@ public class TypesetController {
|
||||
}
|
||||
}
|
||||
picMap.put(imageName, lastParagraphText);
|
||||
// //System.out.println(pictureId +"\t|" + imageName + "\t|" + lastParagraphText);
|
||||
//获取word文本中所有的图片
|
||||
// List<XWPFPictureData> allPictures = xdoc.getAllPictures();
|
||||
//遍历照片
|
||||
// for (XWPFPictureData picture: allPictures) {
|
||||
byte[] data = pictureData.getData();
|
||||
File filePicture = new File(path + imageName.replace("image", ""));
|
||||
if (!filePicture.exists()) {
|
||||
@@ -1089,34 +1131,23 @@ public class TypesetController {
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(filePicture);
|
||||
fileOutputStream.write(data, 0, data.length);
|
||||
fileOutputStream.close();
|
||||
//System.out.println("执行结束了");
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
// //System.out.println("picNameList===========>"+picNameList);
|
||||
// //System.out.println("picMap===========>"+picMap);
|
||||
//2.获取按模板新生成的文档添加图片
|
||||
|
||||
|
||||
//其他方式
|
||||
Document doc = new Document();
|
||||
doc.loadFromFile(newFileName);
|
||||
Section sec = doc.getSections().get(0);
|
||||
// //System.out.println("sec=================>"+sec);
|
||||
String text = doc.getText();
|
||||
// //System.out.println("text=================>"+text);
|
||||
Paragraph para = sec.getParagraphs().get(0);
|
||||
// //System.out.println("para=================>"+para);
|
||||
for (int i = 0; i < doc.getSections().getCount(); i++) {
|
||||
Section section = doc.getSections().get(i);
|
||||
for (int j = 0; j < section.getParagraphs().getCount(); j++) {
|
||||
Paragraph paragraph = section.getParagraphs().get(j);
|
||||
// //System.out.println(j+"新方式内容"+paragraph.getText());
|
||||
for (String pic : picNameList) {
|
||||
String replace = String.valueOf(paragraph.getText()).replace(",", "").replace(" ", "");
|
||||
if (replace.contains(picMap.get(pic).replace(",", "").replace(" ", ""))) {
|
||||
// //System.out.println("包含");
|
||||
String imgPath = IMG_DIR + randomFix + pic.replace("image", "");
|
||||
|
||||
File picture = new File(imgPath);
|
||||
@@ -1158,10 +1189,6 @@ public class TypesetController {
|
||||
//获取图片文字环绕
|
||||
String wrappingstyle = docPicture.getTextWrappingStyle().toString();//图片文字环绕方式
|
||||
String wrappingtype = docPicture.getTextWrappingType().toString();//环绕文字类型
|
||||
|
||||
//System.out.println("坐标位置为: X =" + x + " Y=" + y
|
||||
// + "\n 图片宽:"+ width1 + " 图片高:" + height
|
||||
// + "\n 图片的文字环绕方式:" + wrappingstyle + " 环绕文字类型:" + wrappingtype);
|
||||
} else {
|
||||
//图片为大图 单栏
|
||||
DocPicture docPicture = paragraph.appendPicture(imgPath);
|
||||
@@ -1181,10 +1208,6 @@ public class TypesetController {
|
||||
//获取图片文字环绕
|
||||
String wrappingstyle = docPicture.getTextWrappingStyle().toString();//图片文字环绕方式
|
||||
String wrappingtype = docPicture.getTextWrappingType().toString();//环绕文字类型
|
||||
|
||||
//System.out.println("坐标位置为: X =" + x + " Y=" + y
|
||||
// + "\n 图片宽:"+ width1 + " 图片高:" + height
|
||||
// + "\n 图片的文字环绕方式:" + wrappingstyle + " 环绕文字类型:" + wrappingtype);
|
||||
}
|
||||
// }
|
||||
|
||||
@@ -1193,198 +1216,73 @@ public class TypesetController {
|
||||
|
||||
}
|
||||
}
|
||||
SectionCollection secs = doc.getSections();
|
||||
//处理表格
|
||||
for (int i = 0; i < secs.getCount(); i++) {
|
||||
//获取第一个section
|
||||
// Section section = doc.getSections().get(0);
|
||||
|
||||
TableCollection tables = secs.get(i).getTables();
|
||||
//System.out.println(tables);
|
||||
//获取section中第一个表格
|
||||
// Table table = sec.getTables().get(0);
|
||||
int count = tables.getCount();
|
||||
//System.out.println("===================>"+count);
|
||||
for (int j = 0; j < tables.getCount(); j++) {
|
||||
//给表格应用样式
|
||||
tables.get(j).applyStyle(DefaultTableStyle.Table_Classic_1);
|
||||
// //设置表格的右边框
|
||||
// tables.get(j).getTableFormat().getBorders().getRight().setBorderType(BorderStyle.Hairline);
|
||||
// tables.get(j).getTableFormat().getBorders().getRight().setLineWidth(0F);
|
||||
// tables.get(j).getTableFormat().getBorders().getRight().setColor(Color.white);
|
||||
// SectionCollection secs = doc.getSections();
|
||||
// //处理表格
|
||||
// for (int i = 0; i < secs.getCount(); i++) {
|
||||
// //获取第一个section
|
||||
//// Section section = doc.getSections().get(0);
|
||||
//
|
||||
//设置表格的顶部边框
|
||||
tables.get(j).getTableFormat().getBorders().getTop().setBorderType(BorderStyle.Hairline);
|
||||
tables.get(j).getTableFormat().getBorders().getTop().setLineWidth(0.2F);
|
||||
tables.get(j).getTableFormat().getBorders().getTop().setColor(Color.black);
|
||||
// TableCollection tables = secs.get(i).getTables();
|
||||
// //System.out.println(tables);
|
||||
// //获取section中第一个表格
|
||||
//// Table table = sec.getTables().get(0);
|
||||
// int count = tables.getCount();
|
||||
// //System.out.println("===================>"+count);
|
||||
// for (int j = 0; j < tables.getCount(); j++) {
|
||||
// //给表格应用样式
|
||||
// tables.get(j).applyStyle(DefaultTableStyle.Table_Classic_1);
|
||||
//// //设置表格的右边框
|
||||
//// tables.get(j).getTableFormat().getBorders().getRight().setBorderType(BorderStyle.Hairline);
|
||||
//// tables.get(j).getTableFormat().getBorders().getRight().setLineWidth(0F);
|
||||
//// tables.get(j).getTableFormat().getBorders().getRight().setColor(Color.white);
|
||||
////
|
||||
// //设置表格的顶部边框
|
||||
// tables.get(j).getTableFormat().getBorders().getTop().setBorderType(BorderStyle.Hairline);
|
||||
// tables.get(j).getTableFormat().getBorders().getTop().setLineWidth(0.2F);
|
||||
// tables.get(j).getTableFormat().getBorders().getTop().setColor(Color.black);
|
||||
////
|
||||
//// //设置表格的左边框
|
||||
//// tables.get(j).getTableFormat().getBorders().getLeft().setBorderType(BorderStyle.Hairline);
|
||||
//// tables.get(j).getTableFormat().getBorders().getLeft().setLineWidth(0F);
|
||||
//// tables.get(j).getTableFormat().getBorders().getLeft().setColor(Color.white);
|
||||
////
|
||||
// //设置表格的底部边框
|
||||
// tables.get(j).getTableFormat().getBorders().getBottom().setBorderType(BorderStyle.Hairline);
|
||||
//// tables.get(j).getTableFormat().getBorders().getLeft().setColor(Color.black);
|
||||
// tables.get(j).getTableFormat().getBorders().getBottom().setLineWidth(0.2F);
|
||||
// //设置表格的水平和垂直边框
|
||||
//// tables.get(j).getTableFormat().getBorders().getVertical().setBorderType(BorderStyle.Hairline);
|
||||
//// tables.get(j).getTableFormat().getBorders().getHorizontal().setBorderType(BorderStyle.Hairline);
|
||||
//// tables.get(j).getTableFormat().getBorders().getVertical().setLineWidth(0F);
|
||||
//// tables.get(j).getTableFormat().getBorders().getHorizontal().setLineWidth(0F);
|
||||
//// tables.get(j).getTableFormat().getBorders().getVertical().setColor(Color.white);
|
||||
//
|
||||
// //设置表格的左边框
|
||||
// tables.get(j).getTableFormat().getBorders().getLeft().setBorderType(BorderStyle.Hairline);
|
||||
// tables.get(j).getTableFormat().getBorders().getLeft().setLineWidth(0F);
|
||||
// tables.get(j).getTableFormat().getBorders().getLeft().setColor(Color.white);
|
||||
//// tables.get(j).getRows().get(0).setHeight(99F);
|
||||
//// tables.get(j).getRows().get(0).getRowFormat().getBorders().setBorderType(BorderStyle.Hairline);
|
||||
//// RowCollection rows = tables.get(j).getRows();
|
||||
//// for (int l = 0; l < rows.getCount(); l++) {
|
||||
//// rows.get(l).setHeight(15F);
|
||||
//// }
|
||||
//
|
||||
//设置表格的底部边框
|
||||
tables.get(j).getTableFormat().getBorders().getBottom().setBorderType(BorderStyle.Hairline);
|
||||
// tables.get(j).getTableFormat().getBorders().getLeft().setColor(Color.black);
|
||||
tables.get(j).getTableFormat().getBorders().getBottom().setLineWidth(0.2F);
|
||||
//设置表格的水平和垂直边框
|
||||
// tables.get(j).getTableFormat().getBorders().getVertical().setBorderType(BorderStyle.Hairline);
|
||||
// tables.get(j).getTableFormat().getBorders().getHorizontal().setBorderType(BorderStyle.Hairline);
|
||||
// tables.get(j).getTableFormat().getBorders().getVertical().setLineWidth(0F);
|
||||
// tables.get(j).getTableFormat().getBorders().getHorizontal().setLineWidth(0F);
|
||||
// tables.get(j).getTableFormat().getBorders().getVertical().setColor(Color.white);
|
||||
|
||||
// tables.get(j).getRows().get(0).setHeight(99F);
|
||||
// tables.get(j).getRows().get(0).getRowFormat().getBorders().setBorderType(BorderStyle.Hairline);
|
||||
// RowCollection rows = tables.get(j).getRows();
|
||||
// for (int l = 0; l < rows.getCount(); l++) {
|
||||
// rows.get(l).setHeight(15F);
|
||||
//
|
||||
// CellCollection rowCollection = tables.get(j).getRows().get(0).getCells();
|
||||
// for (int k = 0; k < rowCollection.getCount(); k++) {
|
||||
// rowCollection.get(k).getCellFormat().getBorders().getBottom().setBorderType(BorderStyle.Hairline);
|
||||
// rowCollection.get(k).getCellFormat().getBorders().getBottom().setLineWidth(0.2F);
|
||||
//// rowCollection.get(k).getCellFormat().getBorders().getBottom().setColor(Color.red);
|
||||
// }
|
||||
|
||||
|
||||
CellCollection rowCollection = tables.get(j).getRows().get(0).getCells();
|
||||
for (int k = 0; k < rowCollection.getCount(); k++) {
|
||||
rowCollection.get(k).getCellFormat().getBorders().getBottom().setBorderType(BorderStyle.Hairline);
|
||||
rowCollection.get(k).getCellFormat().getBorders().getBottom().setLineWidth(0.2F);
|
||||
// rowCollection.get(k).getCellFormat().getBorders().getBottom().setColor(Color.red);
|
||||
}
|
||||
// tables.get(j).getRows().get(0).getCells().get(0).getCellFormat().getBorders().getBottom().setBorderType(BorderStyle.Hairline);
|
||||
tables.get(j).autoFit(AutoFitBehaviorType.Auto_Fit_To_Window);
|
||||
|
||||
// tables.get(j).getTableFormat().setHorizontalAlignment(RowAlignment.Right);
|
||||
}
|
||||
}
|
||||
//// tables.get(j).getRows().get(0).getCells().get(0).getCellFormat().getBorders().getBottom().setBorderType(BorderStyle.Hairline);
|
||||
// tables.get(j).autoFit(AutoFitBehaviorType.Auto_Fit_To_Window);
|
||||
//
|
||||
//// tables.get(j).getTableFormat().setHorizontalAlignment(RowAlignment.Right);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
String uuid = UUID.randomUUID().toString().trim().replaceAll("-", "");
|
||||
|
||||
// for (int i=0 ; i < paragraphs.size() ; i++){
|
||||
// //System.out.println("内容为"+paragraphs.get(i).getRuns());
|
||||
// List<XWPFRun> runs = paragraphs.get(i).getRuns();
|
||||
// String replace = String.valueOf(runs).replace(",", "").replace(" ","");
|
||||
// for (String pic: picNameList){
|
||||
// if (replace.contains(picMap.get(pic).replace(",","").replace(" ",""))){
|
||||
// //System.out.println("包含执行了");
|
||||
// //获取光标
|
||||
// XmlCursor xmlCursor = paragraphs.get(i+1).getCTP().newCursor();
|
||||
// XWPFParagraph xwpfParagraph = newXdoc.insertNewParagraph(xmlCursor);
|
||||
//
|
||||
// XWPFRun run = xwpfParagraph.createRun();
|
||||
//// run.addBreak(BreakClear.ALL);
|
||||
//// run.setText("{{@image}}");
|
||||
// FileInputStream inputStream = new FileInputStream("C:\\Users\\yl\\Desktop\\pictures\\"+pic.replace("image",""));
|
||||
// run.addPicture2(inputStream,XWPFDocument.PICTURE_TYPE_JPEG,pic, Units.toEMU(500),Units.toEMU(180));
|
||||
// //
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// FileOutputStream os = new FileOutputStream(IMG_DIR+"New.doc");
|
||||
// newXdoc.write(os);
|
||||
|
||||
|
||||
doc.saveToFile(path + uuid + ".docx");
|
||||
//System.out.println("输出完毕");
|
||||
// os.close();
|
||||
inputStream.close();
|
||||
|
||||
filePath = randomFix + uuid + ".docx";
|
||||
// //处理角标
|
||||
// File newFile = new File(filePath);
|
||||
// FileInputStream newFis = new FileInputStream(newFile);
|
||||
// XWPFDocument newXdoc = new XWPFDocument(newFis);
|
||||
// List<XWPFParagraph> paragraphs = newXdoc.getParagraphs();
|
||||
// for (XWPFParagraph paragraph: paragraphs
|
||||
// ) {
|
||||
// int runNumber = 0;
|
||||
// List<XWPFRun> runs = paragraph.getRuns();
|
||||
//
|
||||
// for (XWPFRun run : runs) {
|
||||
// String s = run.text();
|
||||
//// Pattern p = Pattern.compile("(?<=q).*?(?=q)");
|
||||
//// Matcher m = p.matcher(s);
|
||||
//// //找到角标文字
|
||||
//// while(m.find()) {
|
||||
// if (s.contains("<q>")){
|
||||
//// //System.out.println("角标"+m.group());
|
||||
//// String group = m.group();
|
||||
// break;
|
||||
//
|
||||
//// char[] strArray = group.toCharArray();
|
||||
//// char[] runChars = s.toCharArray();
|
||||
//// for (char c : strArray) {
|
||||
////// String value = String.valueOf(c);
|
||||
////// if (s != null && s.contains(value)) { //if we have a run with an "a" in it, then
|
||||
////// char[] runChars = s.toCharArray();
|
||||
//// StringBuffer sb = new StringBuffer();
|
||||
//// for (int charNumber = 0; charNumber < runChars.length; charNumber++) { //go through all characters in that run
|
||||
//// if (runChars[charNumber] == c && String.valueOf(c) != null) { //if the charcter is an 'a' then
|
||||
////// run.setText(sb.toString(), 0); //set all characters, which are current buffered, as the text of the actual run
|
||||
////// r = paragraph.insertNewRun(++runNumber); //insert new run for the '@' as the replacement for the 'a'
|
||||
////// r.setText("@", 0);
|
||||
////// r.setColor("DC143C");
|
||||
////// r = paragraph.insertNewRun(++runNumber); //insert new run for the next characters
|
||||
//// run.setText(sb.toString(), 0); //set all characters, which are current buffered, as the text of the actual run
|
||||
//// run = paragraph.insertNewRun(++runNumber); //insert new run for the '@' as the replacement for the 'a'
|
||||
//// run.setText(String.valueOf(c), 0);
|
||||
//// run.setSubscript(VerticalAlign.SUPERSCRIPT);
|
||||
//// } else {
|
||||
//// sb.append(runChars[charNumber]); //buffer all characters which are not 'a's
|
||||
//// }
|
||||
//// }
|
||||
//// run.setText(sb.toString(), 0); //set all characters, which are current buffered, as the text of the actual run
|
||||
////// }
|
||||
////
|
||||
////
|
||||
//// }
|
||||
//// runNumber++;
|
||||
// }
|
||||
// }
|
||||
// XWPFRun run1 = paragraph.createRun();
|
||||
// run1.setText("112");
|
||||
// XWPFRun run2 = paragraph.createRun();
|
||||
// run2.setText("345");
|
||||
// run2.setSubscript(VerticalAlign.SUPERSCRIPT);
|
||||
//
|
||||
//// int runNumber = 0;
|
||||
//// while (runNumber < paragraph.getRuns().size()) { //go through all runs, we cannot use for each since we will possibly insert new runs
|
||||
////// XWPFRun r = paragraph.getRuns().get(runNumber);
|
||||
////// String runText = r.getText(0);
|
||||
//////
|
||||
//////
|
||||
////// Pattern p = Pattern.compile("/(?<=q).*?(?=q)/");
|
||||
////// Matcher m = p.matcher(runText);
|
||||
////// while(m.find()) {
|
||||
////// //System.out.println("角标"+m.group(1));
|
||||
////// }
|
||||
////
|
||||
////
|
||||
////
|
||||
////
|
||||
////// if (runText != null && runText.contains("a")) { //if we have a run with an "a" in it, then
|
||||
////// char[] runChars = runText.toCharArray();
|
||||
////// StringBuffer sb = new StringBuffer();
|
||||
////// for (int charNumber = 0; charNumber < runChars.length; charNumber++) { //go through all characters in that run
|
||||
////// if (runChars[charNumber] == 'a') { //if the charcter is an 'a' then
|
||||
////// r.setText(sb.toString(), 0); //set all characters, which are current buffered, as the text of the actual run
|
||||
////// r = paragraph.insertNewRun(++runNumber); //insert new run for the '@' as the replacement for the 'a'
|
||||
////// r.setText("@", 0);
|
||||
////// r.setColor("DC143C");
|
||||
////// r = paragraph.insertNewRun(++runNumber); //insert new run for the next characters
|
||||
////// sb = new StringBuffer(); //empty buffer
|
||||
////// } else {
|
||||
////// sb.append(runChars[charNumber]); //buffer all characters which are not 'a's
|
||||
////// }
|
||||
////// }
|
||||
////// r.setText(sb.toString(), 0); //set all characters, which are current buffered, as the text of the actual run
|
||||
////// }
|
||||
////// runNumber++;
|
||||
//// }
|
||||
// }
|
||||
|
||||
|
||||
// newFis.close();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -81,15 +81,17 @@ public class UserController {
|
||||
@ApiOperation(value = "验证登录,用户名、密码")
|
||||
@PostMapping("/login")
|
||||
public ReturnValue checkUser(String account, String password) {
|
||||
|
||||
return new ReturnValue(ReturnCodeAndMsgEnum.SYSTEM_STOP);
|
||||
// if (!capchar.equals(session.getAttribute("verCode"))) {
|
||||
//
|
||||
// }
|
||||
User user = userservice.checkUser(account.trim(), DigestUtils.md5Hex(password.trim()));
|
||||
if (user == null) {
|
||||
return new ReturnValue(ReturnCodeAndMsgEnum.No_Data);
|
||||
} else {
|
||||
return new ReturnValue(ReturnCodeAndMsgEnum.Success, user);
|
||||
}
|
||||
// User user = userservice.checkUser(account.trim(), DigestUtils.md5Hex(password.trim()));
|
||||
// if (user == null) {
|
||||
// return new ReturnValue(ReturnCodeAndMsgEnum.No_Data);
|
||||
// } else {
|
||||
// return new ReturnValue(ReturnCodeAndMsgEnum.Success, user);
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user