From 7c8e0d59b2fedb299106db9139c21e81ea5e0a39 Mon Sep 17 00:00:00 2001 From: anhc <3442943606@qq.com> Date: Mon, 19 Sep 2022 16:06:14 +0800 Subject: [PATCH] =?UTF-8?q?Excel=E5=AF=BC=E5=85=A5=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E5=9B=BEreview=20,=E6=8B=93=E5=B1=95=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E4=B8=8D=E6=88=90=E5=8A=9F=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../apps/coe/pal/batch/web/BatchWeb.java | 1 - .../web/create/shape/ImportShapeExcel1.java | 25 +++++-- .../web/create/shape/ValidShapeExcel.java | 73 ------------------- .../web/create/shape/model/CellObject.java | 7 +- 4 files changed, 23 insertions(+), 83 deletions(-) diff --git a/com.actionsoft.apps.coe.pal.batch/src/com/actionsoft/apps/coe/pal/batch/web/BatchWeb.java b/com.actionsoft.apps.coe.pal.batch/src/com/actionsoft/apps/coe/pal/batch/web/BatchWeb.java index 460568d3..1daad199 100644 --- a/com.actionsoft.apps.coe.pal.batch/src/com/actionsoft/apps/coe/pal/batch/web/BatchWeb.java +++ b/com.actionsoft.apps.coe.pal.batch/src/com/actionsoft/apps/coe/pal/batch/web/BatchWeb.java @@ -355,7 +355,6 @@ public class BatchWeb extends ActionWeb { 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(); } diff --git a/com.actionsoft.apps.coe.pal.batch/src/com/actionsoft/apps/coe/pal/batch/web/create/shape/ImportShapeExcel1.java b/com.actionsoft.apps.coe.pal.batch/src/com/actionsoft/apps/coe/pal/batch/web/create/shape/ImportShapeExcel1.java index fd2f41f7..253df090 100644 --- a/com.actionsoft.apps.coe.pal.batch/src/com/actionsoft/apps/coe/pal/batch/web/create/shape/ImportShapeExcel1.java +++ b/com.actionsoft.apps.coe.pal.batch/src/com/actionsoft/apps/coe/pal/batch/web/create/shape/ImportShapeExcel1.java @@ -80,7 +80,7 @@ public class ImportShapeExcel1 { LogUtil.appendLog("PAL 泳道图Excel批量导入模型 Begin " + UtilDate.datetimeFormat(startDate), simpleLogFile, fullLogFile); LogUtil.appendLog("--------------------------------", simpleLogFile, fullLogFile); - LogUtil.appendLog("若模型存在多版本,只与模型使用中版本进行匹配,过往版本忽略不进行任何处理,若最新版本模型非可编辑状态(已发布、已停用、审批中),直接跳过该模型,不做任何调整", simpleLogFile, fullLogFile); + LogUtil.appendLog("若模型存在多版本,只与模型使用中版本进行匹配,过往版本忽略不进行任何处理,若使用中版本模型非可编辑状态(已发布、已停用、审批中),直接跳过该模型,不做任何调整", simpleLogFile, fullLogFile); //前端入参table数据读取 JSONObject data = object.getJSONObject("data"); @@ -121,7 +121,6 @@ public class ImportShapeExcel1 { JSONObject drawBranchShape = this.drawBranchShape(repositoryId, branchData, offsetX, nodeMap, relationList); double maxRight = drawBranchShape.getDouble("rightMaxLine"); int maxLevel = drawBranchShape.getInteger("maxLevel"); - rightMaxLine = Math.max(rightMaxLine,maxRight); offsetX = rightMaxLine + 150; @@ -187,7 +186,11 @@ public class ImportShapeExcel1 { double offsetX = originOffsetX; int maxLevelNum = 0; + //repositoryId + PALRepositoryModel palModel = PALRepositoryCache.getCache().get(repositoryId); + for (Map.Entry>>> branch : branchData.entrySet()) { + LogUtil.appendLog(BatchConst.LOG_DESC + "[执行阶段] 绘制["+ palModel.getName() +"] "+branch.getKey()+"分支图形", simpleLogFile, fullLogFile); // <层级,同级别map> Map>> levelMap = branch.getValue(); @@ -245,6 +248,9 @@ public class ImportShapeExcel1 { //节点画图, JSONObject shape =this.drawShape(node, 0, offsetX, i, i); + if (null == shape){ + continue; + } //计算最右边界 rightMaxLine = this.getRightMaxLine(shape,rightMaxLine); shapes.add(shape); @@ -307,6 +313,9 @@ public class ImportShapeExcel1 { //绘制当前节点图形 JSONObject shape = this.drawShape(node, levelNodeIndex, offset, level, i); + if(null == shape){ + continue; + } LogUtil.appendLog(BatchConst.LOG_START + "[新增][" + node.getShapeName() + "]形状", simpleLogFile, fullLogFile); LogUtil.appendLog(BatchConst.LOG_START + "[新增][" + node.getShapeName() + "]形状,形状类型[" + node.getShapeType() + "]", fullLogFile); @@ -1244,13 +1253,16 @@ public class ImportShapeExcel1 { } private String getCellObjectUUID(CellObject node){ - //名称+类型+序号 + //名称+类型+序号+分支 return node.getShapeName()+"|"+node.getShapeType()+"|"+node.getShapeBranch()+"|"+node.getShapeNum(); } private JSONObject drawShape(CellObject node,int levelNodeIndex,double offset,int level,int zIndex){ JSONObject shape = ShapeUtil.getProcessShapeDefinition("process.flowchart", node.getShapeType()); - // + //特殊处理如果图形类型与图形不匹配 + if(null == shape){ + return shape; + } shape.put("text", node.getShapeName()); shape.put("id", UUIDGener.getUUID()); shape.put("shapeNum", node.getShapeNum()); @@ -1334,8 +1346,6 @@ public class ImportShapeExcel1 { for (int rowIndex = 0; rowIndex < row.size(); rowIndex++) { JSONObject cell = row.getJSONObject(rowIndex); - JSONArray expandArr = new JSONArray(); - if (cell.getString("name").equals(ShapeConst.TABLE_SHAPE_BRANCH)){ //形状分支 branch = cell.getString("value"); @@ -1360,8 +1370,7 @@ public class ImportShapeExcel1 { cellObject.setShapeNum(cell.getString("value")); }else { //拓展属性 - expandArr.add(cell); - cellObject.setExpandArr(expandArr); + cellObject.addExpandArr(cell); } } diff --git a/com.actionsoft.apps.coe.pal.batch/src/com/actionsoft/apps/coe/pal/batch/web/create/shape/ValidShapeExcel.java b/com.actionsoft.apps.coe.pal.batch/src/com/actionsoft/apps/coe/pal/batch/web/create/shape/ValidShapeExcel.java index ccf0bf8d..6eaca9a8 100644 --- a/com.actionsoft.apps.coe.pal.batch/src/com/actionsoft/apps/coe/pal/batch/web/create/shape/ValidShapeExcel.java +++ b/com.actionsoft.apps.coe.pal.batch/src/com/actionsoft/apps/coe/pal/batch/web/create/shape/ValidShapeExcel.java @@ -975,79 +975,6 @@ public class ValidShapeExcel { } } - // 查询一些形状定义 - /*Map> shapeObjMap = new HashMap<>();// 形状定义信息 - Map> 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 shapeList = CoeDesignerUtil.getShapeMessageJson5(palId); - shapeObjMap.put(key, shapeList); - }*/ - - // 形状名称+类型的数量统计 key:key,value:key:shapeName+shapeType,value:count - /*Map> sameShapeMap = new HashMap<>(); - for (Map.Entry> entry : shapeObjMap.entrySet()) { - String key = entry.getKey(); - List 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 matchShapeList = new ArrayList<>(); iterator = excelShapeModels.iterator(); diff --git a/com.actionsoft.apps.coe.pal.batch/src/com/actionsoft/apps/coe/pal/batch/web/create/shape/model/CellObject.java b/com.actionsoft.apps.coe.pal.batch/src/com/actionsoft/apps/coe/pal/batch/web/create/shape/model/CellObject.java index d22ea4f2..c8787430 100644 --- a/com.actionsoft.apps.coe.pal.batch/src/com/actionsoft/apps/coe/pal/batch/web/create/shape/model/CellObject.java +++ b/com.actionsoft.apps.coe.pal.batch/src/com/actionsoft/apps/coe/pal/batch/web/create/shape/model/CellObject.java @@ -2,6 +2,7 @@ package com.actionsoft.apps.coe.pal.batch.web.create.shape.model; import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; /** * 前后入参table解析后cell对象 @@ -35,7 +36,7 @@ public class CellObject { /** * 拓展属性数组 */ - private JSONArray expandArr; + private JSONArray expandArr = new JSONArray(); public CellObject() { } @@ -105,4 +106,8 @@ public class CellObject { public void setExpandArr(JSONArray expandArr) { this.expandArr = expandArr; } + + public void addExpandArr(JSONObject expand){ + this.expandArr.add(expand); + } }