diff --git a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/DataMigrationController.java b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/DataMigrationController.java index df6a6d4d..a44c00c9 100644 --- a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/DataMigrationController.java +++ b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/DataMigrationController.java @@ -1,6 +1,7 @@ package com.actionsoft.apps.coe.pal.datamigration; import com.actionsoft.apps.coe.pal.datamigration.aris.web.ArisXmlImportWeb; +import com.actionsoft.apps.coe.pal.datamigration.util.readtable.ReadTable; import com.actionsoft.apps.coe.pal.datamigration.util.readword.ReadWordUtil; import com.actionsoft.apps.coe.pal.datamigration.web.DataMigrationWeb; import com.actionsoft.bpms.commons.mvc.view.ResponseObject; @@ -58,6 +59,23 @@ public class DataMigrationController { return ro.toString(); } + /** + * by bzp 表单属性文件上传 解析文件 + * @param me + * @param wsId + * @param groupValue + * @param fileValue + * @param fileName + * @return + */ + @Mapping("com.actionsoft.apps.coe.pal.formImport_process_attribute_import") + public String formattributeimport(UserContext me,String wsId,String groupValue,String fileValue,String fileName){ + new ReadTable().getTableInfo(me,wsId,groupValue,fileValue,fileName); + //new DataMigrationWeb().translateDocToTable(me,wsId,groupValue,fileValue,fileName); + ResponseObject ro = ResponseObject.newOkResponse(); + return ro.toString(); + } + /** * 查询aris流程导入日志 * @param uc diff --git a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/htmltodocx/HtmlToWord.java b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/htmltodocx/HtmlToWord.java index b5ba58c6..e3fb0647 100644 --- a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/htmltodocx/HtmlToWord.java +++ b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/htmltodocx/HtmlToWord.java @@ -1,13 +1,10 @@ -/* package com.actionsoft.apps.coe.pal.datamigration.util.htmltodocx; -*/ /** * @author baizp * @Description: * @date 2022/6/24 16:01 - *//* - + */ import org.docx4j.dml.wordprocessingDrawing.Inline; import org.docx4j.jaxb.Context; @@ -31,26 +28,22 @@ import java.io.*; import java.math.BigInteger; import java.util.List; -*/ /** * @program: htmltoword * @description: html 转 docx * @author: corey * @create: 2020-04-29 14:10 - **//* - + **/ public class HtmlToWord { private static ObjectFactory factory; private static WordprocessingMLPackage wordMLPackage; - */ -/** + /** * 将一段富文本字符串转为一个字节数组 * * @param data * @return - *//* - + */ public static byte[] resolveHtml(String data) { Document document = Jsoup.parseBodyFragment(data, "UTF-8"); ByteArrayOutputStream out = null; @@ -79,16 +72,16 @@ public class HtmlToWord { documentPart.addStyledParagraphOfText("Subtitle", em.text()); break; case "imgurl": - String imgSrc = em.attr("src"); + /*String imgSrc = em.attr("src"); File file = new File(imgSrc); byte[] bytes = convertImageToByteArray(file); - addImageToPackage(wordMLPackage, bytes); + addImageToPackage(wordMLPackage, bytes);*/ break; case "imgbase64": break; case "table": - Tbl table = addTable(em); - documentPart.addObject(table); + /*Tbl table = addTable(em); + documentPart.addObject(table);*/ break; case "h1": P tmp = documentPart.addStyledParagraphOfText("Heading1", em.text()); @@ -151,28 +144,20 @@ public class HtmlToWord { public static void setNum1(int level,P p){ - */ -/*ObjectFactory factory = new org.docx4j.wml.ObjectFactory(); - P p = factory.createP();*//* + /*ObjectFactory factory = new org.docx4j.wml.ObjectFactory(); + P p = factory.createP();*/ + /*org.docx4j.wml.Text t = factory.createText(); + t.setValue(em.text());*/ - */ -/*org.docx4j.wml.Text t = factory.createText(); - t.setValue(em.text());*//* - - - */ -/*org.docx4j.wml.R run = factory.createR(); + /*org.docx4j.wml.R run = factory.createR(); run.getContent().add(t); - p.getContent().add(run);*//* + p.getContent().add(run);*/ + /*org.docx4j.wml.PPr ppr = factory.createPPr(); - */ -/*org.docx4j.wml.PPr ppr = factory.createPPr(); - - p.setPPr(ppr);*//* - + p.setPPr(ppr);*/ org.docx4j.wml.PPr ppr =p.getPPr(); // Create and add PPrBase.NumPr numPr = factory.createPPrBaseNumPr(); @@ -191,16 +176,14 @@ public class HtmlToWord { //wordMLPackage.getMainDocumentPart().addObject(p); } - */ -/** + /** * @param @param text * @param @return 设定文件 * @return P 返回类型 * @throws * @Title: addParapraph * @Description: (文本转段落) - *//* - + */ private static P addParapraph(String text) { factory = Context.getWmlObjectFactory(); P paragraph = factory.createP(); @@ -214,15 +197,13 @@ public class HtmlToWord { return paragraph; } - */ -/** + /** * @param @param p * @param @param str 设定文件 * @return void 返回类型 * @throws * @Title: setFirstLine - *//* - + */ private static void setFirstLine(P p, String str) { PPr ppr = getPPr(p); Ind ind = ppr.getInd(); @@ -244,11 +225,9 @@ public class HtmlToWord { return ppr; } - */ -/** + /** * table @param @return 设定文件 @return Tbl 返回类型 @throws - *//* - + */ private static Tbl addTable(Element table) { factory = Context.getWmlObjectFactory(); Tbl tbl = factory.createTbl(); @@ -261,11 +240,9 @@ public class HtmlToWord { return tbl; } - */ -/** + /** * tr @param @return 设定文件 @return Tr 返回类型 @throws - *//* - + */ private static Tr addTableTr(Element tr) { Elements tds = tr.getElementsByTag("th").isEmpty() ? tr.getElementsByTag("td") : tr.getElementsByTag("th"); Tr ftr = factory.createTr(); @@ -278,11 +255,9 @@ public class HtmlToWord { return ftr; } - */ -/** + /** * 本方法创建一个单元格属性集对象和一个表格宽度对象. 将给定的宽度设置到宽度对象然后将其添加到 属性集对象. 最后将属性集对象设置到单元格中. - *//* - + */ private static void setCellWidth(Tc tableCell, int width) { TcPr tableCellProperties = new TcPr(); TblWidth tableWidth = new TblWidth(); @@ -291,11 +266,9 @@ public class HtmlToWord { tableCell.setTcPr(tableCellProperties); } - */ -/** + /** * 本方法为表格添加边框 - *//* - + */ private static void addBorders(Tbl table) { table.setTblPr(new TblPr()); CTBorder border = new CTBorder(); @@ -314,16 +287,14 @@ public class HtmlToWord { table.getTblPr().setTblBorders(borders); } - */ -/** + /** * 将图片从文件对象转换成字节数组. * * @param file 将要转换的文件 * @return 包含图片字节数据的字节数组 * @throws FileNotFoundException * @throws IOException - *//* - + */ private static byte[] convertImageToByteArray(File file) throws FileNotFoundException, IOException { InputStream is = new FileInputStream(file); long length = file.length(); @@ -345,8 +316,7 @@ public class HtmlToWord { return bytes; } - */ -/** + /** * Docx4j拥有一个由字节数组创建图片部件的工具方法, 随后将其添加到给定的包中. 为了能将图片添加 到一个段落中, 我们需要将图片转换成内联对象. * 这也有一个方法, 方法需要文件名提示, 替换文本, 两个id标识符和一个是嵌入还是链接到的指示作为参数. 一个id用于文档中绘图对象不可见的属性, * 另一个id用于图片本身不可见的绘制属性. 最后我们将内联 对象添加到段落中并将段落添加到包的主文档部件. @@ -354,8 +324,7 @@ public class HtmlToWord { * @param wordMLPackage 要添加图片的包 * @param bytes 图片对应的字节数组 * @throws Exception 不幸的createImageInline方法抛出一个异常(没有更多具体的异常类型) - *//* - + */ private static void addImageToPackage(WordprocessingMLPackage wordMLPackage, byte[] bytes) throws Exception { BinaryPartAbstractImage imagePart = BinaryPartAbstractImage.createImagePart(wordMLPackage, bytes); @@ -368,15 +337,13 @@ public class HtmlToWord { wordMLPackage.getMainDocumentPart().addObject(paragraph); } - */ -/** + /** * 创建一个对象工厂并用它创建一个段落和一个可运行块R. 然后将可运行块添加到段落中. 接下来创建一个图画并将其添加到可运行块R中. 最后我们将内联 * 对象添加到图画中并返回段落对象. * * @param inline 包含图片的内联对象. * @return 包含图片的段落 - *//* - + */ private static P addInlineImageToParagraph(Inline inline) { // 添加内联对象到一个段落中 ObjectFactory factory = new ObjectFactory(); @@ -389,8 +356,7 @@ public class HtmlToWord { return paragraph; } - */ -/** + /** * This method alters the default style sheet that is part of each document. *

* To do this, we first retrieve the style sheet from the package and then get @@ -399,8 +365,7 @@ public class HtmlToWord { * the alterations if applicable. * * @param - *//* - + */ public static void alterStyleSheet() { StyleDefinitionsPart styleDefinitionsPart = wordMLPackage.getMainDocumentPart().getStyleDefinitionsPart(); Styles styles = null; @@ -424,14 +389,12 @@ public class HtmlToWord { } } - */ -/** + /** * First we create a run properties object as we want to remove nearly all of * the existing styling. Then we change the font and font size and set the run * properties on the given style. As in previous examples, the font size is * defined to be in half-point size. - *//* - + */ private static void alterNormalStyle(Style style) { // we want to change (or remove) almost all the run properties of the // normal style, so we create a new one. @@ -441,20 +404,16 @@ public class HtmlToWord { style.setRPr(rpr); } - */ -/** + /** * For this style, we get the existing run properties from the style and remove * the theme font information from them. Then we also remove the bold styling, * change the font size (half-points) and add an underline. - *//* - + */ private static void alterHeading1Style(Style style) { RPr rpr = getRunPropertiesAndRemoveThemeInfo(style); removeBoldStyle(rpr); changeFontSize(rpr, 28); - */ -/* addUnderline(rpr); *//* - + /* addUnderline(rpr); */ } private static void alterHeading2Style(Style style) { @@ -462,9 +421,7 @@ public class HtmlToWord { removeBoldStyle(rpr); changeFontSize(rpr, 24); - */ -/* addUnderline(rpr); *//* - + /* addUnderline(rpr); */ } private static RPr getRunPropertiesAndRemoveThemeInfo(Style style) { @@ -475,8 +432,7 @@ public class HtmlToWord { return rpr; } - */ -/** + /** * Change the font of the given run properties to Arial. *

* A run font specifies the fonts which shall be used to display the contents of @@ -485,8 +441,7 @@ public class HtmlToWord { * properties. * * @param runProperties - *//* - + */ private static void changeFontToArial(RPr runProperties) { RFonts runFont = new RFonts(); runFont.setAscii("Arial"); @@ -494,55 +449,47 @@ public class HtmlToWord { runProperties.setRFonts(runFont); } - */ -/** + /** * Change the font size of the given run properties to the given value. * * @param runProperties * @param fontSize Twice the size needed, as it is specified as half-point value - *//* - + */ private static void changeFontSize(RPr runProperties, int fontSize) { HpsMeasure size = new HpsMeasure(); size.setVal(BigInteger.valueOf(fontSize)); runProperties.setSz(size); } - */ -/** + /** * Removes the theme font information from the run properties. If this is not * removed then the styles based on the normal style won't inherit the Arial * font from the normal style. * * @param runProperties - *//* - + */ private static void removeThemeFontInformation(RPr runProperties) { runProperties.getRFonts().setAsciiTheme(null); runProperties.getRFonts().setHAnsiTheme(null); } - */ -/** + /** * Removes the Bold styling from the run properties. * * @param runProperties - *//* - + */ private static void removeBoldStyle(RPr runProperties) { runProperties.getB().setVal(false); } - */ -/** + /** * As in the previous example, this method creates a footer part and adds it to * the main document and then returns the corresponding relationship. * * @return * @throws InvalidFormatException - *//* - + */ private static Relationship createFooterPart() throws InvalidFormatException { FooterPart footerPart = new FooterPart(); footerPart.setPackage(wordMLPackage); @@ -552,8 +499,7 @@ public class HtmlToWord { return wordMLPackage.getMainDocumentPart().addTargetPart(footerPart); } - */ -/** + /** * As in the previous example, we create a footer and a paragraph object. But * this time, instead of adding text to a run, we add a field. And just as with * the table of content, we have to add a begin and end character around the @@ -561,8 +507,7 @@ public class HtmlToWord { * content of the footer and then return it. * * @return - *//* - + */ public static Ftr createFooterWithPageNr() { Ftr ftr = factory.createFtr(); P paragraph = factory.createP(); @@ -575,8 +520,7 @@ public class HtmlToWord { return ftr; } - */ -/** + /** * Creating the page number field is nearly the same as creating the field in * the TOC example. The only difference is in the value. We use the PAGE * command, which prints the number of the current page, together with the @@ -584,8 +528,7 @@ public class HtmlToWord { * preserved when the field is updated. * * @param paragraph - *//* - + */ private static void addPageNumberField(P paragraph) { R run = factory.createR(); Text txt = new Text(); @@ -595,14 +538,12 @@ public class HtmlToWord { paragraph.getContent().add(run); } - */ -/** + /** * Every fields needs to be delimited by complex field characters. This method * adds the delimiter that precedes the actual field to the given paragraph. * * @param paragraph - *//* - + */ private static void addFieldBegin(P paragraph) { R run = factory.createR(); FldChar fldchar = factory.createFldChar(); @@ -611,14 +552,12 @@ public class HtmlToWord { paragraph.getContent().add(run); } - */ -/** + /** * Every fields needs to be delimited by complex field characters. This method * adds the delimiter that follows the actual field to the given paragraph. * * @param paragraph - *//* - + */ private static void addFieldEnd(P paragraph) { FldChar fldcharend = factory.createFldChar(); fldcharend.setFldCharType(STFldCharType.END); @@ -627,14 +566,12 @@ public class HtmlToWord { paragraph.getContent().add(run3); } - */ -/** + /** * This method fetches the document final section properties, and adds a newly * created footer reference to them. * * @param relationship - *//* - + */ public static void createFooterReference(Relationship relationship) { List sections = wordMLPackage.getDocumentModel().getSections(); @@ -653,13 +590,11 @@ public class HtmlToWord { sectPr.getEGHdrFtrReferences().add(footerReference); } - */ -/** + /** * Adds a page break to the document. * * @param documentPart - *//* - + */ private static void addPageBreak(MainDocumentPart documentPart) { Br breakObj = new Br(); breakObj.setType(STBrType.PAGE); @@ -672,5 +607,4 @@ public class HtmlToWord { e.printStackTrace(); } } -} -*/ +} \ No newline at end of file diff --git a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/htmltodocx/Test.java b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/htmltodocx/Test.java index 95281ba9..de6f3f25 100644 --- a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/htmltodocx/Test.java +++ b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/htmltodocx/Test.java @@ -12,7 +12,7 @@ import java.io.OutputStream; */ public class Test { public static void main(String[] args) { - String text = "

4.1 流程制度类文件分类管理

4.1.1 流程制度类文件分类

4.1.2 分类管理原则

4.1.2.1 流程制度类文件不做分级管理,以文件分类为准,业务执行过程中可通过所属流程架构的层级判定流程制度类文件的层级和业务覆盖范围。

4.1.2.2 管理手册通常对应流程架构中一、二级流程,范围覆盖较大业务领域,三级及以下流程相关管理要求的呈现建议使用制度规范。

4.1.2.3 为保证文件分类的清晰界限,制度规范可描述针对流程不同阶段的管理要求,但勿体现流程说明和过程描述性质的内容,如涉及,可以引用相关流程文件,以“参见xxx流程”的形式体现。

4.2 流程制度类文件编制

4.2.1 构成与相关属性

4.2.1.1 文件均由封面、目录、文控信息、修订记录及正文构成。

4.2.1.2 正文一般包括目的、术语定义、组织/角色职责、管理原则(管理规范)、流程图和流程说明(流程文件)

4.2.1.3 文件适用范围:是指流程制度类文件发行后,文件内容所适用的具体单位、组织。

4.2.1.4 文件发放范围:是指包含文件适用范围,以及文件的知悉需求的,文件发送单位(适用范围)、抄送单位的总和。

4.2.2 流程制度类文件命名

4.2.2.1 通用命名原则:明确管理内容、适用范围、文件类型等文件关键要素,无范围歧义,确保文件命名的唯一性,如:《伊利集团内部控制评价管理办法》、《液奶品牌策略制定流程》。

4.2.2.2 各类流程制度类文件命名细则:

1) 流程架构文件:流程架构文件命名为《伊利集团流程架构》

2) 管理手册:依据管理范围命名为“XX管理手册”,如“流程管理手册”“质量管理手册”。

3) 制度规范:制度规范命名规则为“适用范围、管理内容等”+“规范/准则/制度/办法/规则/机制/细则等”,勿使用“方案”等具有明显项目或阶段性管理特征的命名,以免对文件类型产生误导;另外,当文件仅涉及评价标准等管理标准类内容时可使用“标准”进行命名。

