From 4fbc213c5799096ff2d8cbce5e7c1ac87f530cdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E6=9C=A8?= <594326199@qq.com> Date: Thu, 3 Dec 2026 15:11:40 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=A2=84=E7=83=AD=E4=BE=9B=E5=BA=94?= =?UTF-8?q?=E5=95=86=E5=AF=B9=E8=B4=A6=E8=B4=A2=E5=8A=A1=E7=AD=9B=E9=80=89?= =?UTF-8?q?=E7=BC=93=E5=AD=98=20Co-authored-by:=20=E8=8B=8F=E6=9C=A8=20<59?= =?UTF-8?q?4326199@qq.com>=20Co-committed-by:=20=E8=8B=8F=E6=9C=A8=20<5943?= =?UTF-8?q?26199@qq.com>?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...rmSupplierReconciliationFinanceFilters.php | 23 +++++++++++++++++++ deploy/activate-incremental-release.sh | 2 ++ deploy/activate-release.sh | 2 ++ .../View/SupplierReconciliationPageData.php | 12 ++++++++-- .../Deployment/BusinessMirrorScheduleTest.php | 13 +++++++++++ 5 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 app/Console/Commands/WarmSupplierReconciliationFinanceFilters.php diff --git a/app/Console/Commands/WarmSupplierReconciliationFinanceFilters.php b/app/Console/Commands/WarmSupplierReconciliationFinanceFilters.php new file mode 100644 index 000000000..89fd73b96 --- /dev/null +++ b/app/Console/Commands/WarmSupplierReconciliationFinanceFilters.php @@ -0,0 +1,23 @@ +option('company')); + $pageData->warmFinanceFilters($companyId); + $this->info("公司 {$companyId} 的财务端供应商对账筛选缓存已预热。"); + + return self::SUCCESS; + } +} diff --git a/deploy/activate-incremental-release.sh b/deploy/activate-incremental-release.sh index e2831f367..8686795dd 100644 --- a/deploy/activate-incremental-release.sh +++ b/deploy/activate-incremental-release.sh @@ -213,6 +213,8 @@ CRON_TZ=Asia/Shanghai # 供应商货款预估:每天 07:00 日结前一天;每月 1 日 07:10 重跑上月并记录差异。 0 7 * * * root CAIWU_BATCH_LOCK_WAIT=10800 /bin/sh /opt/caiwuxitong/run-finance-batch.sh supplier-payable-forecast:sync --quiet >> /opt/caiwuxitong/runtime/sync-logs/supplier-payable-forecast.log 2>&1 10 7 1 * * root CAIWU_BATCH_LOCK_WAIT=10800 /bin/sh /opt/caiwuxitong/run-finance-batch.sh supplier-payable-forecast:sync --monthly --quiet >> /opt/caiwuxitong/runtime/sync-logs/supplier-payable-forecast.log 2>&1 +# 供应商对账财务端:持续预热月份和对账人筛选,避免缓存过期后的首个请求扫描超大数据集。 +*/10 * * * * root /usr/bin/docker exec -u www-data caiwu_app php artisan supplier-reconciliation:warm-finance-filters --company=1 --quiet >/dev/null 2>&1 # 之前月未定价-本月定价:每月 2 日使用工作平台价格镜像自动生成上月数据;后两次仅在未完成时重试。 30 8,12,16 2 * * root CAIWU_BATCH_LOCK_WAIT=10800 /bin/sh /opt/caiwuxitong/run-finance-batch.sh payables:unpriced-cycle:auto --company=1 --quiet >> /opt/caiwuxitong/runtime/sync-logs/payables-unpriced-cycle.log 2>&1 0 0 * * * root /usr/bin/flock -w 3600 /run/caiwu-upstream-sync.lock /bin/sh -c '/usr/bin/docker exec -u www-data caiwu_app php artisan business-mirror:warm-report-caches --quiet' >/dev/null 2>&1 diff --git a/deploy/activate-release.sh b/deploy/activate-release.sh index d2a051983..0b797a22f 100644 --- a/deploy/activate-release.sh +++ b/deploy/activate-release.sh @@ -217,6 +217,8 @@ CRON_TZ=Asia/Shanghai # 供应商货款预估:每天 07:00 日结前一天;每月 1 日 07:10 重跑上月并记录差异。 0 7 * * * root CAIWU_BATCH_LOCK_WAIT=10800 /bin/sh /opt/caiwuxitong/run-finance-batch.sh supplier-payable-forecast:sync --quiet >> /opt/caiwuxitong/runtime/sync-logs/supplier-payable-forecast.log 2>&1 10 7 1 * * root CAIWU_BATCH_LOCK_WAIT=10800 /bin/sh /opt/caiwuxitong/run-finance-batch.sh supplier-payable-forecast:sync --monthly --quiet >> /opt/caiwuxitong/runtime/sync-logs/supplier-payable-forecast.log 2>&1 +# 供应商对账财务端:持续预热月份和对账人筛选,避免缓存过期后的首个请求扫描超大数据集。 +*/10 * * * * root /usr/bin/docker exec -u www-data caiwu_app php artisan supplier-reconciliation:warm-finance-filters --company=1 --quiet >/dev/null 2>&1 # 之前月未定价-本月定价:每月 2 日使用工作平台价格镜像自动生成上月数据;后两次仅在未完成时重试。 30 8,12,16 2 * * root CAIWU_BATCH_LOCK_WAIT=10800 /bin/sh /opt/caiwuxitong/run-finance-batch.sh payables:unpriced-cycle:auto --company=1 --quiet >> /opt/caiwuxitong/runtime/sync-logs/payables-unpriced-cycle.log 2>&1 0 0 * * * root /usr/bin/flock -w 3600 /run/caiwu-upstream-sync.lock /bin/sh -c '/usr/bin/docker exec -u www-data caiwu_app php artisan business-mirror:warm-report-caches --quiet' >/dev/null 2>&1 diff --git a/modules/EcommerceFinance/View/SupplierReconciliationPageData.php b/modules/EcommerceFinance/View/SupplierReconciliationPageData.php index 88c072fe4..8c98bbd76 100644 --- a/modules/EcommerceFinance/View/SupplierReconciliationPageData.php +++ b/modules/EcommerceFinance/View/SupplierReconciliationPageData.php @@ -396,6 +396,14 @@ class SupplierReconciliationPageData return $this->vendorPeriodContext()['accountingMonthKey']; } + public function warmFinanceFilters(int $companyId): void + { + $mineDataset = PayablesFinalActions::DATASET_PREFIX . 'supplier:payment-reconciliation'; + $returnDataset = PayablesFinalActions::DATASET_PREFIX . 'supplier:return-reconciliation'; + $this->financeReconcilers($mineDataset, $returnDataset, $companyId); + $this->financeMonths($mineDataset, $returnDataset, $companyId); + } + /** * 跨月账期:当前月份核对上一月份,并给出催办窗口、终版日期和退货确认截止时间。 * @@ -1331,7 +1339,7 @@ class SupplierReconciliationPageData { return cache()->remember( "supplier-reconciliation:v2:{$companyId}:reconcilers", - now()->addMinutes(10), + now()->addHour(), function () use ($mineDataset, $returnDataset, $companyId): array { $reconcilers = array_values(array_unique(array_merge( $this->store->distinctJsonValues($mineDataset, $companyId, 'reconciler'), @@ -1349,7 +1357,7 @@ class SupplierReconciliationPageData { return cache()->remember( "supplier-reconciliation:v2:{$companyId}:months", - now()->addMinutes(10), + now()->addHour(), function () use ($mineDataset, $returnDataset, $companyId): array { $months = array_values(array_unique(array_merge( $this->store->distinctMonths($mineDataset, $companyId), diff --git a/tests/Unit/Deployment/BusinessMirrorScheduleTest.php b/tests/Unit/Deployment/BusinessMirrorScheduleTest.php index c0a2199fc..ce69fe19d 100644 --- a/tests/Unit/Deployment/BusinessMirrorScheduleTest.php +++ b/tests/Unit/Deployment/BusinessMirrorScheduleTest.php @@ -292,6 +292,19 @@ class BusinessMirrorScheduleTest extends TestCase $this->assertStringContainsString('"payables:unpriced-cycle:auto"', $registry); } + public function test_release_scripts_warm_finance_reconciliation_filters(): void + { + $expected = '*/10 * * * * root /usr/bin/docker exec -u www-data caiwu_app php artisan ' + . 'supplier-reconciliation:warm-finance-filters --company=1 --quiet >/dev/null 2>&1'; + + foreach (['activate-release.sh', 'activate-incremental-release.sh'] as $script) { + $contents = file_get_contents(dirname(__DIR__, 3) . '/deploy/' . $script); + $this->assertIsString($contents); + $this->assertStringContainsString($expected, $contents, $script); + $this->assertSame(1, substr_count($contents, 'supplier-reconciliation:warm-finance-filters'), $script); + } + } + public function test_release_scripts_fully_reconcile_supplier_payable_receipts_daily(): void { foreach (['activate-release.sh', 'activate-incremental-release.sh'] as $script) {