Merge remote-tracking branch 'origin/apps_dev' into apps_dev

This commit is contained in:
Mr-wang 2023-07-17 20:15:31 +08:00
commit ae13f74497
2 changed files with 383 additions and 392 deletions

View File

@ -1,29 +1,5 @@
package com.actionsoft.apps.coe.pal.datamigration.util.readtable;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.usermodel.CharacterRun;
import org.apache.poi.hwpf.usermodel.Paragraph;
import org.apache.poi.hwpf.usermodel.Range;
import org.apache.poi.hwpf.usermodel.Table;
import org.apache.poi.hwpf.usermodel.TableCell;
import org.apache.poi.hwpf.usermodel.TableRow;
import com.actionsoft.apps.coe.pal.datamigration.model.po.WordAttribute;
import com.actionsoft.apps.coe.pal.datamigration.model.po.WordField;
import com.actionsoft.apps.coe.pal.datamigration.util.ShapeUtil;
@ -49,8 +25,13 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.aspose.words.Document;
import com.aspose.words.SaveFormat;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.usermodel.*;
import java.io.*;
import java.util.*;
/**
* @author baizp
@ -99,27 +80,27 @@ public class ReadTable {
fileName = fileName.trim();
String fileName2 = fileName;
HashMap<String, Object> logMaps = new HashMap<String, Object>();
if(fileName.substring(0, 4).contains("")) {
fileName2 = fileName2.substring(fileName2.indexOf("")+1);
if (fileName.substring(0, 4).contains("")) {
fileName2 = fileName2.substring(fileName2.indexOf("") + 1);
}
if(fileName.substring(0, 4).contains(".")) {
fileName2 = fileName2.substring(fileName2.indexOf(".")+1);
if (fileName.substring(0, 4).contains(".")) {
fileName2 = fileName2.substring(fileName2.indexOf(".") + 1);
}
logMaps.put("FILENAME", fileName);
try {
String name = "";
if(fileName2.contains("-附件")) {
if (fileName2.contains("-附件")) {
name = fileName2.substring(0, fileName2.indexOf("-附件"));
}else if(fileName2.contains("+附件")){
} else if (fileName2.contains("+附件")) {
name = fileName2.substring(0, fileName2.indexOf("+附件"));
}else {
} else {
name = fileName2.substring(0, fileName2.lastIndexOf("."));
}
PALRepositoryModel palRepositoryModel = null;
//String name = fileName.substring(0, fileName.lastIndexOf("."));
String sqlss = "select id from App_Act_Coe_Pal_Repository where plname = '"+name+"' and ISUSE = '1'";
String sqlss = "select id from App_Act_Coe_Pal_Repository where plname = '" + name + "' and ISUSE = '1'";
String plid = DBSql.getString(sqlss);
if(UtilString.isNotEmpty(plid)) {
if (UtilString.isNotEmpty(plid)) {
palRepositoryModel = PALRepositoryCache.getCache().get(plid);
}
//PALRepositoryModel palRepositoryModel = ReadWordUtil.getRepositoryByName2(wsId, name);
@ -188,19 +169,19 @@ public class ReadTable {
DCContext dcContextorigin = new DCContext(userContext, dcProfilepdfdoc,
"com.actionsoft.apps.coe.pal.datamigration", groupValue, fileValue, fileName);
if(fileName.contains("-附件")) {
fileName = fileName.substring(fileName.indexOf("-附件")+1);
if (fileName.contains("-附件")) {
fileName = fileName.substring(fileName.indexOf("-附件") + 1);
}
if(fileName.contains("+附件")) {
fileName = fileName.substring(fileName.indexOf("+附件")+1);
if (fileName.contains("+附件")) {
fileName = fileName.substring(fileName.indexOf("+附件") + 1);
}
if(fileName.length()>4) {
if(fileName.substring(0, 4).contains("")) {
fileName = fileName.substring(fileName.indexOf("")+1);
if (fileName.length() > 4) {
if (fileName.substring(0, 4).contains("")) {
fileName = fileName.substring(fileName.indexOf("") + 1);
}
if(fileName.substring(0, 4).contains(".")) {
fileName = fileName.substring(fileName.indexOf(".")+1);
if (fileName.substring(0, 4).contains(".")) {
fileName = fileName.substring(fileName.indexOf(".") + 1);
}
}
@ -241,26 +222,26 @@ public class ReadTable {
DCContext dcContextorigin = new DCContext(userContext, dcProfilepdfdoc,
"com.actionsoft.apps.coe.pal.datamigration", groupValue, fileValue, fileName);
if(fileName.contains("-附件")) {
fileName = fileName.substring(fileName.indexOf("-附件")+1);
if (fileName.contains("-附件")) {
fileName = fileName.substring(fileName.indexOf("-附件") + 1);
}
if(fileName.contains("+附件")) {
fileName = fileName.substring(fileName.indexOf("+附件")+1);
if (fileName.contains("+附件")) {
fileName = fileName.substring(fileName.indexOf("+附件") + 1);
}
if(fileName.length()>4) {
if(fileName.substring(0, 4).contains("")) {
fileName = fileName.substring(fileName.indexOf("")+1);
if (fileName.length() > 4) {
if (fileName.substring(0, 4).contains("")) {
fileName = fileName.substring(fileName.indexOf("") + 1);
}
if(fileName.substring(0, 4).contains(".")) {
fileName = fileName.substring(fileName.indexOf(".")+1);
if (fileName.substring(0, 4).contains(".")) {
fileName = fileName.substring(fileName.indexOf(".") + 1);
}
}
StringBuffer sql = new StringBuffer();
sql.append("delete from ").append(UpfileModel.DATABASE_ENTITY)
.append(" WHERE FILENAME = '" + fileName + "' AND PALREPOSITORYID = '"+id+"'");
.append(" WHERE FILENAME = '" + fileName + "' AND PALREPOSITORYID = '" + id + "'");
/*
* if(!fileName.contains("附件")) { // 删除已有文件 Date d = new Date(); StringBuffer
@ -315,21 +296,31 @@ public class ReadTable {
}
@SuppressWarnings("deprecation")
public void controlPolicyFile_import(UserContext userContext, String wsId, String groupValue, String fileValue, String fileName) {
HashMap<String,Object> logMaps = new HashMap<String,Object>();
HashMap<String, Object> logMaps = new HashMap<String, Object>();
logMaps.put("FILENAME", fileName);
try {
String substring = fileName.substring(0,fileName.indexOf(".xml"));
//获取最后一个.的位置
int lastIndexOf = fileName.lastIndexOf(".");
//获取文件的后缀名
String suffix = fileName.substring(lastIndexOf);
String substring;
if (StringUtils.equals(suffix, ".xml")) {
substring = fileName.substring(0, fileName.indexOf(".xml"));
} else {
substring = fileName.substring(0, fileName.indexOf(".doc"));
}
PALRepositoryModel palRepositoryModel = ReadWordUtil.getRepositoryByName2(wsId, substring);
if(null==palRepositoryModel) {
if (null == palRepositoryModel) {
logMaps.put("UPFILESTATE", "文件没有匹配到制度模型!");
}else {
} else {
String id = palRepositoryModel.getId();
logMaps.put("PALID",id);
logMaps.put("PALID", id);
//查询对应绩效模型中数据模型进行填充数据
BaseModel defineModel = CoeDesignerAPIManager.getInstance().getDefinition(id, 0);
String shpId = "";
@ -338,14 +329,14 @@ public class ReadTable {
JSONObject elements = definition.getJSONObject("elements");
for (String key : elements.keySet()) {
JSONObject shape1 = elements.getJSONObject(key);
if("regulation".equals(shape1.getString("name"))) {
if ("regulation".equals(shape1.getString("name"))) {
shpId = key;
break;
}
}
if("".equals(shpId)) {
if ("".equals(shpId)) {
logMaps.put("UPFILESTATE", "模型中没有对应的形状!");
}else {
} else {
DCPluginProfile dcProfilepdfdoc = DCProfileManager.getDCProfile("com.actionsoft.apps.coe.pal.datamigration", "migration");
//将文件挂载到附件里面
DCContext dcContextorigin = new DCContext(userContext, dcProfilepdfdoc, "com.actionsoft.apps.coe.pal.datamigration", groupValue, fileValue, fileName);
@ -356,9 +347,9 @@ public class ReadTable {
InputStream originfile = SDK.getDCAPI().read(dcContextorigin);
try {
boolean writeFileTodisk = new ReadWordUtil().writeFileTodisk(userContext, shpId, fileName, originfile, id, "s");
if(writeFileTodisk) {
if (writeFileTodisk) {
logMaps.put("UPFILESTATE", "上传成功!");
}else {
} else {
logMaps.put("UPFILESTATE", "上传失败!");
}
} catch (FileNotFoundException e1) {
@ -366,51 +357,53 @@ public class ReadTable {
}
}
}
} catch (Exception e) {
// TODO: handle exception
}finally {
} finally {
SDK.getBOAPI().createDataBO("BO_ACT_DATAMIGRATION_LOG_T", new BO().setAll(logMaps), userContext);
}
}
//导入表单附件
public void formDataFile_import(UserContext userContext, String wsId, String groupValue, String fileValue, String fileName) {
HashMap<String,Object> logMaps = new HashMap<String,Object>();
HashMap<String, Object> logMaps = new HashMap<String, Object>();
logMaps.put("FILENAME", fileName);
try {
String name = fileName.substring(0,fileName.lastIndexOf("."));
String name = fileName.substring(0, fileName.lastIndexOf("."));
PALRepositoryModel palRepositoryModel = ReadWordUtil.getRepositoryByName(wsId, name);
if(null==palRepositoryModel) {
if (null == palRepositoryModel) {
logMaps.put("UPFILESTATE", "文件没有匹配到表单模型!");
}else {
} else {
String shpId = "";
String id = palRepositoryModel.getId();
logMaps.put("PALID",id);
logMaps.put("PALID", id);
//查询对应绩效模型中数据模型进行填充数据
BaseModel defineModel = CoeDesignerAPIManager.getInstance().getDefinition(id, 0);
if(null==defineModel) {
if (null == defineModel) {
shpId = createOneMap2(wsId, name, userContext);
if("".equals(shpId)) {
if ("".equals(shpId)) {
logMaps.put("UPFILESTATE", "表单图形创建失败!");
}
}else {
} else {
String define = defineModel.getDefinition();
JSONObject definition = JSONObject.parseObject(define);
JSONObject elements = definition.getJSONObject("elements");
for (String key : elements.keySet()) {
JSONObject shape1 = elements.getJSONObject(key);
if("form".equals(shape1.getString("name"))) {
if ("form".equals(shape1.getString("name"))) {
shpId = key;
break;
}
}
}
if("".equals(shpId)) {
if ("".equals(shpId)) {
//画一个图形 并返回图形ID
shpId = createOneMap2(wsId, name, userContext);
if("".equals(shpId)) {
if ("".equals(shpId)) {
logMaps.put("UPFILESTATE", "表单图形创建失败!");
}
@ -423,15 +416,15 @@ public class ReadTable {
if (fileList != null && fileList.size() > 0)
for (UpfileModel upfileModel : fileList) {
if ("s".equals(upfileModel.getType())) {
String fileName_shaps= upfileModel.getFileName();
if(UtilString.isNotEmpty(fileName_shaps)) {
fileName_shap = fileName_shaps.substring(0,fileName_shaps.lastIndexOf("."));
String fileName_shaps = upfileModel.getFileName();
if (UtilString.isNotEmpty(fileName_shaps)) {
fileName_shap = fileName_shaps.substring(0, fileName_shaps.lastIndexOf("."));
}
}
}
if(name.equals(fileName_shap)) {
if (name.equals(fileName_shap)) {
logMaps.put("UPFILESTATE", "此文件已存在,已忽略!");
}else {
} else {
DCPluginProfile dcProfilepdfdoc = DCProfileManager.getDCProfile("com.actionsoft.apps.coe.pal.datamigration", "migration");
//将文件挂载到附件里面
@ -439,9 +432,9 @@ public class ReadTable {
InputStream originfile = SDK.getDCAPI().read(dcContextorigin);
try {
boolean writeFileTodisk = new ReadWordUtil().writeFileTodisk(userContext, shpId, fileName, originfile, id, "s");
if(writeFileTodisk) {
if (writeFileTodisk) {
logMaps.put("UPFILESTATE", "上传成功!");
}else {
} else {
logMaps.put("UPFILESTATE", "上传失败!");
}
} catch (FileNotFoundException e1) {
@ -454,7 +447,7 @@ public class ReadTable {
} catch (Exception e) {
// TODO: handle exception
}finally {
} finally {
SDK.getBOAPI().createDataBO("BO_ACT_FORMDATDFILE_LOG_F", new BO().setAll(logMaps), userContext);
}
}
@ -566,7 +559,6 @@ public class ReadTable {
}
/**
* 创建表单图形,用于挂附件
*
@ -614,7 +606,6 @@ public class ReadTable {
}
/**
* 创建表单图形
*