挂载附件~解析word内的制度名称
This commit is contained in:
parent
e794286ed6
commit
dbe84f0e9b
@ -179,10 +179,10 @@ public class ReadTable {
|
||||
*/
|
||||
public String createOneMap(String plId, String name, UserContext userContext, InputStream docfile) {
|
||||
boolean result = analysisWordTable(docfile);
|
||||
String title = fileFieldMap.get("标题").getData().toString();
|
||||
if(title.isEmpty()){
|
||||
if(fileFieldMap.get("标题") == null){
|
||||
return "";
|
||||
}
|
||||
String title = fileFieldMap.get("标题").getData().toString();
|
||||
PALRepositoryModel palRepositoryModel = ReadWordUtil.getRepositoryByName(plId, title);
|
||||
if(palRepositoryModel == null){
|
||||
return "";
|
||||
|
||||
@ -4,10 +4,9 @@ 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\":\"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\":\"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_date\"},{\"title\":\"审核人\",\"type\":\"auditor\"},{\"title\":\"复核人\",\"type\":\"reviewer\"},{\"title\":\"审批人\",\"type\":\"approver\"},{\"title\":\"术语\",\"type\":\"term\"},{\"title\":\"组织/角色名称\",\"type\":\"Organization_role_name\"},{\"title\":\"组织/角色职责\",\"type\":\"Organization_and_role_responsibilities\"},{\"title\":\"相关文件\",\"type\":\"relevant_flies\"},{\"title\":\"支持文件\",\"type\":\"support_files\"},{\"title\":\"相关知识\",\"type\":\"relevant_flies\"},{\"title\":\"附则\",\"type\":\"T_supplementary_articles\"}]";
|
||||
|
||||
// 构造连线时的几个固定参数
|
||||
public final static double ANGLE_RIGHT = 0;
|
||||
public final static double ANGLE_DOWN = 1.5707963267948968;
|
||||
|
||||
@ -82,10 +82,10 @@ public class ReadWordUtil {
|
||||
public void writeAttrbute(UserContext userContext, InputStream file, String name, String wsdl) {
|
||||
boolean result = analysisWordTable(file);
|
||||
if (result) {
|
||||
String title = fileFieldMap.get("标题").getData().toString();
|
||||
if(title.isEmpty()){
|
||||
if (fileFieldMap.get("标题") == null) {
|
||||
return;
|
||||
}
|
||||
String title = fileFieldMap.get("标题").getData().toString();
|
||||
//根据名称获取PAL制度模型
|
||||
PALRepositoryModel palRepositoryModel = getRepositoryByName(wsdl, name);
|
||||
if (palRepositoryModel != null) {
|
||||
@ -182,10 +182,10 @@ public class ReadWordUtil {
|
||||
InputStream docfile = SDK.getDCAPI().read(dcContextpdfdoc);
|
||||
//ReadWordUtil tmp = new ReadWordUtil();
|
||||
writeAttrbute(userContext, docfile, fileName, wsId);
|
||||
String title = fileFieldMap.get("标题").getData().toString();
|
||||
if(title.isEmpty()){
|
||||
if (fileFieldMap.get("标题") == null) {
|
||||
return;
|
||||
}
|
||||
String title = fileFieldMap.get("标题").getData().toString();
|
||||
PALRepositoryModel palRepositoryModel = getRepositoryByName(wsId, title);
|
||||
if (palRepositoryModel != null) {
|
||||
try {
|
||||
@ -210,21 +210,32 @@ public class ReadWordUtil {
|
||||
HWPFDocument doc = new HWPFDocument(file);
|
||||
//XWPFDocument doc = new XWPFDocument(file);
|
||||
Range range = doc.getRange();
|
||||
boolean isDepart = false;
|
||||
int titleover = 0;
|
||||
for (int i = 0; i < range.numParagraphs(); i++) {
|
||||
Paragraph nowPara = range.getParagraph(i);
|
||||
String text = nowPara.text();
|
||||
if (StringUtils.isEmpty(text)) {
|
||||
continue;
|
||||
}
|
||||
boolean isTitle = isTitle(nowPara);
|
||||
if(isTitle){
|
||||
String nowtext = nowPara.text().replace("\r", "");
|
||||
if (nowtext.contains("内蒙古伊利集团部门文件")) {
|
||||
isDepart = true;
|
||||
}
|
||||
boolean isTitle = isTitle(nowPara, isDepart);
|
||||
if (isTitle && titleover < 2) {
|
||||
String title = "";
|
||||
if(fieldMap.get("标题") != null){
|
||||
if (fieldMap.get("标题") != null) {
|
||||
title = fieldMap.get("标题").toString();
|
||||
}
|
||||
title = title+nowPara.text().replace("\r","");
|
||||
title = title + nowPara.text().replace("\r", "").replace("\b", "").replace("\t", "");
|
||||
fieldMap.put("标题", title);
|
||||
fileFieldMap.put("标题", new WordField<>(title));
|
||||
titleover = 1;
|
||||
continue;
|
||||
}
|
||||
if (titleover == 1) {
|
||||
titleover = 2;
|
||||
}
|
||||
WordAttribute wordAttribute = wordAttributeMap.get(text.trim());
|
||||
if ("目的".equals(text.trim())) {
|
||||
@ -264,7 +275,7 @@ public class ReadWordUtil {
|
||||
Map<String, List<String>> tabelDocText = this.getHorizontalTableMapText(table);
|
||||
|
||||
//在基本信息中特殊获取文件名称和版本号
|
||||
if (text.trim().equals("文控信息")) {
|
||||
if (text.trim().equals("文控信息") || text.trim().equals("基本信息")) {
|
||||
tabelDocText.keySet().forEach(key -> {
|
||||
if (key.replaceAll(" ", "").equals("版本")) {
|
||||
List<String> strings = tabelDocText.get(key);
|
||||
@ -486,21 +497,24 @@ public class ReadWordUtil {
|
||||
|
||||
/**
|
||||
* 判断是否为文档标题
|
||||
* 标志:黑体一号
|
||||
* 标志:黑体一号
|
||||
*
|
||||
* @param paragraph
|
||||
* @param type 1:正常的制度文件 2: 部门文件
|
||||
* @return
|
||||
*/
|
||||
public boolean isTitle(Paragraph paragraph){
|
||||
public boolean isTitle(Paragraph paragraph, boolean type) {
|
||||
int size = paragraph.numCharacterRuns();
|
||||
String fontName = "";
|
||||
int fontSize = 0;
|
||||
boolean bold ;
|
||||
for (int j = 0; j < size; j++) {
|
||||
CharacterRun characterRun = paragraph.getCharacterRun(j);
|
||||
fontName = characterRun.getFontName();
|
||||
if (fontName.contains("黑体")){
|
||||
if (fontName.contains("黑体") && !type) {
|
||||
//与文档fontsize标号2倍关系 ,黑体一号 等于 26号size
|
||||
return characterRun.isBold() && characterRun.getFontSize() == 52;
|
||||
return characterRun.isBold() && characterRun.getFontSize() == 52;
|
||||
}
|
||||
if (fontName.contains("宋体") && type) {
|
||||
return characterRun.isBold() && (characterRun.getFontSize() == 21 || characterRun.getFontSize() == 36);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user