From d5b55323a1f03a05d0586643f8e98edefb799e25 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Wed, 30 Aug 2023 17:08:20 +0800 Subject: [PATCH] * Refactor checkCFDData method. --- module/execution/control.php | 2 +- module/execution/model.php | 8 +++++--- module/execution/test/execution.class.php | 8 +++++--- .../model/{checkcfddata.php => updatecfddata.php} | 11 ++++------- 4 files changed, 15 insertions(+), 14 deletions(-) rename module/execution/test/model/{checkcfddata.php => updatecfddata.php} (83%) diff --git a/module/execution/control.php b/module/execution/control.php index 8a1abd1fc2..2f23a80aeb 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -1381,7 +1381,7 @@ class execution extends control if(dao::isError()) return $this->sendError(dao::getError()); $this->execution->computeCFD($executionID); - $this->execution->checkCFDData($executionID, $begin); + $this->execution->updateCFDData($executionID, $begin); return $this->send(array('result' => 'success', 'locate' => $this->createLink('execution', 'cfd', "executionID=$executionID&type=$type&withWeekend=$withWeekend&begin=" . helper::safe64Encode(urlencode($begin)) . "&end=" . helper::safe64Encode(urlencode($end))))); } diff --git a/module/execution/model.php b/module/execution/model.php index 85b8d884b4..fafc33adaf 100755 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -3878,14 +3878,15 @@ class executionModel extends model } /** + * 查看指定的执行日期是否有数据,且没有更新最新日期的数据。 * Check whether there is data on the specified date of execution, and there is no data with the latest date added. * - * @param int $executionID - * @param string $date + * @param int $executionID + * @param string $date * @access public * @return void */ - public function checkCFDData($executionID, $date) + public function updateCFDData(int $executionID, string $date) { $today = helper::today(); if($date >= $today) return; @@ -3894,6 +3895,7 @@ class executionModel extends model ->where('execution')->eq((int)$executionID) ->andWhere('date')->eq($date) ->orderBy('date DESC, id asc')->fetchGroup('name', 'date'); + if(!$checkData) { $closetoDate = $this->dao->select("max(date) as date")->from(TABLE_CFD)->where('execution')->eq((int)$executionID)->andWhere('date')->lt($date)->fetch('date'); diff --git a/module/execution/test/execution.class.php b/module/execution/test/execution.class.php index 36b46162a3..d74a775e4d 100644 --- a/module/execution/test/execution.class.php +++ b/module/execution/test/execution.class.php @@ -2912,16 +2912,18 @@ class executionTest } /** - * Test check CFD data. + * 查看指定的执行日期是否有数据,且没有更新最新日期的数据。 + * Check whether there is data on the specified date of execution, and there is no data with the latest date added. * * @param int $executionID * @param string $date * @access public * @return array */ - public function checkCFDDataTest($executionID, $date) + public function updateCFDDataTest(int $executionID, string $date): array { - $this->executionModel->checkCFDData($executionID, $date); + $this->executionModel->updateCFDData($executionID, $date); + return $this->executionModel->dao->select("date, `count` AS value, `name`")->from(TABLE_CFD) ->where('execution')->eq((int)$executionID) ->andWhere('date')->eq($date) diff --git a/module/execution/test/model/checkcfddata.php b/module/execution/test/model/updatecfddata.php similarity index 83% rename from module/execution/test/model/checkcfddata.php rename to module/execution/test/model/updatecfddata.php index d10fa83eb0..3c42be4419 100644 --- a/module/execution/test/model/checkcfddata.php +++ b/module/execution/test/model/updatecfddata.php @@ -42,17 +42,14 @@ $CFD->gen(5); /** -title=测试executionModel->checkCFDData(); +title=测试executionModel->updateCFDData(); +timeout=0 cid=1 -pid=1 - -已有日期的情况 >> 5 -未来日期的情况 >> 0 */ $executionTester = new executionTest(); $dateList = array('2022-01-22', '2099-01-01'); -r(count($executionTester->checkCFDDataTest(3, $dateList[0]))) && p() && e('5'); // 已有日期的情况 -r(count($executionTester->checkCFDDataTest(3, $dateList[1]))) && p() && e('0'); // 未来日期的情况 +r(count($executionTester->updateCFDDataTest(3, $dateList[0]))) && p() && e('5'); // 已有日期的情况 +r(count($executionTester->updateCFDDataTest(3, $dateList[1]))) && p() && e('0'); // 未来日期的情况