add 大屏-溯源产品统计接口,智能预警数据接口
This commit is contained in:
parent
e9d72f8d14
commit
73a1ec923b
|
@ -0,0 +1,58 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\controller\dataview;
|
||||||
|
|
||||||
|
use app\api\controller\BaseApiController;
|
||||||
|
use app\common\model\land\LandPlant;
|
||||||
|
use app\common\model\LandCollection;
|
||||||
|
use think\exception\ValidateException;
|
||||||
|
|
||||||
|
class LandController extends BaseApiController
|
||||||
|
{
|
||||||
|
|
||||||
|
public array $notNeedLogin = ['plantProductCount', 'landCollectionList'];
|
||||||
|
|
||||||
|
public $areaCode;
|
||||||
|
public $streetCode;
|
||||||
|
|
||||||
|
public function initialize()
|
||||||
|
{
|
||||||
|
parent::initialize();
|
||||||
|
$this->areaCode = $this->request->param('areaCode', '');
|
||||||
|
$this->streetCode = $this->request->param('streetCode', '');
|
||||||
|
if ($this->areaCode == '') {
|
||||||
|
throw new ValidateException('未获取到位置信息');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 溯源产品统计
|
||||||
|
public function plantProductCount()
|
||||||
|
{
|
||||||
|
$list = LandPlant::alias('lp')->join('land l', 'l.id=lp.land_id')->field('lp.kind,lp.qr_code')
|
||||||
|
->where(function ($query) {
|
||||||
|
if ($this->streetCode != '') {
|
||||||
|
$query->where('l.town_code', $this->streetCode);
|
||||||
|
} else {
|
||||||
|
$query->where('l.county_code', $this->areaCode);
|
||||||
|
}
|
||||||
|
})->limit(30)->select();
|
||||||
|
return $this->success('成功', compact('list'));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 智能预警数据
|
||||||
|
public function landCollectionList()
|
||||||
|
{
|
||||||
|
$list = LandCollection::alias('lc')
|
||||||
|
->field('lc.*,l.title')
|
||||||
|
->join('land l', 'l.id=lc.land_id')
|
||||||
|
->where(function ($query) {
|
||||||
|
if ($this->streetCode != '') {
|
||||||
|
$query->where('l.town_code', $this->streetCode);
|
||||||
|
} else {
|
||||||
|
$query->where('l.county_code', $this->areaCode);
|
||||||
|
}
|
||||||
|
})->limit(30)->select();
|
||||||
|
return $this->success('成功', compact('list'));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue