diff --git a/com.actionsoft.apps.coe.pal.batch/lib/com.actionsoft.apps.coe.pal.batch.jar b/com.actionsoft.apps.coe.pal.batch/lib/com.actionsoft.apps.coe.pal.batch.jar index c12eb0a5..6630c5eb 100644 Binary files a/com.actionsoft.apps.coe.pal.batch/lib/com.actionsoft.apps.coe.pal.batch.jar and b/com.actionsoft.apps.coe.pal.batch/lib/com.actionsoft.apps.coe.pal.batch.jar differ 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 2c73da57..60b30746 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 @@ -105,54 +105,60 @@ public class ImportShapeExcel1 { //根据基准数据绘制图形+连线关系 for (String repositoryId : fileDataMap.keySet()) { - //全局初始偏移量,每个分支最右侧分界线 - double offsetX = ShapeConst.SHAPE_BRANCH_INTERVAL; - double rightMaxLine = 0; - LogUtil.appendLog("准备导入" + I18nRes.findValue(CoEConstant.APP_ID, methodCategory) + "数据[开始]", fullLogFile); - //计算后形状与连线保存数据保存 - Map> nodeMap = new LinkedHashMap<>(); - //形状关联属性结果集 - List relationList = new ArrayList<>(); + try { + //全局初始偏移量,每个分支最右侧分界线 + double offsetX = ShapeConst.SHAPE_BRANCH_INTERVAL; + double rightMaxLine = 0; - //多分支常规图形绘制 - LogUtil.appendLog(BatchConst.LOG_DESC + "[执行阶段][绘制常规分支图形]", simpleLogFile, fullLogFile); - Map>>> branchData = fileDataMap.get(repositoryId); - JSONObject drawBranchShape = this.drawBranchShape(repositoryId, branchData, offsetX, nodeMap, relationList); - double maxRight = drawBranchShape.getDouble("rightMaxLine"); - int maxLevel = drawBranchShape.getInteger("maxLevel"); - rightMaxLine = Math.max(rightMaxLine,maxRight); + LogUtil.appendLog("准备导入" + I18nRes.findValue(CoEConstant.APP_ID, methodCategory) + "数据[开始]", fullLogFile); + //计算后形状与连线保存数据保存 + Map> nodeMap = new LinkedHashMap<>(); + //形状关联属性结果集 + List relationList = new ArrayList<>(); - offsetX = rightMaxLine + 150; - rightMaxLine = offsetX; + //多分支常规图形绘制 + LogUtil.appendLog(BatchConst.LOG_DESC + "[执行阶段][绘制常规分支图形]", simpleLogFile, fullLogFile); + Map>>> branchData = fileDataMap.get(repositoryId); + JSONObject drawBranchShape = this.drawBranchShape(repositoryId, branchData, offsetX, nodeMap, relationList); + double maxRight = drawBranchShape.getDouble("rightMaxLine"); + int maxLevel = drawBranchShape.getInteger("maxLevel"); + rightMaxLine = Math.max(rightMaxLine,maxRight); - //特殊图形绘制 - LogUtil.appendLog(BatchConst.LOG_DESC + "[执行阶段][绘制特殊分支图形]", simpleLogFile, fullLogFile); - List specicalCell = specialMap.get(repositoryId); - rightMaxLine = this.drawSpecialShape(offsetX,rightMaxLine,specicalCell,nodeMap); + offsetX = rightMaxLine + 150; + rightMaxLine = offsetX; - //文件操作 - LogUtil.appendLog(BatchConst.LOG_END + "[执行阶段][保存模型阶段]", simpleLogFile, fullLogFile); - this.saveDefine(repositoryId,nodeMap,rightMaxLine,maxLevel); + //特殊图形绘制 + LogUtil.appendLog(BatchConst.LOG_DESC + "[执行阶段][绘制特殊分支图形]", simpleLogFile, fullLogFile); + List specicalCell = specialMap.get(repositoryId); + rightMaxLine = this.drawSpecialShape(offsetX,rightMaxLine,specicalCell,nodeMap); - //关联属性处理 - DesignerShapeRelationDao relationDao = new DesignerShapeRelationDao(); - if (relationList.size() == 0) { - LogUtil.appendLog(BatchConst.LOG_WARNING + "新增形状属性关联属性内容忽略", simpleLogFile, fullLogFile); - } else { - LogUtil.appendLog(BatchConst.LOG_START + "新增形状属性关联属性内容", simpleLogFile, fullLogFile); - boolean insertProps = relationDao.barchInsert(relationList); - if (insertProps) { - for (int i = 0; i < relationList.size(); i++) { - String name = relationList.get(i).getAttrId(); - String value = relationList.get(i).getRelationShapeText(); + //文件操作 + LogUtil.appendLog(BatchConst.LOG_END + "[执行阶段][保存模型阶段]", simpleLogFile, fullLogFile); + this.saveDefine(repositoryId,nodeMap,rightMaxLine,maxLevel); - LogUtil.appendLog(BatchConst.LOG_DESC + "形状属性关联属性内容[" + name + "],属性内容值为[" + value + "]", simpleLogFile, fullLogFile); - } - LogUtil.appendLog(BatchConst.LOG_END + "新增形状属性关联属性内容,总共新增[" + relationList.size() + "]条", simpleLogFile, fullLogFile); + //关联属性处理 + DesignerShapeRelationDao relationDao = new DesignerShapeRelationDao(); + if (relationList.size() == 0) { + LogUtil.appendLog(BatchConst.LOG_WARNING + "新增形状属性关联属性内容忽略", simpleLogFile, fullLogFile); } else { - LogUtil.appendLog(BatchConst.LOG_WARNING + "新增形状属性关联属性内容失败,详情查看BPM平台运行日志", simpleLogFile, fullLogFile); + LogUtil.appendLog(BatchConst.LOG_START + "新增形状属性关联属性内容", simpleLogFile, fullLogFile); + boolean insertProps = relationDao.barchInsert(relationList); + if (insertProps) { + for (int i = 0; i < relationList.size(); i++) { + String name = relationList.get(i).getAttrId(); + String value = relationList.get(i).getRelationShapeText(); + + LogUtil.appendLog(BatchConst.LOG_DESC + "形状属性关联属性内容[" + name + "],属性内容值为[" + value + "]", simpleLogFile, fullLogFile); + } + LogUtil.appendLog(BatchConst.LOG_END + "新增形状属性关联属性内容,总共新增[" + relationList.size() + "]条", simpleLogFile, fullLogFile); + } else { + LogUtil.appendLog(BatchConst.LOG_WARNING + "新增形状属性关联属性内容失败,详情查看BPM平台运行日志", simpleLogFile, fullLogFile); + } } + }catch (Exception e){ + LogUtil.appendLog(BatchConst.LOG_ERROR + "[执行异常]文件id:"+repositoryId+";异常原因:"+e.getMessage(), simpleLogFile, fullLogFile); + e.printStackTrace(); } } @@ -172,6 +178,18 @@ public class ImportShapeExcel1 { DesignerShapeRelationCache.getCache().reload(); } + //判断当前层级是否整数节点,还是小数节点,独立获得整数类型,或小数类型 + //编号规则处理 + + /** + * 绘制常规分支下图形与连线,并计算位置重叠偏移 + * @param repositoryId + * @param branchData + * @param originOffsetX + * @param nodeMap + * @param relationList + * @return + */ private JSONObject drawBranchShape(String repositoryId,Map>>> branchData,double originOffsetX,Map> nodeMap, List relationList){ JSONObject res = new JSONObject(); @@ -186,34 +204,39 @@ public class ImportShapeExcel1 { double offsetX = originOffsetX; int maxLevelNum = 0; - //repositoryId + //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> 层级map Map>> levelMap = branch.getValue(); - //获取最大层级 - int maxLevel = levelMap.keySet().size(); + + //获取最大层级数,可以初始节点编号不从0起始,最大的分支数(注意多余小数节点不连线分支牵连问题) + JSONObject maxObj = this.getMaxLevelNo(levelMap); + int maxLevel = maxObj.getInteger("maxLevel"); + int maxBranch = maxObj.getInteger("maxBranch"); + maxLevelNum = Math.max(maxLevel,maxLevelNum); //遍历层级,产出图+连线 - rightMaxLine = this.drawShapeAndLinker(repositoryId, maxLevel, offsetX, rightMaxLine, levelMap, nodeMap, relationList); + rightMaxLine = this.drawShapeAndLinker(repositoryId, maxLevel,maxBranch, offsetX, rightMaxLine, levelMap, nodeMap, relationList); //位置重叠偏移计算 //左边界 double leftMinLine = offsetX - ShapeConst.SHAPE_BRANCH_INTERVAL; - JSONObject object = this.changeShapePosition(levelMap, nodeMap, offsetX, rightMaxLine, leftMinLine); + JSONObject object = this.changeShapePosition(levelMap, nodeMap, offsetX,maxLevel,maxBranch, rightMaxLine, leftMinLine); Double changeLeftMinLine = object.getDouble("leftMinLine"); Double changeRightMaxLine = object.getDouble("rightMaxLine"); rightMaxLine = Math.max(changeRightMaxLine,rightMaxLine); - // 整体调整分支偏移量,比较返回左边界>> levelMap){ + JSONObject res = new JSONObject(); + res.put("maxLevel" ,0); + res.put("maxBranch" ,0); + if (null == levelMap){ + return res; + } + int maxLevel = 0; + int maxBranch = 0; + + for (String s : levelMap.keySet()) { + maxLevel = Math.max(maxLevel, Integer.parseInt(s)); + Map> numMap = levelMap.get(s); + numMap = this.filterLevelNum(numMap); + maxBranch = Math.max(maxBranch,numMap.keySet().size()); + } + res.put("maxLevel" ,maxLevel); + res.put("maxBranch" ,maxBranch); + return res; + } + /** * 绘制特殊处理的图形,只画图不连线 * @param offsetX @@ -272,24 +321,31 @@ public class ImportShapeExcel1 { * @param relationList * @return */ - private double drawShapeAndLinker(String repositoryId,int maxLevel,double offsetX ,double rightMaxLine,Map>> levelMap,Map> nodeMap,List relationList){ + private double drawShapeAndLinker(String repositoryId,int maxLevel,int maxBranch,double offsetX ,double rightMaxLine,Map>> levelMap,Map> nodeMap,List relationList){ + + + //遍历0-maxLevel层级 + for (int level = 0; level < maxLevel+1; level++) { - for (int level = 0; level < maxLevel; level++) { //同层级多分支节点信息, <序号,同序号listNode> - Map> numList = levelMap.get("" + level); - if (null == numList){ + Map> numMap = levelMap.get("" + level); + if (null == numMap){ + //当前层级没有数据 continue; } + Map> newNumMap = this.filterLevelNum(numMap); + //计算同层级索引 int levelNodeIndex = 0; - for (int i = 0; i < numList.keySet().size()+1; i++) { + for (int i = 0; i < numMap.keySet().size()+1; i++) { //构建同层级的分支序号 String levelNo = this.getLevelNo(level, i); //当前分支的最终节点,同序号节点list - List nodes = numList.get(levelNo); + List nodes = numMap.get(levelNo); if (null == nodes){ + //同层级没有下属分支node continue; } @@ -298,9 +354,9 @@ public class ImportShapeExcel1 { JSONArray upList = upNodes.getJSONArray("upList"); // 根据上级计算offset,没有上级,一个上级,多个上级 - double offset = this.getLevelStartNodeOffset(levelNo,offsetX,upList,nodes,numList); + double offset = this.getLevelStartNodeOffset(levelNo,offsetX,upList,nodes,newNumMap); - // 分支下的分支计算同序号偏移量重新计算 + // 分支下的同序号多节点偏移量重新计算 if (null != upList && !upList.isEmpty() && upList.size()==1 && upList.getJSONObject(0).getString("shapeNum").contains(".")){ levelNodeIndex = 0; } @@ -328,15 +384,13 @@ public class ImportShapeExcel1 { shapes.add(shape); //存在父级节点,计算与上级节点list的连线 - if (upNodes.getBooleanValue("isUp")){ - if (nodes.size()>1 && upList.size()>1){ - //多下级与多上级的连线不处理 - continue; - } + if (this.isDrawLinker(upNodes,nodes)){ //与多个上级节点直接连线 for (Object o : upList) { - JSONObject linker = this.drawLinker((JSONObject) o, shape, nodeIndex); - shapes.add(linker); + if (this.isDrawLinker(node,numMap)){ + JSONObject linker = this.drawLinker((JSONObject) o, shape, nodeIndex); + shapes.add(linker); + } } } @@ -349,13 +403,19 @@ public class ImportShapeExcel1 { return rightMaxLine; } - private double branchMoveToRight(Map>> levelMap,Map> nodeMap,double offset,double rightMaxLine){ + /** + * 整体平移分支流程 + * @param levelMap + * @param nodeMap + * @param offset + * @param maxLevel + * @param rightMaxLine + * @return + */ + private double branchMoveToRight(Map>> levelMap,Map> nodeMap,double offset,int maxLevel,double rightMaxLine){ double rightLine = rightMaxLine; - //获取最大层级 - int maxLevel = levelMap.keySet().size(); - - for (int level = 0; level < maxLevel; level++) { + for (int level = 0; level < maxLevel+1; level++) { //同层级多分支节点信息, <序号,同序号listNode> Map> numList = levelMap.get("" + level); if (null == numList){ @@ -411,32 +471,26 @@ public class ImportShapeExcel1 { return Math.max(rightLine,rightMaxLine); } - - private JSONObject changeShapePosition(Map>> levelMap,Map> nodeMap,double offsetX,double rightMaxLine,double leftMinLine){ + /** + * 计算调整图形重叠位置 + * @param levelMap + * @param nodeMap + * @param offsetX + * @param maxLevel + * @param maxBranch + * @param rightMaxLine + * @param leftMinLine + * @return + */ + private JSONObject changeShapePosition(Map>> levelMap,Map> nodeMap,double offsetX,int maxLevel,int maxBranch,double rightMaxLine,double leftMinLine){ JSONObject res = new JSONObject(); res.put("rightMaxLine",rightMaxLine); res.put("leftMinLine",leftMinLine); - int maxLevel = levelMap.keySet().size(); - - int branchMax = 0; + int branchMax = maxBranch; int startLevel = 0; - //计算分支数量 - for (int level = 0; level < maxLevel; level++) { - //同层级多分支节点信息, <序号,同序号listNode> - Map> numList = levelMap.get("" + level); - if (numList == null ){ - //跳级处理, - continue; - } - //找到一个出现分支的层级 - branchMax = numList.keySet().size(); - startLevel = level; - break; - } - //计算当前分支是奇数还是偶数项,branchMax 为0 说明没有分支不需要计算 if (branchMax == 0){ return res; @@ -458,18 +512,31 @@ public class ImportShapeExcel1 { return res; } - //奇数分支处理 + /** + * 奇数分支处理 + * @param levelMap + * @param nodeMap + * @param maxLevel + * @param startLevel + * @param medianBranch + * @param rightMaxLine + * @param leftMinLine + * @return + */ private JSONObject oddBranchChange(Map>> levelMap,Map> nodeMap,int maxLevel,int startLevel,double medianBranch,double rightMaxLine,double leftMinLine){ JSONObject res = new JSONObject(); res.put("rightMaxLine",rightMaxLine); res.put("leftMinLine",leftMinLine); - for (int level = maxLevel-1; level>=startLevel; level--){ + //层级倒序计算 + for (int level = maxLevel; level>=startLevel; level--){ //同层级多分支节点信息 - Map> numList = levelMap.get("" + level); - if (null == numList){ + Map> numMap = levelMap.get("" + level); + if (null == numMap){ continue; } + numMap = this.filterLevelNum(numMap); + //奇数左半部分支调整,逆序 int branchMedian = (int) medianBranch; @@ -478,9 +545,13 @@ public class ImportShapeExcel1 { String leftLevelNo = this.getLevelNo(level, i); String rightLevelNo = this.getLevelNo(level,i+1); + if (leftLevelNo.equals("4.1")){ + Object o = new Object(); + } + //同分支序号多节点list - List leftNodes = numList.get(leftLevelNo); - List rightNodes = numList.get(rightLevelNo); + List leftNodes = numMap.get(leftLevelNo); + List rightNodes = numMap.get(rightLevelNo); if (null == leftNodes || leftNodes.isEmpty() ){ continue; } @@ -500,20 +571,20 @@ public class ImportShapeExcel1 { if (leftShapeX + 15 > rightShapeX){ //需要调整,向左边移动 double offset = leftShapeX - (rightShapeX - ShapeConst.SHAPE_NODE_INTERVAL - ShapeConst.SHAPE_NODE_WIDTH ); - double leftOffset = this.leftOffsetNode(leftNodes, levelMap, nodeMap, offset, leftMinLine); + double leftOffset = this.leftOffsetNode(leftNodes, levelMap, nodeMap,maxLevel, offset, leftMinLine); res.put("leftMinLine",Math.min(leftOffset,leftMinLine)); } } //奇数右半部调整 - for (int i = branchMedian; i < numList.keySet().size();i++){ + for (int i = branchMedian; i < numMap.keySet().size();i++){ //构建同层级的分支序号 String leftLevelNo = this.getLevelNo(level, i); String rightLevelNo = this.getLevelNo(level,i+1); //同分支序号多节点list - List leftNodes = numList.get(leftLevelNo); - List rightNodes = numList.get(rightLevelNo); + List leftNodes = numMap.get(leftLevelNo); + List rightNodes = numMap.get(rightLevelNo); if (rightNodes == null || rightNodes.isEmpty()){ continue; } @@ -531,7 +602,7 @@ public class ImportShapeExcel1 { if (leftShapeX + 15 > rightShapeX){ //需要调整,向右边移动 double offset = leftShapeX + ShapeConst.SHAPE_NODE_INTERVAL + ShapeConst.SHAPE_NODE_WIDTH; - double rightOffset = this.rightOffsetNode(rightNodes, levelMap, nodeMap, offset, rightMaxLine); + double rightOffset = this.rightOffsetNode(rightNodes, levelMap, nodeMap,maxLevel, offset, rightMaxLine); res.put("rightMaxLine",Math.max(rightMaxLine,rightOffset)); } } @@ -549,12 +620,14 @@ public class ImportShapeExcel1 { for (int level = maxLevel-1; level>=startLevel; level--){ //同层级多分支节点信息 - Map> numList = levelMap.get("" + level); - if (null == numList){ + Map> numMap = levelMap.get("" + level); + if (null == numMap){ //只调整分支节点 continue; } + numMap = this.filterLevelNum(numMap); + //偶数左半部分支调整,逆序 int branchMedian = (int) Math.ceil(medianBranch); for (int i = branchMedian-1; i >=1; i--){ @@ -566,8 +639,8 @@ public class ImportShapeExcel1 { } //同分支序号多节点list - List leftNodes = numList.get(leftLevelNo); - List rightNodes = numList.get(rightLevelNo); + List leftNodes = numMap.get(leftLevelNo); + List rightNodes = numMap.get(rightLevelNo); if (null == leftNodes || leftNodes.isEmpty()){ continue; } @@ -581,14 +654,14 @@ public class ImportShapeExcel1 { if (leftShapeX + 15 > rightShapeX){ //需要调整,向左边移动 double offset = leftShapeX - (rightShapeX - ShapeConst.SHAPE_NODE_INTERVAL - ShapeConst.SHAPE_NODE_WIDTH ); - double leftOffset = this.leftOffsetNode(leftNodes, levelMap, nodeMap, offset, leftMinLine); + double leftOffset = this.leftOffsetNode(leftNodes, levelMap, nodeMap,maxLevel, offset, leftMinLine); res.put("leftMinLine",Math.min(leftMinLine,leftOffset)); } } //偶数右半部调整 branchMedian = (int) Math.floor(medianBranch); - for (int i = branchMedian; i < numList.keySet().size();i++){ + for (int i = branchMedian; i < numMap.keySet().size();i++){ //构建同层级的分支序号 String leftLevelNo = "-1"; String rightLevelNo = this.getLevelNo(level,i+1); @@ -597,8 +670,8 @@ public class ImportShapeExcel1 { } //同分支序号多节点list - List leftNodes = numList.get(leftLevelNo); - List rightNodes = numList.get(rightLevelNo); + List leftNodes = numMap.get(leftLevelNo); + List rightNodes = numMap.get(rightLevelNo); if (rightNodes == null || rightNodes.isEmpty()){ continue; } @@ -614,7 +687,7 @@ public class ImportShapeExcel1 { if (leftShapeX + 15 > rightShapeX){ //需要调整,向右边移动 double offset = leftShapeX + ShapeConst.SHAPE_NODE_INTERVAL + ShapeConst.SHAPE_NODE_WIDTH; - double rightOffset = this.rightOffsetNode(rightNodes, levelMap, nodeMap, offset, rightMaxLine); + double rightOffset = this.rightOffsetNode(rightNodes, levelMap, nodeMap,maxLevel, offset, rightMaxLine); res.put("rightMaxLine",Math.max(rightMaxLine,rightOffset)); } } @@ -624,12 +697,20 @@ public class ImportShapeExcel1 { } - private double leftOffsetNode(List nodes,Map>> levelMap,Map> nodeMap,double offset,double leftMinLine){ + /** + * 将分支nodes对应已经画好的shape向左平移offset + * @param nodes + * @param levelMap + * @param nodeMap + * @param offset + * @param leftMinLine + * @return + */ + private double leftOffsetNode(List nodes,Map>> levelMap,Map> nodeMap,int maxLevel,double offset,double leftMinLine){ double leftLine = leftMinLine; //递归处理父级所有图形+连线的x的偏移量 double upLeftLine = this.changeUpLeftOffset(nodes.get(0).getShapeNum(), levelMap, nodeMap, offset, leftLine); - leftLine = Math.min(leftLine,upLeftLine); //处理当前nodes的偏移x @@ -637,13 +718,22 @@ public class ImportShapeExcel1 { leftLine = Math.min(leftLine,moveLeftLine); //递归处理子级所有图形+连线x的偏移量 - double subLeftLine = this.changeSubLeftOffset(nodes.get(0).getShapeNum(), levelMap, nodeMap, offset, leftLine); + double subLeftLine = this.changeSubLeftOffset(nodes.get(0).getShapeNum(), levelMap, nodeMap,maxLevel, offset, leftLine); leftLine = Math.min(leftLine,subLeftLine); return Math.min(leftLine,leftMinLine); } + /** + * 父级分支节点向左偏移 + * @param shapeNum + * @param levelMap + * @param nodeMap + * @param offset + * @param leftMinLine + * @return + */ private double changeUpLeftOffset(String shapeNum,Map>> levelMap,Map> nodeMap,double offset,double leftMinLine){ double leftLine = leftMinLine; @@ -658,32 +748,51 @@ public class ImportShapeExcel1 { return leftLine; } - Map> numList = levelMap.get(level); - if (null == numList){ + Map> numMap = levelMap.get(level); + if (null == numMap){ //层级跳级处理 double upLeftLine = this.changeUpLeftOffset(level+"."+branch, levelMap, nodeMap, offset, leftLine); leftLine = Math.min(leftLine,upLeftLine); return Math.min(leftLine,leftMinLine); } - List upList = numList.get(level + "." + branch); + //过滤 + numMap = this.filterLevelNum(numMap); + + List upList = numMap.get(level + "." + branch); if (upList == null || upList.isEmpty()){ - //分支父级跳级处理 + //上级分支跳级 double upLeftLine = this.changeUpLeftOffset(level+"."+branch, levelMap, nodeMap, offset, leftLine); leftLine = Math.min(leftLine,upLeftLine); return Math.min(leftLine,leftMinLine); } - double upLeftLine = this.changeUpLeftOffset(upList.get(0).getShapeNum(), levelMap, nodeMap, offset, leftLine); leftLine = Math.min(leftLine,upLeftLine); //移动父级节点 - double moveLeftLine = this.moveLeftNode(upList, nodeMap, offset, leftLine,true,false); + + //获取当前序号分支的直接上级分支 + boolean isSub = true; + List upBranchNode = this.findUpBranchNode(levelMap, upList.get(0).getShapeNum()); + if (upBranchNode.isEmpty()){ + isSub = false; + } + double moveLeftLine = this.moveLeftNode(upList, nodeMap, offset, leftLine,true,isSub); leftLine = Math.min(leftLine,moveLeftLine); return Math.min(leftLine,leftMinLine); } + /** + * nodes对应画好的shape整体向左偏移 + * @param nodes + * @param nodeMap + * @param offset + * @param leftMinLine + * @param isUp + * @param isSub + * @return + */ private double moveLeftNode(List nodes,Map> nodeMap,double offset,double leftMinLine,boolean isUp,boolean isSub){ double leftLine = leftMinLine; if (nodes==null || nodes.isEmpty()){ @@ -732,7 +841,16 @@ public class ImportShapeExcel1 { return leftLine; } - private double changeSubLeftOffset(String shapeNum,Map>> levelMap,Map> nodeMap,double offset,double leftMinLine){ + /** + * 下级分支节点向左偏移 + * @param node + * @param levelMap + * @param nodeMap + * @param offset + * @param leftMinLine + * @return + */ + private double changeSubLeftOffset(String shapeNum,Map>> levelMap,Map> nodeMap,int maxLevel ,double offset,double leftMinLine){ double leftLine = leftMinLine; if (!shapeNum.contains(".")){ @@ -743,18 +861,23 @@ public class ImportShapeExcel1 { String[] split = shapeNum.split("\\."); String level = ""+ (Integer.parseInt(split[0])+1); String branch = split[1]; - if (Integer.parseInt(level)<0){ + + if (Integer.parseInt(level)>maxLevel){ return leftLine; } Map> numList = levelMap.get(level); if(null == numList){ //层级跳级处理 - double subLeftOffset = this.changeSubLeftOffset(level+"."+branch, levelMap, nodeMap, offset, leftLine); + double subLeftOffset = this.changeSubLeftOffset(level+"."+branch, levelMap, nodeMap,maxLevel, offset, leftLine); leftLine = Math.min(leftLine,subLeftOffset); return Math.min(leftLine,leftMinLine); } + + //过滤 + numList = this.filterLevelNum(numList); + List subList = numList.get(level + "." + branch); if (subList == null || subList.isEmpty()){ subList = numList.get(level); @@ -762,16 +885,14 @@ public class ImportShapeExcel1 { //直接特殊处理,下一个整数节点连线调整 for (CellObject cellObject : subList) { - String upLevelno = Integer.parseInt(level) - 1 + "." + branch; - //图形+连线 List shapes = nodeMap.get(this.getCellObjectUUID(cellObject)); for (JSONObject shape : shapes) { //只调整连线的from点位 if (shape.getString("name").equals("linker")){ - //只调整与上一次递归分支的连线,调整to的x,pointer的0对象的x + //只调整与上一次递归分支的连线,调整from的x,pointer的0对象的x JSONObject from = shape.getJSONObject("from"); - if (from.getString("shapeNum").equals(upLevelno)){ + if (this.getBranchNo(from.getString("shapeNum")).equals(branch)){ Double x = from.getDouble("x"); from.put("x",(double)x-offset); @@ -784,15 +905,15 @@ public class ImportShapeExcel1 { } } - }else { + } else { //下级分支跳级直连 - double subLeftOffset = this.changeSubLeftOffset(level+"."+branch, levelMap, nodeMap, offset, leftLine); + double subLeftOffset = this.changeSubLeftOffset(level+"."+branch, levelMap, nodeMap,maxLevel, offset, leftLine); leftLine = Math.min(leftLine,subLeftOffset); } return Math.min(leftLine,leftMinLine); } - double subLeftOffset = this.changeSubLeftOffset(subList.get(0).getShapeNum(), levelMap, nodeMap, offset, leftLine); + double subLeftOffset = this.changeSubLeftOffset(subList.get(0).getShapeNum(), levelMap, nodeMap,maxLevel, offset, leftLine); leftLine = Math.min(leftLine,subLeftOffset); //移动子级节点 @@ -802,7 +923,7 @@ public class ImportShapeExcel1 { return Math.min(leftLine,leftMinLine); } - private double rightOffsetNode(List nodes,Map>> levelMap,Map> nodeMap,double offset,double rightMaxLine){ + private double rightOffsetNode(List nodes,Map>> levelMap,Map> nodeMap,int maxLevel,double offset,double rightMaxLine){ double rightLine = rightMaxLine; //递归处理父级所有图形+连线的x的偏移量 @@ -815,7 +936,7 @@ public class ImportShapeExcel1 { rightLine = Math.max(rightLine,moveRightOffset); //递归处理子级所有图形+连线x的偏移量 - double subRightOffset = this.changeSubRightOffset(nodes.get(0).getShapeNum(), levelMap, nodeMap, offset, rightLine); + double subRightOffset = this.changeSubRightOffset(nodes.get(0).getShapeNum(), levelMap, nodeMap,maxLevel, offset, rightLine); rightLine = Math.max(subRightOffset,rightLine); return Math.max(rightLine,rightMaxLine); @@ -836,17 +957,20 @@ public class ImportShapeExcel1 { } - Map> numList = levelMap.get(level); - if (null == numList){ - //层级跳级 处理 + Map> numMap = levelMap.get(level); + if (null == numMap){ + //层级跳级处理 double upRightOffset = this.changeUpRightOffset(level+"."+branch, levelMap, nodeMap, offset, rightLine); rightLine = Math.max(rightLine,upRightOffset); return Math.max(rightLine,rightMaxLine); } - List upList = numList.get(level + "." + branch); + //过滤 + numMap = this.filterLevelNum(numMap); + + List upList = numMap.get(level + "." + branch); if (upList == null || upList.isEmpty()){ - //分支父级跳级处理 + //上级分支跳级 double upRightOffset = this.changeUpRightOffset(level+"."+branch, levelMap, nodeMap, offset, rightLine); rightLine = Math.max(rightLine,upRightOffset); return Math.max(rightLine,rightMaxLine); @@ -856,8 +980,14 @@ public class ImportShapeExcel1 { rightLine = Math.max(rightLine,upRightOffset); //移动父节点x的偏移量 - double moveRightOffset = this.moveRightNode(upList, nodeMap, offset, rightLine, true, false); + //获取当前序号分支的直接上级分支 + boolean isSub = true; + List upBranchNode = this.findUpBranchNode(levelMap, upList.get(0).getShapeNum()); + if (upBranchNode.isEmpty()){ + isSub = false; + } + double moveRightOffset = this.moveRightNode(upList, nodeMap, offset, rightLine, true, isSub); rightLine = Math.max(moveRightOffset,rightLine); return Math.max(rightLine,rightMaxLine); @@ -911,7 +1041,7 @@ public class ImportShapeExcel1 { return rightLine; } - private double changeSubRightOffset(String shapeNum,Map>> levelMap,Map> nodeMap,double offset,double rightMaxLine){ + private double changeSubRightOffset(String shapeNum,Map>> levelMap,Map> nodeMap,int maxLevel,double offset,double rightMaxLine){ double rightLine = rightMaxLine; if (!shapeNum.contains(".")){ return rightLine; @@ -921,32 +1051,36 @@ public class ImportShapeExcel1 { String[] split = shapeNum.split("\\."); String level = ""+ (Integer.parseInt(split[0])+1); String branch = split[1]; - if (Integer.parseInt(level)<0){ + if (Integer.parseInt(level)>maxLevel){ return rightLine; } Map> numList = levelMap.get(level); if(null == numList){ //层级跳级处理 - double subRightOffset = this.changeSubRightOffset(level + "." + branch, levelMap, nodeMap, offset, rightLine); + double subRightOffset = this.changeSubRightOffset(level + "." + branch, levelMap, nodeMap, maxLevel,offset, rightLine); rightLine = Math.max(rightLine,subRightOffset); return Math.max(rightLine,rightMaxLine); } + + //过滤 + numList = this.filterLevelNum(numList); + + List subList = numList.get(level + "." + branch); if (subList == null || subList.isEmpty()){ subList = numList.get(level); if (subList != null){ //直接特殊处理,下一个整数节点连线调整 for (CellObject cellObject : subList) { - String upLevelno = Integer.parseInt(level) - 1 + "." + branch; //图形+连线 List shapes = nodeMap.get(this.getCellObjectUUID(cellObject)); for (JSONObject shape : shapes) { //只调整连线的from点位 if (shape.getString("name").equals("linker")){ - //只调整与上一次递归分支的连线,调整to的x,pointer的0对象的x + //只调整与上一次递归分支的连线,调整from的x,pointer的0对象的x JSONObject from = shape.getJSONObject("from"); - if (from.getString("shapeNum").equals(upLevelno)){ + if (this.getBranchNo(from.getString("shapeNum")).equals(branch)){ Double x = from.getDouble("x"); from.put("x",(double)x-offset); @@ -958,15 +1092,15 @@ public class ImportShapeExcel1 { } } } - }else{ + } else{ //分支下级跳级处理 - double subRightOffset = this.changeSubRightOffset(level + "." + branch, levelMap, nodeMap, offset, rightLine); + double subRightOffset = this.changeSubRightOffset(level + "." + branch, levelMap, nodeMap,maxLevel, offset, rightLine); rightLine = Math.max(rightLine,subRightOffset); } - return Math.max(rightLine,rightMaxLine); + return rightLine; } - double subRightOffset = this.changeSubRightOffset(subList.get(0).getShapeNum(), levelMap, nodeMap, offset, rightLine); + double subRightOffset = this.changeSubRightOffset(subList.get(0).getShapeNum(), levelMap, nodeMap,maxLevel, offset, rightLine); rightLine = Math.max(rightLine,subRightOffset); //移动子级节点 @@ -976,6 +1110,12 @@ public class ImportShapeExcel1 { return Math.max(rightLine,rightMaxLine); } + /** + * 获取同序号nodes的最左边界X + * @param leftNodes + * @param nodeMap + * @return + */ private double getNumListLeftShapeX(List leftNodes,Map> nodeMap){ JSONObject shape = this.getNumListLeftShape(leftNodes, nodeMap); if (shape == null){ @@ -985,6 +1125,12 @@ public class ImportShapeExcel1 { return props.getDouble("x"); } + /** + * 获取同序号nodes的最右边界X + * @param rightNodes + * @param nodeMap + * @return + */ private double getNumListRightShapeX(List rightNodes,Map> nodeMap){ JSONObject shape = this.getNumListRightShape(rightNodes, nodeMap); if (shape == null){ @@ -994,6 +1140,12 @@ public class ImportShapeExcel1 { return props.getDouble("x"); } + /** + * 获取同序号集合的右边shape + * @param leftNodes + * @param nodeMap + * @return + */ private JSONObject getNumListLeftShape(List leftNodes,Map> nodeMap){ if (null == leftNodes || leftNodes.isEmpty()){ return null; @@ -1004,6 +1156,12 @@ public class ImportShapeExcel1 { return jsonObjects == null || jsonObjects.isEmpty() ? null:jsonObjects.get(0); } + /** + * 获取同序号集合最左边shape + * @param rightNodes + * @param nodeMap + * @return + */ private JSONObject getNumListRightShape(List rightNodes,Map> nodeMap){ if (null == rightNodes || rightNodes.isEmpty()){ return null; @@ -1014,6 +1172,12 @@ public class ImportShapeExcel1 { return jsonObjects == null || jsonObjects.isEmpty() ? null:jsonObjects.get(0); } + /** + * 计算图形最右边界 + * @param shape + * @param rightMaxLine + * @return + */ private double getRightMaxLine(JSONObject shape, double rightMaxLine){ if (null == shape){ return 0; @@ -1025,17 +1189,28 @@ public class ImportShapeExcel1 { return Math.max(shapeRight,rightMaxLine); } + /** + * 计算图形最左边界 + * @param shape + * @param leftMaxLine + * @return + */ private double getLeftMinLine(JSONObject shape,double leftMaxLine){ if (null == shape){ return 0; } - JSONObject props = shape.getJSONObject("props"); Double x = props.getDouble("x"); - return Math.min(x,leftMaxLine); } + /** + * 拓展属性信息整理 + * @param repositoryId + * @param shape + * @param expandArr + * @param relationList + */ private void handleExpandAttr(String repositoryId,JSONObject shape,JSONArray expandArr,List relationList){ JSONArray attributesJsonArray = new JSONArray(); String shapeTitle = shape.getString("title"); @@ -1245,7 +1420,6 @@ public class ImportShapeExcel1 { } - private void saveDefine(String repositoryId,Map> nodeMap,double rightMaxLine,int maxLevel){ PALRepositoryModel palModel = PALRepositoryCache.getCache().get(repositoryId); BaseModel defineModel = CoeDesignerAPIManager.getInstance().getDefinition(palModel.getId(), 0); @@ -1297,18 +1471,33 @@ public class ImportShapeExcel1 { LogRealTimeCountCache.getCache().get(logId).setSuccessCount(LogRealTimeCountCache.getCache().get(logId).getSuccessCount() + 1); } + /** + * 获取node唯一标识 + * @param node + * @return + */ private String getCellObjectUUID(CellObject node){ //名称+类型+序号+分支 return node.getShapeName()+"|"+node.getShapeType()+"|"+node.getShapeBranch()+"|"+node.getShapeNum(); } + /** + * 绘制图形数据 + * @param node + * @param levelNodeIndex + * @param offset + * @param level + * @param zIndex + * @return + */ 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()); + //Todo:测试修改text为名称+编号 + shape.put("text", node.getShapeName()+node.getShapeNum()); shape.put("id", UUIDGener.getUUID()); shape.put("shapeNum", node.getShapeNum()); @@ -1326,13 +1515,51 @@ public class ImportShapeExcel1 { return shape; } + /** + * 根据父级节点与当前层级nodes判断是否需要画连线 + * @param upNodes + * @param nodes + * @return + */ + private boolean isDrawLinker(JSONObject upNodes,List nodes){ + if (null == upNodes){ + return false; + } + JSONArray upList = upNodes.getJSONArray("upList"); + if (upList == null || upList.isEmpty()){ + return false; + } + if (upNodes.getBooleanValue("isUp")){ + if (nodes.size()>1 && upList.size()>1){ + //多下级与多上级的连线不处理 + return false; + } + } + return true; + } + + /** + * 根据同层级节点list与当前node判断是否需要连线 + * @param nodes + * @param node + * @return + */ + private boolean isDrawLinker(CellObject node,Map> numMap){ + Map> newNumMap = this.filterLevelNum(numMap); + return newNumMap.keySet().contains(node.getShapeNum()); + } + + /** + * 绘制图形与多个父级直接的连线 + * @param fromNode + * @param toNode + * @param zIndex + * @return + */ private JSONObject drawLinker(JSONObject fromNode,JSONObject toNode,int zIndex){ JSONObject linker = JSONObject.parseObject(linkerDef); linker.put("id", UUIDGener.getUUID()); -// JSONObject fromNode = (JSONObject) node; -// JSONObject toNode = shape; - JSONObject from = this.getShapeBottomPoint(fromNode); from.put("id", fromNode.getString("id")); from.put("shapeNum",fromNode.getString("shapeNum")); @@ -1466,8 +1693,8 @@ public class ImportShapeExcel1 { for (CellObject cellObject : cellList) { String shapeNum = cellObject.getShapeNum(); - if (shapeNum.matches("[\\u4e00-\\u9fbb]+")){ - //序号中有中文,进入特殊处理分支 + if (this.isSpecialShape(shapeNum)){ + //不规则编号进入特殊处理分支 //文件下特殊分支cell List cellObjectList = specialMap.get(repositoryId); if (null == cellObjectList){ @@ -1476,14 +1703,7 @@ public class ImportShapeExcel1 { cellObjectList.add(cellObject); specialMap.put(repositoryId,cellObjectList); }else{ - //流程结束节点特殊处理 - if (cellObject.getShapeName().contains("流程结束")){ -// shapeNum = "-2"; - shapeNum = levelMap.keySet().size()+""; - cellObject.setShapeNum(shapeNum); - } - String shapeLevel = this.getCellObjecyLevel(shapeNum); - + String shapeLevel = this.getCellObjectLevel(shapeNum); //序号map下的层级map Map> numMap = levelMap.get(shapeLevel); if (null == numMap){ @@ -1501,6 +1721,43 @@ public class ImportShapeExcel1 { levelMap.put(shapeLevel,numMap); } } + + //特殊处理流程结束节点 + Map> specialNumList = levelMap.get("0"); + if (specialNumList != null){ + List zoreCells = specialNumList.get("0"); + if (zoreCells!=null){ + Iterator iterator = zoreCells.iterator(); + while (iterator.hasNext()){ + CellObject cellObject = iterator.next(); + if (cellObject.getShapeName().contains("流程结束")){ + JSONObject maxObj = this.getMaxLevelNo(levelMap); + String shapeNum = (maxObj.getInteger("maxLevel")+1) + ""; + cellObject.setShapeNum(shapeNum); + + String shapeLevel = this.getCellObjectLevel(shapeNum); + //序号map下的层级map + Map> numMap = levelMap.get(shapeLevel); + if (null == numMap){ + numMap = new LinkedHashMap<>(); + } + //同一层级处理:层级map下的序号数组数据 + List cells = numMap.get(shapeNum); + if (null == cells){ + cells = new ArrayList<>(); + } + cells.add(cellObject); + //设置序号数据 + numMap.put(shapeNum,cells); + + levelMap.put(shapeLevel,numMap); + + iterator.remove(); + } + } + } + } + branchMap.put(branch,levelMap); } @@ -1508,7 +1765,21 @@ public class ImportShapeExcel1 { } } - private String getCellObjecyLevel(String shapeNum){ + /** + * 判断是否为特殊编号 + * @param shapeNum + * @return + */ + private boolean isSpecialShape(String shapeNum){ + return !shapeNum.matches("^\\d{1,}\\.\\d{1,}|\\d{1,}"); + } + + /** + * 根据节点编号获取层级 + * @param shapeNum + * @return + */ + private String getCellObjectLevel(String shapeNum){ if (shapeNum.contains(".")){ //小数 String[] split = shapeNum.split("\\."); @@ -1517,6 +1788,12 @@ public class ImportShapeExcel1 { return shapeNum; } + /** + * 根据层级与索引返回当前节点的序号 + * @param level + * @param index + * @return + */ private String getLevelNo(int level,int index){ if (index < 1){ return ""+level; @@ -1524,6 +1801,12 @@ public class ImportShapeExcel1 { return ""+level+"."+index; } + /** + * 递归搜索当前编号同分支直接上级 + * @param levelMap + * @param levelNo + * @return + */ private List findUpBranchNode(Map>> levelMap,String levelNo){ List list = new ArrayList<>(); if (!levelNo.contains(".")){ @@ -1540,19 +1823,20 @@ public class ImportShapeExcel1 { Map> numList = levelMap.get(level); if (null == numList){ - //跳级 直接递归找上级 + //层级跳级 直接递归找上级 List upBranchNode = this.findUpBranchNode(levelMap, level + "." + branch); list.addAll(upBranchNode); return list; } + //过滤 + numList = this.filterLevelNum(numList); List cellObjects = numList.get(level + "." + branch); - if (cellObjects==null){ - return list; + if (cellObjects!=null){ + list.addAll(cellObjects); } - list.addAll(cellObjects); - if (cellObjects.isEmpty()){ + if (cellObjects == null || cellObjects.isEmpty()){ List upBranchNode = this.findUpBranchNode(levelMap, level + "." + branch); list.addAll(upBranchNode); } @@ -1561,7 +1845,8 @@ public class ImportShapeExcel1 { } /** - * 找到已经画好的上级节点 改为递归 + * 找到已经画好的上级节点 + * * @param no * @param levelMap * @param nodeMap @@ -1584,6 +1869,15 @@ public class ImportShapeExcel1 { } + /** + * 递归搜索no对应的父级节点 + * 支持跨级搜索 + * 过滤整数与小数共存 + * @param no + * @param levelMap + * @param nodeMap + * @return + */ private List find(String no,Map>> levelMap,Map> nodeMap){ List upList = new ArrayList<>(); String level = ""; @@ -1597,6 +1891,8 @@ public class ImportShapeExcel1 { //整数 level = Integer.parseInt(no)-1 + ""; } + + //超出层级范围 if (level.equals("-1")){ return upList; } @@ -1604,21 +1900,27 @@ public class ImportShapeExcel1 { Map> numMap = levelMap.get(level); if (null == numMap){ - //出现跨级越级处理 - List list = this.find(StringUtils.isNotEmpty(branch) ? level +"."+ branch : level, levelMap, nodeMap); ; + //当前层级没有数据,跨级继续搜索 + List list = this.find(StringUtils.isNotEmpty(branch) ? level +"."+ branch : level, levelMap, nodeMap); ; upList.addAll(list); }else{ + //过滤序号--小数与整数共存问题 + numMap = this.filterLevelNum(numMap); if (StringUtils.isEmpty(branch)){ - //整数节点找父级节点 + //整数节点找父级节点,可以是小数或整数节点 boolean flag = false; for (String s : numMap.keySet()) { List nodes = numMap.get(s); + if (null == nodes || nodes.isEmpty()){ + continue; + } + for (CellObject node : nodes) { //计算最终确定位置map的key:名称+类型+序号 - String key = this.getCellObjectUUID(node); - List shapes = nodeMap.get(key); + List shapes = nodeMap.get(this.getCellObjectUUID(node)); if (null != shapes){ + //对应节点已经画过图,取图形信息 for (JSONObject shape : shapes) { if (!shape.get("name").equals("linker")){ upList.add(shape); @@ -1634,10 +1936,10 @@ public class ImportShapeExcel1 { } } if (flag){ - //递归寻找多分支中整数节点的上级节点 + //递归上层其他层级,寻找其他分支中当前整数节点的上级节点 List list = this.find(level, levelMap, nodeMap); - //获取当前上级节点的list中的分支情况 + //获取当前已知上级节点的list中的分支情况,整数节点上级要么是整数,要么全是小数节点 List upBranchNo = this.getUpBranchNo(upList); if (!upBranchNo.isEmpty()){ for (JSONObject object : list) { @@ -1645,6 +1947,7 @@ public class ImportShapeExcel1 { if (shapeNum.contains(".")){ String branchNo = this.getBranchNo(shapeNum); if (!upBranchNo.contains(branchNo)){ + //其他分支 upList.add(object); } } @@ -1652,18 +1955,20 @@ public class ImportShapeExcel1 { } } }else { - //分支节点找父级节点 + //分支节点找父级节点,可以整数节点也可以是小数节点 List nodes = numMap.get(level +"."+ branch); - List nodes1 = numMap.get(level); - if ((nodes == null || nodes.isEmpty()) && (nodes1 == null || nodes1.isEmpty())){ + List integerNodes = numMap.get(level); + + //分支跳级搜索 + if ((nodes == null || nodes.isEmpty()) && (integerNodes == null || integerNodes.isEmpty())){ + //同层级分支节点与去整的分支节点都为空递归向上搜索 List list = this.find(level +"."+ branch, levelMap, nodeMap); upList.addAll(list); }else { if (nodes!=null){ for (CellObject node : nodes) { - //计算最终确定位置map的key:名称+类型+序号 - String key = this.getCellObjectUUID(node); - List shapes = nodeMap.get(key); + //计算最终确定位置map的key + List shapes = nodeMap.get(this.getCellObjectUUID(node)); if (null != shapes){ for (JSONObject shape : shapes) { if (!shape.get("name").equals("linker")){ @@ -1673,11 +1978,10 @@ public class ImportShapeExcel1 { } } } - if (nodes1 != null){ - for (CellObject node : nodes1) { + if (integerNodes != null){ + for (CellObject node : integerNodes) { //计算最终确定位置map的key:名称+类型+序号 - String key = this.getCellObjectUUID(node); - List shapes = nodeMap.get(key); + List shapes = nodeMap.get(this.getCellObjectUUID(node)); if (null != shapes){ for (JSONObject shape : shapes) { if (!shape.get("name").equals("linker")){ @@ -1687,8 +1991,6 @@ public class ImportShapeExcel1 { } } } - - } } } @@ -1696,6 +1998,39 @@ public class ImportShapeExcel1 { return upList; } + /** + * 过滤同层级序号 + * 若同为小数节点或整数节点直接返回 + * 若出现小数与整数节点则过滤掉小数 + *@param nodes + * @return + */ + private Map> filterLevelNum(Map> numMap){ + Map> newNumMap = new LinkedHashMap<>(); + if (numMap==null || numMap.isEmpty()){ + return newNumMap; + } + + int integerNum = 0; + for (String num : numMap.keySet()) { + if (!num.contains(".")){ + integerNum++; + } + if (integerNum>0 && num.contains(".")){ + //存在整数序号同时存在小数序号 + continue; + } + newNumMap.put(num,numMap.get(num)); + } + + return newNumMap; + } + + /** + * 获取父级shape的分支序号list + * @param upList + * @return + */ private List getUpBranchNo(List upList){ List list = new ArrayList<>(); for (JSONObject jsonObject : upList) { @@ -1712,6 +2047,11 @@ public class ImportShapeExcel1 { return list; } + /** + * 获取序号对应的分支号 + * @param no + * @return + */ private String getBranchNo (String no){ String branch = ""; if (no.contains(".")){ @@ -1723,6 +2063,15 @@ public class ImportShapeExcel1 { return branch; } + /** + * 计算同层级基于父级节点list的起始偏移量计算 + * @param levelNo + * @param offsetX + * @param upList + * @param nodes + * @param numList + * @return + */ private double getLevelStartNodeOffset(String levelNo, double offsetX,JSONArray upList,List nodes,Map> numList){ //根据上级计算offset,没有上级,一个上级,多个上级 double levelOffset = offsetX;