冗余代码调整

This commit is contained in:
walker-sheng” 2024-07-02 18:34:39 +08:00
parent 13c25c0ba8
commit 8e20a049a4
1 changed files with 11 additions and 21 deletions

View File

@ -174,38 +174,28 @@ func NewLinkNodeAndLinkAndBuildLinkship(ta model.Turnout, tap model.PipePort, tb
nodeb = repo1.getOrBuildLinkNode(tb)
pla = nil
plb = model.NewPipeLink(nodeb, tbp)
exist, link = repo1.isLinkExist(pla, plb)
if exist {
return
}
link = model.NewLink(pla, plb)
link.SetLinkedElement(model.PipePortB, plb)
nodeb.SetLinkedElement(tbp, model.NewPipeLink(link, model.PipePortB))
} else if tb == nil {
nodea = repo1.getOrBuildLinkNode(ta)
nodeb = nil
pla = model.NewPipeLink(nodea, tap)
plb = nil
exist, link = repo1.isLinkExist(pla, plb)
if exist {
return
}
link = model.NewLink(pla, plb)
link.SetLinkedElement(model.PipePortA, pla)
nodea.SetLinkedElement(tap, model.NewPipeLink(link, model.PipePortA))
} else {
nodea = repo1.getOrBuildLinkNode(ta)
nodeb = repo1.getOrBuildLinkNode(tb)
pla = model.NewPipeLink(nodea, tap)
plb = model.NewPipeLink(nodeb, tbp)
exist, link = repo1.isLinkExist(pla, plb)
if exist {
return
}
link = model.NewLink(pla, plb)
link.SetLinkedElement(model.PipePortA, pla)
link.SetLinkedElement(model.PipePortB, plb)
}
exist, link = repo1.isLinkExist(pla, plb)
if exist {
return
}
link = model.NewLink(pla, plb)
link.SetLinkedElement(model.PipePortA, pla)
link.SetLinkedElement(model.PipePortB, plb)
if nodea != nil {
nodea.SetLinkedElement(tap, model.NewPipeLink(link, model.PipePortA))
}
if nodeb != nil {
nodeb.SetLinkedElement(tbp, model.NewPipeLink(link, model.PipePortB))
}
return