diff --git a/module/execution/model.php b/module/execution/model.php index 6040faef74..9d50ec12c1 100755 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -4953,7 +4953,7 @@ class executionModel extends model * Get plan data from the ID list of the product. * * @param array $productID - * @param string $param withMainPlan|skipParent + * @param string $param withMainPlan|skipParent|unexpired|noclosed * @param int $executionID * @return array */ @@ -5002,11 +5002,11 @@ class executionModel extends model * Process product planning data. * * @param array $plans - * @param string $param + * @param string $param withmainplan|skipparent * @access public * @return array */ - public function processProductPlans(array $plans, string $param): array + public function processProductPlans(array $plans, string $param = ''): array { if(strpos($param, 'sortedbydate') !== false) { diff --git a/module/execution/test/execution.class.php b/module/execution/test/execution.class.php index 2914e7d753..8460db315b 100644 --- a/module/execution/test/execution.class.php +++ b/module/execution/test/execution.class.php @@ -3128,4 +3128,25 @@ class executionTest return $this->executionModel->buildExecutionPairs($mode, $allExecutions, $executions, $parents, $projectPairs); } + + /** + * 处理产品计划的数据。 + * Process product planning data. + * + * @param array $productIdList + * @param string $param + * @access public + * @return array + */ + public function processProductPlansTest(array $productIdList, string $param = ''): array + { + $plans = $this->executionModel->dao->select('t1.id,t1.title,t1.product,t1.parent,t1.begin,t1.end,t1.branch,t2.type as productType')->from(TABLE_PRODUCTPLAN)->alias('t1') + ->leftJoin(TABLE_PRODUCT)->alias('t2')->on('t2.id=t1.product') + ->where('t1.product')->in($productIdList) + ->andWhere('t1.deleted')->eq(0) + ->orderBy('t1.begin desc, t1.id desc') + ->fetchAll('id'); + + return $this->executionModel->processProductPlans($plans, $param); + } } diff --git a/module/execution/test/model/processproductplans.php b/module/execution/test/model/processproductplans.php new file mode 100644 index 0000000000..f9c5a70d50 --- /dev/null +++ b/module/execution/test/model/processproductplans.php @@ -0,0 +1,25 @@ +#!/usr/bin/env php +gen(5); +su('admin'); + +/** + +title=测试executionModel->processProductPlans(); +timeout=0 +cid=1 + +*/ + +$productIdList = array(1, 2, 3, 4, 5); +$paramList = array('', 'withmainplan', 'skipparent'); + +$executionTester = new executionTest(); +r($executionTester->processProductPlansTest($productIdList, $paramList[0])) && p('5:15') && e('计划15 待定'); // 处理产品的计划信息 +r($executionTester->processProductPlansTest($productIdList, $paramList[1])) && p('4:10') && e('计划10 待定'); // 处理产品的带主干计划信息 +r($executionTester->processProductPlansTest($productIdList, $paramList[2])) && p('2:5') && e('计划5 待定'); // 处理产品的非父计划信息 +r(count($executionTester->processProductPlansTest($productIdList, $paramList[0]))) && p() && e('5'); // 处理产品的计划数量 +r(count($executionTester->processProductPlansTest($productIdList, $paramList[1]))) && p() && e('5'); // 处理产品的带主干计划数量 +r(count($executionTester->processProductPlansTest($productIdList, $paramList[2]))) && p() && e('5'); // 处理产品的非父计划数量