4) 流程文件:命名规则=“流程名称”

5) 操作指导:操作指导命名规则为“指导范围、指导内容等”+“操作指导”其中指导内容如为某流程的操作指导,尽可能采用对应流程名称。

6) 表单/模板:“表单/模板适用范围、表单/模板内容等”+“表单”/“模板”

4.2.3 流程制度类文件适用范围设定

流程制度类文件的适用范围是其一个重要属性,需在文控信息及文件编号中明确体现。各单位和组织在文件拟制过程中,需要考虑文件的适用范围合理性,具体原则如下:

集团总部职能部门原则上建议拟制适用于整个公司或者总部职能范围的流程制度类文件,针对某个事业部的流程制度类文件,建议由事业部拟制发布。

事业部职能部门拟制的文件可适用于本事业部、事业部某特定大区或者工厂,不可拟制适用于多个事业部的流程制度类文件。

事业部某大区或者工厂拟制的文件可适用于本大区或者工厂,不可拟制适用于多个工厂或者大区的流程制度类文件。

4.2.4 流程制度类文件编号

流程制度类文件编号根据流程架构参照以下编号规则进行编订,须确保文件编号的唯一性,以方便文件管理。具体如下:

4.2.4.1 文件编号规则

文件整体编号由“文件编号”“版本号”“适用范围”组成,“文件编号”由“架构标号+末级流程编号”“文件类型编码”及“顺序号”组成,其中“架构编号+末级流程编号”与“文件类型编码”之间用“/”隔开,“适用范围”与“版本号”之间用“-”隔开。

