更新后台管理

This commit is contained in:
yaooo 2023-11-24 17:34:27 +08:00
parent 2a90a490be
commit 5f73210ce9
33 changed files with 3367 additions and 3 deletions

View File

@ -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 })
}

View File

@ -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 })
}

View File

@ -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 })
}

View File

@ -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 })
}

View File

@ -0,0 +1,181 @@
<template>
<div class="edit-popup">
<popup
ref="popupRef"
:title="popupTitle"
:async="true"
width="550px"
@confirm="handleSubmit"
@close="handleClose"
>
<el-form ref="formRef" :model="formData" label-width="120px" :rules="formRules">
<el-form-item label="设备ID" prop="device_id">
<el-input v-model="formData.device_id" disabled clearable placeholder="请输入设备ID" />
</el-form-item>
<el-form-item label="风向" prop="wind_direction">
<el-input v-model="formData.wind_direction" disabled clearable placeholder="请输入风向" />
</el-form-item>
<el-form-item label="风速" prop="wind_speed">
<el-input v-model="formData.wind_speed" disabled clearable placeholder="请输入风速" />
</el-form-item>
<el-form-item label="空气温度" prop="temperature">
<el-input v-model="formData.temperature" disabled clearable placeholder="请输入空气温度" />
</el-form-item>
<el-form-item label="空气湿度" prop="moisture">
<el-input v-model="formData.moisture" disabled clearable placeholder="请输入空气湿度" />
</el-form-item>
<el-form-item label="二氧化碳含量" prop="co2_content">
<el-input v-model="formData.co2_content" disabled clearable placeholder="请输入二氧化碳含量" />
</el-form-item>
<el-form-item label="大气压强" prop="pressure">
<el-input v-model="formData.pressure" disabled clearable placeholder="请输入大气压强" />
</el-form-item>
<el-form-item label="降雨量" prop="rainfall">
<el-input v-model="formData.rainfall" disabled clearable placeholder="请输入降雨量" />
</el-form-item>
<el-form-item label="光照强度" prop="light_intensity">
<el-input v-model="formData.light_intensity" disabled clearable placeholder="请输入光照强度" />
</el-form-item>
</el-form>
</popup>
</div>
</template>
<script lang="ts" setup name="airMonitorEdit">
import type { FormInstance } from 'element-plus'
import Popup from '@/components/popup/index.vue'
import { apiAirMonitorAdd, apiAirMonitorEdit, apiAirMonitorDetail } from '@/api/air_monitor'
import { timeFormat } from '@/utils/util'
import type { PropType } from 'vue'
defineProps({
dictData: {
type: Object as PropType<Record<string, any[]>>,
default: () => ({})
}
})
const emit = defineEmits(['success', 'close'])
const formRef = shallowRef<FormInstance>()
const popupRef = shallowRef<InstanceType<typeof Popup>>()
const mode = ref('add')
//
const popupTitle = computed(() => {
return mode.value == 'edit' ? '空气监测数据' : '新增空气监测'
})
//
const formData = reactive({
id: '',
device_id: '',
wind_direction: '',
wind_speed: '',
temperature: '',
moisture: '',
co2_content: '',
pressure: '',
rainfall: '',
light_intensity: '',
})
//
const formRules = reactive<any>({
device_id: [{
required: true,
message: '请输入设备ID',
trigger: ['blur']
}],
wind_direction: [{
required: true,
message: '请输入风向',
trigger: ['blur']
}],
wind_speed: [{
required: true,
message: '请输入风速',
trigger: ['blur']
}],
temperature: [{
required: true,
message: '请输入空气温度',
trigger: ['blur']
}],
moisture: [{
required: true,
message: '请输入空气湿度',
trigger: ['blur']
}],
co2_content: [{
required: true,
message: '请输入二氧化碳含量',
trigger: ['blur']
}],
pressure: [{
required: true,
message: '请输入大气压强',
trigger: ['blur']
}],
rainfall: [{
required: true,
message: '请输入降雨量',
trigger: ['blur']
}],
light_intensity: [{
required: true,
message: '请输入光照强度',
trigger: ['blur']
}],
})
//
const setFormData = async (data: Record<any, any>) => {
for (const key in formData) {
if (data[key] != null && data[key] != undefined) {
//@ts-ignore
formData[key] = data[key]
}
}
}
const getDetail = async (row: Record<string, any>) => {
const data = await apiAirMonitorDetail({
id: row.id
})
setFormData(data)
}
//
const handleSubmit = async () => {
await formRef.value?.validate()
const data = { ...formData, }
mode.value == 'edit'
? await apiAirMonitorEdit(data)
: await apiAirMonitorAdd(data)
popupRef.value?.close()
emit('success')
}
//
const open = (type = 'add') => {
mode.value = type
popupRef.value?.open()
}
//
const handleClose = () => {
emit('close')
}
defineExpose({
open,
setFormData,
getDetail
})
</script>

View File

