替换常量CoEConstant引用路径

This commit is contained in:
chengli 2022-07-01 17:24:28 +08:00
parent 413b303fd2
commit 14e0d08fdc

View File

@ -6,7 +6,7 @@ package com.actionsoft.apps.coe.pal.datamigration.util.readword;
* @date 2022/6/21 17:21
*/
import com.actionsoft.apps.coe.pal.datamigration.constant.CoEConstant;
import com.actionsoft.apps.coe.pal.constant.CoEConstant;
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;
@ -37,13 +37,17 @@ public class WordFinal {
/**
* 文档内附件复制
*
* @param args
* @param me
* @param reid PAL模型id
* @param inputStream 文档流
* @param pluuid
* @param mactchs 匹配规则
* @param type 类型 f文件 s图形
* @throws IOException
* @throws XmlException
* @throws OpenXML4JException
*/
public void copyWord(UserContext me, String reid, InputStream inputStream, String pluuid) throws IOException, XmlException, OpenXML4JException {
public void copyWord(UserContext me, String reid, InputStream inputStream, String pluuid,String mactchs,String type) throws IOException, XmlException, OpenXML4JException {
//XWPFDocument srcDoc = new XWPFDocument(new FileInputStream("/Users/jiuyabai/Desktop/yili项目/制度样例2—创新中心功效研究管理办法1.docx"));
XWPFDocument srcDoc = new XWPFDocument(inputStream);
//XWPFDocument srcDoc = new XWPFDocument(new FileInputStream("/Users/jiuyabai/Desktop/yili项目/测试附件.docx"));
@ -64,12 +68,11 @@ public class WordFinal {
if (elementType == BodyElementType.PARAGRAPH) {
XWPFParagraph srcPr = (XWPFParagraph) bodyElement;
String tmptext = srcPr.getParagraphText();
if (tmptext.matches("附件\\d{1,}")) {
//if (tmptext.matches("附件:")) {
if (tmptext.matches(mactchs)) {
if (count != 1) {
destDoc.write(out);
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
writeFileTodisk(me, reid, filename, in, pluuid);
writeFileTodisk(me, reid, filename, in, pluuid,type);
out.close();
}
isstart = true;
@ -147,7 +150,7 @@ public class WordFinal {
if(count != 1){
destDoc.write(out);
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
writeFileTodisk(me, reid, filename, in, pluuid);
writeFileTodisk(me, reid, filename, in, pluuid,type);
out.close();
}
}
@ -158,7 +161,7 @@ public class WordFinal {
* @param reid 制度图id
* @throws FileNotFoundException
*/
public void writeFileTodisk(UserContext me, String reid, String filename, ByteArrayInputStream inputStream, String pl_uuid) throws FileNotFoundException {
public void writeFileTodisk(UserContext me, String reid, String filename, ByteArrayInputStream inputStream, String pl_uuid,String type) throws FileNotFoundException {
//InputStream ins = new FileInputStream("");
DCPluginProfile fileProfile = DCProfileManager.getDCProfile(CoEConstant.APP_ID, CoeFileConstant.COE_UPFILE);
DCContext dcContextpdf = new DCContext(me, fileProfile, CoEConstant.APP_ID, "file", reid, filename);
@ -168,10 +171,16 @@ public class WordFinal {
SDK.getDCAPI().write(inputStream, dcContextpdf);
//创建数据库数据
UpfileModel model = new UpfileModel();
model.setShape_uuid("");
model.setType("f");
if("f".equals(type)){
model.setShape_uuid("");
model.setType("f");
model.setPl_uuid(reid);
}else {
model.setShape_uuid(reid);
model.setType("s");
model.setPl_uuid("");
}
model.setUuid(UUIDGener.getUUID());
model.setPl_uuid(reid);
model.setFileName(filename);
model.setDownload(1);
model.setCreateUser(me.getUID());