整体编号格式为“对应流程架构的架构编号.末级流程编号/文件类型代码+文件顺序号+版本号-适用范围”,方式如下:

 

其中架构编号和末级流程编号为4个两位数字中间用“.”间隔组成,两位数字取值为“0~99”,取值小于10时,补足两位表示,如三级流程“11.1.1”表示为“11.01.01.00”,末级流程“11.1.2.1”表示为“11.01.02.01”

4.2.4.2 适用范围编码规则

适用范围的编号格式为“单位属性代码+区域代码+其他代码”,方式如下:

 

1) 单位属性代码

单位属性代码用代表单位简称的2个字母组成,体现文件的适用范围,包括:集团(全公司)、总部职能(全部)、事业部、分公司、子公司、某总部职能部门,代码表:

单位

编码

集团(全公司)

YL

总部职能

ZB

液奶事业部

YN

酸奶事业部

SN

奶粉事业部

NF

冷饮事业部

LY

奶酪事业部

NL

分公司

FG

子公司

ZG

单位代码表1

单位

编码

单位

编码

总裁办公室

ZC

品牌管理部

PP

战略企划部

ZQ

企业事务部

QS

审计部

SJ

媒介部

MJ

投资管理部

TZ

党群综合部

ZH

董事会办公室

DB

并购部

BG

供应保障部

GY

法律事务部

FL

信息科技中心

XX

质量管理部

ZG

数字化管理办公室

SZ

市场研究部

SC

乳业技术研究院

RY

工程管理部

GC

人力资源部

RL

财务管理部

CW

投资者关系部

TG

国际业务部

GJ

单位代码表2

2) 区域代码

如文件适用范围适用于本单位之下的所有工厂/大区(默认归属到事业部而非分子公司)、或其他分子公司,则区域代码为YY如文件适用范围为某大区、工厂或其以外的分子公司,需使用区域代码进一步明确范围,代码表如下:

工厂/分公司名称

代码

工厂/分公司名称

代码

工厂/分公司名称

代码

工厂/分公司名称

代码

辽宁

LN

包头

BT

云南

YN

长春

CC

黄冈

HG

广西

GX

济源

JY

武汉

WH

西安

XA

多伦

DL

龙游

LY

巴彦淖尔

BY

成都

CD

赤峰

CF

梅州

MZ

锡林浩特

XL

金川

JC

咸阳

XY

齐齐哈尔

QQ

廊坊

LF

定州

DZ

河南

HN

金海

JA

杜蒙

DM

天津

TJ

滦州

LU

苏州

SZ

张北

ZB

广东

GD

黑龙江

