Aris流程数据迁移日志记录处理
This commit is contained in:
parent
9224351aaa
commit
bdddcbeef2
Binary file not shown.
@ -1,5 +1,6 @@
|
||||
package com.actionsoft.apps.coe.pal.datamigration;
|
||||
|
||||
import com.actionsoft.apps.coe.pal.datamigration.aris.web.ArisXmlImportWeb;
|
||||
import com.actionsoft.apps.coe.pal.datamigration.util.readword.ReadWordUtil;
|
||||
import com.actionsoft.apps.coe.pal.datamigration.web.DataMigrationWeb;
|
||||
import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
|
||||
@ -48,4 +49,31 @@ public class DataMigrationController {
|
||||
ResponseObject ro = ResponseObject.newOkResponse();
|
||||
return ro.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询aris流程导入日志
|
||||
* @param uc
|
||||
* @param logId
|
||||
* @param path
|
||||
* @param timer
|
||||
* @return
|
||||
*/
|
||||
@Mapping("com.actionsoft.apps.coe.pal.datamigration_data_migrate_log_query")
|
||||
public String queryArisXmlImportLog(UserContext uc, String logId, String path, String timer) {
|
||||
ArisXmlImportWeb web = new ArisXmlImportWeb(uc);
|
||||
return web.queryArisXmlImportLog(logId, path, timer);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载日志
|
||||
* @param uc
|
||||
* @param logId
|
||||
* @param path
|
||||
* @return
|
||||
*/
|
||||
@Mapping("com.actionsoft.apps.coe.pal.datamigration_data_migrate_log_download")
|
||||
public String downloadArisXmlImportLog(UserContext uc, String logId, String path) {
|
||||
ArisXmlImportWeb web = new ArisXmlImportWeb(uc);
|
||||
return web.downloadArisXmlImportLog(logId, path);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,9 +4,11 @@ public class ArisConstant {
|
||||
|
||||
public final static String REPOSITORY_NAME = "arisXML";// aris xml文件导入dc根目录
|
||||
|
||||
public final static String UPFILE = "upfile";// aris xml文件上传根目录,在REPOSITORY_NAME之下
|
||||
public final static String GROUP_VALUE_UPFILE = "upfile";// aris xml文件上传根目录,在REPOSITORY_NAME之下
|
||||
|
||||
public final static String LOG_GROUP_VALUE = "log";// aris xml文件导入日志根目录,在REPOSITORY_NAME之下
|
||||
public final static String GROUP_VALUE_LOG = "log";// aris xml文件导入日志根目录,在REPOSITORY_NAME之下
|
||||
|
||||
public final static String GROUP_VALUE_DOWNLOAD = "download";
|
||||
|
||||
public final static String IMPORT_LOG_FILE_SIMPLE = "simpleImport.log";// 简要日志,展示给前端,体现大致的导入内容和进度
|
||||
public final static String IMPORT_LOG_FILE_FULL = "fullImport.log";// 详细日志,包括全量信息内容
|
||||
|
||||
@ -128,15 +128,15 @@ public class ArisXmlImportRun {
|
||||
});
|
||||
|
||||
String arisRootPath = "\\伊利集团业务流程管理平台";
|
||||
int totalArisCount = LogRealTimeCountCache.getCache().get(logId).getTotalCount();
|
||||
int totalCount = LogRealTimeCountCache.getCache().get(logId).getTotalCount();
|
||||
for (int i = 0; i < arisEpcModelList.size(); i++) {
|
||||
ModelModel arisModel = arisEpcModelList.get(i);
|
||||
String arisPath = arisRootPath + arisModel.getModelPath();
|
||||
int importingCount = i + 1;// 当前是导入的第几个
|
||||
LogRealTimeCountCache.getCache().get(logId).setImportingCount(importingCount);// 当前记录缓存
|
||||
// 当前正在导入的流程全部日志记录,方便对照
|
||||
// LogUtil.appendLog("************-----[" + importingCount + "/" + totalArisCount + "]************-----", simpleLogFile, fullLogFile, warnLogFile);
|
||||
LogUtil.appendLog("\n************[执行进度]当前执行第[" + importingCount + "]条,共["+ totalArisCount +"]条************", simpleLogFile, fullLogFile, warnLogFile);
|
||||
// LogUtil.appendLog("************-----[" + importingCount + "/" + totalCount + "]************-----", simpleLogFile, fullLogFile, warnLogFile);
|
||||
LogUtil.appendLog("\n************[执行进度]当前执行第[" + importingCount + "]条,共["+ totalCount +"]条************", simpleLogFile, fullLogFile, warnLogFile);
|
||||
|
||||
LogUtil.appendLog("\n" + Constant.LOG_START + "************[执行阶段][流程匹配阶段]PAL过程链图与ARIS流程进行匹配************", simpleLogFile, fullLogFile);
|
||||
|
||||
@ -292,9 +292,7 @@ public class ArisXmlImportRun {
|
||||
// 保存文件
|
||||
CoeDesignerAPIManager.getInstance().storeDefinition(defineModel);// dao操作
|
||||
|
||||
// 记录结束日志
|
||||
endTime = System.currentTimeMillis();
|
||||
Timestamp endDate = new Timestamp(System.currentTimeMillis());
|
||||
// 记录流程导入结束日志
|
||||
LogRealTimeCountCache.getCache().get(logId).setSuccessCount(LogRealTimeCountCache.getCache().get(logId).getSuccessCount() + 1);
|
||||
LogUtil.appendLog(Constant.LOG_END + "保存PAL过程链图[" + palModel.getName() + "]的形状和连线", simpleLogFile, fullLogFile);
|
||||
|
||||
@ -302,7 +300,8 @@ public class ArisXmlImportRun {
|
||||
|
||||
LogUtil.appendLog("\n" + Constant.LOG_END + "导入ARIS流程" + "[" + arisModel.getName() + "]", simpleLogFile, fullLogFile, warnLogFile);
|
||||
}
|
||||
Timestamp endDate = new Timestamp(System.currentTimeMillis());
|
||||
endTime = System.currentTimeMillis();
|
||||
Timestamp endDate = new Timestamp(endTime);
|
||||
LogRealTimeCountModel model = LogRealTimeCountCache.getCache().get(logId);
|
||||
String takeTimeText = takeTime(endTime, startTime);
|
||||
String resultMsg = "导入完成,总耗时" + takeTimeText + ",ArisXML流程总共[" + model.getTotalCount() + "],导入成功[" + model.getSuccessCount() + "]条,导入失败[" + (model.getTotalCount() - model.getSuccessCount())
|
||||
@ -317,7 +316,7 @@ public class ArisXmlImportRun {
|
||||
e.printStackTrace();
|
||||
// 记录结束日志
|
||||
endTime = System.currentTimeMillis();
|
||||
Timestamp endDate = new Timestamp(System.currentTimeMillis());
|
||||
Timestamp endDate = new Timestamp(endTime);
|
||||
LogRealTimeCountModel model = LogRealTimeCountCache.getCache().get(logId);
|
||||
String takeTimeText = takeTime(endTime, startTime);
|
||||
String resultMsg = "导入失败,报错信息:" + e.getMessage() + ",总耗时" + takeTimeText + ",导入成功[" + model.getSuccessCount() + "]条,导入失败[" + (model.getTotalCount() - model.getSuccessCount())
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.actionsoft.apps.coe.pal.datamigration.aris.web;
|
||||
|
||||
import com.actionsoft.apps.coe.pal.batch.cache.BatchCache;
|
||||
import com.actionsoft.apps.coe.pal.constant.CoEConstant;
|
||||
import com.actionsoft.apps.coe.pal.datamigration.aris.constant.ArisConstant;
|
||||
import com.actionsoft.apps.coe.pal.datamigration.aris.model.*;
|
||||
@ -22,15 +23,18 @@ import com.actionsoft.bpms.server.fs.DCContext;
|
||||
import com.actionsoft.bpms.server.fs.dc.DCProfileManager;
|
||||
import com.actionsoft.bpms.util.UUIDGener;
|
||||
import com.actionsoft.bpms.util.UtilDate;
|
||||
import com.actionsoft.bpms.util.UtilFile;
|
||||
import com.actionsoft.bpms.util.UtilString;
|
||||
import com.actionsoft.i18n.I18nRes;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import okhttp3.Response;
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.DocumentException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
@ -39,9 +43,6 @@ public class ArisXmlImportWeb extends ActionWeb {
|
||||
|
||||
UserContext _uc;
|
||||
|
||||
public ArisXmlImportWeb() {
|
||||
}
|
||||
|
||||
public ArisXmlImportWeb(UserContext uc) {
|
||||
_uc = uc;
|
||||
}
|
||||
@ -63,7 +64,7 @@ public class ArisXmlImportWeb extends ActionWeb {
|
||||
String fileValue = "arisXML-" + new SimpleDateFormat("yyyy-MM-dd-HHmmss").format(new Date()) + "-" + _uc.getUID();
|
||||
// 创建dc目录
|
||||
DCPluginProfile dcProfile = DCProfileManager.getDCProfile(Constant.APP_ID, ArisConstant.REPOSITORY_NAME);
|
||||
DCContext dc = new DCContext(_uc, dcProfile, Constant.APP_ID, ArisConstant.LOG_GROUP_VALUE, fileValue);
|
||||
DCContext dc = new DCContext(_uc, dcProfile, Constant.APP_ID, ArisConstant.GROUP_VALUE_LOG, fileValue);
|
||||
String dirPath = dc.getPath();
|
||||
File dir = new File(dirPath);
|
||||
dir.mkdirs();
|
||||
@ -136,16 +137,21 @@ public class ArisXmlImportWeb extends ActionWeb {
|
||||
* @return
|
||||
*/
|
||||
public String dataMigrate(String wsId, String groupValue, String fileValue, String fileName) {
|
||||
ResponseObject ro = ResponseObject.newOkResponse();
|
||||
// 初始化一些参数
|
||||
initParams();
|
||||
// 读取dc
|
||||
DCPluginProfile dcProfile = DCProfileManager.getDCProfile(Constant.APP_ID, "migration");// repositoryName要调整新的路径,配合前端, todo
|
||||
DCPluginProfile dcProfile = DCProfileManager.getDCProfile(Constant.APP_ID, ArisConstant.REPOSITORY_NAME);// repositoryName要调整新的路径,配合前端, todo
|
||||
DCContext dc = new DCContext(_uc, dcProfile, Constant.APP_ID, groupValue, fileValue, fileName);
|
||||
this.fileName = fileName;
|
||||
this.filePath = dc.getFilePath();
|
||||
Timestamp startDate = new Timestamp(startTime);
|
||||
// 创建日志信息db
|
||||
createLogModel(logId, wsId, fileName, filePath, startDate);
|
||||
ro.put("logId", logId);
|
||||
ro.put("path", logPath);
|
||||
ro.put("resultStatus", LogUtil.queryLog(logId).getResultStatus());
|
||||
|
||||
LogUtil.appendLog("注:该日志文件存储简要日志信息", simpleLogFile);
|
||||
LogUtil.appendLog("注:该日志文件存储详细日志信息", fullLogFile);
|
||||
LogUtil.appendLog("注:该日志文件记录警告、出错日志信息", warnLogFile);
|
||||
@ -164,28 +170,32 @@ public class ArisXmlImportWeb extends ActionWeb {
|
||||
if (!isActive) {
|
||||
msg = Constant.LOG_ERROR + "资产库不存在或已停用," + Constant.IMPORT_STOP_MSG;
|
||||
updateErrLog(msg, msg);
|
||||
return ResponseObject.newErrResponse("资产库不存在或已停用").toString();
|
||||
ro.err("资产库不存在或已停用");
|
||||
return ro.toString();
|
||||
}
|
||||
LogUtil.appendLog(Constant.LOG_END + "校验资产库存在并可用", simpleLogFile, fullLogFile);
|
||||
|
||||
// 校验文件/形状属性配置是否正常
|
||||
ResponseObject checkRo = checkMethodConfig(wsId);
|
||||
if (checkRo.isErr()) {
|
||||
return checkRo.toString();
|
||||
ro.err(checkRo.getMsg());
|
||||
return ro.toString();
|
||||
}
|
||||
// 校验文件是否存在
|
||||
File file = new File(dc.getFilePath());
|
||||
if (!file.exists()) {
|
||||
msg = Constant.LOG_ERROR + "上传文件不存在," + Constant.IMPORT_STOP_MSG;
|
||||
updateErrLog(msg, msg);
|
||||
return ResponseObject.newErrResponse("上传文件不存在").toString();
|
||||
ro.err("上传文件不存在");
|
||||
return ro.toString();
|
||||
}
|
||||
LogUtil.appendLog(Constant.LOG_END + "校验上传文件是否存在", simpleLogFile, fullLogFile);
|
||||
|
||||
if (!".xml".equals(fileName.substring(fileName.lastIndexOf(".")))) {
|
||||
msg = Constant.LOG_ERROR + "上传文件名称格式不正确," + Constant.IMPORT_STOP_MSG;
|
||||
updateErrLog(msg, msg);
|
||||
return ResponseObject.newErrResponse("上传文件名称格式不正确,请上传XML文件").toString();
|
||||
ro.err("上传文件名称格式不正确,请上传XML文件");
|
||||
return ro.toString();
|
||||
}
|
||||
LogUtil.appendLog(Constant.LOG_END + "校验上传文件是否为XML格式", simpleLogFile, fullLogFile);
|
||||
|
||||
@ -197,7 +207,8 @@ public class ArisXmlImportWeb extends ActionWeb {
|
||||
if (doc == null) {
|
||||
msg = Constant.LOG_ERROR + "解析XML文件结构," + Constant.IMPORT_STOP_MSG;
|
||||
updateErrLog(msg, msg);
|
||||
return ResponseObject.newErrResponse("解析XML文件错误,详情见日志").toString();
|
||||
ro.err("解析XML文件错误,详情见日志");
|
||||
return ro.toString();
|
||||
}
|
||||
LogUtil.appendLog(Constant.LOG_END + "解析XML文件结构", simpleLogFile, fullLogFile);
|
||||
ArisXmlHandleWeb handleWeb = new ArisXmlHandleWeb();
|
||||
@ -208,19 +219,22 @@ public class ArisXmlImportWeb extends ActionWeb {
|
||||
e.printStackTrace();
|
||||
msg = Constant.LOG_ERROR + "解析XML文件内容异常,异常信息:" + e.getMessage() + "," + Constant.IMPORT_STOP_MSG;
|
||||
updateErrLog(msg, msg);
|
||||
ro.err("解析XML文件内容异常");
|
||||
return ro.toString();
|
||||
}
|
||||
LogUtil.appendLog(Constant.LOG_END + "解析XML文件内容", simpleLogFile, fullLogFile);
|
||||
|
||||
// 统计epc流程图的个数,用以进度展示
|
||||
int totalEpcCount = countProcessMainInfo(handleWeb.modelMap);
|
||||
if (totalEpcCount == 0) {
|
||||
int totalCount = countProcessMainInfo(handleWeb.modelMap);
|
||||
if (totalCount == 0) {
|
||||
msg = Constant.LOG_ERROR + "上传文件不包含任何" + I18nRes.findValue(CoEConstant.APP_ID, Constant.PROCESS_EPC) + "," + Constant.IMPORT_STOP_MSG;
|
||||
updateErrLog(msg, msg);
|
||||
return ResponseObject.newErrResponse("上传文件不包含任何" + I18nRes.findValue(CoEConstant.APP_ID, Constant.PROCESS_EPC)).toString();
|
||||
ro.err("上传文件不包含任何" + I18nRes.findValue(CoEConstant.APP_ID, Constant.PROCESS_EPC));
|
||||
return ro.toString();
|
||||
}
|
||||
// 存储缓存,导入计数
|
||||
LogRealTimeCountModel countModel = new LogRealTimeCountModel();
|
||||
countModel.setTotalCount(totalEpcCount);
|
||||
countModel.setTotalCount(totalCount);
|
||||
countModel.setSuccessCount(0);
|
||||
countModel.setArisBlankCount(0);
|
||||
countModel.setPalExistsCount(0);
|
||||
@ -230,14 +244,12 @@ public class ArisXmlImportWeb extends ActionWeb {
|
||||
|
||||
LogUtil.appendLog(Constant.LOG_END + "[执行阶段][校验阶段]", simpleLogFile, fullLogFile, simpleLogFile, fullLogFile);
|
||||
|
||||
LogUtil.appendLog("\n" + Constant.LOG_START + "预计导入[" + fileName + "]" + I18nRes.findValue(CoEConstant.APP_ID, Constant.PROCESS_EPC + ",共[" + totalEpcCount + "]条流程"));
|
||||
LogUtil.appendLog("\n" + Constant.LOG_START + "预计导入[" + fileName + "]" + I18nRes.findValue(CoEConstant.APP_ID, Constant.PROCESS_EPC + ",共[" + totalCount + "]条流程"));
|
||||
// 开始执行导入
|
||||
new Thread(()->{new ArisXmlImportRun(_uc, wsId, logId, logPath, simpleLogFile, fullLogFile, warnLogFile, this.filePath, this.fileName, startTime).execute(handleWeb);}) .start();
|
||||
|
||||
ResponseObject ro = ResponseObject.newOkResponse();
|
||||
ro.put("logId", logId);
|
||||
ro.put("path", logPath);
|
||||
ro.put("endLog", Constant.END_LOG);
|
||||
ro.put("totalCount", totalCount);
|
||||
ro.put("importCount", LogRealTimeCountCache.getCache().get(logId).getImportingCount());
|
||||
return ro.toString();
|
||||
}
|
||||
|
||||
@ -392,4 +404,59 @@ public class ArisXmlImportWeb extends ActionWeb {
|
||||
return o == null || o.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询导入流程日志
|
||||
* @param logId
|
||||
* @param path
|
||||
* @param timer
|
||||
* @return
|
||||
*/
|
||||
public String queryArisXmlImportLog(String logId, String path, String timer) {
|
||||
String content = "";
|
||||
if (new File(path).exists()) {
|
||||
content = LogUtil.getLogContent(new File(path));
|
||||
}
|
||||
ResponseObject ro = ResponseObject.newOkResponse();
|
||||
ro.put("content", content);
|
||||
ro.put("timer", timer);
|
||||
ro.put("resultStatus", LogUtil.queryLog(logId).getResultStatus());
|
||||
return ro.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载日志
|
||||
* @param logId
|
||||
* @param path
|
||||
* @return
|
||||
*/
|
||||
public String downloadArisXmlImportLog(String logId, String path) {
|
||||
File file = new File(path);
|
||||
if (!file.exists()) {
|
||||
return ResponseObject.newErrResponse("日志文件不存在").toString();
|
||||
}
|
||||
LogModel model = LogUtil.queryLog(logId);
|
||||
String fileName = model.getFileName();
|
||||
// 创建dc目录
|
||||
DCPluginProfile dcProfile = DCProfileManager.getDCProfile(Constant.APP_ID, ArisConstant.REPOSITORY_NAME);
|
||||
DCContext dc = new DCContext(_uc, dcProfile, Constant.APP_ID, ArisConstant.GROUP_VALUE_DOWNLOAD, file.getParentFile().getName());
|
||||
String dirPath = dc.getPath();
|
||||
File dir = new File(dirPath);
|
||||
if (!dir.exists()) {
|
||||
dir.mkdirs();
|
||||
}
|
||||
|
||||
String targetFileName = fileName.substring(0, fileName.lastIndexOf(".")) + "导入日志.zip";
|
||||
File targetFile = new File(dir.getPath() + File.separator + targetFileName);
|
||||
try {
|
||||
UtilFile.zipCompress(file.getParentFile().getPath(), targetFile);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return ResponseObject.newErrResponse("压缩日志文件失败,详细信息:" + e.getMessage()).toString();
|
||||
}
|
||||
DCContext dc2 = new DCContext(_uc, dcProfile, Constant.APP_ID, ArisConstant.GROUP_VALUE_DOWNLOAD, file.getParentFile().getName(), targetFileName);
|
||||
String url = dc2.getDownloadURL();
|
||||
ResponseObject ro = ResponseObject.newOkResponse();
|
||||
ro.put("url", url + "&isInline=false");
|
||||
return ro.toString();
|
||||
}
|
||||
}
|
||||
@ -17,13 +17,13 @@
|
||||
<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 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">
|
||||
<script type="module" crossorigin src="../apps/com.actionsoft.apps.coe.pal.datamigration/main/js/entry-index-9631faac.js"></script>
|
||||
<link rel="stylesheet" href="../apps/com.actionsoft.apps.coe.pal.datamigration/main/assets/asset-style-931be2b3.css">
|
||||
</head>
|
||||
<body style="margin:0;">
|
||||
<div id="app"></div>
|
||||
|
||||
@ -25,4 +25,13 @@
|
||||
<param name="fileValue"/>
|
||||
<param name="fileName"/>
|
||||
</cmd-bean>
|
||||
<cmd-bean name="com.actionsoft.apps.coe.pal.datamigration_data_migrate_log_query">
|
||||
<param name="logId"/>
|
||||
<param name="path"/>
|
||||
<param name="timer"/>
|
||||
</cmd-bean>
|
||||
<cmd-bean name="com.actionsoft.apps.coe.pal.datamigration_data_migrate_log_download">
|
||||
<param name="logId"/>
|
||||
<param name="path"/>
|
||||
</cmd-bean>
|
||||
</aws-actions>
|
||||
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 one or more lines are too long
Loading…
Reference in New Issue
Block a user