批量清单上传

This commit is contained in:
446052889@qq.com 2022-07-14 16:42:25 +08:00
parent aff4b3ad7c
commit ee955c8d6a
36 changed files with 1659 additions and 678 deletions

View File

@ -34,9 +34,9 @@ public class BatchController {
* @return
*/
@Mapping("com.actionsoft.apps.coe.pal.batch_create_download_template")
public String getDownloadTemplateUrl(UserContext uc, String type, String wsId, String versionIds) {
public String getDownloadTemplateUrl(UserContext uc, String type, String wsId, String versionIds, String methodCategory) {
BatchWeb web = new BatchWeb(uc);
return web.getDownloadTemplateUrl(type, wsId, versionIds);
return web.getDownloadTemplateUrl(type, wsId, versionIds, methodCategory);
}
/**
@ -102,9 +102,9 @@ public class BatchController {
* @return
*/
@Mapping("com.actionsoft.apps.coe.pal.batch_create_process_data_check")
public String checkProcessData(UserContext uc, String wsId, String teamId, String type, String fileValue, String fileName) {
public String checkProcessData(UserContext uc, String wsId, String teamId, String type, String fileValue, String fileName, String methodCategory) {
BatchWeb web = new BatchWeb(uc);
return web.checkProcessData(wsId, teamId, type, fileValue, fileName);
return web.checkProcessData(wsId, teamId, type, fileValue, fileName, methodCategory);
}
/**
@ -114,9 +114,9 @@ public class BatchController {
* @return
*/
@Mapping("com.actionsoft.apps.coe.pal.batch_create_data_save")
public String saveBatchCreateData(UserContext uc, String param) {
public String saveBatchCreateData(UserContext uc, String param, String methodCategory) {
BatchWeb web = new BatchWeb(uc);
return web.saveBatchCreateData(param);
return web.saveBatchCreateData(param, methodCategory);
}
/**

View File

@ -33,5 +33,19 @@ public class BatchConst {
// 日志结束语
public static final String END_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流程匹配失败的
// 日志常量记录
public static final String LOG_SUCCESS = "[成功]";
public static final String LOG_WARNING = "[警告]";
public static final String LOG_ERROR = "[错误]";
// 日志导入开始节点
public static final String LOG_START = "[开始]";
// 日志导入完成节点
public static final String LOG_END = "[完成]";
public static final String LOG_DESC = "[说明]";
}

View File

@ -23,6 +23,7 @@ import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache;
import com.actionsoft.apps.coe.pal.pal.repository.designer.CoeDesignerShapeAPIManager;
import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel;
import com.actionsoft.apps.coe.pal.yili.log.batch.cache.BatchCache;
import com.actionsoft.apps.coe.pal.yili.log.datamigration.log.Cache.LogRealTimeCountCache;
import com.actionsoft.apps.resource.plugin.profile.DCPluginProfile;
import com.actionsoft.bpms.commons.htmlframework.HtmlPageTemplate;
import com.actionsoft.bpms.commons.mvc.view.ActionWeb;
@ -89,9 +90,10 @@ public class BatchWeb extends ActionWeb {
* @param type processList: 流程清单模版 shapeList:流程结构模版
* @param wsId
* @param versionIds 流程版本Id集合type为shapeList时有效
* @param methodCategory 大类
* @return
*/
public String getDownloadTemplateUrl(String type, String wsId, String versionIds) {
public String getDownloadTemplateUrl(String type, String wsId, String versionIds, String methodCategory) {
// 校验资产库
boolean isActive = PALRepositoryQueryAPIManager.getInstance().isActiveWorkSpace(wsId);
if (!isActive) {
@ -99,7 +101,7 @@ public class BatchWeb extends ActionWeb {
}
ResponseObject ro = ResponseObject.newOkResponse();
if (BatchConst.PROCESS_LIST.equals(type)) {
ro = new CreateProcessExcel().createProcessTemplate(uc, wsId);
ro = new CreateProcessExcel().createProcessTemplate(uc, wsId, methodCategory);
} else if (BatchConst.SHAPE_LIST.equals(type)) {
ro = new CreateShapeExcel().createShapeTemplate(uc, wsId, versionIds);
}
@ -267,7 +269,7 @@ public class BatchWeb extends ActionWeb {
* @param fileName
* @return
*/
public String checkProcessData(String wsId, String teamId, String type, String fileValue, String fileName) {
public String checkProcessData(String wsId, String teamId, String type, String fileValue, String fileName, String methodCategory) {
DCPluginProfile dcProfile = DCProfileManager.getDCProfile(BatchConst.APP_ID, BatchConst.TMP);
DCContext dc = new DCContext(uc, dcProfile, BatchConst.APP_ID, BatchConst.UPLOAD, fileValue, fileName);
File file = new File(dc.getFilePath());
@ -280,7 +282,7 @@ public class BatchWeb extends ActionWeb {
return ro.toString();
}
if ("processList".equals(type)) {// 流程清单校验
return new ValidProcessExcel(uc).checkProcessList(file, wsId).toString();
return new ValidProcessExcel(uc).checkProcessList(file, wsId, methodCategory).toString();
}
if ("shapeList".equals(type)) {// 模型结构上传
return new ValidShapeExcel().checkShapeList(uc, file, wsId, teamId).toString();
@ -293,7 +295,7 @@ public class BatchWeb extends ActionWeb {
* @param param
* @return
*/
public String saveBatchCreateData(String param) {
public String saveBatchCreateData(String param, String methodCategory) {
JSONObject object = JSONObject.parseObject(param);
String type = object.getString("type");
String simpleLogName = "simpleCreate.log";
@ -329,7 +331,7 @@ public class BatchWeb extends ActionWeb {
logPath = simpleLogFile.getPath();
if ("processList".equals(type)) {// 流程清单保存
new Thread(()->{new ImportProcessExcel().execute(uc, object, simpleLogFile, fullLogFile, logId);}) .start();
new Thread(()->{new ImportProcessExcel().execute(uc, object, simpleLogFile, fullLogFile, logId, methodCategory);}) .start();
}
if ("shapeList".equals(type)) {// 模型结构保存
new Thread(()->{new ImportShapeExcel().execute(uc, object, simpleLogFile, fullLogFile, logId);}) .start();
@ -354,9 +356,16 @@ public class BatchWeb extends ActionWeb {
public String queryBatchCreateLog(String type, String logId, String path, String timer) {
String content = "";
if (new File(path).exists()) {
if (BatchCache.getCache().get(logId) == null) {
timer = "";
if ("processList".equals(type)) {// 流程清单保存
if (LogRealTimeCountCache.getCache().get(logId) == null) {
timer = "";
}
} else if ("shapeList".equals(type)) {// 模型结构保存
if (BatchCache.getCache().get(logId) == null) {
timer = "";
}
}
content = LogUtil.getLogContent(new File(path));
}
ResponseObject ro = ResponseObject.newOkResponse();

View File

@ -30,19 +30,20 @@ import com.actionsoft.bpms.util.UtilFile;
public class CreateProcessExcel {
public ResponseObject createProcessTemplate(UserContext uc, String wsId) {
public ResponseObject createProcessTemplate(UserContext uc, String wsId, String methodCategory) {
// 获取当前资产库流程下的所有类别
List<String> categorys = ProcessUtil.getProcessCategory();
ResponseObject ro = ResponseObject.newOkResponse();
ro.put("url", createExcelTemplate(uc, categorys));
ro.put("url", createExcelTemplate(uc, categorys, methodCategory));
return ro;
}
/**
* 创建Excel模版
* @param categorys
* @param methodCategory
*/
private String createExcelTemplate(UserContext uc, List<String> categorys) {
private String createExcelTemplate(UserContext uc, List<String> categorys, String methodCategory) {
String groupValue = "template";
String fileValue = UUIDGener.getUUID();
DCPluginProfile dcProfile = DCProfileManager.getDCProfile(BatchConst.APP_ID, BatchConst.TMP);
@ -58,8 +59,8 @@ public class CreateProcessExcel {
}
try {
XSSFWorkbook wb = new XSSFWorkbook();// 创建Excel工作簿对象
// 流程清单页签
XSSFSheet sheet = wb.createSheet(ProcessConst.SHEET_NAME);// 创建工作表对象
// 模型清单页签
XSSFSheet sheet = wb.createSheet(ProcessUtil.getModelListName(methodCategory));// 创建工作表对象
// 编号名称文件类型描述/定义责任部门责任人扩展<xxx>...
XSSFRow titleRow = sheet.createRow(0);
titleRow.setHeightInPoints(25);
@ -70,19 +71,27 @@ public class CreateProcessExcel {
List<XSSFCell> titleList = new ArrayList<>();
int index = 0;
//  编号
titleList.add(titleRow.createCell((short)index));
titleList.get((short)index).setCellStyle(cellStyle);
titleList.get((short)index).setCellValue(ProcessConst.TABLE_NO);
sheet.setColumnWidth((short)index, 3000);// 设置当前列宽度
index++;
// titleList.add(titleRow.createCell((short)index));
// titleList.get((short)index).setCellStyle(cellStyle);
// titleList.get((short)index).setCellValue(ProcessConst.TABLE_NO);
// sheet.setColumnWidth((short)index, 3000);// 设置当前列宽度
//
// index++;
//
// 名称
titleList.add(titleRow.createCell((short)index));
titleList.get((short)index).setCellStyle(cellStyle);
titleList.get((short)index).setCellValue(ProcessConst.TABLE_NAME);
sheet.setColumnWidth((short)index, 13000);// 设置当前列宽度
index++;
// 上级名称
titleList.add(titleRow.createCell((short)index));
titleList.get((short)index).setCellStyle(cellStyle);
titleList.get((short)index).setCellValue(ProcessConst.TABLE_PARENT_NAME);
sheet.setColumnWidth((short)index, 13000);// 设置当前列宽度
index++;
// 文件类型

View File

@ -7,7 +7,7 @@ package com.actionsoft.apps.coe.pal.batch.web.create.process;
public class ProcessConst {
// Excel工作表sheet页名称
public final static String SHEET_NAME = "流程清单";
public final static String SHEET_NAME_SUFFIX = "清单";
public final static String SHEET_HELPER = "说明";
// 扩展属性名称前后缀
@ -17,14 +17,15 @@ public class ProcessConst {
// 表格表头
public final static String TABLE_NO = "编号";
public final static String TABLE_NAME = "名称";
public final static String TABLE_PARENT_NAME = "上级名称";
public final static String TABLE_TYPE = "文件类型";
public final static String TABLE_EXTAND_EXAMPLE = "扩展<xxx>";
public final static String TABLE_EXTAND_EXAMPLE2 = "...";
// 表格表头
public final static String [] PROCESS_TITLE_ROW = new String [] {TABLE_NO, TABLE_NAME, TABLE_TYPE};
public final static String PROCESS_BASE_TITLE_ROW = "编号、名称、文件类型";
public final static String PROCESS_EXAMPLE_TITLE_ROW = "编号、名称、文件类型、扩展&lt;xxx&gt;、扩展&lt;xxx&gt;、...";
public final static String [] PROCESS_TITLE_ROW = new String [] {TABLE_NAME, TABLE_PARENT_NAME, TABLE_TYPE};
public final static String PROCESS_BASE_TITLE_ROW = "名称、上级名称、文件类型";
public final static String PROCESS_EXAMPLE_TITLE_ROW = "名称、文件类型、扩展&lt;xxx&gt;、扩展&lt;xxx&gt;、...";

View File

@ -1,6 +1,8 @@
package com.actionsoft.apps.coe.pal.batch.web.create.process;
import com.actionsoft.apps.AppsConst;
import com.actionsoft.apps.coe.pal.CoeComponentsController;
import com.actionsoft.apps.coe.pal.batch.web.create.process.model.RepositoryInfoModel;
import com.actionsoft.apps.coe.pal.constant.CoEConstant;
import com.actionsoft.apps.coe.pal.pal.method.PALMethodManager;
import com.actionsoft.apps.coe.pal.pal.method.cache.PALMethodCache;
@ -8,24 +10,36 @@ import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodAttributeModel;
import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodModel;
import com.actionsoft.apps.coe.pal.pal.repository.PALRepositoryAPIManager;
import com.actionsoft.apps.coe.pal.pal.repository.PALRepositoryQueryAPIManager;
import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache;
import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel;
import com.actionsoft.apps.lifecycle.api.AppsAPIManager;
import com.actionsoft.apps.resource.AppContext;
import com.actionsoft.bpms.server.UserContext;
import com.actionsoft.i18n.I18nRes;
import com.actionsoft.sdk.local.SDK;
import com.alibaba.fastjson.JSONObject;
import java.util.*;
public class ProcessUtil {
/**
* 获取模型清单名称
* @param methodCategory
* @return
*/
public static String getModelListName(String methodCategory) {
return I18nRes.findValue(CoEConstant.APP_ID, methodCategory) + ProcessConst.SHEET_NAME_SUFFIX;
}
/**
* 获取流程下文件分类
* @return
*/
@Deprecated
public static List<String> getProcessCategory() {
List<String> list = new ArrayList<String>();
list.add("简单文件分类");
list.add("文件夹");
List<PALMethodModel> methodModels = PALMethodManager.getInstance().getPALMethodModelListByMethod("process");
List<AppContext> listApps = AppsAPIManager.getInstance().getInstalledApps();
int size = listApps.size();
@ -75,7 +89,7 @@ public class ProcessUtil {
}
return list;
}
/**
* 获取流程下文件分类
* @return
@ -106,9 +120,10 @@ public class ProcessUtil {
* 获取流程下文件分类
* @return
*/
@Deprecated
public static Map<String, String> getProcessCategoryMethod() {
Map<String, String> result = new HashMap<>();
result.put("简单文件分类", "default");
result.put("文件夹", "default");
List<PALMethodModel> methodModels = PALMethodManager.getInstance().getPALMethodModelListByMethod("process");
List<AppContext> listApps = AppsAPIManager.getInstance().getInstalledApps();
int size = listApps.size();
@ -159,14 +174,62 @@ public class ProcessUtil {
return result;
}
/**
* 获取根目录下文件分类
* @param category
* @param reverse false获取结果keymethodIdvaluemethodName true获取结果keymethodNamevaluemethodId
* @return
*/
public static JSONObject getCategoryMethods(String category, boolean reverse) {
JSONObject result = new JSONObject();
result.put("default", "文件夹");
List<PALMethodModel> methodModels = PALMethodManager.getInstance().getPALMethodModelListByMethod(category);
List<AppContext> listApps = AppsAPIManager.getInstance().getInstalledApps();
int size = listApps.size();
Map<String, String> map1 = new HashMap<String, String>();
for (int i = 0; i < size; i++) {
map1.put(listApps.get(i).getId(), listApps.get(i).getRuntimeState());
}
for (int i = 0, methodSize = methodModels.size(); i < methodSize; i++) {
PALMethodModel palMethodModel = methodModels.get(i);
String appId = palMethodModel.getId();
if (map1.containsKey("com.actionsoft.apps.coe.method." + appId)) {
String methodId1 = map1.get("com.actionsoft.apps.coe.method." + appId);
if (methodId1.equals(AppsConst.RUNTIME_STATE_STOPPED) || methodId1.equals(AppsConst.RUNTIME_STATE_FAILED) || methodId1.equals(AppsConst.RUNTIME_STATE_READY) || methodId1.equals(AppsConst.RUNTIME_STATE_STARTING) || methodId1.equals(AppsConst.RUNTIME_STATE_STOPPING) || methodId1.equals(AppsConst.RUNTIME_STATE_UNINSTALLED) || methodId1.equals(AppsConst.RUNTIME_STATE_UNINSTALLING) || methodId1.equals(AppsConst.RUNTIME_STATE_FAILED))
continue;
}
result.put(palMethodModel.getId(), I18nRes.findValue(CoEConstant.APP_ID, palMethodModel.getId()));
}
if ("process".equals(category)) {// 伊利流程类型下增加表单图和制度图
PALMethodModel palMethodModel = PALMethodManager.getInstance().getPALMethodModelById("control.policy");
if (palMethodModel != null) {
result.put(palMethodModel.getId(), I18nRes.findValue(CoEConstant.APP_ID, palMethodModel.getId()));
}
palMethodModel = PALMethodManager.getInstance().getPALMethodModelById("data.form");
if (palMethodModel != null) {
result.put(palMethodModel.getId(), I18nRes.findValue(CoEConstant.APP_ID, palMethodModel.getId()));
}
}
if (reverse) {// key value反转
JSONObject reverseResult = new JSONObject();
for (String key : result.keySet()) {
reverseResult.put(result.getString(key), key);
}
return reverseResult;
}
return result;
}
/**
* 获取流程下文件分类
*
* @return
*/
@Deprecated
public static JSONObject getProcessMethods() {
JSONObject result = new JSONObject();
result.put("default", "简单文件分类");
result.put("default", "文件夹");
List<PALMethodModel> methodModels = PALMethodManager.getInstance().getPALMethodModelListByMethod("process");
List<AppContext> listApps = AppsAPIManager.getInstance().getInstalledApps();
int size = listApps.size();
@ -188,9 +251,9 @@ public class ProcessUtil {
return result;
}
public static Set<String> getProcessMethodAttrNames(String wsId) {
public static Set<String> getProcessMethodAttrNames(String wsId, String methodCategory) {
Set<String> result = new HashSet<>();
List<PALMethodModel> methodIdList = PALMethodCache.getPALMethodModelListByMethod("process");
List<PALMethodModel> methodIdList = PALMethodCache.getPALMethodModelListByMethod(methodCategory);
for (PALMethodModel methodModel : methodIdList) {
List<PALMethodAttributeModel> attributeModelList = PALRepositoryAPIManager.getInstance().getValidAttributeModels(wsId, methodModel.getId());
for (PALMethodAttributeModel attributeModel : attributeModelList) {
@ -243,11 +306,8 @@ public class ProcessUtil {
* @return
*/
public static boolean isView(PALRepositoryModel model) {
if (model.isPublish() || model.isApproval() || model.isStop()) {
return true;
}
return false;
}
return model.isPublish() || model.isApproval() || model.isStop();
}
/**
*
@ -257,10 +317,95 @@ public class ProcessUtil {
public static boolean isBlank(UserContext uc, PALRepositoryModel model) {
String define = PALRepositoryQueryAPIManager.getInstance().getProcessDefinition(uc, model.getId());
JSONObject array = JSONObject.parseObject(define);
if (array.containsKey("elements") && array.getJSONObject("elements").size() == 0) {
return true;
return array.containsKey("elements") && array.getJSONObject("elements").size() == 0;
}
/**
* 去除字符串所有空格增加处理特殊空格ASCII码值为160
* @param str
* @return
*/
public static String removeAllBlack(String str) {
return str == null ? "" : str.replaceAll("\\u00A0+", "").replace(" ", "");
}
/**
* 将PAL模型转换为批处理特定模型包含名称上级名称ID以及在资产库中存在的标识
* @param list
* @param category
* @return
*/
public static List<RepositoryInfoModel> palRepository2RepositoryInfoList(List<PALRepositoryModel> list, String category) {
List<RepositoryInfoModel> result = new ArrayList<>();
for (PALRepositoryModel model : list) {
RepositoryInfoModel infoModel = new RepositoryInfoModel();
infoModel.setId(model.getId());
infoModel.setName(removeAllBlack(model.getName()));
infoModel.setPalModel(true);
infoModel.setMethodId(model.getMethodId());
infoModel.setMethodName(I18nRes.findValue(CoEConstant.APP_ID, model.getMethodId()));
PALRepositoryModel parentModel = getParentRepositoryModel(model.getParentId());
if (parentModel == null) {
infoModel.setParentId(category);
infoModel.setParentName(I18nRes.findValue(CoEConstant.APP_ID, category));
} else {
infoModel.setParentId(parentModel.getId());// 最新版本的ID
infoModel.setParentName(removeAllBlack(parentModel.getName()));
}
infoModel.setPathId(new ArrayList<>());
infoModel.setPathName(new ArrayList<>());
result.add(infoModel);
}
return false;
return result;
}
// 获取父节点
private static PALRepositoryModel getParentRepositoryModel(String parentId) {
if (parentId.length() < 36) {
return null;
} else {
PALRepositoryModel parentModel = PALRepositoryCache.getCache().get(parentId);
if (parentModel == null) {
List<PALRepositoryModel> verList = PALRepositoryCache.getByVersionId(parentId);
if (verList.size() > 0) {
parentModel = verList.get(0);
}
}
if (parentModel != null) {
List<PALRepositoryModel> verList = PALRepositoryCache.getByVersionId(parentModel.getVersionId());
verList.sort((p1, p2) -> {return (p1.getVersion() - p2.getVersion() >= 0) ? 1 : -1;});
return verList.get(0);
}
}
return null;
}
/**
* 获取指定根目录下所有的最新版本模型列表
* @param wsId
* @param category 根节点分类如processdataorg等
* @return
*/
public static List<PALRepositoryModel> getRecentRepositoryList(String wsId, String category) {
List<PALRepositoryModel> list = new ArrayList<>();
Set<String> ids = new HashSet<>();
PALRepositoryCache.getAllChildrenModelsByPid(wsId, category, list, ids);
// 找到最新版本只匹配最新版本在日志中添加此明显提示 todo
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());
}
return recentVerList;
}
}

View File

@ -1,13 +1,23 @@
package com.actionsoft.apps.coe.pal.batch.web.create.process;
import java.io.File;
import java.sql.ResultSet;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.actionsoft.apps.coe.pal.batch.util.BatchUtil;
import com.actionsoft.apps.coe.pal.batch.web.create.process.model.ExcelRowModel;
import com.actionsoft.apps.coe.pal.batch.web.create.process.model.RepositoryInfoModel;
import com.actionsoft.apps.coe.pal.batch.web.create.process.valid.impl.type.ValidAwsOrg;
import com.actionsoft.apps.coe.pal.batch.web.create.process.valid.impl.type.ValidSelect;
import com.actionsoft.apps.coe.pal.constant.CoEConstant;
import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache;
import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel;
import com.actionsoft.bpms.server.UserContext;
import com.actionsoft.sdk.local.SDK;
import com.actionsoft.bpms.util.UUIDGener;
import com.actionsoft.i18n.I18nRes;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
@ -40,12 +50,12 @@ public class ValidProcessExcel {
this.uc = uc;
}
public ResponseObject checkProcessList(File file, String wsId) {
public ResponseObject checkProcessList(File file, String wsId, String methodCategory) {
XSSFWorkbook wb = POIUtil.getWorkbook(file);
if (wb == null) {
return ResponseObject.newErrResponse("获取上传文件失败");
}
String sheetName = ProcessConst.SHEET_NAME;
String sheetName = ProcessUtil.getModelListName(methodCategory);
XSSFSheet sheet = wb.getSheet(sheetName);
if (sheet == null) {
return ResponseObject.newErrResponse(errMsg + "上传文件中【" + sheetName + "】工作表不存在");
@ -68,7 +78,7 @@ public class ValidProcessExcel {
return ResponseObject.newErrResponse(errMsg + "上传文件工作表中首行为标题行,不能为空,请调整");
}
// 校验标题行
ResponseObject checkTitleRo = checkTitleRow(wsId, titleList);
ResponseObject checkTitleRo = checkTitleRow(wsId, titleList, methodCategory);
if (!checkTitleRo.isOk()) {
return checkTitleRo;
}
@ -76,47 +86,197 @@ public class ValidProcessExcel {
// 获取所有数据
JSONObject result = new JSONObject();
result.put("titleRow", titleList);
result.put("data", checkData(getDataList(sheet, titleList), titleList, wsId));
result.put("data", checkData(getDataList(sheet, titleList), titleList, wsId, methodCategory));
ro.put("data", result);
return ro;
}
/**
* 校验表格数据
* @param dataList
* @param titleList
* @param wsId
*/
private JSONArray checkData(List<List<String>> dataList, List<String> titleList, String wsId) {
JSONArray result = new JSONArray();
private JSONObject checkData(List<List<String>> dataList, List<String> titleList, String wsId, String methodCategory) {
int nameIndex = titleList.indexOf(ProcessConst.TABLE_NAME);// 名称位置
int pNameIndex = titleList.indexOf(ProcessConst.TABLE_PARENT_NAME);// 上级名称位置
int typeIndex = titleList.indexOf(ProcessConst.TABLE_TYPE);// 文件类型
// System.out.println(dataList);
// System.out.println(titleList);
// 将excel数据记录到model
List<ExcelRowModel> excelRowModels = new ArrayList<>();
for (int i = 0; i < dataList.size(); i++) {
JSONObject noObj = null;
JSONObject typeObj = null;
List<String> rowDataList = dataList.get(i);
excelRowModels.add(new ExcelRowModel(i+1, dataList.get(i)));
}
// 1.过滤掉名称上级名称文件类型存在空值的数据
List<RepositoryInfoModel> blankList = new ArrayList<>();
Iterator<ExcelRowModel> iterator = excelRowModels.iterator();
while (iterator.hasNext()) {
ExcelRowModel row = iterator.next();
String name = ProcessUtil.removeAllBlack(row.getRowData().get(nameIndex));
String parentName = ProcessUtil.removeAllBlack(row.getRowData().get(pNameIndex));
String methodName = ProcessUtil.removeAllBlack(row.getRowData().get(typeIndex));
// 名称/上级名称/类型校验是否为空待定 todo
if (UtilString.isEmpty(name) || UtilString.isEmpty(parentName) || UtilString.isEmpty(methodName)) {
RepositoryInfoModel blankModel = new RepositoryInfoModel();
blankModel.setParentName(name);
blankModel.setParentName(parentName);
blankModel.setMethodName(methodName);
blankModel.setExcelModel(true);
blankModel.setExcelRowModel(row);
blankModel.setResult("blank");
blankModel.setRowOk(false);
blankModel.setRowMsg("名称、上级名称、文件类型不允许为空");
blankList.add(blankModel);
iterator.remove();
}
}
// 2.过滤Excel中的重复数据记录
List<RepositoryInfoModel> excelRepeatList = new ArrayList<>();
Map<String, Integer> tmpMap = new HashMap<>();
Set<String> tmpSet = new HashSet<>();
// 按照名称上级名称文件类型对重复数据进行过滤
iterator = excelRowModels.iterator();
while (iterator.hasNext()) {
ExcelRowModel row = iterator.next();
String name = ProcessUtil.removeAllBlack(row.getRowData().get(nameIndex));
String parentName = ProcessUtil.removeAllBlack(row.getRowData().get(pNameIndex));
String methodName = ProcessUtil.removeAllBlack(row.getRowData().get(typeIndex));
String key = name + "|" + methodName + "|" +parentName;
if (tmpMap.containsKey(key)) {
RepositoryInfoModel repeatModel = new RepositoryInfoModel();
repeatModel.setParentName(name);
repeatModel.setParentName(parentName);
repeatModel.setMethodName(methodName);
repeatModel.setExcelModel(true);
repeatModel.setExcelRowModel(row);
repeatModel.setResult("repeat");
repeatModel.setRowOk(false);
repeatModel.setRowMsg("与Excel第" + tmpMap.get(key) + "行重复");
excelRepeatList.add(repeatModel);
iterator.remove();
} else {
tmpMap.put(key, row.getRow());
}
}
// 3.校验在pal中是否存在并整合到目录框架
// 获取指定根目录下所有的最新版本模型列表
List<PALRepositoryModel> recentVerList = ProcessUtil.getRecentRepositoryList(wsId, methodCategory);
// 模型进行转换
List<RepositoryInfoModel> batchModelList = ProcessUtil.palRepository2RepositoryInfoList(recentVerList, methodCategory);
// 查找重复的
for (RepositoryInfoModel infoModel : batchModelList) {
String palName = ProcessUtil.removeAllBlack(infoModel.getName());
String palParentName = ProcessUtil.removeAllBlack(infoModel.getParentName());
String palMethodName = ProcessUtil.removeAllBlack(infoModel.getMethodName());
Iterator<ExcelRowModel> iterator1 = excelRowModels.iterator();
while (iterator1.hasNext()) {
ExcelRowModel row = iterator1.next();
String name = ProcessUtil.removeAllBlack(row.getRowData().get(nameIndex));
String parentName = ProcessUtil.removeAllBlack(row.getRowData().get(pNameIndex));
String type = ProcessUtil.removeAllBlack(row.getRowData().get(typeIndex));
if (name.equals(palName) && parentName.equals(palParentName) && type.equals(palMethodName)) {
// 是同一个
infoModel.setExcelModel(true);
infoModel.setExcelRowModel(row);
iterator1.remove();
}
}
}
// 剩下excelRowModels都是不重复的同样添加到batchModelList
iterator = excelRowModels.iterator();
while (iterator.hasNext()) {
ExcelRowModel row = iterator.next();
String name = ProcessUtil.removeAllBlack(row.getRowData().get(nameIndex));
String parentName = ProcessUtil.removeAllBlack(row.getRowData().get(pNameIndex));
String methodName = ProcessUtil.removeAllBlack(row.getRowData().get(typeIndex));
RepositoryInfoModel newModel = new RepositoryInfoModel();
newModel.setId(UUIDGener.getUUID());// 构造一个id
newModel.setName(name);
newModel.setParentName(parentName);
if (parentName.equals(I18nRes.findValue(CoEConstant.APP_ID, methodCategory))) {// 若是根节点构造为根节点
newModel.setParentId(methodCategory);
}
newModel.setMethodName(methodName);
newModel.setPalModel(false);
newModel.setExcelModel(true);
newModel.setPathId(new ArrayList<>());
newModel.setPathName(new ArrayList<>());
newModel.setExcelRowModel(row);
batchModelList.add(newModel);
}
// 4.计算位置(进行位置匹配)
// 先找根节点依次往下构建
String rootName = I18nRes.findValue(CoEConstant.APP_ID, methodCategory);
JSONObject methodObj = ProcessUtil.getCategoryMethods(methodCategory, true);
List<RepositoryInfoModel> matchResult = new ArrayList<>();
Set<String> ids = new HashSet<>();// 记录key,防止死循环
List<String> pathId = new ArrayList<>();
pathId.add(methodCategory);
List<String> pathName = new ArrayList<>();
pathName.add(rootName);
// 从根节点开始构建一棵路径相连的树
getChildrenModels(methodCategory, rootName, pathId, pathName, batchModelList, matchResult, methodObj, ids);
// 匹配结果输出
// for (RepositoryInfoModel r : matchResult) {
// System.out.println(StringUtils.join(r.getPathName(), "/") + "/" + r.getName());
// System.out.println("palExist: " + r.isPalModel() + " ExcelExist: " + r.isExcelModel());
// }
List<RepositoryInfoModel> noMatchList = new ArrayList<>();
// 找到没有匹配上的,对所有路径进行组装没有拼接上
for (RepositoryInfoModel model : batchModelList) {
// 匹配上
if (model.isPalModel()) {// 资产库存在标记为更新
model.setResult("update");
} else {// 资产库不存在标记为新增
model.setResult("add");
}
if (model.isExcelModel() && !model.isPalModel() && !ids.contains(model.getId())) {
model.setResult("noMatch");
model.setRowOk(false);
model.setRowMsg("无法匹配到有效路径");
noMatchList.add(model);
continue;
}
}
// 5.进行数据校验
// blankListexcelRepeatListnoMatchList按整行错误对待处理对matchResult进行校验
for (int i = 0; i < matchResult.size(); i++) {
RepositoryInfoModel model = matchResult.get(i);
ExcelRowModel row = model.getExcelRowModel();
int excelRow = row.getRow();
JSONArray rowJson = new JSONArray();
List<String> rowDataList = row.getRowData();
JSONObject typeObj = null;
for (int j = 0; j < rowDataList.size(); j++) {
String title = titleList.get(j);
String cellValue = rowDataList.get(j);
if (ProcessConst.TABLE_NO.equals(title)) {
JSONObject object = JSONObject.parseObject(new Valid(new ValidNo()).execute(cellValue).toString());
noObj = object;
rowJson.add(object);
} else if (ProcessConst.TABLE_NAME.equals(title)) {
if (ProcessConst.TABLE_NAME.equals(title)) {
JSONObject param = new JSONObject();
param.put("value", cellValue);
param.put("noObj", noObj);
param.put("wsId", wsId);
rowJson.add(JSONObject.parseObject(new Valid(new ValidName()).execute(param).toString()));
} else if (ProcessConst.TABLE_PARENT_NAME.equals(title)) {
JSONObject o = new JSONObject();
o.put("name", ProcessConst.TABLE_PARENT_NAME);
o.put("name2", ProcessConst.TABLE_PARENT_NAME);
o.put("value", BatchUtil.specialCharTransfer(cellValue));
o.put("isOk", true);
o.put("msg", "");
rowJson.add(o);
} else if (ProcessConst.TABLE_TYPE.equals(title)) {
JSONObject object = JSONObject.parseObject(new Valid(new ValidType()).execute(cellValue).toString());
JSONObject param = new JSONObject();
param.put("value", cellValue);
param.put("category", methodCategory);
JSONObject object = JSONObject.parseObject(new Valid(new ValidType()).execute(param).toString());
typeObj = object;
rowJson.add(object);
} else {// 扩展属性列
if (typeObj != null && typeObj.getBooleanValue("isOk")) {
// 获取流程类型
Map<String, String> categoryMethods = ProcessUtil.getProcessCategoryMethod();
String methodId = categoryMethods.get(typeObj.getString("value"));
JSONObject categoryMethods = ProcessUtil.getCategoryMethods(methodCategory, true);
String methodId = categoryMethods.getString(typeObj.getString("value"));
if ("default".equals(methodId)) {// 简单文件类型无任何扩展属性不校验不显示
// 所有扩展属性忽略
break;
@ -158,62 +318,188 @@ public class ValidProcessExcel {
}
}
}
result.add(rowJson);
model.setCheckResult(rowJson);
}
// 判断是否有重复编号+名称数据(前提是编号和名称校验通过
Map<String, Integer> map = new HashMap<>();
for (int i = 0; i < result.size(); i++) {
JSONArray array = result.getJSONArray(i);
// 编号
JSONObject noObj = array.getJSONObject(0);
// 名称
JSONObject nameObj = array.getJSONObject(1);
// 资产库中已存在的标识
if (nameObj.containsKey("isExist")) {
if (nameObj.getBooleanValue("isExist")) {
noObj.put("isExist", true);
noObj.put("plId", nameObj.getString("plId"));
} else {
noObj.put("isExist", false);
noObj.put("plId", "");
// 整理最终结果
List<RepositoryInfoModel> allDataList = new ArrayList<>();
allDataList.addAll(blankList);
allDataList.addAll(excelRepeatList);
allDataList.addAll(noMatchList);
allDataList.addAll(matchResult);
// 整体按照Excel表中顺序排序
allDataList.sort((a1, a2)-> {return a1.getExcelRowModel().getRow() - a2.getExcelRowModel().getRow();});
// 构造结果集返给前端
int totalCount = allDataList.size();
int repeatCount = excelRepeatList.size();
int blankCount = blankList.size();
int noMatchCount = noMatchList.size();
int okCount = 0;
int errCount = 0;
for (RepositoryInfoModel model : matchResult) {
model.setRowOk(true);
JSONArray arr = model.getCheckResult();
for (int i = 0; i < arr.size(); i++) {
if (!arr.getJSONObject(i).getBooleanValue("isOk")) {
model.setRowOk(false);
}
}
String tmp = noObj.getString("value") + ":" + nameObj.getString("value");
if (!map.containsKey(tmp)) {
map.put(tmp, i + 1);
if (model.isRowOk()) {
okCount++;
} else {
noObj.put("isExcelExist", true);
noObj.put("excelExistRow", map.get(tmp));
errCount++;
}
}
// 构造返回前端结果集
JSONArray result = new JSONArray();
for (int i = 0; i < allDataList.size(); i++) {
RepositoryInfoModel model = allDataList.get(i);
if ("blank".equals(model.getResult())) {// 空白构造界面数据
JSONArray row = new JSONArray();
List<String> list = model.getExcelRowModel().getRowData();
for (int j = 0; j < list.size(); j++) {
String s = list.get(j);
JSONObject cell = new JSONObject();
cell.put("name", titleList.get(j));
cell.put("name2", ProcessConst.EXTEND_PROP_PREFIX + titleList.get(j) + ProcessConst.EXTEND_PROP_SUFFIX);
if (ProcessConst.TABLE_NAME.equals(titleList.get(j))) {
cell.put("isOk", false);
cell.put("msg", model.getRowMsg());
} else {
cell.put("isOk", true);
cell.put("msg", "");
}
cell.put("value", s);
row.add(cell);
}
JSONObject rowResult = new JSONObject();
rowResult.put("row", row);
rowResult.put("excelNo", model.getExcelRowModel().getRow());// Excel中行
rowResult.put("pathName", "");
rowResult.put("isRowOk", model.isRowOk());
rowResult.put("result", model.getResult());
result.add(rowResult);
} else if ("repeat".equals(model.getResult())) {// 重复
JSONArray row = new JSONArray();
List<String> list = model.getExcelRowModel().getRowData();
for (int j = 0; j < list.size(); j++) {
String s = list.get(j);
JSONObject cell = new JSONObject();
cell.put("name", titleList.get(j));
cell.put("name2", ProcessConst.EXTEND_PROP_PREFIX + titleList.get(j) + ProcessConst.EXTEND_PROP_SUFFIX);
if (ProcessConst.TABLE_NAME.equals(titleList.get(j))) {
cell.put("isOk", false);
cell.put("msg", model.getRowMsg());
} else {
cell.put("isOk", true);
cell.put("msg", "");
}
cell.put("value", s);
row.add(cell);
}
JSONObject rowResult = new JSONObject();
rowResult.put("row", row);
rowResult.put("excelNo", model.getExcelRowModel().getRow());// Excel中行
rowResult.put("pathName", "");
rowResult.put("isRowOk", model.isRowOk());
rowResult.put("result", model.getResult());
result.add(rowResult);
} else if ("noMatch".equals(model.getResult())) {// 没匹配到
JSONArray row = new JSONArray();
List<String> list = model.getExcelRowModel().getRowData();
for (int j = 0; j < list.size(); j++) {
String s = list.get(j);
JSONObject cell = new JSONObject();
cell.put("name", titleList.get(j));
cell.put("name2", ProcessConst.EXTEND_PROP_PREFIX + titleList.get(j) + ProcessConst.EXTEND_PROP_SUFFIX);
if (ProcessConst.TABLE_NAME.equals(titleList.get(j))) {
cell.put("isOk", false);
cell.put("msg", model.getRowMsg());
} else {
cell.put("isOk", true);
cell.put("msg", "");
}
cell.put("value", s);
row.add(cell);
}
JSONObject rowResult = new JSONObject();
rowResult.put("row", row);
rowResult.put("excelNo", model.getExcelRowModel().getRow());// Excel中行
rowResult.put("pathName", "");
rowResult.put("isRowOk", model.isRowOk());
rowResult.put("result", model.getResult());
result.add(rowResult);
} else if ("add".equals(model.getResult())) {// 新增
JSONArray row = model.getCheckResult();
JSONObject rowResult = new JSONObject();
rowResult.put("row", row);
rowResult.put("excelNo", model.getExcelRowModel().getRow());// Excel中行
rowResult.put("pathName", StringUtils.join(model.getPathName(), "/"));
rowResult.put("isRowOk", model.isRowOk());
rowResult.put("result", model.getResult());
rowResult.put("pathIdArr", model.getPathId());
rowResult.put("pathNameArr", model.getPathName());
rowResult.put("id", model.getId());
rowResult.put("parentId", model.getParentId());
rowResult.put("methodId", model.getMethodId());
result.add(rowResult);
} else if ("update".equals(model.getResult())) {// pal中存在更新
JSONArray row = model.getCheckResult();
JSONObject rowResult = new JSONObject();
rowResult.put("row", row);
rowResult.put("excelNo", model.getExcelRowModel().getRow());// Excel中行
rowResult.put("pathName", StringUtils.join(model.getPathName(), "/"));
rowResult.put("isRowOk", model.isRowOk());
rowResult.put("result", model.getResult());
rowResult.put("pathIdArr", model.getPathId());
rowResult.put("pathNameArr", model.getPathName());
rowResult.put("id", model.getId());
rowResult.put("parentId", model.getParentId());
rowResult.put("methodId", model.getMethodId());
result.add(rowResult);
}
}
// 排序
// result = sort(result);
return result;
// for (int i = 0; i < result.size(); i++) {
// System.out.println(result.getJSONObject(i));
// }
// System.out.println(result);
JSONObject ro = new JSONObject();
ro.put("result", result);
ro.put("totalCount", totalCount);
ro.put("repeatCount", repeatCount);
ro.put("blankCount", blankCount);
ro.put("noMatchCount", noMatchCount);
ro.put("okCount", okCount);
ro.put("errCount", errCount);
return ro;
}
private JSONArray sort(JSONArray array) {
List<JSONArray> list = JSONObject.parseArray(array.toJSONString(), JSONArray.class);
Collections.sort(list, new Comparator<JSONArray>() {
@Override
public int compare(JSONArray o1, JSONArray o2) {
String [] no1 = o1.getJSONObject(0).getString("value").split("\\.");
String [] no2 = o2.getJSONObject(0).getString("value").split("\\.");
int minLength = no1.length <= no2.length ? no1.length : no2.length;
for (int i = 0; i < minLength; i++) {
int n1 = Integer.parseInt(no1[i]);
int n2 = Integer.parseInt(no2[i]);
if (n1 != n2) {
return n1 - n2;
} else {
continue;
}
}
return no1.length - no2.length;
private void getChildrenModels(String parentId, String parentName, List<String> pathId, List<String> pathName, List<RepositoryInfoModel> batchModelList, List<RepositoryInfoModel> result, JSONObject methodObj, Set<String> ids) {
for (RepositoryInfoModel infoModel : batchModelList) {
if (ids.contains(infoModel.getId())) {
continue;
}
});
return JSONArray.parseArray(JSON.toJSONString(list));
if (infoModel.getParentName().equals(parentName)) {
infoModel.setParentId(parentId);
for (String id : pathId) {
infoModel.getPathId().add(id);
}
for (String name : pathName) {
infoModel.getPathName().add(name);
}
infoModel.setMethodId(!methodObj.containsKey(infoModel.getMethodName()) ? "" : methodObj.getString(infoModel.getMethodName()));
if (infoModel.isExcelModel()) {
result.add(infoModel);
}
ids.add(infoModel.getId());
// 路径累加
List<String> pathId2 = new ArrayList<>(pathId);
pathId2.add(infoModel.getId());
List<String> pathName2 = new ArrayList<>(pathName);
pathName2.add(infoModel.getName());
getChildrenModels(infoModel.getId(), infoModel.getName(), pathId2, pathName2, batchModelList, result, methodObj, ids);
}
}
}
private List<List<String>> getDataList(XSSFSheet sheet, List<String> titleList) {
@ -241,8 +527,9 @@ public class ValidProcessExcel {
/**
* 校验标题行
* @param titleRow
* @param methodCategory
*/
public ResponseObject checkTitleRow(String wsId, List<String> titleRow) {
public ResponseObject checkTitleRow(String wsId, List<String> titleRow, String methodCategory) {
// 标题固定行验证
if (titleRow.size() < ProcessConst.PROCESS_TITLE_ROW.length) {// 固定行列不够
StringBuilder msg = new StringBuilder();
@ -273,7 +560,7 @@ public class ValidProcessExcel {
if (titleRow.size() > ProcessConst.PROCESS_TITLE_ROW.length) {// 有扩展属性
List<String> illegalAttrTitle = new ArrayList<>();
// 获取当前扩展属性
Set<String> attributeNames = ProcessUtil.getProcessMethodAttrNames(wsId);
Set<String> attributeNames = ProcessUtil.getProcessMethodAttrNames(wsId, methodCategory);
for (int i = ProcessConst.PROCESS_TITLE_ROW.length; i < titleRow.size(); i++) {
String title = titleRow.get(i);
int prefix = title.indexOf("扩展<");

View File

@ -0,0 +1,41 @@
package com.actionsoft.apps.coe.pal.batch.web.create.process.model;
import java.util.List;
/**
* Excel行数据
*/
public class ExcelRowModel {
private int row;// 当前行从1开始
private List<String> rowData;// 当前行数据
public ExcelRowModel(int row, List<String> rowData) {
this.row = row;
this.rowData = rowData;
}
public int getRow() {
return row;
}
public void setRow(int row) {
this.row = row;
}
public List<String> getRowData() {
return rowData;
}
public void setRowData(List<String> rowData) {
this.rowData = rowData;
}
@Override
public String toString() {
return "ExcelRowModel{" +
"row=" + row +
", rowData=" + rowData +
'}';
}
}

View File

@ -0,0 +1,166 @@
package com.actionsoft.apps.coe.pal.batch.web.create.process.model;
import com.alibaba.fastjson.JSONArray;
import java.util.List;
public class RepositoryInfoModel {
private String id;
private String name;
private String parentName;// 如果parentName与根目录名称相同则认为是在根目录下
private String parentId;
private List<String> pathId;
private List<String> pathName;
private String methodName;
private String methodId;
private boolean isPalModel;// 是否pal存在的模型
private boolean isExcelModel;// 是否excel中存在的模型
private ExcelRowModel excelRowModel;
private JSONArray checkResult;// 若匹配成功存储校验结果
private String result;// 结果标识 blank关键信息空白repeatexcel信息重复noMatch未匹配上update匹配上需要更新add匹配上需要新增
private boolean isRowOk;// 行校验结果
private String rowMsg;// 行校验结果提示
public RepositoryInfoModel() {
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getParentName() {
return parentName;
}
public void setParentName(String parentName) {
this.parentName = parentName;
}
public String getParentId() {
return parentId;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
public List<String> getPathId() {
return pathId;
}
public void setPathId(List<String> pathId) {
this.pathId = pathId;
}
public List<String> getPathName() {
return pathName;
}
public void setPathName(List<String> pathName) {
this.pathName = pathName;
}
public boolean isPalModel() {
return isPalModel;
}
public void setPalModel(boolean palModel) {
isPalModel = palModel;
}
public boolean isExcelModel() {
return isExcelModel;
}
public void setExcelModel(boolean excelModel) {
isExcelModel = excelModel;
}
public String getMethodId() {
return methodId;
}
public void setMethodId(String methodId) {
this.methodId = methodId;
}
public ExcelRowModel getExcelRowModel() {
return excelRowModel;
}
public void setExcelRowModel(ExcelRowModel excelRowModel) {
this.excelRowModel = excelRowModel;
}
public String getMethodName() {
return methodName;
}
public void setMethodName(String methodName) {
this.methodName = methodName;
}
public JSONArray getCheckResult() {
return checkResult;
}
public void setCheckResult(JSONArray checkResult) {
this.checkResult = checkResult;
}
public String getResult() {
return result;
}
public void setResult(String result) {
this.result = result;
}
public boolean isRowOk() {
return isRowOk;
}
public void setRowOk(boolean rowOk) {
isRowOk = rowOk;
}
public String getRowMsg() {
return rowMsg;
}
public void setRowMsg(String rowMsg) {
this.rowMsg = rowMsg;
}
@Override
public String toString() {
return "RepositoryInfoModel{" +
"id='" + id + '\'' +
", name='" + name + '\'' +
", parentName='" + parentName + '\'' +
", parentId='" + parentId + '\'' +
", pathId=" + pathId +
", pathName=" + pathName +
", methodName='" + methodName + '\'' +
", methodId='" + methodId + '\'' +
", isPalModel=" + isPalModel +
", isExcelModel=" + isExcelModel +
", excelRowModel=" + excelRowModel +
'}';
}
}

View File

@ -7,9 +7,6 @@ import java.util.regex.Pattern;
import com.actionsoft.apps.coe.pal.batch.util.BatchUtil;
import com.actionsoft.apps.coe.pal.batch.web.create.process.ProcessConst;
import com.actionsoft.apps.coe.pal.batch.web.create.process.valid.ValidCell;
import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache;
import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel;
import com.actionsoft.bpms.util.UtilString;
import com.alibaba.fastjson.JSONObject;
/**
@ -31,9 +28,7 @@ public class ValidName implements ValidCell {
boolean isExist = false;
String plId = "";
String msg = "";
if (UtilString.isEmpty(value)) {
msg = "名称不允许为空";
} else if (BatchUtil.containHtmlEles(value)) {
if (BatchUtil.containHtmlEles(value)) {
msg = BatchUtil.eleErrMsg;
} else {
isOk = true;
@ -44,69 +39,7 @@ public class ValidName implements ValidCell {
Pattern p = Pattern.compile(regEx);
Matcher m = p.matcher(value);
if (m.find()) {
// if (false) {
// 获取编号以编号+名称判断是否存在该流程
JSONObject noObj = paramObj.getJSONObject("noObj");
if (noObj != null && noObj.getBooleanValue("isOk")) {// 编号校验通过
String no = noObj.getString("value");
String[] noArr = no.split("\\.");
String pid = "process";
for (int k = 1; k < noArr.length + 1; k++) {
int level = k;
List<PALRepositoryModel> list = PALRepositoryCache.getAllSubModelsByPid(paramObj.getString("wsId"), pid);
if (list == null || list.size() == 0) {
isOk = true;
break;
}
if (k == noArr.length) {// 找到了最后一层判断名称是否相等
boolean flag = false;
for (PALRepositoryModel model : list) {
if (model.isUse()) {
if (model.getLevel() == level && model.getOrderIndex() == Integer.parseInt(noArr[k - 1])) {
pid = null;
flag = true;
if (value.equals(model.getName())) {
isOk = false;
msg = ""; //""流程已存在";
plId = model.getId();
isExist = true;
pid = null;
break;
} else {
isOk = true;
isExist = false;
break;
}
}
}
}
if (flag) {
continue;
} else {
isOk = true;
break;
}
} else {
boolean flag = false;
for (PALRepositoryModel model : list) {
if (model.isUse()) {
if (model.getLevel() == level && model.getOrderIndex() == Integer.parseInt(noArr[k - 1])) {
pid = model.getId();
flag = true;
}
}
}
if (flag) {
continue;
} else {
isOk = true;
break;
}
}
}
} else {
isOk = true;
}
isOk = true;
}
}

View File

@ -18,23 +18,25 @@ public class ValidType implements ValidCell {
@Override
public Object validTableCell(Object param) {
String type = param.toString();
List<String> categorys = ProcessUtil.getProcessCategory();
JSONObject paramObj = JSONObject.parseObject(param.toString());
String value = paramObj.getString("value");
String category = paramObj.getString("category");
JSONObject categoryObj = ProcessUtil.getCategoryMethods(category, true);
JSONObject result = new JSONObject();
boolean isOk = false;
String msg = "";
if (UtilString.isEmpty(type)) {
if (UtilString.isEmpty(value)) {
msg = "文件类型不允许为空";
} else if (BatchUtil.containHtmlEles(type)) {
} else if (BatchUtil.containHtmlEles(value)) {
msg = BatchUtil.eleErrMsg;
} else if (!categorys.contains(type)) {
} else if (!categoryObj.containsKey(value)) {
msg = "该文件类型不存在";
} else {
isOk = true;
}
result.put("name", ProcessConst.TABLE_TYPE);
result.put("name2", ProcessConst.TABLE_TYPE);
result.put("value", BatchUtil.specialCharTransfer(type));
result.put("value", BatchUtil.specialCharTransfer(value));
result.put("isOk", isOk);
result.put("msg", BatchUtil.specialCharTransfer(msg));
return result;

View File

@ -1,4 +1,4 @@
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=../apps/com.actionsoft.apps.coe.pal.batch/main/favicon.ico><title>com.actionsoft.apps.coe.pal.batch</title><script>const settingParam = <#settingParam>;
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=../apps/com.actionsoft.apps.coe.pal.batch/main/favicon.ico><title>com.actionsoft.apps.coe.pal.batch</title><script>const settingParam =; <#settingParam>;
const axiosBaseUrl = "./";
const production = true;</script><script>var mainPage = '<#mainPage>';// create replace
var wsId = '<#wsId>';
@ -11,4 +11,4 @@
var shapeFileValue = '<#shapeFileValue>';
var palId = '<#palId>';// 流程id不为空则为设计器内单只流程形状属性替换
var wHref = "./w";
var jdHref = "./jd";</script><link href=../apps/com.actionsoft.apps.coe.pal.batch/main/css/chunk-0896b577.2aef31d9.css rel=prefetch><link href=../apps/com.actionsoft.apps.coe.pal.batch/main/css/chunk-847f2fd2.ca5c30c5.css rel=prefetch><link href=../apps/com.actionsoft.apps.coe.pal.batch/main/css/chunk-d674f310.832a3f23.css rel=prefetch><link href=../apps/com.actionsoft.apps.coe.pal.batch/main/js/chunk-0896b577.ec2470ef.js rel=prefetch><link href=../apps/com.actionsoft.apps.coe.pal.batch/main/js/chunk-2d224ef1.56860032.js rel=prefetch><link href=../apps/com.actionsoft.apps.coe.pal.batch/main/js/chunk-3a9b7577.28a44c1e.js rel=prefetch><link href=../apps/com.actionsoft.apps.coe.pal.batch/main/js/chunk-847f2fd2.c65bbdef.js rel=prefetch><link href=../apps/com.actionsoft.apps.coe.pal.batch/main/js/chunk-d674f310.e050c059.js rel=prefetch><link href=../apps/com.actionsoft.apps.coe.pal.batch/main/css/app.d580077e.css rel=preload as=style><link href=../apps/com.actionsoft.apps.coe.pal.batch/main/css/chunk-vendors.53f73f21.css rel=preload as=style><link href=../apps/com.actionsoft.apps.coe.pal.batch/main/js/app.e84aff8e.js rel=preload as=script><link href=../apps/com.actionsoft.apps.coe.pal.batch/main/js/chunk-vendors.c8d67742.js rel=preload as=script><link href=../apps/com.actionsoft.apps.coe.pal.batch/main/css/chunk-vendors.53f73f21.css rel=stylesheet><link href=../apps/com.actionsoft.apps.coe.pal.batch/main/css/app.d580077e.css rel=stylesheet></head><body style=margin:0;><div id=app></div><script src=../apps/com.actionsoft.apps.coe.pal.batch/main/js/chunk-vendors.c8d67742.js></script><script src=../apps/com.actionsoft.apps.coe.pal.batch/main/js/app.e84aff8e.js></script></body></html>
var jdHref = "./jd";</script><link href=../apps/com.actionsoft.apps.coe.pal.batch/main/css/chunk-0896b577.2aef31d9.css rel=prefetch><link href=../apps/com.actionsoft.apps.coe.pal.batch/main/css/chunk-71858c07.59caaf8f.css rel=prefetch><link href=../apps/com.actionsoft.apps.coe.pal.batch/main/css/chunk-d674f310.832a3f23.css rel=prefetch><link href=../apps/com.actionsoft.apps.coe.pal.batch/main/js/chunk-0896b577.93b0818d.js rel=prefetch><link href=../apps/com.actionsoft.apps.coe.pal.batch/main/js/chunk-2d224ef1.9043bb4b.js rel=prefetch><link href=../apps/com.actionsoft.apps.coe.pal.batch/main/js/chunk-3a9b7577.a1c1d3f9.js rel=prefetch><link href=../apps/com.actionsoft.apps.coe.pal.batch/main/js/chunk-71858c07.07a22954.js rel=prefetch><link href=../apps/com.actionsoft.apps.coe.pal.batch/main/js/chunk-d674f310.2dd90041.js rel=prefetch><link href=../apps/com.actionsoft.apps.coe.pal.batch/main/css/app.f3fd84ae.css rel=preload as=style><link href=../apps/com.actionsoft.apps.coe.pal.batch/main/css/chunk-vendors.53f73f21.css rel=preload as=style><link href=../apps/com.actionsoft.apps.coe.pal.batch/main/js/app.633e0fbc.js rel=preload as=script><link href=../apps/com.actionsoft.apps.coe.pal.batch/main/js/chunk-vendors.edec05de.js rel=preload as=script><link href=../apps/com.actionsoft.apps.coe.pal.batch/main/css/chunk-vendors.53f73f21.css rel=stylesheet><link href=../apps/com.actionsoft.apps.coe.pal.batch/main/css/app.f3fd84ae.css rel=stylesheet></head><body style=margin:0;><div id=app></div><script src=../apps/com.actionsoft.apps.coe.pal.batch/main/js/chunk-vendors.edec05de.js></script><script src=../apps/com.actionsoft.apps.coe.pal.batch/main/js/app.633e0fbc.js></script></body></html>

View File

@ -11,6 +11,7 @@
<param name="type"/>
<param name="wsId"/>
<param name="versionIds"/>
<param name="methodCategory"/>
</cmd-bean>
<cmd-bean name="com.actionsoft.apps.coe.pal.batch_create_repository_tree_data">
<param name="wsId"/>
@ -37,9 +38,11 @@
<param name="type"/>
<param name="fileValue"/>
<param name="fileName"/>
<param name="methodCategory"/>
</cmd-bean>
<cmd-bean name="com.actionsoft.apps.coe.pal.batch_create_data_save">
<param name="param"/>
<param name="methodCategory"/>
</cmd-bean>
<cmd-bean name="com.actionsoft.apps.coe.pal.batch_create_log_query">
<param name="type"/>

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
#palRepositoryTree[data-v-9da10dd4] .el-dialog__body{padding:10px 20px;color:#606266;font-size:14px;word-break:break-all}#palRepositoryTree[data-v-9da10dd4] .el-input__inner{border-radius:0}#palRepositoryTree[data-v-9da10dd4] .el-tree--highlight-current .el-tree-node.is-current>.el-tree-node__content{background-color:#f5f7fa;color:#4e7ff9}#palRepositoryTree[data-v-9da10dd4] .el-tree--highlight-current .el-tree-node.is-current>.el-tree-node__content .awsui-iconfont{color:#4e7ff9!important}.tree[data-v-9da10dd4]{overflow:auto;width:458px;height:200px}#palRepositoryTree[data-v-9da10dd4] .el-tree{min-width:100%;display:inline-block!important}#mycode[data-v-23d00217] .CodeMirror-lines{background-color:#2c2c2c;color:#58a0f0}#mycode[data-v-23d00217] .CodeMirror{height:auto!important}#header[data-v-fa72a222] .el-step__title{font-size:14px}
#palRepositoryTree[data-v-9da10dd4] .el-dialog__body{padding:10px 20px;color:#606266;font-size:14px;word-break:break-all}#palRepositoryTree[data-v-9da10dd4] .el-input__inner{border-radius:0}#palRepositoryTree[data-v-9da10dd4] .el-tree--highlight-current .el-tree-node.is-current>.el-tree-node__content{background-color:#f5f7fa;color:#4e7ff9}#palRepositoryTree[data-v-9da10dd4] .el-tree--highlight-current .el-tree-node.is-current>.el-tree-node__content .awsui-iconfont{color:#4e7ff9!important}.tree[data-v-9da10dd4]{overflow:auto;width:458px;height:200px}#palRepositoryTree[data-v-9da10dd4] .el-tree{min-width:100%;display:inline-block!important}#mycode[data-v-64ad3307] .CodeMirror-lines{background-color:#2c2c2c;color:#58a0f0}#mycode[data-v-64ad3307] .CodeMirror{height:auto!important}#header[data-v-44c1fb28] .el-step__title{font-size:14px}

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

View File

@ -35,7 +35,7 @@ public class ProcessUtil {
*/
public static List<String> getProcessCategory() {
List<String> list = new ArrayList<String>();
list.add("简单文件分类");
list.add("文件夹");
List<PALMethodModel> methodModels = PALMethodManager.getInstance().getPALMethodModelListByMethod("process");
List<AppContext> listApps = AppsAPIManager.getInstance().getInstalledApps();
int size = listApps.size();
@ -88,7 +88,7 @@ public class ProcessUtil {
*/
public static Map<String, String> getProcessCategoryMethod() {
Map<String, String> result = new HashMap<>();
result.put("简单文件分类", "default");
result.put("文件夹", "default");
List<PALMethodModel> methodModels = PALMethodManager.getInstance().getPALMethodModelListByMethod("process");
List<AppContext> listApps = AppsAPIManager.getInstance().getInstalledApps();
int size = listApps.size();
@ -116,7 +116,7 @@ public class ProcessUtil {
*/
public static JSONObject getProcessMethods() {
JSONObject result = new JSONObject();
result.put("default", "简单文件分类");
result.put("default", "文件夹");
List<PALMethodModel> methodModels = PALMethodManager.getInstance().getPALMethodModelListByMethod("process");
List<AppContext> listApps = AppsAPIManager.getInstance().getInstalledApps();
int size = listApps.size();

View File

@ -271,7 +271,7 @@ public class PALRepositoryPropertyDao extends DaoObject<PALRepositoryPropertyMod
}
}
// 执行批量更新
resultNum = DBSql.batch(conn, sql.toString(), new BatchPreparedStatementSetter() {
resultNum = DBSql.batch(conn, sql, new BatchPreparedStatementSetter() {
@Override
public void setValues(PreparedStatement pst, int paramInt) throws SQLException {
PALRepositoryPropertyModel model = propertys.get(paramInt);
@ -364,8 +364,48 @@ public class PALRepositoryPropertyDao extends DaoObject<PALRepositoryPropertyMod
return r;
}
/**
* 更新流程的所有自定义属性
* @param propertys
* @throws SQLException
*/
public int[] batchDeletePropListById(final List<PALRepositoryPropertyModel> propertys) throws SQLException {
Connection conn = DBSql.open();
conn.setAutoCommit(false);
int[] resultNum = null;
try {
String sql = "DELETE FROM " + entityName() + " WHERE ID = ?";
// 执行批量删除
resultNum = DBSql.batch(conn, sql, new BatchPreparedStatementSetter() {
@Override
public void setValues(PreparedStatement pst, int paramInt) throws SQLException {
PALRepositoryPropertyModel model = propertys.get(paramInt);
pst.setString(1, model.getId());
}
public int getBatchSize() {
return propertys.size();
}
});
conn.commit();
/*
* 更新缓存
*/
for (PALRepositoryPropertyModel model : propertys) {
PALRepositoryPropertyCache.getCache().remove(model.getId());
}
return resultNum;
} catch(SQLException e) {
conn.rollback();
throw e;
}finally {
DBSql.close(conn);
}
}
public int deletePropertyById(String ids) {
String sql = "DELETE FORM " + entityName() + " WHERE ID IN (" + ids + ")";
String sql = "DELETE FROM " + entityName() + " WHERE ID IN (" + ids + ")";
int result = DBSql.update(sql);
if (!UtilString.isEmpty(ids)) {
ids = ids.replaceAll("'", "");

View File

@ -459,9 +459,9 @@ public class DesignerShapeRelationDao extends DaoObject<DesignerShapeRelationMod
StringBuilder sql = new StringBuilder("SELECT * FROM " + entityName() + " WHERE SHAPEID=? AND RELATIONFILEID=?");
if (attrId != null && !"".equals(attrId)) {
sql.append(" AND ATTRID=?");
return DBSql.query(sql.toString(), rowMapper(), new Object[]{ shapeId, relationFileId, attrId });
return DBSql.query(sql.toString(), rowMapper(), shapeId, relationFileId, attrId);
} else {
return DBSql.query(sql.toString(), rowMapper(), new Object[]{ shapeId, relationFileId });
return DBSql.query(sql.toString(), rowMapper(), shapeId, relationFileId);
}
}
@ -474,7 +474,7 @@ public class DesignerShapeRelationDao extends DaoObject<DesignerShapeRelationMod
*/
public List<DesignerShapeRelationModel> getModelListByRelationShapeId(String fileId, String relationShapeId) {
StringBuilder sql = new StringBuilder("SELECT * FROM " + entityName() + " WHERE RELATIONSHAPEID=? AND FILEID=?");
return DBSql.query(sql.toString(), rowMapper(), new Object[]{ relationShapeId, fileId });
return DBSql.query(sql.toString(), rowMapper(), relationShapeId, fileId);
}
/**
@ -485,7 +485,7 @@ public class DesignerShapeRelationDao extends DaoObject<DesignerShapeRelationMod
*/
public List<DesignerShapeRelationModel> getModelListByRelationShapeId(String relationShapeId) {
String sql = "SELECT * FROM " + entityName() + " WHERE RELATIONSHAPEID=?";
return DBSql.query(sql, rowMapper(), new Object[]{ relationShapeId });
return DBSql.query(sql, rowMapper(), relationShapeId);
}
/**
@ -496,7 +496,7 @@ public class DesignerShapeRelationDao extends DaoObject<DesignerShapeRelationMod
*/
public List<DesignerShapeRelationModel> getModelListByShapeId(String shapeId) {
String sql = "SELECT * FROM " + entityName() + " WHERE SHAPEID=?";
return DBSql.query(sql, rowMapper(), new Object[]{ shapeId });
return DBSql.query(sql, rowMapper(), shapeId);
}
/**
@ -518,7 +518,7 @@ public class DesignerShapeRelationDao extends DaoObject<DesignerShapeRelationMod
*/
public List<DesignerShapeRelationModel> getModelListByFileId(String fileId) {
String sql = "SELECT * FROM " + entityName() + " WHERE FILEID=?";
return DBSql.query(sql, rowMapper(), new Object[]{ fileId });
return DBSql.query(sql, rowMapper(), fileId);
}
/**
@ -753,13 +753,13 @@ public class DesignerShapeRelationDao extends DaoObject<DesignerShapeRelationMod
for (String shapeId : deleteMap.keySet()) {
Iterator<DesignerShapeRelationModel> iter2 = DesignerShapeRelationCache.getByShapeId(uuid, shapeId);
while (iter2.hasNext()) {
DesignerShapeRelationModel model = (DesignerShapeRelationModel) iter2.next();
DesignerShapeRelationModel model = iter2.next();
DesignerShapeRelationCache.getCache().remove(model.getId(), false);
// System.out.println("删除【shapeId】本地缓存" + JSON.toJSONString(model));
}
Iterator<DesignerShapeRelationModel> iter = DesignerShapeRelationCache.getByRelationShapeId(uuid, shapeId);
while (iter.hasNext()) {
DesignerShapeRelationModel model = (DesignerShapeRelationModel) iter.next();
DesignerShapeRelationModel model = iter.next();
DesignerShapeRelationCache.getCache().remove(model.getId(), false);
// System.out.println("删除【RelationShapeId】本地缓存" + JSON.toJSONString(model));
}
@ -899,4 +899,46 @@ public class DesignerShapeRelationDao extends DaoObject<DesignerShapeRelationMod
return r;
}
/**
* 批量删除
* @param list
* @return
*/
public int[] batchDeleteRelationListById (final List<DesignerShapeRelationModel> list) throws SQLException {
Connection conn = DBSql.open();
int[] resultNum = null;
try {
conn.setAutoCommit(false);
String sql = "DELETE FROM " + entityName() + " WHERE ID = ? ";
resultNum = DBSql.batch(conn, sql, new BatchPreparedStatementSetter() {
@Override
public int getBatchSize() {
return list.size();
}
@Override
public void setValues(PreparedStatement prest, int paramInt)
throws SQLException {
DesignerShapeRelationModel relation = list.get(paramInt);
prest.setString(1, relation.getId());
}
});
conn.commit();
for (DesignerShapeRelationModel model : list) {
DesignerShapeRelationCache.removeById(model.getId());
}
return resultNum;
} catch (SQLException e) {
try {
conn.rollback();
} catch (SQLException e1) {
e1.printStackTrace();
}
e.printStackTrace();
} finally {
DBSql.close(conn);
}
return resultNum;
}
}