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
30187ca0
Commit
30187ca0
authored
May 05, 2019
by
杨苏杭
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
封存
parent
7105ff2d
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
82 additions
and
63 deletions
+82
-63
application/controller/accept/AccessController.php
+18
-13
application/controller/business/port/OfflineController.php
+21
-18
application/controller/business/port/OnlineController.php
+10
-9
application/controller/setting/DeviceMacController.php
+11
-5
lib/cdz/order/state/OfflineNetState.php
+7
-11
lib/cdz/order/state/OfflinePowerState.php
+5
-3
lib/cdz/order/state/ShedState.php
+10
-4
No files found.
application/controller/accept/AccessController.php
View file @
30187ca0
...
...
@@ -70,7 +70,7 @@ class AccessController extends Controller
'nb_device_id'
],
'mac_address='
.
$mac
);
if
(
$gatewayModelResult
==
false
)
{
if
(
$gatewayModelResult
==
false
)
{
Gateway
::
closeClient
(
$this
->
clientId
);
return
;
}
...
...
@@ -96,15 +96,15 @@ class AccessController extends Controller
'name'
,
],
'id='
.
$stationId
);
if
(
isset
(
$stationData
[
'park_id'
])
&&
isset
(
$stationData
[
'name'
])
)
{
if
(
isset
(
$stationData
[
'park_id'
])
&&
isset
(
$stationData
[
'name'
])
)
{
$parkId
=
$stationData
[
'park_id'
];
Session
::
update
(
'station_name'
,
$stationData
[
'name'
]);
if
(
isset
(
$parkId
)
)
{
if
(
isset
(
$parkId
)
)
{
$parkModel
=
new
ParkModel
();
Session
::
update
(
'park_id'
,
$parkId
);
$agentId
=
$parkModel
->
getColumn
(
'agent_id'
,
'id='
.
$parkId
);
if
(
isset
(
$agentId
)
)
{
if
(
isset
(
$agentId
)
)
{
Session
::
update
(
'agent_id'
,
$agentId
);
}
...
...
@@ -170,7 +170,7 @@ class AccessController extends Controller
$portMacState
=
[];
if
(
strlen
(
$this
->
message
)
<
(
12
*
2
+
9
*
2
*
$count
)
)
{
if
(
strlen
(
$this
->
message
)
<
(
12
*
2
+
9
*
2
*
$count
)
)
{
Log
::
debug
(
'fail'
);
return
;
...
...
@@ -184,7 +184,7 @@ class AccessController extends Controller
$portMacState
[
$mac
]
=
hexdec
(
$state
);
}
if
(
filled
(
Session
::
get
(
'port_mac_id'
))
==
false
)
{
if
(
filled
(
Session
::
get
(
'port_mac_id'
))
==
false
)
{
Log
::
error
(
'can not get port_mac_id'
);
...
...
@@ -200,7 +200,7 @@ class AccessController extends Controller
foreach
(
$portMacState
as
$mac
=>
$state
)
{
if
(
isset
(
$portsMacId
[
$mac
])
)
{
if
(
isset
(
$portsMacId
[
$mac
])
)
{
array_push
(
$portsId
,
$portsMacId
[
$mac
]);
}
}
...
...
@@ -210,7 +210,7 @@ class AccessController extends Controller
foreach
(
$portMacState
as
$mac
=>
$state
)
{
$portId
=
isset
(
$portsMacId
[
$mac
])
?
$portsMacId
[
$mac
]
:
false
;
if
(
$portId
===
false
)
{
if
(
$portId
===
false
)
{
continue
;
}
...
...
@@ -229,7 +229,7 @@ class AccessController extends Controller
$deviceModel
=
new
DeviceModel
();
if
(
filled
(
Session
::
get
(
'port_logic_id'
))
)
{
if
(
filled
(
Session
::
get
(
'port_logic_id'
))
)
{
Session
::
update
(
'port_logic_id'
,
Session
::
get
(
'port_logic_id'
)
+
$portsLogicId
);
}
else
{
...
...
@@ -256,18 +256,20 @@ class AccessController extends Controller
$port
->
setPortId
(
$portId
);
$orderId
=
$port
->
getPortUsingOrderId
();
if
(
$orderId
==
false
||
$orderId
==
''
)
{
if
(
$orderId
==
false
||
$orderId
==
''
)
{
continue
;
}
$order
->
setId
(
$orderId
);
if
(
$order
->
getOrderCache
(
app
(
'Redis'
))
==
false
)
{
if
(
$order
->
getOrderCache
(
app
(
'Redis'
))
==
false
)
{
continue
;
}
$order
->
setOnlineTime
(
time
());
if
(
$offlineReason
==
0
)
{
Log
::
debug
(
$offlineReason
);
if
(
$offlineReason
==
0
)
{
$orderState
=
new
OfflineNetState
(
$order
);
}
else
{
$orderState
=
new
OfflinePowerState
(
$order
);
...
...
@@ -276,11 +278,14 @@ class AccessController extends Controller
$remainTime
=
$orderState
->
getRemainChargerTime
();
if
(
$remainTime
>
0
)
{
if
(
$remainTime
>
0
)
{
$logicNum
=
sprintf
(
'%02x'
,
$order
->
getPortLogicId
());
$orderId
=
sprintf
(
'%012x'
,
$order
->
getId
());
$time
=
sprintf
(
'%04x'
,
$remainTime
);
Log
::
debug
(
'remain_time'
.
$remainTime
);
Log
::
debug
(
$orderId
);
array_push
(
$responseOrder
,
$logicNum
.
$orderId
.
$time
);
}
...
...
application/controller/business/port/OfflineController.php
View file @
30187ca0
...
...
@@ -12,6 +12,7 @@ namespace Application\controller\business\port;
use
Application\controller\Controller
;
use
Application\model\ExceptionModel
;
use
Illuminate\Support\Facades\Log
;
use
Lib\Session
;
use
Lib\StateCode
;
use
Lib\station\gateway\port\Port
;
use
Src\BroadcastToAgent
;
...
...
@@ -59,44 +60,46 @@ class OfflineController extends Controller
}
if
(
!
isset
(
$_SESSION
[
'port_mac_id'
])
)
{
if
(
blank
(
Session
::
get
(
'port_mac_id'
))
)
{
return
;
}
$portsMacId
=
$_SESSION
[
'port_mac_id'
]
;
$portsMacId
=
Session
::
get
(
'port_mac_id'
)
;
$port
=
new
Port
();
$exceptionModel
=
new
ExceptionModel
();
if
(
!
(
isset
(
$_SESSION
[
'station_id'
])
||
!
isset
(
$_SESSION
[
'gateway_id'
]))
)
{
if
(
blank
(
Session
::
get
(
'station_id'
))
||
blank
(
Session
::
get
(
'gateway_id'
))
)
{
return
;
}
$broadcastToAgent
=
new
BroadcastToAgent
();
$offlinePorts
=
[];
$portIdName
=
Session
::
get
(
'port_id_name'
);
foreach
(
$portsLogicMac
as
$portLogic
=>
$portMac
)
{
if
(
isset
(
$portsMacId
[
$portMac
])
)
{
if
(
isset
(
$portsMacId
[
$portMac
])
)
{
$portId
=
$portsMacId
[
$portMac
];
if
(
isset
(
$_SESSION
[
'port_id_name'
][
$portId
])
)
{
array_push
(
$offlinePorts
,
[
'name'
=>
$
_SESSION
[
'port_id_name'
]
[
$portId
],
'id'
=>
$portId
]);
if
(
isset
(
$portIdName
[
$portId
])
)
{
array_push
(
$offlinePorts
,
[
'name'
=>
$
portIdName
[
$portId
],
'id'
=>
$portId
]);
}
Log
::
debug
(
'offline port_id'
.
$portId
);
$port
->
setPortId
(
$portId
);
$port
->
setStationId
(
$_SESSION
[
'station_id'
]
);
$port
->
setGatewayId
(
$_SESSION
[
'gateway_id'
]
);
$port
->
setStationId
(
Session
::
get
(
'station_id'
)
);
$port
->
setGatewayId
(
Session
::
get
(
'gateway_id'
)
);
$port
->
setState
(
StateCode
::
PORT_OFFLINE
);
$port
->
updatePortState
();
// 记录口子离线
$exceptionModel
->
insertRow
([
'message'
=>
'口子离线'
,
'gateway_id'
=>
isset
(
$_SESSION
[
'gateway_id'
])
?
$_SESSION
[
'gateway_id'
]
:
''
,
'station_id'
=>
isset
(
$_SESSION
[
'station_id'
])
?
$_SESSION
[
'station_id'
]
:
''
,
'port_id'
=>
$portId
,
'message'
=>
'口子离线'
,
'gateway_id'
=>
Session
::
get
(
'gateway_id'
)
,
'station_id'
=>
Session
::
get
(
'station_id'
)
,
'port_id'
=>
$portId
,
'created_at'
=>
date
(
'Y-m-d H:i:s'
),
'type'
=>
1
,
'type'
=>
1
,
]);
}
...
...
@@ -105,11 +108,11 @@ class OfflineController extends Controller
$broadcastToAgent
->
broadcast
([
'notice_exception_code'
=>
StateCode
::
PORT_OFFLINE
,
'ports'
=>
$offlinePorts
,
'
station_name'
=>
$_SESSION
[
'station_name'
]
,
'
gateway_name'
=>
$_SESSION
[
'gateway_name'
]
,
'station_
id'
=>
$_SESSION
[
'station_id'
]
,
'gateway_id'
=>
$_SESSION
[
'gateway_id'
]
,
'ports'
=>
$offlinePorts
,
'
gateway_name'
=>
Session
::
get
(
'gateway_name'
)
,
'
station_id'
=>
Session
::
get
(
'station_id'
)
,
'station_
name'
=>
Session
::
get
(
'station_name'
)
,
'gateway_id'
=>
Session
::
get
(
'gateway_id'
)
,
]);
}
...
...
application/controller/business/port/OnlineController.php
View file @
30187ca0
...
...
@@ -11,6 +11,7 @@ namespace Application\controller\business\port;
use
Application\controller\Controller
;
use
Application\model\ExceptionModel
;
use
Lib\Session
;
use
Lib\StateCode
;
use
Lib\station\gateway\port\Port
;
...
...
@@ -53,36 +54,36 @@ class OnlineController extends Controller
}
if
(
!
isset
(
$_SESSION
[
'port_mac_id'
]))
{
if
(
blank
(
Session
::
get
(
'port_mac_id'
))
)
{
return
;
}
$portsMacId
=
$_SESSION
[
'port_mac_id'
]
;
$portsMacId
=
Session
::
get
(
'port_mac_id'
)
;
$port
=
new
Port
();
$exceptionModel
=
new
ExceptionModel
();
if
(
!
(
isset
(
$_SESSION
[
'station_id'
])
&&
isset
(
$_SESSION
[
'gateway_id'
]))
)
{
if
(
!
(
blank
(
Session
::
get
(
'station_id'
))
&&
!
blank
(
Session
::
get
(
'gateway_id'
)))
)
{
return
;
}
foreach
(
$portsLogicMac
as
$portLogic
=>
$portMac
)
{
if
(
isset
(
$portsMacId
[
$portMac
])
)
{
if
(
isset
(
$portsMacId
[
$portMac
])
)
{
$portId
=
$portsMacId
[
$portMac
];
$port
->
setPortId
(
$portId
);
$port
->
setStationId
(
$_SESSION
[
'station_id'
]
);
$port
->
setGatewayId
(
$_SESSION
[
'gateway_id'
]
);
$port
->
setStationId
(
Session
::
get
(
'station_id'
)
);
$port
->
setGatewayId
(
Session
::
get
(
'gateway_id'
)
);
$port
->
setState
(
StateCode
::
PORT_ONLINE
);
$port
->
updatePortState
();
// 记录口子上线
$exceptionModel
->
insertRow
([
'port_id'
=>
$portId
,
'gateway_id'
=>
isset
(
$_SESSION
[
'gateway_id'
])
?
$_SESSION
[
'gateway_id'
]
:
''
,
'station_id'
=>
isset
(
$_SESSION
[
'station_id'
])
?
$_SESSION
[
'station_id'
]
:
''
,
'port_id'
=>
$portId
,
'gateway_id'
=>
Session
::
get
(
'gateway_id'
)
,
'station_id'
=>
Session
::
get
(
'station_id'
)
,
'created_at'
=>
date
(
'Y-m-d H:i:s'
),
]);
...
...
application/controller/setting/DeviceMacController.php
View file @
30187ca0
...
...
@@ -21,31 +21,37 @@ class DeviceMacController extends Controller
protected
$parameterMap
=
[
'0E'
=>
[
'logic'
=>
1
,
]
];
public
function
getAll
()
{
$logic
=
hexdec
(
$this
->
request
->
get
(
'logic'
));
$gatewayId
=
Session
::
get
(
'gateway_id'
);
if
(
$gatewayId
!==
''
)
{
if
(
$gatewayId
!==
''
)
{
$deviceModel
=
new
DeviceModel
();
$devicesMac
=
$deviceModel
->
getAllColumns
([
'device_mac'
],
'gateway_id='
.
$gatewayId
);
$totalCount
=
sprintf
(
'%02x'
,
count
(
$devicesMac
));
$devicesMac
=
array_slice
(
$devicesMac
,
$logic
,
3
);
$count
=
sprintf
(
'%02x'
,
count
(
$devicesMac
));
$count
=
count
(
$devicesMac
);
$tmp
=
[];
foreach
(
$devicesMac
as
$deviceMac
)
{
array_push
(
$tmp
,
$deviceMac
->
device_mac
);
}
$devicesMacStr
=
implode
(
''
,
$tmp
);
$this
->
response
->
send
(
'0e'
,
sprintf
(
'%02x'
,
$count
)
.
$devicesMacStr
);
$logic
=
sprintf
(
'%02x'
,
$logic
);
$this
->
response
->
send
(
'0e'
,
$logic
.
$count
.
$totalCount
.
$devicesMacStr
);
}
...
...
lib/cdz/order/state/OfflineNetState.php
View file @
30187ca0
...
...
@@ -27,7 +27,7 @@ class OfflineNetState extends State
{
parent
::
__construct
(
$order
);
if
(
$this
->
order
->
getIsRefund
()
===
1
)
{
if
(
$this
->
order
->
getIsRefund
()
===
1
)
{
//已经退款 下发结束充电命令
//$this->order->stop($this->order,$_SESSION['client_id'],43);
$this
->
remainChargerTime
=
0
;
...
...
@@ -38,19 +38,15 @@ class OfflineNetState extends State
$startTime
=
$this
->
order
->
getStartTime
();
$stateCode
=
$this
->
order
->
getStateCode
();
if
(
$startTime
===
''
)
{
Log
::
debug
(
'time equal purchase time'
);
Log
::
debug
(
$startTime
);
if
(
$startTime
===
''
)
{
$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
=
$purchaseTime
*
60
-
((
int
)
$this
->
order
->
getOnlineTime
()
-
$startTime
);
$this
->
remainChargerTime
=
ceil
(
$this
->
remainChargerTime
/
60
);
...
...
@@ -72,7 +68,7 @@ class OfflineNetState extends State
public
function
toChargerState
()
{
if
(
$this
->
order
->
getIsRefund
()
===
1
)
{
if
(
$this
->
order
->
getIsRefund
()
===
1
)
{
//已经退款 下发结束充电命令
$this
->
order
->
stop
(
$this
->
order
,
$_SESSION
[
'client_id'
],
43
);
return
;
...
...
@@ -102,7 +98,7 @@ class OfflineNetState extends State
*/
public
function
toShedState
()
{
if
(
$this
->
remainChargerTime
>
0
)
{
if
(
$this
->
remainChargerTime
>
0
)
{
$this
->
publishPortShed
(
$this
->
order
);
}
...
...
lib/cdz/order/state/OfflinePowerState.php
View file @
30187ca0
...
...
@@ -23,7 +23,7 @@ class OfflinePowerState extends State
public
function
__construct
(
Order
$order
)
{
parent
::
__construct
(
$order
);
if
(
$this
->
order
->
getIsRefund
()
===
1
)
{
if
(
$this
->
order
->
getIsRefund
()
===
1
)
{
//已经退款 下发结束充电命令
//$this->order->stop($this->order,$_SESSION['client_id'],43);
$this
->
remainChargerTime
=
0
;
...
...
@@ -33,7 +33,9 @@ class OfflinePowerState extends State
$offlineTime
=
$this
->
order
->
getOfflineTime
();
$startTime
=
$this
->
order
->
getStartTime
();
if
(
$startTime
===
''
||
$this
->
order
->
getOfflineTime
()
==
'0'
)
{
Log
::
debug
(
$startTime
.
'power off'
);
if
(
$startTime
===
''
||
$this
->
order
->
getOfflineTime
()
==
'0'
)
{
$this
->
remainChargerTime
=
(
int
)(
$this
->
order
->
getPurchaseTime
());
}
else
{
...
...
@@ -65,7 +67,7 @@ class OfflinePowerState extends State
public
function
toChargerState
()
{
if
(
$this
->
order
->
getIsRefund
()
===
1
)
{
if
(
$this
->
order
->
getIsRefund
()
===
1
)
{
//已经退款 下发结束充电命令
//$this->order->stop($this->order,$_SESSION['client_id'],43);
$this
->
remainChargerTime
=
0
;
...
...
lib/cdz/order/state/ShedState.php
View file @
30187ca0
...
...
@@ -65,7 +65,7 @@ class ShedState extends State
$finishByUserMessage
->
setOrderAmount
(
$this
->
order
->
getPayAmount
());
$sendMessage
=
new
SendMessage
();
if
(
$sendMessage
->
request
(
$finishByUserMessage
)
==
false
)
{
if
(
$sendMessage
->
request
(
$finishByUserMessage
)
==
false
)
{
Log
::
error
(
'send finish by user message fail'
);
}
...
...
@@ -116,7 +116,7 @@ class ShedState extends State
$sendMessage
=
new
SendMessage
();
if
(
$sendMessage
->
request
(
$chargerReloadMessage
)
===
false
)
{
if
(
$sendMessage
->
request
(
$chargerReloadMessage
)
===
false
)
{
Log
::
error
(
'send order reload message fail'
);
}
...
...
@@ -200,7 +200,7 @@ class ShedState extends State
$sendMessage
=
new
SendMessage
();
if
(
$sendMessage
->
request
(
$shedTimeoutMessage
)
===
false
)
{
if
(
$sendMessage
->
request
(
$shedTimeoutMessage
)
===
false
)
{
Log
::
error
(
'send shed timeout message fail'
);
}
...
...
@@ -259,7 +259,7 @@ class ShedState extends State
$chargerTimeoutMessage
->
setStationName
(
$this
->
order
->
getStationName
());
$sendMessage
=
new
SendMessage
();
if
(
$sendMessage
->
request
(
$chargerTimeoutMessage
)
===
false
)
{
if
(
$sendMessage
->
request
(
$chargerTimeoutMessage
)
===
false
)
{
Log
::
error
(
'shed state order send charger timeout message fail'
);
}
...
...
@@ -272,5 +272,10 @@ class ShedState extends State
// TODO: Implement stopFail() method.
}
public
function
toRefundFinish
()
{
}
}
\ No newline at end of file
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