数据迁移应用上传

This commit is contained in:
446052889@qq.com 2022-06-27 17:39:30 +08:00
parent 3d26ceaf52
commit 1d6767c36b
45 changed files with 1716586 additions and 0 deletions

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<app xmlns="http://www.actionsoft.com.cn/app">
<name>PAL数据迁移</name>
<version>1.0</version>
<buildNo>2</buildNo>
<developer id="776cca9a287c8b4d63b9cad216aa3859" tablePrefix="ACT" url="http://www.actionsoft.com.cn">北京炎黄盈动科技发展有限责任公司</developer>
<categoryVisible>false</categoryVisible>
<description><![CDATA[数据迁移]]></description>
<details><![CDATA[]]></details>
<installListener/>
<pluginListener>com.actionsoft.apps.coe.pal.datamigration.plugin.Plugins</pluginListener>
<startListener/>
<stopListener/>
<upgradeListener/>
<uninstallListener/>
<reloadable>true</reloadable>
<requires/>
<properties/>
<allowStartup>true</allowStartup>
<allowUpgradeByStore>true</allowUpgradeByStore>
<depend versions="6.5" env="">com.actionsoft.apps.coe.pal</depend>
<modelAdministrator/>
<installDate>2022-04-27 00:02:23</installDate>
<icon code="&amp;#xe612;" color="#3383da"/>
<productId/>
</app>

View File

@ -0,0 +1,25 @@
package com.actionsoft.apps.coe.pal.datamigration;
import com.actionsoft.apps.coe.pal.datamigration.web.DataMigrationWeb;
import com.actionsoft.bpms.server.UserContext;
import com.actionsoft.bpms.server.bind.annotation.Controller;
import com.actionsoft.bpms.server.bind.annotation.Mapping;
@Controller
public class DataMigrationController {
@Mapping("com.actionsoft.apps.coe.pal.datamigration_data_migrate")
public String dataMigrate(UserContext uc, String wsId,String groupValue,String fileValue,String fileName) {
return new DataMigrationWeb(uc).dataMigrate(wsId,groupValue,fileValue,fileName);
}
@Mapping("com.actionsoft.apps.coe.pal.datamigration_process_attribute_import")
public String processAttributeImport(UserContext uc, String wsId,String groupValue,String fileValue,String fileName){
return new DataMigrationWeb(uc).processAttributeImport(wsId,groupValue,fileValue,fileName);
}
@Mapping("com.actionsoft.apps.coe.pal.datamigration_IT_attribute_import")
public String ITAttributeImport(UserContext uc, String wsId,String groupValue,String fileValue,String fileName){
return new DataMigrationWeb(uc).ITAttributeImport(wsId,groupValue,fileValue,fileName);
}
}

View File

@ -0,0 +1,130 @@
package com.actionsoft.apps.coe.pal.datamigration.aris.mapping;
import com.actionsoft.apps.coe.pal.datamigration.aris.model.ObjDefMappingModel;
import com.actionsoft.apps.coe.pal.pal.method.cache.PALMethodCache;
import com.actionsoft.apps.coe.pal.pal.repository.PALRepositoryQueryAPIManager;
import com.alibaba.fastjson.JSONObject;
import java.util.HashMap;
import java.util.Map;
public class ModelMappingAPIManager {
private ModelMappingAPIManager() {}
public static ModelMappingAPIManager getInstance() {
return ModelMappingAPIManager.Inner.instance;
}
private static class Inner {
private final static ModelMappingAPIManager instance = new ModelMappingAPIManager();
}
/**
* Aris图类型与PALmethodId映射
* @return
*/
public Map<String, String> getModelMappingMap() {
Map<String, String> modelMappingMap = new HashMap<>();// Aris图类型与PALmethodId映射
// 图类型映射
modelMappingMap.put("MT_EEPC", "process.epc");
return modelMappingMap;
}
/**
* 获取形状连线定义
* @return
*/
public JSONObject getLinkerDef() {
String linker = "{\"fontStyle\":{\"fontFamily\":\"Arial\",\"size\":13,\"color\":\"50,50,50\",\"underline\":false,\"textAlign\":\"center\",\"bold\":false,\"italic\":false},\"points\":[],\"dataAttributes\":[{\"shapeDesc\":\"\",\"name\":\"AWSProperties\",\"id\":\"AWSPropertiesID\",\"type\":\"string\",\"category\":\"default\",\"value\":\"\"}],\"props\":{\"zindex\":0},\"linkerType\":\"broken\",\"lineStyle\":{\"lineStyle\":\"solid\",\"lineColor\":\"50,50,50\",\"beginArrowStyle\":\"none\",\"endArrowStyle\":\"solidArrow\",\"lineWidth\":1},\"name\":\"linker\",\"orderIndex\":0,\"from\":{\"x\":0,\"y\":0,\"angle\":0,\"id\":\"\"},\"id\":\"\",\"text\":\"\",\"to\":{\"x\":0,\"y\":0,\"angle\":0,\"id\":\"\"},\"locked\":false,\"group\":\"\"}";
return JSONObject.parseObject(linker);
}
/**
* Aris图形状类型与PAL形状/属性映射
* @return
*/
public Map<String, ObjDefMappingModel> getObjDefMappingMap() {
Map<String, ObjDefMappingModel> objDefMappingMap = new HashMap<>();// Aris图形状类型与PAL形状/属性映射
// 形状类型映射
if (PALMethodCache.getPALMethodModelById("process.epc") != null) {
// epc-method
ObjDefMappingModel o1 = new ObjDefMappingModel("OT_FUNC", "ST_FUNC", "method_approval_node", "process.epc", null, "shape");
objDefMappingMap.put("OT_FUNC-ST_FUNC", o1);
// epc-method-system
ObjDefMappingModel o2 = new ObjDefMappingModel("OT_FUNC", "ST_SYS_FUNC_ACT", "method_service_node", "process.epc", null, "shape");
objDefMappingMap.put("OT_FUNC-ST_SYS_FUNC_ACT", o2);
// epc-event
ObjDefMappingModel o3 = new ObjDefMappingModel("OT_EVT", "ST_EV", "event", "process.epc", null, "shape");
objDefMappingMap.put("OT_EVT-ST_EV", o3);
// epc-procedure
ObjDefMappingModel o4 = new ObjDefMappingModel("OT_FUNC", "ST_PRCS_IF", "procedure", "process.epc", null, "shape");
objDefMappingMap.put("OT_FUNC-ST_PRCS_IF", o4);
// epc-or
ObjDefMappingModel o5 = new ObjDefMappingModel("OT_RULE", "ST_OPR_OR_1", "or", "process.epc", null, "shape");
objDefMappingMap.put("OT_RULE-ST_OPR_OR_1", o5);
// epc-and
ObjDefMappingModel o6 = new ObjDefMappingModel("OT_RULE", "ST_OPR_AND_1", "and", "process.epc", null, "shape");
objDefMappingMap.put("OT_RULE-ST_OPR_AND_1", o6);
// epc-xor
ObjDefMappingModel o7 = new ObjDefMappingModel("OT_RULE", "ST_OPR_XOR_1", "xor", "process.epc", null, "shape");
objDefMappingMap.put("OT_RULE-ST_OPR_XOR_1", o7);
}
// 以下进行属性内容匹配先用形状匹配
if (PALMethodCache.getPALMethodModelById("process.flowchart") != null) {
// 流程文件-文档
ObjDefMappingModel o8 = new ObjDefMappingModel("OT_INFO_CARR", "ST_DOC", "document", "process.flowchart", null, "shape");
objDefMappingMap.put("OT_INFO_CARR-ST_DOC", o8);
// ObjDefMappingModel o8 = new ObjDefMappingModel("OT_PERS_TYPE", "ST_EMPL_TYPE", null, null, "ROLE", "shape");
}
if (PALMethodCache.getPALMethodModelById("org.normal") != null) {
// 角色
ObjDefMappingModel o9 = new ObjDefMappingModel("OT_PERS_TYPE", "ST_EMPL_TYPE", "role", "org.normal", null, "shape");
objDefMappingMap.put("OT_PERS_TYPE-ST_EMPL_TYPE", o9);
// ObjDefMappingModel o9 = new ObjDefMappingModel("OT_PERS_TYPE", "ST_EMPL_TYPE", null, null, "ROLE", "shape");
// 岗位
ObjDefMappingModel o10 = new ObjDefMappingModel("OT_POS","ST_POS","position","org.normal",null,"attr");
objDefMappingMap.put("OT_POS-ST_POS",o10);
}
if (PALMethodCache.getPALMethodModelById("itsystem.normal") != null) {
// 岗位
ObjDefMappingModel o11 = new ObjDefMappingModel("OT_APPL_SYS_TYPE","ST_APPL_SYS_TYPE","appSystem","itsystem.normal",null,"shape");
objDefMappingMap.put("OT_APPL_SYS_TYPE-ST_APPL_SYS_TYPE",o11);
}
if (1==2) {
}
return objDefMappingMap;
}
/**
* Aris形状的属性key与PAL属性key映射
* @return
*/
public Map<String, String> getAttrObjDefMappingMap() {
Map<String, String> attrObjDefMappingMap = new HashMap<>();// Aris形状的属性key与PAL属性key映射
// Aris形状属性映射
// 描述
attrObjDefMappingMap.put("AT_DESC", "desc");
// 编号
attrObjDefMappingMap.put("AT_PROC_CODE", "number");
return attrObjDefMappingMap;
}
/**
* Aris模型的属性key与PAL属性key映射
* @return
*/
public Map<String, String> getAttrModelMappingMap() {
Map<String, String> attrModelMappingMap = new HashMap<>();// Aris模型的属性key与PAL属性key映射
// Aris模型属性映射
// 模型编号 AT_ID
attrModelMappingMap.put("AT_ID", "number");
return attrModelMappingMap;
}
}

View File

@ -0,0 +1,57 @@
package com.actionsoft.apps.coe.pal.datamigration.aris.model;
import java.util.List;
/**
* 连线Model
* 记录当前形状指向到下一个形状的连线
*/
public class CxnOccModel {
private String id;// CxnOcc.ID
private String toId;// ToObjOcc.IdRef
private String objDefId;// 连线起始端形状定义ID
private String toObjDefId;// 连线终点形状定义ID
private List<PositionModel> positionList;// 连线起始端+折点
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getToId() {
return toId;
}
public void setToId(String toId) {
this.toId = toId;
}
public String getObjDefId() {
return objDefId;
}
public void setObjDefId(String objDefId) {
this.objDefId = objDefId;
}
public String getToObjDefId() {
return toObjDefId;
}
public void setToObjDefId(String toObjDefId) {
this.toObjDefId = toObjDefId;
}
public List<PositionModel> getPositionList() {
return positionList;
}
public void setPositionList(List<PositionModel> positionList) {
this.positionList = positionList;
}
}

View File

