diff --git a/controllers/DeviceController.php b/controllers/DeviceController.php index 4ec02692..d7bcdfcf 100644 --- a/controllers/DeviceController.php +++ b/controllers/DeviceController.php @@ -16,6 +16,7 @@ use yii\filters\VerbFilter; use yii\helpers\Html; use yii\helpers\Url; use app\models\Logs; +use app\models\EventType; /** * DeviceController implements the CRUD actions for Device model. @@ -472,8 +473,9 @@ class DeviceController extends Controller { $device = $this->findModel(Yii::$app->request->post("data")); $response = json_decode(common::requestToCardService("/GetDeviceData/GetLog", ["DeviceIP" => $device->ip_address]), true); $datas = []; + $eventTypeCode = EventType::eventTypeCode(); 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"]]; } $model = new Logs(); diff --git a/models/EventType.php b/models/EventType.php index f584e7ca..b98458b5 100644 --- a/models/EventType.php +++ b/models/EventType.php @@ -54,4 +54,13 @@ class EventType extends \yii\db\ActiveRecord { return $results; } + public static function eventTypeCode() { + $lists = self::find()->all(); + $results = []; + foreach ($lists as $key => $value) { + $results[] = $value->code; + } + return $results; + } + }