@ -0,0 +1,130 @@
<template>
<div>
<el-card class="!border-none mb-4" shadow="never">
<el-form
class="mb-[-16px]"
:model="queryParams"
inline
>
<el-form-item label="设备ID" prop="device_id">
<el-input class="w-[280px]" v-model="queryParams.device_id" clearable placeholder="请输入设备ID" />
</el-form-item>
<el-form-item label="创建时间" prop="create_time">
<daterange-picker
v-model:startTime="queryParams.start_time"
v-model:endTime="queryParams.end_time"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="resetPage">查询</el-button>
<el-button @click="resetParams">重置</el-button>
</el-form-item>
</el-form>
</el-card>
<el-card class="!border-none" v-loading="pager.loading" shadow="never">
<div class="mt-4">
<el-table :data="pager.lists" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" />
<el-table-column label="ID" prop="id" show-overflow-tooltip />
<el-table-column label="设备ID" prop="device_id" show-overflow-tooltip />
<el-table-column label="设备名称" prop="device.name" show-overflow-tooltip />
<el-table-column label="风向" prop="wind_direction" show-overflow-tooltip />
<el-table-column label="风速" prop="wind_speed" show-overflow-tooltip />
<el-table-column label="空气温度" prop="temperature" show-overflow-tooltip />
<el-table-column label="空气湿度" prop="moisture" show-overflow-tooltip />
<el-table-column label="二氧化碳含量" prop="co2_content" show-overflow-tooltip />
<el-table-column label="大气压强" prop="pressure" show-overflow-tooltip />
<el-table-column label="降雨量" prop="rainfall" show-overflow-tooltip />
<el-table-column label="光照强度" prop="light_intensity" show-overflow-tooltip />
<el-table-column label="创建时间" prop="create_time" show-overflow-tooltip />
<el-table-column label="操作" width="120" fixed="right">
<template #default="{ row }">
<el-button
v-perms="['device.air_monitor/edit']"
type="primary"
link
@click="handleEdit(row)"
>
编辑
</el-button>
<el-button
v-perms="['device.air_monitor/delete']"
type="danger"
link
@click="handleDelete(row.id)"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
</div>
<div class="flex mt-4 justify-end">
<pagination v-model="pager" @change="getLists" />
</div>
</el-card>
<edit-popup v-if="showEdit" ref="editRef" :dict-data="dictData" @success="getLists" @close="showEdit = false" />
</div>
</template>
<script lang="ts" setup name="airMonitorLists">
import { usePaging } from '@/hooks/usePaging'
import { useDictData } from '@/hooks/useDictOptions'
import { apiAirMonitorLists, apiAirMonitorDelete } from '@/api/air_monitor'
import { timeFormat } from '@/utils/util'
import feedback from '@/utils/feedback'
import EditPopup from './edit.vue'
const editRef = shallowRef<InstanceType<typeof EditPopup>>()
//
const showEdit = ref(false)
//
const queryParams = reactive({
device_id: '',
create_time: '',
})
//
const selectData = ref<any[]>([])
//
const handleSelectionChange = (val: any[]) => {
selectData.value = val.map(({ id }) => id)
}
//
const { dictData } = useDictData('')
//
const { pager, getLists, resetParams, resetPage } = usePaging({
fetchFun: apiAirMonitorLists,
params: queryParams
})
//
const handleAdd = async () => {
showEdit.value = true
await nextTick()
editRef.value?.open('add')
}
//
const handleEdit = async (data: any) => {
showEdit.value = true
await nextTick()
editRef.value?.open('edit')
editRef.value?.setFormData(data)
}
//
const handleDelete = async (id: number | any[]) => {
await feedback.confirm('确定要删除?')
await apiAirMonitorDelete({ id })
getLists()
}
getLists()
</script>

View File

@ -57,9 +57,6 @@
</el-form-item>
<el-form-item label="种植图片" prop="pic">
<material-picker v-model="formData.pic" />
</el-form-item>
<el-form-item label="溯源二维码" prop="qr_code">
<material-picker v-model="formData.qr_code" />
</el-form-item>
<el-form-item label="播种时间" prop="plant_date">
<el-date-picker

View File

@ -0,0 +1,152 @@
<template>
<div class="edit-popup">
<popup
ref="popupRef"
:title="popupTitle"
:async="true"
width="550px"
@confirm="handleSubmit"
@close="handleClose"
>
<el-form ref="formRef" :model="formData" label-width="90px" :rules="formRules">
<el-form-item label="设备ID" prop="device_id">
<el-input v-model="formData.device_id" clearable disabled placeholder="请输入设备ID" />
</el-form-item>
<el-form-item label="监测类型" prop="type">
<el-select class="flex-1" v-model="formData.type" disabled clearable placeholder="请选择监测类型">
<el-option
v-for="(item, index) in dictData.alarm_type"
:key="index"
:label="item.name"
:value="parseInt(item.value)"
/>
</el-select>
</el-form-item>
<el-form-item label="报警内容" prop="content">
<el-input class="flex-1" v-model="formData.content" type="textarea" rows="4" disabled clearable placeholder="请输入报警内容" />
</el-form-item>
<el-form-item label="报警数值" prop="value">
<el-input v-model="formData.value" disabled clearable placeholder="请输入报警数值" />
</el-form-item>
<el-form-item label="解决方案" prop="solution">
<el-input class="flex-1" v-model="formData.solution" type="textarea" rows="4" clearable placeholder="请输入解决方案" />
</el-form-item>
</el-form>
</popup>
</div>
</template>
<script lang="ts" setup name="monitorAlarmEdit">
import type { FormInstance } from 'element-plus'
import Popup from '@/components/popup/index.vue'
import { apiMonitorAlarmAdd, apiMonitorAlarmEdit, apiMonitorAlarmDetail } from '@/api/monitor_alarm'
import { timeFormat } from '@/utils/util'
import type { PropType } from 'vue'
defineProps({
dictData: {
type: Object as PropType<Record<string, any[]>>,
default: () => ({})
}
})
const emit = defineEmits(['success', 'close'])
const formRef = shallowRef<FormInstance>()
const popupRef = shallowRef<InstanceType<typeof Popup>>()
const mode = ref('add')
//
const popupTitle = computed(() => {
return mode.value == 'edit' ? '监测报警数据' : '新增监测报警'
})
//
const formData = reactive({
id: '',
device_id: '',
type: '',
content: '',
value: '',
solution: '',
})
//
const formRules = reactive<any>({
device_id: [{
required: true,
message: '请输入设备ID',
trigger: ['blur']
}],
type: [{
required: true,
message: '请选择监测类型',
trigger: ['blur']
}],
content: [{
required: true,
message: '请输入报警内容',
trigger: ['blur']
}],
value: [{
required: true,
message: '请输入报警数值',
trigger: ['blur']
}],
solution: [{
required: true,
message: '请输入解决方案',
trigger: ['blur']
}],
})
//
const setFormData = async (data: Record<any, any>) => {
for (const key in formData) {
if (data[key] != null && data[key] != undefined) {
//@ts-ignore
formData[key] = data[key]
}
}
}
const getDetail = async (row: Record<string, any>) => {
const data = await apiMonitorAlarmDetail({
id: row.id
})
setFormData(data)
}
//
const handleSubmit = async () => {
await formRef.value?.validate()
const data = { ...formData, }
mode.value == 'edit'
? await apiMonitorAlarmEdit(data)
: await apiMonitorAlarmAdd(data)
popupRef.value?.close()
emit('success')
}
//
const open = (type = 'add') => {
mode.value = type
popupRef.value?.open()
}
//
const handleClose = () => {
emit('close')
}
defineExpose({
open,
setFormData,
getDetail
})
</script>

