parent
c04809fc76
commit
5e1573731a
|
@ -32,20 +32,26 @@ class DeviceController extends BaseApiController
|
|||
// 设备告警统计
|
||||
public function deviceAlarmCount()
|
||||
{
|
||||
$landId = $this->request->get('land_id', 0);
|
||||
$list = MonitorAlarm::alias('ma')->field('ma.*,d.code AS device_code,d.name AS device_name')
|
||||
->join('device d', 'ma.device_id=d.id')
|
||||
->join('product_device pd', 'd.id=pd.device_id')
|
||||
->join('land_product lp', 'pd.product_id=lp.product_id')
|
||||
->join('land l', 'l.id=lp.land_id')
|
||||
->where(function ($query) {
|
||||
->where(function ($query) use ($landId) {
|
||||
if ($landId != 0) {
|
||||
$query->where('ma.land_id', $landId);
|
||||
} else {
|
||||
if ($this->streetCode != '') {
|
||||
$query->where('l.town_code', $this->streetCode);
|
||||
} else {
|
||||
$query->where('l.county_code', $this->areaCode);
|
||||
}
|
||||
}
|
||||
})
|
||||
->whereWeek('ma.create_time')
|
||||
->limit(30)
|
||||
->fetchSql()
|
||||
->select();
|
||||
return $this->success('成功', compact('list'));
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ use think\exception\ValidateException;
|
|||
class LandController extends BaseApiController
|
||||
{
|
||||
|
||||
public array $notNeedLogin = ['plantProductCount', 'landCollectionList', 'landMonitorAlarmHistory', 'productList', 'landList', 'centralCount'];
|
||||
public array $notNeedLogin = ['plantProductCount', 'landCollectionList', 'landMonitorAlarmHistory', 'productList', 'landList', 'centralCount', 'areaPlantTypeCount'];
|
||||
|
||||
public $areaCode;
|
||||
public $streetCode;
|
||||
|
@ -185,4 +185,16 @@ class LandController extends BaseApiController
|
|||
|
||||
return $this->success('成功', compact('landCount', 'totalArea', 'plantCount'));
|
||||
}
|
||||
|
||||
// 第二页 种植面积/种类
|
||||
public function areaPlantTypeCount()
|
||||
{
|
||||
$landId = $this->request->get('land_id');
|
||||
$query = Land::alias('l')->where('l.id', $landId);
|
||||
// 种植面积
|
||||
$totalArea = $query->value('total_area');
|
||||
// 种植种类
|
||||
$plantKindList = $query->field('lp.land_id,lp.kind')->join('land_plant lp', 'l.id = lp.land_id')->group('lp.kind')->select();
|
||||
return $this->success('成功', compact('totalArea', 'plantKindList'));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue