岗位批处理导入
This commit is contained in:
parent
572208ab3d
commit
9c66c31b7a
@ -1,6 +1,7 @@
|
|||||||
package com.actionsoft.apps.coe.pal.datamigration;
|
package com.actionsoft.apps.coe.pal.datamigration;
|
||||||
|
|
||||||
import com.actionsoft.apps.coe.pal.datamigration.aris.web.ArisXmlImportWeb;
|
import com.actionsoft.apps.coe.pal.datamigration.aris.web.ArisXmlImportWeb;
|
||||||
|
import com.actionsoft.apps.coe.pal.datamigration.position.web.PositionExcelImportWeb;
|
||||||
import com.actionsoft.apps.coe.pal.datamigration.util.readtable.ReadTable;
|
import com.actionsoft.apps.coe.pal.datamigration.util.readtable.ReadTable;
|
||||||
import com.actionsoft.apps.coe.pal.datamigration.util.readword.ReadWordUtil;
|
import com.actionsoft.apps.coe.pal.datamigration.util.readword.ReadWordUtil;
|
||||||
import com.actionsoft.apps.coe.pal.datamigration.web.DataMigrationWeb;
|
import com.actionsoft.apps.coe.pal.datamigration.web.DataMigrationWeb;
|
||||||
@ -173,4 +174,46 @@ public class DataMigrationController {
|
|||||||
ResponseObject ro = ResponseObject.newOkResponse();
|
ResponseObject ro = ResponseObject.newOkResponse();
|
||||||
return ro.toString();
|
return ro.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 岗位导入
|
||||||
|
* @param uc
|
||||||
|
* @param wsId
|
||||||
|
* @param groupValue
|
||||||
|
* @param fileValue
|
||||||
|
* @param fileName
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Mapping("com.actionsoft.apps.coe.pal.datamigration_position_import")
|
||||||
|
public String positionImport(UserContext uc, String wsId,String groupValue,String fileValue,String fileName) {
|
||||||
|
return new DataMigrationWeb(uc).positionImport(wsId,groupValue,fileValue,fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 岗位导入日志查询
|
||||||
|
* @param uc
|
||||||
|
* @param logId
|
||||||
|
* @param path
|
||||||
|
* @param timer
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Mapping("com.actionsoft.apps.coe.pal.datamigration_position_import_log_query")
|
||||||
|
public String queryPositionExcelImportLog(UserContext uc, String logId, String path, String timer) {
|
||||||
|
PositionExcelImportWeb web = new PositionExcelImportWeb(uc);
|
||||||
|
return web.queryPositionExcelImportLog(logId, path, timer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 岗位日志下载
|
||||||
|
* @param uc
|
||||||
|
* @param logId
|
||||||
|
* @param path
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Mapping("com.actionsoft.apps.coe.pal.datamigration_position_import_log_download")
|
||||||
|
public String downloadPositionExcelImportLog(UserContext uc, String logId, String path) {
|
||||||
|
PositionExcelImportWeb web = new PositionExcelImportWeb(uc);
|
||||||
|
return web.downloadPositionExcelImportLog(logId, path);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package com.actionsoft.apps.coe.pal.datamigration.plugin;
|
package com.actionsoft.apps.coe.pal.datamigration.plugin;
|
||||||
|
|
||||||
import com.actionsoft.apps.coe.pal.datamigration.aris.constant.ArisConstant;
|
import com.actionsoft.apps.coe.pal.datamigration.aris.constant.ArisConstant;
|
||||||
|
import com.actionsoft.apps.coe.pal.datamigration.position.constant.PositionConstant;
|
||||||
import com.actionsoft.apps.coe.pal.datamigration.web.DataMigrationWeb;
|
import com.actionsoft.apps.coe.pal.datamigration.web.DataMigrationWeb;
|
||||||
import com.actionsoft.apps.coe.pal.pal.repository.upfile.CoeFileProcessor;
|
import com.actionsoft.apps.coe.pal.pal.repository.upfile.CoeFileProcessor;
|
||||||
import com.actionsoft.apps.listener.PluginListener;
|
import com.actionsoft.apps.listener.PluginListener;
|
||||||
@ -24,6 +25,7 @@ public class Plugins implements PluginListener {
|
|||||||
|
|
||||||
list.add(new DCPluginProfile("migration", CoeFileProcessor.class.getName(), "存放数据迁移文件", false, false));
|
list.add(new DCPluginProfile("migration", CoeFileProcessor.class.getName(), "存放数据迁移文件", false, false));
|
||||||
list.add(new DCPluginProfile(ArisConstant.REPOSITORY_NAME, CoeFileProcessor.class.getName(), "存在arisXML数据迁移日志", false, false));
|
list.add(new DCPluginProfile(ArisConstant.REPOSITORY_NAME, CoeFileProcessor.class.getName(), "存在arisXML数据迁移日志", false, false));
|
||||||
|
list.add(new DCPluginProfile(PositionConstant.REPOSITORY_NAME, CoeFileProcessor.class.getName(), "存在岗位Excel数据导入日志", false, false));
|
||||||
|
|
||||||
// PAL应用扩展点
|
// PAL应用扩展点
|
||||||
Map<String, Object> params0 = new HashMap<String, Object>();
|
Map<String, Object> params0 = new HashMap<String, Object>();
|
||||||
|
|||||||
@ -0,0 +1,36 @@
|
|||||||
|
package com.actionsoft.apps.coe.pal.datamigration.position.constant;
|
||||||
|
|
||||||
|
public class PositionConstant {
|
||||||
|
|
||||||
|
public final static String REPOSITORY_NAME = "positionExcel";// 岗位Excel文件导入dc根目录
|
||||||
|
|
||||||
|
public final static String GROUP_VALUE_UPFILE = "upfile";// 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";// 详细日志,包括全量信息内容
|
||||||
|
public final static String IMPORT_LOG_FILE_WARN = "warnErrImport.log";// 错误&警告日志,单独记录错误&警告日志,同时详细日志中也有记录
|
||||||
|
|
||||||
|
public final static String IMPORT_LOG_FILE_SUCCESS = "successImport.log";// 导入成功日志单独记录,只记录pal流程名称与对应的Aris地址,客户需要
|
||||||
|
|
||||||
|
public final static String IMPORT_LOG_FILE_MATCH_ERR = "matchErrImport.log";// 导入aris流程匹配失败的
|
||||||
|
|
||||||
|
// Excel标标题
|
||||||
|
public final static String TABLE_PROCESS_NAME = "流程名称";
|
||||||
|
public final static String TABLE_PROCESS_SHAPE_NAME = "活动名称";
|
||||||
|
public final static String TABLE_TYPE_NAME = "类别";
|
||||||
|
public final static String TABLE_NAME = "名称";
|
||||||
|
public final static String TABLE_POSITION_NAME1 = "现在岗位名称1";
|
||||||
|
public final static String TABLE_POSITION_NAME2 = "现在岗位名称2";
|
||||||
|
public final static String TABLE_POSITION_NAME3 = "现在岗位名称3";
|
||||||
|
public final static String TABLE_POSITION_NAME4 = "现在岗位名称4";
|
||||||
|
|
||||||
|
public final static String [] EXCEL_TITLE_ROW_ARR = new String [] {TABLE_PROCESS_NAME, TABLE_PROCESS_SHAPE_NAME, TABLE_TYPE_NAME, TABLE_NAME, TABLE_POSITION_NAME1, TABLE_POSITION_NAME2, TABLE_POSITION_NAME3, TABLE_POSITION_NAME4};
|
||||||
|
public final static String EXCEL_TITLE_ROW = TABLE_PROCESS_NAME+ "、" +TABLE_PROCESS_SHAPE_NAME+ "、" +TABLE_TYPE_NAME+ "、" +TABLE_NAME+ "、" +TABLE_POSITION_NAME1+ "、"
|
||||||
|
+TABLE_POSITION_NAME2+ "、" +TABLE_POSITION_NAME3+ "、" +TABLE_POSITION_NAME4;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,52 @@
|
|||||||
|
package com.actionsoft.apps.coe.pal.datamigration.position.model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PAL中的组织图的岗位
|
||||||
|
*/
|
||||||
|
public class PalOrgPositionModel {
|
||||||
|
String orgId;// PAL组织图ID
|
||||||
|
String orgName;// PAL组织图名称
|
||||||
|
String positionId;// PAL组织图中的岗位ID
|
||||||
|
String positionName;// PAL组织图中的岗位名称
|
||||||
|
|
||||||
|
public String getOrgId() {
|
||||||
|
return orgId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrgId(String orgId) {
|
||||||
|
this.orgId = orgId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOrgName() {
|
||||||
|
return orgName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrgName(String orgName) {
|
||||||
|
this.orgName = orgName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPositionId() {
|
||||||
|
return positionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPositionId(String positionId) {
|
||||||
|
this.positionId = positionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPositionName() {
|
||||||
|
return positionName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPositionName(String positionName) {
|
||||||
|
this.positionName = positionName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "PalOrgPositionModel{" +
|
||||||
|
"orgId='" + orgId + '\'' +
|
||||||
|
", positionId='" + positionId + '\'' +
|
||||||
|
", positionName='" + positionName + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,79 @@
|
|||||||
|
package com.actionsoft.apps.coe.pal.datamigration.position.model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 存储PAL的形状信息
|
||||||
|
*/
|
||||||
|
public class PalShapeInfoModel {
|
||||||
|
private String processId;
|
||||||
|
private String processName;
|
||||||
|
private String shapeId;
|
||||||
|
private String shapeName;
|
||||||
|
private String roleRepositoryId;
|
||||||
|
private String roleRepositoryName;
|
||||||
|
private String roleShapeId;
|
||||||
|
private String roleShapeName;
|
||||||
|
|
||||||
|
public String getProcessId() {
|
||||||
|
return processId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProcessId(String processId) {
|
||||||
|
this.processId = processId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProcessName() {
|
||||||
|
return processName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProcessName(String processName) {
|
||||||
|
this.processName = processName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getShapeId() {
|
||||||
|
return shapeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShapeId(String shapeId) {
|
||||||
|
this.shapeId = shapeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getShapeName() {
|
||||||
|
return shapeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShapeName(String shapeName) {
|
||||||
|
this.shapeName = shapeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRoleRepositoryId() {
|
||||||
|
return roleRepositoryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRoleRepositoryId(String roleRepositoryId) {
|
||||||
|
this.roleRepositoryId = roleRepositoryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRoleRepositoryName() {
|
||||||
|
return roleRepositoryName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRoleRepositoryName(String roleRepositoryName) {
|
||||||
|
this.roleRepositoryName = roleRepositoryName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRoleShapeId() {
|
||||||
|
return roleShapeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRoleShapeId(String roleShapeId) {
|
||||||
|
this.roleShapeId = roleShapeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRoleShapeName() {
|
||||||
|
return roleShapeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRoleShapeName(String roleShapeName) {
|
||||||
|
this.roleShapeName = roleShapeName;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,79 @@
|
|||||||
|
package com.actionsoft.apps.coe.pal.datamigration.position.model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Excel数据model
|
||||||
|
*/
|
||||||
|
public class PositionExcelModel {
|
||||||
|
private String processName;// 流程名称
|
||||||
|
private String processShapeName;// 活动名称
|
||||||
|
private String type;// 类别
|
||||||
|
private String roleName;// 名称(角色)
|
||||||
|
private String positionName1;// 岗位名称1
|
||||||
|
private String positionName2;// 岗位名称2
|
||||||
|
private String positionName3;// 岗位名称3
|
||||||
|
private String positionName4;// 岗位名称4
|
||||||
|
|
||||||
|
public String getProcessName() {
|
||||||
|
return processName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProcessName(String processName) {
|
||||||
|
this.processName = processName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProcessShapeName() {
|
||||||
|
return processShapeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProcessShapeName(String processShapeName) {
|
||||||
|
this.processShapeName = processShapeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRoleName() {
|
||||||
|
return roleName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRoleName(String roleName) {
|
||||||
|
this.roleName = roleName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPositionName1() {
|
||||||
|
return positionName1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPositionName1(String positionName1) {
|
||||||
|
this.positionName1 = positionName1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPositionName2() {
|
||||||
|
return positionName2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPositionName2(String positionName2) {
|
||||||
|
this.positionName2 = positionName2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPositionName3() {
|
||||||
|
return positionName3;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPositionName3(String positionName3) {
|
||||||
|
this.positionName3 = positionName3;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPositionName4() {
|
||||||
|
return positionName4;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPositionName4(String positionName4) {
|
||||||
|
this.positionName4 = positionName4;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,55 @@
|
|||||||
|
package com.actionsoft.apps.coe.pal.datamigration.position.model;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将PositionExcelModel数据剔除无效数据,进行岗位数据整合到该model
|
||||||
|
*/
|
||||||
|
public class PositionValidDataModel {
|
||||||
|
private String processName;// 流程名称
|
||||||
|
private String processShapeName;// 流程活动名称
|
||||||
|
private String roleName;// 角色(形状)名称
|
||||||
|
private List<String> positionList;// 整合后的岗位文本
|
||||||
|
|
||||||
|
public String getProcessName() {
|
||||||
|
return processName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProcessName(String processName) {
|
||||||
|
this.processName = processName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProcessShapeName() {
|
||||||
|
return processShapeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProcessShapeName(String processShapeName) {
|
||||||
|
this.processShapeName = processShapeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRoleName() {
|
||||||
|
return roleName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRoleName(String roleName) {
|
||||||
|
this.roleName = roleName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getPositionList() {
|
||||||
|
return positionList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPositionList(List<String> positionList) {
|
||||||
|
this.positionList = positionList;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "PositionValidDataModel{" +
|
||||||
|
"processName='" + processName + '\'' +
|
||||||
|
", processShapeName='" + processShapeName + '\'' +
|
||||||
|
", roleName='" + roleName + '\'' +
|
||||||
|
", positionList=" + positionList +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,303 @@
|
|||||||
|
package com.actionsoft.apps.coe.pal.datamigration.position.util;
|
||||||
|
|
||||||
|
import com.actionsoft.apps.coe.pal.datamigration.util.StrUtil;
|
||||||
|
import com.actionsoft.bpms.util.UtilString;
|
||||||
|
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
|
||||||
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||||
|
import org.apache.poi.hssf.util.HSSFColor;
|
||||||
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
||||||
|
import org.apache.poi.ss.usermodel.*;
|
||||||
|
import org.apache.poi.ss.util.CellRangeAddress;
|
||||||
|
import org.apache.poi.xssf.usermodel.*;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
public class POIUtil {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表格title行主要信息样式
|
||||||
|
* @param wb
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static XSSFCellStyle getMainCellStyle(XSSFWorkbook wb) {
|
||||||
|
XSSFCellStyle result = wb.createCellStyle();
|
||||||
|
XSSFFont font = wb.createFont();
|
||||||
|
font.setBold(true);
|
||||||
|
font.setFontHeightInPoints((short)12);
|
||||||
|
result.setFont(font);
|
||||||
|
result.setAlignment(HorizontalAlignment.CENTER);
|
||||||
|
result.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||||
|
result.setFillForegroundColor(HSSFColor.SKY_BLUE.index);
|
||||||
|
result.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
||||||
|
result.setBorderBottom(BorderStyle.THIN);
|
||||||
|
result.setBorderLeft(BorderStyle.THIN);
|
||||||
|
result.setBorderTop(BorderStyle.THIN);
|
||||||
|
result.setBorderRight(BorderStyle.THIN);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表格title行扩展属性信息样式
|
||||||
|
* @param wb
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static XSSFCellStyle getExtendCellStyle(XSSFWorkbook wb) {
|
||||||
|
XSSFCellStyle result = wb.createCellStyle();
|
||||||
|
XSSFFont font = wb.createFont();
|
||||||
|
font.setBold(true);
|
||||||
|
font.setFontHeightInPoints((short)12);
|
||||||
|
result.setFont(font);
|
||||||
|
result.setAlignment(HorizontalAlignment.CENTER);
|
||||||
|
result.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||||
|
result.setFillForegroundColor((short)51);
|
||||||
|
result.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
||||||
|
result.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
||||||
|
result.setBorderBottom(BorderStyle.THIN);
|
||||||
|
result.setBorderLeft(BorderStyle.THIN);
|
||||||
|
result.setBorderTop(BorderStyle.THIN);
|
||||||
|
result.setBorderRight(BorderStyle.THIN);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表格边框样式
|
||||||
|
* @param wb
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static XSSFCellStyle getTableCellStyle(XSSFWorkbook wb) {
|
||||||
|
XSSFCellStyle result = wb.createCellStyle();
|
||||||
|
result.setBorderBottom(BorderStyle.THIN);
|
||||||
|
result.setBorderLeft(BorderStyle.THIN);
|
||||||
|
result.setBorderTop(BorderStyle.THIN);
|
||||||
|
result.setBorderRight(BorderStyle.THIN);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 复制一个单元格样式到目的单元格样式
|
||||||
|
* @param wb
|
||||||
|
* @param fromStyle
|
||||||
|
* @param toStyle
|
||||||
|
*/
|
||||||
|
public static void copyCellStyle(XSSFWorkbook wb, XSSFCellStyle fromStyle, XSSFCellStyle toStyle) {
|
||||||
|
toStyle.setAlignment(fromStyle.getAlignmentEnum());
|
||||||
|
//边框和边框颜色
|
||||||
|
toStyle.setBorderBottom(fromStyle.getBorderBottomEnum());
|
||||||
|
toStyle.setBorderLeft(fromStyle.getBorderLeftEnum());
|
||||||
|
toStyle.setBorderRight(fromStyle.getBorderRightEnum());
|
||||||
|
toStyle.setBorderTop(fromStyle.getBorderTopEnum());
|
||||||
|
toStyle.setTopBorderColor(fromStyle.getTopBorderColor());
|
||||||
|
toStyle.setBottomBorderColor(fromStyle.getBottomBorderColor());
|
||||||
|
toStyle.setRightBorderColor(fromStyle.getRightBorderColor());
|
||||||
|
toStyle.setLeftBorderColor(fromStyle.getLeftBorderColor());
|
||||||
|
|
||||||
|
//背景和前景
|
||||||
|
toStyle.setFillBackgroundColor(fromStyle.getFillBackgroundColor());
|
||||||
|
toStyle.setFillForegroundColor(fromStyle.getFillForegroundColor());
|
||||||
|
|
||||||
|
toStyle.setDataFormat(fromStyle.getDataFormat());
|
||||||
|
toStyle.setFillPattern(fromStyle.getFillPatternEnum());
|
||||||
|
// toStyle.setFont(fromStyle.getFont(null));
|
||||||
|
toStyle.setHidden(fromStyle.getHidden());
|
||||||
|
toStyle.setIndention(fromStyle.getIndention());//首行缩进
|
||||||
|
toStyle.setLocked(fromStyle.getLocked());
|
||||||
|
toStyle.setRotation(fromStyle.getRotation());//旋转
|
||||||
|
toStyle.setVerticalAlignment(fromStyle.getVerticalAlignmentEnum());
|
||||||
|
toStyle.setWrapText(fromStyle.getWrapText());
|
||||||
|
|
||||||
|
// 字体
|
||||||
|
XSSFFont newFont = wb.createFont();
|
||||||
|
XSSFFont fromFont = fromStyle.getFont();
|
||||||
|
newFont.setBold(fromFont.getBold());
|
||||||
|
newFont.setCharSet(fromFont.getCharSet());
|
||||||
|
newFont.setColor(fromFont.getColor());
|
||||||
|
newFont.setFamily(fromFont.getFamily());
|
||||||
|
newFont.setFontHeight(fromFont.getFontHeight());
|
||||||
|
newFont.setFontHeightInPoints(fromFont.getFontHeightInPoints());
|
||||||
|
newFont.setFontName(fromFont.getFontName());
|
||||||
|
newFont.setItalic(fromFont.getItalic());
|
||||||
|
newFont.setScheme(fromFont.getScheme());
|
||||||
|
newFont.setStrikeout(fromFont.getStrikeout());
|
||||||
|
newFont.setThemeColor(fromFont.getThemeColor());
|
||||||
|
newFont.setTypeOffset(fromFont.getTypeOffset());
|
||||||
|
newFont.setUnderline(fromFont.getUnderline());
|
||||||
|
toStyle.setFont(newFont);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Sheet复制
|
||||||
|
* @param fromSheet
|
||||||
|
* @param toSheet
|
||||||
|
* @param copyValueFlag
|
||||||
|
*/
|
||||||
|
public static void copySheet(XSSFWorkbook wb,XSSFSheet fromSheet, XSSFSheet toSheet, boolean copyValueFlag) {
|
||||||
|
//合并区域处理
|
||||||
|
mergerRegion(fromSheet, toSheet);
|
||||||
|
// 设置列宽
|
||||||
|
setColumnWidth(wb, fromSheet, toSheet);
|
||||||
|
for (Iterator rowIt = fromSheet.rowIterator(); rowIt.hasNext();) {
|
||||||
|
XSSFRow tmpRow = (XSSFRow) rowIt.next();
|
||||||
|
XSSFRow newRow = toSheet.createRow(tmpRow.getRowNum());
|
||||||
|
//行复制
|
||||||
|
copyRow(wb,tmpRow,newRow,copyValueFlag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void setColumnWidth(XSSFWorkbook wb, XSSFSheet fromSheet, XSSFSheet toSheet) {
|
||||||
|
int maxColumnIndex = 0;
|
||||||
|
for (Iterator rowIt = fromSheet.rowIterator(); rowIt.hasNext();) {
|
||||||
|
XSSFRow fromRow = (XSSFRow) rowIt.next();
|
||||||
|
int index = 0;
|
||||||
|
for (Iterator cellIt = fromRow.cellIterator(); cellIt.hasNext();) {
|
||||||
|
XSSFCell tmpCell = (XSSFCell) cellIt.next();
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
maxColumnIndex = maxColumnIndex > index ? maxColumnIndex : index;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < maxColumnIndex; i++) {
|
||||||
|
toSheet.setColumnWidth(i, fromSheet.getColumnWidth(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 行复制功能
|
||||||
|
* @param fromRow
|
||||||
|
* @param toRow
|
||||||
|
*/
|
||||||
|
public static void copyRow(XSSFWorkbook wb,XSSFRow fromRow,XSSFRow toRow,boolean copyValueFlag){
|
||||||
|
for (Iterator cellIt = fromRow.cellIterator(); cellIt.hasNext();) {
|
||||||
|
XSSFCell tmpCell = (XSSFCell) cellIt.next();
|
||||||
|
XSSFCell newCell = toRow.createCell(tmpCell.getColumnIndex());
|
||||||
|
copyCell(wb,tmpCell, newCell, copyValueFlag);
|
||||||
|
}
|
||||||
|
toRow.setHeight(fromRow.getHeight());
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 复制原有sheet的合并单元格到新创建的sheet
|
||||||
|
*/
|
||||||
|
public static void mergerRegion(XSSFSheet fromSheet, XSSFSheet toSheet) {
|
||||||
|
int sheetMergerCount = fromSheet.getNumMergedRegions();
|
||||||
|
for (int i = 0; i < sheetMergerCount; i++) {
|
||||||
|
CellRangeAddress mergedRegionAt = fromSheet.getMergedRegion(i);
|
||||||
|
toSheet.addMergedRegion(mergedRegionAt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 复制单元格
|
||||||
|
*
|
||||||
|
* @param srcCell
|
||||||
|
* @param distCell
|
||||||
|
* @param copyValueFlag
|
||||||
|
* true则连同cell的内容一起复制
|
||||||
|
*/
|
||||||
|
public static void copyCell(XSSFWorkbook wb,XSSFCell srcCell, XSSFCell distCell, boolean copyValueFlag) {
|
||||||
|
XSSFCellStyle newstyle=wb.createCellStyle();
|
||||||
|
copyCellStyle(wb, srcCell.getCellStyle(), newstyle);
|
||||||
|
distCell.setCellType(srcCell.getCellType());
|
||||||
|
// distCell.setEncoding(srcCell.seten.getEncoding());
|
||||||
|
|
||||||
|
//评论
|
||||||
|
if (srcCell.getCellComment() != null) {
|
||||||
|
distCell.setCellComment(srcCell.getCellComment());
|
||||||
|
}
|
||||||
|
// 不同数据类型处理
|
||||||
|
int srcCellType = srcCell.getCellType();
|
||||||
|
distCell.setCellType(srcCellType);
|
||||||
|
if (copyValueFlag) {
|
||||||
|
if (srcCellType == XSSFCell.CELL_TYPE_NUMERIC) {
|
||||||
|
if (HSSFDateUtil.isCellDateFormatted(srcCell)) {
|
||||||
|
distCell.setCellValue(srcCell.getDateCellValue());
|
||||||
|
} else {
|
||||||
|
distCell.setCellValue(srcCell.getNumericCellValue());
|
||||||
|
}
|
||||||
|
} else if (srcCellType == XSSFCell.CELL_TYPE_STRING) {
|
||||||
|
distCell.setCellValue(srcCell.getRichStringCellValue());
|
||||||
|
} else if (srcCellType == XSSFCell.CELL_TYPE_BLANK) {
|
||||||
|
// nothing21
|
||||||
|
} else if (srcCellType == XSSFCell.CELL_TYPE_BOOLEAN) {
|
||||||
|
distCell.setCellValue(srcCell.getBooleanCellValue());
|
||||||
|
} else if (srcCellType == XSSFCell.CELL_TYPE_ERROR) {
|
||||||
|
distCell.setCellErrorValue(srcCell.getErrorCellValue());
|
||||||
|
} else if (srcCellType == XSSFCell.CELL_TYPE_FORMULA) {
|
||||||
|
distCell.setCellFormula(srcCell.getCellFormula());
|
||||||
|
} else { // nothing29
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取单元格各类型值,返回字符串类型
|
||||||
|
public static String getCellValueByCell(Cell cell) {
|
||||||
|
//判断是否为null或空串
|
||||||
|
if (cell == null || cell.toString().trim().equals("")) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
String cellValue = "";
|
||||||
|
int cellType = cell.getCellType();
|
||||||
|
// 以下是判断数据的类型
|
||||||
|
switch (cellType) {
|
||||||
|
case Cell.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 Cell.CELL_TYPE_STRING: // 字符串
|
||||||
|
cellValue = cell.getStringCellValue();
|
||||||
|
break;
|
||||||
|
case Cell.CELL_TYPE_BOOLEAN: // Boolean
|
||||||
|
cellValue = cell.getBooleanCellValue() + "";
|
||||||
|
break;
|
||||||
|
case Cell.CELL_TYPE_FORMULA: // 公式
|
||||||
|
cellValue = cell.getCellFormula() + "";
|
||||||
|
break;
|
||||||
|
case Cell.CELL_TYPE_BLANK: // 空值
|
||||||
|
cellValue = "";
|
||||||
|
break;
|
||||||
|
// case XSSFCell.CELL_TYPE_ERROR: // 故障
|
||||||
|
// cellValue = "非法字符";
|
||||||
|
// break;
|
||||||
|
default:
|
||||||
|
cellValue = "";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return StrUtil.removeAllBlack(cellValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取文档数据
|
||||||
|
* @param file
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static Workbook getWorkbook(File file, String suffix) {
|
||||||
|
Workbook wb = null;
|
||||||
|
try {
|
||||||
|
if("xls".equals(suffix)) {
|
||||||
|
FileInputStream fis = new FileInputStream(file);
|
||||||
|
wb = new HSSFWorkbook(fis);
|
||||||
|
} else if ("xlsx".equals(suffix)) {
|
||||||
|
wb = new XSSFWorkbook(file);
|
||||||
|
}
|
||||||
|
} catch (InvalidFormatException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return wb;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,375 @@
|
|||||||
|
package com.actionsoft.apps.coe.pal.datamigration.position.web;
|
||||||
|
|
||||||
|
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.mapping.ModelMappingAPIManager;
|
||||||
|
import com.actionsoft.apps.coe.pal.datamigration.aris.model.*;
|
||||||
|
import com.actionsoft.apps.coe.pal.datamigration.aris.util.ArisXmlUtil;
|
||||||
|
import com.actionsoft.apps.coe.pal.datamigration.aris.web.ArisXmlHandleWeb;
|
||||||
|
import com.actionsoft.apps.coe.pal.datamigration.constant.Constant;
|
||||||
|
import com.actionsoft.apps.coe.pal.datamigration.position.model.PalOrgPositionModel;
|
||||||
|
import com.actionsoft.apps.coe.pal.datamigration.position.model.PalShapeInfoModel;
|
||||||
|
import com.actionsoft.apps.coe.pal.datamigration.position.model.PositionExcelModel;
|
||||||
|
import com.actionsoft.apps.coe.pal.datamigration.position.model.PositionValidDataModel;
|
||||||
|
import com.actionsoft.apps.coe.pal.datamigration.util.LogUtil;
|
||||||
|
import com.actionsoft.apps.coe.pal.datamigration.util.ProcessUtil;
|
||||||
|
import com.actionsoft.apps.coe.pal.datamigration.util.ShapeUtil;
|
||||||
|
import com.actionsoft.apps.coe.pal.datamigration.util.StrUtil;
|
||||||
|
import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodAttributeModel;
|
||||||
|
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.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.dao.PALRepositoryPropertyDao;
|
||||||
|
import com.actionsoft.apps.coe.pal.pal.repository.designer.CoeDesignerShapeAPIManager;
|
||||||
|
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.relation.cache.DesignerShapeRelationCache;
|
||||||
|
import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.dao.DesignerShapeRelationDao;
|
||||||
|
import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.model.DesignerShapeRelationModel;
|
||||||
|
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.PALRepositoryPropertyModel;
|
||||||
|
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.yili.log.datamigration.log.Cache.LogRealTimeCountCache;
|
||||||
|
import com.actionsoft.apps.coe.pal.yili.log.datamigration.log.Model.LogRealTimeCountModel;
|
||||||
|
import com.actionsoft.bpms.server.UserContext;
|
||||||
|
import com.actionsoft.bpms.util.UUIDGener;
|
||||||
|
import com.actionsoft.bpms.util.UtilDate;
|
||||||
|
import com.actionsoft.bpms.util.UtilString;
|
||||||
|
import com.actionsoft.exception.AWSException;
|
||||||
|
import com.actionsoft.i18n.I18nRes;
|
||||||
|
import com.actionsoft.sdk.local.SDK;
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class PositionExcelImportRun {
|
||||||
|
|
||||||
|
private final UserContext uc;
|
||||||
|
private final String wsId;
|
||||||
|
private final String logId;
|
||||||
|
private final String logPath;
|
||||||
|
private final File simpleLogFile;
|
||||||
|
private final File fullLogFile;
|
||||||
|
private final File warnLogFile;
|
||||||
|
private final File successLogFile;// 客户特殊需要,记录成功日志
|
||||||
|
private final File matchErrImportFile;// 匹配失败记录
|
||||||
|
private final String filePath;
|
||||||
|
private final String fileName;
|
||||||
|
private final long startTime;
|
||||||
|
|
||||||
|
private long endTime;
|
||||||
|
|
||||||
|
public PositionExcelImportRun(UserContext uc, String wsId, String logId, String logPath, File simpleLogFile, File fullLogFile, File warnLogFile, String filePath, String fileName, long startTime) {
|
||||||
|
this.uc = uc;
|
||||||
|
this.wsId = wsId;
|
||||||
|
this.logId = logId;
|
||||||
|
this.logPath = logPath;
|
||||||
|
this.simpleLogFile = simpleLogFile;
|
||||||
|
this.fullLogFile = fullLogFile;
|
||||||
|
this.warnLogFile = warnLogFile;
|
||||||
|
this.filePath = filePath;
|
||||||
|
this.fileName = fileName;
|
||||||
|
this.startTime = startTime;
|
||||||
|
// 单独创建一个成功日志
|
||||||
|
successLogFile = new File(fullLogFile.getParentFile().getPath() + File.separator + ArisConstant.IMPORT_LOG_FILE_SUCCESS);
|
||||||
|
matchErrImportFile = new File(fullLogFile.getParentFile().getPath() + File.separator + ArisConstant.IMPORT_LOG_FILE_MATCH_ERR);
|
||||||
|
try {
|
||||||
|
successLogFile.createNewFile();
|
||||||
|
matchErrImportFile.createNewFile();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行导入
|
||||||
|
* @param processMap Excel流程map,key:流程名称,value:Excel中该流程的活动+角色与岗位信息
|
||||||
|
* @param arisNameMap pal的流程与aris流程名称的关系map,key:aris流程名称,value:key对应的pal流程id
|
||||||
|
* @param posMap pal的组织图的岗位关系map,key:pal的组织的岗位名称,value:该岗位对应的组织
|
||||||
|
*/
|
||||||
|
public void execute(Map<String, List<PositionValidDataModel>> processMap, Map<String, String> arisNameMap, Map<String, PalOrgPositionModel> posMap) {
|
||||||
|
DesignerShapeRelationDao relationDao = new DesignerShapeRelationDao();
|
||||||
|
try {
|
||||||
|
int totalCount = LogRealTimeCountCache.getCache().get(logId).getTotalCount();
|
||||||
|
// 以流程为单位进行导入
|
||||||
|
int importingCount = 0;// 当前导入的第几个
|
||||||
|
for (Map.Entry<String, List<PositionValidDataModel>> entry : processMap.entrySet()) {
|
||||||
|
List<PositionValidDataModel> excelData = entry.getValue();
|
||||||
|
importingCount++;
|
||||||
|
String processName = entry.getKey();// Excel流程名称
|
||||||
|
LogRealTimeCountCache.getCache().get(logId).setImportingCount(importingCount);// 当前记录缓存
|
||||||
|
// 当前正在导入的流程全部日志记录,方便对照
|
||||||
|
LogUtil.appendLog("\n************[执行进度]当前执行第[" + importingCount + "]条,共["+ totalCount +"]条************", simpleLogFile, fullLogFile, warnLogFile);
|
||||||
|
|
||||||
|
LogUtil.appendLog("\n" + Constant.LOG_START + "************[执行阶段][流程匹配阶段]PAL过程链图与Excel中流程进行匹配************", simpleLogFile, fullLogFile);
|
||||||
|
// 校验pal是否存在该流程
|
||||||
|
if (!arisNameMap.containsKey(processName)) {
|
||||||
|
// Excel中的流程在PAL中不存在,当作警告处理,全部记录
|
||||||
|
LogUtil.appendLog(Constant.LOG_WARNING + "Excel流程" + "[" + processName + "]未在PAL中找到,忽略导入", simpleLogFile, fullLogFile, warnLogFile);
|
||||||
|
LogUtil.appendLog("[Excel流程未找到]Excel流程" + "[" + processName + "]", matchErrImportFile);
|
||||||
|
LogRealTimeCountCache.getCache().get(logId).setArisBlankCount(LogRealTimeCountCache.getCache().get(logId).getArisBlankCount() + 1);// 借用ArisBlankCount
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String palId = arisNameMap.get(processName);
|
||||||
|
List<DesignerShapeRelationModel> insertModels = new ArrayList<>();// 匹配上待保存的数据
|
||||||
|
List<DesignerShapeRelationModel> delModels = null;// 待删除的数据(Excel中存在代表要更新/删除)
|
||||||
|
|
||||||
|
// 获取pal流程的形状信息以及形状对应的角色信息
|
||||||
|
List<PalShapeInfoModel> palShapeInfoModelList = new ArrayList<>();
|
||||||
|
Map<String, List<JSONObject>> roleRepositoryMap = new HashMap<>();
|
||||||
|
|
||||||
|
// 获取pal里面的形状列表
|
||||||
|
List<JSONObject> shapeList = CoeDesignerUtil.getShapeMessageJson5(palId);
|
||||||
|
for (JSONObject shape : shapeList) {
|
||||||
|
PalShapeInfoModel info = new PalShapeInfoModel();
|
||||||
|
info.setProcessId(palId);
|
||||||
|
info.setProcessName(processName);
|
||||||
|
info.setShapeId(shape.getString("id"));
|
||||||
|
info.setShapeName(StrUtil.removeAllBlack(shape.getString("text")));
|
||||||
|
queryProcessShapeRole(info, roleRepositoryMap);// 完善info中的角色信息
|
||||||
|
if (UtilString.isNotEmpty(info.getShapeName())) {
|
||||||
|
palShapeInfoModelList.add(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (PositionValidDataModel model : excelData) {
|
||||||
|
boolean matched = false;
|
||||||
|
PalShapeInfoModel matchPal = null;// 与Excel中model匹配的pal形状和角色信息
|
||||||
|
String excelShapeName = model.getProcessShapeName();
|
||||||
|
String excelRoleName = model.getRoleName();
|
||||||
|
for (PalShapeInfoModel info : palShapeInfoModelList) {
|
||||||
|
if (info.getShapeName().equals(excelShapeName) && info.getRoleShapeName().equals(excelRoleName)) {// 对比形状名称和角色名称
|
||||||
|
matchPal = info;
|
||||||
|
matched = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (matched) {
|
||||||
|
// 匹配上了形状和角色
|
||||||
|
// 先记录删除,即Excel中存在但岗位为空,则默认为清空该角色下的岗位属性
|
||||||
|
delModels = DesignerShapeRelationCache.getListByAttrId(matchPal.getRoleRepositoryId(), matchPal.getRoleShapeId(), Constant.METHOD_POST);
|
||||||
|
// 查询对应的岗位是否存在
|
||||||
|
List<String> positionList = model.getPositionList();
|
||||||
|
if (positionList.size() == 0) {
|
||||||
|
// 无任何岗位,忽略
|
||||||
|
LogUtil.appendLog(Constant.LOG_WARNING + "Excel流程[" + model.getProcessName() + "]的活动["+ model.getProcessShapeName() +"]的角色[" + model.getRoleName() + "]在Excel中无任何岗位信息,忽略", simpleLogFile, fullLogFile, matchErrImportFile);
|
||||||
|
} else {
|
||||||
|
// 有岗位
|
||||||
|
for (String posStr : positionList) {
|
||||||
|
// 岗位是否存在
|
||||||
|
if (posMap.containsKey(posStr)) {
|
||||||
|
// 对应岗位找到,导入
|
||||||
|
PalOrgPositionModel positionModel = posMap.get(posStr);
|
||||||
|
LogUtil.appendLog(Constant.LOG_SUCCESS + "Excel流程[" + model.getProcessName() + "]的活动["+ model.getProcessShapeName() +"]的角色[" + model.getRoleName() + "]匹配上了岗位图[" + positionModel.getOrgName() + "]的岗位[" + positionModel.getPositionName() + "]", simpleLogFile, fullLogFile, successLogFile);
|
||||||
|
DesignerShapeRelationModel newModel = new DesignerShapeRelationModel();
|
||||||
|
newModel.setId(UUIDGener.getUUID());
|
||||||
|
newModel.setFileId(matchPal.getRoleRepositoryId());
|
||||||
|
newModel.setShapeId(matchPal.getShapeId());
|
||||||
|
newModel.setShapeText(matchPal.getShapeName());
|
||||||
|
newModel.setAttrId(Constant.METHOD_POST);
|
||||||
|
newModel.setRelationFileId(positionModel.getOrgId());
|
||||||
|
newModel.setRelationShapeId(positionModel.getPositionId());
|
||||||
|
newModel.setRelationShapeText(positionModel.getPositionName());
|
||||||
|
insertModels.add(newModel);
|
||||||
|
} else {
|
||||||
|
// 无相关岗位数据
|
||||||
|
LogUtil.appendLog(Constant.LOG_WARNING + "Excel流程[" + model.getProcessName() + "]的活动["+ model.getProcessShapeName() +"]的角色[" + model.getRoleName() + "]对应的岗位["+ posStr +"]没有对应的PAL的岗位,忽略", simpleLogFile, fullLogFile, matchErrImportFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 没有匹配上形状和角色,记录日志
|
||||||
|
LogUtil.appendLog(Constant.LOG_WARNING + "Excel流程[" + model.getProcessName() + "]的活动["+ model.getProcessShapeName() +"]的角色[" + model.getRoleName() + "]没有匹配的PAL的活动形状和岗位信息,忽略", simpleLogFile, fullLogFile, matchErrImportFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 删除现有的
|
||||||
|
LogUtil.appendLog(Constant.LOG_START + "[删除]原有的流程[" + processName + "]活动对应角色关联的岗位", simpleLogFile, fullLogFile);
|
||||||
|
if (delModels.size() > 0) {
|
||||||
|
relationDao.batchDeleteRelationListById(delModels);
|
||||||
|
for (DesignerShapeRelationModel relation : delModels) {
|
||||||
|
String name = relation.getAttrId();
|
||||||
|
String posNmae = relation.getRelationShapeText();
|
||||||
|
String value = relation.toString();
|
||||||
|
LogUtil.appendLog(Constant.LOG_SUCCESS + "流程[" + processName + "]的活动涉及到的角色[" + name + "]原有的关联岗位[" + posNmae + "]删除", simpleLogFile, fullLogFile);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
LogUtil.appendLog(Constant.LOG_SUCCESS + "流程[" + processName + "]的活动涉及到的角色之前没有关联的岗位,忽略", simpleLogFile, fullLogFile);
|
||||||
|
}
|
||||||
|
LogUtil.appendLog(Constant.LOG_END + "[删除]原有的流程[" + processName + "]活动对应角色关联的岗位", simpleLogFile, fullLogFile);
|
||||||
|
// 保存已更新的
|
||||||
|
// 过滤重复的数据
|
||||||
|
Set<String> ids = new HashSet<>();
|
||||||
|
List<DesignerShapeRelationModel> tmpList = new ArrayList<>();
|
||||||
|
for (DesignerShapeRelationModel model : insertModels) {
|
||||||
|
String id = model.getFileId() + "-" + model.getShapeId() + "-" + model.getRelationFileId() + "-" + model.getRelationShapeId() + "-" + model.getAttrId();
|
||||||
|
if (!ids.contains(id)) {
|
||||||
|
tmpList.add(model);
|
||||||
|
ids.add(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
insertModels = tmpList;
|
||||||
|
LogUtil.appendLog(Constant.LOG_START + "[新增]流程[" + processName + "]活动对应角色关联的岗位", simpleLogFile, fullLogFile);
|
||||||
|
if (insertModels.size() > 0) {
|
||||||
|
// 保存
|
||||||
|
boolean insertRelation = relationDao.barchInsert(insertModels);
|
||||||
|
if (insertRelation) {
|
||||||
|
for (DesignerShapeRelationModel relation : insertModels) {
|
||||||
|
String name = relation.getAttrId();
|
||||||
|
String posNmae = relation.getRelationShapeText();
|
||||||
|
String value = relation.toString();
|
||||||
|
LogUtil.appendLog(Constant.LOG_SUCCESS + "流程[" + processName + "]的活动涉及到的角色[" + name + "]原有的关联岗位[" + posNmae + "]更新", simpleLogFile, fullLogFile);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
LogUtil.appendLog(Constant.LOG_WARNING + "[新增]流程[" + processName + "]活动对应角色关联的岗位", simpleLogFile, fullLogFile, warnLogFile);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
LogUtil.appendLog(Constant.LOG_SUCCESS + "[新增]流程[" + processName + "]的活动涉及到的角色没有新关联的岗位,忽略", simpleLogFile, fullLogFile);
|
||||||
|
}
|
||||||
|
LogUtil.appendLog(Constant.LOG_END + "[新增]流程[" + processName + "]活动对应角色关联的岗位", simpleLogFile, fullLogFile);
|
||||||
|
|
||||||
|
|
||||||
|
LogUtil.appendLog("\n" + Constant.LOG_START + "************[执行阶段][流程匹配阶段]PAL过程链图与Excel中流程进行匹配************", simpleLogFile, fullLogFile);
|
||||||
|
|
||||||
|
// 记录流程导入结束日志
|
||||||
|
LogRealTimeCountCache.getCache().get(logId).setSuccessCount(LogRealTimeCountCache.getCache().get(logId).getSuccessCount() + 1);
|
||||||
|
LogUtil.appendLog(Constant.LOG_END + "保存PAL流程[" + processName + "]的的活动角色关联的岗位", simpleLogFile, fullLogFile, successLogFile);
|
||||||
|
}
|
||||||
|
endTime = System.currentTimeMillis();
|
||||||
|
Timestamp endDate = new Timestamp(endTime);
|
||||||
|
LogRealTimeCountModel model = LogRealTimeCountCache.getCache().get(logId);
|
||||||
|
String takeTimeText = takeTime(endTime, startTime);
|
||||||
|
String resultMsg = "导入完成,总耗时" + takeTimeText + ",Excel流程总共[" + model.getTotalCount() + "],导入成功[" + model.getSuccessCount() + "]条,导入失败[" + (model.getTotalCount() - model.getSuccessCount()) + "]条";
|
||||||
|
LogUtil.updateLog(logId, endDate, Constant.LOG_RESULT_StATUS_SUCCESS, resultMsg);
|
||||||
|
LogUtil.appendLog("\n" + Constant.LOG_END + resultMsg, simpleLogFile, fullLogFile, warnLogFile);
|
||||||
|
LogUtil.appendLog("\n" + "岗位Excel导入 End " + UtilDate.datetimeFormat(endDate), simpleLogFile, fullLogFile, warnLogFile);
|
||||||
|
LogUtil.appendLog("--------------------------------", simpleLogFile, fullLogFile, warnLogFile);
|
||||||
|
LogUtil.appendLog(Constant.END_LOG, simpleLogFile, fullLogFile, warnLogFile);
|
||||||
|
LogRealTimeCountCache.getCache().remove(logId);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
// 记录结束日志
|
||||||
|
endTime = 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()) + "]条";
|
||||||
|
LogUtil.updateLog(logId, endDate, Constant.LOG_RESULT_StATUS_ERROR, resultMsg);
|
||||||
|
LogUtil.appendLog(Constant.LOG_ERROR + resultMsg, simpleLogFile, fullLogFile, warnLogFile);
|
||||||
|
LogUtil.appendLog(Constant.END_LOG, simpleLogFile, fullLogFile, warnLogFile);
|
||||||
|
LogRealTimeCountCache.getCache().remove(logId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询流程对应的活动形状的角色
|
||||||
|
* @param info
|
||||||
|
* @param roleRepositoryMap
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private void queryProcessShapeRole(PalShapeInfoModel info, Map<String, List<JSONObject>> roleRepositoryMap) {
|
||||||
|
// 对应的角色名称查询
|
||||||
|
List<DesignerShapeRelationModel> relationModelList = DesignerShapeRelationCache.getListByAttrId(info.getProcessId(), info.getShapeId(), Constant.METHOD_ROLE);
|
||||||
|
if (relationModelList.size() != 0 && relationModelList.size() > 0) {
|
||||||
|
DesignerShapeRelationModel roleRelation = relationModelList.get(0);
|
||||||
|
String roleRepositoryId = roleRelation.getRelationFileId();
|
||||||
|
String roleShapeId = roleRelation.getRelationShapeId();
|
||||||
|
if (!roleRepositoryMap.containsKey(roleRepositoryId)) {
|
||||||
|
roleRepositoryMap.put(roleRepositoryId, CoeDesignerUtil.getShapeMessageJson5(roleRepositoryId));
|
||||||
|
}
|
||||||
|
List<JSONObject> roleShapeList = roleRepositoryMap.get(roleRepositoryId);
|
||||||
|
if (roleShapeList != null) {
|
||||||
|
for (JSONObject roleShape : roleShapeList) {
|
||||||
|
if (roleShapeId.equals(roleShape.getString("id"))) {
|
||||||
|
info.setRoleRepositoryId(roleRepositoryId);
|
||||||
|
info.setRoleRepositoryName(PALRepositoryCache.getCache().get(roleRepositoryId).getName());
|
||||||
|
info.setRoleShapeId(roleShapeId);
|
||||||
|
info.setRoleShapeName(StrUtil.removeAllBlack(roleShape.getString("text")));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 时间转换
|
||||||
|
* @param type
|
||||||
|
* @param timeStr
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private Timestamp getTimeStampDate(String type, String timeStr) {
|
||||||
|
timeStr = timeStr.replaceAll(".000;", ";");
|
||||||
|
DateFormat format = new SimpleDateFormat("HH:mm:ss;MM/dd/yyyy");
|
||||||
|
try {
|
||||||
|
Timestamp time = new Timestamp(format.parse(timeStr).getTime());
|
||||||
|
return time;
|
||||||
|
} catch (ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
LogUtil.appendLog(Constant.LOG_WARNING + "[" + type + "]转换异常,异常信息" + e.getMessage(), simpleLogFile, fullLogFile, warnLogFile);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算使用时间
|
||||||
|
* @param endTime
|
||||||
|
* @param startTime
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private String takeTime(long endTime, long startTime) {
|
||||||
|
long time = endTime - startTime;
|
||||||
|
String timeMsg = "";
|
||||||
|
if (time > 1000 * 60) {
|
||||||
|
timeMsg = "[" + (time / 1000 / 60) + "]分钟";
|
||||||
|
} else if (time > 1000) {
|
||||||
|
timeMsg = "[" + (time / 1000) + "]秒";
|
||||||
|
} else {
|
||||||
|
timeMsg = "[" + time + "]毫秒";
|
||||||
|
}
|
||||||
|
return timeMsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验和创建角色模型文件夹
|
||||||
|
* @param coeProcessLevel
|
||||||
|
* @param wsId
|
||||||
|
* @return 已经存在的或新创建的角色模型ID
|
||||||
|
*/
|
||||||
|
private String checkAndCreatePalRoleFolderModel(PALRepository coeProcessLevel, String wsId) {
|
||||||
|
// 组织下创建[角色模型]文件夹
|
||||||
|
List<PALRepositoryModel> defaultModels = PALRepositoryQueryAPIManager.getInstance().getPalRepositoryModelsByWsIdAndMethodId(wsId, "org");
|
||||||
|
defaultModels = defaultModels.stream()
|
||||||
|
.filter(model -> "default".equals(model.getMethodId()))
|
||||||
|
.filter(model -> Constant.DEFAULT_FOLDER_NAME.equals(model.getName())).collect(Collectors.toList());
|
||||||
|
if (defaultModels.size() == 0) {
|
||||||
|
String id = UUIDGener.getUUID();
|
||||||
|
|
||||||
|
int orderIndex = coeProcessLevel.getChildrenMaxOrderIndexByPidAndWsId("org", wsId) + 1;
|
||||||
|
Timestamp nowTime = new Timestamp(System.currentTimeMillis());
|
||||||
|
PALRepositoryModelImpl defaultModel = CoeProcessLevelUtil.createPALRepositoryModel(id, UUIDGener.getUUID(), wsId, Constant.DEFAULT_FOLDER_NAME, "", orderIndex, "org", "org", true, 1,
|
||||||
|
id, false, "default", "0", 1, null, null, uc.getUID(), uc.getUID(), nowTime, null, null, null, null,
|
||||||
|
null, null, null, null, null, -1);
|
||||||
|
coeProcessLevel.insert(defaultModel);
|
||||||
|
defaultModels.add(defaultModel);
|
||||||
|
LogUtil.appendLog(Constant.LOG_END + "角色模型文件夹创建", simpleLogFile, fullLogFile);
|
||||||
|
return defaultModel.getId();
|
||||||
|
} else {
|
||||||
|
LogUtil.appendLog(Constant.LOG_WARNING + "角色模型文件夹已存在,不再重复创建", simpleLogFile, fullLogFile, warnLogFile);
|
||||||
|
return defaultModels.get(0).getId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,699 @@
|
|||||||
|
package com.actionsoft.apps.coe.pal.datamigration.position.web;
|
||||||
|
|
||||||
|
import com.actionsoft.apps.coe.pal.constant.CoEConstant;
|
||||||
|
import com.actionsoft.apps.coe.pal.datamigration.constant.Constant;
|
||||||
|
import com.actionsoft.apps.coe.pal.datamigration.log.model.LogModel;
|
||||||
|
import com.actionsoft.apps.coe.pal.datamigration.position.constant.PositionConstant;
|
||||||
|
import com.actionsoft.apps.coe.pal.datamigration.position.model.PalOrgPositionModel;
|
||||||
|
import com.actionsoft.apps.coe.pal.datamigration.position.model.PalShapeInfoModel;
|
||||||
|
import com.actionsoft.apps.coe.pal.datamigration.position.model.PositionExcelModel;
|
||||||
|
import com.actionsoft.apps.coe.pal.datamigration.position.model.PositionValidDataModel;
|
||||||
|
import com.actionsoft.apps.coe.pal.datamigration.position.util.POIUtil;
|
||||||
|
import com.actionsoft.apps.coe.pal.datamigration.util.LogUtil;
|
||||||
|
import com.actionsoft.apps.coe.pal.datamigration.util.ProcessUtil;
|
||||||
|
import com.actionsoft.apps.coe.pal.datamigration.util.ShapeUtil;
|
||||||
|
import com.actionsoft.apps.coe.pal.datamigration.util.StrUtil;
|
||||||
|
import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodAttributeModel;
|
||||||
|
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.cache.PALRepositoryCache;
|
||||||
|
import com.actionsoft.apps.coe.pal.pal.repository.dao.PALRepository;
|
||||||
|
import com.actionsoft.apps.coe.pal.pal.repository.designer.CoeDesignerShapeAPIManager;
|
||||||
|
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.yili.log.datamigration.log.Cache.LogRealTimeCountCache;
|
||||||
|
import com.actionsoft.apps.coe.pal.yili.log.datamigration.log.Model.LogRealTimeCountModel;
|
||||||
|
import com.actionsoft.apps.resource.plugin.profile.DCPluginProfile;
|
||||||
|
import com.actionsoft.bpms.commons.mvc.view.ActionWeb;
|
||||||
|
import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
|
||||||
|
import com.actionsoft.bpms.server.UserContext;
|
||||||
|
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 org.apache.commons.lang.StringUtils;
|
||||||
|
import org.apache.poi.ss.usermodel.Cell;
|
||||||
|
import org.apache.poi.ss.usermodel.Row;
|
||||||
|
import org.apache.poi.ss.usermodel.Sheet;
|
||||||
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
|
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 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.*;
|
||||||
|
|
||||||
|
public class PositionExcelImportWeb extends ActionWeb {
|
||||||
|
|
||||||
|
UserContext _uc;
|
||||||
|
|
||||||
|
public PositionExcelImportWeb(UserContext uc) {
|
||||||
|
_uc = uc;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String logId;
|
||||||
|
private String logPath;
|
||||||
|
private File simpleLogFile;
|
||||||
|
private File fullLogFile;
|
||||||
|
private File warnLogFile;
|
||||||
|
private String filePath;
|
||||||
|
private String fileName;
|
||||||
|
private final long startTime = System.currentTimeMillis();
|
||||||
|
|
||||||
|
// Timestamp startDate = new Timestamp(System.currentTimeMillis());
|
||||||
|
|
||||||
|
|
||||||
|
public void initParams () {
|
||||||
|
logId = UUIDGener.getUUID();// 记录缓存
|
||||||
|
String fileValue = "arisXML-" + new SimpleDateFormat("yyyy-MM-dd-HHmmss").format(new Date()) + "-" + _uc.getUID();
|
||||||
|
// 创建dc目录
|
||||||
|
DCPluginProfile dcProfile = DCProfileManager.getDCProfile(Constant.APP_ID, PositionConstant.REPOSITORY_NAME);
|
||||||
|
DCContext dc = new DCContext(_uc, dcProfile, Constant.APP_ID, PositionConstant.GROUP_VALUE_LOG, fileValue);
|
||||||
|
String dirPath = dc.getPath();
|
||||||
|
File dir = new File(dirPath);
|
||||||
|
dir.mkdirs();
|
||||||
|
simpleLogFile = new File(dirPath, PositionConstant.IMPORT_LOG_FILE_SIMPLE);
|
||||||
|
try {
|
||||||
|
simpleLogFile.createNewFile();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
fullLogFile = new File(dirPath, PositionConstant.IMPORT_LOG_FILE_FULL);
|
||||||
|
try {
|
||||||
|
fullLogFile.createNewFile();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
warnLogFile = new File(dirPath, PositionConstant.IMPORT_LOG_FILE_WARN);
|
||||||
|
try {
|
||||||
|
warnLogFile.createNewFile();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
logPath = simpleLogFile.getPath();// 前端实时展示的日志
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建日志记录Model
|
||||||
|
* @param id
|
||||||
|
* @param wsId
|
||||||
|
* @param fileName
|
||||||
|
* @param filePath
|
||||||
|
* @param createDate
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private void createLogModel(String id, String wsId, String fileName, String filePath, Timestamp createDate) {
|
||||||
|
LogModel model = new LogModel();
|
||||||
|
model.setId(id);
|
||||||
|
model.setWsId(wsId);
|
||||||
|
model.setFileName(fileName);
|
||||||
|
model.setFilePath(filePath);
|
||||||
|
model.setLogPath(logPath);
|
||||||
|
model.setCreateUser(_uc.getUID());
|
||||||
|
model.setCreateUserName(_uc.getUserName());
|
||||||
|
model.setCreateDate(createDate);
|
||||||
|
model.setStartDate(createDate);
|
||||||
|
model.setResultStatus(Constant.LOG_RESULT_StATUS_RUN);
|
||||||
|
model.setMainInfo("导入进行中");
|
||||||
|
// 存储日志db
|
||||||
|
LogUtil.createLog(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入停止时更新日志db状态
|
||||||
|
* @param logFileMsg
|
||||||
|
* @param logDbMsg
|
||||||
|
*/
|
||||||
|
private void updateErrLog(String logFileMsg, String logDbMsg) {
|
||||||
|
// 记录日志
|
||||||
|
LogUtil.appendLog(logFileMsg, simpleLogFile, fullLogFile, warnLogFile);
|
||||||
|
// 日志表记录导入结果
|
||||||
|
LogUtil.updateLog(logId, new Timestamp(System.currentTimeMillis()), Constant.LOG_RESULT_StATUS_ERROR, logDbMsg);
|
||||||
|
// 清空缓存
|
||||||
|
LogRealTimeCountCache.getCache().remove(logId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 迁移测试
|
||||||
|
*
|
||||||
|
* @param wsId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String positionImport(String wsId, String groupValue, String fileValue, String fileName) {
|
||||||
|
ResponseObject ro = ResponseObject.newOkResponse();
|
||||||
|
// 初始化一些参数
|
||||||
|
initParams();
|
||||||
|
// 读取dc
|
||||||
|
DCPluginProfile dcProfile = DCProfileManager.getDCProfile(Constant.APP_ID, PositionConstant.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);
|
||||||
|
|
||||||
|
LogUtil.appendLog("\n[信息]操作人:" + _uc.getUserName() + "<" + _uc.getUID() + ">", simpleLogFile, fullLogFile, warnLogFile);
|
||||||
|
LogUtil.appendLog("[信息]操作时间:" + UtilDate.datetimeFormat(startDate), simpleLogFile, fullLogFile, warnLogFile);
|
||||||
|
LogUtil.appendLog("[信息]岗位Excel文件:" + fileName, simpleLogFile, fullLogFile, warnLogFile);
|
||||||
|
LogUtil.appendLog("[信息]岗位Excel文件路径:" + filePath, simpleLogFile, fullLogFile, warnLogFile);
|
||||||
|
|
||||||
|
LogUtil.appendLog("\n岗位Excel导入 Begin " + UtilDate.datetimeFormat(startDate), simpleLogFile, fullLogFile, warnLogFile);
|
||||||
|
|
||||||
|
LogUtil.appendLog("\n若模型(流程、角色等各类模型)存在多版本,只与模型最新版本进行匹配,过往版本忽略不进行任何处理,若最新版本模型非可编辑状态(已发布、已停用、审批中),也会进行数据更新");
|
||||||
|
|
||||||
|
String msg;
|
||||||
|
LogUtil.appendLog("\n" + Constant.LOG_START + "************[执行阶段][校验阶段]校验导入文件、属性配置等基础事项************", simpleLogFile, fullLogFile);
|
||||||
|
// 校验资产库是否存在可用
|
||||||
|
boolean isActive = PALRepositoryQueryAPIManager.getInstance().isActiveWorkSpace(wsId);
|
||||||
|
if (!isActive) {
|
||||||
|
msg = Constant.LOG_ERROR + "资产库不存在或已停用," + Constant.IMPORT_STOP_MSG;
|
||||||
|
updateErrLog(msg, msg);
|
||||||
|
ro.err("资产库不存在或已停用");
|
||||||
|
return ro.toString();
|
||||||
|
}
|
||||||
|
LogUtil.appendLog(Constant.LOG_END + "校验资产库存在并可用", simpleLogFile, fullLogFile);
|
||||||
|
|
||||||
|
// 校验文件/形状属性配置是否正常
|
||||||
|
ResponseObject checkRo = checkMethodConfig(wsId);
|
||||||
|
if (checkRo.isErr()) {
|
||||||
|
msg = Constant.LOG_ERROR + checkRo.getMsg() + "," + Constant.IMPORT_STOP_MSG;
|
||||||
|
updateErrLog(msg, msg);
|
||||||
|
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);
|
||||||
|
ro.err("上传文件不存在");
|
||||||
|
return ro.toString();
|
||||||
|
}
|
||||||
|
if (!".xls".equals(fileName.substring(fileName.lastIndexOf(".")))) {
|
||||||
|
msg = Constant.LOG_ERROR + "上传文件名称格式不正确," + Constant.IMPORT_STOP_MSG;
|
||||||
|
updateErrLog(msg, msg);
|
||||||
|
ro.err("上传文件名称格式不正确,请上传xls文件");
|
||||||
|
return ro.toString();
|
||||||
|
}
|
||||||
|
LogUtil.appendLog(Constant.LOG_END + "校验上传文件是否为xls格式", simpleLogFile, fullLogFile);
|
||||||
|
|
||||||
|
// 解析Excel
|
||||||
|
Workbook wb = POIUtil.getWorkbook(file, fileName.substring(fileName.lastIndexOf(".") + 1));
|
||||||
|
if (wb == null) {
|
||||||
|
msg = Constant.LOG_ERROR + "获取上传文件失败," + Constant.IMPORT_STOP_MSG;
|
||||||
|
updateErrLog(msg, msg);
|
||||||
|
ro.err("获取上传文件失败,请重新上传");
|
||||||
|
return ro.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
LogUtil.appendLog(Constant.LOG_END + "校验上传文件是否存在", simpleLogFile, fullLogFile);
|
||||||
|
|
||||||
|
// 解析xls标题
|
||||||
|
Sheet sheet = wb.getSheetAt(0);
|
||||||
|
List<String> titleList = new LinkedList<String>();
|
||||||
|
Row titleRow = sheet.getRow(0);
|
||||||
|
if (titleRow == null ) {
|
||||||
|
msg = Constant.LOG_ERROR + "上传文件工作表中首行为标题行,不能为空,请调整," + Constant.IMPORT_STOP_MSG;
|
||||||
|
updateErrLog(msg, msg);
|
||||||
|
ro.err("上传文件工作表中首行为标题行,不能为空,请调整");
|
||||||
|
return ro.toString();
|
||||||
|
}
|
||||||
|
int cellNum = titleRow.getLastCellNum();
|
||||||
|
for (int i = 0; i < cellNum; i++) {
|
||||||
|
Cell cell = titleRow.getCell(i);
|
||||||
|
String title = POIUtil.getCellValueByCell(cell);
|
||||||
|
if (UtilString.isEmpty(title)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
titleList.add(title);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (titleList.size() == 0) {
|
||||||
|
msg = Constant.LOG_ERROR + "上传文件工作表中首行为标题行,不能为空,请调整," + Constant.IMPORT_STOP_MSG;
|
||||||
|
updateErrLog(msg, msg);
|
||||||
|
ro.err("上传文件工作表中首行为标题行,不能为空,请调整");
|
||||||
|
return ro.toString();
|
||||||
|
}
|
||||||
|
// 校验Excel标题
|
||||||
|
ResponseObject checkTitleRo = checkExcelTitle(titleList);
|
||||||
|
if (!checkTitleRo.isOk()) {
|
||||||
|
msg = Constant.LOG_ERROR + checkTitleRo.getMsg() + "," + Constant.IMPORT_STOP_MSG;
|
||||||
|
updateErrLog(msg, msg);
|
||||||
|
ro.err(checkTitleRo.getMsg());
|
||||||
|
return ro.toString();
|
||||||
|
}
|
||||||
|
// 解析xls内容
|
||||||
|
List<PositionExcelModel> excelModelList = getExcelContent(sheet);
|
||||||
|
if (excelModelList.size() == 0) {
|
||||||
|
msg = Constant.LOG_ERROR + "上传文件工作表中内容不能为空," + Constant.IMPORT_STOP_MSG;
|
||||||
|
updateErrLog(msg, msg);
|
||||||
|
ro.err("上传文件工作表中内容不能为空");
|
||||||
|
return ro.toString();
|
||||||
|
}
|
||||||
|
// 过滤类型不是角色的
|
||||||
|
List<PositionExcelModel> excelModelList2 = new ArrayList<>();
|
||||||
|
for (PositionExcelModel model : excelModelList) {
|
||||||
|
if ("角色".equals(model.getType())) {
|
||||||
|
excelModelList2.add(model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (excelModelList2.size() == 0) {
|
||||||
|
msg = Constant.LOG_ERROR + "上传文件工作表中类型为角色的内容不能为空," + Constant.IMPORT_STOP_MSG;
|
||||||
|
updateErrLog(msg, msg);
|
||||||
|
ro.err("上传文件工作表中类型为角色的内容不能为空");
|
||||||
|
return ro.toString();
|
||||||
|
}
|
||||||
|
excelModelList = excelModelList2;
|
||||||
|
// 校验aris流程名称是否重复
|
||||||
|
Map<String, String> arisNameMap = ProcessUtil.getPalRepositoryArisNameMap(wsId);// 获取流程以及流程的aris名称
|
||||||
|
ResponseObject checkRepeatArisNameRo = checkRepositoryPropArisName(arisNameMap);
|
||||||
|
if (!checkRepeatArisNameRo.isOk()) {
|
||||||
|
msg = Constant.LOG_ERROR + checkRepeatArisNameRo.getMsg() + "," + Constant.IMPORT_STOP_MSG;
|
||||||
|
updateErrLog(msg, msg);
|
||||||
|
ro.err(checkRepeatArisNameRo.getMsg());
|
||||||
|
return ro.toString();
|
||||||
|
}
|
||||||
|
// 岗位重复校验 todo
|
||||||
|
Map<String, PalOrgPositionModel> posMap = new HashMap<>();
|
||||||
|
Map<String, List<PalOrgPositionModel>> posListMap = new HashMap<>();
|
||||||
|
List<PALRepositoryModel> posList = ProcessUtil.getLatestVerPalRepositoryListByMethodId(wsId, "org.normal");
|
||||||
|
for (PALRepositoryModel posModel : posList) {
|
||||||
|
List<JSONObject> shapeList = CoeDesignerUtil.getShapeMessageJson5(posModel.getId());
|
||||||
|
for (JSONObject shape : shapeList) {
|
||||||
|
if ("position".equals(shape.getString("name"))) {
|
||||||
|
PalOrgPositionModel positionModel = new PalOrgPositionModel();
|
||||||
|
positionModel.setOrgId(posModel.getId());
|
||||||
|
positionModel.setOrgName(posModel.getName());
|
||||||
|
positionModel.setPositionId(shape.getString("id"));
|
||||||
|
positionModel.setPositionName(StrUtil.removeAllBlack(shape.getString("text")));
|
||||||
|
if (!posListMap.containsKey(positionModel.getPositionName())) {
|
||||||
|
posListMap.put(positionModel.getPositionName(), new ArrayList<>());
|
||||||
|
}
|
||||||
|
posListMap.get(positionModel.getPositionName()).add(positionModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
boolean isOk = true;
|
||||||
|
for (Map.Entry<String, List<PalOrgPositionModel>> entry : posListMap.entrySet()) {
|
||||||
|
if (entry.getValue().size() > 1) {
|
||||||
|
List<String> nameList = new ArrayList<>();
|
||||||
|
for (PalOrgPositionModel positionModel : entry.getValue()) {
|
||||||
|
nameList.add(positionModel.getOrgName());
|
||||||
|
}
|
||||||
|
LogUtil.appendLog(Constant.LOG_ERROR + "同一岗位名称[" + entry.getKey() + "]对应多个PAL组织岗位图[" + StringUtils.join(nameList, "、") + "]", simpleLogFile, fullLogFile, simpleLogFile, fullLogFile);
|
||||||
|
isOk = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!isOk) {
|
||||||
|
msg = Constant.LOG_ERROR + "同一岗位名称出现对应多个PAL组织岗位图,详情见日志" + "," + Constant.IMPORT_STOP_MSG;
|
||||||
|
updateErrLog(msg, msg);
|
||||||
|
ro.err("同一岗位名称出现对应多个PAL组织岗位图,详情见日志");
|
||||||
|
return ro.toString();
|
||||||
|
}
|
||||||
|
for (Map.Entry<String, List<PalOrgPositionModel>> entry : posListMap.entrySet()) {
|
||||||
|
posMap.put(entry.getKey(), entry.getValue().get(0));
|
||||||
|
}
|
||||||
|
// 整合岗位数据(将流程-活动-角色下的多行岗位分类)
|
||||||
|
Map<String, List<PositionExcelModel>> map = new LinkedHashMap<>();
|
||||||
|
for (PositionExcelModel model : excelModelList) {
|
||||||
|
String key = model.getProcessName() + "_" + model.getProcessShapeName() + "_" + model.getRoleName();
|
||||||
|
if (!map.containsKey(key)) {
|
||||||
|
map.put(key, new ArrayList<>());
|
||||||
|
}
|
||||||
|
map.get(key).add(model);
|
||||||
|
}
|
||||||
|
List<PositionValidDataModel> validPosList = new ArrayList<>();
|
||||||
|
// 整合岗位数据(将流程-活动-角色下的多行岗位数据合并)
|
||||||
|
for (Map.Entry<String, List<PositionExcelModel>> entry : map.entrySet()) {
|
||||||
|
List<PositionExcelModel> list = entry.getValue();
|
||||||
|
String processName = list.get(0).getProcessName();
|
||||||
|
String processShapeName = list.get(0).getProcessShapeName();
|
||||||
|
String roleName = list.get(0).getRoleName();
|
||||||
|
|
||||||
|
PositionValidDataModel model = new PositionValidDataModel();
|
||||||
|
model.setProcessName(processName);
|
||||||
|
model.setProcessShapeName(processShapeName);
|
||||||
|
model.setRoleName(roleName);
|
||||||
|
List<String> positionList = new ArrayList<>();
|
||||||
|
for (PositionExcelModel position : list) {
|
||||||
|
if (UtilString.isNotEmpty(position.getPositionName1()) && !positionList.contains(position.getPositionName1())) {
|
||||||
|
positionList.add(position.getPositionName1());
|
||||||
|
}
|
||||||
|
if (UtilString.isNotEmpty(position.getPositionName2()) && !positionList.contains(position.getPositionName2())) {
|
||||||
|
positionList.add(position.getPositionName2());
|
||||||
|
}
|
||||||
|
if (UtilString.isNotEmpty(position.getPositionName3()) && !positionList.contains(position.getPositionName3())) {
|
||||||
|
positionList.add(position.getPositionName3());
|
||||||
|
}
|
||||||
|
if (UtilString.isNotEmpty(position.getPositionName4()) && !positionList.contains(position.getPositionName4())) {
|
||||||
|
positionList.add(position.getPositionName4());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
model.setPositionList(positionList);
|
||||||
|
validPosList.add(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 按照流程名称再次整合
|
||||||
|
Map<String, List<PositionValidDataModel>> processMap = new LinkedHashMap<>();
|
||||||
|
for (PositionValidDataModel model : validPosList) {
|
||||||
|
if (!processMap.containsKey(model.getProcessName())) {
|
||||||
|
processMap.put(model.getProcessName(), new ArrayList<>());
|
||||||
|
}
|
||||||
|
processMap.get(model.getProcessName()).add(model);
|
||||||
|
}
|
||||||
|
// Aris流程名称与PALID反转
|
||||||
|
Map<String, String> arisNameMap2 = new HashMap<>();
|
||||||
|
for (Map.Entry<String, String> entry : arisNameMap.entrySet()) {
|
||||||
|
arisNameMap2.put(entry.getValue(), entry.getKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
int totalCount = processMap.size();
|
||||||
|
// 存储缓存,导入计数
|
||||||
|
LogRealTimeCountModel countModel = new LogRealTimeCountModel();
|
||||||
|
countModel.setTotalCount(totalCount);
|
||||||
|
countModel.setSuccessCount(0);
|
||||||
|
countModel.setArisBlankCount(0);
|
||||||
|
countModel.setPalExistsCount(0);
|
||||||
|
countModel.setImportingCount(0);
|
||||||
|
countModel.setMatchFieldCount(0);
|
||||||
|
LogRealTimeCountCache.getCache().put(logId, countModel, true);
|
||||||
|
|
||||||
|
LogUtil.appendLog(Constant.LOG_END + "[执行阶段][校验阶段]", simpleLogFile, fullLogFile, simpleLogFile, fullLogFile);
|
||||||
|
|
||||||
|
LogUtil.appendLog("\n" + Constant.LOG_START + "预计导入[" + fileName + "]" + I18nRes.findValue(CoEConstant.APP_ID, Constant.PROCESS_EPC + ",共[" + totalCount + "]条流程"));
|
||||||
|
// 开始执行导入
|
||||||
|
new Thread(()->{new PositionExcelImportRun(_uc, wsId, logId, logPath, simpleLogFile, fullLogFile, warnLogFile, this.filePath, this.fileName, startTime).execute(processMap, arisNameMap2, posMap);}) .start();
|
||||||
|
|
||||||
|
ro.put("totalCount", totalCount);
|
||||||
|
ro.put("importingCount", LogRealTimeCountCache.getCache().get(logId).getImportingCount());
|
||||||
|
return ro.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验流程Aris名称
|
||||||
|
* @param arisNameMap
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private ResponseObject checkRepositoryPropArisName(Map<String, String> arisNameMap) {
|
||||||
|
boolean isOk = true;
|
||||||
|
Map<String, List<String>> map = new HashMap<>();
|
||||||
|
for (Map.Entry<String, String> entry : arisNameMap.entrySet()) {
|
||||||
|
String palId = entry.getKey();
|
||||||
|
String arisName = entry.getValue();
|
||||||
|
if (!map.containsKey(arisName)) {
|
||||||
|
map.put(arisName, new ArrayList<>());
|
||||||
|
}
|
||||||
|
map.get(arisName).add(palId);
|
||||||
|
}
|
||||||
|
for (Map.Entry<String, List<String>> entry : map.entrySet()) {
|
||||||
|
List<String> idList = entry.getValue();
|
||||||
|
String arisName = entry.getKey();
|
||||||
|
if (idList.size() > 1) {
|
||||||
|
isOk = false;
|
||||||
|
List<String> nameList = new ArrayList<>();
|
||||||
|
for (String palId : idList) {
|
||||||
|
PALRepositoryModel model = PALRepositoryCache.getCache().get(palId);
|
||||||
|
nameList.add(model.getName());
|
||||||
|
}
|
||||||
|
LogUtil.appendLog(Constant.LOG_ERROR + "同一Aris流程名称[" + arisName + "]对应多个PAL流程[" + StringUtils.join(nameList, "、") + "]", simpleLogFile, fullLogFile, simpleLogFile, fullLogFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!isOk) {
|
||||||
|
return ResponseObject.newErrResponse("存在同一Aris流程名称对应多个PAL流程,详情见日志");
|
||||||
|
}
|
||||||
|
return ResponseObject.newOkResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取Excel内容
|
||||||
|
* @param sheet
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private List<PositionExcelModel> getExcelContent(Sheet sheet) {
|
||||||
|
List<PositionExcelModel> list = new ArrayList<>();
|
||||||
|
for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) {
|
||||||
|
Row row = sheet.getRow(i);
|
||||||
|
PositionExcelModel rowModel = new PositionExcelModel();
|
||||||
|
// 流程名称
|
||||||
|
Cell cell1 = row.getCell(0);
|
||||||
|
rowModel.setProcessName(POIUtil.getCellValueByCell(cell1));
|
||||||
|
// 活动名称
|
||||||
|
Cell cell2 = row.getCell(1);
|
||||||
|
rowModel.setProcessShapeName(POIUtil.getCellValueByCell(cell2));
|
||||||
|
// 类别
|
||||||
|
Cell cell3 = row.getCell(2);
|
||||||
|
rowModel.setType(POIUtil.getCellValueByCell(cell3));
|
||||||
|
// 角色名称
|
||||||
|
Cell cell4 = row.getCell(3);
|
||||||
|
rowModel.setRoleName(POIUtil.getCellValueByCell(cell4));
|
||||||
|
// 现在岗位名称1
|
||||||
|
Cell cell5 = row.getCell(4);
|
||||||
|
rowModel.setPositionName1(POIUtil.getCellValueByCell(cell5));
|
||||||
|
// 现在岗位名称2
|
||||||
|
Cell cell6 = row.getCell(5);
|
||||||
|
rowModel.setPositionName2(POIUtil.getCellValueByCell(cell6));
|
||||||
|
// 现在岗位名称3
|
||||||
|
Cell cell7 = row.getCell(6);
|
||||||
|
rowModel.setPositionName3(POIUtil.getCellValueByCell(cell7));
|
||||||
|
// 现在岗位名称4
|
||||||
|
Cell cell8 = row.getCell(7);
|
||||||
|
rowModel.setPositionName4(POIUtil.getCellValueByCell(cell8));
|
||||||
|
list.add(rowModel);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验Excel标题
|
||||||
|
* @param titleList
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private ResponseObject checkExcelTitle(List<String> titleList) {
|
||||||
|
ResponseObject ro = ResponseObject.newOkResponse();
|
||||||
|
if (titleList.size() < PositionConstant.EXCEL_TITLE_ROW_ARR.length) {
|
||||||
|
ro.err("上传文件工作表中标题行错误,请按照" + PositionConstant.EXCEL_TITLE_ROW + "的格式填写");
|
||||||
|
return ro;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < PositionConstant.EXCEL_TITLE_ROW_ARR.length; i++) {
|
||||||
|
if (!PositionConstant.EXCEL_TITLE_ROW_ARR[i].equals(titleList.get(i))) {
|
||||||
|
ro.err("上传文件工作表中标题行错误,请按照" + PositionConstant.EXCEL_TITLE_ROW + "的格式填写,若有隐藏列,请移动至最后");
|
||||||
|
return ro;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ro;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计EPC流程图个数,用以展示进度
|
||||||
|
* @param modelMap
|
||||||
|
*/
|
||||||
|
// private int countProcessMainInfo(Map<String, ModelModel> modelMap) {
|
||||||
|
// int count = 0;
|
||||||
|
//// for (Map.Entry<String, ModelModel> entry : modelMap.entrySet()) {
|
||||||
|
//// ModelModel model = entry.getValue();
|
||||||
|
//// if ("MT_EEPC".equals(model.getType())) {
|
||||||
|
//// count++;
|
||||||
|
//// }
|
||||||
|
//// }
|
||||||
|
// return count;
|
||||||
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验文件/形状属性是否存在
|
||||||
|
* @param wsId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private ResponseObject checkMethodConfig(String wsId) {
|
||||||
|
// 校验EPC图的文件属性
|
||||||
|
// 校验Aris地址、Aris流程名称属性
|
||||||
|
ResponseObject checkRo = checkMethodAttrExist(wsId, Constant.PROCESS_EPC, null, Constant.METHOD_ARIS_URL, Constant.METHOD_ARIS_NAME);
|
||||||
|
if (checkRo.isErr()) {
|
||||||
|
return checkRo;
|
||||||
|
}
|
||||||
|
// 校验epc流程图的形状属性是否配置
|
||||||
|
// 校验线上审批的角色
|
||||||
|
checkRo = checkMethodAttrExist(wsId, Constant.PROCESS_EPC, Constant.METHOD_APPROVAL_NODE, Constant.METHOD_ROLE);
|
||||||
|
if (checkRo.isErr()) {
|
||||||
|
return checkRo;
|
||||||
|
}
|
||||||
|
// 校验线下审批的角色
|
||||||
|
checkRo = checkMethodAttrExist(wsId, Constant.PROCESS_EPC, Constant.METHOD_SERVICE_NODE, Constant.METHOD_ROLE);
|
||||||
|
if (checkRo.isErr()) {
|
||||||
|
return checkRo;
|
||||||
|
}
|
||||||
|
// 校验系统任务的角色
|
||||||
|
checkRo = checkMethodAttrExist(wsId, Constant.PROCESS_EPC, Constant.METHOD_APPROVAL_NODE3, Constant.METHOD_ROLE);
|
||||||
|
if (checkRo.isErr()) {
|
||||||
|
return checkRo;
|
||||||
|
}
|
||||||
|
// 校验人工任务的角色
|
||||||
|
checkRo = checkMethodAttrExist(wsId, Constant.PROCESS_EPC, Constant.METHOD_SERVICE_NODE4, Constant.METHOD_ROLE);
|
||||||
|
if (checkRo.isErr()) {
|
||||||
|
return checkRo;
|
||||||
|
}
|
||||||
|
// 校验角色图的岗位属性
|
||||||
|
checkRo = checkMethodAttrExist(wsId, Constant.ORG_ROLE, Constant.METHOD_ROLE, Constant.METHOD_POST);
|
||||||
|
if (checkRo.isErr()) {
|
||||||
|
return checkRo;
|
||||||
|
}
|
||||||
|
return ResponseObject.newOkResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验属性是否存在
|
||||||
|
* @param methodId
|
||||||
|
* @param shapeName
|
||||||
|
* @param attrs
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private ResponseObject checkMethodAttrExist(String wsId, String methodId, String shapeName, String ... attrs) {
|
||||||
|
String methodName = I18nRes.findValue(CoEConstant.APP_ID, methodId);
|
||||||
|
// 形状属性校验
|
||||||
|
if (UtilString.isNotEmpty(shapeName)) {
|
||||||
|
JSONObject shape = ShapeUtil.getProcessShapeDefinitionByName(methodId, shapeName);
|
||||||
|
if (isEmptyJsonOject(shape)) {
|
||||||
|
String msg = Constant.LOG_ERROR + "模型[" + methodName + "]中的形状[" + shapeName + "]不存在," + Constant.IMPORT_STOP_MSG;
|
||||||
|
updateErrLog(msg, msg);
|
||||||
|
return ResponseObject.newErrResponse("模型[" + methodName + "]中的形状[" + shapeName + "]不存在");
|
||||||
|
}
|
||||||
|
String shapeText = shape.getString("text");
|
||||||
|
List<PALMethodAttributeModel> list = CoeDesignerShapeAPIManager.getInstance().getValidAndUseAttributeModels(wsId, methodId, shapeName, methodId);
|
||||||
|
Map<String, PALMethodAttributeModel> attrMap = new HashMap<>();
|
||||||
|
for (PALMethodAttributeModel attrModel : list) {
|
||||||
|
attrMap.put(attrModel.getKey(), attrModel);
|
||||||
|
}
|
||||||
|
List<PALMethodAttributeModel> list2 = CoeDesignerShapeAPIManager.getInstance().getValidAttributeModels(wsId, methodId, shapeName, methodId);
|
||||||
|
Map<String, PALMethodAttributeModel> attrMap2 = new HashMap<>();
|
||||||
|
for (PALMethodAttributeModel attrModel : list2) {
|
||||||
|
attrMap2.put(attrModel.getKey(), attrModel);
|
||||||
|
}
|
||||||
|
for (String attrId : attrs) {
|
||||||
|
String text = attrMap2.containsKey(attrId) ? attrMap2.get(attrId).getNewTitle() : attrId;
|
||||||
|
if (!attrMap.containsKey(attrId)) {
|
||||||
|
String msg = Constant.LOG_ERROR + "[" + methodName + "]中的形状[" + shapeText + "]属性[" + text + "]不存在,请检查相应属性配置," + Constant.IMPORT_STOP_MSG;
|
||||||
|
updateErrLog(msg, msg);
|
||||||
|
return ResponseObject.newErrResponse("[" + methodName + "]中的形状[" + shapeText + "]属性[" + text + "]不存在");
|
||||||
|
}
|
||||||
|
LogUtil.appendLog(Constant.LOG_END + "校验[" + methodName + "]中的形状[" + shapeText + "]属性[" + text + "]", simpleLogFile, fullLogFile);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 文件属性校验
|
||||||
|
List<PALMethodAttributeModel> list = PALRepositoryAPIManager.getInstance().getValidAndUseAttributeModels(wsId, methodId);
|
||||||
|
Map<String, PALMethodAttributeModel> attrMap = new HashMap<>();
|
||||||
|
for (PALMethodAttributeModel attrModel : list) {
|
||||||
|
attrMap.put(attrModel.getKey(), attrModel);
|
||||||
|
}
|
||||||
|
List<PALMethodAttributeModel> list2 = PALRepositoryAPIManager.getInstance().getValidAttributeModels(wsId, methodId);
|
||||||
|
Map<String, PALMethodAttributeModel> attrMap2 = new HashMap<>();
|
||||||
|
for (PALMethodAttributeModel attrModel : list2) {
|
||||||
|
attrMap2.put(attrModel.getKey(), attrModel);
|
||||||
|
}
|
||||||
|
for (String attrId : attrs) {
|
||||||
|
String text = attrMap2.containsKey(attrId) ? attrMap2.get(attrId).getNewTitle() : attrId;
|
||||||
|
if (!attrMap.containsKey(attrId)) {
|
||||||
|
|
||||||
|
String msg = Constant.LOG_ERROR + "[" + methodName + "]的文件属性[" + text + "]不存在,请检查相应属性配置," + Constant.IMPORT_STOP_MSG;
|
||||||
|
updateErrLog(msg, msg);
|
||||||
|
return ResponseObject.newErrResponse("[" + methodName + "]的文件属性[" + text + "]不存在");
|
||||||
|
}
|
||||||
|
LogUtil.appendLog(Constant.LOG_END + "校验[" + methodName + "]的文件属性[" + text + "]", simpleLogFile, fullLogFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ResponseObject.newOkResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验是否为空的对象
|
||||||
|
* @param o
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private boolean isEmptyJsonOject(JSONObject o) {
|
||||||
|
return o == null || o.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询导入流程日志
|
||||||
|
* @param logId
|
||||||
|
* @param path
|
||||||
|
* @param timer
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String queryPositionExcelImportLog(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);
|
||||||
|
|
||||||
|
LogRealTimeCountModel countCache = LogRealTimeCountCache.getCache().get(logId);
|
||||||
|
int importingCount = 0;
|
||||||
|
int resultStatus = Constant.LOG_RESULT_StATUS_RUN;
|
||||||
|
if (countCache != null) {
|
||||||
|
importingCount = countCache.getImportingCount();
|
||||||
|
} else {
|
||||||
|
resultStatus = LogUtil.queryLog(logId).getResultStatus();
|
||||||
|
}
|
||||||
|
ro.put("resultStatus", resultStatus);
|
||||||
|
ro.put("importingCount", importingCount);
|
||||||
|
return ro.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载日志
|
||||||
|
* @param logId
|
||||||
|
* @param path
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String downloadPositionExcelImportLog(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, PositionConstant.REPOSITORY_NAME);
|
||||||
|
DCContext dc = new DCContext(_uc, dcProfile, Constant.APP_ID, PositionConstant.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, PositionConstant.GROUP_VALUE_DOWNLOAD, file.getParentFile().getName(), targetFileName);
|
||||||
|
String url = dc2.getDownloadURL();
|
||||||
|
ResponseObject ro = ResponseObject.newOkResponse();
|
||||||
|
ro.put("url", url + "&isInline=false");
|
||||||
|
return ro.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -325,5 +325,49 @@ public class ProcessUtil {
|
|||||||
}
|
}
|
||||||
return propValMap;
|
return propValMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取指定建模方法模型列表
|
||||||
|
* @param wsId
|
||||||
|
* @param methodId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static List<PALRepositoryModel> getLatestVerPalRepositoryListByMethodId(String wsId, String methodId) {
|
||||||
|
Map<String, String> propValMap = new HashMap<>();
|
||||||
|
Iterator<PALRepositoryModel> iterator = PALRepositoryCache.getByWsId(wsId);
|
||||||
|
List<PALRepositoryModel> list = new ArrayList<>();
|
||||||
|
|
||||||
|
if (UtilString.isNotEmpty(methodId)) {
|
||||||
|
// 过滤method
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
PALRepositoryModel model = iterator.next();
|
||||||
|
if (UtilString.isNotEmpty(methodId)) {
|
||||||
|
if (methodId.equals(model.getMethodId())) {
|
||||||
|
list.add(model);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
list.add(model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 找到最新版本,只匹配最新版本(在日志中添加此明显提示)
|
||||||
|
List<PALRepositoryModel> recentVerList = new ArrayList<>();
|
||||||
|
Map<String, PALRepositoryModel> modelMap = new HashMap<>();
|
||||||
|
for (PALRepositoryModel model : list) {
|
||||||
|
if (!modelMap.containsKey(model.getVersionId())) {
|
||||||
|
modelMap.put(model.getVersionId(), model);
|
||||||
|
} else {
|
||||||
|
if (modelMap.get(model.getVersionId()).getVersion() < model.getVersion()) {
|
||||||
|
modelMap.put(model.getVersionId(), model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (Map.Entry<String, PALRepositoryModel> entry : modelMap.entrySet()) {
|
||||||
|
recentVerList.add(entry.getValue());
|
||||||
|
}
|
||||||
|
list = recentVerList;
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import com.actionsoft.apps.coe.pal.datamigration.aris.web.ArisXmlImportWeb;
|
|||||||
import com.actionsoft.apps.coe.pal.datamigration.constant.Constant;
|
import com.actionsoft.apps.coe.pal.datamigration.constant.Constant;
|
||||||
import com.actionsoft.apps.coe.pal.datamigration.model.po.AwsOrgInfo;
|
import com.actionsoft.apps.coe.pal.datamigration.model.po.AwsOrgInfo;
|
||||||
import com.actionsoft.apps.coe.pal.datamigration.model.po.WordField;
|
import com.actionsoft.apps.coe.pal.datamigration.model.po.WordField;
|
||||||
|
import com.actionsoft.apps.coe.pal.datamigration.position.web.PositionExcelImportWeb;
|
||||||
import com.actionsoft.apps.coe.pal.datamigration.util.*;
|
import com.actionsoft.apps.coe.pal.datamigration.util.*;
|
||||||
import com.actionsoft.apps.coe.pal.datamigration.util.readword.CreateMaps;
|
import com.actionsoft.apps.coe.pal.datamigration.util.readword.CreateMaps;
|
||||||
import com.actionsoft.apps.coe.pal.datamigration.util.readword.ReadWordUtil;
|
import com.actionsoft.apps.coe.pal.datamigration.util.readword.ReadWordUtil;
|
||||||
@ -920,4 +921,16 @@ public class DataMigrationWeb extends ActionWeb {
|
|||||||
ro.put("name", plModel.getName());
|
ro.put("name", plModel.getName());
|
||||||
return ro.toString();
|
return ro.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 岗位导入执行
|
||||||
|
* @param wsId
|
||||||
|
* @param groupValue
|
||||||
|
* @param fileValue
|
||||||
|
* @param fileName
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String positionImport(String wsId, String groupValue, String fileValue, String fileName) {
|
||||||
|
return new PositionExcelImportWeb(_uc).positionImport(wsId, groupValue, fileValue, fileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,8 +22,8 @@
|
|||||||
const production = true;
|
const production = true;
|
||||||
const devUserInfo = {};
|
const devUserInfo = {};
|
||||||
</script>
|
</script>
|
||||||
<script type="module" crossorigin src="../apps/com.actionsoft.apps.coe.pal.datamigration/main/js/entry-index-3ad8e044.js"></script>
|
<script type="module" crossorigin src="../apps/com.actionsoft.apps.coe.pal.datamigration/main/js/entry-index-4d9d5df5.js"></script>
|
||||||
<link rel="stylesheet" href="../apps/com.actionsoft.apps.coe.pal.datamigration/main/assets/asset-style-0d4d4c3a.css">
|
<link rel="stylesheet" href="../apps/com.actionsoft.apps.coe.pal.datamigration/main/assets/asset-style-1286d7e8.css">
|
||||||
</head>
|
</head>
|
||||||
<body style="margin:0;">
|
<body style="margin:0;">
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
|
|||||||
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
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user