修改警报消息内容

dev
vine_liutk 2022-11-17 09:28:15 +08:00
parent 088999bbeb
commit dbd69e15d8
1 changed files with 6 additions and 4 deletions

View File

@ -9,6 +9,7 @@ use App\Models\WaterQualityMonitoringLog;
use App\Models\SoilMonitoringLog; use App\Models\SoilMonitoringLog;
use Carbon\Carbon; use Carbon\Carbon;
use App\Models\Device; use App\Models\Device;
use App\Models\AgriculturalBase;
class DeviceWarningService class DeviceWarningService
{ {
@ -93,19 +94,20 @@ class DeviceWarningService
} }
if($_warning){//插入警报内容 if($_warning){//插入警报内容
$this->inLog($device->sn, $reportedAt, $log, $_lv, $key); $this->inLog($device, $reportedAt, $log, $_lv, $key);
} }
} }
} }
private function inLog(string $deviceSn, Carbon $reportedAt, Model $log, $lv, $column){ private function inLog(Device $device, Carbon $reportedAt, Model $log, $lv, $column){
$base = AgriculturalBase::find($log->agricultural_base_id);
DeviceWarning::create([ DeviceWarning::create([
'device_id' => $log->device_id, 'device_id' => $log->device_id,
'base_id' => $log->agricultural_base_id, 'base_id' => $log->agricultural_base_id,
'lv' => $lv, 'lv' => $lv,
'content' => $this->columnTexts[$column] . '达到' .$log->$column. $this->columnUnit[$column], 'content' => '【'.($base?->name ?? '').'-'.$device->monitoring_point.'】'.$this->columnTexts[$column] . '达到' .$log->$column. $this->columnUnit[$column],
'linkos_device_id' => $deviceSn, 'linkos_device_id' => $device->sn,
'linkos_reported_at' => $reportedAt 'linkos_reported_at' => $reportedAt
]); ]);
} }