diff --git a/app/api/controller/dataview/LandController.php b/app/api/controller/dataview/LandController.php index a18b9b30..fcbdf532 100644 --- a/app/api/controller/dataview/LandController.php +++ b/app/api/controller/dataview/LandController.php @@ -6,6 +6,7 @@ use app\api\controller\BaseApiController; use app\common\model\device\MonitorAlarm; use app\common\model\land\Land; use app\common\model\land\LandPlant; +use app\common\model\land\Product; use app\common\model\LandCollection; use think\facade\Db; use think\exception\ValidateException; @@ -13,7 +14,7 @@ use think\exception\ValidateException; class LandController extends BaseApiController { - public array $notNeedLogin = ['plantProductCount', 'landCollectionList', 'landMonitorAlarmHistory', 'landList', 'centralCount']; + public array $notNeedLogin = ['plantProductCount', 'landCollectionList', 'landMonitorAlarmHistory', 'productList', 'landList', 'centralCount']; public $areaCode; public $streetCode; @@ -150,6 +151,21 @@ class LandController extends BaseApiController return $this->success('成功', compact('list')); } + public function productList() + { + $list = Product::alias('p')->field('p.*') + ->join('land_product lp', 'p.id=lp.product_id') + ->join('land l', 'lp.land_id=l.id') + ->where(function ($query) { + if ($this->streetCode != '') { + $query->where('l.town_code', $this->streetCode); + } else { + $query->where('l.county_code', $this->areaCode); + } + })->select(); + return $this->success('成功', compact('list')); + } + public function centralCount() {