View File

@ -0,0 +1,144 @@
<template>
<div>
<el-card class="!border-none mb-4" shadow="never">
<el-form
class="mb-[-16px]"
:model="queryParams"
inline
>
<el-form-item label="设备ID" prop="device_id">
<el-input class="w-[280px]" v-model="queryParams.device_id" clearable placeholder="请输入设备ID" />
</el-form-item>
<el-form-item label="监测类型" prop="type">
<el-select class="w-[280px]" v-model="queryParams.type" clearable placeholder="请选择监测类型">
<el-option label="全部" value=""></el-option>
<el-option
v-for="(item, index) in dictData.alarm_type"
:key="index"
:label="item.name"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="创建时间" prop="create_time">
<daterange-picker
v-model:startTime="queryParams.start_time"
v-model:endTime="queryParams.end_time"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="resetPage">查询</el-button>
<el-button @click="resetParams">重置</el-button>
</el-form-item>
</el-form>
</el-card>
<el-card class="!border-none" v-loading="pager.loading" shadow="never">
<div class="mt-4">
<el-table :data="pager.lists" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" />
<el-table-column label="ID" prop="id" show-overflow-tooltip />
<el-table-column label="设备ID" prop="device_id" show-overflow-tooltip />
<el-table-column label="设备名称" prop="device.name" show-overflow-tooltip />
<el-table-column label="监测类型" prop="type">
<template #default="{ row }">
<dict-value :options="dictData.alarm_type" :value="row.type" />
</template>
</el-table-column>
<el-table-column label="报警内容" prop="content" show-overflow-tooltip />
<el-table-column label="报警数值" prop="value" show-overflow-tooltip />
<el-table-column label="报警时间" prop="plant_date">
<template #default="{ row }">
<span>{{ row.create_time ? timeFormat(row.plant_date, 'yyyy-mm-dd hh:MM:ss') : '' }}</span>
</template>
</el-table-column>
<el-table-column label="操作" width="120" fixed="right">
<template #default="{ row }">
<el-button
v-perms="['device.monitor_alarm/edit']"
type="primary"
link
@click="handleEdit(row)"
>
编辑
</el-button>
<el-button
v-perms="['device.monitor_alarm/delete']"
type="danger"
link
@click="handleDelete(row.id)"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
</div>
<div class="flex mt-4 justify-end">
<pagination v-model="pager" @change="getLists" />
</div>
</el-card>
<edit-popup v-if="showEdit" ref="editRef" :dict-data="dictData" @success="getLists" @close="showEdit = false" />
</div>
</template>
<script lang="ts" setup name="monitorAlarmLists">
import { usePaging } from '@/hooks/usePaging'
import { useDictData } from '@/hooks/useDictOptions'
import { apiMonitorAlarmLists, apiMonitorAlarmDelete } from '@/api/monitor_alarm'
import { timeFormat } from '@/utils/util'
import feedback from '@/utils/feedback'
import EditPopup from './edit.vue'
const editRef = shallowRef<InstanceType<typeof EditPopup>>()
//
const showEdit = ref(false)
//
const queryParams = reactive({
device_id: '',
type: '',
})
//
const selectData = ref<any[]>([])
//
const handleSelectionChange = (val: any[]) => {
selectData.value = val.map(({ id }) => id)
}
//
const { dictData } = useDictData('alarm_type')
//
const { pager, getLists, resetParams, resetPage } = usePaging({
fetchFun: apiMonitorAlarmLists,
params: queryParams
})
//
const handleAdd = async () => {
showEdit.value = true
await nextTick()
editRef.value?.open('add')
}
//
const handleEdit = async (data: any) => {
showEdit.value = true
await nextTick()
editRef.value?.open('edit')
editRef.value?.setFormData(data)
}
//
const handleDelete = async (id: number | any[]) => {
await feedback.confirm('确定要删除?')
await apiMonitorAlarmDelete({ id })
getLists()
}
getLists()
</script>

View File

