制度手册段落迁移验证
This commit is contained in:
parent
a21a504b5e
commit
0e266fcd27
@ -71,7 +71,7 @@ $(function() {
|
||||
fileValue:fileValue,
|
||||
// filesToFilter: [["Images (*.jpg; *.jpeg; *.gif; *.png; *.bmp)","Document (*.doc;*.docx;*.xls;*.xlsx;*.ppt;*.pptx;*.pdf;)", "*.jpg; *.jpeg; *.gif; *.png; *.bmp; *.pdf; *.doc; *.docx; *.xls; *.xlsx; *.ppt; *.pptx; *.txt"]],
|
||||
filesToFilter: [["Images (*.jpg; *.jpeg; *.gif; *.png; *.bmp),Document (*.doc;*.docx;*.xls;*.xlsx;*.ppt;*.pptx;*.pdf;), Video (*.mp3; *.mp4; *.avi; *.mpeg; *.flv; *.swf; *.wmv)",
|
||||
"*.jpg; *.jpeg; *.gif; *.png; *.bmp; *.pdf; *.doc; *.docx; *.xls; *.xlsx; *.ppt; *.pptx; *.txt,*.mp3; *.mp4; *.avi; *.mpeg; *.flv; *.swf; *.wmv"]],
|
||||
"*.jpg; *.jpeg; *.gif; *.png; *.bmp; *.pdf; *.doc; *.docx; *.xls; *.xlsx; *.ppt; *.pptx; *.txt,*.mp3; *.mp4; *.avi; *.mpeg; *.flv; *.swf; *.wmv; *.xml"]],
|
||||
repositoryName: repositoryName,
|
||||
numLimit : 0,
|
||||
sizeLimit : 500 * 1024 * 1024,
|
||||
@ -79,6 +79,7 @@ $(function() {
|
||||
//事件回调函数
|
||||
},
|
||||
add: function(e, data) { //附件被添加到上传列表时触发,当返回false时,可阻止上传
|
||||
debugger;
|
||||
if (data.files.length == 0) {
|
||||
return false;
|
||||
}
|
||||
@ -114,7 +115,7 @@ $(function() {
|
||||
}
|
||||
//阻止非支持类型文件的上传
|
||||
var suffix = data.files[0].name.substring(data.files[0].name.lastIndexOf(".") + 1);
|
||||
var fileTypes = "jpg,jpeg,gif,png,bmp,pdf,doc,docx,ppt,pptx,xls,xlsx,txt,mp3,mp4,avi,mpeg,flv,swf,wmv";
|
||||
var fileTypes = "jpg,jpeg,gif,png,bmp,pdf,doc,docx,ppt,pptx,xls,xlsx,txt,mp3,mp4,avi,mpeg,flv,swf,wmv,xml";
|
||||
if (fileTypes.indexOf(suffix) < 0) {
|
||||
upfileAccessoryTmpObj[data.files[0].name] = {
|
||||
status: 'error',
|
||||
|
||||
Binary file not shown.
@ -1,6 +1,7 @@
|
||||
package com.awspaas.apps.coe.pal.output.zd.report1;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
@ -39,6 +40,10 @@ import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.awspaas.apps.coe.pal.output.zd.util.PrReportComment;
|
||||
import com.awspaas.apps.coe.pal.output.zd.util.ReportRepositoryCompare;
|
||||
import com.awspaas.apps.coe.pal.output.zd.util.XMLUtil;
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.DocumentException;
|
||||
import org.dom4j.Element;
|
||||
|
||||
import static com.actionsoft.apps.coe.pal.pal.output.util.OutputWordUtil.specialCharTransfer;
|
||||
|
||||
@ -85,7 +90,8 @@ public class Report1Gener {
|
||||
OutputAppProfile appModel = OutputAppManager.getProfile(model.getProfileId());
|
||||
String tempPath = appModel.getAppContext().getPath();
|
||||
//String tempName = "步骤横表-流程手册.xml";
|
||||
String tempName = "制度-手册(修改中).xml";
|
||||
// String tempName = "制度-手册(修改中).xml";
|
||||
String tempName = "伊利集团流程制度类文件管理规范.xml";
|
||||
log.info("begin...");
|
||||
log.info("-------------------");
|
||||
// ----文件处理-----
|
||||
@ -160,19 +166,134 @@ public class Report1Gener {
|
||||
}
|
||||
JSONObject dataMap = getData(repositoryId, wizardJsonData, docPath, fileName);
|
||||
if (dataMap != null) {
|
||||
// OutputWordUtil.createDoc2(dataMap, tempPath, tempName, docName);
|
||||
OutputWordUtil.createDoc2(dataMap, tempPath, tempName, docName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private JSONObject getData(String repositoryId, JSONObject wizardJsonData, String docPath, String fileName) {
|
||||
PALRepositoryModel repositoryModel = PALRepositoryQueryAPIManager.getInstance().queryPalRepositoryModelByPalId(repositoryId);
|
||||
if (repositoryModel == null) {
|
||||
return null;
|
||||
}
|
||||
JSONObject dataMap = new JSONObject();
|
||||
String content = "";
|
||||
// 读取附件
|
||||
// 流程附件列表
|
||||
UpFileDao upFileDao = new UpFileDao();
|
||||
StringBuffer sqlWhere = new StringBuffer();
|
||||
sqlWhere.append(" and PALREPOSITORYID ='").append(repositoryModel.getId()).append("'");
|
||||
List<UpfileModel> search = upFileDao.search(sqlWhere.toString());
|
||||
|
||||
DCContext dc = null;
|
||||
File file = null;
|
||||
if (search != null && search.size() > 0) {
|
||||
// 复制附件
|
||||
for (UpfileModel upfileModel : search) {
|
||||
if (!"f".equals(upfileModel.getType())) {// 文件
|
||||
continue;
|
||||
}
|
||||
if (upfileModel.getFileName().contains(".xml")) {
|
||||
DCPluginProfile dcProfile = DCProfileManager.getDCProfile(CoEConstant.APP_ID, CoeFileConstant.COE_UPFILE);
|
||||
if (dcProfile != null) {
|
||||
dc = new DCContext(userContext, dcProfile, CoEConstant.APP_ID, "file", upfileModel.getPl_uuid(), upfileModel.getFileName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (dc != null) {
|
||||
file = new File(dc.getFilePath());
|
||||
}
|
||||
if (file != null) {
|
||||
// 解析xml文件
|
||||
// 校验xml文档是否能够正常解析
|
||||
// Document doc = analysisXMLFile(file.getPath(), true);
|
||||
// if (doc == null) {
|
||||
// System.out.println("解析xml失败");
|
||||
// return null;
|
||||
// }
|
||||
// // 解析根节点
|
||||
// Element root = doc.getRootElement();
|
||||
// // System.out.println(root.getName());
|
||||
// Element body = root.element("body");
|
||||
// if (body != null) {
|
||||
// // System.out.println(body.getName());
|
||||
// // System.out.println(body.asXML());
|
||||
// List<Element> childList = body.elements();
|
||||
// if (childList != null) {
|
||||
// for (Element e : childList) {
|
||||
// content += e.asXML();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// 获取字符串
|
||||
content = getFileContent(file);
|
||||
content = content.substring(content.indexOf("<wx:sect>") + 9, content.indexOf("<w:sectPr"));
|
||||
|
||||
}
|
||||
dataMap.put("content", content);
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
public static String getFileContent(File file) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
InputStreamReader reader = null;
|
||||
BufferedReader br = null;
|
||||
try {
|
||||
reader = new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8);
|
||||
br = new BufferedReader(reader);
|
||||
String s;
|
||||
while ((s = br.readLine()) != null) {
|
||||
builder.append(s);
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (reader != null) {
|
||||
reader.close();
|
||||
}
|
||||
if (br != null) {
|
||||
br.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文档数据
|
||||
* @param repositoryId
|
||||
* @param wizardJsonData
|
||||
* 解析xml文档
|
||||
* @param path
|
||||
* @param b
|
||||
* @return
|
||||
*/
|
||||
private JSONObject getData(String repositoryId, JSONObject wizardJsonData, String docPath, String fileName) {
|
||||
private Document analysisXMLFile(String path, boolean b) {
|
||||
Document d = null;
|
||||
try {
|
||||
d = XMLUtil.readXML(path, true);
|
||||
} catch (DocumentException e) {
|
||||
e.printStackTrace();
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取文档数据
|
||||
* @param repositoryId
|
||||
* @param wizardJsonData
|
||||
* @return
|
||||
*/
|
||||
private JSONObject getData2(String repositoryId, JSONObject wizardJsonData, String docPath, String fileName) {
|
||||
JSONObject dataMap = new JSONObject();
|
||||
dataMap.put("organizationType", "涉及部门及岗位\\角色");
|
||||
boolean raciRelationType = SDK.getAppAPI().getPropertyBooleanValue("com.awspaas.user.apps.coe.pal.output.zd", "DETY_POSITION_ROLE_RELATION_TYPE", false);
|
||||
|
||||
@ -0,0 +1,124 @@
|
||||
package com.awspaas.apps.coe.pal.output.zd.util;
|
||||
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.DocumentException;
|
||||
import org.dom4j.DocumentHelper;
|
||||
import org.dom4j.Element;
|
||||
import org.dom4j.io.OutputFormat;
|
||||
import org.dom4j.io.SAXReader;
|
||||
import org.dom4j.io.XMLWriter;
|
||||
import org.xml.sax.EntityResolver;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* XML读取帮助类
|
||||
* @author zhouxuan
|
||||
*/
|
||||
public class XMLUtil {
|
||||
|
||||
/**
|
||||
* copy数据,将unicode数据转换为中文
|
||||
* @param fromFilePath
|
||||
* @param toFilePath
|
||||
*/
|
||||
public static void unicode2String(String fromFilePath, String toFilePath) throws DocumentException, FileNotFoundException{
|
||||
Document d = XMLUtil.readXML(fromFilePath, true);
|
||||
XMLUtil.writeXml(d, toFilePath);
|
||||
}
|
||||
|
||||
public static Document readXML(String filePath, boolean ignoreDtd) throws DocumentException, FileNotFoundException {
|
||||
if (filePath == null) {
|
||||
return null;
|
||||
}
|
||||
SAXReader reader = new SAXReader();
|
||||
if (ignoreDtd) {
|
||||
reader.setValidation(false);
|
||||
reader.setEntityResolver(new EntityResolver() {
|
||||
@Override
|
||||
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
|
||||
return new InputSource(new ByteArrayInputStream("<?xml version='1.0' encoding='UTF-8'?>".getBytes()));
|
||||
}
|
||||
});
|
||||
}
|
||||
Document document = null;
|
||||
try {
|
||||
int jarIndicator = filePath.indexOf('!');
|
||||
if (jarIndicator > 0) {
|
||||
filePath = filePath.substring(5, filePath.indexOf('!'));
|
||||
}
|
||||
File f = new File(filePath);
|
||||
InputStream in = new FileInputStream(f);
|
||||
if (in != null) {
|
||||
document = reader.read(in);
|
||||
} else {
|
||||
File file = new File(filePath);
|
||||
document = reader.read(file);
|
||||
}
|
||||
|
||||
return document;
|
||||
} catch (DocumentException e) {
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
public static Document readXMLFromInputStream(InputStream in) {
|
||||
Document document = null;
|
||||
SAXReader reader = new SAXReader();
|
||||
|
||||
try {
|
||||
document = reader.read(in);
|
||||
} catch (DocumentException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return document;
|
||||
}
|
||||
|
||||
public static void writeXml(Document document, String filePath) {
|
||||
File xmlFile = new File(filePath);
|
||||
XMLWriter writer = null;
|
||||
try {
|
||||
if (xmlFile.exists())
|
||||
xmlFile.delete();
|
||||
writer = new XMLWriter(new FileOutputStream(xmlFile), OutputFormat.createPrettyPrint());
|
||||
writer.write(document);
|
||||
writer.close();
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (writer != null) {
|
||||
try {
|
||||
writer.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Document createDocument(String rootName, String attributeName, String attributeVaule) {
|
||||
Document document = null;
|
||||
try {
|
||||
document = DocumentHelper.createDocument();
|
||||
Element root = document.addElement(rootName);
|
||||
root.addAttribute(attributeName, attributeVaule);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e + "->创建的【" + rootName + "】根节点出现错误");
|
||||
}
|
||||
return document;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
7486
com.awspaas.user.apps.coe.pal.output.zd/伊利集团流程制度类文件管理规范.xml
Normal file
7486
com.awspaas.user.apps.coe.pal.output.zd/伊利集团流程制度类文件管理规范.xml
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user