diff --git a/module/programplan/model.php b/module/programplan/model.php index 017e454389..d3ba174f21 100755 --- a/module/programplan/model.php +++ b/module/programplan/model.php @@ -329,7 +329,6 @@ class programplanModel extends model */ public function create(array $plans, int $projectID = 0, int $productID = 0, int $parentID = 0): bool { - if(!$this->isCreateTask($parentID)) dao::$errors['message'][] = $this->lang->programplan->error->createdTask; if(empty($plans)) dao::$errors['message'][] = sprintf($this->lang->error->notempty, $this->lang->programplan->name); if(dao::isError()) return false; @@ -343,6 +342,7 @@ class programplanModel extends model $updateUserViewIdList = array(); $enabledPoints = array(); $parallel = 0; + $firstStageID = 0; foreach($plans as $plan) { $parallel = isset($plan->parallel) ? $plan->parallel : 0; @@ -374,12 +374,15 @@ class programplanModel extends model $this->execution->updateProducts($stageID, $linkProducts); if($plan->acl != 'open') $updateUserViewIdList[] = $stageID; + + if(!$firstStageID) $firstStageID = $stageID; } } if($project && $project->model == 'ipd') $this->dao->update(TABLE_PROJECT)->set('parallel')->eq($parallel)->where('id')->eq($projectID)->exec(); if($updateUserViewIdList) $this->loadModel('user')->updateUserView($updateUserViewIdList, 'sprint'); if($enabledPoints) $this->programplanTao->updatePoint($projectID, $enabledPoints); + if(!$this->isCreateTask($parentID) && $firstStageID) $this->programplanTao->syncParentData($firstStageID, $parentID); return true; } diff --git a/module/programplan/tao.php b/module/programplan/tao.php index e2760de745..4552ec5d14 100644 --- a/module/programplan/tao.php +++ b/module/programplan/tao.php @@ -941,4 +941,30 @@ class programplanTao extends programplanModel return $plans; } + + /** + * 将父阶段数据转移到第一个子阶段中。 + * Sync parent data to first stage. + * + * @param int $executionID + * @param int $parentID + * @access protected + * @return bool + */ + protected function syncParentData(int $executionID, int $parentID): bool + { + $this->dao->update(TABLE_TASK)->set('execution')->eq($executionID)->where('execution')->eq($parentID)->exec(); + $this->dao->update(TABLE_PROJECTSTORY)->set('project')->eq($executionID)->where('project')->eq($parentID)->exec(); + $this->dao->update(TABLE_BUG)->set('execution')->eq($executionID)->where('execution')->eq($parentID)->exec(); + $this->dao->update(TABLE_CASE)->set('execution')->eq($executionID)->where('execution')->eq($parentID)->exec(); + $this->dao->update(TABLE_PROJECTCASE)->set('project')->eq($executionID)->where('project')->eq($parentID)->exec(); + $this->dao->update(TABLE_TESTTASK)->set('execution')->eq($executionID)->where('execution')->eq($parentID)->exec(); + $this->dao->update(TABLE_TESTREPORT)->set('execution')->eq($executionID)->where('execution')->eq($parentID)->exec(); + $this->dao->update(TABLE_BUILD)->set('execution')->eq($executionID)->where('execution')->eq($parentID)->exec(); + $this->dao->update(TABLE_EFFORT)->set('execution')->eq($executionID)->where('execution')->eq($parentID)->exec(); + $this->dao->update(TABLE_ACTION)->set('execution')->eq($executionID)->where('execution')->eq($parentID)->andWhere('objectType')->ne('execution')->exec(); + $this->dao->update(TABLE_ACTIONRECENT)->set('execution')->eq($executionID)->where('execution')->eq($parentID)->andWhere('objectType')->ne('execution')->exec(); + $this->dao->update(TABLE_DOCLIB)->set('execution')->eq($executionID)->where('type')->eq('execution')->andWhere('execution')->eq($parentID)->andWhere('main')->eq('0')->exec(); + return !dao::isError(); + } }