处理重复报警问题
parent
cf78e26df7
commit
8840e75eb2
|
|
@ -17,7 +17,6 @@ class CustomRegionController extends AdminController
|
|||
|
||||
public function regionIndex($type)
|
||||
{
|
||||
|
||||
switch($type){
|
||||
case 'yuyang':
|
||||
// $this->pageTitle = '育秧列表';
|
||||
|
|
|
|||
|
|
@ -23,6 +23,10 @@ class WarningNotice extends Model
|
|||
];
|
||||
}
|
||||
|
||||
public function loggable(){
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
||||
public function device(){
|
||||
return $this->belongsTo(Device::class, 'device_id');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,8 +48,16 @@ class DeviceWarningService
|
|||
foreach($rule['children'] as $child){
|
||||
$cRes = $this->verifyRule($child, $log);
|
||||
if($cRes && $cRes['status']){
|
||||
$res['status'] = true;
|
||||
$res['keys'] = array_merge($res['keys'], $cRes['keys']);
|
||||
if($log->wasChanged($cRes['keys'])){
|
||||
$res['status'] = true;
|
||||
$res['keys'] = array_merge($res['keys'], $cRes['keys']);
|
||||
}elseif(WarningNotice::where([
|
||||
'loggable_type' => $log::class,
|
||||
'loggable_id' => $log->id,
|
||||
])->count() == 0){
|
||||
$res['status'] = true;
|
||||
$res['keys'] = array_merge($res['keys'], $cRes['keys']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -66,8 +74,16 @@ class DeviceWarningService
|
|||
break;
|
||||
}
|
||||
}
|
||||
$res['status'] = true;
|
||||
$res['keys'][] = implode(',', $_keys);
|
||||
if($log->wasChanged($_keys)){
|
||||
$res['status'] = true;
|
||||
$res['keys'][] = implode(',', $_keys);
|
||||
}elseif(WarningNotice::where([
|
||||
'loggable_type' => $log::class,
|
||||
'loggable_id' => $log->id,
|
||||
])->count() == 0){
|
||||
$res['status'] = true;
|
||||
$res['keys'][] = implode(',', $_keys);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -134,6 +150,8 @@ class DeviceWarningService
|
|||
'reported_at' => $reportedAt,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
'loggable_type' => $log::class,
|
||||
'loggable_id' => $log->id,
|
||||
];
|
||||
}
|
||||
count($notices) > 0 && WarningNotice::insert($notices);
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ return new class extends Migration
|
|||
$table->unsignedTinyInteger('status')->default(0)->comment('状态:0未处理,1已处理,2已忽略');
|
||||
$table->string('remarks')->nullable()->comment('备注');
|
||||
$table->timestamp('reported_at');
|
||||
$table->nullableMorphs('loggable');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue