From d82fa1b70ec60008085c70f5cd8f73ff6f6a6f13 Mon Sep 17 00:00:00 2001 From: qixinzhi Date: Fri, 22 Sep 2023 06:44:15 +0000 Subject: [PATCH] * Add firstEnd field in table project and record end date when start a execution. --- module/common/model.php | 3 +++ module/execution/model.php | 1 + module/project/model.php | 18 ++++++++++++++++++ 3 files changed, 22 insertions(+) diff --git a/module/common/model.php b/module/common/model.php index b14520ef4e..5f27f85cdc 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -125,6 +125,8 @@ class commonModel extends model ->where('id')->eq($projectID) ->exec(); + $this->loadModel('project')->recordFirstEnd($projectID); + $actionType = $project->multiple ? 'syncproject' : 'syncmultipleproject'; $this->loadModel('action')->create('project', $projectID, $actionType); } @@ -180,6 +182,7 @@ class commonModel extends model if($execution->status == 'wait') { $this->dao->update(TABLE_EXECUTION)->set('status')->eq('doing')->set('realBegan')->eq($today)->where('id')->eq($execution->id)->exec(); + $this->loadModel('project')->recordFirstEnd($execution->id); $this->loadModel('action')->create('execution', $execution->id, 'syncexecution'); if($execution->parent) { diff --git a/module/execution/model.php b/module/execution/model.php index b3f64d6c25..e0f82bb75f 100755 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -1209,6 +1209,7 @@ class executionModel extends model ->checkFlow() ->where('id')->eq((int)$executionID) ->exec(); + $this->loadModel('project')->recordFirstEnd($executionID); /* When it has multiple errors, only the first one is prompted */ if(dao::isError() and count(dao::$errors['realBegan']) > 1) dao::$errors['realBegan'] = dao::$errors['realBegan'][0]; diff --git a/module/project/model.php b/module/project/model.php index 7c0e16d3a4..b0980daac8 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -1837,6 +1837,8 @@ class projectModel extends model ->where('id')->eq((int)$projectID) ->exec(); + $this->recordFirstEnd($projectID); + /* When it has multiple errors, only the first one is prompted */ if(dao::isError() and count(dao::$errors['realBegan']) > 1) dao::$errors['realBegan'] = dao::$errors['realBegan'][0]; @@ -3224,4 +3226,20 @@ class projectModel extends model return $leftTasks; } + + + /** + * 记录项目启动时的计划完成日期。 + * Record the end date when the project is started. + * + * @param int $projectID + * @access public + * @return bool + */ + public function recordFirstEnd(int $projectID): bool + { + $project = $this->dao->select('end')->from(TABLE_PROJECT)->where('id')->eq($projectID)->fetch(); + $this->dao->update(TABLE_PROJECT)->set('firstEnd')->eq($project->end)->where('id')->eq($projectID)->exec(); + return !dao::isError(); + } }