根据制度正文生成条款调整
This commit is contained in:
parent
16c0b40946
commit
ed7e3f55d5
@ -288,7 +288,8 @@ public class CreateMaps implements IJob {
|
||||
* @param name
|
||||
*/
|
||||
public boolean updateMaps2(UserContext userContext, String id,DCContext dcContextpdf1, String name, String groupValue, String fileValue, String fileName) {
|
||||
PALRepositoryModel palRepositoryModel = ReadWordUtil.getRepositoryByName(id, name);
|
||||
PALRepositoryModel palRepositoryModel = PALRepositoryCache.getCache().get(fileValue);
|
||||
//PALRepositoryModel palRepositoryModel = ReadWordUtil.getRepositoryByName(id, name);
|
||||
if(palRepositoryModel == null){
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ package com.actionsoft.apps.coe.pal.datamigration.util.readword;
|
||||
import com.actionsoft.apps.coe.pal.constant.CoEConstant;
|
||||
import com.actionsoft.apps.coe.pal.datamigration.model.po.WordAttribute;
|
||||
import com.actionsoft.apps.coe.pal.datamigration.model.po.WordField;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.dao.CoeProcessLevelDaoFacotory;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.designer.manage.CoeDesignerAPIManager;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.designer.model.BaseModel;
|
||||
@ -271,32 +272,25 @@ public class ReadWordUtil {
|
||||
//将文件挂载到附件里面
|
||||
DCContext dcContextorigin = new DCContext(userContext, dcProfilepdfdoc, "com.actionsoft.apps.coe.pal.datamigration", groupValue, fileValue, fileName);
|
||||
InputStream originfile = SDK.getDCAPI().read(dcContextorigin);
|
||||
PALRepositoryModel palRepositoryModel = getRepositoryByName(wsId, name);
|
||||
try {
|
||||
String id = palRepositoryModel.getId();
|
||||
logMaps.put("PALID",id);
|
||||
//查询对应绩效模型中数据模型进行填充数据
|
||||
BaseModel defineModel = CoeDesignerAPIManager.getInstance().getDefinition(id, 0);
|
||||
String shpId = "";
|
||||
String define = defineModel.getDefinition();
|
||||
JSONObject definition = JSONObject.parseObject(define);
|
||||
JSONObject elements = definition.getJSONObject("elements");
|
||||
for (String key : elements.keySet()) {
|
||||
JSONObject shape1 = elements.getJSONObject(key);
|
||||
if("regulation".equals(shape1.getString("name"))) {
|
||||
shpId = key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//删除已有xml文件
|
||||
StringBuffer sql = new StringBuffer();
|
||||
sql.append("delete from ").append(UpfileModel.DATABASE_ENTITY).append(" WHERE SHAPEID = '" + shpId + "'");
|
||||
int update = DBSql.update(sql.toString());
|
||||
boolean writeFileTodisk = writeFileTodisk(userContext, shpId, fileName, originfile, palRepositoryModel.getId(), "s");
|
||||
} catch (FileNotFoundException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
/* 上传附件到第一个形状,现在已改为每次重新生成第一个节点
|
||||
* try { PALRepositoryModel palRepositoryModel =
|
||||
* PALRepositoryCache.getCache().get(fileValue); String id =
|
||||
* palRepositoryModel.getId(); logMaps.put("PALID",id); //查询对应绩效模型中数据模型进行填充数据
|
||||
* BaseModel defineModel = CoeDesignerAPIManager.getInstance().getDefinition(id,
|
||||
* 0); String shpId = ""; String define = defineModel.getDefinition();
|
||||
* JSONObject definition = JSONObject.parseObject(define); JSONObject elements =
|
||||
* definition.getJSONObject("elements"); for (String key : elements.keySet()) {
|
||||
* JSONObject shape1 = elements.getJSONObject(key);
|
||||
* if("regulation".equals(shape1.getString("name"))||"I/O_L4".equals(shape1.
|
||||
* getString("name"))) { shpId = key; break; } } //删除已有xml文件 StringBuffer sql =
|
||||
* new StringBuffer();
|
||||
* sql.append("delete from ").append(UpfileModel.DATABASE_ENTITY).
|
||||
* append(" WHERE SHAPEID = '" + shpId + "'"); int update =
|
||||
* DBSql.update(sql.toString()); boolean writeFileTodisk =
|
||||
* writeFileTodisk(userContext, shpId, fileName, originfile,
|
||||
* palRepositoryModel.getId(), "s"); } catch (FileNotFoundException e) { // TODO
|
||||
* Auto-generated catch block e.printStackTrace(); }
|
||||
*/
|
||||
//创建图形
|
||||
if (iscreatemap) {
|
||||
DCContext dcContextpdf1 = new DCContext(userContext, dcProfilepdfdoc, "com.actionsoft.apps.coe.pal.datamigration", groupValue, fileValue, fileName);
|
||||
|
||||
@ -1,9 +1,30 @@
|
||||
package com.actionsoft.apps.coe.pal.datamigration.util.readword;
|
||||
|
||||
import cn.jpush.api.utils.StringUtils;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStream;
|
||||
import java.math.BigInteger;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.poi.hwpf.usermodel.Paragraph;
|
||||
import org.apache.poi.xwpf.usermodel.IBodyElement;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
|
||||
|
||||
import com.actionsoft.apps.coe.pal.constant.CoEConstant;
|
||||
import com.actionsoft.apps.coe.pal.datamigration.aris.mapping.ModelMappingAPIManager;
|
||||
import com.actionsoft.apps.coe.pal.datamigration.constant.Constant;
|
||||
import com.actionsoft.apps.coe.pal.datamigration.util.ShapeUtil;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.upfile.constant.CoeFileConstant;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.upfile.dao.UpFileDao;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.upfile.model.UpfileModel;
|
||||
import com.actionsoft.apps.resource.plugin.profile.DCPluginProfile;
|
||||
import com.actionsoft.bpms.server.UserContext;
|
||||
import com.actionsoft.bpms.server.fs.DCContext;
|
||||
@ -15,19 +36,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.spire.doc.Document;
|
||||
import com.spire.doc.FileFormat;
|
||||
|
||||
import org.apache.poi.hwpf.usermodel.Paragraph;
|
||||
import org.apache.poi.xwpf.usermodel.*;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.math.BigInteger;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import cn.jpush.api.utils.StringUtils;
|
||||
|
||||
/**
|
||||
* @author baizp
|
||||
@ -109,319 +118,318 @@ public class WordUtilXWPF {
|
||||
}
|
||||
|
||||
public JSONObject rewritContent2(UserContext userContext, JSONObject elements, DCContext dcContextpdf, String name,
|
||||
JSONObject shapefirst, String plid, int type,String groupValue, String fileValue, String fileName) {
|
||||
|
||||
// File file = null;
|
||||
int count = 0;
|
||||
List<String> failTitleList = new ArrayList<>();
|
||||
StringBuilder richSbuild = new StringBuilder();
|
||||
// String filePath =
|
||||
// "/Users/jiuyabai/Desktop/yili项目/制度样例1—伊利集团流程制度类文件管理规范1.docx";
|
||||
try {
|
||||
// file = new File(filePath);
|
||||
elements.clear();
|
||||
String path = dcContextpdf.getPath();
|
||||
// String filePath = "D:/制度样例1—伊利集团流程制度类文件管理规范2.xml"; //创建实例,加载xml测试文档
|
||||
Document docs = new Document();
|
||||
docs.loadFromFile(path + fileName);
|
||||
JSONObject shapefirst, String plid, int type, String groupValue, String fileValue, String fileName) {
|
||||
|
||||
// 保存为Docx格式
|
||||
|
||||
docs.saveToFile(path+name+".docx",FileFormat.Docx);
|
||||
// File file = null;
|
||||
int count = 0;
|
||||
List<String> failTitleList = new ArrayList<>();
|
||||
StringBuilder richSbuild = new StringBuilder();
|
||||
// String filePath =
|
||||
// "/Users/jiuyabai/Desktop/yili项目/制度样例1—伊利集团流程制度类文件管理规范1.docx";
|
||||
try {
|
||||
// file = new File(filePath);
|
||||
elements.clear();
|
||||
String path = dcContextpdf.getPath();
|
||||
// String filePath = "D:/制度样例1—伊利集团流程制度类文件管理规范2.xml"; //创建实例,加载xml测试文档
|
||||
Document docs = new Document();
|
||||
docs.loadFromFile(path + fileName);
|
||||
|
||||
File f = new File(path + fileName);
|
||||
// 保存为Docx格式
|
||||
|
||||
InputStream in = new FileInputStream(f);
|
||||
docs.saveToFile(path + name + ".docx", FileFormat.Docx);
|
||||
|
||||
byte b[] = new byte[(int) f.length()]; // 创建合适文件大小的数组
|
||||
File f = new File(path + fileName);
|
||||
|
||||
in.read(b); // 读取文件中的内容到b[]数组
|
||||
InputStream in = new FileInputStream(f);
|
||||
|
||||
in.close();
|
||||
byte b[] = new byte[(int) f.length()]; // 创建合适文件大小的数组
|
||||
|
||||
// System.out.println(new String(b));
|
||||
in.read(b); // 读取文件中的内容到b[]数组
|
||||
|
||||
// 保存为Doc格式 //docs.saveToFile("toDoc.doc",FileFormat.Doc);
|
||||
in.close();
|
||||
|
||||
//
|
||||
DCPluginProfile dcProfilepdfdoc = DCProfileManager.getDCProfile("com.actionsoft.apps.coe.pal.datamigration", "migration");
|
||||
DCContext dcContextpdf1 = new DCContext(userContext, dcProfilepdfdoc, "com.actionsoft.apps.coe.pal.datamigration", groupValue, fileValue, name+".docx");
|
||||
InputStream docxfile = SDK.getDCAPI().read(dcContextpdf1);
|
||||
|
||||
XWPFDocument doc = new XWPFDocument(docxfile);
|
||||
JSONArray onlinedata = new JSONArray();
|
||||
if (shapefirst == null || shapefirst.size() == 0) {
|
||||
JSONObject shapeze = ShapeUtil.getProcessShapeDefinitionByName("control.policy", "regulation");
|
||||
String shapeIdz = UUIDGener.getObjectId();
|
||||
shapeze.put("text", name);// 不生效
|
||||
shapeze.put("level", 0);
|
||||
JSONObject props1 = shapeze.getJSONObject("props");// 位置大小
|
||||
shapeze.put("id", shapeIdz);
|
||||
props1.put("x", 100);
|
||||
props1.put("y", 277);
|
||||
props1.put("w", 110);
|
||||
props1.put("h", 50);
|
||||
props1.put("zindex", 0);
|
||||
shapeze.put("next", true);
|
||||
elements.put(shapeIdz, shapeze);
|
||||
shapeze.put("p", 0);
|
||||
onlinedata.add(shapeze);
|
||||
} else {
|
||||
elements.put(shapefirst.getString("id"), shapefirst);
|
||||
shapefirst.put("next", true);
|
||||
shapefirst.put("p", 0);
|
||||
onlinedata.add(shapefirst);
|
||||
// System.out.println(new String(b));
|
||||
|
||||
// 保存为Doc格式 //docs.saveToFile("toDoc.doc",FileFormat.Doc);
|
||||
|
||||
//
|
||||
DCPluginProfile dcProfilepdfdoc = DCProfileManager.getDCProfile("com.actionsoft.apps.coe.pal.datamigration",
|
||||
"migration");
|
||||
DCContext dcContextpdf1 = new DCContext(userContext, dcProfilepdfdoc,
|
||||
"com.actionsoft.apps.coe.pal.datamigration", groupValue, fileValue, name + ".docx");
|
||||
InputStream docxfile = SDK.getDCAPI().read(dcContextpdf1);
|
||||
|
||||
XWPFDocument doc = new XWPFDocument(docxfile);
|
||||
JSONArray onlinedata = new JSONArray();
|
||||
|
||||
// 创建起始节点
|
||||
JSONObject shapeze = ShapeUtil.getProcessShapeDefinitionByName("control.policy", "regulation");
|
||||
String shapeIdz = UUIDGener.getObjectId();
|
||||
shapeze.put("text", name);// 不生效
|
||||
shapeze.put("level", 0);
|
||||
JSONObject props1 = shapeze.getJSONObject("props");// 位置大小
|
||||
shapeze.put("id", shapeIdz);
|
||||
props1.put("x", 180);
|
||||
props1.put("y", 180);
|
||||
props1.put("w", 150);
|
||||
props1.put("h", 66);
|
||||
props1.put("zindex", 0);
|
||||
shapeze.put("next", true);
|
||||
elements.put(shapeIdz, shapeze);
|
||||
shapeze.put("p", 0);
|
||||
onlinedata.add(shapeze);
|
||||
// 上传附件
|
||||
writeFileTodisk(userContext, shapeIdz, fileName, docxfile, fileValue, "s");
|
||||
|
||||
// 获取段落
|
||||
List<XWPFParagraph> paras = doc.getParagraphs();
|
||||
// 级别依次
|
||||
// 记录x横向的位置
|
||||
int x = 1;
|
||||
// 记录y轴的位置
|
||||
int y = 1;
|
||||
// 记录上次层级
|
||||
int lastindex = 0;
|
||||
boolean isfirst = true;
|
||||
// 所以条数
|
||||
int countall = 0;
|
||||
// 上级节点是否已有子节点
|
||||
boolean hasnext = false;
|
||||
// 内容的所有数据
|
||||
StringBuilder strb = new StringBuilder();
|
||||
// 记录这条线上的所有节点 顺序就是层级
|
||||
// List<JSONObject> onlinedata = new ArrayList<JSONObject>();
|
||||
boolean lastislast = false;
|
||||
XWPFDocument newfile = new XWPFDocument();
|
||||
boolean isend = false;
|
||||
boolean isstart = true;
|
||||
for (XWPFParagraph para : paras) {
|
||||
BigInteger numlevel = para.getNumIlvl();
|
||||
String paragraphText = para.getParagraphText();
|
||||
countall += 1;
|
||||
// 处理富文本的情况
|
||||
if (shapefirst != null && type == 0) {
|
||||
isstart = false;
|
||||
}
|
||||
if (isstart) {// && numlevel == null && isstart) {
|
||||
count++;
|
||||
isstart = false;
|
||||
// continue;
|
||||
}
|
||||
if (isstart) {
|
||||
continue;
|
||||
}
|
||||
if (!para.getParagraphText().isEmpty()) {
|
||||
if (para.getParagraphText().matches("附件\\d{1,}:")) {
|
||||
isend = true;
|
||||
}
|
||||
XWPFParagraph tmpp = newfile.createParagraph();
|
||||
WordCreatFile.copyAllRunsToAnotherParagraph(para, tmpp);
|
||||
}
|
||||
if (isend) {
|
||||
continue;
|
||||
}
|
||||
hasnext = false;
|
||||
JSONObject shap = new JSONObject();
|
||||
String leveltext = para.getNumLevelText();
|
||||
|
||||
// 获取段落
|
||||
List<XWPFParagraph> paras = doc.getParagraphs();
|
||||
// 级别依次
|
||||
// 记录x横向的位置
|
||||
int x = 1;
|
||||
// 记录y轴的位置
|
||||
int y = 1;
|
||||
// 记录上次层级
|
||||
int lastindex = 0;
|
||||
boolean isfirst = true;
|
||||
// 所以条数
|
||||
int countall = 0;
|
||||
// 上级节点是否已有子节点
|
||||
boolean hasnext = false;
|
||||
// 内容的所有数据
|
||||
StringBuilder strb = new StringBuilder();
|
||||
// 记录这条线上的所有节点 顺序就是层级
|
||||
// List<JSONObject> onlinedata = new ArrayList<JSONObject>();
|
||||
boolean lastislast = false;
|
||||
XWPFDocument newfile = new XWPFDocument();
|
||||
boolean isend = false;
|
||||
boolean isstart = true;
|
||||
for (XWPFParagraph para : paras) {
|
||||
BigInteger numlevel = para.getNumIlvl();
|
||||
String paragraphText = para.getParagraphText();
|
||||
countall += 1;
|
||||
// 处理富文本的情况
|
||||
if (shapefirst != null && type == 0) {
|
||||
isstart = false;
|
||||
}
|
||||
if (isstart) {// && numlevel == null && isstart) {
|
||||
count++;
|
||||
isstart = false;
|
||||
//continue;
|
||||
}
|
||||
if (isstart) {
|
||||
continue;
|
||||
}
|
||||
if (!para.getParagraphText().isEmpty()) {
|
||||
if (para.getParagraphText().matches("附件\\d{1,}:")) {
|
||||
isend = true;
|
||||
String titleLvl = getTitleLvl(doc, para);// 获取段落级别
|
||||
// System.out.println("numlevel" + numlevel + "======leveltext=====" + leveltext
|
||||
// + "=====获取到的级别为=====" + titleLvl + " =======内容为=====" + para.getText());
|
||||
|
||||
// System.out.println("=====当前level为" + (numlevel != null ? numlevel.intValue()
|
||||
// : "空") + "=====上一节点层级为" + lastindex + " ");
|
||||
|
||||
// 标题级别
|
||||
if (numlevel != null && numlevel.intValue() > 0) {
|
||||
int nowlevel = numlevel.intValue();
|
||||
// 如果换层级了 就清空后面的数据
|
||||
if ((nowlevel < lastindex || lastindex == 0) && onlinedata.size() >= (nowlevel + 1)) {
|
||||
// System.out.println("进行数据清理");
|
||||
JSONArray tmp = new JSONArray();
|
||||
for (int i = 0; i <= nowlevel; i++) {
|
||||
tmp.add(onlinedata.getJSONObject(i));
|
||||
}
|
||||
XWPFParagraph tmpp = newfile.createParagraph();
|
||||
WordCreatFile.copyAllRunsToAnotherParagraph(para, tmpp);
|
||||
onlinedata = tmp;
|
||||
}
|
||||
if (isend) {
|
||||
continue;
|
||||
}
|
||||
hasnext = false;
|
||||
JSONObject shap = new JSONObject();
|
||||
String leveltext = para.getNumLevelText();
|
||||
|
||||
String titleLvl = getTitleLvl(doc, para);// 获取段落级别
|
||||
// System.out.println("numlevel" + numlevel + "======leveltext=====" + leveltext
|
||||
// + "=====获取到的级别为=====" + titleLvl + " =======内容为=====" + para.getText());
|
||||
|
||||
// System.out.println("=====当前level为" + (numlevel != null ? numlevel.intValue()
|
||||
// : "空") + "=====上一节点层级为" + lastindex + " ");
|
||||
|
||||
// 标题级别
|
||||
if (numlevel != null && numlevel.intValue() > 0) {
|
||||
int nowlevel = numlevel.intValue();
|
||||
// 如果换层级了 就清空后面的数据
|
||||
if ((nowlevel < lastindex || lastindex == 0) && onlinedata.size() >= (nowlevel + 1)) {
|
||||
// System.out.println("进行数据清理");
|
||||
JSONArray tmp = new JSONArray();
|
||||
for (int i = 0; i <= nowlevel; i++) {
|
||||
tmp.add(onlinedata.getJSONObject(i));
|
||||
}
|
||||
onlinedata = tmp;
|
||||
}
|
||||
lastislast = false;
|
||||
String shapeId1 = UUIDGener.getObjectId();
|
||||
int pnode = lastindex;
|
||||
boolean issamelevel = false;
|
||||
// 如果是同级,需要找到父节点
|
||||
if (lastindex == nowlevel) {
|
||||
JSONObject tmpshap1 = onlinedata.getJSONObject(lastindex);
|
||||
pnode = tmpshap1.getInteger("p");
|
||||
x = 0;
|
||||
} else {
|
||||
if (nowlevel > lastindex && (lastindex != 0 || isfirst)) {
|
||||
x = 1;
|
||||
} else {
|
||||
x = 0;
|
||||
}
|
||||
/**
|
||||
* 如果不是同级 需要找到同级
|
||||
*/
|
||||
if ((onlinedata.size() - 1) >= nowlevel && onlinedata.get(nowlevel) != null) {
|
||||
JSONObject tmpshap1 = onlinedata.getJSONObject(nowlevel);
|
||||
pnode = tmpshap1.getInteger("p");
|
||||
lastindex = nowlevel;
|
||||
}
|
||||
/**
|
||||
* 找上一级
|
||||
*/
|
||||
if (onlinedata.size() == nowlevel && lastindex == 0) {
|
||||
lastindex = nowlevel - 1;
|
||||
JSONObject tmpshap1 = onlinedata.getJSONObject(lastindex);
|
||||
pnode = lastindex;
|
||||
hasnext = tmpshap1.getBoolean("next");
|
||||
x = 1;
|
||||
}
|
||||
}
|
||||
isfirst = false;
|
||||
// 如果是父节点新增,则要父节点的节点
|
||||
JSONObject tmpshap = onlinedata.getJSONObject(lastindex);
|
||||
// System.out.println("======获取上一节点位置为:" + lastindex + " ====节点内容为:" +
|
||||
// tmpshap.getString("text"));
|
||||
int len = para.getParagraphText().length() / 8 - 2;
|
||||
/**
|
||||
* 计算y
|
||||
*/
|
||||
if (nowlevel <= lastindex || hasnext) {
|
||||
y += 1;
|
||||
}
|
||||
|
||||
shap = getSharp(x, y, countall, len, tmpshap, para.getParagraphText(), "item2");
|
||||
shap.put("id", shapeId1);
|
||||
shap.put("text", getShowText(para.getParagraphText()));
|
||||
shap.put("level", nowlevel);
|
||||
shap.put("p", pnode);
|
||||
elements.put(shapeId1, shap);
|
||||
// 拼接富文本标签
|
||||
richSbuild.append(DocToHtml.getHtml(nowlevel, para.getParagraphText()));
|
||||
JSONObject linkshap = onlinedata.getJSONObject(pnode);
|
||||
linkshap.put("next", true);
|
||||
onlinedata.set(pnode, linkshap);
|
||||
craetline(elements, linkshap, shap, countall);
|
||||
onlinedata.set(nowlevel, shap);
|
||||
lastindex = nowlevel;
|
||||
lastislast = false;
|
||||
String shapeId1 = UUIDGener.getObjectId();
|
||||
int pnode = lastindex;
|
||||
boolean issamelevel = false;
|
||||
// 如果是同级,需要找到父节点
|
||||
if (lastindex == nowlevel) {
|
||||
JSONObject tmpshap1 = onlinedata.getJSONObject(lastindex);
|
||||
pnode = tmpshap1.getInteger("p");
|
||||
x = 0;
|
||||
} else {
|
||||
// 内容
|
||||
if (StringUtils.isNotEmpty(para.getParagraphText())) {
|
||||
if (para.getParagraphText().contains("表单/模板适用范围")) {
|
||||
System.out.println("断电测试11111");
|
||||
}
|
||||
// countall += 1;
|
||||
// 判断下一个是否同一级
|
||||
boolean islast = false;
|
||||
if (countall == paras.size()) {
|
||||
if (nowlevel > lastindex && (lastindex != 0 || isfirst)) {
|
||||
x = 1;
|
||||
} else {
|
||||
x = 0;
|
||||
}
|
||||
/**
|
||||
* 如果不是同级 需要找到同级
|
||||
*/
|
||||
if ((onlinedata.size() - 1) >= nowlevel && onlinedata.get(nowlevel) != null) {
|
||||
JSONObject tmpshap1 = onlinedata.getJSONObject(nowlevel);
|
||||
pnode = tmpshap1.getInteger("p");
|
||||
lastindex = nowlevel;
|
||||
}
|
||||
/**
|
||||
* 找上一级
|
||||
*/
|
||||
if (onlinedata.size() == nowlevel && lastindex == 0) {
|
||||
lastindex = nowlevel - 1;
|
||||
JSONObject tmpshap1 = onlinedata.getJSONObject(lastindex);
|
||||
pnode = lastindex;
|
||||
hasnext = tmpshap1.getBoolean("next");
|
||||
x = 1;
|
||||
}
|
||||
}
|
||||
isfirst = false;
|
||||
// 如果是父节点新增,则要父节点的节点
|
||||
JSONObject tmpshap = onlinedata.getJSONObject(lastindex);
|
||||
// System.out.println("======获取上一节点位置为:" + lastindex + " ====节点内容为:" +
|
||||
// tmpshap.getString("text"));
|
||||
int len = para.getParagraphText().length() / 8 - 2;
|
||||
/**
|
||||
* 计算y
|
||||
*/
|
||||
if (nowlevel <= lastindex || hasnext) {
|
||||
y += 1;
|
||||
}
|
||||
|
||||
shap = getSharp(x, y, countall, len, tmpshap, para.getParagraphText(), "item2");
|
||||
shap.put("id", shapeId1);
|
||||
shap.put("text", getShowText(para.getParagraphText()));
|
||||
shap.put("level", nowlevel);
|
||||
shap.put("p", pnode);
|
||||
elements.put(shapeId1, shap);
|
||||
// 拼接富文本标签
|
||||
richSbuild.append(DocToHtml.getHtml(nowlevel, para.getParagraphText()));
|
||||
JSONObject linkshap = onlinedata.getJSONObject(pnode);
|
||||
linkshap.put("next", true);
|
||||
onlinedata.set(pnode, linkshap);
|
||||
craetline(elements, linkshap, shap, countall);
|
||||
onlinedata.set(nowlevel, shap);
|
||||
lastindex = nowlevel;
|
||||
} else {
|
||||
// 内容
|
||||
if (StringUtils.isNotEmpty(para.getParagraphText())) {
|
||||
if (para.getParagraphText().contains("表单/模板适用范围")) {
|
||||
System.out.println("断电测试11111");
|
||||
}
|
||||
// countall += 1;
|
||||
// 判断下一个是否同一级
|
||||
boolean islast = false;
|
||||
if (countall == paras.size()) {
|
||||
islast = true;
|
||||
}
|
||||
if (countall < paras.size()) {
|
||||
BigInteger nextlevel = paras.get(countall).getNumIlvl();
|
||||
// 后面数据为高级别文字
|
||||
if (nextlevel != null && nextlevel.intValue() > 0) {
|
||||
islast = true;
|
||||
}
|
||||
if (countall < paras.size()) {
|
||||
BigInteger nextlevel = paras.get(countall).getNumIlvl();
|
||||
// 后面数据为高级别文字
|
||||
if (nextlevel != null && nextlevel.intValue() > 0) {
|
||||
islast = true;
|
||||
} else {
|
||||
// 后面为图片 或者表格 则要判断这之后是否有同级文字
|
||||
int tmp = countall;
|
||||
while (tmp < paras.size()) {
|
||||
XWPFParagraph paratmp = paras.get(tmp);
|
||||
BigInteger nextleveltmp = paratmp.getNumIlvl();
|
||||
if (nextleveltmp == null && paratmp.getParagraphText().length() == 0) {
|
||||
tmp += 1;
|
||||
} else {
|
||||
// 后面为图片 或者表格 则要判断这之后是否有同级文字
|
||||
int tmp = countall;
|
||||
while (tmp < paras.size()) {
|
||||
XWPFParagraph paratmp = paras.get(tmp);
|
||||
BigInteger nextleveltmp = paratmp.getNumIlvl();
|
||||
if (nextleveltmp == null && paratmp.getParagraphText().length() == 0) {
|
||||
tmp += 1;
|
||||
} else {
|
||||
// 有同级文字
|
||||
if ((nextleveltmp == null || nextleveltmp.intValue() == 0)
|
||||
&& paratmp.getParagraphText().length() > 0) {
|
||||
islast = false;
|
||||
} else {
|
||||
// 有同级文字
|
||||
if ((nextleveltmp == null || nextleveltmp.intValue() == 0)
|
||||
&& paratmp.getParagraphText().length() > 0) {
|
||||
islast = false;
|
||||
} else {
|
||||
islast = true;
|
||||
}
|
||||
if (paratmp.getParagraphText().matches("附件\\d{1,}:")) {
|
||||
islast = true;
|
||||
}
|
||||
if ("".equals(para.getParagraphText())) {
|
||||
// System.err.println("========相关文件========");
|
||||
islast = true;
|
||||
isend = true;
|
||||
}
|
||||
break;
|
||||
islast = true;
|
||||
}
|
||||
if (paratmp.getParagraphText().matches("附件\\d{1,}:")) {
|
||||
islast = true;
|
||||
}
|
||||
if ("".equals(para.getParagraphText())) {
|
||||
// System.err.println("========相关文件========");
|
||||
islast = true;
|
||||
isend = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (islast && !isend) {
|
||||
strb.append(para.getParagraphText());
|
||||
// 拼接富文本标签
|
||||
richSbuild.append(DocToHtml.getHtml(0, para.getParagraphText()));
|
||||
}
|
||||
if (strb.length() > 0 && islast) {
|
||||
if ("".equals(para.getParagraphText())) {
|
||||
isend = true;
|
||||
lastislast = true;
|
||||
break;
|
||||
}
|
||||
String shapeId1 = UUIDGener.getObjectId();
|
||||
// System.out.println("段落内容===" + para.getParagraphText());//段落内容
|
||||
lastindex = onlinedata.size() - 1;
|
||||
// 获取级数
|
||||
int len = strb.length() / 8 - 2;
|
||||
int pnode = lastindex;
|
||||
int nowlevel = 0;
|
||||
if (numlevel != null) {
|
||||
nowlevel = numlevel.intValue();
|
||||
}
|
||||
/*
|
||||
* if (lastindex == nowlevel) { JSONObject tmpshap1 =
|
||||
* onlinedata.getJSONObject(lastindex); pnode = tmpshap1.getInteger("p"); }
|
||||
*/
|
||||
x = 1;
|
||||
JSONObject tmpshap = onlinedata.getJSONObject(lastindex);
|
||||
// 根据上一个位置计算当前位置
|
||||
shap = getSharp(x, y, countall, len, tmpshap, strb.toString(), "item1");
|
||||
shap.put("id", shapeId1);
|
||||
shap.put("text", getShowText(strb.toString()).replaceAll("\n", ""));
|
||||
// shap.put("p", pnode);
|
||||
shap.put("level", 0);
|
||||
|
||||
JSONObject linkshap = onlinedata.getJSONObject(lastindex);
|
||||
craetline(elements, linkshap, shap, countall);
|
||||
linkshap.put("next", true);
|
||||
onlinedata.set(pnode, linkshap);
|
||||
elements.put(shapeId1, shap);
|
||||
strb = new StringBuilder();
|
||||
} else {
|
||||
strb.append(para.getParagraphText()).append("\n");
|
||||
// 拼接富文本标签
|
||||
richSbuild.append(DocToHtml.getHtml(0, para.getParagraphText()));
|
||||
}
|
||||
lastislast = true;
|
||||
lastindex = 0;
|
||||
}
|
||||
|
||||
if (islast && !isend) {
|
||||
strb.append(para.getParagraphText());
|
||||
// 拼接富文本标签
|
||||
richSbuild.append(DocToHtml.getHtml(0, para.getParagraphText()));
|
||||
}
|
||||
if (strb.length() > 0 && islast) {
|
||||
if ("".equals(para.getParagraphText())) {
|
||||
isend = true;
|
||||
lastislast = true;
|
||||
break;
|
||||
}
|
||||
String shapeId1 = UUIDGener.getObjectId();
|
||||
// System.out.println("段落内容===" + para.getParagraphText());//段落内容
|
||||
lastindex = onlinedata.size() - 1;
|
||||
// 获取级数
|
||||
int len = strb.length() / 8 - 2;
|
||||
int pnode = lastindex;
|
||||
int nowlevel = 0;
|
||||
if (numlevel != null) {
|
||||
nowlevel = numlevel.intValue();
|
||||
}
|
||||
/*
|
||||
* if (lastindex == nowlevel) { JSONObject tmpshap1 =
|
||||
* onlinedata.getJSONObject(lastindex); pnode = tmpshap1.getInteger("p"); }
|
||||
*/
|
||||
x = 1;
|
||||
JSONObject tmpshap = onlinedata.getJSONObject(lastindex);
|
||||
// 根据上一个位置计算当前位置
|
||||
shap = getSharp(x, y, countall, len, tmpshap, strb.toString(), "item1");
|
||||
shap.put("id", shapeId1);
|
||||
shap.put("text", getShowText(strb.toString()).replaceAll("\n", ""));
|
||||
// shap.put("p", pnode);
|
||||
shap.put("level", 0);
|
||||
|
||||
JSONObject linkshap = onlinedata.getJSONObject(lastindex);
|
||||
craetline(elements, linkshap, shap, countall);
|
||||
linkshap.put("next", true);
|
||||
onlinedata.set(pnode, linkshap);
|
||||
elements.put(shapeId1, shap);
|
||||
strb = new StringBuilder();
|
||||
} else {
|
||||
strb.append(para.getParagraphText()).append("\n");
|
||||
// 拼接富文本标签
|
||||
richSbuild.append(DocToHtml.getHtml(0, para.getParagraphText()));
|
||||
}
|
||||
lastislast = true;
|
||||
lastindex = 0;
|
||||
}
|
||||
}
|
||||
// 将doc保存为富文本
|
||||
if (type == 1) {
|
||||
saveRichText(userContext, richSbuild, plid, shapefirst.getString("id"));
|
||||
}
|
||||
// new WordCreatFile().createFile(newfile);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
// 会在本地产生临时文件,用完后需要删除
|
||||
/*
|
||||
* if (file.exists()) { //file.delete(); }
|
||||
*/
|
||||
}
|
||||
if (count > 0) {
|
||||
return elements;
|
||||
// 将doc保存为富文本
|
||||
if (type == 1) {
|
||||
saveRichText(userContext, richSbuild, plid, shapefirst.getString("id"));
|
||||
}
|
||||
// new WordCreatFile().createFile(newfile);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
// 会在本地产生临时文件,用完后需要删除
|
||||
/*
|
||||
* if (file.exists()) { //file.delete(); }
|
||||
*/
|
||||
}
|
||||
if (count > 0) {
|
||||
return elements;
|
||||
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1044,4 +1052,43 @@ public class WordUtilXWPF {
|
||||
}
|
||||
return titleLvl;
|
||||
}
|
||||
/**
|
||||
* 将文件挂载到附件
|
||||
*
|
||||
* @param me
|
||||
* @param reid
|
||||
* @param filename
|
||||
* @param inputStream
|
||||
* @param pl_uuid
|
||||
* @param type
|
||||
* @throws FileNotFoundException
|
||||
*/
|
||||
public boolean writeFileTodisk(UserContext me, String reid, String filename, InputStream inputStream, String pl_uuid, String type) throws FileNotFoundException {
|
||||
//InputStream ins = new FileInputStream("");
|
||||
DCPluginProfile fileProfile = DCProfileManager.getDCProfile(CoEConstant.APP_ID, CoeFileConstant.COE_UPFILE);
|
||||
DCContext dcContextpdf = null;
|
||||
//创建数据库数据
|
||||
UpfileModel model = new UpfileModel();
|
||||
model.setPl_uuid(pl_uuid);
|
||||
if ("f".equals(type)) {
|
||||
model.setShape_uuid("");
|
||||
model.setType("f");
|
||||
dcContextpdf = new DCContext(me, fileProfile, CoEConstant.APP_ID, "file", pl_uuid, filename);
|
||||
} else {
|
||||
//dcContextpdf = new DCContext(me, fileProfile, CoEConstant.APP_ID, "file", pl_uuid, filename);
|
||||
dcContextpdf = new DCContext(me, fileProfile, CoEConstant.APP_ID, pl_uuid, reid, filename);
|
||||
model.setShape_uuid(reid);
|
||||
model.setType("s");
|
||||
}
|
||||
SDK.getDCAPI().write(inputStream, dcContextpdf);
|
||||
model.setUuid(UUIDGener.getUUID());
|
||||
model.setFileName(filename);
|
||||
model.setDownload(1);
|
||||
model.setCreateUser(me.getUID());
|
||||
model.setCreateTime(new Timestamp(System.currentTimeMillis()));
|
||||
if(new UpFileDao().create(model)>0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -801,14 +801,14 @@
|
||||
<!-- <div id="bar_activityNo" awsui-qtip='节点编号排序' class="toolbar_button">
|
||||
<div class="ico extend_activityNo"></div>
|
||||
</div>-->
|
||||
<div id="bar_importShape" awsui-qtip='上传附件并创建相应节点' class="toolbar_button" style="<#importShapeStyle>">
|
||||
<!-- <div id="bar_importShape" awsui-qtip='上传附件并创建相应节点' class="toolbar_button" style="<#importShapeStyle>">
|
||||
<div class="ico ico_importShape"></div>
|
||||
</div>
|
||||
</div>-->
|
||||
|
||||
<div id="QualityInspection" awsui-qtip='质量检测' class="toolbar_button">
|
||||
<div class="ico QualityInspection"></div>
|
||||
</div>
|
||||
<div id="bar_importPolicyFile" awsui-qtip='上传附件并创建制度' class="toolbar_button" style="<#importShapeStyle>">
|
||||
<div id="bar_importPolicyFile" awsui-qtip='上传正文生成条款' class="toolbar_button" style="<#importShapeStyle>">
|
||||
<div class="ico ico_importShape"></div>
|
||||
</div>
|
||||
<!-- <div id="bar_import" awsui-qtip='导入' class="toolbar_button" style="<#importStyle>">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user