From 7845ef16bc634978554f78eb02f49f008cb5bf4d Mon Sep 17 00:00:00 2001 From: tianshujie Date: Wed, 20 Sep 2023 16:00:25 +0800 Subject: [PATCH] * Move the function getGroupRoadmapData from tao into the model. --- module/product/model.php | 50 +++++++++++++++++++ module/product/tao.php | 50 ------------------- .../{tao => model}/getgrouproadmapdata.php | 0 3 files changed, 50 insertions(+), 50 deletions(-) rename module/product/test/{tao => model}/getgrouproadmapdata.php (100%) diff --git a/module/product/model.php b/module/product/model.php index d0148d2b2d..f4818c5712 100755 --- a/module/product/model.php +++ b/module/product/model.php @@ -1793,4 +1793,54 @@ class productModel extends model return $statusCountList; } + + /** + * 获取产品路线图的分组数据。 + * Get group roadmap data of product. + * + * @param int $productID + * @param string $branch all|0|1 + * @param int $count + * @access public + * @return [array, bool] + */ + public function getGroupRoadmapData(int $productID, string $branch, int $count): array + { + $roadmap = array(); + $return = false; + + /* Get product plans. */ + $planList = $this->loadModel('productplan')->getList($productID, $branch); + + /* Filter the valid plans, then get the ordered and parents plans. */ + list($orderedPlans, $parentPlans) = $this->productTao->filterOrderedAndParentPlans($planList); + + /* Get roadmaps of product plans. */ + list($roadmap, $total, $return) = $this->productTao->getRoadmapOfPlans($orderedPlans, $parentPlans, $branch, $count); + if($return) return array($roadmap, $return); + + /* Get roadmpas of product releases. */ + $releases = $this->loadModel('release')->getList($productID, $branch); + list($roadmap, $subTotal, $return) = $this->productTao->getRoadmapOfReleases($roadmap, $releases, $branch, $count); + if($return) return array($roadmap, $return); + $total += $subTotal; + + /* Re-group with branch ID. */ + $groupRoadmap = array(); + foreach($roadmap as $year => $branchRoadmap) + { + foreach($branchRoadmap as $branch => $roadmapItems) + { + /* Split roadmap items into multiple lines. */ + $totalData = count($roadmapItems); + $rows = ceil($totalData / 8); + $maxPerRow = ceil($totalData / $rows); + + $groupRoadmap[$year][$branch] = array_chunk($roadmapItems, (int)$maxPerRow); + foreach(array_keys($groupRoadmap[$year][$branch]) as $row) krsort($groupRoadmap[$year][$branch][$row]); + } + } + + return array($groupRoadmap, $return); + } } diff --git a/module/product/tao.php b/module/product/tao.php index b2156667ca..08c43092d7 100644 --- a/module/product/tao.php +++ b/module/product/tao.php @@ -449,56 +449,6 @@ class productTao extends productModel ->fetchAll(); } - /** - * 获取产品路线图的分组数据。 - * Get group roadmap data of product. - * - * @param int $productID - * @param string $branch all|0|1 - * @param int $count - * @access protected - * @return [array, bool] - */ - protected function getGroupRoadmapData(int $productID, string $branch, int $count): array - { - $roadmap = array(); - $return = false; - - /* Get product plans. */ - $planList = $this->loadModel('productplan')->getList($productID, $branch); - - /* Filter the valid plans, then get the ordered and parents plans. */ - list($orderedPlans, $parentPlans) = $this->filterOrderedAndParentPlans($planList); - - /* Get roadmaps of product plans. */ - list($roadmap, $total, $return) = $this->getRoadmapOfPlans($orderedPlans, $parentPlans, $branch, $count); - if($return) return array($roadmap, $return); - - /* Get roadmpas of product releases. */ - $releases = $this->loadModel('release')->getList($productID, $branch); - list($roadmap, $subTotal, $return) = $this->getRoadmapOfReleases($roadmap, $releases, $branch, $count); - if($return) return array($roadmap, $return); - $total += $subTotal; - - /* Re-group with branch ID. */ - $groupRoadmap = array(); - foreach($roadmap as $year => $branchRoadmap) - { - foreach($branchRoadmap as $branch => $roadmapItems) - { - /* Split roadmap items into multiple lines. */ - $totalData = count($roadmapItems); - $rows = ceil($totalData / 8); - $maxPerRow = ceil($totalData / $rows); - - $groupRoadmap[$year][$branch] = array_chunk($roadmapItems, (int)$maxPerRow); - foreach(array_keys($groupRoadmap[$year][$branch]) as $row) krsort($groupRoadmap[$year][$branch][$row]); - } - } - - return array($groupRoadmap, $return); - } - /** * 过滤有效的产品计划, 并返回所有父级计划。 * Filter valid product plans. diff --git a/module/product/test/tao/getgrouproadmapdata.php b/module/product/test/model/getgrouproadmapdata.php similarity index 100% rename from module/product/test/tao/getgrouproadmapdata.php rename to module/product/test/model/getgrouproadmapdata.php