Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cdz_gateway_v2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨苏杭
cdz_gateway_v2
Commits
3baf527c
Commit
3baf527c
authored
Sep 25, 2018
by
banice
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改充满自停的开始时间格式
parent
840b5072
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
135 additions
and
21 deletions
+135
-21
.env
+1
-0
.idea/workspace.xml
+0
-0
.staging
+2
-2
application/controller/accept/AccessController.php
+7
-2
application/controller/update/QueryController.php
+95
-0
application/model/GatewayUpdateModel.php
+18
-0
application/route/Api.php
+1
-1
lib/cdz/order/state/ChargerState.php
+4
-2
lib/log/Log.php
+2
-7
lib/remote/api/message/ChargerFullMessage.php
+5
-7
No files found.
.env
View file @
3baf527c
...
...
@@ -31,5 +31,6 @@ MESSAGE_CHARGER_TIMEOUT=f0DDXSxvRTbHyzkCnwnYijtgteFTdfdUR7J8REwTYJ8
MESSAGE_RELOAD=t_PyOGCKN_fmD0blw0EuIQs-8sS3qOTmpQay12haPZY
MESSAGE_SHED_TIMEOUT=rdzTNQ7t4uRXkP0SkuwW10WH77A_CIgYFiJykXJ0utU
MESSAGE_CHARGER_SHED=C0LvfETe-1rCR_IhOydDGPTUwwYkrWZxgfwMsETrhw8
DOWNLOAD_HOST=https://cdzpay.test.senthink.com
LOW_POWER_LIMIT=30
.idea/workspace.xml
View file @
3baf527c
This diff is collapsed.
Click to expand it.
.staging
View file @
3baf527c
REDIS_HOST=redis.staging.senthink.com
REGISTER_IP=1
27.0.0.1
REGISTER_IP=1
00.109.192.7
REGISTER_PORT=1239
GATEWAY_PORT=8282
GATEWAY_IP=127.0.0.1
GATEWAY_COUNT=4
GATEWAY_START_PORT=1230
START_FILE=business
|gateway|register
START_FILE=business
DB_HOST=db.staging.senthink.com
DB_USERNAME=senthink
...
...
application/controller/accept/AccessController.php
View file @
3baf527c
...
...
@@ -56,6 +56,7 @@ class AccessController extends Controller
{
$mac
=
$this
->
request
->
get
(
'mac'
);
$_SESSION
[
'gateway_mac'
]
=
$mac
;
$gatewayModel
=
new
GatewayModel
();
...
...
@@ -68,7 +69,8 @@ class AccessController extends Controller
$gatewayModelResult
=
$gatewayModel
->
getColumns
([
'station_id'
,
'id'
,
'name'
'name'
,
'type_id'
],
'mac_address = '
.
"'
$mac
'"
);
if
(
$gatewayModelResult
==
false
)
{
...
...
@@ -83,6 +85,8 @@ class AccessController extends Controller
$_SESSION
[
'gateway_id'
]
=
$gatewayModelResult
[
'id'
];
$_SESSION
[
'gateway_type'
]
=
$gatewayModelResult
[
'type_id'
];
//日志记录
$this
->
logRecord
->
setGatewayId
(
$gatewayId
);
...
...
@@ -263,8 +267,9 @@ class AccessController extends Controller
$order
->
setOnlineTime
(
time
());
if
(
$offlineReason
==
1
)
{
}
else
{
$orderState
=
new
OfflineNetState
(
$order
);
}
else
{
$orderState
=
new
OfflinePowerState
(
$order
);
}
$remainTime
=
$orderState
->
getRemainChargerTime
();
...
...
application/controller/update/QueryController.php
0 → 100644
View file @
3baf527c
<?php
/**
* Created by PhpStorm.
* User: banice
* Date: 2018/9/17
* Time: 上午10:52
*/
namespace
Application\controller\update
;
use
Application\controller\Controller
;
use
Application\model\GatewayModel
;
use
Application\model\GatewayUpdateModel
;
use
GatewayWorker\Lib\Gateway
;
use
Lib\log\Log
;
class
QueryController
extends
Controller
{
protected
$parameterMap
=
[
'D1'
=>
[
'hardware_version'
=>
4
,
'software_version'
=>
4
,
]
];
public
function
__construct
(
string
$clientId
,
string
$message
,
string
$command
)
{
parent
::
__construct
(
$clientId
,
$message
,
$command
);
}
public
function
__destruct
()
{
parent
::
__destruct
();
}
/**
* @throws \Exception
*/
public
function
check
()
{
$hardwareVersion
=
$this
->
request
->
get
(
'hardware_version'
);
$softwareVersion
=
$this
->
request
->
get
(
'software_version'
);
$response
=
''
;
Log
::
debug
(
'session'
,
Gateway
::
getSession
(
$this
->
clientId
));
$gatewayType
=
isset
(
$_SESSION
[
'gateway_type'
])
?
$_SESSION
[
'gateway_type'
]
:
false
;
if
(
$gatewayType
===
false
)
{
Log
::
debug
(
'can not find gateway type'
);
return
;
}
$gatewayUpdateModel
=
new
GatewayUpdateModel
();
$updateInfo
=
$gatewayUpdateModel
->
getColumns
([
'hardware_version'
,
'software_version'
],
'gateway_type = '
.
$gatewayType
);
if
(
count
(
$updateInfo
)
!==
0
)
{
$updateHardwareVersion
=
$updateInfo
[
'hardware_version'
];
// $updateSoftwareVersion = sprintf('%08x', $updateInfo['software_version']);
$updateSoftwareVersion
=
sprintf
(
$updateInfo
[
'software_version'
]);
if
(
$updateHardwareVersion
==
$hardwareVersion
&&
$updateSoftwareVersion
==
$softwareVersion
)
{
$returnCode
=
'10'
;
}
else
{
//todo 检查下载资源
$returnCode
=
'12'
;
$host
=
getenv
(
'DOWNLOAD_HOST'
);
if
(
$host
===
false
)
{
throw
new
\Exception
(
'can not find download host'
);
}
$downloadUrl
=
$host
.
'/update/'
.
$updateHardwareVersion
.
$updateSoftwareVersion
.
'.bin'
;
$urlHex
=
''
;
for
(
$i
=
0
;
$i
<
strlen
(
$downloadUrl
);
$i
++
)
{
$hex
=
sprintf
(
'%02x'
,
ord
(
$downloadUrl
[
$i
]));
$urlHex
.=
$hex
;
}
$this
->
response
->
send
(
'd1'
,
$returnCode
.
$updateHardwareVersion
.
$updateSoftwareVersion
.
$urlHex
);
}
}
}
}
\ No newline at end of file
application/model/GatewayUpdateModel.php
0 → 100644
View file @
3baf527c
<?php
/**
* Created by PhpStorm.
* User: banice
* Date: 2018/9/17
* Time: 上午11:10
*/
namespace
Application\model
;
class
GatewayUpdateModel
extends
Model
{
protected
$table
=
'gateway_update'
;
}
\ No newline at end of file
application/route/Api.php
View file @
3baf527c
...
...
@@ -43,7 +43,7 @@ class Api
$this
->
add
(
'35'
,
'card\charger\OverController@over'
);
$this
->
add
(
'0E'
,
'setting\DeviceMacController@getAll'
);
$this
->
add
(
'D1'
,
'update\QueryController@check'
);
}
...
...
lib/cdz/order/state/ChargerState.php
View file @
3baf527c
...
...
@@ -202,13 +202,15 @@ class ChargerState extends State
$orderExceptionModel
->
insertRow
([
'order_id'
=>
$this
->
order
->
getId
(),
'state'
=>
StateCode
::
PORT_CHARGER
.
StateCode
::
FINISH_FULL
,
'desc'
=>
'订单充
电
自停'
,
'desc'
=>
'订单充
满
自停'
,
'created_at'
=>
$this
->
nowDate
,
]);
Log
::
debug
(
'充满自停状态'
);
$chargerFullMessage
=
new
ChargerFullMessage
();
$chargerFullMessage
->
setEndTime
(
$this
->
nowDate
);
$chargerFullMessage
->
setStartTime
(
$this
->
order
->
getStartTime
(
));
$chargerFullMessage
->
setStartTime
(
date
(
'Y-m-d H:i:s'
,
$this
->
order
->
getStartTime
()
));
$chargerFullMessage
->
setPurchaseTime
(
$this
->
order
->
getPurchaseTime
());
$chargerFullMessage
->
setUserId
(
$this
->
order
->
getUserId
());
$chargerFullMessage
->
setRemark
(
$chargerFullMessage
->
getRemark
()
.
'\n'
.
sprintf
(
'%012x'
,
$this
->
order
->
getId
()));
...
...
lib/log/Log.php
View file @
3baf527c
...
...
@@ -51,6 +51,7 @@ class Log
}
else
{
static
::
$log
=
new
Logger
(
$logName
);
static
::
$log
->
pushHandler
(
new
RotatingFileHandler
(
$logName
,
30
));
}
}
...
...
@@ -63,13 +64,7 @@ class Log
public
static
function
__callStatic
(
$name
,
$arguments
)
{
$gatewayMac
=
isset
(
$_SESSION
[
'gateway_mac'
])
?
$_SESSION
[
'gateway_mac'
]
:
'null mac'
;
$handle
=
new
RotatingFileHandler
(
self
::
LOG_NAME
,
30
);
$output
=
"[%datetime%] [%
$gatewayMac
%].%level_name%: %message% %context% %extra%
\n
"
;
$handle
->
setFormatter
(
new
LineFormatter
(
$output
,
'Y-m-d H:i:s'
));
static
::
bootLog
();
return
call_user_func_array
([
static
::
$log
,
$name
],
$arguments
);
...
...
lib/remote/api/message/ChargerFullMessage.php
View file @
3baf527c
...
...
@@ -24,6 +24,11 @@ class ChargerFullMessage extends Message
private
$remark
=
'温馨提示:您的爱车已停止充电,如有疑问您可以在公众号后台留言或直接拨打客服热线进行咨询。
感谢您的使用'
;
public
function
__construct
()
{
$this
->
templateId
=
getenv
(
'MESSAGE_CHARGER_FULL'
);
}
public
function
getPushJson
()
:
string
{
...
...
@@ -64,13 +69,6 @@ class ChargerFullMessage extends Message
return
$this
->
templateId
;
}
/**
* @param string $templateId
*/
public
function
setTemplateId
(
string
$templateId
)
:
void
{
$this
->
templateId
=
$templateId
;
}
/**
* @return string
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment