制度格式兼容
This commit is contained in:
parent
53d18f902c
commit
54b0fe1cb2
Binary file not shown.
@ -4,30 +4,61 @@ public class Constant {
|
||||
|
||||
public final static String APP_ID = "com.actionsoft.apps.coe.pal.datamigration";
|
||||
public final static String UPFILE = "migration";
|
||||
public final static String WORDIMPORT = "[{\"title\":\"基本信息\",\"type\":\"DirectFeild\"},{\"title\":\"文控信息\",\"type\":\"DirectFeild\"},{\"title\":\"修订记录\",\"type\":\"VerticalFeild\"},{\"title\":\"术语\",\"type\":\"Table\"},{\"title\":\"组织/角色与职责\",\"type\":\"Table\"},{\"title\":\"相关文件\",\"type\":\"File\"},{\"title\":\"支持文件\",\"type\":\"File\"}]";
|
||||
public final static String WORDIMPORT = "[{\"title\":\"基本信息\",\"type\":\"DirectFeild\"}," +
|
||||
"{\"title\":\"文控信息\",\"type\":\"DirectFeild\"}," +
|
||||
"{\"title\":\"修订记录\",\"type\":\"VerticalFeild\"}," +
|
||||
"{\"title\":\"文件变更履历表\",\"type\":\"VerticalFeild\"}," +
|
||||
"{\"title\":\"术语\",\"type\":\"Table\"}," +
|
||||
"{\"title\":\"术语定义\",\"type\":\"Table\"}," +
|
||||
"{\"title\":\"专业术语\",\"type\":\"Table\"}," +
|
||||
"{\"title\":\"组织/角色与职责\",\"type\":\"Table\"}," +
|
||||
"{\"title\":\"组织职责\",\"type\":\"Table\"}," +
|
||||
"{\"title\":\"组织与职责\",\"type\":\"Table\"}," +
|
||||
"{\"title\":\"相关文件\",\"type\":\"File\"}," +
|
||||
"{\"title\":\"支持文件\",\"type\":\"File\"}" +
|
||||
"]";
|
||||
//public final static String NAMETOID = "[{\"title\":\"目的\",\"type\":\"goal\"},{\"title\":\"拟制/修订人\",\"type\":\"reviser\"},{\"title\":\"拟制/修订日期\",\"type\":\"reviseddate\"},{\"title\":\"审核人\",\"type\":\"auditor\"},{\"title\":\"复核人\",\"type\":\"reviewer\"},{\"title\":\"审批人\",\"type\":\"approver\"},{\"title\":\"术语\",\"type\":\"term\"},{\"title\":\"术语定义\",\"type\":\"definition\"},{\"title\":\"组织/角色名称\",\"type\":\"Character\"},{\"title\":\"组织/角色职责\",\"type\":\"responsibilities\"},{\"title\":\"相关文件\",\"type\":\"relevant\"},{\"title\":\"支持文件\",\"type\":\"support\"},{\"title\":\"相关知识\",\"type\":\"related\"},{\"title\":\"附则\",\"type\":\"supplementary\"}]";
|
||||
public final static String NAMETOID = "[{\"title\":\"目的\",\"type\":\"Purpose\"}," +
|
||||
"{\"title\":\"拟制/修订人\",\"type\":\"Drafted_and_revised_by\"}," +
|
||||
"{\"title\":\"拟制人\",\"type\":\"Drafted_and_revised_by\"}," +
|
||||
"{\"title\":\"拟制/修订日期\",\"type\":\"Drafted_and_revised_date\"}," +
|
||||
"{\"title\":\"审核人\",\"type\":\"auditor\"}," +
|
||||
"{\"title\":\"审核\",\"type\":\"auditor\"}," +
|
||||
"{\"title\":\"复核人\",\"type\":\"reviewer\"}," +
|
||||
"{\"title\":\"复审\",\"type\":\"reviewer\"}," +
|
||||
"{\"title\":\"审批人\",\"type\":\"approver\"}," +
|
||||
"{\"title\":\"审批\",\"type\":\"approver\"}," +
|
||||
"{\"title\":\"术语\",\"type\":\"term\"}," +
|
||||
"{\"title\":\"组织/角色名称\",\"type\":\"Organizational_role\"}," +
|
||||
"{\"title\":\"组织/角色与职责\",\"type\":\"Organization_and_role_responsibilities\"}," +
|
||||
"{\"title\":\"组织职责\",\"type\":\"Organization_and_role_responsibilities\"}," +
|
||||
"{\"title\":\"组织与职责\",\"type\":\"Organization_and_role_responsibilities\"}," +
|
||||
"{\"title\":\"相关文件\",\"type\":\"relevant_flies\"}," +
|
||||
"{\"title\":\"支持文件\",\"type\":\"support_files\"}," +
|
||||
"{\"title\":\"相关知识\",\"type\":\"relevant_flies\"}," +
|
||||
"{\"title\":\"附则\",\"type\":\"T_supplementary_articles\"}," +
|
||||
"{\"title\":\"L1\",\"type\":\"Process_Architecture_L1\"}," +
|
||||
"{\"title\":\"L2\",\"type\":\"Process_Architecture_L2\"}," +
|
||||
"{\"title\":\"L3\",\"type\":\"Process_Architecture_L3\"}," +
|
||||
//"{\"title\":\"L1\",\"type\":\"Process_Architecture_L1\"}," +
|
||||
//"{\"title\":\"L2\",\"type\":\"Process_Architecture_L2\"}," +
|
||||
//"{\"title\":\"L3\",\"type\":\"Process_Architecture_L3\"}," +
|
||||
"{\"title\":\"文件编码\",\"type\":\"file_number\"}," +
|
||||
"{\"title\":\"适用范围\",\"type\":\"application\"}," +
|
||||
"{\"title\":\"发放范围\",\"type\":\"application\"}," +
|
||||
"{\"title\":\"范围\",\"type\":\"application\"}," +
|
||||
"{\"title\":\"版本\",\"type\":\"versions\"}," +
|
||||
"{\"title\":\"生效日期\",\"type\":\"effective_date\"}," +
|
||||
"{\"title\":\"日期\",\"type\":\"effective_date\"}," +
|
||||
"{\"title\":\"修订内容及理由\",\"type\":\"Contents_and_reasons_for_revision\"}," +
|
||||
"{\"title\":\"拟制/修订单位\",\"type\":\"Drafted_and_revised_Company\"}]";
|
||||
"{\"title\":\"修订内容\",\"type\":\"Contents_and_reasons_for_revision\"}," +
|
||||
"{\"title\":\"拟制/修订单位\",\"type\":\"Drafted_and_revised_Company\"}," +
|
||||
"{\"title\":\"拟制部门\",\"type\":\"Drafted_and_revised_Company\"}," +
|
||||
"{\"title\":\"编制\",\"type\":\"Drafted_and_revised_Company\"}," +
|
||||
"{\"title\":\"术语定义\",\"type\":\"term\"}," +
|
||||
"{\"title\":\"专业术语\",\"type\":\"term\"}," +
|
||||
"{\"title\":\"文件编号\",\"type\":\"file_number\"}," +
|
||||
"{\"title\":\"版号\",\"type\":\"versions\"}," +
|
||||
"{\"title\":\"拟定日期\",\"type\":\"Drafted_and_revised_date\"}," +
|
||||
//"{\"title\":\"制发日期\",\"type\":\"Drafted_and_revised_date\"}," +
|
||||
"]";
|
||||
// 构造连线时的几个固定参数
|
||||
public final static double ANGLE_RIGHT = 0;
|
||||
public final static double ANGLE_DOWN = 1.5707963267948968;
|
||||
|
||||
@ -96,7 +96,7 @@ public class ReadWordUtil {
|
||||
WordField tmp = fileFieldMap.get(key);
|
||||
if (tmp != null) {
|
||||
//如果是术语~则特殊处理 还有相关文件
|
||||
if ("术语".equals(key)) {
|
||||
if ("术语".equals(key) || "术语定义".equals(key) || "专业术语".equals(key) ) {
|
||||
List nowdata = (List) tmp.getData();
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("name", "术语");
|
||||
@ -108,7 +108,7 @@ public class ReadWordUtil {
|
||||
jsonArray.add(jsonObject1);
|
||||
//存表格 将名称过滤掉
|
||||
nowdata.stream().filter(datatmp -> {
|
||||
return !"名称".equals(((List) datatmp).get(0));
|
||||
return !"名称".equals(((List) datatmp).get(0)) && !"名词".equals(((List) datatmp).get(0)) && !"无".equals(((List) datatmp).get(0));
|
||||
}).forEach(datatmp -> {
|
||||
JSONObject tmpjb = new JSONObject();
|
||||
tmpjb.put("name", ((List) datatmp).get(0));
|
||||
@ -119,7 +119,7 @@ public class ReadWordUtil {
|
||||
});
|
||||
jsonObject.put("table", jsonArray);
|
||||
new CoeProcessLevelWeb(userContext).moreAttrContentSave(id, "term", jsonObject.toJSONString());
|
||||
} else if ("组织/角色与职责".equals(key)) {
|
||||
} else if ("组织/角色与职责".equals(key) || "组织职责".equals(key) || "组织与职责".equals(key)) {
|
||||
List nowdata = (List) tmp.getData();
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("name", "组织角色");
|
||||
@ -131,7 +131,7 @@ public class ReadWordUtil {
|
||||
jsonArray.add(jsonObject1);
|
||||
//存表格 将名称过滤掉
|
||||
nowdata.stream().filter(datatmp -> {
|
||||
return !"组织/角色名称".equals(((List) datatmp).get(0));
|
||||
return !"组织/角色名称".equals(((List) datatmp).get(0)) && !"组织".equals(((List) datatmp).get(0));
|
||||
}).forEach(datatmp -> {
|
||||
JSONObject tmpjb = new JSONObject();
|
||||
tmpjb.put("name", ((List) datatmp).get(0));
|
||||
@ -237,6 +237,7 @@ public class ReadWordUtil {
|
||||
//XWPFDocument doc = new XWPFDocument(file);
|
||||
Range range = doc.getRange();
|
||||
boolean isDepart = false;
|
||||
//0,1是计算标题 2是标题计算完毕
|
||||
int titleover = 0;
|
||||
for (int i = 0; i < range.numParagraphs(); i++) {
|
||||
Paragraph nowPara = range.getParagraph(i);
|
||||
@ -263,21 +264,78 @@ public class ReadWordUtil {
|
||||
if (titleover == 1) {
|
||||
titleover = 2;
|
||||
}
|
||||
WordAttribute wordAttribute = wordAttributeMap.get(text.trim());
|
||||
if ("目的".equals(text.trim())) {
|
||||
text = text.replace("\r", "").replace("\b", "").replace("\t", "").replace("\f", "").replaceAll(" ","");
|
||||
if(text.isEmpty()){
|
||||
continue;
|
||||
}
|
||||
if(text.length() > 0 && titleover == 2){
|
||||
//判断是否是标题后直接为表格~~
|
||||
if(nowPara.isInTable()){
|
||||
Table table = range.getTable(nowPara);
|
||||
Map<String, List<String>> verticalTableText = this.getVerticalTableText(table);
|
||||
for (String key : verticalTableText.keySet()) {
|
||||
List<String> values = verticalTableText.get(key);
|
||||
fieldMap.put(key, values.get(0));
|
||||
fileFieldMap.put(key, new WordField<>(values.get(0)));
|
||||
}
|
||||
i += table.numParagraphs();
|
||||
titleover = 3;
|
||||
continue;
|
||||
}
|
||||
//判断是否是标题后直接为key:value
|
||||
if(text.contains(":") ){
|
||||
boolean flag = true;
|
||||
while (flag){
|
||||
String[] strarr = text.split(":");
|
||||
String tmpkey = strarr[0];
|
||||
if(nameToIdMap.containsKey(tmpkey)){
|
||||
fieldMap.put(tmpkey, strarr[1]);
|
||||
fileFieldMap.put(tmpkey, new WordField<>(strarr[1]));
|
||||
}
|
||||
i = i + 1 > range.numParagraphs() ? i : i + 1;
|
||||
Paragraph tmpPara = range.getParagraph(i);
|
||||
text = tmpPara.text().replace("\r", "").replace("\b", "").replace("\t", "").replace("\f", "").replaceAll(" ","");
|
||||
if(text.length() > 0 && !text.contains(":") || text.contains("目的")){
|
||||
flag = false;
|
||||
i = i-1;
|
||||
}
|
||||
}
|
||||
titleover = 3;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
//最后是正常情况
|
||||
//获取正确的key
|
||||
String tmpkey = text.trim();
|
||||
if(tmpkey.contains(".")){
|
||||
String[] tmparr = tmpkey.split("\\.");
|
||||
if(tmparr.length == 2){
|
||||
tmpkey = tmparr[1];
|
||||
}
|
||||
}
|
||||
if (!tmpkey.isEmpty() && ("目的".equals(tmpkey) || ("目的:").equals(tmpkey))) {
|
||||
int index = i + 1 > range.numParagraphs() ? i : i + 1;
|
||||
Paragraph tmpPara = range.getParagraph(index);
|
||||
fieldMap.put("目的", tmpPara.text());
|
||||
fileFieldMap.put("目的", new WordField<>(tmpPara.text()));
|
||||
continue;
|
||||
}
|
||||
if ("附则".equals(text.trim())) {
|
||||
if(!tmpkey.isEmpty() && "2.适用范围:".contains(tmpkey)){
|
||||
int index = i + 1 > range.numParagraphs() ? i : i + 1;
|
||||
Paragraph tmpPara = range.getParagraph(index);
|
||||
fieldMap.put("适用范围", tmpPara.text());
|
||||
fileFieldMap.put("适用范围", new WordField<>(tmpPara.text()));
|
||||
continue;
|
||||
}
|
||||
if ("附则".equals(tmpkey)) {
|
||||
int index = i + 1 > range.numParagraphs() ? i : i + 1;
|
||||
Paragraph tmpPara = range.getParagraph(index);
|
||||
fieldMap.put("附则", tmpPara.text());
|
||||
fileFieldMap.put("附则", new WordField<>(tmpPara.text()));
|
||||
continue;
|
||||
}
|
||||
|
||||
WordAttribute wordAttribute = wordAttributeMap.get(tmpkey);
|
||||
if (null == wordAttribute) {
|
||||
continue;
|
||||
}
|
||||
@ -338,8 +396,8 @@ public class ReadWordUtil {
|
||||
Table table = range.getTable(paragraph);
|
||||
Map<String, List<String>> verticalTableText = this.getVerticalTableText(table);
|
||||
|
||||
if (text.trim().equals("修订记录")) {
|
||||
List<String> strings = verticalTableText.get("版本");
|
||||
if (text.trim().equals("修订记录") || text.replaceAll(" ","").equals("文件变更履历表")) {
|
||||
List<String> strings = verticalTableText.get("版本") != null ? verticalTableText.get("版本") : verticalTableText.get("版本号");
|
||||
int subIndex = 0;
|
||||
for (int j = 0; j < strings.size(); j++) {
|
||||
String s = strings.get(j);
|
||||
@ -377,7 +435,7 @@ public class ReadWordUtil {
|
||||
int index = i + 1 > range.numParagraphs() ? i : i + 1;
|
||||
Paragraph paragraph = range.getParagraph(index);
|
||||
if (paragraph.isInTable()) {
|
||||
if ("相关文件,支持文件".contains(text.trim())) {
|
||||
if (!text.trim().isEmpty() && "相关文件,支持文件".contains(text.trim())) {
|
||||
//取文件名名称即可
|
||||
Table table = range.getTable(paragraph);
|
||||
Map<String, List<String>> verticalTableText = this.getVerticalTableText(table);
|
||||
@ -602,7 +660,7 @@ public class ReadWordUtil {
|
||||
fontName = characterRun.getFontName();
|
||||
if (fontName.contains("黑体") && !type) {
|
||||
//与文档fontsize标号2倍关系 ,黑体一号 等于 26号size
|
||||
return characterRun.isBold() && characterRun.getFontSize() == 52;
|
||||
return characterRun.isBold() && (characterRun.getFontSize() == 52 || characterRun.getFontSize() == 48 || characterRun.getFontSize() == 72);
|
||||
}
|
||||
if (fontName.contains("宋体") && type) {
|
||||
return characterRun.isBold() && (characterRun.getFontSize() == 21 || characterRun.getFontSize() == 36);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user