test connection
This commit is contained in:
parent
70db83d3ab
commit
fc71a6c7b8
|
@ -240,14 +240,61 @@ class DepartmentController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function actionTest() {
|
public function actionTest() {
|
||||||
$test = file_get_contents("http://192.168.2.119:2001/TestConnection", false, stream_context_create([
|
$timezone = [
|
||||||
|
"DeviceIP" => "192.168.1.200",
|
||||||
|
"TimezoneId" => 1,
|
||||||
|
"SunTime1" => 0, "SunTime2" => 0, "SunTime3" => 0,
|
||||||
|
"MonTime1" => 0, "MonTime2" => 0, "MonTime3" => 0,
|
||||||
|
"TueTime1" => 0, "TueTime2" => 0, "TueTime3" => 0,
|
||||||
|
"WedTime1" => 0, "WedTime2" => 0, "WedTime3" => 0,
|
||||||
|
"ThuTime1" => 0, "ThuTime2" => 0, "ThuTime3" => 0,
|
||||||
|
"FriTime1" => $this->convertTime("8:30", "12:30"), "FriTime2" => $this->convertTime("13:30", "18:30"), "FriTime3" => 0,
|
||||||
|
"SatTime1" => 0, "SatTime2" => 0, "SatTime3" => 0,
|
||||||
|
"Hol1Time1" => 0, "Hol1Time2" => 0, "Hol1Time3" => 0,
|
||||||
|
"Hol2Time1" => 0, "Hol2Time2" => 0, "Hol2Time3" => 0,
|
||||||
|
"Hol3Time1" => 0, "Hol3Time2" => 0, "Hol3Time3" => 0
|
||||||
|
];
|
||||||
|
$timezoneRq = $this->requestToMCard("/SetDeviceData/timezone", $timezone);
|
||||||
|
|
||||||
|
$user = [
|
||||||
|
"DeviceIP" => "192.168.1.200",
|
||||||
|
"CardNo" => 16673827,
|
||||||
|
"Pin" => 69,
|
||||||
|
"Password" => "",
|
||||||
|
"Group" => "",
|
||||||
|
"StartTime" => "",
|
||||||
|
"EndTime" => ""
|
||||||
|
];
|
||||||
|
$userRq = $this->requestToMCard("/SetDeviceData/user", $user);
|
||||||
|
|
||||||
|
$userAuthor = [
|
||||||
|
"DeviceIP" => "192.168.1.200",
|
||||||
|
"Pin" => 69,
|
||||||
|
"AuthorizeTimezoneId" => 1,
|
||||||
|
"AuthorizeDoorId" => 2
|
||||||
|
];
|
||||||
|
|
||||||
|
$userAuthorRq = $this->requestToMCard("/SetDeviceData/userauthorize", $userAuthor);
|
||||||
|
|
||||||
|
return var_dump($timezoneRq, $userRq, $userAuthorRq);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function requestToMCard($path, $data) {
|
||||||
|
return file_get_contents("http://192.168.2.119:2001" . $path, false, stream_context_create([
|
||||||
'http' => [
|
'http' => [
|
||||||
'header' => "Content-Type: application/json",
|
'header' => "Content-Type: application/json",
|
||||||
'method' => "POST",
|
'method' => "POST",
|
||||||
'content' => json_encode(["DeviceIP" => "192.168.1.200"])
|
'content' => json_encode($data)
|
||||||
]
|
]
|
||||||
]));
|
]));
|
||||||
return var_dump($test);
|
}
|
||||||
|
|
||||||
|
public function convertTime($from, $to) {
|
||||||
|
$fTemp = explode(":", $from);
|
||||||
|
$front = dechex(intval($fTemp[0]) * 100 + intval($fTemp[1]));
|
||||||
|
$tTemp = explode(":", $to);
|
||||||
|
$back = dechex(intval($tTemp[0]) * 100 + intval($tTemp[1]));
|
||||||
|
return hexdec("0" . $front . "0" . $back);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,12 +37,12 @@
|
||||||
{GridView::widget([
|
{GridView::widget([
|
||||||
'dataProvider' => $dataProvider,
|
'dataProvider' => $dataProvider,
|
||||||
'filterModel' => $searchModel,
|
'filterModel' => $searchModel,
|
||||||
'layout'=> \app\helpers\DepartmentGrid::getLayout(),
|
'layout'=> \app\helpers\CommonGrid::getLayout(),
|
||||||
'tableOptions' => [
|
'tableOptions' => [
|
||||||
'class' => 'table table-striped table-bordered table-hover',
|
'class' => 'table table-striped table-bordered table-hover',
|
||||||
'style' => 'background:#fff;min-width:700px;'
|
'style' => 'background:#fff;min-width:700px;'
|
||||||
],
|
],
|
||||||
'rowOptions' => \app\helpers\DepartmentGrid::rows("device"),
|
'rowOptions' => \app\helpers\CommonGrid::rows("device"),
|
||||||
'columns' => [
|
'columns' => [
|
||||||
[
|
[
|
||||||
'class' => 'yii\grid\SerialColumn',
|
'class' => 'yii\grid\SerialColumn',
|
||||||
|
@ -54,17 +54,21 @@
|
||||||
'format' => 'raw',
|
'format' => 'raw',
|
||||||
'contentOptions' => ['class' => 'text-center'],
|
'contentOptions' => ['class' => 'text-center'],
|
||||||
'headerOptions' => ['class' => 'text-center', 'style' => 'width:3%'],
|
'headerOptions' => ['class' => 'text-center', 'style' => 'width:3%'],
|
||||||
'value' => \app\helpers\DepartmentGrid::checkbox("device")
|
'value' => \app\helpers\CommonGrid::checkbox("device")
|
||||||
],
|
],
|
||||||
'name',
|
'name',
|
||||||
|
'serial',
|
||||||
'ip_address',
|
'ip_address',
|
||||||
|
'status',
|
||||||
|
'type',
|
||||||
|
'area_id',
|
||||||
[
|
[
|
||||||
'attribute' => 'created_at',
|
'attribute' => 'created_at',
|
||||||
'value' => \app\helpers\DepartmentGrid::createdAt()
|
'value' => \app\helpers\CommonGrid::createdAt()
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'attribute' => 'modified_at',
|
'attribute' => 'modified_at',
|
||||||
'value' => \app\helpers\DepartmentGrid::modifiedAt()
|
'value' => \app\helpers\CommonGrid::modifiedAt()
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
])}
|
])}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user