From fb7866a54f5675a71a925f2c3abe94ab8c39a5ad Mon Sep 17 00:00:00 2001 From: vine_liutk <961510893@qq.com> Date: Wed, 22 Mar 2023 21:16:36 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/CropYieldController.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/Http/Controllers/CropYieldController.php b/app/Http/Controllers/CropYieldController.php index 0ea1016..8a7202b 100644 --- a/app/Http/Controllers/CropYieldController.php +++ b/app/Http/Controllers/CropYieldController.php @@ -15,6 +15,7 @@ use Illuminate\Support\Facades\DB; use Peidikeji\Keywords\Models\Keywords; use App\Services\OperationLogService; use App\Enums\OperationType; +use App\Enums\BaseType; class CropYieldController extends Controller { @@ -197,6 +198,9 @@ class CropYieldController extends Controller if ($baseId) { $q->where('base_id', $baseId); + }else{ + $baseIds = AgriculturalBase::where('type', BaseType::Town)->pluck('id')->toArray(); + $q->whereIn('base_id', $baseIds); } $q1 = clone $q; $sumSql = 'quarter, sum(yield) as yield_total, sum(cultivated) as cultivated_total, sum(output) as output_total '; @@ -228,6 +232,9 @@ class CropYieldController extends Controller $q->where('time_year', $year); if ($baseId) { $q->where('base_id', $baseId); + }else{ + $baseIds = AgriculturalBase::where('type', BaseType::Town)->pluck('id')->toArray(); + $q->whereIn('base_id', $baseIds); } $q->groupBy('category_id'); $totalData = $q->select(DB::raw('category_id, sum(output) as output_total ')) @@ -297,6 +304,9 @@ class CropYieldController extends Controller $q = CropYield::query(); if ($baseId) { $q->where('base_id', $baseId); + }else{ + $baseIds = AgriculturalBase::where('type', BaseType::Town)->pluck('id')->toArray(); + $q->whereIn('base_id', $baseIds); } $q->where('time_year', '>=', $nowYear - 3);