HL

金华

JH

林甸

LD

合肥

HF

沈阳

SY

潍坊

WF

临朐

LQ

肇东

ZD

北京

BJ

金山

JS

晋中

JZ

乌鲁木齐

WM

阜新

FX

乌兰察布

WL

贵阳

GY

宁夏

NX

济南

JN

兰州

LZ

太原

TY

哈尔滨

HE

郑州

ZZ

广州

GZ

南昌

NC

大连

DA

长沙

CS

深圳

SH

福建

FJ

吉林省

JL

上海

SA

南宁

NN

青岛

QD

石家庄

SJ

南京

NJ

重庆

CQ

杭州

HA

工厂/分公司代码表

 

大区名称

代码

大区名称

代码

大区名称

代码

B2B)北区

BQ

晋冀蒙大区

JM

浙沪大区

ZH

B2B)东区

DQ

京津大区

JJ

两湖大区

LH

B2B)南区

NQ

京津冀大区

3J

云贵广大区

YG

B2B)西区

XQ

鲁豫大区

YQ

安徽大区

AH

东北大区

DB

蒙晋大区

MJ

江苏大区

SQ

华北大区

HB

闽赣大区

MG

河南大区

HQ

华东大区

HD

苏皖大区

SW

粤海大区

YH

华南大区

HU

西北大区

XB

山东大区

SD

华中大区

HZ

西南大区

XN

华西大区

HX

销售大区代码

子公司名称

代码

子公司名称

代码

印尼乳业

ID

新西兰ODL

NZ

印尼绿色亚洲

IG

西部乳业

WL

泰国Chomthana

TH

伊知牛

YZ

其他分子公司代码

 

3) 其他代码

如文件适用范围为某产品、某业务场景、品类、模块,以及后续可能扩展的其他分类,可使用其他代码,代码命名规则为两位英文字母,由文件编码者进行代码注册申请后方可使用,如,安慕希代码可注册为AM。

如文件范围不涉及产品、业务场景、品类、模块等其他扩展分类,则其他代码为YY。

4) 代码注册

当事业部、职能部门、工厂、销售大区或分子公司等新增、变更,或适用范围为特定某些工厂/区域组合、文件适用范围涉及“其他代码”等现有代码表未覆盖适用范围的情况发生时,由文件编制者向流程制度类文件管理部门申请增加编码,并提供对应的流程责任人信息,获得确认和反馈后,可使用文件编码。

5) 编码示例

全集团适用的文件,适用范围编码为为“YLYYYY”;

仅总部职能适用的文件,适用范围编码为为“ZBYYYY”;

仅液奶事业部适用的文件,适用范围编码为为“YNYYYY”;

仅液奶金川工厂适用的文件,适用范围编码为为“YNJCYY”;

仅奶粉西北大区适用的文件,适用范围编码为“NFXBYY”;

仅液奶事业部安慕希产品适用的文件,适用范围编码为“YNYYAM”

仅北京分公司适用的文件,适用范围编码为“FGBJYY”

仅印尼乳业适用的文件,适用范围编码为“GJIDYY”

仅伊知牛适用的文件,适用范围编码为“ZGYZYY”

4.2.4.3 文件类别号

文件类别号用一位字母表示,具体如下。

序号

文件类别

编码

编码备注

1

流程架构文件

A

Architecture

2

管理手册

M

Manual

3

制度规范

R

Rule

4

流程文件

P

Process

5

操作指导

W

Working Instruction

6

表单\\模板

T

Template

