Excel导入流程图review ,编号跨级问题修改

This commit is contained in:
anhc 2022-09-19 16:39:44 +08:00
parent 7c8e0d59b2
commit 0790e9664e
2 changed files with 73 additions and 63 deletions

View File

@ -358,6 +358,9 @@ public class ImportShapeExcel1 {
for (int level = 0; level < maxLevel; level++) {
//同层级多分支节点信息, <序号同序号listNode>
Map<String, List<CellObject>> numList = levelMap.get("" + level);
if (null == numList){
continue;
}
for (int i = 0; i < numList.keySet().size()+1; i++) {
//构建同层级的分支序号
@ -424,8 +427,8 @@ public class ImportShapeExcel1 {
for (int level = 0; level < maxLevel; level++) {
//同层级多分支节点信息, <序号同序号listNode>
Map<String, List<CellObject>> numList = levelMap.get("" + level);
if (numList.keySet().size()<=1){
//只调整分支节点
if (numList == null ){
//跳级处理,
continue;
}
//找到一个出现分支的层级
@ -655,6 +658,7 @@ public class ImportShapeExcel1 {
Map<String, List<CellObject>> numList = levelMap.get(level);
List<CellObject> upList = numList.get(level + "." + branch);
if (upList == null || upList.isEmpty()){
return leftLine;
@ -1506,7 +1510,6 @@ public class ImportShapeExcel1 {
list.addAll(upBranchNode);
}
return list;
}
@ -1553,58 +1556,17 @@ public class ImportShapeExcel1 {
Map<String, List<CellObject>> numMap = levelMap.get(level);
if (StringUtils.isEmpty(branch)){
//整数节点找父级节点
boolean flag = false;
for (String s : numMap.keySet()) {
if (null == numMap){
//出现跨级越级处理
List<JSONObject> list = this.find(StringUtils.isNotEmpty(branch) ? level +"."+ branch : level, levelMap, nodeMap); ;
upList.addAll(list);
}else{
if (StringUtils.isEmpty(branch)){
//整数节点找父级节点
boolean flag = false;
for (String s : numMap.keySet()) {
List<CellObject> nodes = numMap.get(s);
for (CellObject node : nodes) {
//计算最终确定位置map的key名称+类型+序号
String key = this.getCellObjectUUID(node);
List<JSONObject> shapes = nodeMap.get(key);
if (null != shapes){
for (JSONObject shape : shapes) {
if (!shape.get("name").equals("linker")){
upList.add(shape);
}
}
}
}
if (s.contains(".")){
//父级节点是分支下节点
flag = true;
}else {
flag = false;
}
}
if (flag){
//递归寻找多分支中整数节点的上级节点
List<JSONObject> list = this.find(level, levelMap, nodeMap);
//获取当前上级节点的list中的分支情况
List<String> upBranchNo = this.getUpBranchNo(upList);
if (!upBranchNo.isEmpty()){
for (JSONObject object : list) {
String shapeNum = object.getString("shapeNum");
if (shapeNum.contains(".")){
String branchNo = this.getBranchNo(shapeNum);
if (!upBranchNo.contains(branchNo)){
upList.add(object);
}
}
}
}
}
}else {
//分支节点找父级节点
List<CellObject> nodes = numMap.get(level +"."+ branch);
List<CellObject> nodes1 = numMap.get(level);
if ((nodes == null || nodes.isEmpty()) && (nodes1 == null || nodes1.isEmpty())){
List<JSONObject> list = this.find(level +"."+ branch, levelMap, nodeMap);
upList.addAll(list);
}else {
if (nodes!=null){
List<CellObject> nodes = numMap.get(s);
for (CellObject node : nodes) {
//计算最终确定位置map的key名称+类型+序号
String key = this.getCellObjectUUID(node);
@ -1617,25 +1579,73 @@ public class ImportShapeExcel1 {
}
}
}
if (s.contains(".")){
//父级节点是分支下节点
flag = true;
}else {
flag = false;
}
}
if (nodes1 != null){
for (CellObject node : nodes1) {
//计算最终确定位置map的key名称+类型+序号
String key = this.getCellObjectUUID(node);
List<JSONObject> shapes = nodeMap.get(key);
if (null != shapes){
for (JSONObject shape : shapes) {
if (!shape.get("name").equals("linker")){
upList.add(shape);
if (flag){
//递归寻找多分支中整数节点的上级节点
List<JSONObject> list = this.find(level, levelMap, nodeMap);
//获取当前上级节点的list中的分支情况
List<String> upBranchNo = this.getUpBranchNo(upList);
if (!upBranchNo.isEmpty()){
for (JSONObject object : list) {
String shapeNum = object.getString("shapeNum");
if (shapeNum.contains(".")){
String branchNo = this.getBranchNo(shapeNum);
if (!upBranchNo.contains(branchNo)){
upList.add(object);
}
}
}
}
}
}else {
//分支节点找父级节点
List<CellObject> nodes = numMap.get(level +"."+ branch);
List<CellObject> nodes1 = numMap.get(level);
if ((nodes == null || nodes.isEmpty()) && (nodes1 == null || nodes1.isEmpty())){
List<JSONObject> 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<JSONObject> shapes = nodeMap.get(key);
if (null != shapes){
for (JSONObject shape : shapes) {
if (!shape.get("name").equals("linker")){
upList.add(shape);
}
}
}
}
}
if (nodes1 != null){
for (CellObject node : nodes1) {
//计算最终确定位置map的key名称+类型+序号
String key = this.getCellObjectUUID(node);
List<JSONObject> shapes = nodeMap.get(key);
if (null != shapes){
for (JSONObject shape : shapes) {
if (!shape.get("name").equals("linker")){
upList.add(shape);
}
}
}
}
}
}
}
}
return upList;
}