From f3d061405cf13d2fcaff1943c6cc5d1ba5515d2e Mon Sep 17 00:00:00 2001 From: songchenxuan Date: Mon, 25 Nov 2024 13:54:07 +0800 Subject: [PATCH] * [task#133012,133013,5h,doing]. --- module/pivot/lang/de.php | 1 + module/pivot/lang/en.php | 1 + module/pivot/lang/fr.php | 1 + module/pivot/lang/zh-cn.php | 1 + module/pivot/model.php | 49 +++++++++++++++++++++++++++++++++++++ module/pivot/zen.php | 15 +++++++++--- 6 files changed, 65 insertions(+), 3 deletions(-) diff --git a/module/pivot/lang/de.php b/module/pivot/lang/de.php index cc8a819c3e..1d1ad7d3c8 100644 --- a/module/pivot/lang/de.php +++ b/module/pivot/lang/de.php @@ -27,6 +27,7 @@ $lang->pivot->story = 'Story'; $lang->pivot->clear = 'Clear'; $lang->pivot->keep = 'Keep'; $lang->pivot->new = 'New'; +$lang->pivot->newVersion = 'New version'; $lang->pivot->version = 'Version'; $lang->pivot->viewVersion = 'View version'; diff --git a/module/pivot/lang/en.php b/module/pivot/lang/en.php index 57f7c4f643..24959593c5 100644 --- a/module/pivot/lang/en.php +++ b/module/pivot/lang/en.php @@ -27,6 +27,7 @@ $lang->pivot->story = 'Story'; $lang->pivot->clear = 'Clear'; $lang->pivot->keep = 'Keep'; $lang->pivot->new = 'New'; +$lang->pivot->newVersion = 'New version'; $lang->pivot->version = 'Version'; $lang->pivot->viewVersion = 'View version'; diff --git a/module/pivot/lang/fr.php b/module/pivot/lang/fr.php index 553a97548e..bd32fe89b2 100644 --- a/module/pivot/lang/fr.php +++ b/module/pivot/lang/fr.php @@ -27,6 +27,7 @@ $lang->pivot->story = 'Story'; $lang->pivot->clear = 'Clear'; $lang->pivot->keep = 'Keep'; $lang->pivot->new = 'New'; +$lang->pivot->newVersion = 'New version'; $lang->pivot->version = 'Version'; $lang->pivot->viewVersion = 'View version'; diff --git a/module/pivot/lang/zh-cn.php b/module/pivot/lang/zh-cn.php index 99a1a3e5c4..fd90c78f19 100644 --- a/module/pivot/lang/zh-cn.php +++ b/module/pivot/lang/zh-cn.php @@ -27,6 +27,7 @@ $lang->pivot->story = '需求'; $lang->pivot->clear = '清空'; $lang->pivot->keep = '保留设计'; $lang->pivot->new = '新'; +$lang->pivot->newVersion = '新版本'; $lang->pivot->version = '当前版本'; $lang->pivot->viewVersion = '查看版本列表'; diff --git a/module/pivot/model.php b/module/pivot/model.php index 00513d4179..3618f08c33 100644 --- a/module/pivot/model.php +++ b/module/pivot/model.php @@ -2902,6 +2902,55 @@ class pivotModel extends model return $maxVersion; } + + /** + * Get max version by idList. + * + * @param string|array $pivotIDList + * @access public + * @return string + */ + public function getMaxVersionByIDList(string|array $pivotIDList) + { + $pivotVersions = $this->dao->select('pivot,version')->from(TABLE_PIVOTSPEC) + ->where('pivot')->in($pivotIDList) + ->fetchGroup('pivot', 'version'); + if(empty($pivotVersions)) return array(); + + $pivotMaxVersion = array(); + foreach($pivotVersions as $pivotID => $versions) + { + $versions = array_keys($versions); + $maxVersion = current($versions); + foreach($versions as $version) + { + if(version_compare($version, $maxVersion, '>')) $maxVersion = $version; + } + + $pivotMaxVersion[$pivotID] = $maxVersion; + } + + return $pivotMaxVersion; + } + + public function isVersionChange(array $pivots) + { + $pivotMaxVersion = $this->getMaxVersionByIDList(array_column($pivots, 'id')); + + foreach($pivots as $index => $pivot) + { + if(isset($pivotMaxVersion[$pivot->id]) && $pivotMaxVersion[$pivot->id] != $pivot->version) + { + $pivots[$index]->versionChange = true; + } + else + { + $pivots[$index]->versionChange = false; + } + } + + return $pivots; + } } /** diff --git a/module/pivot/zen.php b/module/pivot/zen.php index dfbab7f94f..136ee6fbc4 100644 --- a/module/pivot/zen.php +++ b/module/pivot/zen.php @@ -91,6 +91,7 @@ class pivotZen extends pivot $pivots = $this->pivot->getAllPivotByGroupID($group->id); $pivots = $this->pivot->filterInvisiblePivot($pivots); $pivots = $this->loadModel('mark')->getMarks($pivots, 'pivot', 'view'); + $pivots = $this->pivot->isVersionChange($pivots); if(empty($pivots)) continue; if($group->grade > 1) $menus[] = (object)array('id' => $group->id, 'parent' => 0, 'name' => $group->name); @@ -124,9 +125,17 @@ class pivotZen extends pivot */ protected function setNewMark(object $pivot, object $firstAction, array $builtins): void { - if(!isset($builtins[$pivot->id])) return; - if(!$pivot->mark && $pivot->createdDate < $firstAction->date) $pivot->mark = true; - if(!$pivot->mark) $pivot->name = array('text' => $pivot->name, 'html' => $pivot->name . ' ' . $this->lang->pivot->new . ''); + // 版本没有改变,此时讨论是不是新透视表 + if(!$pivot->versionChange) + { + if(!isset($builtins[$pivot->id])) return; + if(!$pivot->mark && $pivot->createdDate < $firstAction->date) $pivot->mark = true; + if(!$pivot->mark) $pivot->name = array('text' => $pivot->name, 'html' => $pivot->name . ' ' . $this->lang->pivot->new . ''); + } + else + { + $pivot->name = array('text' => $pivot->name, 'html' => $pivot->name . ' ' . $this->lang->pivot->newVersion . ''); + } } /**