@ -0,0 +1,280 @@
<template>
<div class="edit-popup">
<popup
ref="popupRef"
:title="popupTitle"
:async="true"
width="650px"
@confirm="handleSubmit"
@close="handleClose"
>
<el-form ref="formRef" :model="formData" label-width="170px" :rules="formRules">
<el-form-item label="土壤最高温度" prop="soil_temp_max">
<el-input v-model="formData.soil_temp_max" clearable placeholder="请输入土壤最高温度" />
</el-form-item>
<el-form-item label="土壤最低温度" prop="soil_temp_min">
<el-input v-model="formData.soil_temp_min" clearable placeholder="请输入土壤最低温度" />
</el-form-item>
<el-form-item label="土壤最高湿度" prop="soil_mois_max">
<el-input v-model="formData.soil_mois_max" clearable placeholder="请输入土壤最高湿度" />
</el-form-item>
<el-form-item label="土壤最低湿度" prop="soil_mois_min">
<el-input v-model="formData.soil_mois_min" clearable placeholder="请输入土壤最低湿度" />
</el-form-item>
<el-form-item label="土壤最高PH值" prop="soil_ph_max">
<el-input v-model="formData.soil_ph_max" clearable placeholder="请输入土壤最高PH值" />
</el-form-item>
<el-form-item label="土壤最低PH值" prop="soil_ph_min">
<el-input v-model="formData.soil_ph_min" clearable placeholder="请输入土壤最低PH值" />
</el-form-item>
<el-form-item label="土壤最高氮含量" prop="soil_n_content_max">
<el-input v-model="formData.soil_n_content_max" clearable placeholder="请输入土壤最高氮含量" />
</el-form-item>
<el-form-item label="土壤最低氮含量" prop="soil_n_content_min">
<el-input v-model="formData.soil_n_content_min" clearable placeholder="请输入土壤最低氮含量" />
</el-form-item>
<el-form-item label="土壤最高磷含量" prop="soil_p_content_max">
<el-input v-model="formData.soil_p_content_max" clearable placeholder="请输入土壤最高磷含量" />
</el-form-item>
<el-form-item label="土壤最低磷含量" prop="soil_p_content_min">
<el-input v-model="formData.soil_p_content_min" clearable placeholder="请输入土壤最低磷含量" />
</el-form-item>
<el-form-item label="土壤最高钾含量" prop="soil_k_content_max">
<el-input v-model="formData.soil_k_content_max" clearable placeholder="请输入土壤最高钾含量" />
</el-form-item>
<el-form-item label="土壤最低钾含量" prop="soil_k_content_min">
<el-input v-model="formData.soil_k_content_min" clearable placeholder="请输入土壤最低钾含量" />
</el-form-item>
<el-form-item label="空气最高温度" prop="air_temp_max">
<el-input v-model="formData.air_temp_max" clearable placeholder="请输入空气最高温度" />
</el-form-item>
<el-form-item label="空气最低温度" prop="air_temp_min">
<el-input v-model="formData.air_temp_min" clearable placeholder="请输入空气最低温度" />
</el-form-item>
<el-form-item label="空气最高湿度" prop="air_mois_max">
<el-input v-model="formData.air_mois_max" clearable placeholder="请输入空气最高湿度" />
</el-form-item>
<el-form-item label="空气最低湿度" prop="air_mois_min">
<el-input v-model="formData.air_mois_min" clearable placeholder="请输入空气最低湿度" />
</el-form-item>
<el-form-item label="空气最大二氧化碳含量" prop="air_co2_content_max">
<el-input v-model="formData.air_co2_content_max" clearable placeholder="请输入空气最大二氧化碳含量" />
</el-form-item>
<el-form-item label="空气最小二氧化碳含量" prop="air_co2_content_min">
<el-input v-model="formData.air_co2_content_min" clearable placeholder="请输入空气最小二氧化碳含量" />
</el-form-item>
<el-form-item label="最大风速" prop="wind_speed_max">
<el-input v-model="formData.wind_speed_max" clearable placeholder="请输入最大风速" />
</el-form-item>
<el-form-item label="最小风速" prop="wind_speed_min">
<el-input v-model="formData.wind_speed_min" clearable placeholder="请输入最小风速" />
</el-form-item>
</el-form>
</popup>
</div>
</template>
<script lang="ts" setup name="monitorThresholdEdit">
import type { FormInstance } from 'element-plus'
import Popup from '@/components/popup/index.vue'
import { apiMonitorThresholdAdd, apiMonitorThresholdEdit, apiMonitorThresholdDetail } from '@/api/monitor_threshold'
import { timeFormat } from '@/utils/util'
import type { PropType } from 'vue'
defineProps({
dictData: {
type: Object as PropType<Record<string, any[]>>,
default: () => ({})
}
})
const emit = defineEmits(['success', 'close'])
const formRef = shallowRef<FormInstance>()
const popupRef = shallowRef<InstanceType<typeof Popup>>()
const mode = ref('add')
//
const popupTitle = computed(() => {
return mode.value == 'edit' ? '编辑报警配置' : '新增报警配置'
})
//
const formData = reactive({
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: '',
})
//
const formRules = reactive<any>({
soil_temp_max: [{
required: true,
message: '请输入土壤最高温度',
trigger: ['blur']
}],
soil_temp_min: [{
required: true,
message: '请输入土壤最低温度',
trigger: ['blur']
}],
soil_mois_max: [{
required: true,
message: '请输入土壤最高湿度',
trigger: ['blur']
}],
soil_mois_min: [{
required: true,
message: '请输入土壤最低湿度',
trigger: ['blur']
}],
soil_ph_max: [{
required: true,
message: '请输入土壤最高PH值',
trigger: ['blur']
}],
soil_ph_min: [{
required: true,
message: '请输入土壤最低PH值',
trigger: ['blur']
}],
soil_n_content_max: [{
required: true,
message: '请输入土壤最高氮含量',
trigger: ['blur']
}],
soil_n_content_min: [{
required: true,
message: '请输入土壤最低氮含量',
trigger: ['blur']
}],
soil_p_content_max: [{
required: true,
message: '请输入土壤最高磷含量',
trigger: ['blur']
}],
soil_p_content_min: [{
required: true,
message: '请输入土壤最低磷含量',
trigger: ['blur']
}],
soil_k_content_max: [{
required: true,
message: '请输入土壤最高钾含量',
trigger: ['blur']
}],
soil_k_content_min: [{
required: true,
message: '请输入土壤最低钾含量',
trigger: ['blur']
}],
air_temp_max: [{
required: true,
message: '请输入空气最高温度',
trigger: ['blur']
}],
air_temp_min: [{
required: true,
message: '请输入空气最低温度',
trigger: ['blur']
}],
air_mois_max: [{
required: true,
message: '请输入空气最高湿度',
trigger: ['blur']
}],
air_mois_min: [{
required: true,
message: '请输入空气最低湿度',
trigger: ['blur']
}],
air_co2_content_max: [{
required: true,
message: '请输入空气最大二氧化碳含量',
trigger: ['blur']
}],
air_co2_content_min: [{
required: true,
message: '请输入空气最小二氧化碳含量',
trigger: ['blur']
}],
wind_speed_max: [{
required: true,
message: '请输入最大风速',
trigger: ['blur']
}],
wind_speed_min: [{
required: true,
message: '请输入最小风速',
trigger: ['blur']
}],
})
//
const setFormData = async (data: Record<any, any>) => {
for (const key in formData) {
if (data[key] != null && data[key] != undefined) {
//@ts-ignore
formData[key] = data[key]
}
}
}
const getDetail = async (row: Record<string, any>) => {
const data = await apiMonitorThresholdDetail({
id: row.id
})
setFormData(data)
}
//
const handleSubmit = async () => {
await formRef.value?.validate()
const data = { ...formData, }
mode.value == 'edit'
? await apiMonitorThresholdEdit(data)
: await apiMonitorThresholdAdd(data)
popupRef.value?.close()
emit('success')
}
//
const open = (type = 'add') => {
mode.value = type
popupRef.value?.open()
}
//
const handleClose = () => {
emit('close')
}
defineExpose({
open,
setFormData,
getDetail
})
</script>

View File

@ -0,0 +1,98 @@
<template>
<div>
<el-card class="!border-none" v-loading="pager.loading" shadow="never">
<div class="mt-4">
<el-table :data="pager.lists" @selection-change="handleSelectionChange">
<el-table-column label="土壤最高温度" prop="soil_temp_max" show-overflow-tooltip />
<el-table-column label="土壤最低温度" prop="soil_temp_min" show-overflow-tooltip />
<el-table-column label="土壤最高湿度" prop="soil_mois_max" show-overflow-tooltip />
<el-table-column label="土壤最低湿度" prop="soil_mois_min" show-overflow-tooltip />
<el-table-column label="土壤最高PH值" prop="soil_ph_max" show-overflow-tooltip />
<el-table-column label="土壤最低PH值" prop="soil_ph_min" show-overflow-tooltip />
<el-table-column label="土壤最高氮含量" prop="soil_n_content_max" show-overflow-tooltip />
<el-table-column label="土壤最低氮含量" prop="soil_n_content_min" show-overflow-tooltip />
<el-table-column label="最大风速" prop="wind_speed_max" show-overflow-tooltip />
<el-table-column label="最小风速" prop="wind_speed_min" show-overflow-tooltip />
<el-table-column label="操作" width="120" fixed="right">
<template #default="{ row }">
<el-button
v-perms="['device.monitor_threshold/edit']"
type="primary"
link
@click="handleEdit(row)"
>
编辑
</el-button>
</template>
</el-table-column>
</el-table>
</div>
<div class="flex mt-4 justify-end">
<pagination v-model="pager" @change="getLists" />
</div>
</el-card>
<edit-popup v-if="showEdit" ref="editRef" :dict-data="dictData" @success="getLists" @close="showEdit = false" />
</div>
</template>
<script lang="ts" setup name="monitorThresholdLists">
import { usePaging } from '@/hooks/usePaging'
import { useDictData } from '@/hooks/useDictOptions'
import { apiMonitorThresholdLists, apiMonitorThresholdDelete } from '@/api/monitor_threshold'
import { timeFormat } from '@/utils/util'
import feedback from '@/utils/feedback'
import EditPopup from './edit.vue'
const editRef = shallowRef<InstanceType<typeof EditPopup>>()
//
const showEdit = ref(false)
//
const queryParams = reactive({
})
//
const selectData = ref<any[]>([])
//
const handleSelectionChange = (val: any[]) => {
selectData.value = val.map(({ id }) => id)
}
//
const { dictData } = useDictData('')
//
const { pager, getLists, resetParams, resetPage } = usePaging({
fetchFun: apiMonitorThresholdLists,
params: queryParams
})
//
const handleAdd = async () => {
showEdit.value = true
await nextTick()
editRef.value?.open('add')
}
//
const handleEdit = async (data: any) => {
showEdit.value = true
await nextTick()
editRef.value?.open('edit')
editRef.value?.setFormData(data)
}
//
const handleDelete = async (id: number | any[]) => {
await feedback.confirm('确定要删除?')
await apiMonitorThresholdDelete({ id })
getLists()
}
getLists()
</script>

View File

