From 5f73210ce96b09548d11cd93ba4bec4bb1900214 Mon Sep 17 00:00:00 2001 From: yaooo <272523191@qq.com> Date: Fri, 24 Nov 2023 17:34:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=90=8E=E5=8F=B0=E7=AE=A1?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/src/api/air_monitor.ts | 26 ++ admin/src/api/monitor_alarm.ts | 26 ++ admin/src/api/monitor_threshold.ts | 26 ++ admin/src/api/soil_monitor.ts | 26 ++ admin/src/views/air_monitor/edit.vue | 181 +++++++++++ admin/src/views/air_monitor/index.vue | 130 ++++++++ admin/src/views/land_plant/edit.vue | 3 - admin/src/views/monitor_alarm/edit.vue | 152 ++++++++++ admin/src/views/monitor_alarm/index.vue | 144 +++++++++ admin/src/views/monitor_threshold/edit.vue | 280 ++++++++++++++++++ admin/src/views/monitor_threshold/index.vue | 98 ++++++ admin/src/views/soil_monitor/edit.vue | 173 +++++++++++ admin/src/views/soil_monitor/index.vue | 134 +++++++++ .../device/AirMonitorController.php | 108 +++++++ .../device/MonitorAlarmController.php | 108 +++++++ .../device/MonitorThresholdController.php | 108 +++++++ .../device/SoilMonitorController.php | 108 +++++++ app/adminapi/lists/device/AirMonitorLists.php | 79 +++++ .../lists/device/MonitorAlarmLists.php | 82 +++++ .../lists/device/MonitorThresholdLists.php | 77 +++++ .../lists/device/SoilMonitorLists.php | 79 +++++ app/adminapi/logic/device/AirMonitorLogic.php | 122 ++++++++ .../logic/device/MonitorAlarmLogic.php | 114 +++++++ .../logic/device/MonitorThresholdLogic.php | 144 +++++++++ .../logic/device/SoilMonitorLogic.php | 120 ++++++++ .../validate/device/AirMonitorValidate.php | 112 +++++++ .../validate/device/MonitorAlarmValidate.php | 104 +++++++ .../device/MonitorThresholdValidate.php | 134 +++++++++ .../validate/device/SoilMonitorValidate.php | 110 +++++++ app/common/model/device/AirMonitor.php | 77 +++++ app/common/model/device/MonitorAlarm.php | 75 +++++ app/common/model/device/MonitorThreshold.php | 34 +++ app/common/model/device/SoilMonitor.php | 76 +++++ 33 files changed, 3367 insertions(+), 3 deletions(-) create mode 100644 admin/src/api/air_monitor.ts create mode 100644 admin/src/api/monitor_alarm.ts create mode 100644 admin/src/api/monitor_threshold.ts create mode 100644 admin/src/api/soil_monitor.ts create mode 100644 admin/src/views/air_monitor/edit.vue create mode 100644 admin/src/views/air_monitor/index.vue create mode 100644 admin/src/views/monitor_alarm/edit.vue create mode 100644 admin/src/views/monitor_alarm/index.vue create mode 100644 admin/src/views/monitor_threshold/edit.vue create mode 100644 admin/src/views/monitor_threshold/index.vue create mode 100644 admin/src/views/soil_monitor/edit.vue create mode 100644 admin/src/views/soil_monitor/index.vue create mode 100644 app/adminapi/controller/device/AirMonitorController.php create mode 100644 app/adminapi/controller/device/MonitorAlarmController.php create mode 100644 app/adminapi/controller/device/MonitorThresholdController.php create mode 100644 app/adminapi/controller/device/SoilMonitorController.php create mode 100644 app/adminapi/lists/device/AirMonitorLists.php create mode 100644 app/adminapi/lists/device/MonitorAlarmLists.php create mode 100644 app/adminapi/lists/device/MonitorThresholdLists.php create mode 100644 app/adminapi/lists/device/SoilMonitorLists.php create mode 100644 app/adminapi/logic/device/AirMonitorLogic.php create mode 100644 app/adminapi/logic/device/MonitorAlarmLogic.php create mode 100644 app/adminapi/logic/device/MonitorThresholdLogic.php create mode 100644 app/adminapi/logic/device/SoilMonitorLogic.php create mode 100644 app/adminapi/validate/device/AirMonitorValidate.php create mode 100644 app/adminapi/validate/device/MonitorAlarmValidate.php create mode 100644 app/adminapi/validate/device/MonitorThresholdValidate.php create mode 100644 app/adminapi/validate/device/SoilMonitorValidate.php create mode 100644 app/common/model/device/AirMonitor.php create mode 100644 app/common/model/device/MonitorAlarm.php create mode 100644 app/common/model/device/MonitorThreshold.php create mode 100644 app/common/model/device/SoilMonitor.php diff --git a/admin/src/api/air_monitor.ts b/admin/src/api/air_monitor.ts new file mode 100644 index 00000000..0d95eb0a --- /dev/null +++ b/admin/src/api/air_monitor.ts @@ -0,0 +1,26 @@ +import request from '@/utils/request' + +// 空气监测列表 +export function apiAirMonitorLists(params: any) { + return request.get({ url: '/device.air_monitor/lists', params }) +} + +// 添加空气监测 +export function apiAirMonitorAdd(params: any) { + return request.post({ url: '/device.air_monitor/add', params }) +} + +// 编辑空气监测 +export function apiAirMonitorEdit(params: any) { + return request.post({ url: '/device.air_monitor/edit', params }) +} + +// 删除空气监测 +export function apiAirMonitorDelete(params: any) { + return request.post({ url: '/device.air_monitor/delete', params }) +} + +// 空气监测详情 +export function apiAirMonitorDetail(params: any) { + return request.get({ url: '/device.air_monitor/detail', params }) +} \ No newline at end of file diff --git a/admin/src/api/monitor_alarm.ts b/admin/src/api/monitor_alarm.ts new file mode 100644 index 00000000..ee06f770 --- /dev/null +++ b/admin/src/api/monitor_alarm.ts @@ -0,0 +1,26 @@ +import request from '@/utils/request' + +// 监测报警列表 +export function apiMonitorAlarmLists(params: any) { + return request.get({ url: '/device.monitor_alarm/lists', params }) +} + +// 添加监测报警 +export function apiMonitorAlarmAdd(params: any) { + return request.post({ url: '/device.monitor_alarm/add', params }) +} + +// 编辑监测报警 +export function apiMonitorAlarmEdit(params: any) { + return request.post({ url: '/device.monitor_alarm/edit', params }) +} + +// 删除监测报警 +export function apiMonitorAlarmDelete(params: any) { + return request.post({ url: '/device.monitor_alarm/delete', params }) +} + +// 监测报警详情 +export function apiMonitorAlarmDetail(params: any) { + return request.get({ url: '/device.monitor_alarm/detail', params }) +} \ No newline at end of file diff --git a/admin/src/api/monitor_threshold.ts b/admin/src/api/monitor_threshold.ts new file mode 100644 index 00000000..b4f33f10 --- /dev/null +++ b/admin/src/api/monitor_threshold.ts @@ -0,0 +1,26 @@ +import request from '@/utils/request' + +// 报警配置列表 +export function apiMonitorThresholdLists(params: any) { + return request.get({ url: '/device.monitor_threshold/lists', params }) +} + +// 添加报警配置 +export function apiMonitorThresholdAdd(params: any) { + return request.post({ url: '/device.monitor_threshold/add', params }) +} + +// 编辑报警配置 +export function apiMonitorThresholdEdit(params: any) { + return request.post({ url: '/device.monitor_threshold/edit', params }) +} + +// 删除报警配置 +export function apiMonitorThresholdDelete(params: any) { + return request.post({ url: '/device.monitor_threshold/delete', params }) +} + +// 报警配置详情 +export function apiMonitorThresholdDetail(params: any) { + return request.get({ url: '/device.monitor_threshold/detail', params }) +} \ No newline at end of file diff --git a/admin/src/api/soil_monitor.ts b/admin/src/api/soil_monitor.ts new file mode 100644 index 00000000..4a584e20 --- /dev/null +++ b/admin/src/api/soil_monitor.ts @@ -0,0 +1,26 @@ +import request from '@/utils/request' + +// 土壤监测列表 +export function apiSoilMonitorLists(params: any) { + return request.get({ url: '/device.soil_monitor/lists', params }) +} + +// 添加土壤监测 +export function apiSoilMonitorAdd(params: any) { + return request.post({ url: '/device.soil_monitor/add', params }) +} + +// 编辑土壤监测 +export function apiSoilMonitorEdit(params: any) { + return request.post({ url: '/device.soil_monitor/edit', params }) +} + +// 删除土壤监测 +export function apiSoilMonitorDelete(params: any) { + return request.post({ url: '/device.soil_monitor/delete', params }) +} + +// 土壤监测详情 +export function apiSoilMonitorDetail(params: any) { + return request.get({ url: '/device.soil_monitor/detail', params }) +} \ No newline at end of file diff --git a/admin/src/views/air_monitor/edit.vue b/admin/src/views/air_monitor/edit.vue new file mode 100644 index 00000000..eafc060d --- /dev/null +++ b/admin/src/views/air_monitor/edit.vue @@ -0,0 +1,181 @@ + + + diff --git a/admin/src/views/air_monitor/index.vue b/admin/src/views/air_monitor/index.vue new file mode 100644 index 00000000..8c305e73 --- /dev/null +++ b/admin/src/views/air_monitor/index.vue @@ -0,0 +1,130 @@ + + + + diff --git a/admin/src/views/land_plant/edit.vue b/admin/src/views/land_plant/edit.vue index 138b15f4..99c78098 100644 --- a/admin/src/views/land_plant/edit.vue +++ b/admin/src/views/land_plant/edit.vue @@ -57,9 +57,6 @@ - - - +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + diff --git a/admin/src/views/monitor_alarm/index.vue b/admin/src/views/monitor_alarm/index.vue new file mode 100644 index 00000000..2711c57f --- /dev/null +++ b/admin/src/views/monitor_alarm/index.vue @@ -0,0 +1,144 @@ + + + + diff --git a/admin/src/views/monitor_threshold/edit.vue b/admin/src/views/monitor_threshold/edit.vue new file mode 100644 index 00000000..74d81380 --- /dev/null +++ b/admin/src/views/monitor_threshold/edit.vue @@ -0,0 +1,280 @@ + + + diff --git a/admin/src/views/monitor_threshold/index.vue b/admin/src/views/monitor_threshold/index.vue new file mode 100644 index 00000000..10524b20 --- /dev/null +++ b/admin/src/views/monitor_threshold/index.vue @@ -0,0 +1,98 @@ + + + + diff --git a/admin/src/views/soil_monitor/edit.vue b/admin/src/views/soil_monitor/edit.vue new file mode 100644 index 00000000..682abdca --- /dev/null +++ b/admin/src/views/soil_monitor/edit.vue @@ -0,0 +1,173 @@ + + + diff --git a/admin/src/views/soil_monitor/index.vue b/admin/src/views/soil_monitor/index.vue new file mode 100644 index 00000000..5e8d9f92 --- /dev/null +++ b/admin/src/views/soil_monitor/index.vue @@ -0,0 +1,134 @@ + + + + diff --git a/app/adminapi/controller/device/AirMonitorController.php b/app/adminapi/controller/device/AirMonitorController.php new file mode 100644 index 00000000..46e4f7d2 --- /dev/null +++ b/app/adminapi/controller/device/AirMonitorController.php @@ -0,0 +1,108 @@ +dataLists(new AirMonitorLists()); + } + + + /** + * @notes 添加 + * @return \think\response\Json + * @author likeadmin + * @date 2023/11/24 16:49 + */ + public function add() + { + $params = (new AirMonitorValidate())->post()->goCheck('add'); + $result = AirMonitorLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(AirMonitorLogic::getError()); + } + + + /** + * @notes 编辑 + * @return \think\response\Json + * @author likeadmin + * @date 2023/11/24 16:49 + */ + public function edit() + { + $params = (new AirMonitorValidate())->post()->goCheck('edit'); + $result = AirMonitorLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(AirMonitorLogic::getError()); + } + + + /** + * @notes 删除 + * @return \think\response\Json + * @author likeadmin + * @date 2023/11/24 16:49 + */ + public function delete() + { + $params = (new AirMonitorValidate())->post()->goCheck('delete'); + AirMonitorLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取详情 + * @return \think\response\Json + * @author likeadmin + * @date 2023/11/24 16:49 + */ + public function detail() + { + $params = (new AirMonitorValidate())->goCheck('detail'); + $result = AirMonitorLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/controller/device/MonitorAlarmController.php b/app/adminapi/controller/device/MonitorAlarmController.php new file mode 100644 index 00000000..3aa94819 --- /dev/null +++ b/app/adminapi/controller/device/MonitorAlarmController.php @@ -0,0 +1,108 @@ +dataLists(new MonitorAlarmLists()); + } + + + /** + * @notes 添加 + * @return \think\response\Json + * @author likeadmin + * @date 2023/11/24 16:34 + */ + public function add() + { + $params = (new MonitorAlarmValidate())->post()->goCheck('add'); + $result = MonitorAlarmLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(MonitorAlarmLogic::getError()); + } + + + /** + * @notes 编辑 + * @return \think\response\Json + * @author likeadmin + * @date 2023/11/24 16:34 + */ + public function edit() + { + $params = (new MonitorAlarmValidate())->post()->goCheck('edit'); + $result = MonitorAlarmLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(MonitorAlarmLogic::getError()); + } + + + /** + * @notes 删除 + * @return \think\response\Json + * @author likeadmin + * @date 2023/11/24 16:34 + */ + public function delete() + { + $params = (new MonitorAlarmValidate())->post()->goCheck('delete'); + MonitorAlarmLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取详情 + * @return \think\response\Json + * @author likeadmin + * @date 2023/11/24 16:34 + */ + public function detail() + { + $params = (new MonitorAlarmValidate())->goCheck('detail'); + $result = MonitorAlarmLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/controller/device/MonitorThresholdController.php b/app/adminapi/controller/device/MonitorThresholdController.php new file mode 100644 index 00000000..a8507e00 --- /dev/null +++ b/app/adminapi/controller/device/MonitorThresholdController.php @@ -0,0 +1,108 @@ +dataLists(new MonitorThresholdLists()); + } + + + /** + * @notes 添加 + * @return \think\response\Json + * @author likeadmin + * @date 2023/11/24 16:17 + */ + public function add() + { + $params = (new MonitorThresholdValidate())->post()->goCheck('add'); + $result = MonitorThresholdLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(MonitorThresholdLogic::getError()); + } + + + /** + * @notes 编辑 + * @return \think\response\Json + * @author likeadmin + * @date 2023/11/24 16:17 + */ + public function edit() + { + $params = (new MonitorThresholdValidate())->post()->goCheck('edit'); + $result = MonitorThresholdLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(MonitorThresholdLogic::getError()); + } + + + /** + * @notes 删除 + * @return \think\response\Json + * @author likeadmin + * @date 2023/11/24 16:17 + */ + public function delete() + { + $params = (new MonitorThresholdValidate())->post()->goCheck('delete'); + MonitorThresholdLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取详情 + * @return \think\response\Json + * @author likeadmin + * @date 2023/11/24 16:17 + */ + public function detail() + { + $params = (new MonitorThresholdValidate())->goCheck('detail'); + $result = MonitorThresholdLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/controller/device/SoilMonitorController.php b/app/adminapi/controller/device/SoilMonitorController.php new file mode 100644 index 00000000..67ef5dc1 --- /dev/null +++ b/app/adminapi/controller/device/SoilMonitorController.php @@ -0,0 +1,108 @@ +dataLists(new SoilMonitorLists()); + } + + + /** + * @notes 添加 + * @return \think\response\Json + * @author likeadmin + * @date 2023/11/24 17:02 + */ + public function add() + { + $params = (new SoilMonitorValidate())->post()->goCheck('add'); + $result = SoilMonitorLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(SoilMonitorLogic::getError()); + } + + + /** + * @notes 编辑 + * @return \think\response\Json + * @author likeadmin + * @date 2023/11/24 17:02 + */ + public function edit() + { + $params = (new SoilMonitorValidate())->post()->goCheck('edit'); + $result = SoilMonitorLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(SoilMonitorLogic::getError()); + } + + + /** + * @notes 删除 + * @return \think\response\Json + * @author likeadmin + * @date 2023/11/24 17:02 + */ + public function delete() + { + $params = (new SoilMonitorValidate())->post()->goCheck('delete'); + SoilMonitorLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取详情 + * @return \think\response\Json + * @author likeadmin + * @date 2023/11/24 17:02 + */ + public function detail() + { + $params = (new SoilMonitorValidate())->goCheck('detail'); + $result = SoilMonitorLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/lists/device/AirMonitorLists.php b/app/adminapi/lists/device/AirMonitorLists.php new file mode 100644 index 00000000..1a450659 --- /dev/null +++ b/app/adminapi/lists/device/AirMonitorLists.php @@ -0,0 +1,79 @@ +params['device_id'])) { + $allowSearch[] = 'device_id'; + } + return array_intersect(array_keys($this->params), $allowSearch); + } + + + /** + * @notes 获取列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2023/11/24 16:49 + */ + public function lists(): array + { + return AirMonitor::withSearch($this->setSearch(), $this->params)->with('device') + ->field(['id', 'device_id', 'wind_direction', 'wind_speed', 'temperature', 'moisture', 'co2_content', 'pressure', 'rainfall', 'light_intensity', 'create_time']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取数量 + * @return int + * @author likeadmin + * @date 2023/11/24 16:49 + */ + public function count(): int + { + return AirMonitor::withSearch($this->setSearch(), $this->params)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/device/MonitorAlarmLists.php b/app/adminapi/lists/device/MonitorAlarmLists.php new file mode 100644 index 00000000..b5fcfd6a --- /dev/null +++ b/app/adminapi/lists/device/MonitorAlarmLists.php @@ -0,0 +1,82 @@ +params['device_id'])) { + $allowSearch[] = 'device_id'; + } + if (!empty($this->params['type'])) { + $allowSearch[] = 'type'; + } + return array_intersect(array_keys($this->params), $allowSearch); + } + + + /** + * @notes 获取列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2023/11/24 16:34 + */ + public function lists(): array + { + return MonitorAlarm::withSearch($this->setSearch(), $this->params)->with('device') + ->field(['id', 'device_id', 'type', 'content', 'value', 'solution', 'create_time']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取数量 + * @return int + * @author likeadmin + * @date 2023/11/24 16:34 + */ + public function count(): int + { + return MonitorAlarm::withSearch($this->setSearch(), $this->params)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/device/MonitorThresholdLists.php b/app/adminapi/lists/device/MonitorThresholdLists.php new file mode 100644 index 00000000..362730c9 --- /dev/null +++ b/app/adminapi/lists/device/MonitorThresholdLists.php @@ -0,0 +1,77 @@ +searchWhere) + ->field(['id', 'soil_temp_max', 'soil_temp_min', 'soil_mois_max', 'soil_mois_min', 'soil_ph_max', 'soil_ph_min', 'soil_n_content_max', 'soil_n_content_min', 'soil_p_content_max', 'soil_p_content_min', 'soil_k_content_max', 'soil_k_content_min', 'air_temp_max', 'air_temp_min', 'air_mois_max', 'air_mois_min', 'air_co2_content_max', 'air_co2_content_min', 'wind_speed_max', 'wind_speed_min']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取数量 + * @return int + * @author likeadmin + * @date 2023/11/24 16:17 + */ + public function count(): int + { + return MonitorThreshold::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/device/SoilMonitorLists.php b/app/adminapi/lists/device/SoilMonitorLists.php new file mode 100644 index 00000000..544dafa9 --- /dev/null +++ b/app/adminapi/lists/device/SoilMonitorLists.php @@ -0,0 +1,79 @@ +params['device_id'])) { + $allowSearch[] = 'device_id'; + } + return array_intersect(array_keys($this->params), $allowSearch); + } + + + /** + * @notes 获取列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2023/11/24 17:02 + */ + public function lists(): array + { + return SoilMonitor::withSearch($this->setSearch(), $this->params)->with('device') + ->field(['id', 'device_id', 'temperature', 'moisture', 'conductivity', 'ph', 'n_content', 'p_content', 'k_content', 'create_time']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取数量 + * @return int + * @author likeadmin + * @date 2023/11/24 17:02 + */ + public function count(): int + { + return SoilMonitor::withSearch($this->setSearch(), $this->params)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/device/AirMonitorLogic.php b/app/adminapi/logic/device/AirMonitorLogic.php new file mode 100644 index 00000000..33ffccc1 --- /dev/null +++ b/app/adminapi/logic/device/AirMonitorLogic.php @@ -0,0 +1,122 @@ + $params['device_id'], + 'wind_direction' => $params['wind_direction'], + 'wind_speed' => $params['wind_speed'], + 'temperature' => $params['temperature'], + 'moisture' => $params['moisture'], + 'co2_content' => $params['co2_content'], + 'pressure' => $params['pressure'], + 'rainfall' => $params['rainfall'], + 'light_intensity' => $params['light_intensity'], + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑 + * @param array $params + * @return bool + * @author likeadmin + * @date 2023/11/24 16:49 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + AirMonitor::where('id', $params['id'])->update([ + 'device_id' => $params['device_id'], + 'wind_direction' => $params['wind_direction'], + 'wind_speed' => $params['wind_speed'], + 'temperature' => $params['temperature'], + 'moisture' => $params['moisture'], + 'co2_content' => $params['co2_content'], + 'pressure' => $params['pressure'], + 'rainfall' => $params['rainfall'], + 'light_intensity' => $params['light_intensity'], + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除 + * @param array $params + * @return bool + * @author likeadmin + * @date 2023/11/24 16:49 + */ + public static function delete(array $params): bool + { + return AirMonitor::destroy($params['id']); + } + + + /** + * @notes 获取详情 + * @param $params + * @return array + * @author likeadmin + * @date 2023/11/24 16:49 + */ + public static function detail($params): array + { + return AirMonitor::findOrEmpty($params['id'])->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/logic/device/MonitorAlarmLogic.php b/app/adminapi/logic/device/MonitorAlarmLogic.php new file mode 100644 index 00000000..ece5379c --- /dev/null +++ b/app/adminapi/logic/device/MonitorAlarmLogic.php @@ -0,0 +1,114 @@ + $params['device_id'], + 'type' => $params['type'], + 'content' => $params['content'], + 'value' => $params['value'], + 'solution' => $params['solution'], + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑 + * @param array $params + * @return bool + * @author likeadmin + * @date 2023/11/24 16:34 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + MonitorAlarm::where('id', $params['id'])->update([ + 'device_id' => $params['device_id'], + 'type' => $params['type'], + 'content' => $params['content'], + 'value' => $params['value'], + 'solution' => $params['solution'], + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除 + * @param array $params + * @return bool + * @author likeadmin + * @date 2023/11/24 16:34 + */ + public static function delete(array $params): bool + { + return MonitorAlarm::destroy($params['id']); + } + + + /** + * @notes 获取详情 + * @param $params + * @return array + * @author likeadmin + * @date 2023/11/24 16:34 + */ + public static function detail($params): array + { + return MonitorAlarm::findOrEmpty($params['id'])->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/logic/device/MonitorThresholdLogic.php b/app/adminapi/logic/device/MonitorThresholdLogic.php new file mode 100644 index 00000000..3d1cfa0c --- /dev/null +++ b/app/adminapi/logic/device/MonitorThresholdLogic.php @@ -0,0 +1,144 @@ + $params['soil_temp_max'], + 'soil_temp_min' => $params['soil_temp_min'], + 'soil_mois_max' => $params['soil_mois_max'], + 'soil_mois_min' => $params['soil_mois_min'], + 'soil_ph_max' => $params['soil_ph_max'], + 'soil_ph_min' => $params['soil_ph_min'], + 'soil_n_content_max' => $params['soil_n_content_max'], + 'soil_n_content_min' => $params['soil_n_content_min'], + 'soil_p_content_max' => $params['soil_p_content_max'], + 'soil_p_content_min' => $params['soil_p_content_min'], + 'soil_k_content_max' => $params['soil_k_content_max'], + 'soil_k_content_min' => $params['soil_k_content_min'], + 'air_temp_max' => $params['air_temp_max'], + 'air_temp_min' => $params['air_temp_min'], + 'air_mois_max' => $params['air_mois_max'], + 'air_mois_min' => $params['air_mois_min'], + 'air_co2_content_max' => $params['air_co2_content_max'], + 'air_co2_content_min' => $params['air_co2_content_min'], + 'wind_speed_max' => $params['wind_speed_max'], + 'wind_speed_min' => $params['wind_speed_min'], + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑 + * @param array $params + * @return bool + * @author likeadmin + * @date 2023/11/24 16:17 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + MonitorThreshold::where('id', $params['id'])->update([ + 'soil_temp_max' => $params['soil_temp_max'], + 'soil_temp_min' => $params['soil_temp_min'], + 'soil_mois_max' => $params['soil_mois_max'], + 'soil_mois_min' => $params['soil_mois_min'], + 'soil_ph_max' => $params['soil_ph_max'], + 'soil_ph_min' => $params['soil_ph_min'], + 'soil_n_content_max' => $params['soil_n_content_max'], + 'soil_n_content_min' => $params['soil_n_content_min'], + 'soil_p_content_max' => $params['soil_p_content_max'], + 'soil_p_content_min' => $params['soil_p_content_min'], + 'soil_k_content_max' => $params['soil_k_content_max'], + 'soil_k_content_min' => $params['soil_k_content_min'], + 'air_temp_max' => $params['air_temp_max'], + 'air_temp_min' => $params['air_temp_min'], + 'air_mois_max' => $params['air_mois_max'], + 'air_mois_min' => $params['air_mois_min'], + 'air_co2_content_max' => $params['air_co2_content_max'], + 'air_co2_content_min' => $params['air_co2_content_min'], + 'wind_speed_max' => $params['wind_speed_max'], + 'wind_speed_min' => $params['wind_speed_min'], + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除 + * @param array $params + * @return bool + * @author likeadmin + * @date 2023/11/24 16:17 + */ + public static function delete(array $params): bool + { + return MonitorThreshold::destroy($params['id']); + } + + + /** + * @notes 获取详情 + * @param $params + * @return array + * @author likeadmin + * @date 2023/11/24 16:17 + */ + public static function detail($params): array + { + return MonitorThreshold::findOrEmpty($params['id'])->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/logic/device/SoilMonitorLogic.php b/app/adminapi/logic/device/SoilMonitorLogic.php new file mode 100644 index 00000000..390cedc9 --- /dev/null +++ b/app/adminapi/logic/device/SoilMonitorLogic.php @@ -0,0 +1,120 @@ + $params['device_id'], + 'temperature' => $params['temperature'], + 'moisture' => $params['moisture'], + 'conductivity' => $params['conductivity'], + 'ph' => $params['ph'], + 'n_content' => $params['n_content'], + 'p_content' => $params['p_content'], + 'k_content' => $params['k_content'], + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑 + * @param array $params + * @return bool + * @author likeadmin + * @date 2023/11/24 17:02 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + SoilMonitor::where('id', $params['id'])->update([ + 'device_id' => $params['device_id'], + 'temperature' => $params['temperature'], + 'moisture' => $params['moisture'], + 'conductivity' => $params['conductivity'], + 'ph' => $params['ph'], + 'n_content' => $params['n_content'], + 'p_content' => $params['p_content'], + 'k_content' => $params['k_content'], + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除 + * @param array $params + * @return bool + * @author likeadmin + * @date 2023/11/24 17:02 + */ + public static function delete(array $params): bool + { + return SoilMonitor::destroy($params['id']); + } + + + /** + * @notes 获取详情 + * @param $params + * @return array + * @author likeadmin + * @date 2023/11/24 17:02 + */ + public static function detail($params): array + { + return SoilMonitor::findOrEmpty($params['id'])->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/validate/device/AirMonitorValidate.php b/app/adminapi/validate/device/AirMonitorValidate.php new file mode 100644 index 00000000..8dd32468 --- /dev/null +++ b/app/adminapi/validate/device/AirMonitorValidate.php @@ -0,0 +1,112 @@ + 'require', + 'device_id' => 'require', + 'wind_direction' => 'require', + 'wind_speed' => 'require', + 'temperature' => 'require', + 'moisture' => 'require', + 'co2_content' => 'require', + 'pressure' => 'require', + 'rainfall' => 'require', + 'light_intensity' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'device_id' => '设备ID', + 'wind_direction' => '风向', + 'wind_speed' => '风速', + 'temperature' => '空气温度', + 'moisture' => '空气湿度', + 'co2_content' => '二氧化碳含量', + 'pressure' => '大气压强', + 'rainfall' => '降雨量', + 'light_intensity' => '光照强度', + ]; + + + /** + * @notes 添加场景 + * @return AirMonitorValidate + * @author likeadmin + * @date 2023/11/24 16:49 + */ + public function sceneAdd() + { + return $this->only(['device_id','wind_direction','wind_speed','temperature','moisture','co2_content','pressure','rainfall','light_intensity']); + } + + + /** + * @notes 编辑场景 + * @return AirMonitorValidate + * @author likeadmin + * @date 2023/11/24 16:49 + */ + public function sceneEdit() + { + return $this->only(['id','device_id','wind_direction','wind_speed','temperature','moisture','co2_content','pressure','rainfall','light_intensity']); + } + + + /** + * @notes 删除场景 + * @return AirMonitorValidate + * @author likeadmin + * @date 2023/11/24 16:49 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return AirMonitorValidate + * @author likeadmin + * @date 2023/11/24 16:49 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/device/MonitorAlarmValidate.php b/app/adminapi/validate/device/MonitorAlarmValidate.php new file mode 100644 index 00000000..bc96e90e --- /dev/null +++ b/app/adminapi/validate/device/MonitorAlarmValidate.php @@ -0,0 +1,104 @@ + 'require', + 'device_id' => 'require', + 'type' => 'require', + 'content' => 'require', + 'value' => 'require', + 'solution' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'device_id' => '设备ID', + 'type' => '监测类型', + 'content' => '报警内容', + 'value' => '报警数值', + 'solution' => '解决方案', + ]; + + + /** + * @notes 添加场景 + * @return MonitorAlarmValidate + * @author likeadmin + * @date 2023/11/24 16:34 + */ + public function sceneAdd() + { + return $this->only(['device_id','type','content','value','solution']); + } + + + /** + * @notes 编辑场景 + * @return MonitorAlarmValidate + * @author likeadmin + * @date 2023/11/24 16:34 + */ + public function sceneEdit() + { + return $this->only(['id','device_id','type','content','value','solution']); + } + + + /** + * @notes 删除场景 + * @return MonitorAlarmValidate + * @author likeadmin + * @date 2023/11/24 16:34 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return MonitorAlarmValidate + * @author likeadmin + * @date 2023/11/24 16:34 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/device/MonitorThresholdValidate.php b/app/adminapi/validate/device/MonitorThresholdValidate.php new file mode 100644 index 00000000..830e3fcf --- /dev/null +++ b/app/adminapi/validate/device/MonitorThresholdValidate.php @@ -0,0 +1,134 @@ + 'require', + 'soil_temp_max' => 'require', + 'soil_temp_min' => 'require', + 'soil_mois_max' => 'require', + 'soil_mois_min' => 'require', + 'soil_ph_max' => 'require', + 'soil_ph_min' => 'require', + 'soil_n_content_max' => 'require', + 'soil_n_content_min' => 'require', + 'soil_p_content_max' => 'require', + 'soil_p_content_min' => 'require', + 'soil_k_content_max' => 'require', + 'soil_k_content_min' => 'require', + 'air_temp_max' => 'require', + 'air_temp_min' => 'require', + 'air_mois_max' => 'require', + 'air_mois_min' => 'require', + 'air_co2_content_max' => 'require', + 'air_co2_content_min' => 'require', + 'wind_speed_max' => 'require', + 'wind_speed_min' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'soil_temp_max' => '土壤最高温度', + 'soil_temp_min' => '土壤最低温度', + 'soil_mois_max' => '土壤最高湿度', + 'soil_mois_min' => '土壤最低湿度', + 'soil_ph_max' => '土壤最高PH值', + 'soil_ph_min' => '土壤最低PH值', + 'soil_n_content_max' => '土壤最高氮含量', + 'soil_n_content_min' => '土壤最低氮含量', + 'soil_p_content_max' => '土壤最高磷含量', + 'soil_p_content_min' => '土壤最低磷含量', + 'soil_k_content_max' => '土壤最高钾含量', + 'soil_k_content_min' => '土壤最低钾含量', + 'air_temp_max' => '空气最高温度', + 'air_temp_min' => '空气最低温度', + 'air_mois_max' => '空气最高湿度', + 'air_mois_min' => '空气最低湿度', + 'air_co2_content_max' => '空气最大二氧化碳含量', + 'air_co2_content_min' => '空气最小二氧化碳含量', + 'wind_speed_max' => '最大风速', + 'wind_speed_min' => '最小风速', + ]; + + + /** + * @notes 添加场景 + * @return MonitorThresholdValidate + * @author likeadmin + * @date 2023/11/24 16:17 + */ + public function sceneAdd() + { + return $this->only(['soil_temp_max','soil_temp_min','soil_mois_max','soil_mois_min','soil_ph_max','soil_ph_min','soil_n_content_max','soil_n_content_min','soil_p_content_max','soil_p_content_min','soil_k_content_max','soil_k_content_min','air_temp_max','air_temp_min','air_mois_max','air_mois_min','air_co2_content_max','air_co2_content_min','wind_speed_max','wind_speed_min']); + } + + + /** + * @notes 编辑场景 + * @return MonitorThresholdValidate + * @author likeadmin + * @date 2023/11/24 16:17 + */ + public function sceneEdit() + { + return $this->only(['id','soil_temp_max','soil_temp_min','soil_mois_max','soil_mois_min','soil_ph_max','soil_ph_min','soil_n_content_max','soil_n_content_min','soil_p_content_max','soil_p_content_min','soil_k_content_max','soil_k_content_min','air_temp_max','air_temp_min','air_mois_max','air_mois_min','air_co2_content_max','air_co2_content_min','wind_speed_max','wind_speed_min']); + } + + + /** + * @notes 删除场景 + * @return MonitorThresholdValidate + * @author likeadmin + * @date 2023/11/24 16:17 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return MonitorThresholdValidate + * @author likeadmin + * @date 2023/11/24 16:17 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/device/SoilMonitorValidate.php b/app/adminapi/validate/device/SoilMonitorValidate.php new file mode 100644 index 00000000..58b3e4ae --- /dev/null +++ b/app/adminapi/validate/device/SoilMonitorValidate.php @@ -0,0 +1,110 @@ + 'require', + 'device_id' => 'require', + 'temperature' => 'require', + 'moisture' => 'require', + 'conductivity' => 'require', + 'ph' => 'require', + 'n_content' => 'require', + 'p_content' => 'require', + 'k_content' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'device_id' => '设备ID', + 'temperature' => '土壤温度', + 'moisture' => '土壤湿度', + 'conductivity' => '电导率', + 'ph' => '土壤酸碱度', + 'n_content' => '氮含量', + 'p_content' => '磷含量', + 'k_content' => '钾含量', + ]; + + + /** + * @notes 添加场景 + * @return SoilMonitorValidate + * @author likeadmin + * @date 2023/11/24 17:02 + */ + public function sceneAdd() + { + return $this->only(['device_id','temperature','moisture','conductivity','ph','n_content','p_content','k_content']); + } + + + /** + * @notes 编辑场景 + * @return SoilMonitorValidate + * @author likeadmin + * @date 2023/11/24 17:02 + */ + public function sceneEdit() + { + return $this->only(['id','device_id','temperature','moisture','conductivity','ph','n_content','p_content','k_content']); + } + + + /** + * @notes 删除场景 + * @return SoilMonitorValidate + * @author likeadmin + * @date 2023/11/24 17:02 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return SoilMonitorValidate + * @author likeadmin + * @date 2023/11/24 17:02 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/common/model/device/AirMonitor.php b/app/common/model/device/AirMonitor.php new file mode 100644 index 00000000..af546476 --- /dev/null +++ b/app/common/model/device/AirMonitor.php @@ -0,0 +1,77 @@ +hasOne(\app\common\model\device\Device::class, 'id', 'device_id'); + } + + /** + * @notes 搜索器-注册时间 + * @param $query + * @param $value + * @param $data + * @author 段誉 + * @date 2022/9/22 16:13 + */ + public function searchStartTimeAttr($query, $value, $data) + { + if ($value) { + $query->where('create_time', '>=', strtotime($value)); + } + } + + /** + * @notes 搜索器-注册时间 + * @param $query + * @param $value + * @param $data + * @author 段誉 + * @date 2022/9/22 16:13 + */ + public function searchEndTimeAttr($query, $value, $data) + { + if ($value) { + $query->where('create_time', '<=', strtotime($value)); + } + } + + + +} \ No newline at end of file diff --git a/app/common/model/device/MonitorAlarm.php b/app/common/model/device/MonitorAlarm.php new file mode 100644 index 00000000..37f41e27 --- /dev/null +++ b/app/common/model/device/MonitorAlarm.php @@ -0,0 +1,75 @@ +hasOne(\app\common\model\device\Device::class, 'id', 'device_id'); + } + + /** + * @notes 搜索器-注册时间 + * @param $query + * @param $value + * @param $data + * @author 段誉 + * @date 2022/9/22 16:13 + */ + public function searchStartTimeAttr($query, $value, $data) + { + if ($value) { + $query->where('create_time', '>=', strtotime($value)); + } + } + + /** + * @notes 搜索器-注册时间 + * @param $query + * @param $value + * @param $data + * @author 段誉 + * @date 2022/9/22 16:13 + */ + public function searchEndTimeAttr($query, $value, $data) + { + if ($value) { + $query->where('create_time', '<=', strtotime($value)); + } + } + +} \ No newline at end of file diff --git a/app/common/model/device/MonitorThreshold.php b/app/common/model/device/MonitorThreshold.php new file mode 100644 index 00000000..4b49e822 --- /dev/null +++ b/app/common/model/device/MonitorThreshold.php @@ -0,0 +1,34 @@ +hasOne(\app\common\model\device\Device::class, 'id', 'device_id'); + } + + /** + * @notes 搜索器-注册时间 + * @param $query + * @param $value + * @param $data + * @author 段誉 + * @date 2022/9/22 16:13 + */ + public function searchStartTimeAttr($query, $value, $data) + { + if ($value) { + $query->where('create_time', '>=', strtotime($value)); + } + } + + /** + * @notes 搜索器-注册时间 + * @param $query + * @param $value + * @param $data + * @author 段誉 + * @date 2022/9/22 16:13 + */ + public function searchEndTimeAttr($query, $value, $data) + { + if ($value) { + $query->where('create_time', '<=', strtotime($value)); + } + } + + +} \ No newline at end of file