@ -0,0 +1,115 @@
package com.actionsoft.apps.coe.pal.datamigration.aris.model;
import com.alibaba.fastjson.JSONObject;
/**
* 组Model
*/
public class GroupModel {
private String id;// Model.ID
private String name;
private String pid;
private String type;// Model.Type
private String modelPath;// model所在路径文本
private String createTime;
private String createUser;
private String modifyTime;
private String modifyUser;
private JSONObject attrData;// 暂时空待确定
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPid() {
return pid;
}
public void setPid(String pid) {
this.pid = pid;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getModelPath() {
return modelPath;
}
public void setModelPath(String modelPath) {
this.modelPath = modelPath;
}
public String getCreateTime() {
return createTime;
}
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
public String getCreateUser() {
return createUser;
}
public void setCreateUser(String createUser) {
this.createUser = createUser;
}
public String getModifyTime() {
return modifyTime;
}
public void setModifyTime(String modifyTime) {
this.modifyTime = modifyTime;
}
public String getModifyUser() {
return modifyUser;
}
public void setModifyUser(String modifyUser) {
this.modifyUser = modifyUser;
}
public JSONObject getAttrData() {
return attrData;
}
public void setAttrData(JSONObject attrData) {
this.attrData = attrData;
}
@Override
public String toString() {
return "GroupModel{" +
"id='" + id + '\'' +
", name='" + name + '\'' +
", pid='" + pid + '\'' +
", type='" + type + '\'' +
", modelPath='" + modelPath + '\'' +
", createTime='" + createTime + '\'' +
", createUser='" + createUser + '\'' +
", modifyTime='" + modifyTime + '\'' +
", modifyUser='" + modifyUser + '\'' +
", attrData=" + attrData +
'}';
}
}

View File

@ -0,0 +1,118 @@
package com.actionsoft.apps.coe.pal.datamigration.aris.model;
import com.alibaba.fastjson.JSONObject;
/**
* 模型Model
*/
public class ModelModel {
private String id;// Model.ID
private String name;
private String pid;
private String type;// Model.Type
private String modelPath;// model所在路径文本
private String createTime;
private String createUser;
private String modifyTime;
private String modifyUser;
private JSONObject attrData;// 名称以外的属性存储
public ModelModel() {
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPid() {
return pid;
}
public void setPid(String pid) {
this.pid = pid;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getModelPath() {
return modelPath;
}
public void setModelPath(String modelPath) {
this.modelPath = modelPath;
}
public String getCreateTime() {
return createTime;
}
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
public String getCreateUser() {
return createUser;
}
public void setCreateUser(String createUser) {
this.createUser = createUser;
}
public String getModifyTime() {
return modifyTime;
}
public void setModifyTime(String modifyTime) {
this.modifyTime = modifyTime;
}
public String getModifyUser() {
return modifyUser;
}
public void setModifyUser(String modifyUser) {
this.modifyUser = modifyUser;
}
public JSONObject getAttrData() {
return attrData;
}
public void setAttrData(JSONObject attrData) {
this.attrData = attrData;
}
@Override
public String toString() {
return "ModelModel{" +
"id='" + id + '\'' +
", name='" + name + '\'' +
", type='" + type + '\'' +
", modelPath='" + modelPath + '\'' +
", createTime='" + createTime + '\'' +
", createUser='" + createUser + '\'' +
", modifyTime='" + modifyTime + '\'' +
", modifyUser='" + modifyUser + '\'' +
", attrData=" + attrData +
'}';
}
}

View File

@ -0,0 +1,71 @@
package com.actionsoft.apps.coe.pal.datamigration.aris.model;
/**
* Aris形状定义类型与PAL形状定义类型映射
*/
public class ObjDefMappingModel {
private String typeNum;// aris类型1
private String symbolNum;// aris类型2
private String shapeType; // pal形状类型
private String shapeMethod;// 形状所属methodId
private String mappingAttrId;// 映射属性key
private String mappingType;// 映射类型shape形状attr属性
public ObjDefMappingModel(String typeNum, String symbolNum, String shapeType, String shapeMethod, String mappingAttrId, String mappingType) {
this.typeNum = typeNum;
this.symbolNum = symbolNum;
this.shapeType = shapeType;
this.shapeMethod = shapeMethod;
this.mappingAttrId = mappingAttrId;
this.mappingType = mappingType;
}
public String getTypeNum() {
return typeNum;
}
public void setTypeNum(String typeNum) {
this.typeNum = typeNum;
}
public String getSymbolNum() {
return symbolNum;
}
public void setSymbolNum(String symbolNum) {
this.symbolNum = symbolNum;
}
public String getShapeType() {
return shapeType;
}
public void setShapeType(String shapeType) {
this.shapeType = shapeType;
}
public String getShapeMethod() {
return shapeMethod;
}
public void setShapeMethod(String shapeMethod) {
this.shapeMethod = shapeMethod;
}
public String getMappingAttrId() {
return mappingAttrId;
}
public void setMappingAttrId(String mappingAttrId) {
this.mappingAttrId = mappingAttrId;
}
public String getMappingType() {
return mappingType;
}
public void setMappingType(String mappingType) {
this.mappingType = mappingType;
}
}

View File

@ -0,0 +1,69 @@
package com.actionsoft.apps.coe.pal.datamigration.aris.model;
import com.alibaba.fastjson.JSONObject;
/**
* 形状定义Model
*/
public class ObjDefModel {
private String id;
private String name;
private String typeNum;// 类型1
private String symbolNum;// 类型2
private JSONObject attrData;// 名称以外的属性存储
public ObjDefModel() {
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getTypeNum() {
return typeNum;
}
public void setTypeNum(String typeNum) {
this.typeNum = typeNum;
}
public String getSymbolNum() {
return symbolNum;
}
public void setSymbolNum(String symbolNum) {
this.symbolNum = symbolNum;
}
public JSONObject getAttrData() {
return attrData;
}
public void setAttrData(JSONObject attrData) {
this.attrData = attrData;
}
@Override
public String toString() {
return "ObjDefModel{" +
"id='" + id + '\'' +
", name='" + name + '\'' +
", typeNum='" + typeNum + '\'' +
", symbolNum='" + symbolNum + '\'' +
", attrData=" + attrData +
'}';
}
}

View File

@ -0,0 +1,97 @@
package com.actionsoft.apps.coe.pal.datamigration.aris.model;
/**
* 模型形状Model
*/
public class ObjOccModel {
private String id;
private String defId;
private String modelId;
// private JSONArray attrData;// 存储属性相关的位置目前不用
private int x;
private int y;
private int w;
private int h;
private String symbolNum;
public ObjOccModel() {
}
public String getSymbolNum() {
return symbolNum;
}
public void setSymbolNum(String symbolNum) {
this.symbolNum = symbolNum;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getDefId() {
return defId;
}
public void setDefId(String defId) {
this.defId = defId;
}
public String getModelId() {
return modelId;
}
public void setModelId(String modelId) {
this.modelId = modelId;
}
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
public int getY() {
return y;
}
public void setY(int y) {
this.y = y;
}
public int getW() {
return w;
}
public void setW(int w) {
this.w = w;
}
public int getH() {
return h;
}
public void setH(int h) {
this.h = h;
}
@Override
public String toString() {
return "ObjOccModel{" +
"id='" + id + '\'' +
", defId='" + defId + '\'' +
", modelId='" + modelId + '\'' +
", x=" + x +
", y=" + y +
", w=" + w +
", h=" + h +
'}';
}
}

View File

@ -0,0 +1,30 @@
package com.actionsoft.apps.coe.pal.datamigration.aris.model;
/**
* 连线起始端和折点Model
*/
public class PositionModel {
private int x;
private int y;
public PositionModel(int x, int y) {
this.x = x;
this.y = y;
}
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
public int getY() {
return y;
}
public void setY(int y) {
this.y = y;
}
}

View File

@ -0,0 +1,128 @@
package com.actionsoft.apps.coe.pal.datamigration.aris.util;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.SAXReader;
import org.dom4j.io.XMLWriter;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import java.io.*;
/**
* XML读取帮助类
* @author zhouxuan
*/
public class XMLUtil {
/**
* copy数据将unicode数据转换为中文
* @param fromFilePath
* @param toFilePath
*/
public static void unicode2String(String fromFilePath, String toFilePath) {
Document d = XMLUtil.readXML(fromFilePath, true);
XMLUtil.writeXml(d, toFilePath);
}
public static Document readXML(String filePath, boolean ignoreDtd) {
if (filePath == null) {
return null;
}
SAXReader reader = new SAXReader();
if (ignoreDtd) {
reader.setValidation(false);
reader.setEntityResolver(new EntityResolver() {
@Override
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
return new InputSource(new ByteArrayInputStream("<?xml version='1.0' encoding='UTF-8'?>".getBytes()));
}
});
}
Document document = null;
try {
int jarIndicator = filePath.indexOf('!');
if (jarIndicator > 0) {
filePath = filePath.substring(5, filePath.indexOf('!'));
}
File f = new File(filePath);
InputStream in = new FileInputStream(f);
if (in != null) {
document = reader.read(in);
} else {
File file = new File(filePath);
document = reader.read(file);
}
return document;
} catch (DocumentException e) {
File fil = new File(filePath);
try {
document = reader.read(fil);
} catch (Exception e1) {
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public static Document readXMLFromInputStream(InputStream in) {
Document document = null;
SAXReader reader = new SAXReader();
try {
document = reader.read(in);
} catch (DocumentException e) {
e.printStackTrace();
}
return document;
}
public static void writeXml(Document document, String filePath) {
File xmlFile = new File(filePath);
XMLWriter writer = null;
try {
if (xmlFile.exists())
xmlFile.delete();
writer = new XMLWriter(new FileOutputStream(xmlFile), OutputFormat.createPrettyPrint());
writer.write(document);
writer.close();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (writer != null) {
try {
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
public static Document createDocument(String rootName, String attributeName, String attributeVaule) {
Document document = null;
try {
document = DocumentHelper.createDocument();
Element root = document.addElement(rootName);
root.addAttribute(attributeName, attributeVaule);
} catch (Exception e) {
throw new RuntimeException(e + "->创建的【" + rootName + "】根节点出现错误");
}
return document;
}
}

View File

@ -0,0 +1,327 @@
package com.actionsoft.apps.coe.pal.datamigration.aris.web;
import com.actionsoft.apps.coe.pal.datamigration.aris.model.*;
import com.actionsoft.bpms.util.UtilString;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang.StringUtils;
import org.dom4j.Document;
import org.dom4j.Element;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 对Aris文件进行解析清洗
*/
public class ArisXmlHandleWeb {
public Map<String, GroupModel> groupMap = new HashMap<>();// 文件夹/组基本信息map记录
public Map<String, ModelModel> modelMap = new HashMap<>();// 模型基本信息map记录
public Map<String, ObjDefModel> objDefMap = new HashMap<>();// 形状定义map记录
public Map<String, List<ObjOccModel>> modelObjOccMap = new HashMap<>();// 模型内形状map记录
public Map<String, ObjOccModel> objOccMap = new HashMap<>();// 所有模型中所有形状map记录
public Map<String, List<CxnOccModel>> cxnOccMap = new HashMap<>();// 所有模型中所有连线map记录
// 连线 todo
// 属性 todo
// 处理文档
public void handleXmlDoc(Document doc) {
// 获取根元素节点
Element root = doc.getRootElement();
String groupPath = "/";
getNodes(root, groupPath);
// 整合Model路径
calculateModelPath();
test();
}
private void calculateModelPath() {
for (Map.Entry<String, ModelModel> entry : modelMap.entrySet()) {
ModelModel modelModel = entry.getValue();
String modelParent = modelModel.getPid();
List<String> path = new ArrayList<>();
if (groupMap.containsKey(modelParent)) {
path.add(groupMap.get(modelParent).getName());
getPath(path, groupMap.get(modelParent).getPid());
}
modelModel.setModelPath(StringUtils.join(path, "\\"));
}
}
private void getPath(List<String> path, String pid) {
if (groupMap.containsKey(pid)) {
path.add(0, groupMap.get(pid).getName());
getPath(path, groupMap.get(pid).getPid());
}
}
public void getNodes(Element node, String groupPath){
if ("FontStyleSheet".equalsIgnoreCase(node.getName())
|| "Header-Info".equalsIgnoreCase(node.getName())
|| "Language".equalsIgnoreCase(node.getName())
|| "FFTextDef".equalsIgnoreCase(node.getName())
|| "OLEDef".equalsIgnoreCase(node.getName())) {
return;
}
// System.out.println("groupPath " + groupPath);
// System.out.println("--------------------");
//当前节点的名称文本内容和属性
// System.out.println("当前节点名称:"+node.getName());//当前节点名称
// System.out.println("当前节点的内容:"+node.getTextTrim());//当前节点名称
// List<Attribute> listAttr=node.attributes();//当前节点的所有属性的list
// for(Attribute attr:listAttr){//遍历当前节点的所有属性
// String name=attr.getName();//属性名称
// String value=attr.getValue();//属性的值
// System.out.println("属性名称:"+name+"属性值:"+value);
// }
//递归遍历当前节点所有的子节点
List<Element> listElement=node.elements();//所有一级子节点的list
for(Element e:listElement){//遍历所有一级子节点
if ("Group".equals(e.getParent().getName())) {
// 获取文件夹拼接组路径
List<Element> attrDefList = e.elements("AttrDef");
for(Element attrDef : attrDefList) {
if ("AT_NAME".equals(attrDef.attributeValue("AttrDef.Type"))) {
String groupName = getAttrValue(attrDef);
groupPath += groupName + "/";
// 不再往下遍历
continue;
} else {
// 其他属性暂无
}
}
}
if ("Group".equals(e.getName())) {
List<Element> attrDefList = e.elements("AttrDef");
String name = "";
JSONObject groupAttr = new JSONObject();
for(Element attrDef : attrDefList) {
if ("AT_NAME".equals(attrDef.attributeValue("AttrDef.Type"))) {
name = getAttrValue(attrDef);
} else {
// 其他attr属性
groupAttr.put(attrDef.attributeValue("AttrDef.Type"), getAttrValue(attrDef));
}
}
String id = e.attributeValue("Group.ID");
String pid = e.getParent().attributeValue("Group.ID");
String type = e.attributeValue("TypeNum");
String modelPath = "";
String createTime = e.attributeValue("CreationTimeStamp");
String createUser = e.attributeValue("Creator");
String modifyTime = e.attributeValue("LastModificationTimeStamp");
String modifyUser = e.attributeValue("LastModifier");
GroupModel groupModel = new GroupModel();
groupModel.setId(id);
groupModel.setName(name);
groupModel.setPid(pid);
groupModel.setType(type);
groupModel.setModelPath(modelPath);
groupModel.setCreateTime(createTime);
groupModel.setCreateUser(createUser);
groupModel.setModifyTime(modifyTime);
groupModel.setModifyUser(modifyUser);
groupModel.setAttrData(groupAttr);
groupMap.put(id, groupModel);
}
// 获取形状定义信息
if ("ObjDef".equals(e.getName())) {
List<Element> attrDefList = e.elements("AttrDef");
String name = "";
JSONObject objDefAttr = new JSONObject();
for(Element attrDef : attrDefList) {
if ("AT_NAME".equals(attrDef.attributeValue("AttrDef.Type"))) {
name = getAttrValue(attrDef);
} else {
// 其他attr属性
objDefAttr.put(attrDef.attributeValue("AttrDef.Type"), getAttrValue(attrDef));
}
}
String id = e.attributeValue("ObjDef.ID");
String typeNum = e.attributeValue("TypeNum");
String symbolNum = e.attributeValue("SymbolNum");
ObjDefModel objDefModel = new ObjDefModel();
objDefModel.setId(id);
objDefModel.setName(name);
objDefModel.setTypeNum(typeNum);
objDefModel.setSymbolNum(symbolNum);
objDefModel.setAttrData(objDefAttr);
objDefMap.put(id, objDefModel);
continue;// 不再往下遍历
}
// 获取Model信息
if ("Model".equals(e.getName())) {
List<Element> attrDefList = e.elements("AttrDef");
String name = "";
JSONObject modelAttr = new JSONObject();
for(Element attrDef : attrDefList) {
if ("AT_NAME".equals(attrDef.attributeValue("AttrDef.Type"))) {
name = getAttrValue(attrDef);
} else {
// 其他attr属性
modelAttr.put(attrDef.attributeValue("AttrDef.Type"), getAttrValue(attrDef));
}
}
String id = e.attributeValue("Model.ID");
String type = e.attributeValue("Model.Type");
String pid = e.getParent().attributeValue("Group.ID");
String createTime = e.attributeValue("CreationTimeStamp");
String createUser = e.attributeValue("Creator");
String modifyTime = e.attributeValue("LastModificationTimeStamp");
String modifyUser = e.attributeValue("LastModifier");
ModelModel modelModel = new ModelModel();
modelModel.setId(id);
modelModel.setName(name);
modelModel.setPid(pid);
modelModel.setType(type);
modelModel.setCreateTime(createTime);
modelModel.setCreateUser(createUser);
modelModel.setModifyTime(modifyTime);
modelModel.setModifyUser(modifyUser);
modelModel.setAttrData(modelAttr);
modelMap.put(id, modelModel);
}
// 获取Model中形状大小位置信息
if ("ObjOcc".equals(e.getName())) {
String id = e.attributeValue("ObjOcc.ID");
String defId = e.attributeValue("ObjDef.IdRef");
// 所有距离的1/3与PAL中等值
int x = Integer.parseInt(e.element("Position").attributeValue("Pos.X")) / 3;
int y = Integer.parseInt(e.element("Position").attributeValue("Pos.Y")) / 3;
int w = Integer.parseInt(e.element("Size").attributeValue("Size.dX")) / 3;
int h = Integer.parseInt(e.element("Size").attributeValue("Size.dY")) / 3;
String modelId = e.getParent().attributeValue("Model.ID");
ObjOccModel objOccModel = new ObjOccModel();
objOccModel.setId(id);
objOccModel.setDefId(defId);
objOccModel.setModelId(modelId);
objOccModel.setX(x);
objOccModel.setY(y);
objOccModel.setW(w);
objOccModel.setH(h);
objOccModel.setSymbolNum(e.attributeValue("SymbolNum"));
objOccMap.put(id, objOccModel);
// 连线处理
getCxnOccModel(id, e);
if (!modelObjOccMap.containsKey(modelId)) {
modelObjOccMap.put(modelId, new ArrayList<>());
}
modelObjOccMap.get(modelId).add(objOccModel);
continue;// 不再往下遍历
}
this.getNodes(e, groupPath);//递归
}
}
// 计算连线创建连线对象
private void getCxnOccModel(String id, Element e) {
List<Element> list = e.elements("CxnOcc");
if (list != null && list.size() > 0) {
for (Element cxnEle: list) {
String toId = cxnEle.attributeValue("ToObjOcc.IdRef");
List<Element> posList = cxnEle.elements("Position");
if (posList != null && posList.size() > 0) {
CxnOccModel cxnOccModel = new CxnOccModel();
cxnOccModel.setId(id);
cxnOccModel.setToId(toId);
cxnOccModel.setPositionList(new ArrayList<>());
for (Element posEle: posList) {
int x = Integer.parseInt(posEle.attributeValue("Pos.X")) / 3;
int y = Integer.parseInt(posEle.attributeValue("Pos.Y")) / 3;
PositionModel pos = new PositionModel(x, y);
cxnOccModel.getPositionList().add(pos);
}
if (!cxnOccMap.containsKey(id)) {
cxnOccMap.put(id, new ArrayList<>());
}
cxnOccMap.get(id).add(cxnOccModel);
}
}
}
}
private void test() {
for (Map.Entry<String, ModelModel> entry : modelMap.entrySet()) {
ModelModel modelModel = entry.getValue();
// System.out.println("=================");
System.out.println("模型信息:" + modelModel.getModelPath() + "/" +modelModel.getName());
// System.out.println(modelModel);
// System.out.println("模型信息" + modelModel.getName() + " " + modelModel.getAttrData());
List<ObjOccModel> list = modelObjOccMap.get(modelModel.getId());
if (list != null) {
System.out.println("模型内形状信息:");
for (ObjOccModel objOccModel : list) {
// System.out.println("模型内的形状信息:" + objDefMap.get(objOccModel.getDefId()).getName());
// System.out.print(objDefMap.get(objOccModel.getDefId()).getName() + " ");
// System.out.println(objDefMap.get(objOccModel.getDefId()).getAttrData());
// System.out.println(objOccModel);
// System.out.println("该形状定义信息");
// System.out.println(objDefMap.get(objOccModel.getDefId()));
}
System.out.println();
// 获取模型内所有连线
for (ObjOccModel occ: list) {
if (cxnOccMap.containsKey(occ.getId())) {
List<CxnOccModel> cxnOccModels = cxnOccMap.get(occ.getId());
for (CxnOccModel cxn: cxnOccModels) {
ObjOccModel idObj = objOccMap.get(cxn.getId());
ObjOccModel toIdObj = objOccMap.get(cxn.getToId());
System.out.println(
objDefMap.get(idObj.getDefId()).getName() + " 的下一个形状是 " + objDefMap.get(toIdObj.getDefId()).getName()
);
}
}
}
}else {
System.out.println("当前流程【"+modelModel.getName()+"】下没有图形 流程的ARIS路径为 "+modelModel.getModelPath());
}
}
System.out.println("================");
}
/**
* 获取编号
* @param e
* @return
*/
private String getAttrValue(Element e) {
if (e.element("AttrValue").isTextOnly()) {
return e.element("AttrValue").getTextTrim();
}
// 递归查询TextValue
List<Element> elements = new ArrayList<>();
getAllChildElements(e, elements);
List<String> textList = new ArrayList<>();
for (Element ele : elements) {
if ("PlainText".equals(ele.getName()) && UtilString.isNotEmpty(ele.attributeValue("TextValue"))) {
textList.add(ele.attributeValue("TextValue"));
}
}
return StringUtils.join(textList, "\n");
}
private void getAllChildElements(Element e, List<Element> elements) {
List<Element> childList = e.elements();
for (Element child : childList) {
elements.add(child);
getAllChildElements(child, elements);
}
}
}

View File

@ -0,0 +1,58 @@
package com.actionsoft.apps.coe.pal.datamigration.constant;
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\":\"FileTable\"},{\"title\":\"支持文件\",\"type\":\"FileTable\"},{\"title\":\"目的\",\"type\":\"Text\"},{\"title\":\"附则\",\"type\":\"Text\"}]";
public final static String OLDWORDIMPORT = "[{\"title\":\"概述\",\"type\":\"DirectFeild\"},{\"title\":\"术语定义\",\"type\":\"Table\"},{\"title\":\"组织职责\",\"type\":\"Table\"},{\"title\":\"附则\",\"type\":\"Text\"},{\"title\":\"附件\",\"type\":\"Text\"}]";
public final static String OLDWORDMAPPING = "[{\"key\":\"修订内容及理由\",\"value\":\"修订内容\"},{\"key\":\"拟制/修订单位\",\"value\":\"拟制部门\"},{\"key\":\"拟制/修订人\",\"value\":\"拟制人\"},{\"key\":\"审批人\",\"value\":\"批准人\"},{\"key\":\"目的\",\"value\":\"流程目的\"},{\"key\":\"适用范围\",\"value\":\"流程范围\"},{\"key\":\"术语\",\"value\":\"术语定义\"},{\"key\":\"组织/角色与职责\",\"value\":\"组织职责\"}]";
// 构造连线时的几个固定参数
public final static double ANGLE_RIGHT = 0;
public final static double ANGLE_DOWN = 1.5707963267948968;
public final static double ANGLE_LEFT = 3.141592653589793;
public final static double ANGLE_UP = 4.71238898038469;
// 建模属性代码--编号
// public static final String METHOD_NUMBER = "number";
public static final String METHOD_NUMBER = "activity_number";
// 建模属性代码--描述
// public static final String METHOD_NUMBER = "number";
public static final String METHOD_DESC = "activity_description";
// 建模属性代码--角色
// public static final String METHOD_ROLE = "role";
public static final String METHOD_ROLE = "role";
// 建模属性代码--岗位
// public static final String METHOD_POST = "post";
public static final String METHOD_POST = "post";
// 建模属性代码--信息系统
public static final String METHOD_INFO_SYSTEM = "information_systems";
// 建模属性代码--输入
public static final String METHOD_INPUT = "input";
// 建模属性代码--输出
public static final String METHOD_OUTPUT = "output";
// 建模属性代码--前置流程
// public static final String METHOD_PRE_PROCESS = "PRE_PROCESS";
public static final String METHOD_PRE_PROCESS = "pre_process";
// 建模属性代码--后置流程
// public static final String METHOD_NEXT_PROCESS = "NEXT_PROCESS";
public static final String METHOD_NEXT_PROCESS = "next_process";
// 流程属性--ARIS地址
// public static final String METHOD_ARIS_URL = "ARISURL";
public static final String METHOD_ARIS_URL = "ARIS";
// 存放与流程同名的角色模型的文件夹名称
public static final String DEFAULT_FOLDER_NAME = "角色模型";
}

View File

@ -0,0 +1,218 @@
package com.actionsoft.apps.coe.pal.datamigration.job;
import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache;
import com.actionsoft.apps.coe.pal.pal.repository.dao.CoeProcessLevelDaoFacotory;
import com.actionsoft.apps.coe.pal.pal.repository.dao.PALRepository;
import com.actionsoft.apps.coe.pal.pal.repository.designer.manage.CoeDesignerAPIManager;
import com.actionsoft.apps.coe.pal.pal.repository.designer.model.BaseModel;
import com.actionsoft.apps.coe.pal.pal.repository.designer.util.CoeDesignerUtil;
import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel;
import com.actionsoft.apps.coe.pal.pal.repository.model.impl.PALRepositoryModelImpl;
import com.actionsoft.apps.coe.pal.pal.repository.util.CoeProcessLevelUtil;
import com.actionsoft.bpms.bo.engine.BO;
import com.actionsoft.bpms.commons.database.RowMap;
import com.actionsoft.bpms.schedule.IJob;
import com.actionsoft.bpms.util.DBSql;
import com.actionsoft.bpms.util.UUIDGener;
import com.actionsoft.sdk.local.SDK;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.sun.corba.se.pept.transport.ContactInfo;
import jodd.madvoc.meta.In;
import jodd.util.StringUtil;
import org.apache.commons.lang.StringUtils;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import java.sql.Timestamp;
import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;
public class SynchronousOrgJob implements IJob {
static List<RowMap> orgdepartmentList;
static int orgindex = 0;
static String parentModelId = "";
@Override
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
Map<String, String> idRelationMap = new HashMap<>();
//先执行新建操作产生plid
PALRepository coeProcessLevel = CoeProcessLevelDaoFacotory.createCoeProcessLevel();
String parentId = "org";
String parentVersionId = "";
int level = 1;
if (parentId.length() < 36) {// 父节点是大类
parentVersionId = parentId;
} else {
PALRepositoryModel parentModel = PALRepositoryCache.getCache().get(parentId);
parentVersionId = parentModel.getVersionId();
level = parentModel.getLevel() + 1;
}
String plRid1 = UUIDGener.getUUID();
String id1 = UUIDGener.getUUID();
orgdepartmentList = DBSql.getMaps("select DEPARTMENTNAME,ID,LAYER,PARENTDEPARTMENTID,ORDERINDEX from ORGDEPARTMENT limit 20");
Timestamp nowTime = new Timestamp(System.currentTimeMillis());
PALRepositoryModelImpl model = CoeProcessLevelUtil.createPALRepositoryModel(id1, plRid1, "6f4e292c-1b90-4dd2-8c20-7da159cb20a5", "内蒙古伊利实业集团股份有限公司",
"", 1, "org", "org", true, 1,
id1, false, "org.normal", "0", 1, null,
null, "admin", "admin", nowTime, "0", null,
null, null, null, null, null, null, null, 1);
coeProcessLevel.insert(model);
parentModelId=model.getId();
// createTree(orgdepartmentList);
orgindex = 0;
createTree();
}
public void createTree() {
for (RowMap oneData : orgdepartmentList) {
System.out.println("onedata======"+oneData.toString());
orgindex++;
/* if (oneData.getString("isCreate").equals("1")) {
continue;
}*/
creatNode(oneData);
}
System.out.println("同步完成,数据" + orgindex);
}
public String creatNode(RowMap org) {
//先执行新建操作产生plid
PALRepository coeProcessLevel = CoeProcessLevelDaoFacotory.createCoeProcessLevel();
String modelId="";
String plRid1 = UUIDGener.getUUID();
String id1 = UUIDGener.getUUID();
Timestamp nowTime = new Timestamp(System.currentTimeMillis());
System.out.println("=================当前节点ID" + org.getString("ID"));
if (org.getString("PARENTDEPARTMENTID").equals("0")) {
String sql1 = "SELECT ID FROM app_act_coe_pal_repository WHERE WSID='6f4e292c-1b90-4dd2-8c20-7da159cb20a5' and EXT1='" + org.getString("ID") + "'";
String parentPalOrgId1 = DBSql.getString(sql1);
if(StringUtil.isEmpty(parentPalOrgId1)){
System.out.println("org========"+org.toString());
System.out.println("parentID"+org.getString("ORDERINDEX"));
PALRepositoryModelImpl model1 = CoeProcessLevelUtil.createPALRepositoryModel(id1, plRid1, "6f4e292c-1b90-4dd2-8c20-7da159cb20a5", org.getString("DEPARTMENTNAME"),
"", 1, parentModelId, "org", true, 1,
id1, false, "org.normal", "0", Integer.valueOf(org.getString("ORDERINDEX")), null,
null, "admin", "admin", nowTime, org.getString("ID"), null,
null, null, null, null, null, null, null, 1);
coeProcessLevel.insert(model1);
// 修改创建状态
//orgdepartmentList.get(orgindex).put("isCreate", "1");
// org.put("isCreate","1");
System.out.println("父节点创建" + model1.getId());
return modelId=model1.getId();
}
} else {
// 获取父部门
// getParentOrg(org);
String parentPalOrgId = getParentPalOrgId(org);
if(StringUtil.isNotEmpty(parentPalOrgId)){
System.out.println("xxxxxxxxxxxxxxxxxx"+org.getString("ORDERINDEX"));
PALRepositoryModelImpl model2 = CoeProcessLevelUtil.createPALRepositoryModel(id1, plRid1, "6f4e292c-1b90-4dd2-8c20-7da159cb20a5", org.getString("DEPARTMENTNAME"),
"", 1, getParentPalOrgId(org), "org", true, 1,
id1, false, "org.normal", "0", Integer.valueOf(org.getString("ORDERINDEX")), null,
null, "admin", "admin", nowTime, org.getString("ID"), null,
null, null, null, null, null, null, null, 1);
coeProcessLevel.insert(model2);
System.out.println("bbbbbbbbbb" + model2.getId());
return modelId=model2.getId();
// 修改创建状态
//orgdepartmentList.get(orgindex).put("isCreate", "1");
}
}
return modelId;
}
public String getParentPalOrgId(RowMap org) {
// RowMap parentOrg;
// List<RowMap> orgdepartmentList = DBSql.getMaps("select DEPARTMENTNAME,ID,LAYER,PARENTDEPARTMENTID from ORGDEPARTMENT where id = '" +org.getString("PARENTDEPARTMENTID")+"'");
// parentOrg = orgdepartmentList.get(0);
// System.out.println( "==============父节点ID"+parentOrg.getString("ID"));
// return parentOrg.getString("ID");
String sql = "SELECT ID FROM app_act_coe_pal_repository WHERE WSID='6f4e292c-1b90-4dd2-8c20-7da159cb20a5' and EXT1='" + org.getString("PARENTDEPARTMENTID") + "'";
String parentPalOrgId = DBSql.getString(sql);
if (parentPalOrgId.equals("0") || parentPalOrgId.equals("") || parentPalOrgId == null) {
RowMap parentOrg = DBSql.getMap("select DEPARTMENTNAME,ID,LAYER,PARENTDEPARTMENTID,ORDERINDEX from ORGDEPARTMENT where id = '" + org.getString("PARENTDEPARTMENTID") + "'");
creatNode(parentOrg);
// 修改创建状态
//orgdepartmentList.remove(org);
// orgdepartmentList.add(parentOrg);
}
return parentPalOrgId;
}
public String getParentPallevel(RowMap org) {
// RowMap parentOrg;
// List<RowMap> orgdepartmentList = DBSql.getMaps("select DEPARTMENTNAME,ID,LAYER,PARENTDEPARTMENTID from ORGDEPARTMENT where id = '" +org.getString("PARENTDEPARTMENTID")+"'");
// parentOrg = orgdepartmentList.get(0);
// System.out.println( "==============父节点ID"+parentOrg.getString("ID"));
// return parentOrg.getString("ID");
String sql = "SELECT ID FROM app_act_coe_pal_repository WHERE WSID='6f4e292c-1b90-4dd2-8c20-7da159cb20a5' and EXT1='" + org.getString("PARENTDEPARTMENTID") + "'";
String parentPalOrgId = DBSql.getString(sql);
if (parentPalOrgId.equals("0") || parentPalOrgId.equals("") || parentPalOrgId == null) {
RowMap parentOrg = DBSql.getMap("select DEPARTMENTNAME,ID,LAYER,PARENTDEPARTMENTID from ORGDEPARTMENT where id = '" + org.getString("PARENTDEPARTMENTID") + "'");
creatNode(parentOrg);
}
return parentPalOrgId;
}
}

View File

@ -0,0 +1,160 @@
package com.actionsoft.apps.coe.pal.datamigration.job;
import com.actionsoft.apps.coe.pal.datamigration.aris.mapping.ModelMappingAPIManager;
import com.actionsoft.apps.coe.pal.datamigration.aris.model.*;
import com.actionsoft.apps.coe.pal.datamigration.util.DiagramUtil;
import com.actionsoft.apps.coe.pal.datamigration.util.ShapeUtil;
import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache;
import com.actionsoft.apps.coe.pal.pal.repository.dao.CoeProcessLevelDaoFacotory;
import com.actionsoft.apps.coe.pal.pal.repository.dao.PALRepository;
import com.actionsoft.apps.coe.pal.pal.repository.designer.constant.CoeDesignerConstant;
import com.actionsoft.apps.coe.pal.pal.repository.designer.manage.CoeDesignerAPIManager;
import com.actionsoft.apps.coe.pal.pal.repository.designer.model.BaseModel;
import com.actionsoft.apps.coe.pal.pal.repository.designer.util.CoeDesignerUtil;
import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel;
import com.actionsoft.apps.coe.pal.pal.repository.model.impl.PALRepositoryModelImpl;
import com.actionsoft.apps.coe.pal.pal.repository.util.CoeProcessLevelUtil;
import com.actionsoft.apps.coe.pal.pal.repository.web.CoeProcessLevelWeb;
import com.actionsoft.bpms.bo.engine.BO;
import com.actionsoft.bpms.commons.database.RowMap;
import com.actionsoft.bpms.commons.login.constant.LoginConst;
import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
import com.actionsoft.bpms.schedule.IJob;
import com.actionsoft.bpms.server.SSOUtil;
import com.actionsoft.bpms.server.UserContext;
import com.actionsoft.bpms.util.DBSql;
import com.actionsoft.bpms.util.UUIDGener;
import com.actionsoft.exception.ExceptionUtil;
import com.actionsoft.sdk.local.SDK;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import jodd.util.StringUtil;
import org.apache.commons.lang.StringUtils;
import org.docx4j.wml.R;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import java.io.IOException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.*;
public class SynchronousPostJob implements IJob {
/**
* 定时从BPM组织同步PAL组织架构中
* @param jobExecutionContext
* @throws JobExecutionException
*/
@Override
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
Map<String, String> idRelationMap = new HashMap<>();
//先执行新建操作产生plid
PALRepository coeProcessLevel = CoeProcessLevelDaoFacotory.createCoeProcessLevel();
String plRid = UUIDGener.getUUID();
String id = UUIDGener.getUUID();
String parentId="org";
String parentVersionId = "";
int level = 1;
if (parentId.length() < 36) {// 父节点是大类
parentVersionId = parentId;
} else {
PALRepositoryModel parentModel = PALRepositoryCache.getCache().get(parentId);
parentVersionId = parentModel.getVersionId();
level = parentModel.getLevel() + 1;
}
Timestamp nowTime = new Timestamp(System.currentTimeMillis());
PALRepositoryModelImpl model = CoeProcessLevelUtil.createPALRepositoryModel(id, plRid, "6f4e292c-1b90-4dd2-8c20-7da159cb20a5", "伊利集团",
"", 1, "org", "org", true, 1,
id, false, "org.normal", "0", 1, null,
null, "admin", "admin", nowTime, null, null,
null, null, null, null, null, null, null,1);
System.out.println(model.getId());
coeProcessLevel.insert(model);
BaseModel defineModel = CoeDesignerAPIManager.getInstance().getDefinition(model.getId(), 0);
if(defineModel ==null ){
defineModel = CoeDesignerUtil.createModel(model.getId(),0);
defineModel.setCreateHistory(false);
}
String define = defineModel.getDefinition();
JSONObject definition = JSONObject.parseObject(define);
JSONObject elements = definition.getJSONObject("elements");
//新建一个uuid
String shapeId = UUIDGener.getObjectId();
//拿到基础结构
JSONObject shape = ShapeUtil.getProcessShapeDefinitionByName("org.normal", "position");
/*shape.put("id", shapeId);
shape.put("text","伊利集团");
JSONObject props = shape.getJSONObject("props");// 位置大小
props.put("zindex", 0);
props.put("x", Integer.parseInt("784"));
props.put("y", Integer.parseInt("166"));
props.put("w", Integer.parseInt("110"));
props.put("h", Integer.parseInt("50"));
elements.put(shapeId, shape);*/
if (StringUtils.isNotEmpty(definition.getString("commonShapeConfig"))) {
definition.remove("commonShapeConfig");
}
List<RowMap> orgdepartmentList=DBSql.getMaps("select * from ORGUSER ");
int zindex = 1;
if(orgdepartmentList.size()>0){
for(int i=0;i<orgdepartmentList.size();i++){
//新建一个uuid
String shapeId1 = UUIDGener.getObjectId();
//拿到基础结构
JSONObject shape1 = ShapeUtil.getProcessShapeDefinitionByName("org.normal", "position");
String postionname=orgdepartmentList.get(i).getString("POSITION_NAME");
if(StringUtil.isNotEmpty(postionname)){
shape1.put("id", shapeId1);
shape1.put("text",orgdepartmentList.get(i).getString("POSITION_NAME"));
JSONObject props1 = shape1.getJSONObject("props");// 位置大小
props1.put("x", 130*zindex);
props1.put("y", 277);
props1.put("w", 110);
props1.put("h", 50);
props1.put("zindex", zindex++);
elements.put(shapeId1, shape1);
}
}
}
// 设置画布大小
DiagramUtil.setDiagramHeightWidth(definition, elements);
defineModel.setDefinition(definition.toString());
// 保存文件
CoeDesignerAPIManager.getInstance().storeDefinition(defineModel);// dao操作
}
}

View File

@ -0,0 +1,39 @@
package com.actionsoft.apps.coe.pal.datamigration.model.po;
public class AwsOrgInfo {
private String id;
private String name;
private String type;
public AwsOrgInfo() { }
public AwsOrgInfo(String id, String name, String type) {
this.id = id;
this.name = name;
this.type = type;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}

View File

@ -0,0 +1,29 @@
package com.actionsoft.apps.coe.pal.datamigration.model.po;
public class WordAttribute {
private String title;
private String type;
public WordAttribute() { }
public WordAttribute(String title, String type) {
this.title = title;
this.type = type;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}

View File

@ -0,0 +1,20 @@
package com.actionsoft.apps.coe.pal.datamigration.model.po;
public class WordField<T> {
private T data;
public WordField() {}
public WordField(T data) {
this.data = data;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
}

View File

@ -0,0 +1,38 @@
package com.actionsoft.apps.coe.pal.datamigration.plugin;
import com.actionsoft.apps.coe.pal.datamigration.web.DataMigrationWeb;
import com.actionsoft.apps.coe.pal.pal.repository.upfile.CoeFileProcessor;
import com.actionsoft.apps.listener.PluginListener;
import com.actionsoft.apps.resource.AppContext;
import com.actionsoft.apps.resource.plugin.profile.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class Plugins implements PluginListener {
public static boolean installed = false;
public Plugins() {
}
@Override
public List<AWSPluginProfile> register(AppContext context) {
List<AWSPluginProfile> list = new ArrayList<AWSPluginProfile>();
list.add(new DCPluginProfile("migration", CoeFileProcessor.class.getName(), "存放数据迁移文件", false, false));
// PAL应用扩展点
Map<String, Object> params0 = new HashMap<String, Object>();
params0.put("title", "PAL数据迁移");
params0.put("icon", "");
params0.put("desc", "PAL数据迁移");
params0.put("mainClass", DataMigrationWeb.class.getName());
params0.put("deletedClass", "");
list.add(new AppExtensionProfile("PAL流程资产库->PAL数据迁移", "aslp://com.actionsoft.apps.coe.pal/registerExtendsApp", params0));
return list;
}
}

View File

@ -0,0 +1,52 @@
package com.actionsoft.apps.coe.pal.datamigration.util;
import com.alibaba.fastjson.JSONObject;
import java.util.Iterator;
public class DiagramUtil {
/**
* 设置画布大小
* @param elements
*/
public static void setDiagramHeightWidth(JSONObject definition, JSONObject elements) {
// 获取最大宽高给100长度富余
JSONObject maxHW = getMaxPositionXY(elements);
int maxX = maxHW.getInteger("maxX") + 150;
int maxH = maxHW.getInteger("maxY") + 150;
JSONObject page = definition.getJSONObject("page");
int pageW = page.getInteger("width");
int pageH = page.getInteger("height");
page.put("width", pageW > maxX ? pageW : maxX);
page.put("height", pageH > maxH ? pageH : maxH);
definition.put("page", page);
}
public static JSONObject getMaxPositionXY(JSONObject elements) {
int maxX = -99999;
int maxY = -99999;
Iterator<String> it = elements.keySet().iterator();
while (it.hasNext()) {
String key = it.next();
JSONObject shape = elements.getJSONObject(key);
String shapeName = shape.getString("name");
if(!"linker".equals(shapeName)) {
JSONObject props = shape.getJSONObject("props");
int x = props.getInteger("x");
int y = props.getInteger("y");
maxX = maxX < x ? x : maxX;
maxY = maxY < y ? y : maxY;
}
}
JSONObject result = new JSONObject();
result.put("maxX", maxX);
result.put("maxY", maxY);
return result;
}
}

View File

@ -0,0 +1,126 @@
package com.actionsoft.apps.coe.pal.datamigration.util;
import com.actionsoft.bpms.util.UtilString;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.io.File;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
public class ExcelUtil {
private Map<String,Integer> titleMap = new HashMap<>();
private List<List<String>> dataList = new ArrayList<>();
public boolean analysisExcel(String path){
XSSFWorkbook sheets = null;
try {
sheets = new XSSFWorkbook(new File(path));
//默认获取第一个sheet页面
XSSFSheet sheet = sheets.getSheetAt(0);
//获取第一行为标题行
int firstRowNum = sheet.getFirstRowNum();
XSSFRow titleRow = sheet.getRow(firstRowNum);
for (int i=0;i<titleRow.getLastCellNum();i++){
XSSFCell cell = titleRow.getCell(i);
String key = this.getCellValueByCell(cell);
titleMap.put(key,i);
}
//标题行到最后解析数据信息
for (int i = firstRowNum+1; i<sheet.getLastRowNum();i++){
XSSFRow row = sheet.getRow(i);
List<String> rowList = new ArrayList<>();
for (int j = 0; j < row.getLastCellNum(); j++) {
XSSFCell cell = row.getCell(j);
String cellValue = this.getCellValueByCell(cell);
rowList.add(cellValue);
}
dataList.add(rowList);
}
} catch (IOException e) {
e.printStackTrace();
return false;
} catch (InvalidFormatException e) {
e.printStackTrace();
return false;
}
return true;
}
//获取单元格各类型值返回字符串类型
public String getCellValueByCell(XSSFCell cell) {
//判断是否为null或空串
if (cell == null || cell.toString().trim().equals("")) {
return "";
}
String cellValue = "";
int cellType = cell.getCellType();
// 以下是判断数据的类型
switch (cellType) {
case XSSFCell.CELL_TYPE_NUMERIC: // 数字
if (0 == cell.getCellType()) {//判断单元格的类型是否则NUMERIC类型
if (org.apache.poi.ss.usermodel.DateUtil.isCellDateFormatted(cell)) {// 判断是否为日期类型
Date date = cell.getDateCellValue();
DateFormat formater = new SimpleDateFormat(
"yyyy-MM-dd HH:mm");
cellValue = formater.format(date);
} else {
cellValue = cell.getNumericCellValue() + "";
if (!UtilString.isEmpty(cellValue)) {
cellValue = cellValue.endsWith(".0") ? cellValue.substring(0, cellValue.lastIndexOf(".0")) : cellValue;
}
}
}
break;
case XSSFCell.CELL_TYPE_STRING: // 字符串
cellValue = cell.getStringCellValue();
break;
case XSSFCell.CELL_TYPE_BOOLEAN: // Boolean
cellValue = cell.getBooleanCellValue() + "";
break;
case XSSFCell.CELL_TYPE_FORMULA: // 公式
cellValue = cell.getCellFormula() + "";
break;
case XSSFCell.CELL_TYPE_BLANK: // 空值
cellValue = "";
break;
// case XSSFCell.CELL_TYPE_ERROR: // 故障
// cellValue = "非法字符";
// break;
default:
cellValue = "";
break;
}
return cellValue.trim();
}
public Map<String, Integer> getTitleMap() {
return titleMap;
}
public void setTitleMap(Map<String, Integer> titleMap) {
this.titleMap = titleMap;
}
public List<List<String>> getDataList() {
return dataList;
}
public void setDataList(List<List<String>> dataList) {
this.dataList = dataList;
}
}

View File

@ -0,0 +1,206 @@
package com.actionsoft.apps.coe.pal.datamigration.util;
import com.actionsoft.apps.AppsConst;
import com.actionsoft.apps.coe.pal.constant.CoEConstant;
import com.actionsoft.apps.coe.pal.pal.method.PALMethodManager;
import com.actionsoft.apps.coe.pal.pal.method.cache.PALMethodCache;
import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodAttributeModel;
import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodModel;
import com.actionsoft.apps.coe.pal.pal.repository.PALRepositoryAPIManager;
import com.actionsoft.apps.coe.pal.pal.repository.PALRepositoryQueryAPIManager;
import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel;
import com.actionsoft.apps.lifecycle.api.AppsAPIManager;
import com.actionsoft.apps.resource.AppContext;
import com.actionsoft.bpms.server.UserContext;
import com.actionsoft.i18n.I18nRes;
import com.alibaba.fastjson.JSONObject;
import java.util.*;
public class ProcessUtil {
/**
* 获取流程下文件分类
* @return
*/
public static List<String> getProcessCategory() {
List<String> list = new ArrayList<String>();
list.add("简单文件分类");
List<PALMethodModel> methodModels = PALMethodManager.getInstance().getPALMethodModelListByMethod("process");
List<AppContext> listApps = AppsAPIManager.getInstance().getInstalledApps();
int size = listApps.size();
Map<String, String> map1 = new HashMap<String, String>();
for (int i = 0; i < size; i++) {
map1.put(listApps.get(i).getId(), listApps.get(i).getRuntimeState());
}
for (int i = 0, methodSize = methodModels.size(); i < methodSize; i++) {
PALMethodModel palMethodModel = methodModels.get(i);
String appId = palMethodModel.getId();
if (map1.containsKey("com.actionsoft.apps.coe.method." + appId)) {
String methodId1 = map1.get("com.actionsoft.apps.coe.method." + appId);
if (methodId1.equals(AppsConst.RUNTIME_STATE_STOPPED) || methodId1.equals(AppsConst.RUNTIME_STATE_FAILED) || methodId1.equals(AppsConst.RUNTIME_STATE_READY) || methodId1.equals(AppsConst.RUNTIME_STATE_STARTING) || methodId1.equals(AppsConst.RUNTIME_STATE_STOPPING) || methodId1.equals(AppsConst.RUNTIME_STATE_UNINSTALLED) || methodId1.equals(AppsConst.RUNTIME_STATE_UNINSTALLING) || methodId1.equals(AppsConst.RUNTIME_STATE_FAILED))
continue;
}
list.add(I18nRes.findValue(CoEConstant.APP_ID, palMethodModel.getId()));
}
return list;
}
/**
* 获取流程下文件分类
* @return
*/
public static List<String> getProcessCategoryCategoryMehtodList() {
List<String> list = new ArrayList<String>();
List<PALMethodModel> methodModels = PALMethodManager.getInstance().getPALMethodModelListByMethod("process");
List<AppContext> listApps = AppsAPIManager.getInstance().getInstalledApps();
int size = listApps.size();
Map<String, String> map1 = new HashMap<String, String>();
for (int i = 0; i < size; i++) {
map1.put(listApps.get(i).getId(), listApps.get(i).getRuntimeState());
}
for (int i = 0, methodSize = methodModels.size(); i < methodSize; i++) {
PALMethodModel palMethodModel = methodModels.get(i);
String appId = palMethodModel.getId();
if (map1.containsKey("com.actionsoft.apps.coe.method." + appId)) {
String methodId1 = map1.get("com.actionsoft.apps.coe.method." + appId);
if (methodId1.equals(AppsConst.RUNTIME_STATE_STOPPED) || methodId1.equals(AppsConst.RUNTIME_STATE_FAILED) || methodId1.equals(AppsConst.RUNTIME_STATE_READY) || methodId1.equals(AppsConst.RUNTIME_STATE_STARTING) || methodId1.equals(AppsConst.RUNTIME_STATE_STOPPING) || methodId1.equals(AppsConst.RUNTIME_STATE_UNINSTALLED) || methodId1.equals(AppsConst.RUNTIME_STATE_UNINSTALLING) || methodId1.equals(AppsConst.RUNTIME_STATE_FAILED))
continue;
}
list.add(palMethodModel.getId());
}
return list;
}
/**
* 获取流程下文件分类
* @return
*/
public static Map<String, String> getProcessCategoryMethod() {
Map<String, String> result = new HashMap<>();
result.put("简单文件分类", "default");
List<PALMethodModel> methodModels = PALMethodManager.getInstance().getPALMethodModelListByMethod("process");
List<AppContext> listApps = AppsAPIManager.getInstance().getInstalledApps();
int size = listApps.size();
Map<String, String> map1 = new HashMap<String, String>();
for (int i = 0; i < size; i++) {
map1.put(listApps.get(i).getId(), listApps.get(i).getRuntimeState());
}
for (int i = 0, methodSize = methodModels.size(); i < methodSize; i++) {
PALMethodModel palMethodModel = methodModels.get(i);
String appId = palMethodModel.getId();
if (map1.containsKey("com.actionsoft.apps.coe.method." + appId)) {
String methodId1 = map1.get("com.actionsoft.apps.coe.method." + appId);
if (methodId1.equals(AppsConst.RUNTIME_STATE_STOPPED) || methodId1.equals(AppsConst.RUNTIME_STATE_FAILED) || methodId1.equals(AppsConst.RUNTIME_STATE_READY) || methodId1.equals(AppsConst.RUNTIME_STATE_STARTING) || methodId1.equals(AppsConst.RUNTIME_STATE_STOPPING) || methodId1.equals(AppsConst.RUNTIME_STATE_UNINSTALLED) || methodId1.equals(AppsConst.RUNTIME_STATE_UNINSTALLING) || methodId1.equals(AppsConst.RUNTIME_STATE_FAILED))
continue;
}
result.put(I18nRes.findValue(CoEConstant.APP_ID, palMethodModel.getId()), palMethodModel.getId());
}
return result;
}
/**
* 获取流程下文件分类
*
* @return
*/
public static JSONObject getProcessMethods() {
JSONObject result = new JSONObject();
result.put("default", "简单文件分类");
List<PALMethodModel> methodModels = PALMethodManager.getInstance().getPALMethodModelListByMethod("process");
List<AppContext> listApps = AppsAPIManager.getInstance().getInstalledApps();
int size = listApps.size();
Map<String, String> map1 = new HashMap<String, String>();
for (int i = 0; i < size; i++) {
map1.put(listApps.get(i).getId(), listApps.get(i).getRuntimeState());
}
for (int i = 0, methodSize = methodModels.size(); i < methodSize; i++) {
PALMethodModel palMethodModel = methodModels.get(i);
String appId = palMethodModel.getId();
if (map1.containsKey("com.actionsoft.apps.coe.method." + appId)) {
String methodId1 = map1.get("com.actionsoft.apps.coe.method." + appId);
if (methodId1.equals(AppsConst.RUNTIME_STATE_STOPPED) || methodId1.equals(AppsConst.RUNTIME_STATE_FAILED) || methodId1.equals(AppsConst.RUNTIME_STATE_READY) || methodId1.equals(AppsConst.RUNTIME_STATE_STARTING) || methodId1.equals(AppsConst.RUNTIME_STATE_STOPPING) || methodId1.equals(AppsConst.RUNTIME_STATE_UNINSTALLED) || methodId1.equals(AppsConst.RUNTIME_STATE_UNINSTALLING) || methodId1.equals(AppsConst.RUNTIME_STATE_FAILED))
continue;
}
result.put(palMethodModel.getId(), I18nRes.findValue(CoEConstant.APP_ID, palMethodModel.getId()));
}
return result;
}
public static Set<String> getProcessMethodAttrNames(String wsId) {
Set<String> result = new HashSet<>();
List<PALMethodModel> methodIdList = PALMethodCache.getPALMethodModelListByMethod("process");
for (PALMethodModel methodModel : methodIdList) {
List<PALMethodAttributeModel> attributeModelList = PALRepositoryAPIManager.getInstance().getValidAttributeModels(wsId, methodModel.getId());
for (PALMethodAttributeModel attributeModel : attributeModelList) {
result.add(attributeModel.getNewTitle());
}
}
return result;
}
public static JSONObject getProcessMethodAttr(String wsId, String methodId) {
JSONObject result = new JSONObject();
List<PALMethodAttributeModel> attributeModelList = PALRepositoryAPIManager.getInstance().getValidAttributeModels(wsId, methodId);
for (PALMethodAttributeModel attributeModel : attributeModelList) {
JSONObject obj = new JSONObject();
obj.put("id", attributeModel.getKey());
obj.put("title", attributeModel.getNewTitle());
obj.put("type", attributeModel.getType());
obj.put("ref", attributeModel.getRef());
obj.put("groupPath", attributeModel.getGroupPath());
result.put(attributeModel.getNewTitle(), obj);
}
return result;
}
/**
* 获取流程更多特性配置信息
* @param methodId 流程分类
* @param attrId 属性key值
* @return
*/
public static JSONObject getProcessMethodAttr(String wsId, String methodId, String attrId) {
JSONObject result = new JSONObject();
List<PALMethodAttributeModel> attributeModelList = PALRepositoryAPIManager.getInstance().getValidAttributeModels(wsId, methodId);
for (PALMethodAttributeModel attributeModel : attributeModelList) {
if (attributeModel.getKey().equals(attrId)) {
result.put("id", attributeModel.getKey());
result.put("title", attributeModel.getNewTitle());
result.put("type", attributeModel.getType());
result.put("ref", attributeModel.getRef());
result.put("value", attributeModel.getValue());
result.put("groupPath", attributeModel.getGroupPath());
}
}
return result;
}
/**
*
* @param model
* @return
*/
public static boolean isView(PALRepositoryModel model) {
if (model.isPublish() || model.isApproval() || model.isStop()) {
return true;
}
return false;
}
/**
*
* @param model
* @return
*/
public static boolean isBlank(UserContext uc, PALRepositoryModel model) {
String define = PALRepositoryQueryAPIManager.getInstance().getProcessDefinition(uc, model.getId());
JSONObject array = JSONObject.parseObject(define);
if (array.containsKey("elements") && array.getJSONObject("elements").size() == 0) {
return true;
}
return false;
}
}

View File

@ -0,0 +1,279 @@
package com.actionsoft.apps.coe.pal.datamigration.util;
import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodAttributeModel;
import com.actionsoft.apps.coe.pal.pal.repository.designer.CoeDesignerShapeAPIManager;
import com.actionsoft.apps.coe.pal.pal.repository.designer.util.CoeDesignerUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import java.util.*;
public class ShapeUtil {
/**
* BPMN图并不全部使用给定范围
*/
private static List<String> bpmnShapeScope() {
List<String> list = new ArrayList<>();
list.add("startEvent");// 开始事件
list.add("messageStartEvent");// 消息开始事件
list.add("timerStartEvent");// 时间开始事件
list.add("signalStartEvent");// 信号开始事件
list.add("userTask");// 人工任务
list.add("serviceTask");// 服务任务
list.add("manualTask");// 手工任务
list.add("scriptTask");// 脚本任务
list.add("inclusiveGateway");// 包容网关
list.add("complexGateway");// 复杂网关
list.add("eventBasedGateway");// 事件网关
list.add("parallelGateway");// 并行网关
list.add("exclusiveGateway");// 排他网关
list.add("timerIntermediateCatchEvent");// 捕获时间事件
list.add("messageIntermediateCatchEvent");// 捕获消息事件
list.add("signalIntermediateCatchEvent");// 捕获信号事件
list.add("messageIntermediateThrowingEvent");// 抛出消息事件
list.add("signalIntermediateThrowingEvent");// 抛出信号事件
list.add("messageBoundaryInterrputingEvent");// 边界消息事件
list.add("signalBoundaryInterrputingEvent");// 边界信号事件
list.add("errorBoundaryInterrputingEvent");// 边界错误事件
list.add("endEvent");// 结束事件
list.add("terminateEndEvent");// 终止事件
list.add("messageEndEvent");// 消息结束事件
list.add("signalEndEvent");// 信号结束事件
list.add("errorEndEvent");// 错误结束事件
list.add("callActivityCallingProcess");// 调用子流程
list.add("group");//
// list.add("textAnnotation");// 注释
return list;
}
/**
* 获取流程类别下所有模型的形状title
* @return
*/
public static Map<String, List<String>> getProcessShapeTitles() {
Map<String, List<String>> result = new HashMap<>();
// 获取流程类别下所有的模型分类
List<String> methods = ProcessUtil.getProcessCategoryCategoryMehtodList();
for (String methodId : methods) {
List<String> list = new ArrayList<>();
JSONArray shapes = CoeDesignerUtil.getShapeDefinition(methodId);
for (Object shape : shapes) {
JSONObject shapeObj = (JSONObject) shape;
if (shapeObj.containsKey("title")) {
if (methodId.contains("bpmn")) {
if (bpmnShapeScope().contains(shapeObj.getString("name"))) {
list.add(shapeObj.getString("title"));
}
} else {
list.add(shapeObj.getString("title"));
}
}
}
result.put(methodId, list);
}
return result;
}
public static List<String> getProcessShapeTypeList(String methodId) {
List<String> result = new ArrayList<>();
JSONArray shapes = CoeDesignerUtil.getShapeDefinition(methodId);
for (Object shape : shapes) {
JSONObject shapeObj = (JSONObject) shape;
if (shapeObj.containsKey("title")) {
if (methodId.contains("bpmn")) {
if (bpmnShapeScope().contains(shapeObj.getString("name"))) {
result.add(shapeObj.getString("title"));
}
} else {
result.add(shapeObj.getString("title"));
}
}
}
return result;
}
public static JSONArray getProcessShapeTypeArr(String methodId) {
JSONArray result = new JSONArray();
JSONArray shapes = CoeDesignerUtil.getShapeDefinition(methodId);
for (Object shape : shapes) {
JSONObject shapeObj = (JSONObject) shape;
if (shapeObj.containsKey("title")) {
if (methodId.contains("bpmn")) {
if (bpmnShapeScope().contains(shapeObj.getString("name"))) {
result.add(shapeObj.getString("title"));
}
} else {
result.add(shapeObj.getString("title"));
}
}
}
return result;
}
public static Set<String> getProcessMethodAttrNames(String wsId, String methodId) {
Set<String> result = new HashSet<>();
List<PALMethodAttributeModel> attributeModelList = CoeDesignerShapeAPIManager.getInstance().getAllValidShapeAttributeModels(wsId, methodId);
for (PALMethodAttributeModel attributeModel : attributeModelList) {
result.add(attributeModel.getNewTitle());
}
return result;
}
public static String getProcessShapeName(String methodId, String shapeTitle) {
JSONArray shapes = CoeDesignerUtil.getShapeDefinition(methodId);
for (Object shape : shapes) {
JSONObject shapeObj = (JSONObject) shape;
if (shapeObj.containsKey("title")) {
if (methodId.contains("bpmn")) {
if (bpmnShapeScope().contains(shapeObj.getString("name")) && shapeObj.getString("title").equals(shapeTitle)) {
return shapeObj.getString("name");
}
} else {
if (shapeObj.getString("title").equals(shapeTitle)) {
return shapeObj.getString("name");
}
}
}
}
return null;
}
/**
* 获取流程节点定义
* @param methodId 类型
* @param shapeTitle 节点默认标题
* @return
*/
public static JSONObject getProcessShapeDefinition(String methodId, String shapeTitle) {
JSONArray shapes = CoeDesignerUtil.getShapeDefinition(methodId);
for (Object shape : shapes) {
JSONObject shapeObj = (JSONObject) shape;
if (shapeObj.containsKey("title")) {
if (methodId.contains("bpmn")) {
if (bpmnShapeScope().contains(shapeObj.getString("name")) && shapeObj.getString("title").equals(shapeTitle)) {
return shapeObj;
}
} else {
if (shapeObj.getString("title").equals(shapeTitle)) {
return shapeObj;
}
}
}
}
return null;
}
/**
* 获取流程节点定义
* @param methodId 类型
* @param shapeName 节点类型
* @return
*/
public static JSONObject getProcessShapeDefinitionByName(String methodId, String shapeName) {
JSONArray shapes = CoeDesignerUtil.getShapeDefinition(methodId);
for (Object shape : shapes) {
JSONObject shapeObj = (JSONObject) shape;
if (shapeObj.containsKey("name")) {
String name = shapeObj.getString("name");
if (methodId.contains("bpmn")) {
if (bpmnShapeScope().contains(shapeObj.getString("name")) && name.equals(shapeName)) {
return shapeObj;
}
} else {
if (name.equals(shapeName)) {
return shapeObj;
}
}
}
}
return null;
}
/**
* 具体流程类别下的扩展属性列表
* @param methodId
* @return
*/
public static JSONObject getProcessUseShapeMethodAttrByShapeName(String wsId, String shapeMethod, String methodId, String shapeName) {
JSONObject result = new JSONObject();
List<PALMethodAttributeModel> attributeModelList = CoeDesignerShapeAPIManager.getInstance().getValidAndUseAttributeModels(wsId, shapeMethod, shapeName, methodId);
for (PALMethodAttributeModel attributeModel : attributeModelList) {
String scope = attributeModel.getScope();
if (scope.contains("*") || "*".equals(scope) || scope.contains(shapeName)) {
JSONObject obj = new JSONObject();
obj.put("readonly", attributeModel.getReadonly());
obj.put("id", attributeModel.getKey());
obj.put("key", attributeModel.getKey());
obj.put("scope", attributeModel.getScope());
obj.put("name", attributeModel.getTitle());
obj.put("title", attributeModel.getNewTitle());
obj.put("type", attributeModel.getType());
obj.put("ref", attributeModel.getRef());
obj.put("groupPath", attributeModel.getGroupPath());
result.put(attributeModel.getKey(), obj);
}
}
return result;
}
/**
* 具体流程类别下的扩展属性列表
* @param methodId
* @return
*/
public static JSONObject getProcessShapeMethodAttr(String wsId, String methodId, String shapeTitle) {
JSONObject result = new JSONObject();
// 获取图形名称的
String shapeName = getProcessShapeName(methodId, shapeTitle);
if (shapeName == null) {
return result;
}
List<PALMethodAttributeModel> attributeModelList = CoeDesignerShapeAPIManager.getInstance().getAllValidShapeAttributeModels(wsId, methodId);
for (PALMethodAttributeModel attributeModel : attributeModelList) {
String scope = attributeModel.getScope();
if (scope.contains("*") || "*".equals(scope) || scope.contains(shapeName)) {
JSONObject obj = new JSONObject();
obj.put("readonly", attributeModel.getReadonly());
obj.put("id", attributeModel.getKey());
obj.put("key", attributeModel.getKey());
obj.put("scope", attributeModel.getScope());
obj.put("name", attributeModel.getTitle());
obj.put("title", attributeModel.getNewTitle());
obj.put("type", attributeModel.getType());
obj.put("ref", attributeModel.getRef());
obj.put("groupPath", attributeModel.getGroupPath());
result.put(attributeModel.getNewTitle(), obj);
}
}
return result;
}
/**
* 具体流程类别下的扩展属性列表
* @param methodId
* @return
*/
public static JSONObject getProcessShapeMethodAttrById(String wsId, String methodId, String attrId) {
JSONObject result = new JSONObject();
List<PALMethodAttributeModel> attributeModelList = CoeDesignerShapeAPIManager.getInstance().getAllValidShapeAttributeModels(wsId, methodId);
for (PALMethodAttributeModel attributeModel : attributeModelList) {
if (attrId.equals(attributeModel.getKey())) {
result.put("readonly", attributeModel.getReadonly());
result.put("pid", attributeModel.getGroupPath());
result.put("id", attributeModel.getKey());
result.put("key", attributeModel.getKey());
result.put("scope", attributeModel.getScope());
result.put("name", attributeModel.getTitle());
result.put("title", attributeModel.getNewTitle());
result.put("type", attributeModel.getType());
result.put("ref", attributeModel.getRef());
result.put("value", attributeModel.getValue());
result.put("groupPath", attributeModel.getGroupPath());
}
}
return result;
}
}

View File

@ -0,0 +1,488 @@
package com.actionsoft.apps.coe.pal.datamigration.util;
import com.actionsoft.apps.coe.pal.datamigration.constant.Constant;
import com.actionsoft.apps.coe.pal.datamigration.model.po.WordAttribute;
import com.actionsoft.apps.coe.pal.datamigration.model.po.WordField;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.usermodel.*;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.*;
public class WordUtil {
/**
* 文档版本号
*/
private String version = "";
/**
* 流程文件名称
*/
private String fileName = "";
/**
* 流程文件编码
*/
private String fileNo = "";
/**
* 文档新旧标志
*/
private boolean isOldVersion = false;
/**
* 待分析的标题
*/
private static Map<String,WordAttribute> wordAttributeMap = new HashMap<>();
private static Map<String,WordAttribute> oldWordAttributeMap = new HashMap<>();
private Map<String,String> oldWordMapping = new HashMap<>();
/**
* 分析结果集
*/
private Map<String, WordField<Object>> fileFieldMap = new HashMap<>();
static {
List<WordAttribute> wordAttributes = JSON.parseArray(Constant.WORDIMPORT,WordAttribute.class);
List<WordAttribute> oldwordAttributes = JSON.parseArray(Constant.OLDWORDIMPORT,WordAttribute.class);
wordAttributes.forEach(wordAttribute -> {
wordAttributeMap.put(wordAttribute.getTitle(),wordAttribute);
});
oldwordAttributes.forEach(wordAttribute -> {
oldWordAttributeMap.put(wordAttribute.getTitle(),wordAttribute);
});
}
{
JSONArray oldwordMapping = JSON.parseArray(Constant.OLDWORDMAPPING);
for (Object obj : oldwordMapping) {
JSONObject object = (JSONObject) obj;
oldWordMapping.put(object.getString("key"),object.getString("value"));
}
}
public WordUtil() { }
public boolean analysisWordTable(String filePath){
try {
HWPFDocument doc = new HWPFDocument(new FileInputStream(filePath));
Range range = doc.getRange();
for (int i =0;i<range.numParagraphs();i++){
Paragraph paragraph = range.getParagraph(i);
String text = paragraph.text();
if (StringUtils.isEmpty(text)||"\r".equals(text)){
continue;
}
//获取文件编码
if (text.contains("文件编码") && fileFieldMap.get("文件编码") == null){
this.fileNo = this.getFileNo(text);
this.isOldVersion = this.isOldVersion(this.fileNo);
fileFieldMap.put("文件编码",new WordField<>(this.fileNo));
}
//获取文件名称
if (StringUtils.isEmpty(this.fileName) && this.isTitle(paragraph)){
this.fileName = text.trim();
}
if (this.isOldVersion){
//旧版本文档
AnalysisStrategyContext strategyContext = new AnalysisStrategyContext();
if (this.isTitle(paragraph)){
//文件标题下解析后续table
AnalysisStrategy titleField = strategyContext.getStrategy("VerticalFeild");
Map<String, WordField<Object>> analysis = titleField.analysis(doc, i);
fileFieldMap.putAll(analysis);
}
WordAttribute wordAttribute = oldWordAttributeMap.get(text.trim());
if (null == wordAttribute){
continue;
}
AnalysisStrategy strategy = strategyContext.getStrategy(wordAttribute.getType());
Map<String, WordField<Object>> analysis = strategy.analysis(doc, i);
fileFieldMap.putAll(analysis);
}else {
WordAttribute wordAttribute = wordAttributeMap.get(text.trim());
if (null == wordAttribute){
continue;
}
AnalysisStrategy strategy = new AnalysisStrategyContext().getStrategy(wordAttribute.getType());
Map<String, WordField<Object>> analysis = strategy.analysis(doc,i);
fileFieldMap.putAll(analysis);
}
}
} catch (IOException e) {
e.printStackTrace();
return false;
}
return true;
}
private String getFileNo(String text){
if (StringUtils.isEmpty(text)){
return "";
}
int index = text.indexOf("");
return text.substring(index + 1);
}
private boolean isOldVersion(String fileNo){
return fileNo.startsWith("YL");
}
/**
* 判断是否为文档标题
* 标志黑体一号
* @param paragraph
* @return
*/
private boolean isTitle(Paragraph paragraph){
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("黑体")){
//与文档fontsize标号2倍关系 黑体一号 等于 26号size
return characterRun.isBold() && characterRun.getFontSize() == 52;
}
}
return false;
}
public Paragraph findNextInTableParagragh(Range range, int index){
if (index + 1 > range.numParagraphs()-1){
return null;
}
int i = index+1;
Paragraph paragraph = range.getParagraph(i);
if (paragraph.isInTable()){
return paragraph;
}
return this.findNextInTableParagragh(range,i);
}
/**
* 获取标题下属全部段落信息
* @param doc
* @param range
* @param index
* @return
*/
public String getRecursionSubText(HWPFDocument doc,Range range,int index){
StringBuffer buffer = new StringBuffer();
if (index + 1 > range.numParagraphs()-1){
return buffer.toString();
}
index = index+1;
Paragraph paragraph = range.getParagraph(index);
short styleIndex = paragraph.getStyleIndex();
String description = doc.getStyleSheet().getStyleDescription(styleIndex).getName();
if (description.contains("标题")){
return "";
}
String text = paragraph.text();
//去除text特殊符号
if (null != text && !"".equals(text)) {
text = text.replaceAll("\\p{C}", "");
}
buffer.append(text+"\n");
String recursionSubText = getRecursionSubText(doc, range, index);
buffer.append(recursionSubText);
return buffer.toString();
}
public Map<String, List<String>> getHorizontalTableMapText(Table tb) {
Map<String, List<String>> result = new HashMap<>(16);
//迭代行默认从0开始,可以依据需要设置i的值,改变起始行数也可设置读取到那行只需修改循环的判断条件即可
for (int i = 0; i < tb.numRows(); i++) {
List<String> list = new ArrayList<>(16);
int x = 0;
TableRow tr = tb.getRow(i);
String key = null;
//迭代列默认从0开始
for (int j = 0; j < tr.numCells(); j++) {
//取得单元格
TableCell td = tr.getCell(j);
String text = td.text();
if (x == 0) {
key = text.replace(" ","").trim();
} else {
String value = text.trim();
list.add(value == null || Objects.deepEquals(value, "") ? null : value.replace(",", ""));
}
x++;
}
result.put(key, list);
}
return result;
}
public List<List<String>> getHorizontalTableText(Table table){
List<List<String>> list = new ArrayList<>();
for (int i=0;i<table.numRows();i++){
List<String> rowList = new ArrayList<>();
TableRow row = table.getRow(i);
for (int j=0;j<row.numCells();j++){
TableCell cell = row.getCell(j);
String text = cell.text().trim();
//去除text特殊符号
if (null != text && !"".equals(text)) {
text = text.replaceAll("\\p{C}", "");
}
text.replace(" ","");
rowList.add(text);
}
list.add(rowList);
}
return list;
}
public Map<String, List<String>> getVerticalTableText(Table table){
Map<String, List<String>> result = new HashMap<>();
List<String> stringList = new ArrayList<>();
for (int i=0;i<table.numRows();i++){
TableRow row = table.getRow(i);
for (int j=0;j<row.numCells();j++){
TableCell cell = row.getCell(j);
String text = cell.text().trim();
//去除text特殊符号
if (null != text && !"".equals(text)) {
text = text.replaceAll("\\p{C}", "");
}
text.replace(" ","");
if (i == 0){
//首行为标题行
result.put(text,new ArrayList<>());
stringList.add(text);
}else {
result.get(stringList.get(j)).add(text);
}
}
}
return result;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public boolean getIsOldVersion() {
return isOldVersion;
}
public Map<String, WordField<Object>> getFileFieldMap() {
return fileFieldMap;
}
public Map<String, String> getOldWordMapping() {
return oldWordMapping;
}
class AnalysisStrategyContext {
private Map<String,AnalysisStrategy> map = new HashMap<>();
{
map.put("DirectFeild",new DirectFeildStrategy());
map.put("VerticalFeild",new VerticalFeildStrategy());
map.put("Table",new TableStrategy());
map.put("FileTable",new FileTableStrategy());
map.put("Text",new TextStrategy());
}
public AnalysisStrategy getStrategy(String key){
return map.get(key)==null ? null : map.get(key);
}
}
interface AnalysisStrategy {
Map<String, WordField<Object>> analysis(HWPFDocument doc,int index);
}
class DirectFeildStrategy implements AnalysisStrategy{
@Override
public Map<String, WordField<Object>> analysis(HWPFDocument doc,int index) {
Map<String, WordField<Object>> result = new HashMap<>();
WordUtil wordUtil = new WordUtil();
Range range = doc.getRange();
Paragraph paragraph = wordUtil.findNextInTableParagragh(range, index);
if (null == paragraph){
return result;
}
//标题后续直接为table
if (paragraph.isInTable()){
Table table = range.getTable(paragraph);
Map<String, List<String>> tabelDocText = wordUtil.getHorizontalTableMapText(table);
//结果集放入
tabelDocText.keySet().forEach(key->{
List<String> strings = tabelDocText.get(key);
//版本号特殊处理
if (key.equals("版本")){
version = strings.get(0);
}
if (!strings.isEmpty()){
result.put(key,new WordField<>(strings.get(0)));
}
});
}
return result;
}
}
class VerticalFeildStrategy implements AnalysisStrategy{
@Override
public Map<String, WordField<Object>> analysis(HWPFDocument doc, int index) {
Map<String, WordField<Object>> result = new HashMap<>();
WordUtil wordUtil = new WordUtil();
Range range = doc.getRange();
Paragraph paragraph = wordUtil.findNextInTableParagragh(range, index);
if (null == paragraph){
return result;
}
if (paragraph.isInTable()){
Table table = range.getTable(paragraph);
Map<String, List<String>> verticalTableText = wordUtil.getVerticalTableText(table);
if (verticalTableText.values().isEmpty()){
return result;
}
//将结果放入结果集中
for (String key : verticalTableText.keySet()) {
List<String> values = verticalTableText.get(key);
if (values.size() <= 1){
result.put(key,new WordField<>(values.get(0)));
}else {
result.put(key,new WordField<>(values));
}
}
//修改记录中版本特殊处理
if (verticalTableText.containsKey("版本")){
List<String> strings = verticalTableText.get("版本");
int subIndex = 0;
for (int j=0;j<strings.size();j++){
String s = strings.get(j);
if (s.equals(version)){
subIndex = j;
}
}
for (String key : verticalTableText.keySet()) {
List<String> values = verticalTableText.get(key);
result.put(key,new WordField<>(values.get(subIndex)));
}
}
}
return result;
}
}
class TableStrategy implements AnalysisStrategy{
@Override
public Map<String, WordField<Object>> analysis(HWPFDocument doc, int index) {
Map<String, WordField<Object>> result = new HashMap<>();
WordUtil wordUtil = new WordUtil();
Range range = doc.getRange();
Paragraph titleParagragh = range.getParagraph(index);
Paragraph paragraph = wordUtil.findNextInTableParagragh(range, index);
if (null == paragraph){
return result;
}
if (paragraph.isInTable()){
Table table = range.getTable(paragraph);
List<List<String>> horizontalTableText = wordUtil.getHorizontalTableText(table);
result.put(titleParagragh.text().trim(),new WordField<>(horizontalTableText));
}
return result;
}
}
class FileTableStrategy implements AnalysisStrategy{
@Override
public Map<String, WordField<Object>> analysis(HWPFDocument doc, int index) {
Map<String, WordField<Object>> result = new HashMap<>();
WordUtil wordUtil = new WordUtil();
Range range = doc.getRange();
Paragraph titleParagragh = range.getParagraph(index);
Paragraph paragraph = wordUtil.findNextInTableParagragh(range, index);
if (null == paragraph){
return result;
}
if (paragraph.isInTable()){
Table table = range.getTable(paragraph);
Map<String, List<String>> verticalTableText = wordUtil.getVerticalTableText(table);
List<String> strings = verticalTableText.get("文件名称");
result.put(titleParagragh.text().trim(),new WordField<>(strings));
}
return result;
}
}
class TextStrategy implements AnalysisStrategy{
@Override
public Map<String, WordField<Object>> analysis(HWPFDocument doc, int index) {
Map<String, WordField<Object>> result = new HashMap<>();
WordUtil wordUtil = new WordUtil();
Range range = doc.getRange();
Paragraph titleParagragh = range.getParagraph(index);
//获取标题下所有段落文字直至下一个标题
String recursionSubText = wordUtil.getRecursionSubText(doc, range, index);
result.put(titleParagragh.text().trim(),new WordField<>(recursionSubText));
return result;
}
}
}

View File

@ -0,0 +1,33 @@
<!DOCTYPE html>
<html lang="en">
<head>
<script>
if(window.navigator.userAgent.indexOf('MSIE') > -1 || window.navigator.userAgent.indexOf('Trident') > -1){
window.location.replace("../not_support_vue.htm");
}
</script>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="../apps/com.actionsoft.apps.coe.pal.datamigration/main/favicon.ico" />
<title></title>
<link type='text/css' rel='stylesheet' href='../commons/css/font/iconfont.css'/>
<!--
其它的js或css引用方式示例<%= htmlWebpackPlugin.options.awsjsandcsspath%>
<link rel="stylesheet" type="text/css" href="<%= htmlWebpackPlugin.options.awsjsandcsspath%>apps/_bpm.platform/css/model/console.m.dw.design.css"/>
-->
<script>
const settingParam = <#settingParam>;
const axiosBaseUrl = "./";
const production = true;
const devUserInfo = {};
</script>
<script type="module" crossorigin src="../apps/com.actionsoft.apps.coe.pal.datamigration/main/js/entry-index-f11ffa5c.js"></script>
<link rel="stylesheet" href="../apps/com.actionsoft.apps.coe.pal.datamigration/main/assets/asset-style-6cf72a9c.css">
</head>
<body style="margin:0;">
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<aws-actions>
<cmd-bean name="com.actionsoft.apps.coe.pal.datamigration_data_migrate">
<param name="wsId"/>
<param name="groupValue"/>
<param name="fileValue"/>
<param name="fileName"/>
</cmd-bean>
<cmd-bean name="com.actionsoft.apps.coe.pal.datamigration_process_attribute_import">
<param name="wsId"/>
<param name="groupValue"/>
<param name="fileValue"/>
<param name="fileName"/>
</cmd-bean>
<cmd-bean name="com.actionsoft.apps.coe.pal.datamigration_IT_attribute_import">
<param name="wsId"/>
<param name="groupValue"/>
<param name="fileValue"/>
<param name="fileName"/>
</cmd-bean>
</aws-actions>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB