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