* Finish task #84583.

This commit is contained in:
hufangzhou
2023-02-18 16:04:53 +00:00
parent 74a7615cca
commit 75b5b2562c
15 changed files with 725 additions and 215 deletions
+56
View File
@@ -1616,4 +1616,60 @@ class programplanModel extends model
$this->updateSubStageAttr($childID, $attribute, $withDeleted);
}
}
/**
* Get plan and its children.
*
* @param array $planIdList
* @access public
* @return array
*/
public function getSelfAndChildrenList($planIdList)
{
$planList = $this->dao->select('t2.*')->from(TABLE_EXECUTION)->alias('t1')
->leftJoin(TABLE_EXECUTION)->alias('t2')->on('FIND_IN_SET(t1.id,t2.`path`)')
->where('t1.id')->in($planIdList)
->andWhere('t2.deleted')->eq(0)
->fetchAll('id');
$selfAndChildrenList = array();
foreach($planIdList as $planID)
{
if(!isset($selfAndChildrenList[$planID])) $selfAndChildrenList[$planID] = array();
foreach($planList as $plan)
{
if(strpos($plan->path, ",$planID,") !== false) $selfAndChildrenList[$planID][$plan->id] = $plan;
}
}
return $selfAndChildrenList;
}
/**
* Get plan's siblings.
*
* @param array $planIdList
* @access public
* @return array
*/
public function getSiblings($planIdList)
{
$siblingsList = $this->dao->select('t1.*')->from(TABLE_EXECUTION)->alias('t1')
->leftJoin(TABLE_EXECUTION)->alias('t2')->on('t1.parent=t2.parent')
->where('t2.id')->in($planIdList)
->andWhere('t1.deleted')->eq(0)
->fetchAll('id');
$siblingStages = array();
foreach($planIdList as $planID)
{
if(!isset($siblingStages[$planID])) $siblingStages[$planID] = array();
foreach($siblingsList as $sibling)
{
if($siblingsList[$planID]->parent == $sibling->parent) $siblingStages[$planID][$sibling->id] = $sibling;
}
}
return $siblingStages;
}
}