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
93410bf8
Commit
93410bf8
authored
Oct 16, 2018
by
banice
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复开始充电无开始用电量问题
parent
29a8f66c
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
72 additions
and
18 deletions
+72
-18
.idea/workspace.xml
+0
-0
application/controller/accept/AccessController.php
+1
-1
application/controller/business/charger/StartController.php
+4
-11
application/controller/business/power/PowerController.php
+8
-0
application/controller/update/QueryController.php
+27
-0
application/route/Api.php
+2
-0
lib/cdz/card_order/state/ChargerState.php
+6
-0
lib/cdz/order/state/ChargerState.php
+1
-1
lib/cdz/order/state/OfflineNetState.php
+9
-2
lib/cdz/order/state/OfflinePowerState.php
+2
-0
lib/cdz/order/state/WaitingState.php
+7
-3
lib/rabbitmq/PublishPortShed.php
+0
-0
vendor/workerman/workerman/Protocols/Bintohex.php
+5
-0
No files found.
.idea/workspace.xml
View file @
93410bf8
This diff is collapsed.
Click to expand it.
application/controller/accept/AccessController.php
View file @
93410bf8
...
...
@@ -357,7 +357,7 @@ class AccessController extends Controller
}
$order
->
setOnlineTime
(
time
());
if
(
$offlineReason
==
1
)
{
if
(
$offlineReason
==
0
)
{
$orderState
=
new
OfflineNetState
(
$order
);
}
else
{
$orderState
=
new
OfflinePowerState
(
$order
);
...
...
application/controller/business/charger/StartController.php
View file @
93410bf8
...
...
@@ -49,9 +49,7 @@ class StartController extends Controller
$this
->
logRecord
->
setOrderId
(
$orderId
);
$capacity
=
hexdec
(
$this
->
getRequest
()
->
get
(
'capacity'
));
Log
::
debug
(
$this
->
getRequest
()
->
get
(
'capacity'
));
Log
::
debug
(
'order_id-->'
.
$orderId
);
Log
::
debug
(
'capacity-->'
.
$capacity
);
if
(
$type
==
1
)
{
...
...
@@ -87,29 +85,24 @@ class StartController extends Controller
}
}
$lastState
=
$order
->
getStateCode
();
$orderState
=
new
WaitingState
(
$order
);
// break;
// case StateCode::PORT_CHARGER;
// $orderState = new ChargerState($order);
// break;
//
// }
$portId
=
$orderState
->
getOrder
()
->
getPortId
();
$this
->
logRecord
->
setPortId
(
$portId
);
switch
(
$state
)
{
case
StateCode
::
PORT_CHARGER
:
$orderState
->
toChargerState
();
break
;
case
StateCode
::
PORT_EXCEPTION
:
$orderState
->
toExceptionState
();
break
;
case
StateCode
::
PORT_SHED
:
Log
::
debug
(
'port_shed'
);
$orderState
->
toShedState
();
break
;
case
StateCode
::
FINISH_EXCEED
:
Log
::
debug
(
'exceed'
);
$orderState
->
toPowerExceedState
();
break
;
...
...
application/controller/business/power/PowerController.php
View file @
93410bf8
...
...
@@ -111,6 +111,7 @@ class PowerController extends Controller
public
function
plural
()
{
//todo 最近的用电量作为结束用电量更新
$logicId
=
hexdec
(
$this
->
request
->
get
(
'logic_id'
));
$startTime
=
hexdec
(
$this
->
request
->
get
(
'start_time'
));
$intervalTime
=
hexdec
(
$this
->
request
->
get
(
'interval_time'
));
...
...
@@ -170,6 +171,13 @@ class PowerController extends Controller
]);
$startTime
+=
$intervalTime
;
//更新结束充电用电量
if
(
$i
===
(
$count
-
1
))
{
$orderModel
=
new
OrderModel
();
$orderModel
->
update
([
'end_capacity'
=>
hexdec
(
$capacitys
[
$i
]),
],
'id = '
.
$orderId
);
}
}
}
else
{
...
...
application/controller/update/QueryController.php
View file @
93410bf8
...
...
@@ -10,6 +10,7 @@ namespace Application\controller\update;
use
Application\controller\Controller
;
use
Application\model\DeviceModel
;
use
Application\model\GatewayModel
;
use
Application\model\GatewayUpdateModel
;
use
GatewayWorker\Lib\Gateway
;
...
...
@@ -23,6 +24,10 @@ class QueryController extends Controller
'D1'
=>
[
'hardware_version'
=>
4
,
'software_version'
=>
4
,
],
'CD'
=>
[
'hardware_version'
=>
4
,
'software_version'
=>
4
,
]
];
...
...
@@ -36,6 +41,19 @@ class QueryController extends Controller
parent
::
__destruct
();
}
public
function
currentVersion
()
{
$gatewayModel
=
new
GatewayModel
();
$gatewayModel
->
update
([
'hardware_version'
=>
$this
->
request
->
get
(
'hardware_version'
),
'software_version'
=>
$this
->
request
->
get
(
'software_version'
),
],
'id = '
.
$_SESSION
[
'gateway_id'
]);
}
/**
* @throws \Exception
*/
...
...
@@ -85,11 +103,20 @@ class QueryController extends Controller
$urlHex
.=
$hex
;
}
Log
::
debug
(
$updateSoftwareVersion
);
Log
::
debug
(
$updateHardwareVersion
);
Log
::
debug
(
$sign
);
Log
::
debug
(
$urlHex
);
$this
->
response
->
send
(
'd1'
,
$returnCode
.
$updateHardwareVersion
.
$updateSoftwareVersion
.
$sign
.
$urlHex
);
return
;
}
$this
->
response
->
send
(
'd1'
,
$returnCode
);
return
;
}
$this
->
response
->
send
(
'd1'
,
'11'
);
return
;
}
...
...
application/route/Api.php
View file @
93410bf8
...
...
@@ -45,6 +45,8 @@ class Api
$this
->
add
(
'0E'
,
'setting\DeviceMacController@getAll'
);
$this
->
add
(
'D1'
,
'update\QueryController@check'
);
$this
->
add
(
'CD'
,
'update\QueryController@currentVersion'
);
}
...
...
lib/cdz/card_order/state/ChargerState.php
View file @
93410bf8
...
...
@@ -352,6 +352,12 @@ class ChargerState extends State
}
public
function
toRefundFinish
()
{
Log
::
error
(
'charger state can not change to refund finish'
);
}
/**
* 关闭失败
*/
...
...
lib/cdz/order/state/ChargerState.php
View file @
93410bf8
...
...
@@ -300,7 +300,7 @@ class ChargerState extends State
Log
::
error
(
'send port shed message fail'
);
}
//
todo
publish 十分钟的延迟任务
// publish 十分钟的延迟任务
try
{
...
...
lib/cdz/order/state/OfflineNetState.php
View file @
93410bf8
...
...
@@ -9,6 +9,7 @@
namespace
Lib\cdz\order\state
;
use
GuzzleHttp\Psr7\LazyOpenStream
;
use
Lib\cdz\order\NoticePortShed
;
use
Lib\cdz\order\Order
;
use
Lib\log\Log
;
...
...
@@ -35,14 +36,20 @@ class OfflineNetState extends State
}
$startTime
=
$this
->
order
->
getStartTime
();
$stateCode
=
$this
->
order
->
getStateCode
();
if
(
$startTime
===
''
||
$this
->
order
->
getOfflineTime
()
==
'0'
)
{
if
(
$startTime
===
''
)
{
Log
::
debug
(
'time equal purchase time'
);
$this
->
remainChargerTime
=
(
int
)(
$this
->
order
->
getPurchaseTime
());
}
else
{
$purchaseTime
=
$this
->
order
->
getPurchaseTime
();
$this
->
remainChargerTime
=
$purchaseTime
*
60
-
((
int
)
$this
->
order
->
getOnlineTime
()
-
$startTime
);
Log
::
debug
(
'off net'
);
Log
::
debug
(
$this
->
order
->
getOnlineTime
());
Log
::
debug
(
$startTime
.
'start_time'
);
Log
::
debug
(
'remain charger time'
.
$this
->
remainChargerTime
);
Log
::
debug
(
'remain time'
.
ceil
(
$this
->
remainChargerTime
/
60
));
$this
->
remainChargerTime
=
ceil
(
$this
->
remainChargerTime
/
60
);
...
...
lib/cdz/order/state/OfflinePowerState.php
View file @
93410bf8
...
...
@@ -40,6 +40,8 @@ class OfflinePowerState extends State
$purchaseTime
=
$this
->
order
->
getPurchaseTime
();
$this
->
remainChargerTime
=
$purchaseTime
*
60
-
(
$offlineTime
-
$startTime
);
Log
::
debug
(
$offlineTime
.
'---'
.
$startTime
.
'-----'
.
$this
->
remainChargerTime
);
$this
->
order
->
setStartTime
(
strval
((
int
)
$startTime
+
((
int
)
time
()
-
(
int
)
$offlineTime
)));
$this
->
remainChargerTime
=
ceil
(
$this
->
remainChargerTime
/
60
);
$saveOrder
=
new
OrderSaveRedis
(
$this
->
order
);
...
...
lib/cdz/order/state/WaitingState.php
View file @
93410bf8
...
...
@@ -84,6 +84,8 @@ class WaitingState extends State
*/
public
function
toChargerState
()
:
void
{
//订单已经退款则直接结束
if
(
$this
->
order
->
getIsRefund
()
==
1
)
{
// 下发结束充电命令
...
...
@@ -130,13 +132,15 @@ class WaitingState extends State
}
//更新订单状态
$update
=
[
'is_charger'
=>
StateCode
::
PORT_CHARGER
,
'start_time'
=>
date
(
'Y-m-d H:i:s'
,
$this
->
order
->
getStartTime
()),
'start_capacity'
=>
$this
->
order
->
getStartCapacity
(),
];
//更新订单状态
if
(
$this
->
order
->
getStartCapacity
()
!==
-
2
)
{
$update
[
'start_capacity'
]
=
(
int
)
$this
->
order
->
getStartCapacity
();
}
$orderModel
=
new
OrderModel
();
$orderModel
->
update
(
$update
,
'id = '
.
$this
->
order
->
getId
());
...
...
lib/rabbitmq/PublishPortShed.php
View file @
93410bf8
vendor/workerman/workerman/Protocols/Bintohex.php
View file @
93410bf8
...
...
@@ -69,6 +69,11 @@ class Bintohex
Log
::
error
(
'encode error'
);
return
;
}
if
(
ctype_xdigit
(
$buffer
)
===
false
)
{
Log
::
error
(
'not hex fomat'
,
[
'buffer'
=>
$buffer
]);
return
;
}
return
pack
(
'H*'
,
bin2hex
(
hex2bin
(
$buffer
)));
}
...
...
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