Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cdz_nb
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_nb
Commits
390604ad
You need to sign in or sign up before continuing.
Commit
390604ad
authored
Nov 20, 2018
by
banice
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
解决断电时间恢复
parent
7bc74168
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
74 additions
and
15 deletions
+74
-15
app/Http/Controllers/GatewayController.php
+11
-0
application/controller/business/power/ShutdownController.php
+23
-1
application/controller/setting/SettingController.php
+3
-1
application/route/Api.php
+1
-1
lib/Api.php
+1
-3
lib/cdz/order/state/ChargerState.php
+0
-5
lib/station/gateway/Gateway.php
+31
-0
routes/web.php
+1
-1
src/BroadcastToAgent.php
+3
-3
No files found.
app/Http/Controllers/GatewayController.php
View file @
390604ad
...
...
@@ -14,6 +14,7 @@ use Illuminate\Support\Facades\DB;
use
Lib\Session
;
use
Lib\station\gateway\Gateway
;
use
Lib\station\gateway\port\Port
;
use
Src\BroadcastToAgent
;
class
GatewayController
extends
Controller
{
...
...
@@ -44,6 +45,16 @@ class GatewayController extends Controller
$redis
->
exec
();
$broadcastToAgent
=
new
BroadcastToAgent
();
$broadcastToAgent
->
broadcast
([
'notice_exception_code'
=>
15
,
'gateway_id'
=>
Session
::
get
(
'gateway_id'
),
'station_id'
=>
Session
::
get
(
'station_id'
),
'station_name'
=>
Session
::
get
(
'station_name'
),
'gateway_mac'
=>
Session
::
get
(
'gateway_mac'
),
]);
}
...
...
application/controller/business/power/ShutdownController.php
View file @
390604ad
...
...
@@ -10,13 +10,16 @@ namespace Application\controller\business\power;
use
Application\controller\Controller
;
use
GuzzleHttp\Client
;
use
Illuminate\Support\Facades\Log
;
use
Lib\Session
;
class
ShutdownController
extends
Controller
{
protected
$parameterMap
=
[
'0
4
'
=>
[]
'0
F
'
=>
[]
];
public
function
__construct
(
string
$clientId
,
string
$message
,
string
$command
)
...
...
@@ -27,6 +30,25 @@ class ShutdownController extends Controller
public
function
shutdown
()
{
Log
::
debug
(
'offline'
);
$gatewayId
=
Session
::
get
(
'gateway_id'
);
if
(
filled
(
$gatewayId
))
{
$client
=
new
Client
([
'http_errors'
=>
false
,
]);
$response
=
$client
->
request
(
'POST'
,
route
(
'deviceStateOffline'
),
[
'form_params'
=>
[
'ids'
=>
[
$gatewayId
]],
]);
if
(
$response
->
getStatusCode
()
===
200
)
{
Log
::
info
(
'gateway offline by 0F'
,
compact
(
'gatewayId'
));
}
else
{
Log
::
error
(
'gateway offline by 0F request fail'
);
}
}
}
...
...
application/controller/setting/SettingController.php
View file @
390604ad
...
...
@@ -60,7 +60,9 @@ class SettingController extends Controller
$powerSaturateInvertalTime
=
$idConfigsValue
[
'7'
];
$extraTime
=
$idConfigsValue
[
'8'
];
$powerLowerLimit
=
getenv
(
'LOW_POWER_LIMIT'
);
// $powerLowerLimit = getenv('LOW_POWER_LIMIT');
$powerLowerLimit
=
30
;
$detectTime
=
5
;
$afterFormat
=
$this
->
adaptor
([
[
$invertalTime
,
4
],
...
...
application/route/Api.php
View file @
390604ad
...
...
@@ -33,7 +33,7 @@ class Api
$this
->
add
(
'08'
,
'business\port\OnlineController@online'
);
$this
->
add
(
'09'
,
'business\port\OfflineController@offline'
);
//
$this->add('0F', 'business\power\ShutdownController@shutdown');
$this
->
add
(
'0F'
,
'business\power\ShutdownController@shutdown'
);
$this
->
add
(
'0A'
,
'setting\SettingController@get'
);
$this
->
add
(
'31'
,
'card\PayRuleController@get'
);
...
...
lib/Api.php
View file @
390604ad
...
...
@@ -21,8 +21,6 @@ class Api
public
function
boot
()
{
Log
::
debug
(
'boot'
);
$this
->
add
(
'01'
,
'accept\CertifyController@certify'
);
$this
->
add
(
'00'
,
'HeartController@break'
);
$this
->
add
(
'02'
,
'accept\AccessController@request'
);
...
...
@@ -42,7 +40,7 @@ class Api
$this
->
add
(
'08'
,
'business\port\OnlineController@online'
);
$this
->
add
(
'09'
,
'business\port\OfflineController@offline'
);
//
$this->add('0F', 'business\power\ShutdownController@shutdown');
$this
->
add
(
'0F'
,
'business\power\ShutdownController@shutdown'
);
$this
->
add
(
'0A'
,
'setting\SettingController@get'
);
$this
->
add
(
'31'
,
'card\PayRuleController@get'
);
...
...
lib/cdz/order/state/ChargerState.php
View file @
390604ad
...
...
@@ -206,7 +206,6 @@ class ChargerState extends State
'created_at'
=>
$this
->
nowDate
,
]);
Log
::
debug
(
'充满自停状态'
);
$chargerFullMessage
=
new
ChargerFullMessage
();
$chargerFullMessage
->
setEndTime
(
$this
->
nowDate
);
...
...
@@ -237,10 +236,6 @@ class ChargerState extends State
* 推送用户信息
* 发布延时任务十分钟后检测端口
*
*
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \AMQPConnectionException
* @throws \AMQPExchangeException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public
function
toShedState
()
...
...
lib/station/gateway/Gateway.php
View file @
390604ad
...
...
@@ -9,6 +9,10 @@
namespace
Lib\station\gateway
;
use
Application\model\OrderExceptionModel
;
use
Illuminate\Support\Facades\DB
;
use
Lib\cdz\order\Order
;
use
Lib\cdz\order\save\OrderSaveRedis
;
use
Lib\Session
;
use
Lib\station\gateway\port\Port
;
use
Illuminate\Support\Facades\Log
;
...
...
@@ -38,6 +42,9 @@ class Gateway
Log
::
debug
(
$portsMacId
);
$portsId
=
array_values
(
$portsMacId
);
$redis
=
app
(
'Redis'
);
$offlineTime
=
time
();
$date
=
date
(
'Y-m-d H:i:s'
);
if
(
$redis
instanceof
\Redis
)
{
...
...
@@ -45,12 +52,36 @@ class Gateway
$port
=
new
Port
();
$orderExceptionModel
=
[];
foreach
(
$portsId
as
$portId
)
{
$port
->
setPortId
(
$portId
);
$port
->
setState
(
10
);
$port
->
updatePortState
();
$usingOrderId
=
$port
->
getPortUsingOrderId
();
Log
::
debug
(
$usingOrderId
.
'using'
);
if
(
filled
(
$usingOrderId
))
{
$order
=
new
Order
(
$usingOrderId
);
$order
->
setOfflineTime
(
$offlineTime
);
$orderRedis
=
new
OrderSaveRedis
(
$order
);
$orderRedis
->
save
([
'offlineTime'
]);
array_push
(
$orderExceptionModel
,
[
'order_id'
=>
$usingOrderId
,
'state'
=>
10
,
'desc'
=>
'网关离线,订单离线'
,
'created_at'
=>
$date
,
]);
}
}
DB
::
table
(
'wx_charger_orders_exception'
)
->
insert
(
$orderExceptionModel
);
}
...
...
routes/web.php
View file @
390604ad
...
...
@@ -46,7 +46,7 @@ $router->post('gateway/offline', 'GatewayController@offline');
$router
->
get
(
'gateway'
,
'SessionController@getSession'
);
$router
->
post
(
'gateway/offline'
,
'device\StateController@offline'
);
$router
->
post
(
'gateway/offline'
,
[
'uses'
=>
'device\StateController@offline'
,
'as'
=>
'deviceStateOffline'
]
);
...
...
src/BroadcastToAgent.php
View file @
390604ad
...
...
@@ -10,6 +10,7 @@ namespace Src;
use
Lib\Gateway
;
use
Lib\Session
;
class
BroadcastToAgent
{
...
...
@@ -18,9 +19,8 @@ class BroadcastToAgent
public
function
__construct
()
{
if
(
isset
(
$_SESSION
[
'agent_id'
]))
{
$this
->
agentId
=
$_SESSION
[
'agent_id'
];
if
(
filled
(
Session
::
get
(
'agent_id'
)))
{
$this
->
agentId
=
Session
::
get
(
'agent_id'
);
}
}
...
...
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