gojs流程图判断节点是否完整
流程图
st=>start: start
op=>subroutine: 节点1|past
e=>end
st->op->e
方法验证
if (StringUtil.isNotBlank(noteArray) && StringUtil.isNotBlank(linkArray) &&!noteArray.equals("[]")&& !linkArray.equals("[]") ) {
//节点
List<ProcessNote> noteList = JsonUtils.parseArray(noteArray, ProcessNote.class);
//节点网关连线
List<ProcessNoteGateway> gatewayList = JsonUtils.parseArray(linkArray, ProcessNoteGateway.class);
//判断节点连线是否完整
boolean completeFlag = true;
for(ProcessNote note:noteList){
//排除开始节点和结束节点
if(null==note.getCategory() || (null!=note.getCategory() && !note.getCategory().equals("start") && !note.getCategory().equals("end"))){
boolean fromFlag = false;
boolean toFlag = false;
//查询其他节点是否存在来向节点和去向节点
for(ProcessNoteGateway gateway:gatewayList){
//判断是否存在来向节点
if(gateway.getFromNoteCode().equals(note.getNoteCode())){
fromFlag = true;
}
//判断是否存在去向节点
if(gateway.getToNoteCode().equals(note.getNoteCode())){
toFlag = true;
}
}
//存在不完整节点返回,结束循环
if(!fromFlag || !toFlag){
completeFlag = false;
break;
}
}
}
if (!completeFlag){
data.setCode(WebResponseCode.FAIL);
data.setMsg("节点信息不完整,缺少连线");
return data;
}
processNoteService.updateNoteList(processId, noteList, gatewayList);
data.setCode(WebResponseCode.SUCCESS);
data.setMsg("操作成功!");
return data;
} else {
data.setCode(WebResponseCode.FAIL);
data.setMsg("节点信息不完善!");
return data;
}
来源:oschina
链接:https://my.oschina.net/u/3204029/blog/4417270