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
@ -91,374 +72,386 @@ public class ReadTable {
idToNameMap.put(wordAttribute.getType(), wordAttribute.getTitle());
});
}
// 批量上传附件
public void dataFile_import(UserContext userContext, String wsId, String groupValue, String fileValue,
String fileName) {
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);
}
logMaps.put("FILENAME", fileName);
try {
String name = "";
if(fileName2.contains("-附件")) {
name = fileName2.substring(0, fileName2.indexOf("-附件"));
}else if(fileName2.contains("+附件")){
name = fileName2.substring(0, fileName2.indexOf("+附件"));
}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 plid = DBSql.getString(sqlss);
if(UtilString.isNotEmpty(plid)) {
palRepositoryModel = PALRepositoryCache.getCache().get(plid);
}
//PALRepositoryModel palRepositoryModel = ReadWordUtil.getRepositoryByName2(wsId, name);
/*
* if (palRepositoryModel == null) { PALRepositoryModel palRepositoryModel_s =
* ReadWordUtil.getRepositoryByName2(wsId, "酸奶" + name); if
* (palRepositoryModel_s != null) { palRepositoryModel = palRepositoryModel_s; }
* PALRepositoryModel palRepositoryModel_y =
* ReadWordUtil.getRepositoryByName2(wsId, "液奶" + name); if
* (palRepositoryModel_y != null) { palRepositoryModel = palRepositoryModel_y; }
* PALRepositoryModel palRepositoryModel_l =
* ReadWordUtil.getRepositoryByName2(wsId, "冷饮" + name); if
* (palRepositoryModel_l != null) { palRepositoryModel = palRepositoryModel_l; }
* PALRepositoryModel palRepositoryModel_n =
* ReadWordUtil.getRepositoryByName2(wsId, "奶粉" + name); if
* (palRepositoryModel_n != null) { palRepositoryModel = palRepositoryModel_n; }
* if (palRepositoryModel == null) { if (name.startsWith("酸奶") ||
* name.startsWith("液奶") || name.startsWith("冷饮") || name.startsWith("奶粉")) {
* PALRepositoryModel palRepositoryModel_ss =
* ReadWordUtil.getRepositoryByName2(wsId, name.substring(2)); if
* (palRepositoryModel_ss != null) { palRepositoryModel = palRepositoryModel_ss;
* } } } }
*/
if (null == palRepositoryModel) {
logMaps.put("UPFILESTATE", "文件没有匹配到模型!");
} else {
String id = palRepositoryModel.getId();
logMaps.put("PALID", id);
logMaps.put("PALNAME", palRepositoryModel.getName());
String shpId = "";
if (palRepositoryModel.getMethodId().contains("form")) {
logMaps.put("MODLETYPE", "表单模型");
// 查询对应绩效模型中数据模型进行填充数据
BaseModel defineModel = CoeDesignerAPIManager.getInstance().getDefinition(id, 0);
if (null == defineModel) {
shpId = createOneMap2(wsId, name, userContext);
if ("".equals(shpId)) {
logMaps.put("UPFILESTATE", "表单图形创建失败!");
}
} 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"))) {
shpId = key;
break;
}
}
}
if ("".equals(shpId)) {
// 画一个图形 并返回图形ID
shpId = createOneMap2(wsId, name, userContext);
if ("".equals(shpId)) {
logMaps.put("UPFILESTATE", "表单图形创建失败!");
}
}
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);
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.substring(0, 4).contains(".")) {
fileName = fileName.substring(fileName.indexOf(".")+1);
}
}
// 删除已有文件
StringBuffer sql = new StringBuffer();
sql.append("delete from ").append(UpfileModel.DATABASE_ENTITY)
.append(" WHERE SHAPEID = '" + shpId + "'");
InputStream originfile = SDK.getDCAPI().read(dcContextorigin);
try {
logMaps.put("PLNAME", palRepositoryModel.getName());
PALRepositoryModel prmodel = PALRepositoryCache.getCache().get(palRepositoryModel.getParentId());
if (prmodel != null) {
logMaps.put("FRNAME", prmodel.getName());
}
boolean writeFileTodisk = new ReadWordUtil().writeFileTodisk(userContext, shpId, fileName,
originfile, id, "s");
if (writeFileTodisk) {
logMaps.put("UPFILESTATE", "上传成功!");
} else {
logMaps.put("UPFILESTATE", "上传失败!");
}
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}
} else {
logMaps.put("PALID", id);
if (palRepositoryModel.getMethodId().contains("process")) {
logMaps.put("MODLETYPE", "流程模型");
logMaps.put("PLNAME", palRepositoryModel.getName());
} else {
logMaps.put("MODLETYPE", "制度模型");
logMaps.put("PLNAME", palRepositoryModel.getName());
}
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);
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.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+"'");
/*
* if(!fileName.contains("附件")) { // 删除已有文件 Date d = new Date(); StringBuffer
* sql = new StringBuffer(); SimpleDateFormat sdf = new
* SimpleDateFormat("yyyy/MM/dd"); String formatDate = sdf.format(d);
* sql.append("delete from ").append(UpfileModel.DATABASE_ENTITY).
* append(" WHERE CREATETIME < to_date ('"
* +formatDate+"','yyyy-mm-dd') and PALREPOSITORYID = '"+id+"'"); int update =
* DBSql.update(sql.toString());
*
* }
*/
/*
* if(!fileName.contains("附件")) { // 删除已有文件 Date d = new Date(); StringBuffer
* sql = new StringBuffer(); SimpleDateFormat sdf = new
* SimpleDateFormat("yyyy-MM-dd"); String formatDate = sdf.format(d);
* sql.append("delete from ").append(UpfileModel.DATABASE_ENTITY)
* .append(" WHERE CREATETIME < '"+formatDate+"' and PALREPOSITORYID = '"+id+"'"
* ); int update = DBSql.update(sql.toString());
*
* }
*/
InputStream originfile = SDK.getDCAPI().read(dcContextorigin);
try {
logMaps.put("PLNAME", palRepositoryModel.getName());
PALRepositoryModel prmodel = PALRepositoryCache.getCache().get(palRepositoryModel.getParentId());
if (prmodel != null) {
logMaps.put("FRNAME", prmodel.getName());
}
boolean writeFileTodisk = new ReadWordUtil().writeFileTodisk(userContext, "", fileName,
originfile, id, "f");
if (writeFileTodisk) {
logMaps.put("UPFILESTATE", "上传成功!");
} else {
logMaps.put("UPFILESTATE", "上传失败!");
}
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}
}
}
} catch (Exception e) {
// TODO: handle exception
} finally {
SDK.getBOAPI().createDataBO("BO_ACT_FORMDATDFILE_LOG_ALL", new BO().setAll(logMaps), userContext);
}
}
@SuppressWarnings("deprecation")
public void controlPolicyFile_import(UserContext userContext, String wsId, String groupValue, String fileValue, String fileName) {
HashMap<String,Object> logMaps = new HashMap<String,Object>();
logMaps.put("FILENAME", fileName);
try {
String substring = fileName.substring(0,fileName.indexOf(".xml"));
PALRepositoryModel palRepositoryModel = ReadWordUtil.getRepositoryByName2(wsId, substring);
if(null==palRepositoryModel) {
logMaps.put("UPFILESTATE", "文件没有匹配到制度模型!");
}else {
String id = palRepositoryModel.getId();
logMaps.put("PALID",id);
//查询对应绩效模型中数据模型进行填充数据
BaseModel defineModel = CoeDesignerAPIManager.getInstance().getDefinition(id, 0);
String shpId = "";
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("regulation".equals(shape1.getString("name"))) {
shpId = key;
break;
}
}
if("".equals(shpId)) {
logMaps.put("UPFILESTATE", "模型中没有对应的形状!");
}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);
StringBuffer sql = new StringBuffer();
//删除已有xml文件
sql.append("delete from ").append(UpfileModel.DATABASE_ENTITY).append(" WHERE SHAPEID = '" + shpId + "'");
int update = DBSql.update(sql.toString());
InputStream originfile = SDK.getDCAPI().read(dcContextorigin);
try {
boolean writeFileTodisk = new ReadWordUtil().writeFileTodisk(userContext, shpId, fileName, originfile, id, "s");
if(writeFileTodisk) {
logMaps.put("UPFILESTATE", "上传成功!");
}else {
logMaps.put("UPFILESTATE", "上传失败!");
}
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}
}
// 批量上传附件
public void dataFile_import(UserContext userContext, String wsId, String groupValue, String fileValue,
String fileName) {
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);
}
logMaps.put("FILENAME", fileName);
try {
String name = "";
if (fileName2.contains("-附件")) {
name = fileName2.substring(0, fileName2.indexOf("-附件"));
} else if (fileName2.contains("+附件")) {
name = fileName2.substring(0, fileName2.indexOf("+附件"));
} else {
name = fileName2.substring(0, fileName2.lastIndexOf("."));
}
} catch (Exception e) {
// TODO: handle exception
}finally {
SDK.getBOAPI().createDataBO("BO_ACT_DATAMIGRATION_LOG_T", new BO().setAll(logMaps), userContext);
}
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 plid = DBSql.getString(sqlss);
if (UtilString.isNotEmpty(plid)) {
palRepositoryModel = PALRepositoryCache.getCache().get(plid);
}
//PALRepositoryModel palRepositoryModel = ReadWordUtil.getRepositoryByName2(wsId, name);
/*
* if (palRepositoryModel == null) { PALRepositoryModel palRepositoryModel_s =
* ReadWordUtil.getRepositoryByName2(wsId, "酸奶" + name); if
* (palRepositoryModel_s != null) { palRepositoryModel = palRepositoryModel_s; }
* PALRepositoryModel palRepositoryModel_y =
* ReadWordUtil.getRepositoryByName2(wsId, "液奶" + name); if
* (palRepositoryModel_y != null) { palRepositoryModel = palRepositoryModel_y; }
* PALRepositoryModel palRepositoryModel_l =
* ReadWordUtil.getRepositoryByName2(wsId, "冷饮" + name); if
* (palRepositoryModel_l != null) { palRepositoryModel = palRepositoryModel_l; }
* PALRepositoryModel palRepositoryModel_n =
* ReadWordUtil.getRepositoryByName2(wsId, "奶粉" + name); if
* (palRepositoryModel_n != null) { palRepositoryModel = palRepositoryModel_n; }
* if (palRepositoryModel == null) { if (name.startsWith("酸奶") ||
* name.startsWith("液奶") || name.startsWith("冷饮") || name.startsWith("奶粉")) {
* PALRepositoryModel palRepositoryModel_ss =
* ReadWordUtil.getRepositoryByName2(wsId, name.substring(2)); if
* (palRepositoryModel_ss != null) { palRepositoryModel = palRepositoryModel_ss;
* } } } }
*/
if (null == palRepositoryModel) {
logMaps.put("UPFILESTATE", "文件没有匹配到模型!");
} else {
String id = palRepositoryModel.getId();
logMaps.put("PALID", id);
logMaps.put("PALNAME", palRepositoryModel.getName());
String shpId = "";
if (palRepositoryModel.getMethodId().contains("form")) {
logMaps.put("MODLETYPE", "表单模型");
// 查询对应绩效模型中数据模型进行填充数据
BaseModel defineModel = CoeDesignerAPIManager.getInstance().getDefinition(id, 0);
if (null == defineModel) {
shpId = createOneMap2(wsId, name, userContext);
if ("".equals(shpId)) {
logMaps.put("UPFILESTATE", "表单图形创建失败!");
}
} 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"))) {
shpId = key;
break;
}
}
}
if ("".equals(shpId)) {
// 画一个图形 并返回图形ID
shpId = createOneMap2(wsId, name, userContext);
if ("".equals(shpId)) {
logMaps.put("UPFILESTATE", "表单图形创建失败!");
}
}
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);
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.substring(0, 4).contains(".")) {
fileName = fileName.substring(fileName.indexOf(".") + 1);
}
}
// 删除已有文件
StringBuffer sql = new StringBuffer();
sql.append("delete from ").append(UpfileModel.DATABASE_ENTITY)
.append(" WHERE SHAPEID = '" + shpId + "'");
InputStream originfile = SDK.getDCAPI().read(dcContextorigin);
try {
logMaps.put("PLNAME", palRepositoryModel.getName());
PALRepositoryModel prmodel = PALRepositoryCache.getCache().get(palRepositoryModel.getParentId());
if (prmodel != null) {
logMaps.put("FRNAME", prmodel.getName());
}
boolean writeFileTodisk = new ReadWordUtil().writeFileTodisk(userContext, shpId, fileName,
originfile, id, "s");
if (writeFileTodisk) {
logMaps.put("UPFILESTATE", "上传成功!");
} else {
logMaps.put("UPFILESTATE", "上传失败!");
}
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}
} else {
logMaps.put("PALID", id);
if (palRepositoryModel.getMethodId().contains("process")) {
logMaps.put("MODLETYPE", "流程模型");
logMaps.put("PLNAME", palRepositoryModel.getName());
} else {
logMaps.put("MODLETYPE", "制度模型");
logMaps.put("PLNAME", palRepositoryModel.getName());
}
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);
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.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 + "'");
/*
* if(!fileName.contains("附件")) { // 删除已有文件 Date d = new Date(); StringBuffer
* sql = new StringBuffer(); SimpleDateFormat sdf = new
* SimpleDateFormat("yyyy/MM/dd"); String formatDate = sdf.format(d);
* sql.append("delete from ").append(UpfileModel.DATABASE_ENTITY).
* append(" WHERE CREATETIME < to_date ('"
* +formatDate+"','yyyy-mm-dd') and PALREPOSITORYID = '"+id+"'"); int update =
* DBSql.update(sql.toString());
*
* }
*/
/*
* if(!fileName.contains("附件")) { // 删除已有文件 Date d = new Date(); StringBuffer
* sql = new StringBuffer(); SimpleDateFormat sdf = new
* SimpleDateFormat("yyyy-MM-dd"); String formatDate = sdf.format(d);
* sql.append("delete from ").append(UpfileModel.DATABASE_ENTITY)
* .append(" WHERE CREATETIME < '"+formatDate+"' and PALREPOSITORYID = '"+id+"'"
* ); int update = DBSql.update(sql.toString());
*
* }
*/
InputStream originfile = SDK.getDCAPI().read(dcContextorigin);
try {
logMaps.put("PLNAME", palRepositoryModel.getName());
PALRepositoryModel prmodel = PALRepositoryCache.getCache().get(palRepositoryModel.getParentId());
if (prmodel != null) {
logMaps.put("FRNAME", prmodel.getName());
}
boolean writeFileTodisk = new ReadWordUtil().writeFileTodisk(userContext, "", fileName,
originfile, id, "f");
if (writeFileTodisk) {
logMaps.put("UPFILESTATE", "上传成功!");
} else {
logMaps.put("UPFILESTATE", "上传失败!");
}
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}
}
}
} catch (Exception e) {
// TODO: handle exception
} finally {
SDK.getBOAPI().createDataBO("BO_ACT_FORMDATDFILE_LOG_ALL", new BO().setAll(logMaps), userContext);
}
}
@SuppressWarnings("deprecation")
public void controlPolicyFile_import(UserContext userContext, String wsId, String groupValue, String fileValue, String fileName) {
HashMap<String, Object> logMaps = new HashMap<String, Object>();
logMaps.put("FILENAME", fileName);
try {
//获取最后一个.的位置
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) {
logMaps.put("UPFILESTATE", "文件没有匹配到制度模型!");
} else {
String id = palRepositoryModel.getId();
logMaps.put("PALID", id);
//查询对应绩效模型中数据模型进行填充数据
BaseModel defineModel = CoeDesignerAPIManager.getInstance().getDefinition(id, 0);
String shpId = "";
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 ("regulation".equals(shape1.getString("name"))) {
shpId = key;
break;
}
}
if ("".equals(shpId)) {
logMaps.put("UPFILESTATE", "模型中没有对应的形状!");
} 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);
StringBuffer sql = new StringBuffer();
//删除已有xml文件
sql.append("delete from ").append(UpfileModel.DATABASE_ENTITY).append(" WHERE SHAPEID = '" + shpId + "'");
int update = DBSql.update(sql.toString());
InputStream originfile = SDK.getDCAPI().read(dcContextorigin);
try {
boolean writeFileTodisk = new ReadWordUtil().writeFileTodisk(userContext, shpId, fileName, originfile, id, "s");
if (writeFileTodisk) {
logMaps.put("UPFILESTATE", "上传成功!");
} else {
logMaps.put("UPFILESTATE", "上传失败!");
}
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}
}
}
} catch (Exception e) {
// TODO: handle exception
} 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>();
logMaps.put("FILENAME", fileName);
try {
String name = fileName.substring(0,fileName.lastIndexOf("."));
HashMap<String, Object> logMaps = new HashMap<String, Object>();
logMaps.put("FILENAME", fileName);
try {
String name = fileName.substring(0, fileName.lastIndexOf("."));
PALRepositoryModel palRepositoryModel = ReadWordUtil.getRepositoryByName(wsId, name);
if(null==palRepositoryModel) {
logMaps.put("UPFILESTATE", "文件没有匹配到表单模型!");
}else {
String shpId = "";
String id = palRepositoryModel.getId();
logMaps.put("PALID",id);
//查询对应绩效模型中数据模型进行填充数据
BaseModel defineModel = CoeDesignerAPIManager.getInstance().getDefinition(id, 0);
if(null==defineModel) {
shpId = createOneMap2(wsId, name, userContext);
if("".equals(shpId)) {
logMaps.put("UPFILESTATE", "表单图形创建失败!");
}
}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"))) {
shpId = key;
break;
}
}
}
if("".equals(shpId)) {
//画一个图形 并返回图形ID
shpId = createOneMap2(wsId, name, userContext);
if("".equals(shpId)) {
logMaps.put("UPFILESTATE", "表单图形创建失败!");
}
}
String fileName_shap = "";
UpFileDao upFileDao = new UpFileDao();
StringBuilder sqlWhere = new StringBuilder();
sqlWhere.append(" and PALREPOSITORYID ='").append(id).append("'");
List<UpfileModel> fileList = upFileDao.search(sqlWhere.toString());
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("."));
}
}
}
if(name.equals(fileName_shap)) {
logMaps.put("UPFILESTATE", "此文件已存在,已忽略!");
}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);
InputStream originfile = SDK.getDCAPI().read(dcContextorigin);
try {
boolean writeFileTodisk = new ReadWordUtil().writeFileTodisk(userContext, shpId, fileName, originfile, id, "s");
if(writeFileTodisk) {
logMaps.put("UPFILESTATE", "上传成功!");
}else {
logMaps.put("UPFILESTATE", "上传失败!");
}
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}
}
}
} catch (Exception e) {
// TODO: handle exception
}finally {
SDK.getBOAPI().createDataBO("BO_ACT_FORMDATDFILE_LOG_F", new BO().setAll(logMaps), userContext);
}
if (null == palRepositoryModel) {
logMaps.put("UPFILESTATE", "文件没有匹配到表单模型!");
} else {
String shpId = "";
String id = palRepositoryModel.getId();
logMaps.put("PALID", id);
//查询对应绩效模型中数据模型进行填充数据
BaseModel defineModel = CoeDesignerAPIManager.getInstance().getDefinition(id, 0);
if (null == defineModel) {
shpId = createOneMap2(wsId, name, userContext);
if ("".equals(shpId)) {
logMaps.put("UPFILESTATE", "表单图形创建失败!");
}
} 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"))) {
shpId = key;
break;
}
}
}
if ("".equals(shpId)) {
//画一个图形 并返回图形ID
shpId = createOneMap2(wsId, name, userContext);
if ("".equals(shpId)) {
logMaps.put("UPFILESTATE", "表单图形创建失败!");
}
}
String fileName_shap = "";
UpFileDao upFileDao = new UpFileDao();
StringBuilder sqlWhere = new StringBuilder();
sqlWhere.append(" and PALREPOSITORYID ='").append(id).append("'");
List<UpfileModel> fileList = upFileDao.search(sqlWhere.toString());
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("."));
}
}
}
if (name.equals(fileName_shap)) {
logMaps.put("UPFILESTATE", "此文件已存在,已忽略!");
} 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);
InputStream originfile = SDK.getDCAPI().read(dcContextorigin);
try {
boolean writeFileTodisk = new ReadWordUtil().writeFileTodisk(userContext, shpId, fileName, originfile, id, "s");
if (writeFileTodisk) {
logMaps.put("UPFILESTATE", "上传成功!");
} else {
logMaps.put("UPFILESTATE", "上传失败!");
}
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}
}
}
} catch (Exception e) {
// TODO: handle exception
} finally {
SDK.getBOAPI().createDataBO("BO_ACT_FORMDATDFILE_LOG_F", new BO().setAll(logMaps), userContext);
}
}
//导入表单属性及附件
public void getTableInfo(UserContext userContext, String wsId, String groupValue, String fileValue, String fileName) {
DCPluginProfile dcProfilepdf = DCProfileManager.getDCProfile("com.actionsoft.apps.coe.pal.datamigration", "migration");
@ -564,9 +557,8 @@ public class ReadTable {
}
});
}
/**
* 创建表单图形,用于挂附件
*
@ -604,7 +596,7 @@ public class ReadTable {
props1.put("zindex", 0);
elements.put(shapeIdz, shapeze);
// Map<String, Map<String, JSONObject>> methodAttrsMap = new HashMap<>();
// Map<String, Map<String, JSONObject>> methodAttrsMap = new HashMap<>();
//handleShapeDefaultAttr("", palRepositoryModel, elements, methodAttrsMap, docfile);
// 设置画布大小
defineModel.setDefinition(definition.toString());
@ -612,9 +604,8 @@ public class ReadTable {
CoeDesignerAPIManager.getInstance().storeDefinition(defineModel);// dao操作
return shapeIdz;
}
/**
* 创建表单图形
*