deviceId占用

This commit is contained in:
chenbo 2024-02-03 17:30:58 +08:00
parent 8ac6763038
commit 56180ac4f6
2 changed files with 54 additions and 24 deletions

View File

@ -211,30 +211,33 @@ const formRules = reactive<any>({
const deviceChange = async (value: string) => { const deviceChange = async (value: string) => {
const temp = await apiDeviceIccid({ const temp = await apiDeviceIccid({
deviceId: value ?? '' deviceId: value ?? ''
}).catch((err) =>{
formData.iccid = ''
formData.monitor_item = ''
}) })
formData.iccid = temp[0]['iccid'] if (temp.length != 0) {
if ( temp[0]['type'] == 0) { formData.iccid = temp[0]['iccid']
formData.monitor_item = ['temperature'] if ( temp[0]['type'] == 0) {
} formData.monitor_item = ['temperature']
if ( temp[0]['type'] == 1) { }
formData.monitor_item = ['ambient_temperature','ambient_humidity'] if (temp[0]['type'] == 1) {
} formData.monitor_item = ['ambient_temperature','ambient_humidity']
if ( temp[0]['type'] == 2) { }
formData.monitor_item = ['nitrogen'] if ( temp[0]['type'] == 2) {
} formData.monitor_item = ['nitrogen']
if ( temp[0]['type'] == 3) { }
formData.monitor_item = ['methane'] if ( temp[0]['type'] == 3) {
} formData.monitor_item = ['methane']
if ( temp[0]['type'] == 4) { }
formData.monitor_item = ['noise'] if ( temp[0]['type'] == 4) {
formData.monitor_item = ['noise']
}
if ( temp[0]['type'] == 5) {
formData.monitor_item = ['fireproof']
}
} }
if ( temp[0]['type'] == 5) {
formData.monitor_item = ['fireproof']
}
} }
// //

View File

@ -3,7 +3,9 @@
namespace app\api\controller\dataview; namespace app\api\controller\dataview;
use app\api\controller\BaseApiController; use app\api\controller\BaseApiController;
use app\common\model\animal_info\AnimalInfo;
use app\common\model\device\Device; use app\common\model\device\Device;
use app\common\model\dict\DictData;
use app\common\model\farm\Farm; use app\common\model\farm\Farm;
use app\common\model\fence_house\FenceHouse; use app\common\model\fence_house\FenceHouse;
use app\common\model\land\Land; use app\common\model\land\Land;
@ -14,7 +16,7 @@ use think\exception\ValidateException;
class FarmController extends BaseApiController class FarmController extends BaseApiController
{ {
public array $notNeedLogin = [ public array $notNeedLogin = [
'farmCount' 'farmCount','breedTypeCount'
]; ];
public function initialize() public function initialize()
{ {
@ -66,14 +68,39 @@ class FarmController extends BaseApiController
})->toArray(); })->toArray();
return $this->success('成功', compact('farmCount', 'totalScale', 'farmList')); return $this->success('成功', compact('farmCount', 'totalScale', 'farmList'));
} }
public function breedTypeCount()
{
$breedTypeRows = DictData::where('type_value', 'breed_type')->field('name,value')->select()->each(function($breedType){
$breedType['animalCount'] = Farm::alias('f')->join('fence_house fh', 'f.id=fh.farm_id')->where(function ($query) {
if ($this->streetCode != '') {
$query->where('f.street', $this->streetCode);
} else {
$query->where('f.area', $this->areaCode);
}
})->where('fh.animal_type', $breedType['value'])->count();
})->toArray();
$fenceHouseIds = Farm::alias('f')->join('fence_house fh', 'f.id=fh.farm_id')->where(function ($query) {
if ($this->streetCode != '') {
$query->where('f.street', $this->streetCode);
} else {
$query->where('f.area', $this->areaCode);
}
})->column('fh.id');
$animalList = AnimalInfo::whereIn('fence_house_id', $fenceHouseIds)->select();
return $this->success('成功', compact('breedTypeRows', 'animalList'));
}
public function centralCount() public function centralCount()
{ {
$query = Farm::alias('f')->where(function ($query) { $query = Farm::alias('f')->where(function ($query) {
if ($this->streetCode != '') { if ($this->streetCode != '') {
$query->where('f.town_code', $this->streetCode); $query->where('f.street', $this->streetCode);
} else { } else {
$query->where('f.county_code', $this->areaCode); $query->where('f.area', $this->areaCode);
} }
}); });
// 地块数量 // 地块数量