@ -0,0 +1,173 @@
<template>
<div class="edit-popup">
<popup
ref="popupRef"
:title="popupTitle"
:async="true"
width="550px"
@confirm="handleSubmit"
@close="handleClose"
>
<el-form ref="formRef" :model="formData" label-width="120px" :rules="formRules">
<el-form-item label="设备ID" prop="device_id">
<el-input v-model="formData.device_id" disabled clearable placeholder="请输入设备ID" />
</el-form-item>
<el-form-item label="土壤温度" prop="temperature">
<el-input v-model="formData.temperature" disabled clearable placeholder="请输入土壤温度" />
</el-form-item>
<el-form-item label="土壤湿度" prop="moisture">
<el-input v-model="formData.moisture" disabled clearable placeholder="请输入土壤湿度" />
</el-form-item>
<el-form-item label="电导率" prop="conductivity">
<el-input v-model="formData.conductivity" disabled clearable placeholder="请输入电导率" />
</el-form-item>
<el-form-item label="土壤酸碱度" prop="ph">
<el-input v-model="formData.ph" disabled clearable placeholder="请输入土壤酸碱度" />
</el-form-item>
<el-form-item label="氮含量" prop="n_content">
<el-input v-model="formData.n_content" disabled clearable placeholder="请输入氮含量" />
</el-form-item>
<el-form-item label="磷含量" prop="p_content">
<el-input v-model="formData.p_content" disabled clearable placeholder="请输入磷含量" />
</el-form-item>
<el-form-item label="钾含量" prop="k_content">
<el-input v-model="formData.k_content" disabled clearable placeholder="请输入钾含量" />
</el-form-item>
</el-form>
</popup>
</div>
</template>
<script lang="ts" setup name="soilMonitorEdit">
import type { FormInstance } from 'element-plus'
import Popup from '@/components/popup/index.vue'
import { apiSoilMonitorAdd, apiSoilMonitorEdit, apiSoilMonitorDetail } from '@/api/soil_monitor'
import { timeFormat } from '@/utils/util'
import type { PropType } from 'vue'
defineProps({
dictData: {
type: Object as PropType<Record<string, any[]>>,
default: () => ({})
}
})
const emit = defineEmits(['success', 'close'])
const formRef = shallowRef<FormInstance>()
const popupRef = shallowRef<InstanceType<typeof Popup>>()
const mode = ref('add')
//
const popupTitle = computed(() => {
return mode.value == 'edit' ? '土壤监测数据' : '新增土壤监测'
})
//
const formData = reactive({
id: '',
device_id: '',
temperature: '',
moisture: '',
conductivity: '',
ph: '',
n_content: '',
p_content: '',
k_content: '',
})
//
const formRules = reactive<any>({
device_id: [{
required: true,
message: '请输入设备ID',
trigger: ['blur']
}],
temperature: [{
required: true,
message: '请输入土壤温度',
trigger: ['blur']
}],
moisture: [{
required: true,
message: '请输入土壤湿度',
trigger: ['blur']
}],
conductivity: [{
required: true,
message: '请输入电导率',
trigger: ['blur']
}],
ph: [{
required: true,
message: '请输入土壤酸碱度',
trigger: ['blur']
}],
n_content: [{
required: true,
message: '请输入氮含量',
trigger: ['blur']
}],
p_content: [{
required: true,
message: '请输入磷含量',
trigger: ['blur']
}],
k_content: [{
required: true,
message: '请输入钾含量',
trigger: ['blur']
}],
})
//
const setFormData = async (data: Record<any, any>) => {
for (const key in formData) {
if (data[key] != null && data[key] != undefined) {
//@ts-ignore
formData[key] = data[key]
}
}
//@ts-ignore
formData.create_time = timeFormat(formData.create_time,'yyyy-mm-dd hh:MM:ss')
}
const getDetail = async (row: Record<string, any>) => {
const data = await apiSoilMonitorDetail({
id: row.id
})
setFormData(data)
}
//
const handleSubmit = async () => {
await formRef.value?.validate()
const data = { ...formData, }
mode.value == 'edit'
? await apiSoilMonitorEdit(data)
: await apiSoilMonitorAdd(data)
popupRef.value?.close()
emit('success')
}
//
const open = (type = 'add') => {
mode.value = type
popupRef.value?.open()
}
//
const handleClose = () => {
emit('close')
}
defineExpose({
open,
setFormData,
getDetail
})
</script>

View File

