pal 流程图Excel导入后端阶段提交
This commit is contained in:
parent
0c63edf9ed
commit
292a586878
BIN
com.actionsoft.apps.coe.pal.batch/excel/模型导入模板.xlsx
Normal file
BIN
com.actionsoft.apps.coe.pal.batch/excel/模型导入模板.xlsx
Normal file
Binary file not shown.
Binary file not shown.
@ -24,13 +24,15 @@ public class BatchConst {
|
||||
// 批量创建标识
|
||||
public static final String PROCESS_LIST = "processList";// 流程清单
|
||||
public static final String SHAPE_LIST = "shapeList";// 模型结构
|
||||
|
||||
public static final String SHAPE_IMPORT = "shapeImport";// 模型导入
|
||||
|
||||
// 模版文件路径
|
||||
public static final String TEMPLATE_FILE_PATH = AppsConst.APPS_ROOT + AppsConst.FOLDER_INSTALL + File.separator + APP_ID + File.separator + "excel" + File.separator;
|
||||
// 模版文件名称
|
||||
public static final String PROCESS_LIST_TEMPLATE_FILE_SUFFIX = "清单模板.xlsx";
|
||||
public static final String SHAPE_LIST_TEMPLATE_FILE_SUFFIX = "模型结构模板.xlsx";
|
||||
|
||||
public static final String SHAPE_IMPORT_TEMPLATE_FILE_SUFFIX = "模型导入模板.xlsx";
|
||||
|
||||
// 日志结束语
|
||||
public static final String END_LOG = "**建议拷贝本次输出日志做备忘";
|
||||
|
||||
|
||||
@ -2,13 +2,12 @@ package com.actionsoft.apps.coe.pal.batch.web;
|
||||
|
||||
import com.actionsoft.apps.coe.pal.batch.constant.BatchConst;
|
||||
import com.actionsoft.apps.coe.pal.batch.util.LogUtil;
|
||||
import com.actionsoft.apps.coe.pal.batch.util.POIUtil;
|
||||
import com.actionsoft.apps.coe.pal.batch.web.create.process.CreateProcessExcel;
|
||||
import com.actionsoft.apps.coe.pal.batch.web.create.process.ImportProcessExcel;
|
||||
import com.actionsoft.apps.coe.pal.batch.web.create.process.ProcessUtil;
|
||||
import com.actionsoft.apps.coe.pal.batch.web.create.process.ValidProcessExcel;
|
||||
import com.actionsoft.apps.coe.pal.batch.web.create.shape.CreateShapeExcel;
|
||||
import com.actionsoft.apps.coe.pal.batch.web.create.shape.ImportShapeExcel;
|
||||
import com.actionsoft.apps.coe.pal.batch.web.create.shape.ValidShapeExcel;
|
||||
import com.actionsoft.apps.coe.pal.batch.web.create.shape.*;
|
||||
import com.actionsoft.apps.coe.pal.batch.web.replace.FilterReplaceProcess;
|
||||
import com.actionsoft.apps.coe.pal.batch.web.replace.ReplaceProcessSave;
|
||||
import com.actionsoft.apps.coe.pal.constant.CoEConstant;
|
||||
@ -39,6 +38,8 @@ import com.actionsoft.sdk.local.SDK;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -102,7 +103,9 @@ public class BatchWeb extends ActionWeb {
|
||||
if (BatchConst.PROCESS_LIST.equals(type)) {
|
||||
ro = new CreateProcessExcel().createProcessTemplate(uc, wsId, methodCategory);
|
||||
} else if (BatchConst.SHAPE_LIST.equals(type)) {
|
||||
ro = new CreateShapeExcel().createShapeTemplate(uc, wsId, methodCategory);
|
||||
ro = new CreateShapeExcel().createShapeImportTemplate(uc, wsId, methodCategory);
|
||||
} else if (BatchConst.SHAPE_IMPORT.equals(type)) {
|
||||
ro = new CreateShapeExcel().createShapeImportTemplate(uc, wsId, methodCategory);
|
||||
}
|
||||
return ro.toString();
|
||||
}
|
||||
@ -328,12 +331,34 @@ public class BatchWeb extends ActionWeb {
|
||||
e.printStackTrace();
|
||||
}
|
||||
logPath = simpleLogFile.getPath();
|
||||
|
||||
|
||||
DCPluginProfile dcProfile1 = DCProfileManager.getDCProfile(BatchConst.APP_ID, BatchConst.TMP);
|
||||
DCContext dc1 = new DCContext(uc, dcProfile1, BatchConst.APP_ID, BatchConst.UPLOAD, object.getString("fileValue"));
|
||||
String fileLength = dc1.getFileLength();
|
||||
File file = new File(dc1.getPath());
|
||||
XSSFSheet sheet = null;
|
||||
if (!file.isFile()){
|
||||
File[] files = file.listFiles();
|
||||
File file1 = files[0];
|
||||
XSSFWorkbook wb = POIUtil.getWorkbook(file1);
|
||||
if (wb != null){
|
||||
String sheetName1 = ShapeUtil.getModelShapeImportName(methodCategory);
|
||||
sheet = wb.getSheet(sheetName1);
|
||||
sheetName1.length();
|
||||
}
|
||||
}
|
||||
|
||||
if ("processList".equals(type)) {// 流程清单保存
|
||||
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, methodCategory);}) .start();
|
||||
if (sheet!=null){
|
||||
//模型导入保存
|
||||
new Thread(()->{new ImportShapeExcel1().execute(uc, object, simpleLogFile, fullLogFile, logId, methodCategory);}) .start();
|
||||
// new ImportShapeExcel1().execute(uc, object, simpleLogFile, fullLogFile, logId, methodCategory);
|
||||
}else {
|
||||
new Thread(()->{new ImportShapeExcel().execute(uc, object, simpleLogFile, fullLogFile, logId, methodCategory);}) .start();
|
||||
}
|
||||
}
|
||||
ResponseObject ro = ResponseObject.newOkResponse();
|
||||
ro.put("type", type);
|
||||
|
||||
@ -329,5 +329,33 @@ public class ProcessUtil {
|
||||
}
|
||||
return recentVerList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取指定根目录下所有的使用中版本模型列表
|
||||
* @param wsId
|
||||
* @param category 根节点分类,如process,data,org等
|
||||
* @return
|
||||
*/
|
||||
public static List<PALRepositoryModel> getInuseRepositoryList(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()).isUse() && model.isUse()) {
|
||||
modelMap.put(model.getVersionId(), model);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Map.Entry<String, PALRepositoryModel> entry : modelMap.entrySet()) {
|
||||
recentVerList.add(entry.getValue());
|
||||
}
|
||||
return recentVerList;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.actionsoft.apps.coe.pal.batch.web.create.process.ProcessConst;
|
||||
import com.actionsoft.apps.coe.pal.batch.web.create.process.ProcessUtil;
|
||||
@ -51,6 +52,33 @@ public class CreateShapeExcel {
|
||||
ro.put("url", createExcelTemplate(uc, methodCategory, methodNames, shapeNames));
|
||||
return ro;
|
||||
}
|
||||
public ResponseObject createShapeImportTemplate(UserContext uc, String wsId, String methodCategory) {
|
||||
|
||||
//导入泳道图特殊处理
|
||||
if (!methodCategory.equals("process")){
|
||||
return ResponseObject.newErrResponse("仅支持流程制度下泳道图模型导入");
|
||||
}
|
||||
// 获取当前资产库模型下的所有类别
|
||||
Map<String, List<String>> shapeTitleMap = ShapeUtil.getProcessShapeTitles(methodCategory);
|
||||
//泳道图特殊处理
|
||||
Map<String, List<String>> tempMap = new HashMap<>();
|
||||
shapeTitleMap.entrySet().stream().filter(item->{
|
||||
return item.getKey().equals("process.flowchart");
|
||||
}).forEach(item->{
|
||||
tempMap.put(item.getKey(),item.getValue());
|
||||
});
|
||||
shapeTitleMap = tempMap;
|
||||
|
||||
List<String> methodNames = new ArrayList<>();// 建模方法分类
|
||||
List<String> shapeNames = new ArrayList<>();// 形状类型名称
|
||||
for (Map.Entry<String, List<String>> entry : shapeTitleMap.entrySet()) {
|
||||
methodNames.add(I18nRes.findValue(CoEConstant.APP_ID, entry.getKey()));
|
||||
shapeNames.addAll(entry.getValue());
|
||||
}
|
||||
ResponseObject ro = ResponseObject.newOkResponse();
|
||||
ro.put("url", createExcelImportTemplate(uc, methodCategory, methodNames, shapeNames));
|
||||
return ro;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取sheet页名称
|
||||
@ -210,4 +238,133 @@ public class CreateShapeExcel {
|
||||
return downloadURL;
|
||||
}
|
||||
|
||||
private String createExcelImportTemplate(UserContext uc, String methodCategory, List<String> methodNames, List<String> shapeNames) {
|
||||
// 模型名称、模型类型、形状名称、形状类型、扩展<xx>、...
|
||||
String groupValue = "template";
|
||||
String fileValue = UUIDGener.getUUID();
|
||||
DCPluginProfile dcProfile = DCProfileManager.getDCProfile(BatchConst.APP_ID, BatchConst.TMP);
|
||||
DCContext dcContext = new DCContext(uc, dcProfile, BatchConst.APP_ID, groupValue, fileValue);
|
||||
UtilFile utilFile = new UtilFile(dcContext.getPath());
|
||||
// 创建文件
|
||||
utilFile.mkdirs();
|
||||
String excelName = I18nRes.findValue(CoEConstant.APP_ID, methodCategory) + BatchConst.SHAPE_IMPORT_TEMPLATE_FILE_SUFFIX;
|
||||
File file = new File(utilFile + File.separator + excelName);
|
||||
try {
|
||||
file.createNewFile();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
XSSFWorkbook wb = new XSSFWorkbook();// 创建Excel工作簿对象
|
||||
// 模型清单页签
|
||||
XSSFSheet sheet = wb.createSheet(ShapeUtil.getModelShapeImportName(methodCategory));// 创建工作表对象
|
||||
XSSFRow titleRow = sheet.createRow(0);
|
||||
titleRow.setHeightInPoints(25);
|
||||
// 单元格样式
|
||||
XSSFCellStyle cellStyle = POIUtil.getMainCellStyle(wb);
|
||||
XSSFCellStyle cellStyle2 = POIUtil.getExtendCellStyle(wb);
|
||||
XSSFCellStyle commStyle = POIUtil.getTableCellStyle(wb);
|
||||
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(ShapeConst.TABLE_REPOSITORY_NAME);
|
||||
sheet.setColumnWidth((short)index, 13000);// 设置当前列宽度
|
||||
index++;
|
||||
// 模型类型
|
||||
titleList.add(titleRow.createCell((short)index));
|
||||
titleList.get((short)index).setCellStyle(cellStyle);
|
||||
titleList.get((short)index).setCellValue(ShapeConst.TABLE_REPOSITORY_TYPE);
|
||||
sheet.setColumnWidth((short)index, 6000);// 设置当前列宽度
|
||||
// 设置下拉框
|
||||
XSSFDataValidationHelper dvHelper = new XSSFDataValidationHelper(sheet);
|
||||
XSSFDataValidationConstraint dvConstraint = (XSSFDataValidationConstraint) dvHelper.createExplicitListConstraint(methodNames.toArray(new String [methodNames.size()]));
|
||||
CellRangeAddressList addressList = new CellRangeAddressList(1, 65536, 1, 1);
|
||||
XSSFDataValidation validation =(XSSFDataValidation)dvHelper.createValidation(dvConstraint, addressList);
|
||||
sheet.addValidationData(validation);
|
||||
index++;
|
||||
// 节点名称
|
||||
titleList.add(titleRow.createCell((short)index));
|
||||
titleList.get((short)index).setCellStyle(cellStyle);
|
||||
titleList.get((short)index).setCellValue(ShapeConst.TABLE_SHAPE_NAME);
|
||||
sheet.setColumnWidth((short)index, 13000);// 设置当前列宽度
|
||||
index++;
|
||||
// 节点类型
|
||||
titleList.add(titleRow.createCell(index));
|
||||
titleList.get((short)index).setCellStyle(cellStyle);
|
||||
titleList.get((short)index).setCellValue(ShapeConst.TABLE_SHAPE_TYPE);
|
||||
sheet.setColumnWidth((short)index, 6000);// 设置当前列宽度
|
||||
// 设置下拉框
|
||||
// 下拉框数量超过20个,通过sheet页建立下拉框选择
|
||||
// XSSFDataValidationHelper dvHelper2 = new XSSFDataValidationHelper(sheet);
|
||||
// XSSFDataValidationConstraint dvConstraint2 = (XSSFDataValidationConstraint) dvHelper2.createExplicitListConstraint(shapeNames.toArray(new String [shapeNames.size()]));
|
||||
// CellRangeAddressList addressList2 = new CellRangeAddressList(1, 65536, 3, 3);
|
||||
// XSSFDataValidation validation2 =(XSSFDataValidation)dvHelper2.createValidation(dvConstraint2, addressList2);
|
||||
// sheet.addValidationData(validation2);
|
||||
index++;
|
||||
//节点分支
|
||||
titleList.add(titleRow.createCell((short)index));
|
||||
titleList.get((short)index).setCellStyle(cellStyle);
|
||||
titleList.get((short)index).setCellValue(ShapeConst.TABLE_SHAPE_BRANCH);
|
||||
sheet.setColumnWidth((short)index, 6000);// 设置当前列宽度
|
||||
index++;
|
||||
//节点编号
|
||||
titleList.add(titleRow.createCell((short)index));
|
||||
titleList.get((short)index).setCellStyle(cellStyle);
|
||||
titleList.get((short)index).setCellValue(ShapeConst.TABLE_SHAPE_NUM);
|
||||
sheet.setColumnWidth((short)index, 6000);// 设置当前列宽度
|
||||
index++;
|
||||
|
||||
// 以下为扩展
|
||||
titleList.add(titleRow.createCell(index));
|
||||
titleList.get((short)index).setCellStyle(cellStyle2);
|
||||
titleList.get((short)index).setCellValue(ShapeConst.TABLE_EXTAND_EXAMPLE);
|
||||
sheet.setColumnWidth((short)index, 6000);// 设置当前列宽度
|
||||
|
||||
index++;
|
||||
|
||||
titleList.add(titleRow.createCell(index));
|
||||
titleList.get((short)index).setCellStyle(cellStyle2);
|
||||
titleList.get((short)index).setCellValue(ShapeConst.TABLE_EXTAND_EXAMPLE2);
|
||||
sheet.setColumnWidth((short)index, 4000);// 设置当前列宽度
|
||||
|
||||
// 创建20行的表格
|
||||
for (int i = 0; i < 20; i++) {
|
||||
XSSFRow dataRow = sheet.createRow(i+1);
|
||||
List<XSSFCell> dataList = new ArrayList<>();
|
||||
for (int j = 0; j < index + 1; j++) {
|
||||
dataList.add(dataRow.createCell(j));
|
||||
dataList.get((short)j).setCellStyle(commStyle);
|
||||
}
|
||||
}
|
||||
// 增加说明页
|
||||
File descFile = new File(BatchConst.TEMPLATE_FILE_PATH + BatchConst.SHAPE_IMPORT_TEMPLATE_FILE_SUFFIX);
|
||||
if (descFile.exists()) {
|
||||
XSSFWorkbook descWb;
|
||||
try {
|
||||
descWb = new XSSFWorkbook(descFile);
|
||||
XSSFSheet descSheet = descWb.getSheetAt(1);
|
||||
if (descSheet != null) {
|
||||
XSSFSheet sheet2 = wb.createSheet(ProcessConst.SHEET_HELPER);
|
||||
POIUtil.copySheet(wb, descSheet, sheet2, true);
|
||||
}
|
||||
} catch (InvalidFormatException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
// 处理形状类型下拉框
|
||||
POIUtil.setLongXSSFValidation(wb, shapeNames.toArray(new String [shapeNames.size()]), sheet, 1, 65536, 3, 2, "形状类型选项");
|
||||
wb.write(new FileOutputStream(file));
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
DCContext dc = new DCContext(uc, dcProfile, BatchConst.APP_ID, groupValue, fileValue, file.getName());
|
||||
String downloadURL = dc.getDownloadURL() + "&isInline=false";
|
||||
return downloadURL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -4,6 +4,7 @@ public class ShapeConst {
|
||||
|
||||
// Excel工作表sheet页名称
|
||||
public final static String SHEET_NAME_SUFFIX = "模型形状清单";
|
||||
public final static String SHEET_NAME_IMPORT_SUFFIX = "模型导入清单";
|
||||
public final static String SHEET_HELPER = "说明";
|
||||
|
||||
// 扩展属性名称前后缀
|
||||
@ -16,6 +17,8 @@ public class ShapeConst {
|
||||
public final static String TABLE_REPOSITORY_TYPE = "模型类型";
|
||||
public final static String TABLE_SHAPE_NAME = "形状名称";
|
||||
public final static String TABLE_SHAPE_TYPE = "形状类型";
|
||||
public final static String TABLE_SHAPE_BRANCH = "形状分支";
|
||||
public final static String TABLE_SHAPE_NUM = "形状编号";
|
||||
public final static String TABLE_EXTAND_EXAMPLE = "扩展<xxx>";
|
||||
public final static String TABLE_EXTAND_EXAMPLE2 = "...";
|
||||
|
||||
@ -23,4 +26,17 @@ public class ShapeConst {
|
||||
public final static String [] SHAPE_TITLE_ROW = new String [] {TABLE_REPOSITORY_NAME, TABLE_REPOSITORY_TYPE, TABLE_SHAPE_NAME, TABLE_SHAPE_TYPE};
|
||||
public final static String SHAPE_BASE_TITLE_ROW = "模型名称、模型类型、形状名称、形状类型";
|
||||
|
||||
public final static String [] SHAPE_TITLE_ROW_IMPORT = new String [] {TABLE_REPOSITORY_NAME, TABLE_REPOSITORY_TYPE, TABLE_SHAPE_NAME, TABLE_SHAPE_TYPE,TABLE_SHAPE_BRANCH,TABLE_SHAPE_NUM};
|
||||
public final static String SHAPE_BASE_TITLE_ROW_IMPORT = "模型名称、模型类型、形状名称、形状类型、形状分支、形状编号";
|
||||
|
||||
|
||||
public final static Integer SHAPE_NODE_WIDTH = 200;
|
||||
public final static Integer SHAPE_NODE_HEIGHT = 70;
|
||||
|
||||
|
||||
public final static Integer SHAPE_NODE_INTERVAL = 50;
|
||||
public final static Integer SHAPE_HEIGHT_INTERVAL = 100;
|
||||
|
||||
public final static Integer SHAPE_BRANCH_INTERVAL = 500;
|
||||
|
||||
}
|
||||
|
||||
@ -19,6 +19,9 @@ public class ShapeUtil {
|
||||
public static String getModelShapeListName(String methodCategory) {
|
||||
return I18nRes .findValue(CoEConstant.APP_ID, methodCategory) + ShapeConst.SHEET_NAME_SUFFIX;
|
||||
}
|
||||
public static String getModelShapeImportName(String methodCategory) {
|
||||
return I18nRes.findValue(CoEConstant.APP_ID, methodCategory) + ShapeConst.SHEET_NAME_IMPORT_SUFFIX;
|
||||
}
|
||||
|
||||
/**
|
||||
* BPMN图并不全部使用,给定范围
|
||||
|
||||
@ -17,6 +17,8 @@ import com.actionsoft.apps.coe.pal.cooperation.CoeCooperationAPIManager;
|
||||
import com.actionsoft.apps.coe.pal.pal.method.cache.PALMethodCache;
|
||||
import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodModel;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.designer.manage.CoeDesignerAPIManager;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.designer.model.BaseModel;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.designer.util.CoeDesignerUtil;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel;
|
||||
import com.actionsoft.i18n.I18nRes;
|
||||
@ -61,6 +63,12 @@ public class ValidShapeExcel {
|
||||
String sheetName = ShapeUtil.getModelShapeListName(methodCategory);
|
||||
XSSFSheet sheet = wb.getSheet(sheetName);
|
||||
if (sheet == null) {
|
||||
//模型导入 入口
|
||||
String sheetName1 = ShapeUtil.getModelShapeImportName(methodCategory);
|
||||
XSSFSheet sheet1 = wb.getSheet(sheetName1);
|
||||
if (null != sheet1){
|
||||
return this.checkShapeImportList(uc, file, wsId, teamId, methodCategory);
|
||||
}
|
||||
return ResponseObject.newErrResponse(errMsg + "上传文件中【" + sheetName + "】工作表不存在");
|
||||
}
|
||||
List<String> titleList = new LinkedList<String>();
|
||||
@ -96,6 +104,50 @@ public class ValidShapeExcel {
|
||||
return ro;
|
||||
}
|
||||
|
||||
public ResponseObject checkShapeImportList(UserContext uc, File file, String wsId, String teamId, String methodCategory) {
|
||||
XSSFWorkbook wb = POIUtil.getWorkbook(file);
|
||||
if (wb == null) {
|
||||
return ResponseObject.newErrResponse(errMsg + "获取上传文件失败");
|
||||
}
|
||||
|
||||
String sheetName = ShapeUtil.getModelShapeImportName(methodCategory);
|
||||
XSSFSheet sheet = wb.getSheet(sheetName);
|
||||
if (sheet == null) {
|
||||
return ResponseObject.newErrResponse(errMsg + "上传文件中【" + sheetName + "】工作表不存在");
|
||||
}
|
||||
List<String> titleList = new LinkedList<String>();
|
||||
XSSFRow titleRow = sheet.getRow(0);
|
||||
if (titleRow == null ) {
|
||||
return ResponseObject.newErrResponse(errMsg + "上传文件工作表中首行为标题行,不能为空,请调整");
|
||||
}
|
||||
int cellNum = titleRow.getLastCellNum();
|
||||
for (int i = 0; i < cellNum; i++) {
|
||||
XSSFCell cell = titleRow.getCell(i);
|
||||
String title = POIUtil.getCellValueByCell(cell);
|
||||
if (UtilString.isEmpty(title)) {
|
||||
break;
|
||||
}
|
||||
titleList.add(title);
|
||||
}
|
||||
if (titleList.size() == 0) {
|
||||
return ResponseObject.newErrResponse(errMsg + "上传文件工作表中首行为标题行,不能为空,请调整");
|
||||
}
|
||||
// 校验标题行
|
||||
ResponseObject checkTitleRo = checkTitleRowImport(wsId, titleList, methodCategory);
|
||||
if (!checkTitleRo.isOk()) {
|
||||
return checkTitleRo;
|
||||
}
|
||||
// 构造Excel数据model
|
||||
List<ExcelShapeModel> excelShapeModels = handleImportExcel2Model(sheet, titleList);
|
||||
ResponseObject ro = ResponseObject.newOkResponse();
|
||||
// 获取所有数据
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("titleRow", titleList);
|
||||
result.put("data", checkImportData(wsId, teamId, methodCategory, uc, excelShapeModels, titleList));
|
||||
ro.put("data", result);
|
||||
return ro;
|
||||
}
|
||||
|
||||
/**
|
||||
* Excel中数据转换为model处理
|
||||
* @param sheet
|
||||
@ -131,6 +183,47 @@ public class ValidShapeExcel {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Excel中数据转换为model处理
|
||||
* @param sheet
|
||||
* @param titleList
|
||||
* @return
|
||||
*/
|
||||
private List<ExcelShapeModel> handleImportExcel2Model(XSSFSheet sheet, List<String> titleList) {
|
||||
List<ExcelShapeModel> result = new ArrayList<>();
|
||||
// 获取所有Excel数据
|
||||
List<List<String>> dataList = getDataList(sheet, titleList);
|
||||
// Excel内容转换为Model
|
||||
int row = 1;
|
||||
for (List<String> rowDataList : dataList) {
|
||||
// 0,模型名称
|
||||
String repositoryName = rowDataList.get(0);
|
||||
// 1,模型类型
|
||||
String repositoryType = rowDataList.get(1);
|
||||
// 2,形状名称
|
||||
String shapeName = rowDataList.get(2);
|
||||
// 3,形状类型
|
||||
String shapeType = rowDataList.get(3);
|
||||
// 4,形状分支
|
||||
String shapeBranch = rowDataList.get(4);
|
||||
// 5,形状编号
|
||||
String shapeNo = rowDataList.get(5);
|
||||
// 6,扩展属性
|
||||
List<String> shapeRowList = new ArrayList<>(rowDataList.stream().collect(Collectors.toList()));
|
||||
ExcelShapeModel excelShapeModel = new ExcelShapeModel();
|
||||
excelShapeModel.setRow(row++);
|
||||
excelShapeModel.setRepositoryName(repositoryName);
|
||||
excelShapeModel.setRepositoryType(repositoryType);
|
||||
excelShapeModel.setShapeName(shapeName);
|
||||
excelShapeModel.setShapeType(shapeType);
|
||||
excelShapeModel.setShapeBranch(shapeBranch);
|
||||
excelShapeModel.setShapeNo(shapeNo);
|
||||
excelShapeModel.setRowData(shapeRowList);
|
||||
result.add(excelShapeModel);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验数据
|
||||
* @param wsId
|
||||
@ -610,6 +703,578 @@ public class ValidShapeExcel {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 校验数据
|
||||
* @param wsId
|
||||
* @param teamId
|
||||
* @param methodCategory
|
||||
* @param uc
|
||||
* @param excelShapeModels
|
||||
* @param titleList
|
||||
* @return
|
||||
*/
|
||||
private JSONObject checkImportData(String wsId, String teamId, String methodCategory, UserContext uc, List<ExcelShapeModel> excelShapeModels, List<String> titleList) {
|
||||
Iterator<ExcelShapeModel> iterator = excelShapeModels.iterator();
|
||||
// 1. 过滤掉关键信息空白的数据(模型名称、模型类型、形状名称、形状类型、形状分支、形状编号任一为空即满足过滤条件)
|
||||
List<RepositoryShapeInfoModel> blankList = new ArrayList();
|
||||
while (iterator.hasNext()) {
|
||||
ExcelShapeModel row = iterator.next();
|
||||
String repositoryName = row.getRepositoryName();
|
||||
String repositoryType = row.getRepositoryType();
|
||||
String shapeName = row.getShapeName();
|
||||
String shapeType = row.getShapeType();
|
||||
String shapeBranch = row.getShapeBranch();
|
||||
String shapeNo = row.getShapeNo();
|
||||
// 校验模型名称、模型类型、形状名称、形状类型、形状分支、形状编号任一为空
|
||||
if (UtilString.isEmpty(repositoryName) || UtilString.isEmpty(repositoryType)
|
||||
|| UtilString.isEmpty(shapeName) || UtilString.isEmpty(shapeType)
|
||||
|| UtilString.isEmpty(shapeBranch) || UtilString.isEmpty(shapeNo)) {
|
||||
RepositoryShapeInfoModel blankModel = new RepositoryShapeInfoModel();
|
||||
blankModel.setRepositoryName(repositoryName);
|
||||
blankModel.setMethodName(repositoryType);
|
||||
blankModel.setShapeName(shapeName);
|
||||
blankModel.setShapeType(shapeType);
|
||||
blankModel.setShapeBranch(shapeBranch);
|
||||
blankModel.setShapeNo(shapeNo);
|
||||
blankModel.setExcelShapeModel(row);
|
||||
blankModel.setResult("blank");
|
||||
blankModel.setRowOk(false);
|
||||
blankModel.setRowMsg(ShapeConst.SHAPE_BASE_TITLE_ROW_IMPORT + "不允许为空");
|
||||
blankList.add(blankModel);
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
// 2.过滤掉Excel中的重复数据记录(模型名称、模型类型、形状名称、形状类型、形状分支、形状编号四项内容完全重复)
|
||||
List<RepositoryShapeInfoModel> excelRepeatList = new ArrayList<>();
|
||||
Map<String, Integer> tmpMap = new HashMap<>();
|
||||
iterator = excelShapeModels.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
ExcelShapeModel row = iterator.next();
|
||||
String repositoryName = row.getRepositoryName();
|
||||
String repositoryType = row.getRepositoryType();
|
||||
String shapeName = row.getShapeName();
|
||||
String shapeType = row.getShapeType();
|
||||
String shapeBranch = row.getShapeBranch();
|
||||
String shapeNo = row.getShapeNo();
|
||||
String key = repositoryName + "|" + repositoryType + "|" + shapeName + "|" + shapeType+ "|" + shapeBranch+ "|" + shapeNo;
|
||||
if (tmpMap.containsKey(key)) {
|
||||
RepositoryShapeInfoModel repeatModel = new RepositoryShapeInfoModel();
|
||||
repeatModel.setRepositoryName(repositoryName);
|
||||
repeatModel.setMethodName(repositoryType);
|
||||
repeatModel.setShapeName(shapeName);
|
||||
repeatModel.setShapeType(shapeType);
|
||||
repeatModel.setShapeBranch(shapeBranch);
|
||||
repeatModel.setShapeNo(shapeNo);
|
||||
repeatModel.setExcelShapeModel(row);
|
||||
repeatModel.setResult("repeat");
|
||||
repeatModel.setRowOk(false);
|
||||
repeatModel.setRowMsg("与第" + tmpMap.get(key) + "行重复");
|
||||
excelRepeatList.add(repeatModel);
|
||||
iterator.remove();
|
||||
} else {
|
||||
tmpMap.put(key, row.getRow());
|
||||
}
|
||||
}
|
||||
|
||||
// 获取PAL模型信息(多版本只取使用中版本)
|
||||
List<PALRepositoryModel> inuseRepositoryList = ProcessUtil.getInuseRepositoryList(wsId, methodCategory);
|
||||
Map<String, String> repositoryMap = new HashMap<>();// 按照名称+建模分类名称记录对应id
|
||||
Map<String, Integer> repeatNameCountMap = new HashMap<>();// 统计名称重复的
|
||||
for (PALRepositoryModel model : inuseRepositoryList) {
|
||||
String key = model.getName() + "|||" + I18nRes.findValue(CoEConstant.APP_ID, model.getMethodId());
|
||||
repositoryMap.put(key, model.getId());
|
||||
if (!repeatNameCountMap.containsKey(key)) {
|
||||
repeatNameCountMap.put(key, 0);
|
||||
}
|
||||
repeatNameCountMap.put(key, repeatNameCountMap.get(key) + 1);
|
||||
}
|
||||
// 3.模型没有匹配上
|
||||
List<RepositoryShapeInfoModel> noMatchList = new ArrayList<>();
|
||||
iterator = excelShapeModels.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
ExcelShapeModel row = iterator.next();
|
||||
String repositoryName = row.getRepositoryName();
|
||||
String repositoryType = row.getRepositoryType();
|
||||
String shapeName = row.getShapeName();
|
||||
String shapeType = row.getShapeType();
|
||||
String shapeBranch = row.getShapeBranch();
|
||||
String shapeNo = row.getShapeNo();
|
||||
String key = repositoryName + "|||" + repositoryType;
|
||||
if (!repositoryMap.containsKey(key)) {
|
||||
RepositoryShapeInfoModel noMatchModel = new RepositoryShapeInfoModel();
|
||||
noMatchModel.setRepositoryName(repositoryName);
|
||||
noMatchModel.setMethodName(repositoryType);
|
||||
noMatchModel.setShapeName(shapeName);
|
||||
noMatchModel.setShapeType(shapeType);
|
||||
noMatchModel.setShapeBranch(shapeBranch);
|
||||
noMatchModel.setShapeNo(shapeNo);
|
||||
noMatchModel.setExcelShapeModel(row);
|
||||
noMatchModel.setResult("noMatch");
|
||||
noMatchModel.setRowOk(false);
|
||||
noMatchModel.setRowMsg("PAL中不存在对应的模型");
|
||||
noMatchList.add(noMatchModel);
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
// 4.模型没有写权限
|
||||
List<RepositoryShapeInfoModel> noPermList = new ArrayList<>();
|
||||
if (!UtilString.isEmpty(teamId)) {
|
||||
iterator = excelShapeModels.iterator();
|
||||
Set<String> permVerIds = BatchUtil.getPermVersionIds(wsId, teamId, uc.getUID());
|
||||
while (iterator.hasNext()) {
|
||||
ExcelShapeModel row = iterator.next();
|
||||
String repositoryName = row.getRepositoryName();
|
||||
String repositoryType = row.getRepositoryType();
|
||||
String shapeName = row.getShapeName();
|
||||
String shapeType = row.getShapeType();
|
||||
String shapeBranch = row.getShapeBranch();
|
||||
String shapeNo = row.getShapeNo();
|
||||
String key = repositoryName + "|||" + repositoryType;
|
||||
String palId = repositoryMap.get(key);
|
||||
PALRepositoryModel plModel = PALRepositoryCache.getCache().get(palId);
|
||||
BaseModel defineModel = CoeDesignerAPIManager.getInstance().getDefinition(plModel.getId(), 0);
|
||||
String define = defineModel.getDefinition();
|
||||
JSONObject definition = JSON.parseObject(define);
|
||||
JSONObject elements = definition.getJSONObject("elements");
|
||||
|
||||
if (!permVerIds.contains(plModel.getVersionId())) {
|
||||
RepositoryShapeInfoModel noPermModel = new RepositoryShapeInfoModel();
|
||||
noPermModel.setRepositoryName(repositoryName);
|
||||
noPermModel.setMethodName(repositoryType);
|
||||
noPermModel.setShapeName(shapeName);
|
||||
noPermModel.setShapeType(shapeType);
|
||||
noPermModel.setShapeBranch(shapeBranch);
|
||||
noPermModel.setShapeNo(shapeNo);
|
||||
noPermModel.setExcelShapeModel(row);
|
||||
noPermModel.setResult("noPerm");
|
||||
noPermModel.setRowOk(false);
|
||||
noPermModel.setRowMsg("没有对应的数据编辑权限");
|
||||
noPermList.add(noPermModel);
|
||||
iterator.remove();
|
||||
}else if (null == elements || elements.isEmpty()){
|
||||
RepositoryShapeInfoModel noPermModel = new RepositoryShapeInfoModel();
|
||||
noPermModel.setRepositoryName(repositoryName);
|
||||
noPermModel.setMethodName(repositoryType);
|
||||
noPermModel.setShapeName(shapeName);
|
||||
noPermModel.setShapeType(shapeType);
|
||||
noPermModel.setShapeBranch(shapeBranch);
|
||||
noPermModel.setShapeNo(shapeNo);
|
||||
noPermModel.setExcelShapeModel(row);
|
||||
noPermModel.setResult("noPerm");
|
||||
noPermModel.setRowOk(false);
|
||||
noPermModel.setRowMsg("模型已存在形状信息");
|
||||
noPermList.add(noPermModel);
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//已存在形状模型没有权限
|
||||
iterator = excelShapeModels.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
ExcelShapeModel row = iterator.next();
|
||||
String repositoryName = row.getRepositoryName();
|
||||
String repositoryType = row.getRepositoryType();
|
||||
String shapeName = row.getShapeName();
|
||||
String shapeType = row.getShapeType();
|
||||
String shapeBranch = row.getShapeBranch();
|
||||
String shapeNo = row.getShapeNo();
|
||||
String key = repositoryName + "|||" + repositoryType;
|
||||
String palId = repositoryMap.get(key);
|
||||
PALRepositoryModel plModel = PALRepositoryCache.getCache().get(palId);
|
||||
BaseModel defineModel = CoeDesignerAPIManager.getInstance().getDefinition(plModel.getId(), 0);
|
||||
String define = defineModel.getDefinition();
|
||||
JSONObject definition = JSON.parseObject(define);
|
||||
JSONObject elements = definition.getJSONObject("elements");
|
||||
if (null != elements && !elements.isEmpty()){
|
||||
RepositoryShapeInfoModel noPermModel = new RepositoryShapeInfoModel();
|
||||
noPermModel.setRepositoryName(repositoryName);
|
||||
noPermModel.setMethodName(repositoryType);
|
||||
noPermModel.setShapeName(shapeName);
|
||||
noPermModel.setShapeType(shapeType);
|
||||
noPermModel.setShapeBranch(shapeBranch);
|
||||
noPermModel.setShapeNo(shapeNo);
|
||||
noPermModel.setExcelShapeModel(row);
|
||||
noPermModel.setResult("noPerm");
|
||||
noPermModel.setRowOk(false);
|
||||
noPermModel.setRowMsg("模型已存在形状信息");
|
||||
noPermList.add(noPermModel);
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 5.模型出现了多个匹配
|
||||
List<RepositoryShapeInfoModel> moreMatchList = new ArrayList<>();
|
||||
iterator = excelShapeModels.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
ExcelShapeModel row = iterator.next();
|
||||
String repositoryName = row.getRepositoryName();
|
||||
String repositoryType = row.getRepositoryType();
|
||||
String shapeName = row.getShapeName();
|
||||
String shapeType = row.getShapeType();
|
||||
String shapeBranch = row.getShapeBranch();
|
||||
String shapeNo = row.getShapeNo();
|
||||
String key = repositoryName + "|||" + repositoryType;
|
||||
String palId = repositoryMap.get(key);
|
||||
PALRepositoryModel plModel = PALRepositoryCache.getCache().get(palId);
|
||||
if (repeatNameCountMap.get(key) > 1) {
|
||||
RepositoryShapeInfoModel moreMatchModel = new RepositoryShapeInfoModel();
|
||||
moreMatchModel.setRepositoryId(palId);
|
||||
moreMatchModel.setRepositoryName(repositoryName);
|
||||
moreMatchModel.setMethodName(repositoryType);
|
||||
moreMatchModel.setMethodId(plModel.getMethodId());
|
||||
moreMatchModel.setShapeName(shapeName);
|
||||
moreMatchModel.setShapeType(shapeType);
|
||||
moreMatchModel.setShapeBranch(shapeBranch);
|
||||
moreMatchModel.setShapeNo(shapeNo);
|
||||
moreMatchModel.setExcelShapeModel(row);
|
||||
moreMatchModel.setResult("moreMatch");
|
||||
moreMatchModel.setRowOk(false);
|
||||
moreMatchModel.setRowMsg("出现PAL多个符合条件的模型");
|
||||
moreMatchList.add(moreMatchModel);
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
// 6.存在模型为只读的
|
||||
List<RepositoryShapeInfoModel> readonlyList = new ArrayList<>();
|
||||
iterator = excelShapeModels.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
ExcelShapeModel row = iterator.next();
|
||||
String repositoryName = row.getRepositoryName();
|
||||
String repositoryType = row.getRepositoryType();
|
||||
String shapeName = row.getShapeName();
|
||||
String shapeType = row.getShapeType();
|
||||
String shapeBranch = row.getShapeBranch();
|
||||
String shapeNo = row.getShapeNo();
|
||||
String key = repositoryName + "|||" + repositoryType;
|
||||
String palId = repositoryMap.get(key);
|
||||
PALRepositoryModel plModel = PALRepositoryCache.getCache().get(palId);
|
||||
if (plModel.isPublish() || plModel.isApproval() || plModel.isApproval()) {// 已发布、审批中、停用则记录不更新
|
||||
String status = plModel.isPublish() ? "已发布" : plModel.isApproval() ? "审批中" : "已停用";
|
||||
RepositoryShapeInfoModel readonlyModel = new RepositoryShapeInfoModel();
|
||||
readonlyModel.setRepositoryId(palId);
|
||||
readonlyModel.setRepositoryName(repositoryName);
|
||||
readonlyModel.setMethodName(repositoryType);
|
||||
readonlyModel.setMethodId(plModel.getMethodId());
|
||||
readonlyModel.setShapeName(shapeName);
|
||||
readonlyModel.setShapeType(shapeType);
|
||||
readonlyModel.setShapeBranch(shapeBranch);
|
||||
readonlyModel.setShapeNo(shapeNo);
|
||||
readonlyModel.setExcelShapeModel(row);
|
||||
readonlyModel.setResult("readonly");
|
||||
readonlyModel.setRowOk(false);
|
||||
readonlyModel.setRowMsg("模型" + status + "不可编辑");
|
||||
readonlyList.add(readonlyModel);
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
// 查询一些形状定义
|
||||
/*Map<String, List<JSONObject>> shapeObjMap = new HashMap<>();// 形状定义信息
|
||||
Map<String, Map<String, String>> shapeMap = new HashMap<>();// 形状名称类型与id的映射关系
|
||||
// 剩下的数据先获取下形状信息,做进一步判断
|
||||
iterator = excelShapeModels.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
ExcelShapeModel row = iterator.next();
|
||||
String repositoryName = row.getRepositoryName();
|
||||
String repositoryType = row.getRepositoryType();
|
||||
String key = repositoryName + "|||" + repositoryType;
|
||||
String palId = repositoryMap.get(key);
|
||||
PALRepositoryModel plModel = PALRepositoryCache.getCache().get(palId);
|
||||
List<JSONObject> shapeList = CoeDesignerUtil.getShapeMessageJson5(palId);
|
||||
shapeObjMap.put(key, shapeList);
|
||||
}*/
|
||||
|
||||
// 形状名称+类型的数量统计 key:key,value:key:shapeName+shapeType,value:count
|
||||
/*Map<String, Map<String, Integer>> sameShapeMap = new HashMap<>();
|
||||
for (Map.Entry<String, List<JSONObject>> entry : shapeObjMap.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
List<JSONObject> shapeList = entry.getValue();
|
||||
for (JSONObject shapeObj : shapeList) {
|
||||
String shapeId = shapeObj.getString("id");
|
||||
String shapeName = com.actionsoft.apps.coe.pal.pal.repository.designer.util.ShapeUtil.replaceBlank(shapeObj.getString("text")).replace(" ", "");
|
||||
String shapeType = com.actionsoft.apps.coe.pal.pal.repository.designer.util.ShapeUtil.replaceBlank(shapeObj.getString("title")).replace(" ", "");
|
||||
String shapeKey = shapeName + "|||" + shapeType;
|
||||
// 形状名称+类型与对应的形状id映射记录
|
||||
if (!shapeMap.containsKey(key)) {
|
||||
shapeMap.put(key, new HashMap<>());
|
||||
}
|
||||
shapeMap.get(key).put(shapeKey, shapeId);
|
||||
|
||||
// 形状名称+类型的数量记录
|
||||
if (!sameShapeMap.containsKey(key)) {
|
||||
sameShapeMap.put(key, new HashMap<>());
|
||||
}
|
||||
if (!sameShapeMap.get(key).containsKey(shapeKey)) {
|
||||
sameShapeMap.get(key).put(shapeKey, 0);
|
||||
}
|
||||
sameShapeMap.get(key).put(shapeKey, sameShapeMap.get(key).get(shapeKey) + 1);
|
||||
}
|
||||
}*/
|
||||
|
||||
// 7.模型形状存在但是出现了多个匹配
|
||||
// 借用moreMatchList,不再创建新的,统一归为匹配出现多个类型
|
||||
/*iterator = excelShapeModels.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
ExcelShapeModel row = iterator.next();
|
||||
String repositoryName = row.getRepositoryName();
|
||||
String repositoryType = row.getRepositoryType();
|
||||
String shapeName = row.getShapeName();
|
||||
String shapeType = row.getShapeType();
|
||||
String key = repositoryName + "|||" + repositoryType;
|
||||
String palId = repositoryMap.get(key);
|
||||
PALRepositoryModel plModel = PALRepositoryCache.getCache().get(palId);
|
||||
String shapeKey = shapeName + "|||" + shapeType;
|
||||
if (sameShapeMap.containsKey(key) && sameShapeMap.get(key).containsKey(shapeKey) && sameShapeMap.get(key).get(shapeKey) > 1) {
|
||||
RepositoryShapeInfoModel moreMatchModel = new RepositoryShapeInfoModel();
|
||||
moreMatchModel.setRepositoryId(palId);
|
||||
moreMatchModel.setRepositoryName(repositoryName);
|
||||
moreMatchModel.setMethodName(repositoryType);
|
||||
moreMatchModel.setMethodId(plModel.getMethodId());
|
||||
moreMatchModel.setShapeName(shapeName);
|
||||
moreMatchModel.setShapeType(shapeType);
|
||||
moreMatchModel.setExcelShapeModel(row);
|
||||
moreMatchModel.setResult("moreMatch");
|
||||
moreMatchModel.setRowOk(false);
|
||||
moreMatchModel.setRowMsg("出现PAL多个符合条件的模型形状");
|
||||
moreMatchList.add(moreMatchModel);
|
||||
iterator.remove();
|
||||
}
|
||||
}*/
|
||||
|
||||
// 剩下的都是基本信息校验通过的
|
||||
List<RepositoryShapeInfoModel> matchShapeList = new ArrayList<>();
|
||||
iterator = excelShapeModels.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
ExcelShapeModel row = iterator.next();
|
||||
String repositoryName = row.getRepositoryName();
|
||||
String repositoryType = row.getRepositoryType();
|
||||
String shapeName = row.getShapeName();
|
||||
String shapeType = row.getShapeType();
|
||||
String shapeBranch = row.getShapeBranch();
|
||||
String shapeNo = row.getShapeNo();
|
||||
String key = repositoryName + "|||" + repositoryType;
|
||||
String palId = repositoryMap.get(key);
|
||||
PALRepositoryModel plModel = PALRepositoryCache.getCache().get(palId);
|
||||
String shapeKey = shapeName + "|||" + shapeType;
|
||||
// 8.模型形状需要新增
|
||||
String result = "add";
|
||||
String shapeId = "";
|
||||
// if (shapeMap.containsKey(key) && shapeMap.get(key).containsKey(shapeKey)) {
|
||||
// // 9.模型形状需要更新
|
||||
// shapeId = shapeMap.get(key).get(shapeKey);
|
||||
// result = "update";
|
||||
// }
|
||||
RepositoryShapeInfoModel shapeModel = new RepositoryShapeInfoModel();
|
||||
shapeModel.setRepositoryId(palId);
|
||||
shapeModel.setRepositoryName(repositoryName);
|
||||
shapeModel.setMethodName(repositoryType);
|
||||
shapeModel.setMethodId(plModel.getMethodId());
|
||||
shapeModel.setShapeName(shapeName);
|
||||
shapeModel.setShapeType(shapeType);
|
||||
shapeModel.setExcelShapeModel(row);
|
||||
shapeModel.setResult(result);
|
||||
shapeModel.setRowOk(true);
|
||||
shapeModel.setRowMsg("");
|
||||
matchShapeList.add(shapeModel);
|
||||
}
|
||||
// 10.校验属性
|
||||
for (int i = 0; i < matchShapeList.size(); i++) {
|
||||
RepositoryShapeInfoModel model = matchShapeList.get(i);
|
||||
ExcelShapeModel row = model.getExcelShapeModel();
|
||||
String repositoryName = model.getRepositoryName();
|
||||
String methodId = model.getMethodId();
|
||||
String shapeName = model.getShapeName();
|
||||
String shapeType = model.getShapeType();
|
||||
String shapeBranch = model.getShapeBranch();
|
||||
String shapeNo = model.getShapeNo();
|
||||
String shapeId = model.getShapeId();
|
||||
String key = repositoryName + "|||" + methodId;
|
||||
String palId = repositoryMap.get(key);
|
||||
JSONArray rowJson = new JSONArray();
|
||||
List<String> rowDataList = row.getRowData();
|
||||
for (int j = 0; j < rowDataList.size(); j++) {
|
||||
String title = titleList.get(j);
|
||||
String cellValue = rowDataList.get(j);
|
||||
// ****这里面要把所有的列都写全,不然界面的表格会出现列偏移****
|
||||
if (ShapeConst.TABLE_REPOSITORY_NAME.equals(title)) {
|
||||
JSONObject o = new JSONObject();
|
||||
o.put("name", ShapeConst.TABLE_REPOSITORY_NAME);
|
||||
o.put("name2", ShapeConst.TABLE_REPOSITORY_NAME);
|
||||
o.put("value", BatchUtil.specialCharTransfer(cellValue));
|
||||
o.put("isOk", true);
|
||||
o.put("msg", "");
|
||||
rowJson.add(o);
|
||||
} else if (ShapeConst.TABLE_REPOSITORY_TYPE.equals(title)) {
|
||||
JSONObject o = new JSONObject();
|
||||
o.put("name", ShapeConst.TABLE_REPOSITORY_TYPE);
|
||||
o.put("name2", ShapeConst.TABLE_REPOSITORY_TYPE);
|
||||
o.put("value", BatchUtil.specialCharTransfer(cellValue));
|
||||
o.put("isOk", true);
|
||||
o.put("msg", "");
|
||||
rowJson.add(o);
|
||||
} else if (ShapeConst.TABLE_SHAPE_NAME.equals(title)) {
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("value", cellValue);
|
||||
param.put("wsId", wsId);
|
||||
rowJson.add(JSONObject.parseObject(new ValidShape(new ValidShapeName()).execute(param).toString()));
|
||||
} else if (ShapeConst.TABLE_SHAPE_TYPE.equals(title)) {
|
||||
JSONObject o = new JSONObject();
|
||||
o.put("name", ShapeConst.TABLE_SHAPE_TYPE);
|
||||
o.put("name2", ShapeConst.TABLE_SHAPE_TYPE);
|
||||
o.put("value", BatchUtil.specialCharTransfer(cellValue));
|
||||
o.put("isOk", true);
|
||||
o.put("msg", "");
|
||||
rowJson.add(o);
|
||||
}else if (ShapeConst.TABLE_SHAPE_BRANCH.equals(title)) {
|
||||
JSONObject o = new JSONObject();
|
||||
o.put("name", ShapeConst.TABLE_SHAPE_BRANCH);
|
||||
o.put("name2", ShapeConst.TABLE_SHAPE_BRANCH);
|
||||
o.put("value", BatchUtil.specialCharTransfer(cellValue));
|
||||
o.put("isOk", true);
|
||||
o.put("msg", "");
|
||||
rowJson.add(o);
|
||||
}else if (ShapeConst.TABLE_SHAPE_NUM.equals(title)) {
|
||||
JSONObject o = new JSONObject();
|
||||
o.put("name", ShapeConst.TABLE_SHAPE_NUM);
|
||||
o.put("name2", ShapeConst.TABLE_SHAPE_NUM);
|
||||
o.put("value", BatchUtil.specialCharTransfer(cellValue));
|
||||
o.put("isOk", true);
|
||||
o.put("msg", "");
|
||||
rowJson.add(o);
|
||||
} else {// 扩展属性
|
||||
String propertyName = title.substring(title.indexOf("扩展<") + 3, title.lastIndexOf(">"));
|
||||
JSONObject methodAttrs = queryMethodAttrs(wsId, methodId, shapeType);
|
||||
if (methodAttrs.containsKey(propertyName)) {
|
||||
// 校验各种类型
|
||||
JSONObject attr = methodAttrs.getJSONObject(propertyName);
|
||||
String attrType = attr.getString("type");
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("title", propertyName);
|
||||
param.put("attr", attr);
|
||||
param.put("value", cellValue);
|
||||
param.put("wsId", wsId);
|
||||
if ("string".equals(attrType) || "textarea".equals(attrType)) {// 文本
|
||||
rowJson.add(JSONObject.parseObject(new ValidShape(new ValidShapeString()).execute(param).toString()));
|
||||
} else if ("relation".equals(attrType)) {// 关联
|
||||
rowJson.add(JSONObject.parseObject(new ValidShape(new ValidShapeRelation()).execute(param).toString()));
|
||||
} else if ("awsorg".equals(attrType)) {// 关联AWS平台
|
||||
rowJson.add(JSONObject.parseObject(new ValidShape(new ValidShapeAwsOrg()).execute(param).toString()));
|
||||
} else if ("select_m".equals(attrType) || "select".equals(attrType)) {// 单多选
|
||||
rowJson.add(JSONObject.parseObject((new ValidShape(new ValidShapeSelect()).execute(param).toString())));
|
||||
} else {// 其他,按照string对待
|
||||
rowJson.add(JSONObject.parseObject(new ValidShape(new ValidShapeString()).execute(param).toString()));
|
||||
}
|
||||
} else {
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("title", propertyName);
|
||||
param.put("attr", "tmp");
|
||||
param.put("value", "");
|
||||
param.put("wsId", wsId);
|
||||
rowJson.add(JSONObject.parseObject(new ValidShape(new ValidShapeString()).execute(param).toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
model.setCheckResult(rowJson);
|
||||
}
|
||||
// 整理最终结果
|
||||
List<RepositoryShapeInfoModel> allDataList = new ArrayList<>();
|
||||
allDataList.addAll(blankList);
|
||||
allDataList.addAll(excelRepeatList);
|
||||
allDataList.addAll(noMatchList);
|
||||
allDataList.addAll(noPermList);
|
||||
allDataList.addAll(moreMatchList);
|
||||
allDataList.addAll(readonlyList);
|
||||
allDataList.addAll(matchShapeList);
|
||||
// 整体按照Excel表中顺序排序
|
||||
allDataList.sort((a1, a2)-> {return a1.getExcelShapeModel().getRow() - a2.getExcelShapeModel().getRow();});
|
||||
|
||||
// 构造结果集返回给前端
|
||||
int totalCount = allDataList.size();
|
||||
int repeatCount = excelRepeatList.size();
|
||||
int blankCount = blankList.size();
|
||||
int noMatchCount = noMatchList.size();
|
||||
int noPermCount = noPermList.size();
|
||||
int moreMatchCount = moreMatchList.size();
|
||||
int readonlyCount = readonlyList.size();
|
||||
int okCount = 0;
|
||||
int errCount = 0;
|
||||
for (RepositoryShapeInfoModel model : matchShapeList) {
|
||||
model.setRowOk(true);
|
||||
JSONArray arr = model.getCheckResult();
|
||||
for (int i = 0; i < arr.size(); i++) {
|
||||
if (!arr.getJSONObject(i).getBooleanValue("isOk")) {
|
||||
model.setRowOk(false);
|
||||
}
|
||||
}
|
||||
if (model.isRowOk()) {
|
||||
okCount++;
|
||||
} else {
|
||||
errCount++;
|
||||
}
|
||||
}
|
||||
// 构造返回前端数据
|
||||
JSONArray result = new JSONArray();
|
||||
for (int i = 0; i < allDataList.size(); i++) {
|
||||
RepositoryShapeInfoModel model = allDataList.get(i);
|
||||
if ("blank".equals(model.getResult()) ||
|
||||
"repeat".equals(model.getResult()) ||
|
||||
"noMatch".equals(model.getResult()) ||
|
||||
"noPerm".equals(model.getResult()) ||
|
||||
"moreMatch".equals(model.getResult()) ||
|
||||
"readonly".equals(model.getResult())) {
|
||||
JSONArray row = new JSONArray();
|
||||
List<String> list = model.getExcelShapeModel().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", ShapeConst.EXTEND_PROP_PREFIX + titleList.get(j) + ShapeConst.EXTEND_PROP_SUFFIX);
|
||||
if (ShapeConst.TABLE_REPOSITORY_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.getExcelShapeModel().getRow());// Excel中行
|
||||
rowResult.put("isRowOk", model.isRowOk());
|
||||
rowResult.put("result", model.getResult());
|
||||
result.add(rowResult);
|
||||
} else if ("add".equals(model.getResult()) || "update".equals(model.getResult())) {
|
||||
JSONArray row = model.getCheckResult();
|
||||
JSONObject rowResult = new JSONObject();
|
||||
rowResult.put("row", row);
|
||||
rowResult.put("excelNo", model.getExcelShapeModel().getRow());// Excel中行
|
||||
rowResult.put("isRowOk", model.isRowOk());
|
||||
rowResult.put("result", model.getResult());
|
||||
rowResult.put("repositoryId", model.getRepositoryId());
|
||||
rowResult.put("shapeId", model.getShapeId());
|
||||
result.add(rowResult);
|
||||
}
|
||||
}
|
||||
JSONObject ro = new JSONObject();
|
||||
ro.put("result", result);
|
||||
ro.put("totalCount", totalCount);
|
||||
ro.put("repeatCount", repeatCount);
|
||||
ro.put("blankCount", blankCount);
|
||||
ro.put("noPermCount", noPermCount);
|
||||
ro.put("moreMatchCount", moreMatchCount);
|
||||
ro.put("readonlyCount", readonlyCount);
|
||||
ro.put("noMatchCount", noMatchCount);
|
||||
ro.put("okCount", okCount);
|
||||
ro.put("errCount", errCount);
|
||||
return ro;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取更多特性
|
||||
* @param methodId
|
||||
@ -765,4 +1430,88 @@ public class ValidShapeExcel {
|
||||
}
|
||||
return ResponseObject.newOkResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验标题行
|
||||
* @param titleRow
|
||||
*/
|
||||
public ResponseObject checkTitleRowImport(String wsId, List<String> titleRow, String methodCategory) {
|
||||
// 标题固定行验证
|
||||
if (titleRow.size() < ShapeConst.SHAPE_TITLE_ROW_IMPORT.length) {// 固定行列不够
|
||||
StringBuilder msg = new StringBuilder();
|
||||
msg.append("固定属性标题要求:").append(ShapeConst.SHAPE_BASE_TITLE_ROW_IMPORT).append("<br><br>");
|
||||
msg.append("请按照以上固定属性内容及顺序调整工作表并重新上传Excel文件");
|
||||
msg.insert(0, errMsg);
|
||||
return ResponseObject.newErrResponse(msg.toString());
|
||||
}
|
||||
// 校验固定属性是否符合要求
|
||||
List<String> illegalBaseTitle = new ArrayList<>();
|
||||
for (int i = 0; i < titleRow.size(); i++) {
|
||||
if (i < ShapeConst.SHAPE_TITLE_ROW_IMPORT.length) {
|
||||
if (!ShapeConst.SHAPE_TITLE_ROW_IMPORT[i].equals(titleRow.get(i))) {
|
||||
illegalBaseTitle.add(titleRow.get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (illegalBaseTitle.size() > 0) {
|
||||
StringBuilder msg = new StringBuilder();
|
||||
msg.append("固定属性标题要求:").append(ShapeConst.SHAPE_BASE_TITLE_ROW_IMPORT).append("<br><br>");
|
||||
msg.append("不符合要求的属性标题范围:" + String.join("、", illegalBaseTitle)).append("<br><br>");
|
||||
msg.append("请按照以上固定属性内容及顺序调整工作表并重新上传Excel文件");
|
||||
msg.insert(0, errMsg);
|
||||
return ResponseObject.newErrResponse(msg.toString());
|
||||
}
|
||||
// 扩展属性验证
|
||||
if (titleRow.size() > ShapeConst.SHAPE_TITLE_ROW_IMPORT.length) {// 有扩展属性
|
||||
List<String> illegalAttrTitle = new ArrayList<>();
|
||||
// 获取当前扩展属性
|
||||
Set<String> attributeNames = ShapeUtil.getShapeMethodAttrNames(wsId, methodCategory);
|
||||
for (int i = ShapeConst.SHAPE_TITLE_ROW_IMPORT.length; i < titleRow.size(); i++) {
|
||||
String title = titleRow.get(i);
|
||||
int prefix = title.indexOf("扩展<");
|
||||
int suffix = title.lastIndexOf(">");
|
||||
if (prefix == -1 || suffix == -1 || prefix > suffix || suffix != title.length() -1) {
|
||||
illegalAttrTitle.add(title);
|
||||
continue;
|
||||
}
|
||||
String propertyName = title.substring(prefix + 3, suffix);
|
||||
if (!attributeNames.contains(propertyName)) {
|
||||
illegalAttrTitle.add(title.replace("<", "<").replace(">", ">"));
|
||||
}
|
||||
}
|
||||
if (illegalAttrTitle.size() > 0) {
|
||||
List<String> list = new ArrayList<String>(attributeNames);
|
||||
list.sort((name1, name2) -> name1.compareTo(name2));
|
||||
StringBuilder msg = new StringBuilder();
|
||||
msg.append("扩展属性要求格式:扩展<xxx>").append("<br><br>");
|
||||
msg.append("标准扩展属性范围:" + String.join("、", list)).append("<br><br>");
|
||||
msg.append("不符合要求的属性标题范围:" + String.join("、", illegalAttrTitle)).append("<br><br>");
|
||||
msg.append("请按照以上格式及标准扩展属性范围调整工作表并重新上传Excel文件");
|
||||
msg.insert(0, errMsg);
|
||||
return ResponseObject.newErrResponse(msg.toString());
|
||||
}
|
||||
// 校验是否有重复标题,前面几列固定不校验,只在扩展属性校验
|
||||
List<String> repeatTitle = new ArrayList<>();
|
||||
Set<String> set = new HashSet<>();
|
||||
for (int i = ShapeConst.SHAPE_TITLE_ROW_IMPORT.length; i < titleRow.size(); i++) {
|
||||
String title = titleRow.get(i);
|
||||
if (!UtilString.isEmpty(title)) {
|
||||
if (set.contains(title)) {
|
||||
repeatTitle.add(title);
|
||||
} else {
|
||||
set.add(title);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (repeatTitle.size() > 0) {
|
||||
StringBuilder msg = new StringBuilder();
|
||||
msg.append("属性重复").append("<br><br>");
|
||||
msg.append("重复的属性标题:" + String.join("、", repeatTitle)).append("<br><br>");
|
||||
msg.append("请调整重复的属性并重新上传Excel文件");
|
||||
msg.insert(0, errMsg);
|
||||
return ResponseObject.newErrResponse(msg.toString());
|
||||
}
|
||||
}
|
||||
return ResponseObject.newOkResponse();
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,108 @@
|
||||
package com.actionsoft.apps.coe.pal.batch.web.create.shape.model;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
|
||||
/**
|
||||
* 前后入参table解析后cell对象
|
||||
*/
|
||||
public class CellObject {
|
||||
|
||||
/**
|
||||
* 模型名称
|
||||
*/
|
||||
private String modelName;
|
||||
/**
|
||||
* 模型类型
|
||||
*/
|
||||
private String modelType;
|
||||
/**
|
||||
* 形状名称
|
||||
*/
|
||||
private String shapeName;
|
||||
/**
|
||||
* 形状类型
|
||||
*/
|
||||
private String shapeType;
|
||||
/**
|
||||
* 形状分支
|
||||
*/
|
||||
private String shapeBranch;
|
||||
/**
|
||||
* 形状序号
|
||||
*/
|
||||
private String shapeNum;
|
||||
/**
|
||||
* 拓展属性数组
|
||||
*/
|
||||
private JSONArray expandArr;
|
||||
|
||||
public CellObject() {
|
||||
}
|
||||
|
||||
public CellObject(String modelName, String modelType, String shapeName, String shapeType, String shapeBranch, String shapeNum, JSONArray expandArr) {
|
||||
this.modelName = modelName;
|
||||
this.modelType = modelType;
|
||||
this.shapeName = shapeName;
|
||||
this.shapeType = shapeType;
|
||||
this.shapeBranch = shapeBranch;
|
||||
this.shapeNum = shapeNum;
|
||||
this.expandArr = expandArr;
|
||||
}
|
||||
|
||||
public String getModelName() {
|
||||
return modelName;
|
||||
}
|
||||
|
||||
public void setModelName(String modelName) {
|
||||
this.modelName = modelName;
|
||||
}
|
||||
|
||||
public String getModelType() {
|
||||
return modelType;
|
||||
}
|
||||
|
||||
public void setModelType(String modelType) {
|
||||
this.modelType = modelType;
|
||||
}
|
||||
|
||||
public String getShapeName() {
|
||||
return shapeName;
|
||||
}
|
||||
|
||||
public void setShapeName(String shapeName) {
|
||||
this.shapeName = shapeName;
|
||||
}
|
||||
|
||||
public String getShapeType() {
|
||||
return shapeType;
|
||||
}
|
||||
|
||||
public void setShapeType(String shapeType) {
|
||||
this.shapeType = shapeType;
|
||||
}
|
||||
|
||||
public String getShapeBranch() {
|
||||
return shapeBranch;
|
||||
}
|
||||
|
||||
public void setShapeBranch(String shapeBranch) {
|
||||
this.shapeBranch = shapeBranch;
|
||||
}
|
||||
|
||||
public String getShapeNum() {
|
||||
return shapeNum;
|
||||
}
|
||||
|
||||
public void setShapeNum(String shapeNum) {
|
||||
this.shapeNum = shapeNum;
|
||||
}
|
||||
|
||||
public JSONArray getExpandArr() {
|
||||
return expandArr;
|
||||
}
|
||||
|
||||
public void setExpandArr(JSONArray expandArr) {
|
||||
this.expandArr = expandArr;
|
||||
}
|
||||
}
|
||||
@ -11,6 +11,10 @@ public class ExcelShapeModel {
|
||||
private String repositoryType;
|
||||
private String shapeName;
|
||||
private String shapeType;
|
||||
//导入---形状分支
|
||||
private String shapeBranch;
|
||||
//导入 --- 形状编号
|
||||
private String shapeNo;
|
||||
private List<String> rowData;// 扩展属性内容
|
||||
|
||||
public int getRow() {
|
||||
@ -60,4 +64,20 @@ public class ExcelShapeModel {
|
||||
public void setRepositoryType(String repositoryType) {
|
||||
this.repositoryType = repositoryType;
|
||||
}
|
||||
|
||||
public String getShapeBranch() {
|
||||
return shapeBranch;
|
||||
}
|
||||
|
||||
public void setShapeBranch(String shapeBranch) {
|
||||
this.shapeBranch = shapeBranch;
|
||||
}
|
||||
|
||||
public String getShapeNo() {
|
||||
return shapeNo;
|
||||
}
|
||||
|
||||
public void setShapeNo(String shapeNo) {
|
||||
this.shapeNo = shapeNo;
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,6 +16,8 @@ public class RepositoryShapeInfoModel {
|
||||
private String shapeName;// 形状名称
|
||||
private String shapeMethodId;// 形状所属建模方法类型
|
||||
private String shapeType;// 形状类型
|
||||
private String shapeBranch;// 导入---形状分支
|
||||
private String shapeNo;// 导入--- 形状吧编号
|
||||
|
||||
private boolean isPalShape;// 是否pal存在的形状,用户判断是否需要新增形状还是更新形状
|
||||
|
||||
@ -140,4 +142,20 @@ public class RepositoryShapeInfoModel {
|
||||
public void setShapeType(String shapeType) {
|
||||
this.shapeType = shapeType;
|
||||
}
|
||||
|
||||
public String getShapeBranch() {
|
||||
return shapeBranch;
|
||||
}
|
||||
|
||||
public void setShapeBranch(String shapeBranch) {
|
||||
this.shapeBranch = shapeBranch;
|
||||
}
|
||||
|
||||
public String getShapeNo() {
|
||||
return shapeNo;
|
||||
}
|
||||
|
||||
public void setShapeNo(String shapeNo) {
|
||||
this.shapeNo = shapeNo;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user