chỉ đồng bộ logs với event type được lựa chọn
This commit is contained in:
parent
018ca540d5
commit
b5619f7a5f
|
@ -16,6 +16,7 @@ use yii\filters\VerbFilter;
|
||||||
use yii\helpers\Html;
|
use yii\helpers\Html;
|
||||||
use yii\helpers\Url;
|
use yii\helpers\Url;
|
||||||
use app\models\Logs;
|
use app\models\Logs;
|
||||||
|
use app\models\EventType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DeviceController implements the CRUD actions for Device model.
|
* DeviceController implements the CRUD actions for Device model.
|
||||||
|
@ -472,8 +473,9 @@ class DeviceController extends Controller {
|
||||||
$device = $this->findModel(Yii::$app->request->post("data"));
|
$device = $this->findModel(Yii::$app->request->post("data"));
|
||||||
$response = json_decode(common::requestToCardService("/GetDeviceData/GetLog", ["DeviceIP" => $device->ip_address]), true);
|
$response = json_decode(common::requestToCardService("/GetDeviceData/GetLog", ["DeviceIP" => $device->ip_address]), true);
|
||||||
$datas = [];
|
$datas = [];
|
||||||
|
$eventTypeCode = EventType::eventTypeCode();
|
||||||
foreach ($response as $key => $value) {
|
foreach ($response as $key => $value) {
|
||||||
if ($value["Cardno"] !== "0")
|
if ($value["Cardno"] !== "0" && in_array($value["EventType"], $eventTypeCode))
|
||||||
$datas[] = [$value["Pin"], $value["Cardno"], $device->id, $value["DoorID"], $value["InOutState"], Logs::parseTime($value["Time_second"]), $value["EventType"]];
|
$datas[] = [$value["Pin"], $value["Cardno"], $device->id, $value["DoorID"], $value["InOutState"], Logs::parseTime($value["Time_second"]), $value["EventType"]];
|
||||||
}
|
}
|
||||||
$model = new Logs();
|
$model = new Logs();
|
||||||
|
|
|
@ -54,4 +54,13 @@ class EventType extends \yii\db\ActiveRecord {
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function eventTypeCode() {
|
||||||
|
$lists = self::find()->all();
|
||||||
|
$results = [];
|
||||||
|
foreach ($lists as $key => $value) {
|
||||||
|
$results[] = $value->code;
|
||||||
|
}
|
||||||
|
return $results;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user