@ -0,0 +1,134 @@
<template>
<div>
<el-card class="!border-none mb-4" shadow="never">
<el-form
class="mb-[-16px]"
:model="queryParams"
inline
>
<el-form-item label="设备ID" prop="device_id">
<el-input class="w-[280px]" v-model="queryParams.device_id" clearable placeholder="请输入设备ID" />
</el-form-item>
<el-form-item label="创建时间" prop="create_time">
<daterange-picker
v-model:startTime="queryParams.start_time"
v-model:endTime="queryParams.end_time"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="resetPage">查询</el-button>
<el-button @click="resetParams">重置</el-button>
</el-form-item>
</el-form>
</el-card>
<el-card class="!border-none" v-loading="pager.loading" shadow="never">
<div class="mt-4">
<el-table :data="pager.lists" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" />
<el-table-column label="ID" prop="id" show-overflow-tooltip />
<el-table-column label="设备ID" prop="device_id" show-overflow-tooltip />
<el-table-column label="设备名称" prop="device.name" show-overflow-tooltip />
<el-table-column label="土壤温度" prop="temperature" show-overflow-tooltip />
<el-table-column label="土壤湿度" prop="moisture" show-overflow-tooltip />
<el-table-column label="电导率" prop="conductivity" show-overflow-tooltip />
<el-table-column label="土壤酸碱度" prop="ph" show-overflow-tooltip />
<el-table-column label="氮含量" prop="n_content" show-overflow-tooltip />
<el-table-column label="磷含量" prop="p_content" show-overflow-tooltip />
<el-table-column label="钾含量" prop="k_content" show-overflow-tooltip />
<el-table-column label="创建时间" prop="create_time">
<template #default="{ row }">
<span>{{ row.create_time ? timeFormat(row.create_time, 'yyyy-mm-dd hh:MM:ss') : '' }}</span>
</template>
</el-table-column>
<el-table-column label="操作" width="120" fixed="right">
<template #default="{ row }">
<el-button
v-perms="['device.soil_monitor/edit']"
type="primary"
link
@click="handleEdit(row)"
>
编辑
</el-button>
<el-button
v-perms="['device.soil_monitor/delete']"
type="danger"
link
@click="handleDelete(row.id)"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
</div>
<div class="flex mt-4 justify-end">
<pagination v-model="pager" @change="getLists" />
</div>
</el-card>
<edit-popup v-if="showEdit" ref="editRef" :dict-data="dictData" @success="getLists" @close="showEdit = false" />
</div>
</template>
<script lang="ts" setup name="soilMonitorLists">
import { usePaging } from '@/hooks/usePaging'
import { useDictData } from '@/hooks/useDictOptions'
import { apiSoilMonitorLists, apiSoilMonitorDelete } from '@/api/soil_monitor'
import { timeFormat } from '@/utils/util'
import feedback from '@/utils/feedback'
import EditPopup from './edit.vue'
const editRef = shallowRef<InstanceType<typeof EditPopup>>()
//
const showEdit = ref(false)
//
const queryParams = reactive({
device_id: '',
create_time: '',
})
//
const selectData = ref<any[]>([])
//
const handleSelectionChange = (val: any[]) => {
selectData.value = val.map(({ id }) => id)
}
//
const { dictData } = useDictData('')
//
const { pager, getLists, resetParams, resetPage } = usePaging({
fetchFun: apiSoilMonitorLists,
params: queryParams
})
//
const handleAdd = async () => {
showEdit.value = true
await nextTick()
editRef.value?.open('add')
}
//
const handleEdit = async (data: any) => {
showEdit.value = true
await nextTick()
editRef.value?.open('edit')
editRef.value?.setFormData(data)
}
//
const handleDelete = async (id: number | any[]) => {
await feedback.confirm('确定要删除?')
await apiSoilMonitorDelete({ id })
getLists()
}
getLists()
</script>

View File

@ -0,0 +1,108 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\controller\device;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\device\AirMonitorLists;
use app\adminapi\logic\device\AirMonitorLogic;
use app\adminapi\validate\device\AirMonitorValidate;
/**
* AirMonitor控制器
* Class AirMonitorController
* @package app\adminapi\controller\device
*/
class AirMonitorController extends BaseAdminController
{
/**
* @notes 获取列表
* @return \think\response\Json
* @author likeadmin
* @date 2023/11/24 16:49
*/
public function lists()
{
return $this->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);
}
}

View File

@ -0,0 +1,108 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\controller\device;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\device\MonitorAlarmLists;
use app\adminapi\logic\device\MonitorAlarmLogic;
use app\adminapi\validate\device\MonitorAlarmValidate;
/**
* MonitorAlarm控制器
* Class MonitorAlarmController
* @package app\adminapi\controller\device
*/
class MonitorAlarmController extends BaseAdminController
{
/**
* @notes 获取列表
* @return \think\response\Json
* @author likeadmin
* @date 2023/11/24 16:34
*/
public function lists()
{
return $this->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);
}
}

View File

@ -0,0 +1,108 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\controller\device;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\device\MonitorThresholdLists;
use app\adminapi\logic\device\MonitorThresholdLogic;
use app\adminapi\validate\device\MonitorThresholdValidate;
/**
* MonitorThreshold控制器
* Class MonitorThresholdController
* @package app\adminapi\controller\device
*/
class MonitorThresholdController extends BaseAdminController
{
/**
* @notes 获取列表
* @return \think\response\Json
* @author likeadmin
* @date 2023/11/24 16:17
*/
public function lists()
{
return $this->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);
}
}

View File

@ -0,0 +1,108 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\controller\device;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\device\SoilMonitorLists;
use app\adminapi\logic\device\SoilMonitorLogic;
use app\adminapi\validate\device\SoilMonitorValidate;
/**
* SoilMonitor控制器
* Class SoilMonitorController
* @package app\adminapi\controller\device
*/
class SoilMonitorController extends BaseAdminController
{
/**
* @notes 获取列表
* @return \think\response\Json
* @author likeadmin
* @date 2023/11/24 17:02
*/
public function lists()
{
return $this->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);
}
}

View File

@ -0,0 +1,79 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\lists\device;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\device\AirMonitor;
use app\common\lists\ListsSearchInterface;
/**
* AirMonitor列表
* Class AirMonitorLists
* @package app\adminapi\listsdevice
*/
class AirMonitorLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2023/11/24 16:49
*/
public function setSearch(): array
{
$allowSearch = ['start_time', 'end_time'];
if (!empty($this->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();
}
}

View File

@ -0,0 +1,82 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\lists\device;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\device\MonitorAlarm;
use app\common\lists\ListsSearchInterface;
/**
* MonitorAlarm列表
* Class MonitorAlarmLists
* @package app\adminapi\listsdevice
*/
class MonitorAlarmLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2023/11/24 16:34
*/
public function setSearch(): array
{
$allowSearch = ['start_time', 'end_time'];
if (!empty($this->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();
}
}

View File

@ -0,0 +1,77 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\lists\device;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\device\MonitorThreshold;
use app\common\lists\ListsSearchInterface;
/**
* MonitorThreshold列表
* Class MonitorThresholdLists
* @package app\adminapi\listsdevice
*/
class MonitorThresholdLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2023/11/24 16:17
*/
public function setSearch(): array
{
return [
];
}
/**
* @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:17
*/
public function lists(): array
{
return MonitorThreshold::where($this->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();
}
}

View File

@ -0,0 +1,79 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\lists\device;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\device\SoilMonitor;
use app\common\lists\ListsSearchInterface;
/**
* SoilMonitor列表
* Class SoilMonitorLists
* @package app\adminapi\listsdevice
*/
class SoilMonitorLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2023/11/24 17:02
*/
public function setSearch(): array
{
$allowSearch = ['start_time', 'end_time'];
if (!empty($this->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();
}
}

View File

@ -0,0 +1,122 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\logic\device;
use app\common\model\device\AirMonitor;
use app\common\logic\BaseLogic;
use think\facade\Db;
/**
* AirMonitor逻辑
* Class AirMonitorLogic
* @package app\adminapi\logic\device
*/
class AirMonitorLogic extends BaseLogic
{
/**
* @notes 添加
* @param array $params
* @return bool
* @author likeadmin
* @date 2023/11/24 16:49
*/
public static function add(array $params): bool
{
Db::startTrans();
try {
AirMonitor::create([
'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 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();
}
}

View File

@ -0,0 +1,114 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\logic\device;
use app\common\model\device\MonitorAlarm;
use app\common\logic\BaseLogic;
use think\facade\Db;
/**
* MonitorAlarm逻辑
* Class MonitorAlarmLogic
* @package app\adminapi\logic\device
*/
class MonitorAlarmLogic extends BaseLogic
{
/**
* @notes 添加
* @param array $params
* @return bool
* @author likeadmin
* @date 2023/11/24 16:34
*/
public static function add(array $params): bool
{
Db::startTrans();
try {
MonitorAlarm::create([
'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 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();
}
}

View File

@ -0,0 +1,144 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\logic\device;
use app\common\model\device\MonitorThreshold;
use app\common\logic\BaseLogic;
use think\facade\Db;
/**
* MonitorThreshold逻辑
* Class MonitorThresholdLogic
* @package app\adminapi\logic\device
*/
class MonitorThresholdLogic extends BaseLogic
{
/**
* @notes 添加
* @param array $params
* @return bool
* @author likeadmin
* @date 2023/11/24 16:17
*/
public static function add(array $params): bool
{
Db::startTrans();
try {
MonitorThreshold::create([
'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 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();
}
}

View File

@ -0,0 +1,120 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\logic\device;
use app\common\model\device\SoilMonitor;
use app\common\logic\BaseLogic;
use think\facade\Db;
/**
* SoilMonitor逻辑
* Class SoilMonitorLogic
* @package app\adminapi\logic\device
*/
class SoilMonitorLogic extends BaseLogic
{
/**
* @notes 添加
* @param array $params
* @return bool
* @author likeadmin
* @date 2023/11/24 17:02
*/
public static function add(array $params): bool
{
Db::startTrans();
try {
SoilMonitor::create([
'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 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();
}
}

View File

@ -0,0 +1,112 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\validate\device;
use app\common\validate\BaseValidate;
/**
* AirMonitor验证器
* Class AirMonitorValidate
* @package app\adminapi\validate\device
*/
class AirMonitorValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => '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']);
}
}

View File

@ -0,0 +1,104 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\validate\device;
use app\common\validate\BaseValidate;
/**
* MonitorAlarm验证器
* Class MonitorAlarmValidate
* @package app\adminapi\validate\device
*/
class MonitorAlarmValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => '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']);
}
}

View File

@ -0,0 +1,134 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\validate\device;
use app\common\validate\BaseValidate;
/**
* MonitorThreshold验证器
* Class MonitorThresholdValidate
* @package app\adminapi\validate\device
*/
class MonitorThresholdValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => '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']);
}
}

View File

@ -0,0 +1,110 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\validate\device;
use app\common\validate\BaseValidate;
/**
* SoilMonitor验证器
* Class SoilMonitorValidate
* @package app\adminapi\validate\device
*/
class SoilMonitorValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => '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']);
}
}

View File

@ -0,0 +1,77 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\common\model\device;
use app\common\model\BaseModel;
/**
* AirMonitor模型
* Class AirMonitor
* @package app\common\model\device
*/
class AirMonitor extends BaseModel
{
protected $name = 'air_monitor';
/**
* @notes 关联device
* @return \think\model\relation\HasOne
* @author likeadmin
* @date 2023/11/24 16:49
*/
public function device()
{
return $this->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));
}
}
}

View File

@ -0,0 +1,75 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\common\model\device;
use app\common\model\BaseModel;
/**
* MonitorAlarm模型
* Class MonitorAlarm
* @package app\common\model\device
*/
class MonitorAlarm extends BaseModel
{
protected $name = 'monitor_alarm';
/**
* @notes 关联device
* @return \think\model\relation\HasOne
* @author likeadmin
* @date 2023/11/24 16:34
*/
public function device()
{
return $this->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));
}
}
}

View File

@ -0,0 +1,34 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\common\model\device;
use app\common\model\BaseModel;
/**
* MonitorThreshold模型
* Class MonitorThreshold
* @package app\common\model\device
*/
class MonitorThreshold extends BaseModel
{
protected $name = 'monitor_threshold';
}

View File

@ -0,0 +1,76 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\common\model\device;
use app\common\model\BaseModel;
/**
* SoilMonitor模型
* Class SoilMonitor
* @package app\common\model\device
*/
class SoilMonitor extends BaseModel
{
protected $name = 'soil_monitor';
/**
* @notes 关联device
* @return \think\model\relation\HasOne
* @author likeadmin
* @date 2023/11/24 17:02
*/
public function device()
{
return $this->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));
}
}
}