orgdepartmentList = DBSql.getMaps("select * from ORGUSER "); int zindex = 1; - elements = new WordUtilXWPF().rewritContent(elements, inputStream, "制度名称", null); + elements = new WordUtilXWPF().rewritContent(null, elements, inputStream, "制度名称", null, "", 1); // 设置画布大小 setDiagramHeightWidth(definition, elements); @@ -234,8 +235,11 @@ public class CreateMaps implements IJob { * @param file * @param name */ - public void updateMaps(String id, InputStream file, String name) { + public void updateMaps(UserContext userContext, String id, InputStream file, String name) { PALRepositoryModel palRepositoryModel = ReadWordUtil.getRepositoryByName(id, name); + if(palRepositoryModel == null){ + return; + } BaseModel defineModel = CoeDesignerAPIManager.getInstance().getDefinition(palRepositoryModel.getId(), 0); if (defineModel == null) { defineModel = CoeDesignerUtil.createModel(palRepositoryModel.getId(), 0); @@ -249,22 +253,33 @@ public class CreateMaps implements IJob { definition.remove("commonShapeConfig"); } int zindex = 1; - elements = new WordUtilXWPF().rewritContent(elements, file, name, null); + //找到第一个节点 + JSONObject firstNode = new JSONObject(); + for (Map.Entry entry : elements.entrySet()) { + String key = entry.getKey(); + JSONObject value = (JSONObject) entry.getValue(); + if ("regulation".equals(value.getString("name"))) { + firstNode = value; + } + } + elements = new WordUtilXWPF().rewritContent(userContext, elements, file, name, firstNode, palRepositoryModel.getId(), 1); // 设置画布大小 setDiagramHeightWidth(definition, elements); defineModel.setDefinition(definition.toString()); // 保存文件 CoeDesignerAPIManager.getInstance().storeDefinition(defineModel);// dao操作 + } /** * 解析富文本代码 + * * @param plid * @param content * @param shapeId */ - public void updateMapsByRichText(String plid, String content, String shapeId) { + public void updateMapsByRichText(UserContext userContext, String plid, String content, String shapeId) { byte[] result = HtmlToWord.resolveHtml(content); InputStream sbs = new ByteArrayInputStream(result); PALRepositoryModel palRepositoryModel = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(plid); @@ -280,7 +295,7 @@ public class CreateMaps implements IJob { definition.remove("commonShapeConfig"); } int zindex = 1; - elements = new WordUtilXWPF().rewritContent(elements, sbs, "", elements.getJSONObject(shapeId)); + elements = new WordUtilXWPF().rewritContent(userContext, elements, sbs, "", elements.getJSONObject(shapeId), plid, 0); // 设置画布大小 setDiagramHeightWidth(definition, elements); @@ -334,4 +349,4 @@ public class CreateMaps implements IJob { } -} +} \ No newline at end of file diff --git a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/readword/DocToHtml.java b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/readword/DocToHtml.java new file mode 100644 index 00000000..0f77ce51 --- /dev/null +++ b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/readword/DocToHtml.java @@ -0,0 +1,33 @@ +package com.actionsoft.apps.coe.pal.datamigration.util.readword; + +/** + * @author baizp + * @Description: + * @date 2022/7/7 10:44 + */ +public class DocToHtml { + /** + * 将doc转html + * @param level + * @param text + * @return + */ + public static String getHtml(int level,String text){ + if(level == 0){ + return String.format("

%s

",text); + } + if(level == 1){ + return String.format("

%s

",text); + } + if(level == 2){ + return String.format("

%s

",text); + } + if(level == 3){ + return String.format("

%s

",text); + } + if(level >= 4){ + return String.format("

%s

",text); + } + return ""; + } +} diff --git a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/readword/ReadWordUtil.java b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/readword/ReadWordUtil.java index 62720b0e..eca32fa2 100644 --- a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/readword/ReadWordUtil.java +++ b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/readword/ReadWordUtil.java @@ -64,17 +64,17 @@ public class ReadWordUtil { InputStream docfile = new FileInputStream(new File("/Users/jiuyabai/Desktop/yili项目/制度样例1—伊利集团流程制度类文件管理规范(2).doc")); ReadWordUtil tmp = new ReadWordUtil(); boolean result = tmp.analysisWordTable(docfile); - tmp.writeAttrbute(null,docfile, name, id); + tmp.writeAttrbute(null, docfile, name, id); InputStream docxfile = new FileInputStream(new File("/Users/jiuyabai/Desktop/yili项目/制度样例1—伊利集团流程制度类文件管理规范(2).docx")); - new CreateMaps().updateMaps(id, docxfile, name); + new CreateMaps().updateMaps(null, id, docxfile, name); System.out.println(result); } public ReadWordUtil() { } - public void writeAttrbute(UserContext userContext,InputStream file, String name, String wsdl) { + public void writeAttrbute(UserContext userContext, InputStream file, String name, String wsdl) { boolean result = analysisWordTable(file); if (result) { //根据名称获取PAL制度模型 @@ -90,26 +90,26 @@ public class ReadWordUtil { if ("术语".equals(key)) { List nowdata = (List) tmp.getData(); JSONObject jsonObject = new JSONObject(); - jsonObject.put("name","术语"); + jsonObject.put("name", "术语"); JSONArray jsonArray = new JSONArray(); JSONObject jsonObject1 = new JSONObject(); - jsonObject1.put("name","名称"); + jsonObject1.put("name", "名称"); jsonObject1.put("id", "table_head"); - jsonObject1.put("desc","定义"); + jsonObject1.put("desc", "定义"); jsonArray.add(jsonObject1); //存表格 将名称过滤掉 - nowdata.stream().filter(datatmp->{ - return !"名称".equals(((List)datatmp).get(0)); - }).forEach(datatmp->{ + nowdata.stream().filter(datatmp -> { + return !"名称".equals(((List) datatmp).get(0)); + }).forEach(datatmp -> { JSONObject tmpjb = new JSONObject(); - tmpjb.put("name",((List)datatmp).get(0)); + tmpjb.put("name", ((List) datatmp).get(0)); tmpjb.put("id", UUIDGener.getUUID()); - tmpjb.put("desc",((List)datatmp).get(1)); + tmpjb.put("desc", ((List) datatmp).get(1)); //{"name":"术语","table":[{"name":"名称","id":"table_head","desc":"定义"},{"name":"流程责任人","id":"c0723266-bff1-410c-b49e-4332e58cc633","desc":"流程责任人是指对流程全生命周期管理负责的人,流程责任人拥有流程全生命周期管理的权力,同时承担相应的职责,是流程绩效的第一负责人。"},{"name":"业务归属","id":"2e3bbc32-1d3d-4f19-8b2e-75302bf2aed4","desc":"是指流程制度文件所属的流程架构位置以及文件适用范围。"}]} jsonArray.add(tmpjb); }); - jsonObject.put("table",jsonArray); - new CoeProcessLevelWeb(userContext).moreAttrContentSave(id,"term",jsonObject.toJSONString()); + jsonObject.put("table", jsonArray); + new CoeProcessLevelWeb(userContext).moreAttrContentSave(id, "term", jsonObject.toJSONString()); } else if ("支持文件".equals(key) || "相关文件".equals(key)) { //拼文件 List nowdata = (List) tmp.getData(); @@ -128,37 +128,37 @@ public class ReadWordUtil { } } - public void translateDocTDocx(UserContext userContext,String wsId,String groupValue,String fileValue,String fileName){ + public void translateDocTDocx(UserContext userContext, String wsId, String groupValue, String fileValue, String fileName) { DCPluginProfile dcProfilepdf = DCProfileManager.getDCProfile("com.actionsoft.apps.coe.pal.datamigration", "migration"); DCContext dcContextpdf = new DCContext(userContext, dcProfilepdf, "com.actionsoft.apps.coe.pal.datamigration", groupValue, fileValue, fileName); //InputStream docfile = SDK.getDCAPI().read(dcContextpdf); String filepath = dcContextpdf.getFilePath(); String fileNewPath = dcContextpdf.getFilePath(); - String docname = fileName.replace(".docx",".doc"); + String docname = fileName.replace(".docx", ".doc"); String docxname = fileName; - if(fileName.endsWith(".docx")){ - docname = dcContextpdf.getFileName().replace(".docx",".doc"); + if (fileName.endsWith(".docx")) { + docname = dcContextpdf.getFileName().replace(".docx", ".doc"); docxname = dcContextpdf.getFileName(); - fileNewPath = fileNewPath.replace(".docx",".doc"); - try{ + fileNewPath = fileNewPath.replace(".docx", ".doc"); + try { File out = new File(fileNewPath); FileOutputStream outputStream = new FileOutputStream(out); Document doc = new Document(filepath); doc.save(outputStream, SaveFormat.DOC); - }catch (Exception e){ + } catch (Exception e) { e.printStackTrace(); } - }else{ - docxname = dcContextpdf.getFileName().replace(".doc",".docx"); + } else { + docxname = dcContextpdf.getFileName().replace(".doc", ".docx"); docname = dcContextpdf.getFileName(); - fileNewPath = fileNewPath.replace(".doc",".docx"); - try{ + fileNewPath = fileNewPath.replace(".doc", ".docx"); + try { File out = new File(fileNewPath); FileOutputStream outputStream = new FileOutputStream(out); Document doc = new Document(filepath); doc.save(outputStream, SaveFormat.DOCX); - }catch (Exception e){ + } catch (Exception e) { e.printStackTrace(); } } @@ -167,12 +167,11 @@ public class ReadWordUtil { DCContext dcContextpdfdoc = new DCContext(userContext, dcProfilepdfdoc, "com.actionsoft.apps.coe.pal.datamigration", groupValue, fileValue, docname); InputStream docfile = SDK.getDCAPI().read(dcContextpdfdoc); ReadWordUtil tmp = new ReadWordUtil(); - tmp.writeAttrbute(userContext,docfile, docname.replace(".doc",""), wsId); + tmp.writeAttrbute(userContext, docfile, docname.replace(".doc", ""), wsId); DCContext dcContextpdf1 = new DCContext(userContext, dcProfilepdfdoc, "com.actionsoft.apps.coe.pal.datamigration", groupValue, fileValue, docxname); InputStream docxfile = SDK.getDCAPI().read(dcContextpdf1); - new CreateMaps().updateMaps(wsId, docxfile, docxname.replace(".docx","")); - + new CreateMaps().updateMaps(userContext, wsId, docxfile, docxname.replace(".docx", "")); } diff --git a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/readword/WordUtilXWPF.java b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/readword/WordUtilXWPF.java index d71db25c..40cac93a 100644 --- a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/readword/WordUtilXWPF.java +++ b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/readword/WordUtilXWPF.java @@ -4,16 +4,23 @@ import cn.jpush.api.utils.StringUtils; 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.resource.plugin.profile.DCPluginProfile; +import com.actionsoft.bpms.server.UserContext; +import com.actionsoft.bpms.server.fs.DCContext; +import com.actionsoft.bpms.server.fs.dc.DCProfileManager; import com.actionsoft.bpms.util.UUIDGener; +import com.actionsoft.sdk.local.SDK; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; 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; @@ -40,6 +47,7 @@ public class WordUtilXWPF { private static final String regexClearBeginBlank = "^" + splitter + "*|" + splitter + "*$"; + public static void main(String[] args) { JSONObject elements = null; JSONObject shape = null; @@ -100,17 +108,24 @@ public class WordUtilXWPF { } /** - * 重写解析代码 - * + * @param userContext * @param elements + * @param inputStream + * @param name + * @param shapefirst + * @param plid 模型ID + * @param type 是导入还是富文本 1是导入 0是富文本 * @return */ - public JSONObject rewritContent(JSONObject elements, InputStream inputStream, String name, JSONObject shapefirst) { + public JSONObject rewritContent(UserContext userContext, JSONObject elements, InputStream inputStream, String name, JSONObject shapefirst, String plid, int type) { //File file = null; List failTitleList = new ArrayList<>(); + StringBuilder richSbuild = new StringBuilder(); //String filePath = "/Users/jiuyabai/Desktop/yili项目/制度样例1—伊利集团流程制度类文件管理规范1.docx"; try { //file = new File(filePath); + elements.clear(); + elements.put(shapefirst.getString("id"), shapefirst); XWPFDocument doc = new XWPFDocument(inputStream); JSONArray onlinedata = new JSONArray(); if (shapefirst == null) { @@ -161,7 +176,7 @@ public class WordUtilXWPF { BigInteger numlevel = para.getNumIlvl(); countall += 1; //处理富文本的情况 - if(shapefirst != null){ + if (shapefirst != null && type == 0) { isstart = false; } if ("内容".equals(para.getParagraphText()) && numlevel == null && isstart) { @@ -176,7 +191,7 @@ public class WordUtilXWPF { isend = true; } XWPFParagraph tmpp = newfile.createParagraph(); - WordCreatFile.copyAllRunsToAnotherParagraph(para,tmpp); + WordCreatFile.copyAllRunsToAnotherParagraph(para, tmpp); } if (isend) { continue; @@ -254,6 +269,8 @@ public class WordUtilXWPF { 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); @@ -297,6 +314,7 @@ public class WordUtilXWPF { } if ("相关文件".equals(para.getParagraphText()) && numlevel == null) { islast = true; + isend = true; } break; } @@ -306,6 +324,8 @@ public class WordUtilXWPF { if (islast) { strb.append(para.getParagraphText()); + //拼接富文本标签 + richSbuild.append(DocToHtml.getHtml(0, para.getParagraphText())); } if (strb.length() > 0 && islast) { String shapeId1 = UUIDGener.getObjectId(); @@ -339,13 +359,19 @@ public class WordUtilXWPF { strb = new StringBuilder(); } else { strb.append(para.getParagraphText()); + //拼接富文本标签 + richSbuild.append(DocToHtml.getHtml(0, para.getParagraphText())); } lastislast = true; lastindex = 0; } } } - new WordCreatFile().createFile(newfile); + //将doc保存为富文本 + if (type == 1) { + saveRichText(userContext, richSbuild, plid, shapefirst.getString("id")); + } + //new WordCreatFile().createFile(newfile); } catch (Exception e) { e.printStackTrace(); } finally { @@ -354,9 +380,18 @@ public class WordUtilXWPF { //file.delete(); }*/ } + return elements; } + public void saveRichText(UserContext userContext, StringBuilder content, String pluuid, String shapid) { + //先保存 将富文本存为附件 + DCPluginProfile dcProfilepdf = DCProfileManager.getDCProfile("com.actionsoft.apps.coe.pal.datamigration", "migration"); + DCContext dcContextpdf = new DCContext(userContext, dcProfilepdf, "com.actionsoft.apps.coe.pal.datamigration", pluuid, shapid, "richText.text"); + InputStream sbs = new ByteArrayInputStream(content.toString().getBytes(StandardCharsets.UTF_8)); + SDK.getDCAPI().write(sbs, dcContextpdf); + } + /** * 处理超长的字符 * @@ -545,8 +580,6 @@ public class WordUtilXWPF { /** * 连线处理 * - * @param x - * @param y * @param zindex * @return */ diff --git a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/web/DataMigrationWeb.java b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/web/DataMigrationWeb.java index 9a8c682e..e8c8c64c 100644 --- a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/web/DataMigrationWeb.java +++ b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/web/DataMigrationWeb.java @@ -784,7 +784,7 @@ public class DataMigrationWeb extends ActionWeb { InputStream sbs = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8)); SDK.getDCAPI().write(sbs, dcContextpdf); //调用解析代码 生产制度图 - new CreateMaps().updateMapsByRichText(pluuid, content, shapid); + new CreateMaps().updateMapsByRichText(userContext, pluuid, content, shapid); return ResponseObject.newOkResponse(); } diff --git a/com.actionsoft.apps.coe.pal/template/page/pal.pl.repository.designer.htm b/com.actionsoft.apps.coe.pal/template/page/pal.pl.repository.designer.htm index 084b0308..9ddb828e 100755 --- a/com.actionsoft.apps.coe.pal/template/page/pal.pl.repository.designer.htm +++ b/com.actionsoft.apps.coe.pal/template/page/pal.pl.repository.designer.htm @@ -426,7 +426,8 @@ var shapeIds = Utils.getSelectedShapeIds()[0]; var dlgtmp = FrmDialog.open({ title : "富文本制度录入", - height: 400, + height: 600, + width:830, url : "./w", data : { sid : sid, @@ -2951,6 +2952,35 @@ + +