Commit df104c15 by banice

测试版

parent 2abe7fc5
...@@ -28,6 +28,8 @@ MESSAGE_POWER_EXCEED=rdzTNQ7t4uRXkP0SkuwW10WH77A_CIgYFiJykXJ0utU ...@@ -28,6 +28,8 @@ MESSAGE_POWER_EXCEED=rdzTNQ7t4uRXkP0SkuwW10WH77A_CIgYFiJykXJ0utU
MESSAGE_FINISH_USER=f0DDXSxvRTbHyzkCnwnYijtgteFTdfdUR7J8REwTYJ8 MESSAGE_FINISH_USER=f0DDXSxvRTbHyzkCnwnYijtgteFTdfdUR7J8REwTYJ8
MESSAGE_PORT_SHED=C0LvfETe-1rCR_IhOydDGPTUwwYkrWZxgfwMsETrhw8 MESSAGE_PORT_SHED=C0LvfETe-1rCR_IhOydDGPTUwwYkrWZxgfwMsETrhw8
MESSAGE_CHARGER_TIMEOUT=f0DDXSxvRTbHyzkCnwnYijtgteFTdfdUR7J8REwTYJ8 MESSAGE_CHARGER_TIMEOUT=f0DDXSxvRTbHyzkCnwnYijtgteFTdfdUR7J8REwTYJ8
MESSAGE_RELOAD=t_PyOGCKN_fmD0blw0EuIQs-8sS3qOTmpQay12haPZY
MESSAGE_SHED_TIMEOUT=rdzTNQ7t4uRXkP0SkuwW10WH77A_CIgYFiJykXJ0utU
MESSAGE_CHARGER_SHED=C0LvfETe-1rCR_IhOydDGPTUwwYkrWZxgfwMsETrhw8
LOW_POWER_LIMIT=30 LOW_POWER_LIMIT=30
...@@ -2,7 +2,7 @@ REDIS_HOST=redis.test.senthink.com ...@@ -2,7 +2,7 @@ REDIS_HOST=redis.test.senthink.com
REGISTER_IP=127.0.0.1 REGISTER_IP=127.0.0.1
REGISTER_PORT=1239 REGISTER_PORT=1239
GATEWAY_PORT=8282 GATEWAY_PORT=8283
GATEWAY_IP=127.0.0.1 GATEWAY_IP=127.0.0.1
GATEWAY_COUNT=1 GATEWAY_COUNT=1
GATEWAY_START_PORT=2130 GATEWAY_START_PORT=2130
...@@ -25,5 +25,11 @@ MESSAGE_API_URL=https://cdzback2.test.senthink.com ...@@ -25,5 +25,11 @@ MESSAGE_API_URL=https://cdzback2.test.senthink.com
MESSAGE_START=L9SEWl3X73v3PBYHtFBZlTlJeBMdO9DDNIwRgHX6SrY MESSAGE_START=L9SEWl3X73v3PBYHtFBZlTlJeBMdO9DDNIwRgHX6SrY
MESSAGE_FAIL=0al-a6kkNsdqFyXPEe97m4jjtbfOXjEC3eCjEsMHJdw MESSAGE_FAIL=0al-a6kkNsdqFyXPEe97m4jjtbfOXjEC3eCjEsMHJdw
MESSAGE_POWER_EXCEED=rdzTNQ7t4uRXkP0SkuwW10WH77A_CIgYFiJykXJ0utU MESSAGE_POWER_EXCEED=rdzTNQ7t4uRXkP0SkuwW10WH77A_CIgYFiJykXJ0utU
MESSAGE_FINISH_USER=f0DDXSxvRTbHyzkCnwnYijtgteFTdfdUR7J8REwTYJ8
MESSAGE_PORT_SHED=C0LvfETe-1rCR_IhOydDGPTUwwYkrWZxgfwMsETrhw8
MESSAGE_CHARGER_TIMEOUT=f0DDXSxvRTbHyzkCnwnYijtgteFTdfdUR7J8REwTYJ8
MESSAGE_RELOAD=t_PyOGCKN_fmD0blw0EuIQs-8sS3qOTmpQay12haPZY
MESSAGE_SHED_TIMEOUT=rdzTNQ7t4uRXkP0SkuwW10WH77A_CIgYFiJykXJ0utU
MESSAGE_CHARGER_SHED=C0LvfETe-1rCR_IhOydDGPTUwwYkrWZxgfwMsETrhw8
LOW_POWER_LIMIT=30 LOW_POWER_LIMIT=30
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="a4269ceb-5bf6-49dc-9b41-8690287f228c" name="Default" comment="" /> <list default="true" id="a4269ceb-5bf6-49dc-9b41-8690287f228c" name="Default" comment="">
<change beforePath="" afterPath="$PROJECT_DIR$/application/controller/card/BalanceController.php" />
<change beforePath="" afterPath="$PROJECT_DIR$/application/controller/card/PayRuleController.php" />
<change beforePath="" afterPath="$PROJECT_DIR$/application/model/BillTmpModel.php" />
<change beforePath="" afterPath="$PROJECT_DIR$/application/model/CardModel.php" />
<change beforePath="" afterPath="$PROJECT_DIR$/application/model/ExceptionModel.php" />
<change beforePath="" afterPath="$PROJECT_DIR$/application/model/ParkModel.php" />
<change beforePath="" afterPath="$PROJECT_DIR$/lib/remote/api/message/ChargerReloadMessage.php" />
<change beforePath="" afterPath="$PROJECT_DIR$/lib/remote/api/message/ChargerShedMessage.php" />
<change beforePath="" afterPath="$PROJECT_DIR$/lib/remote/api/message/ChargerShedTimeOutMessage.php" />
<change beforePath="" afterPath="$PROJECT_DIR$/src/BroadcastToAgent.php" />
<change beforePath="$PROJECT_DIR$/.env" afterPath="$PROJECT_DIR$/.env" />
<change beforePath="$PROJECT_DIR$/.example" afterPath="$PROJECT_DIR$/.example" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change beforePath="$PROJECT_DIR$/application/Events.php" afterPath="$PROJECT_DIR$/application/Events.php" />
<change beforePath="$PROJECT_DIR$/application/controller/Controller.php" afterPath="$PROJECT_DIR$/application/controller/Controller.php" />
<change beforePath="$PROJECT_DIR$/application/controller/HeartController.php" afterPath="$PROJECT_DIR$/application/controller/HeartController.php" />
<change beforePath="$PROJECT_DIR$/application/controller/accept/AccessController.php" afterPath="$PROJECT_DIR$/application/controller/accept/AccessController.php" />
<change beforePath="$PROJECT_DIR$/application/controller/accept/CertifyController.php" afterPath="$PROJECT_DIR$/application/controller/accept/CertifyController.php" />
<change beforePath="$PROJECT_DIR$/application/controller/business/charger/OverController.php" afterPath="$PROJECT_DIR$/application/controller/business/charger/OverController.php" />
<change beforePath="$PROJECT_DIR$/application/controller/business/charger/StartController.php" afterPath="$PROJECT_DIR$/application/controller/business/charger/StartController.php" />
<change beforePath="$PROJECT_DIR$/application/controller/business/port/OfflineController.php" afterPath="$PROJECT_DIR$/application/controller/business/port/OfflineController.php" />
<change beforePath="$PROJECT_DIR$/application/controller/business/port/OnlineController.php" afterPath="$PROJECT_DIR$/application/controller/business/port/OnlineController.php" />
<change beforePath="$PROJECT_DIR$/application/controller/business/port/StateController.php" afterPath="$PROJECT_DIR$/application/controller/business/port/StateController.php" />
<change beforePath="$PROJECT_DIR$/application/controller/business/power/PowerController.php" afterPath="$PROJECT_DIR$/application/controller/business/power/PowerController.php" />
<change beforePath="$PROJECT_DIR$/application/controller/setting/SettingController.php" afterPath="$PROJECT_DIR$/application/controller/setting/SettingController.php" />
<change beforePath="$PROJECT_DIR$/application/model/StationModel.php" afterPath="$PROJECT_DIR$/application/model/StationModel.php" />
<change beforePath="$PROJECT_DIR$/application/route/Api.php" afterPath="$PROJECT_DIR$/application/route/Api.php" />
<change beforePath="$PROJECT_DIR$/lib/Gateway.php" afterPath="$PROJECT_DIR$/lib/Gateway.php" />
<change beforePath="$PROJECT_DIR$/lib/StateCode.php" afterPath="$PROJECT_DIR$/lib/StateCode.php" />
<change beforePath="$PROJECT_DIR$/lib/cdz/order/Order.php" afterPath="$PROJECT_DIR$/lib/cdz/order/Order.php" />
<change beforePath="$PROJECT_DIR$/lib/cdz/order/save/OrderSaveRedis.php" afterPath="$PROJECT_DIR$/lib/cdz/order/save/OrderSaveRedis.php" />
<change beforePath="$PROJECT_DIR$/lib/cdz/order/state/ChargerState.php" afterPath="$PROJECT_DIR$/lib/cdz/order/state/ChargerState.php" />
<change beforePath="$PROJECT_DIR$/lib/cdz/order/state/ExceptionState.php" afterPath="$PROJECT_DIR$/lib/cdz/order/state/ExceptionState.php" />
<change beforePath="$PROJECT_DIR$/lib/cdz/order/state/OfflineNetState.php" afterPath="$PROJECT_DIR$/lib/cdz/order/state/OfflineNetState.php" />
<change beforePath="$PROJECT_DIR$/lib/cdz/order/state/OfflinePowerState.php" afterPath="$PROJECT_DIR$/lib/cdz/order/state/OfflinePowerState.php" />
<change beforePath="$PROJECT_DIR$/lib/cdz/order/state/PowerExceedState.php" afterPath="$PROJECT_DIR$/lib/cdz/order/state/PowerExceedState.php" />
<change beforePath="$PROJECT_DIR$/lib/cdz/order/state/PowerFullState.php" afterPath="$PROJECT_DIR$/lib/cdz/order/state/PowerFullState.php" />
<change beforePath="$PROJECT_DIR$/lib/cdz/order/state/ShedState.php" afterPath="$PROJECT_DIR$/lib/cdz/order/state/ShedState.php" />
<change beforePath="$PROJECT_DIR$/lib/cdz/order/state/ShedTimeoutState.php" afterPath="$PROJECT_DIR$/lib/cdz/order/state/ShedTimeoutState.php" />
<change beforePath="$PROJECT_DIR$/lib/cdz/order/state/State.php" afterPath="$PROJECT_DIR$/lib/cdz/order/state/State.php" />
<change beforePath="$PROJECT_DIR$/lib/cdz/order/state/TimeoutState.php" afterPath="$PROJECT_DIR$/lib/cdz/order/state/TimeoutState.php" />
<change beforePath="$PROJECT_DIR$/lib/cdz/order/state/WaitingState.php" afterPath="$PROJECT_DIR$/lib/cdz/order/state/WaitingState.php" />
<change beforePath="$PROJECT_DIR$/lib/remote/api/message/FailMessage.php" afterPath="$PROJECT_DIR$/lib/remote/api/message/FailMessage.php" />
<change beforePath="$PROJECT_DIR$/lib/remote/api/message/SendMessage.php" afterPath="$PROJECT_DIR$/lib/remote/api/message/SendMessage.php" />
<change beforePath="$PROJECT_DIR$/lib/remote/api/message/StartMessage.php" afterPath="$PROJECT_DIR$/lib/remote/api/message/StartMessage.php" />
<change beforePath="$PROJECT_DIR$/lib/station/gateway/Gateway.php" afterPath="$PROJECT_DIR$/lib/station/gateway/Gateway.php" />
<change beforePath="$PROJECT_DIR$/lib/station/gateway/port/Port.php" afterPath="$PROJECT_DIR$/lib/station/gateway/port/Port.php" />
<change beforePath="$PROJECT_DIR$/src/Test.php" afterPath="$PROJECT_DIR$/src/Test.php" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" value="true" /> <option name="TRACKING_ENABLED" value="true" />
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
...@@ -17,63 +66,51 @@ ...@@ -17,63 +66,51 @@
</component> </component>
<component name="FileEditorManager"> <component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300"> <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="Controller.php" pinned="false" current-in-tab="false"> <file leaf-file-name="WaitingState.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/application/controller/Controller.php"> <entry file="file://$PROJECT_DIR$/lib/cdz/order/state/WaitingState.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="384"> <state relative-caret-position="705">
<caret line="168" column="9" lean-forward="true" selection-start-line="168" selection-start-column="9" selection-end-line="168" selection-end-column="9" /> <caret line="64" column="50" lean-forward="false" selection-start-line="64" selection-start-column="50" selection-end-line="64" selection-end-column="50" />
<folding>
<element signature="e#126#152#0#PHP" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="StateController.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/application/controller/business/port/StateController.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-474">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
</file> </file>
<file leaf-file-name="CapacityController.php" pinned="false" current-in-tab="false"> <file leaf-file-name="ShedState.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/application/controller/business/power/CapacityController.php"> <entry file="file://$PROJECT_DIR$/lib/cdz/order/state/ShedState.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0"> <state relative-caret-position="571">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" /> <caret line="194" column="58" lean-forward="false" selection-start-line="194" selection-start-column="58" selection-end-line="194" selection-end-column="58" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
</file> </file>
<file leaf-file-name="PowerController.php" pinned="false" current-in-tab="true"> <file leaf-file-name="ChargerShedTimeOutMessage.php" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/application/controller/business/power/PowerController.php"> <entry file="file://$PROJECT_DIR$/lib/remote/api/message/ChargerShedTimeOutMessage.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="624"> <state relative-caret-position="255">
<caret line="74" column="22" lean-forward="false" selection-start-line="74" selection-start-column="22" selection-end-line="74" selection-end-column="22" /> <caret line="22" column="28" lean-forward="true" selection-start-line="22" selection-start-column="28" selection-end-line="22" selection-end-column="28" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
</file> </file>
<file leaf-file-name="OrderSaveRedis.php" pinned="false" current-in-tab="false"> <file leaf-file-name="OverController.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/lib/cdz/order/save/OrderSaveRedis.php"> <entry file="file://$PROJECT_DIR$/application/controller/business/charger/OverController.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="330"> <state relative-caret-position="24">
<caret line="27" column="35" lean-forward="false" selection-start-line="27" selection-start-column="35" selection-end-line="27" selection-end-column="35" /> <caret line="71" column="0" lean-forward="false" selection-start-line="71" selection-start-column="0" selection-end-line="71" selection-end-column="0" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
</file> </file>
<file leaf-file-name="Order.php" pinned="false" current-in-tab="false"> <file leaf-file-name="StateCode.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/lib/cdz/order/Order.php"> <entry file="file://$PROJECT_DIR$/lib/StateCode.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-980"> <state relative-caret-position="345">
<caret line="13" column="6" lean-forward="false" selection-start-line="13" selection-start-column="6" selection-end-line="13" selection-end-column="6" /> <caret line="28" column="10" lean-forward="false" selection-start-line="28" selection-start-column="10" selection-end-line="28" selection-end-column="10" />
<folding /> <folding />
</state> </state>
</provider> </provider>
...@@ -82,8 +119,8 @@ ...@@ -82,8 +119,8 @@
<file leaf-file-name="OnlineController.php" pinned="false" current-in-tab="false"> <file leaf-file-name="OnlineController.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/application/controller/business/port/OnlineController.php"> <entry file="file://$PROJECT_DIR$/application/controller/business/port/OnlineController.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0"> <state relative-caret-position="559">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" /> <caret line="61" column="9" lean-forward="false" selection-start-line="61" selection-start-column="9" selection-end-line="61" selection-end-column="9" />
<folding /> <folding />
</state> </state>
</provider> </provider>
...@@ -92,35 +129,45 @@ ...@@ -92,35 +129,45 @@
<file leaf-file-name="OfflineController.php" pinned="false" current-in-tab="false"> <file leaf-file-name="OfflineController.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/application/controller/business/port/OfflineController.php"> <entry file="file://$PROJECT_DIR$/application/controller/business/port/OfflineController.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0"> <state relative-caret-position="739">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" /> <caret line="71" column="61" lean-forward="false" selection-start-line="71" selection-start-column="61" selection-end-line="71" selection-end-column="61" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
</file> </file>
<file leaf-file-name="AccessController.php" pinned="false" current-in-tab="false"> <file leaf-file-name="TimeoutState.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/application/controller/accept/AccessController.php"> <entry file="file://$PROJECT_DIR$/lib/cdz/order/state/TimeoutState.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-1608"> <state relative-caret-position="852">
<caret line="121" column="0" lean-forward="false" selection-start-line="121" selection-start-column="0" selection-end-line="121" selection-end-column="0" /> <caret line="69" column="5" lean-forward="false" selection-start-line="69" selection-start-column="5" selection-end-line="69" selection-end-column="5" />
<folding> <folding />
<element signature="e#978#1032#0#PHP" expanded="false" />
</folding>
</state> </state>
</provider> </provider>
</entry> </entry>
</file> </file>
<file leaf-file-name="Response.php" pinned="false" current-in-tab="false"> <file leaf-file-name="StateController.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/response/Response.php"> <entry file="file://$PROJECT_DIR$/application/controller/business/port/StateController.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="319"> <state relative-caret-position="522">
<caret line="113" column="20" lean-forward="false" selection-start-line="113" selection-start-column="20" selection-end-line="113" selection-end-column="20" /> <caret line="65" column="0" lean-forward="false" selection-start-line="65" selection-start-column="0" selection-end-line="65" selection-end-column="0" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
</file> </file>
<file leaf-file-name="Port.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/lib/station/gateway/port/Port.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="364">
<caret line="139" column="9" lean-forward="false" selection-start-line="139" selection-start-column="9" selection-end-line="139" selection-end-column="9" />
<folding>
<element signature="e#128#162#0#PHP" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
</leaf> </leaf>
</component> </component>
<component name="FindInProjectRecents"> <component name="FindInProjectRecents">
...@@ -130,11 +177,16 @@ ...@@ -130,11 +177,16 @@
<find>Env::get</find> <find>Env::get</find>
<find>private</find> <find>private</find>
<find>spl_</find> <find>spl_</find>
<find>var_dump</find>
<find>static::add</find> <find>static::add</find>
<find>var_du</find> <find>var_du</find>
<find>var_dum</find> <find>var_dum</find>
<find>unset(resp</find> <find>unset(resp</find>
<find>hello</find>
<find>var_dump</find>
<find>get port</find>
<find>port_logic_id</find>
<find>offline</find>
<find>gateway:port:state:</find>
</findStrings> </findStrings>
<replaceStrings> <replaceStrings>
<replace>$this-&gt;nowDate</replace> <replace>$this-&gt;nowDate</replace>
...@@ -149,57 +201,57 @@ ...@@ -149,57 +201,57 @@
<component name="IdeDocumentHistory"> <component name="IdeDocumentHistory">
<option name="CHANGED_PATHS"> <option name="CHANGED_PATHS">
<list> <list>
<option value="$PROJECT_DIR$/src/exception/order/OrderException.php" /> <option value="$PROJECT_DIR$/vendor/workerman/workerman/Protocols/Bintohex.php" />
<option value="$PROJECT_DIR$/application/model/GatewayLogModel.php" /> <option value="$PROJECT_DIR$/src/response/Response.php" />
<option value="$PROJECT_DIR$/lib/cdz/order/NoticePortShed.php" /> <option value="$PROJECT_DIR$/src/log/record/Record.php" />
<option value="$PROJECT_DIR$/src/Test.php" /> <option value="$PROJECT_DIR$/src/log/GatewayLogWriter.php" />
<option value="$PROJECT_DIR$/application/controller/TestController.php" /> <option value="$PROJECT_DIR$/application/controller/Controller.php" />
<option value="$PROJECT_DIR$/application/start_businessworker.php" /> <option value="$PROJECT_DIR$/application/controller/HeartController.php" />
<option value="$PROJECT_DIR$/start.php" />
<option value="$PROJECT_DIR$/test/test.php" />
<option value="$PROJECT_DIR$/src/Container.php" />
<option value="$PROJECT_DIR$/application/controller/business/charger/StartController.php" />
<option value="$PROJECT_DIR$/application/controller/business/port/OfflineController.php" />
<option value="$PROJECT_DIR$/application/controller/business/port/OnlineController.php" />
<option value="$PROJECT_DIR$/application/controller/business/port/StateController.php" />
<option value="$PROJECT_DIR$/application/controller/business/power/CapacityController.php" />
<option value="$PROJECT_DIR$/src/route/Route.php" />
<option value="$PROJECT_DIR$/application/model/ConfigModel.php" />
<option value="$PROJECT_DIR$/application/model/StationModel.php" />
<option value="$PROJECT_DIR$/.example" />
<option value="$PROJECT_DIR$/application/controller/business/power/ShutDownController.php" />
<option value="$PROJECT_DIR$/application/controller/business/power/ShutdownController.php" />
<option value="$PROJECT_DIR$/application/route/Api.php" /> <option value="$PROJECT_DIR$/application/route/Api.php" />
<option value="$PROJECT_DIR$/application/controller/setting/SettingController.php" /> <option value="$PROJECT_DIR$/application/controller/setting/SettingController.php" />
<option value="$PROJECT_DIR$/application/model/StationModel.php" />
<option value="$PROJECT_DIR$/lib/remote/api/message/FailMessage.php" />
<option value="$PROJECT_DIR$/application/controller/accept/CertifyController.php" />
<option value="$PROJECT_DIR$/application/model/ParkModel.php" />
<option value="$PROJECT_DIR$/src/BroadcastToAgent.php" />
<option value="$PROJECT_DIR$/lib/remote/api/message/ChargerReloadMessage.php" />
<option value="$PROJECT_DIR$/lib/remote/api/message/SendMessage.php" />
<option value="$PROJECT_DIR$/lib/remote/api/message/ChargerShedTimeOutMessage.php" />
<option value="$PROJECT_DIR$/lib/cdz/order/state/State.php" /> <option value="$PROJECT_DIR$/lib/cdz/order/state/State.php" />
<option value="$PROJECT_DIR$/lib/cdz/order/state/OfflineNetState.php" />
<option value="$PROJECT_DIR$/lib/cdz/order/state/ExceptionState.php" /> <option value="$PROJECT_DIR$/lib/cdz/order/state/ExceptionState.php" />
<option value="$PROJECT_DIR$/lib/cdz/order/state/OfflinePowerState.php" /> <option value="$PROJECT_DIR$/lib/cdz/order/state/OfflinePowerState.php" />
<option value="$PROJECT_DIR$/lib/cdz/order/state/PowerExceedState.php" /> <option value="$PROJECT_DIR$/lib/cdz/order/state/PowerExceedState.php" />
<option value="$PROJECT_DIR$/lib/cdz/order/state/PowerFullState.php" /> <option value="$PROJECT_DIR$/lib/cdz/order/state/PowerFullState.php" />
<option value="$PROJECT_DIR$/lib/cdz/order/state/ShedState.php" />
<option value="$PROJECT_DIR$/lib/cdz/order/state/ShedTimeoutState.php" /> <option value="$PROJECT_DIR$/lib/cdz/order/state/ShedTimeoutState.php" />
<option value="$PROJECT_DIR$/lib/cdz/order/state/TimeoutState.php" /> <option value="$PROJECT_DIR$/lib/cdz/order/state/TimeoutState.php" />
<option value="$PROJECT_DIR$/lib/cdz/order/state/WaitingState.php" /> <option value="$PROJECT_DIR$/application/model/ExceptionModel.php" />
<option value="$PROJECT_DIR$/src/Test.php" />
<option value="$PROJECT_DIR$/lib/station/gateway/Gateway.php" />
<option value="$PROJECT_DIR$/lib/cdz/order/save/OrderSaveRedis.php" />
<option value="$PROJECT_DIR$/lib/Gateway.php" />
<option value="$PROJECT_DIR$/application/controller/business/power/PowerController.php" />
<option value="$PROJECT_DIR$/lib/cdz/order/Order.php" /> <option value="$PROJECT_DIR$/lib/cdz/order/Order.php" />
<option value="$PROJECT_DIR$/application/controller/business/charger/OverController.php" /> <option value="$PROJECT_DIR$/lib/cdz/order/state/OfflineNetState.php" />
<option value="$PROJECT_DIR$/lib/remote/api/message/Message.php" />
<option value="$PROJECT_DIR$/lib/remote/api/message/FinishByUserMessage.php" />
<option value="$PROJECT_DIR$/lib/remote/api/message/ShedMessage.php" />
<option value="$PROJECT_DIR$/lib/remote/api/message/ChargerTimeoutMessage.php" />
<option value="$PROJECT_DIR$/lib/cdz/order/state/ChargerState.php" />
<option value="$PROJECT_DIR$/.env" />
<option value="$PROJECT_DIR$/application/controller/HeartController.php" />
<option value="$PROJECT_DIR$/application/start_gateway.php" />
<option value="$PROJECT_DIR$/application/Events.php" />
<option value="$PROJECT_DIR$/vendor/workerman/workerman/Protocols/Bintohex.php" />
<option value="$PROJECT_DIR$/application/controller/accept/CertifyController.php" />
<option value="$PROJECT_DIR$/src/response/Response.php" />
<option value="$PROJECT_DIR$/src/log/record/Record.php" />
<option value="$PROJECT_DIR$/src/log/GatewayLogWriter.php" />
<option value="$PROJECT_DIR$/application/controller/accept/AccessController.php" /> <option value="$PROJECT_DIR$/application/controller/accept/AccessController.php" />
<option value="$PROJECT_DIR$/application/controller/Controller.php" /> <option value="$PROJECT_DIR$/lib/StateCode.php" />
<option value="$PROJECT_DIR$/application/controller/business/power/PowerController.php" /> <option value="$PROJECT_DIR$/application/controller/business/charger/StartController.php" />
<option value="$PROJECT_DIR$/application/Events.php" />
<option value="$PROJECT_DIR$/lib/remote/api/message/StartMessage.php" />
<option value="$PROJECT_DIR$/lib/remote/api/message/ChargerShedMessage.php" />
<option value="$PROJECT_DIR$/.env" />
<option value="$PROJECT_DIR$/.example" />
<option value="$PROJECT_DIR$/lib/cdz/order/state/ChargerState.php" />
<option value="$PROJECT_DIR$/application/model/BillTmpModel.php" />
<option value="$PROJECT_DIR$/application/model/CardModel.php" />
<option value="$PROJECT_DIR$/application/controller/card/BalanceController.php" />
<option value="$PROJECT_DIR$/application/controller/card/PayRuleController.php" />
<option value="$PROJECT_DIR$/application/controller/business/port/OnlineController.php" />
<option value="$PROJECT_DIR$/application/controller/business/port/OfflineController.php" />
<option value="$PROJECT_DIR$/application/controller/business/port/StateController.php" />
<option value="$PROJECT_DIR$/lib/cdz/order/state/WaitingState.php" />
<option value="$PROJECT_DIR$/application/controller/business/charger/OverController.php" />
<option value="$PROJECT_DIR$/lib/station/gateway/port/Port.php" />
<option value="$PROJECT_DIR$/lib/cdz/order/state/ShedState.php" />
</list> </list>
</option> </option>
</component> </component>
...@@ -231,8 +283,10 @@ ...@@ -231,8 +283,10 @@
</include_path> </include_path>
</component> </component>
<component name="ProjectFrameBounds" fullScreen="true"> <component name="ProjectFrameBounds" fullScreen="true">
<option name="width" value="1920" /> <option name="x" value="65" />
<option name="height" value="1080" /> <option name="y" value="23" />
<option name="width" value="1790" />
<option name="height" value="1057" />
</component> </component>
<component name="ProjectLevelVcsManager" settingsEditedManually="true"> <component name="ProjectLevelVcsManager" settingsEditedManually="true">
<ConfirmationsSetting value="2" id="Add" /> <ConfirmationsSetting value="2" id="Add" />
...@@ -252,8 +306,8 @@ ...@@ -252,8 +306,8 @@
<foldersAlwaysOnTop value="true" /> <foldersAlwaysOnTop value="true" />
</navigator> </navigator>
<panes> <panes>
<pane id="Scratches" />
<pane id="Scope" /> <pane id="Scope" />
<pane id="Scratches" />
<pane id="ProjectPane"> <pane id="ProjectPane">
<subPane> <subPane>
<expand> <expand>
...@@ -277,7 +331,7 @@ ...@@ -277,7 +331,7 @@
<item name="cdz_gateway_v2" type="2a2b976b:PhpTreeStructureProvider$1" /> <item name="cdz_gateway_v2" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="application" type="2a2b976b:PhpTreeStructureProvider$1" /> <item name="application" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="controller" type="2a2b976b:PhpTreeStructureProvider$1" /> <item name="controller" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="accept" type="2a2b976b:PhpTreeStructureProvider$1" /> <item name="business" type="2a2b976b:PhpTreeStructureProvider$1" />
</path> </path>
<path> <path>
<item name="cdz_gateway_v2" type="b2602c69:ProjectViewProjectNode" /> <item name="cdz_gateway_v2" type="b2602c69:ProjectViewProjectNode" />
...@@ -285,6 +339,7 @@ ...@@ -285,6 +339,7 @@
<item name="application" type="2a2b976b:PhpTreeStructureProvider$1" /> <item name="application" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="controller" type="2a2b976b:PhpTreeStructureProvider$1" /> <item name="controller" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="business" type="2a2b976b:PhpTreeStructureProvider$1" /> <item name="business" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="charger" type="2a2b976b:PhpTreeStructureProvider$1" />
</path> </path>
<path> <path>
<item name="cdz_gateway_v2" type="b2602c69:ProjectViewProjectNode" /> <item name="cdz_gateway_v2" type="b2602c69:ProjectViewProjectNode" />
...@@ -297,10 +352,49 @@ ...@@ -297,10 +352,49 @@
<path> <path>
<item name="cdz_gateway_v2" type="b2602c69:ProjectViewProjectNode" /> <item name="cdz_gateway_v2" type="b2602c69:ProjectViewProjectNode" />
<item name="cdz_gateway_v2" type="2a2b976b:PhpTreeStructureProvider$1" /> <item name="cdz_gateway_v2" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="application" type="2a2b976b:PhpTreeStructureProvider$1" /> <item name="lib" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="controller" type="2a2b976b:PhpTreeStructureProvider$1" /> </path>
<item name="business" type="2a2b976b:PhpTreeStructureProvider$1" /> <path>
<item name="power" type="2a2b976b:PhpTreeStructureProvider$1" /> <item name="cdz_gateway_v2" type="b2602c69:ProjectViewProjectNode" />
<item name="cdz_gateway_v2" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="lib" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="cdz" type="2a2b976b:PhpTreeStructureProvider$1" />
</path>
<path>
<item name="cdz_gateway_v2" type="b2602c69:ProjectViewProjectNode" />
<item name="cdz_gateway_v2" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="lib" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="cdz" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="order" type="2a2b976b:PhpTreeStructureProvider$1" />
</path>
<path>
<item name="cdz_gateway_v2" type="b2602c69:ProjectViewProjectNode" />
<item name="cdz_gateway_v2" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="lib" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="cdz" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="order" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="state" type="2a2b976b:PhpTreeStructureProvider$1" />
</path>
<path>
<item name="cdz_gateway_v2" type="b2602c69:ProjectViewProjectNode" />
<item name="cdz_gateway_v2" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="lib" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="remote" type="2a2b976b:PhpTreeStructureProvider$1" />
</path>
<path>
<item name="cdz_gateway_v2" type="b2602c69:ProjectViewProjectNode" />
<item name="cdz_gateway_v2" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="lib" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="remote" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="api" type="2a2b976b:PhpTreeStructureProvider$1" />
</path>
<path>
<item name="cdz_gateway_v2" type="b2602c69:ProjectViewProjectNode" />
<item name="cdz_gateway_v2" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="lib" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="remote" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="api" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="message" type="2a2b976b:PhpTreeStructureProvider$1" />
</path> </path>
<path> <path>
<item name="cdz_gateway_v2" type="b2602c69:ProjectViewProjectNode" /> <item name="cdz_gateway_v2" type="b2602c69:ProjectViewProjectNode" />
...@@ -318,15 +412,18 @@ ...@@ -318,15 +412,18 @@
<property name="nodejs_npm_path_reset_for_default_project" value="true" /> <property name="nodejs_npm_path_reset_for_default_project" value="true" />
<property name="php.override.implement.member.chooser.php.doc" value="NONE" /> <property name="php.override.implement.member.chooser.php.doc" value="NONE" />
<property name="settings.editor.selected.configurable" value="preferences.pluginManager" /> <property name="settings.editor.selected.configurable" value="preferences.pluginManager" />
<property name="run.code.analysis.last.selected.profile" value="pProject Default" />
</component> </component>
<component name="RecentsManager"> <component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/vendor/workerman/workerman/Protocols" />
</key>
<key name="MoveFile.RECENT_KEYS"> <key name="MoveFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/application/model" /> <recent name="$PROJECT_DIR$/application/model" />
<recent name="$PROJECT_DIR$/application" /> <recent name="$PROJECT_DIR$/application" />
</key> </key>
<key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/lib/remote/api/message" />
<recent name="$PROJECT_DIR$/lib/cdz/order/state" />
<recent name="$PROJECT_DIR$/vendor/workerman/workerman/Protocols" />
</key>
</component> </component>
<component name="RunDashboard"> <component name="RunDashboard">
<option name="ruleStates"> <option name="ruleStates">
...@@ -357,12 +454,15 @@ ...@@ -357,12 +454,15 @@
<workItem from="1533865958021" duration="13063000" /> <workItem from="1533865958021" duration="13063000" />
<workItem from="1533890909526" duration="33446000" /> <workItem from="1533890909526" duration="33446000" />
<workItem from="1534736026759" duration="2486000" /> <workItem from="1534736026759" duration="2486000" />
<workItem from="1534745314460" duration="73568000" /> <workItem from="1534745314460" duration="104140000" />
<workItem from="1535099164178" duration="184000" />
<workItem from="1535101118300" duration="241000" />
<workItem from="1535169242819" duration="28662000" />
</task> </task>
<servers /> <servers />
</component> </component>
<component name="TimeTrackingManager"> <component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="125425000" /> <option name="totallyTimeSpent" value="185084000" />
</component> </component>
<component name="ToolWindowManager"> <component name="ToolWindowManager">
<frame x="0" y="0" width="1920" height="1080" extended-state="0" /> <frame x="0" y="0" width="1920" height="1080" extended-state="0" />
...@@ -373,9 +473,8 @@ ...@@ -373,9 +473,8 @@
<window_info id="File Transfer" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3286991" sideWeight="0.5" order="8" side_tool="false" content_ui="tabs" /> <window_info id="File Transfer" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3286991" sideWeight="0.5" order="8" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32969216" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" /> <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32969216" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" /> <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Thumbnails" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32969216" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.23535253" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" /> <window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.23535253" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.2513312" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" /> <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.2593184" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="Docker" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" /> <window_info id="Docker" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" /> <window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
...@@ -387,6 +486,7 @@ ...@@ -387,6 +486,7 @@
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="SLIDING" type="SLIDING" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" /> <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="SLIDING" type="SLIDING" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" /> <window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Database Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" /> <window_info id="Database Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Thumbnails" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32969216" sideWeight="0.5" order="9" side_tool="false" content_ui="tabs" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" /> <window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
</layout> </layout>
...@@ -402,421 +502,412 @@ ...@@ -402,421 +502,412 @@
<watches-manager /> <watches-manager />
</component> </component>
<component name="editorHistoryManager"> <component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/src/Message.php"> <entry file="file://$PROJECT_DIR$/lib/cdz/order/state/PowerExceedState.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0"> <state relative-caret-position="852">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" /> <caret line="69" column="5" lean-forward="false" selection-start-line="69" selection-start-column="5" selection-end-line="69" selection-end-column="5" />
<folding /> </state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/cdz/order/state/PowerFullState.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="852">
<caret line="69" column="5" lean-forward="false" selection-start-line="69" selection-start-column="5" selection-end-line="69" selection-end-column="5" />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/request/Request.php"> <entry file="file://$PROJECT_DIR$/application/controller/business/power/CapacityController.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0"> <state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" /> <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/route/Route.php"> <entry file="file://$PROJECT_DIR$/application/controller/business/power/ShutdownController.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="380"> <state relative-caret-position="270">
<caret line="55" column="0" lean-forward="false" selection-start-line="55" selection-start-column="0" selection-end-line="55" selection-end-column="0" /> <caret line="23" column="32" lean-forward="false" selection-start-line="23" selection-start-column="32" selection-end-line="23" selection-end-column="32" />
<folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/test/test.php"> <entry file="file://$PROJECT_DIR$/src/BroadcastToAgent.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="195"> <state relative-caret-position="465">
<caret line="18" column="8" lean-forward="false" selection-start-line="18" selection-start-column="8" selection-end-line="18" selection-end-column="8" /> <caret line="36" column="0" lean-forward="false" selection-start-line="36" selection-start-column="0" selection-end-line="36" selection-end-column="0" />
<folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/application/model/ConfigModel.php"> <entry file="file://$PROJECT_DIR$/application/model/ExceptionModel.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="300"> <state relative-caret-position="165">
<caret line="25" column="0" lean-forward="true" selection-start-line="25" selection-start-column="0" selection-end-line="25" selection-end-column="0" /> <caret line="16" column="1" lean-forward="false" selection-start-line="16" selection-start-column="1" selection-end-line="16" selection-end-column="1" />
<folding>
<marker date="1534903681000" expanded="true" signature="270:299" ph="SELECT id , " />
<marker date="1534903681000" expanded="true" signature="270:300" ph="SELECT id , ${$this-&gt;table}" />
</folding>
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/application/model/StationModel.php"> <entry file="file://$PROJECT_DIR$/application/model/ParkModel.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="135"> <state relative-caret-position="165">
<caret line="14" column="0" lean-forward="false" selection-start-line="14" selection-start-column="0" selection-end-line="14" selection-end-column="0" /> <caret line="16" column="0" lean-forward="false" selection-start-line="16" selection-start-column="0" selection-end-line="16" selection-end-column="0" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/.example"> <entry file="file://$PROJECT_DIR$/lib/log/Log.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="420"> <state relative-caret-position="615">
<caret line="28" column="0" lean-forward="false" selection-start-line="28" selection-start-column="0" selection-end-line="28" selection-end-column="0" /> <caret line="48" column="31" lean-forward="false" selection-start-line="48" selection-start-column="31" selection-end-line="48" selection-end-column="31" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/application/route/Api.php"> <entry file="file://$PROJECT_DIR$/src/Test.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="375"> <state relative-caret-position="165">
<caret line="37" column="0" lean-forward="false" selection-start-line="37" selection-start-column="0" selection-end-line="37" selection-end-column="0" /> <caret line="16" column="0" lean-forward="false" selection-start-line="16" selection-start-column="0" selection-end-line="16" selection-end-column="0" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/application/controller/business/power/ShutdownController.php"> <entry file="file://$PROJECT_DIR$/lib/station/Station.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="270"> <state relative-caret-position="120">
<caret line="23" column="32" lean-forward="false" selection-start-line="23" selection-start-column="32" selection-end-line="23" selection-end-column="32" /> <caret line="13" column="10" lean-forward="false" selection-start-line="13" selection-start-column="10" selection-end-line="13" selection-end-column="10" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/lib/StateCode.php"> <entry file="file://$PROJECT_DIR$/lib/cdz/order/save/OrderSaveRedis.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="615"> <state relative-caret-position="660">
<caret line="46" column="26" lean-forward="false" selection-start-line="46" selection-start-column="26" selection-end-line="46" selection-end-column="26" /> <caret line="49" column="0" lean-forward="false" selection-start-line="49" selection-start-column="0" selection-end-line="49" selection-end-column="0" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/lib/cdz/order/state/ExceptionState.php"> <entry file="file://$PROJECT_DIR$/lib/rabbitmq/PublishPortShed.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="237"> <state relative-caret-position="375">
<caret line="21" column="4" lean-forward="false" selection-start-line="21" selection-start-column="4" selection-end-line="21" selection-end-column="4" /> <caret line="30" column="0" lean-forward="true" selection-start-line="30" selection-start-column="0" selection-end-line="30" selection-end-column="0" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/lib/cdz/order/state/OfflineNetState.php"> <entry file="file://$PROJECT_DIR$/application/model/OrderModel.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="480"> <state relative-caret-position="90">
<caret line="41" column="5" lean-forward="false" selection-start-line="41" selection-start-column="5" selection-end-line="41" selection-end-column="5" /> <caret line="11" column="6" lean-forward="false" selection-start-line="11" selection-start-column="6" selection-end-line="11" selection-end-column="6" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/lib/cdz/order/state/OfflinePowerState.php"> <entry file="file://$PROJECT_DIR$/application/model/OrderPowerModel.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="225"> <state relative-caret-position="90">
<caret line="23" column="5" lean-forward="false" selection-start-line="23" selection-start-column="5" selection-end-line="23" selection-end-column="5" /> <caret line="11" column="6" lean-forward="false" selection-start-line="11" selection-start-column="6" selection-end-line="11" selection-end-column="6" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/lib/cdz/order/state/PowerExceedState.php"> <entry file="file://$PROJECT_DIR$/application/route/Api.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="225"> <state relative-caret-position="525">
<caret line="23" column="5" lean-forward="false" selection-start-line="23" selection-start-column="5" selection-end-line="23" selection-end-column="5" /> <caret line="36" column="23" lean-forward="false" selection-start-line="36" selection-start-column="23" selection-end-line="36" selection-end-column="23" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/lib/cdz/order/state/PowerFullState.php"> <entry file="file://$PROJECT_DIR$/application/controller/accept/CertifyController.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="162"> <state relative-caret-position="657">
<caret line="19" column="5" lean-forward="false" selection-start-line="19" selection-start-column="5" selection-end-line="19" selection-end-column="5" /> <caret line="63" column="43" lean-forward="false" selection-start-line="63" selection-start-column="43" selection-end-line="63" selection-end-column="43" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/lib/cdz/order/state/ShedTimeoutState.php"> <entry file="file://$PROJECT_DIR$/application/controller/business/power/PowerController.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="177"> <state relative-caret-position="161">
<caret line="19" column="0" lean-forward="true" selection-start-line="19" selection-start-column="0" selection-end-line="19" selection-end-column="0" /> <caret line="54" column="1" lean-forward="false" selection-start-line="54" selection-start-column="1" selection-end-line="54" selection-end-column="1" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/lib/cdz/order/state/TimeoutState.php"> <entry file="file://$PROJECT_DIR$/lib/cdz/order/state/ShedTimeoutState.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="162"> <state relative-caret-position="945">
<caret line="19" column="5" lean-forward="false" selection-start-line="19" selection-start-column="5" selection-end-line="19" selection-end-column="5" /> <caret line="68" column="5" lean-forward="false" selection-start-line="68" selection-start-column="5" selection-end-line="68" selection-end-column="5" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/lib/cdz/order/state/WaitingState.php"> <entry file="file://$PROJECT_DIR$/lib/cdz/order/Order.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="345"> <state relative-caret-position="205">
<caret line="40" column="6" lean-forward="false" selection-start-line="40" selection-start-column="6" selection-end-line="40" selection-end-column="6" /> <caret line="28" column="6" lean-forward="false" selection-start-line="28" selection-start-column="6" selection-end-line="28" selection-end-column="6" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/lib/station/gateway/port/Port.php"> <entry file="file://$PROJECT_DIR$/lib/cdz/order/state/OfflineNetState.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="521"> <state relative-caret-position="345">
<caret line="116" column="0" lean-forward="true" selection-start-line="116" selection-start-column="0" selection-end-line="116" selection-end-column="0" /> <caret line="30" column="73" lean-forward="false" selection-start-line="30" selection-start-column="73" selection-end-line="30" selection-end-column="73" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/lib/remote/api/message/PowerExceedMessage.php"> <entry file="file://$PROJECT_DIR$/application/controller/accept/AccessController.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-1316"> <state relative-caret-position="567">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" /> <caret line="269" column="1" lean-forward="true" selection-start-line="269" selection-start-column="1" selection-end-line="269" selection-end-column="1" />
<folding /> <folding>
<element signature="e#1064#1118#0#PHP" expanded="false" />
</folding>
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/lib/remote/api/message/Message.php"> <entry file="file://$PROJECT_DIR$/lib/Gateway.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="822"> <state relative-caret-position="319">
<caret line="78" column="0" lean-forward="false" selection-start-line="78" selection-start-column="0" selection-end-line="78" selection-end-column="0" /> <caret line="161" column="27" lean-forward="false" selection-start-line="161" selection-start-column="27" selection-end-line="161" selection-end-column="27" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/lib/remote/api/message/FailMessage.php"> <entry file="jar://$APPLICATION_HOME_DIR$/plugins/php/lib/php.jar!/stubs/redis/Redis.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-273"> <state relative-caret-position="326">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" /> <caret line="2762" column="20" lean-forward="false" selection-start-line="2762" selection-start-column="20" selection-end-line="2762" selection-end-column="20" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/lib/remote/api/message/FinishByUserMessage.php"> <entry file="file://$PROJECT_DIR$/application/Events.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="15"> <state relative-caret-position="52">
<caret line="12" column="15" lean-forward="false" selection-start-line="12" selection-start-column="15" selection-end-line="12" selection-end-column="15" /> <caret line="126" column="0" lean-forward="false" selection-start-line="126" selection-start-column="0" selection-end-line="126" selection-end-column="0" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/lib/remote/api/message/SendMessage.php"> <entry file="file://$PROJECT_DIR$/lib/station/gateway/Gateway.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="435"> <state relative-caret-position="195">
<caret line="35" column="20" lean-forward="false" selection-start-line="35" selection-start-column="20" selection-end-line="35" selection-end-column="20" /> <caret line="18" column="28" lean-forward="false" selection-start-line="18" selection-start-column="28" selection-end-line="18" selection-end-column="28" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/application/controller/business/charger/OverController.php"> <entry file="file://$PROJECT_DIR$/application/controller/business/charger/StartController.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="385"> <state relative-caret-position="221">
<caret line="44" column="13" lean-forward="false" selection-start-line="44" selection-start-column="13" selection-end-line="44" selection-end-column="13" /> <caret line="49" column="14" lean-forward="false" selection-start-line="49" selection-start-column="14" selection-end-line="49" selection-end-column="14" />
<folding> <folding />
<element signature="e#143#181#0#PHP" expanded="false" />
</folding>
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/lib/cdz/order/state/State.php"> <entry file="file://$PROJECT_DIR$/lib/remote/api/message/Message.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="109"> <state relative-caret-position="1035">
<caret line="13" column="15" lean-forward="false" selection-start-line="13" selection-start-column="15" selection-end-line="13" selection-end-column="15" /> <caret line="74" column="20" lean-forward="false" selection-start-line="74" selection-start-column="20" selection-end-line="74" selection-end-column="20" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/lib/remote/api/message/ShedMessage.php"> <entry file="file://$PROJECT_DIR$/lib/remote/api/message/StartMessage.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1726"> <state relative-caret-position="221">
<caret line="149" column="0" lean-forward="false" selection-start-line="149" selection-start-column="0" selection-end-line="149" selection-end-column="0" /> <caret line="57" column="46" lean-forward="false" selection-start-line="57" selection-start-column="46" selection-end-line="57" selection-end-column="46" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/lib/rabbitmq/PublishPortShed.php"> <entry file="file://$PROJECT_DIR$/lib/cdz/order/state/ChargerShedTimeOutMessage.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="630"> <state relative-caret-position="0">
<caret line="47" column="20" lean-forward="false" selection-start-line="47" selection-start-column="20" selection-end-line="47" selection-end-column="20" /> <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/lib/remote/api/message/ChargerTimeoutMessage.php"> <entry file="file://$PROJECT_DIR$/lib/remote/api/message/ChargerTimeoutMessage.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="424"> <state relative-caret-position="129">
<caret line="51" column="62" lean-forward="false" selection-start-line="51" selection-start-column="62" selection-end-line="51" selection-end-column="62" /> <caret line="49" column="20" lean-forward="false" selection-start-line="49" selection-start-column="20" selection-end-line="49" selection-end-column="20" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/lib/cdz/order/state/ChargerState.php"> <entry file="file://$PROJECT_DIR$/lib/remote/api/message/ChargerFullMessage.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-59"> <state relative-caret-position="0">
<caret line="98" column="25" lean-forward="true" selection-start-line="98" selection-start-column="25" selection-end-line="98" selection-end-column="25" /> <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/lib/cdz/order/state/ShedState.php"> <entry file="file://$PROJECT_DIR$/lib/remote/api/message/ChargerReloadMessage.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="240"> <state relative-caret-position="765">
<caret line="24" column="5" lean-forward="false" selection-start-line="24" selection-start-column="5" selection-end-line="24" selection-end-column="5" /> <caret line="56" column="14" lean-forward="false" selection-start-line="56" selection-start-column="14" selection-end-line="56" selection-end-column="14" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/.env"> <entry file="file://$PROJECT_DIR$/.env">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="60"> <state relative-caret-position="510">
<caret line="4" column="17" lean-forward="false" selection-start-line="4" selection-start-column="17" selection-end-line="4" selection-end-column="17" /> <caret line="34" column="0" lean-forward="true" selection-start-line="0" selection-start-column="0" selection-end-line="35" selection-end-column="0" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/application/controller/setting/SettingController.php"> <entry file="file://$PROJECT_DIR$/.example">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="360">
<caret line="32" column="4" lean-forward="false" selection-start-line="32" selection-start-column="4" selection-end-line="32" selection-end-column="4" />
<folding>
<element signature="e#135#173#0#PHP" expanded="false" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/vendor/workerman/workerman/Protocols/Frame.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0"> <state relative-caret-position="525">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" /> <caret line="35" column="0" lean-forward="true" selection-start-line="35" selection-start-column="0" selection-end-line="35" selection-end-column="0" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/application/Events.php"> <entry file="file://$PROJECT_DIR$/lib/remote/api/message/ChargerShedMessage.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0"> <state relative-caret-position="330">
<caret line="74" column="27" lean-forward="false" selection-start-line="74" selection-start-column="27" selection-end-line="74" selection-end-column="27" /> <caret line="29" column="20" lean-forward="false" selection-start-line="29" selection-start-column="20" selection-end-line="29" selection-end-column="20" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/vendor/workerman/workerman/Protocols/Bintohex.php"> <entry file="file://$PROJECT_DIR$/lib/remote/api/message/ShedMessage.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="540"> <state relative-caret-position="420">
<caret line="41" column="12" lean-forward="false" selection-start-line="41" selection-start-column="12" selection-end-line="41" selection-end-column="12" /> <caret line="33" column="17" lean-forward="false" selection-start-line="33" selection-start-column="17" selection-end-line="33" selection-end-column="17" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/application/controller/HeartController.php"> <entry file="file://$PROJECT_DIR$/lib/cdz/order/state/ChargerState.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="375"> <state relative-caret-position="1823">
<caret line="30" column="5" lean-forward="false" selection-start-line="30" selection-start-column="5" selection-end-line="30" selection-end-column="5" /> <caret line="265" column="41" lean-forward="false" selection-start-line="265" selection-start-column="41" selection-end-line="265" selection-end-column="41" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/application/start_gateway.php"> <entry file="file://$PROJECT_DIR$/application/model/BillTmpModel.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="240"> <state relative-caret-position="135">
<caret line="21" column="28" lean-forward="false" selection-start-line="21" selection-start-column="28" selection-end-line="21" selection-end-column="28" /> <caret line="14" column="38" lean-forward="false" selection-start-line="14" selection-start-column="38" selection-end-line="14" selection-end-column="38" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/application/controller/accept/CertifyController.php"> <entry file="file://$PROJECT_DIR$/application/model/CardModel.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="687"> <state relative-caret-position="135">
<caret line="65" column="0" lean-forward="false" selection-start-line="65" selection-start-column="0" selection-end-line="65" selection-end-column="0" /> <caret line="14" column="31" lean-forward="false" selection-start-line="14" selection-start-column="31" selection-end-line="14" selection-end-column="31" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/log/GatewayLogWriter.php"> <entry file="file://$PROJECT_DIR$/application/controller/card/BalanceController.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="570"> <state relative-caret-position="300">
<caret line="44" column="27" lean-forward="false" selection-start-line="44" selection-start-column="27" selection-end-line="44" selection-end-column="27" /> <caret line="25" column="13" lean-forward="false" selection-start-line="25" selection-start-column="13" selection-end-line="25" selection-end-column="13" />
<folding /> <folding>
<element signature="e#131#169#0#PHP" expanded="false" />
</folding>
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/log/record/Record.php"> <entry file="file://$PROJECT_DIR$/application/controller/card/PayRuleController.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="657"> <state relative-caret-position="330">
<caret line="223" column="5" lean-forward="true" selection-start-line="223" selection-start-column="5" selection-end-line="223" selection-end-column="5" /> <caret line="27" column="13" lean-forward="false" selection-start-line="27" selection-start-column="13" selection-end-line="27" selection-end-column="13" />
<folding /> <folding>
<element signature="e#131#169#0#PHP" expanded="true" />
</folding>
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/response/Response.php"> <entry file="file://$PROJECT_DIR$/application/controller/business/port/StateController.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="319"> <state relative-caret-position="522">
<caret line="113" column="20" lean-forward="false" selection-start-line="113" selection-start-column="20" selection-end-line="113" selection-end-column="20" /> <caret line="65" column="0" lean-forward="false" selection-start-line="65" selection-start-column="0" selection-end-line="65" selection-end-column="0" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/application/controller/accept/AccessController.php"> <entry file="file://$PROJECT_DIR$/application/controller/business/port/OfflineController.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-1608"> <state relative-caret-position="739">
<caret line="121" column="0" lean-forward="false" selection-start-line="121" selection-start-column="0" selection-end-line="121" selection-end-column="0" /> <caret line="71" column="61" lean-forward="false" selection-start-line="71" selection-start-column="61" selection-end-line="71" selection-end-column="61" />
<folding> <folding />
<element signature="e#978#1032#0#PHP" expanded="false" />
</folding>
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/application/controller/Controller.php"> <entry file="file://$PROJECT_DIR$/lib/cdz/order/state/TimeoutState.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="384"> <state relative-caret-position="852">
<caret line="168" column="9" lean-forward="true" selection-start-line="168" selection-start-column="9" selection-end-line="168" selection-end-column="9" /> <caret line="69" column="5" lean-forward="false" selection-start-line="69" selection-start-column="5" selection-end-line="69" selection-end-column="5" />
<folding> <folding />
<element signature="e#126#152#0#PHP" expanded="true" />
</folding>
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/application/controller/business/port/OnlineController.php"> <entry file="file://$PROJECT_DIR$/lib/cdz/order/state/WaitingState.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0"> <state relative-caret-position="705">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" /> <caret line="64" column="50" lean-forward="false" selection-start-line="64" selection-start-column="50" selection-end-line="64" selection-end-column="50" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/application/controller/business/port/OfflineController.php"> <entry file="file://$PROJECT_DIR$/application/controller/business/port/OnlineController.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0"> <state relative-caret-position="559">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" /> <caret line="61" column="9" lean-forward="false" selection-start-line="61" selection-start-column="9" selection-end-line="61" selection-end-column="9" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/application/controller/business/port/StateController.php"> <entry file="file://$PROJECT_DIR$/lib/StateCode.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-474"> <state relative-caret-position="345">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" /> <caret line="28" column="10" lean-forward="false" selection-start-line="28" selection-start-column="10" selection-end-line="28" selection-end-column="10" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/application/controller/business/power/CapacityController.php"> <entry file="file://$PROJECT_DIR$/application/controller/business/charger/OverController.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0"> <state relative-caret-position="24">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" /> <caret line="71" column="0" lean-forward="false" selection-start-line="71" selection-start-column="0" selection-end-line="71" selection-end-column="0" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/lib/cdz/order/Order.php"> <entry file="file://$PROJECT_DIR$/lib/station/gateway/port/Port.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-980"> <state relative-caret-position="364">
<caret line="13" column="6" lean-forward="false" selection-start-line="13" selection-start-column="6" selection-end-line="13" selection-end-column="6" /> <caret line="139" column="9" lean-forward="false" selection-start-line="139" selection-start-column="9" selection-end-line="139" selection-end-column="9" />
<folding /> <folding>
<element signature="e#128#162#0#PHP" expanded="true" />
</folding>
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/lib/cdz/order/save/OrderSaveRedis.php"> <entry file="file://$PROJECT_DIR$/lib/cdz/order/state/ShedState.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="330"> <state relative-caret-position="571">
<caret line="27" column="35" lean-forward="false" selection-start-line="27" selection-start-column="35" selection-end-line="27" selection-end-column="35" /> <caret line="194" column="58" lean-forward="false" selection-start-line="194" selection-start-column="58" selection-end-line="194" selection-end-column="58" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/application/controller/business/power/PowerController.php"> <entry file="file://$PROJECT_DIR$/lib/remote/api/message/ChargerShedTimeOutMessage.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="624"> <state relative-caret-position="255">
<caret line="74" column="22" lean-forward="false" selection-start-line="74" selection-start-column="22" selection-end-line="74" selection-end-column="22" /> <caret line="22" column="28" lean-forward="true" selection-start-line="22" selection-start-column="28" selection-end-line="22" selection-end-column="28" />
<folding /> <folding />
</state> </state>
</provider> </provider>
......
...@@ -27,6 +27,9 @@ class Events ...@@ -27,6 +27,9 @@ class Events
*/ */
private static $redis; private static $redis;
/**
*
*/
public static function onWorkerStart() public static function onWorkerStart()
{ {
...@@ -46,7 +49,6 @@ class Events ...@@ -46,7 +49,6 @@ class Events
static::$redis->select('4'); static::$redis->select('4');
\Lib\log\Log::bootLog(); \Lib\log\Log::bootLog();
...@@ -72,7 +74,6 @@ class Events ...@@ -72,7 +74,6 @@ class Events
$crc = substr($message, -2); $crc = substr($message, -2);
var_dump($message);
$crcConfirm = sprintf('%08x', Crc::crc(substr($message, 0, strlen($message) - 2))); $crcConfirm = sprintf('%08x', Crc::crc(substr($message, 0, strlen($message) - 2)));
if ($crc != mb_strtoupper(substr($crcConfirm, 0, 2))) { if ($crc != mb_strtoupper(substr($crcConfirm, 0, 2))) {
...@@ -80,6 +81,7 @@ class Events ...@@ -80,6 +81,7 @@ class Events
return; return;
} }
Log::debug($message);
$command = substr($message, 6, 2); $command = substr($message, 6, 2);
$api = new Api(); $api = new Api();
...@@ -110,37 +112,90 @@ class Events ...@@ -110,37 +112,90 @@ class Events
} }
/**
* @param $clientId
*/
public static function onClose($clientId) public static function onClose($clientId)
{ {
var_dump('close'); Log::info('client close', [
'client_id' => $clientId,
'gateway_id' => isset($_SESSION['gateway_id']) ? $_SESSION['gateway_id'] : '',
'station_id' => isset($_SESSION['station_id']) ? $_SESSION['station_id'] : ''
]);
$gatewayId = isset($_SESSION['gateway_id']) ? $_SESSION['gateway_id'] : '';
$stationId = isset($_SESSION['station_id']) ? $_SESSION['station_id'] : '';
if ($gatewayId === '' || $stationId === '') {
Log::error('client close can not find station_id or gateway_id');
return;
}
$exceptionModel = new \Application\model\ExceptionModel();
if (isset($_SESSION['station_id']) && isset($_SESSION['gateway_id'])) {
$exceptionModel->insertRow([
'message' => '网关离线',
'gateway_id' => $_SESSION['gateway_id'],
'station_id' => $_SESSION['station_id'],
'type' => 1,
]);
}
Events::pipe();
$gatewayId = $_SESSION['gateway_id'];
$gateway = new Gateway(); $gateway = new Gateway();
//网关状态设置为离线 //网关状态设置为离线
$gateway->setState($gatewayId, 0); $gateway->setState($gatewayId, 0);
if (isset($_SESSION['port_mac_id']) === false) {
Log::error('gateway close can not find port_mac_id in session');
return;
}
$portsMacId = $_SESSION['port_mac_id']; $portsMacId = $_SESSION['port_mac_id'];
$portsId = array_values($portsMacId); $portsId = array_values($portsMacId);
$port = new Port(); $port = new Port();
$exceptionModel = new \Application\model\ExceptionModel();
$date = date('Y-m-d H:i:s');
foreach ($portsId as $portId) { foreach ($portsId as $portId) {
//所有端口状态设置为离线
$port->setPortId($portId); $port->setPortId($portId);
$port->setState(10); $port->setGatewayId($gatewayId);
$port->setStationId($stationId);
$port->setState(\Lib\StateCode::PORT_OFFLINE);
$port->updatePortState(); $port->updatePortState();
} $exceptionModel->insertRow([
//所有端口状态设置为离线 'gateway_id' => $gatewayId,
Events::exec(); 'station_id' => isset($_SESSION['station_id']) ? $_SESSION['station_id'] : '',
'port_id' => $portId,
//端口当前订单记录离线时间 'message' => '口子离线',
'created_at' => $date,
]);
$portUsingOrderId = $port->getPortUsingOrderId();
//端口当前订单记录离线时间
if ($portUsingOrderId != false && $portUsingOrderId != '') {
$order = new \Lib\cdz\order\Order($portUsingOrderId);
if ($order->getOrderCache(static::$redis) != false) {
$order->setOfflineTime(time());
$saveOrder = new \Lib\cdz\order\save\OrderSaveRedis($order);
$saveOrder->save(['offlineTime']);
unset($saveOrder);
}
}
}
} }
......
...@@ -174,6 +174,11 @@ class Controller ...@@ -174,6 +174,11 @@ class Controller
public function __destruct() public function __destruct()
{ {
if($this->command === '00')
{
return ;
}
$logWriter = new GatewayLogWriter(); $logWriter = new GatewayLogWriter();
if($this->response->getResponseMessage() !== '') if($this->response->getResponseMessage() !== '')
......
...@@ -40,5 +40,7 @@ class HeartController extends Controller ...@@ -40,5 +40,7 @@ class HeartController extends Controller
$redis->zIncrBy(self::GATEWAY_HEART_TIMES,1,$_SESSION['gateway_id']); $redis->zIncrBy(self::GATEWAY_HEART_TIMES,1,$_SESSION['gateway_id']);
$this->response->send('00',sprintf('%08x',time()));
} }
} }
\ No newline at end of file
...@@ -12,10 +12,13 @@ namespace Application\controller\accept; ...@@ -12,10 +12,13 @@ namespace Application\controller\accept;
use Application\controller\Controller; use Application\controller\Controller;
use Application\model\DeviceModel; use Application\model\DeviceModel;
use Application\model\GatewayModel; use Application\model\GatewayModel;
use Application\model\ParkModel;
use Application\model\StationModel;
use Lib\cdz\order\Order; use Lib\cdz\order\Order;
use Lib\cdz\order\state\OfflineNetState; use Lib\cdz\order\state\OfflineNetState;
use Lib\cdz\order\state\OfflinePowerState; use Lib\cdz\order\state\OfflinePowerState;
use Lib\Gateway; use Lib\Gateway;
use Lib\log\Log;
use Lib\StateCode; use Lib\StateCode;
use Lib\station\gateway\port\Port; use Lib\station\gateway\port\Port;
use Src\route\Route; use Src\route\Route;
...@@ -67,9 +70,7 @@ class AccessController extends Controller ...@@ -67,9 +70,7 @@ class AccessController extends Controller
'id', 'id',
], 'mac_address = ' . "'$mac'"); ], 'mac_address = ' . "'$mac'");
var_dump($gatewayModelResult); if ($gatewayModelResult == false) {
if($gatewayModelResult == false)
{
Gateway::closeClient($this->clientId); Gateway::closeClient($this->clientId);
return; return;
} }
...@@ -81,6 +82,20 @@ class AccessController extends Controller ...@@ -81,6 +82,20 @@ class AccessController extends Controller
$this->logRecord->setGatewayId($gatewayId); $this->logRecord->setGatewayId($gatewayId);
$this->logRecord->setStationId($stationId); $this->logRecord->setStationId($stationId);
$stationModel = new StationModel();
$parkId = $stationModel->getColumn('park_id', 'id = ' . $stationId);
if (isset($parkId)) {
$parkModel = new ParkModel();
$_SESSION['park_id'] = $parkId;
$agentId = $parkModel->getColumn('agent_id', 'id = ' . $parkId);
if (isset($agentId)) {
$_SESSION['agent_id'] = $agentId;
}
}
$deviceModel = new DeviceModel(); $deviceModel = new DeviceModel();
...@@ -152,9 +167,8 @@ class AccessController extends Controller ...@@ -152,9 +167,8 @@ class AccessController extends Controller
} }
if(isset($_SESSION['port_mac_id']) == false) if (isset($_SESSION['port_mac_id']) == false) {
{ return;
return ;
} }
$portsMacId = $_SESSION['port_mac_id']; $portsMacId = $_SESSION['port_mac_id'];
...@@ -164,7 +178,15 @@ class AccessController extends Controller ...@@ -164,7 +178,15 @@ class AccessController extends Controller
$port = new Port(); $port = new Port();
$portsLogicId = []; $portsLogicId = [];
$portsId = array_values($portsMacId); // $portsId = array_values($portsMacId);
$portsId = [];
foreach ($portMacState as $mac => $state) {
if (isset($portsMacId[$mac])) {
array_push($portsId, $portsMacId[$mac]);
}
}
foreach ($portMacState as $mac => $state) { foreach ($portMacState as $mac => $state) {
$portId = isset($portsMacId[$mac]) ? $portsMacId[$mac] : false; $portId = isset($portsMacId[$mac]) ? $portsMacId[$mac] : false;
...@@ -178,17 +200,19 @@ class AccessController extends Controller ...@@ -178,17 +200,19 @@ class AccessController extends Controller
$port->setState($state); $port->setState($state);
$port->setGatewayId($_SESSION['gateway_id']); $port->setGatewayId($_SESSION['gateway_id']);
$port->setStationId($_SESSION['station_id']); $port->setStationId($_SESSION['station_id']);
$port->updatePortState(); $port->updatePortState();
$portsLogicId[$portId] = $logicStart++; $portsLogicId[$logicStart++] = $portId;
} }
\Events::exec(); \Events::exec();
$deviceModel = new DeviceModel(); $deviceModel = new DeviceModel();
$_SESSION['port_logic_id'] = $portsLogicId; if (isset($_SESSION['port_logic_id'])) {
$_SESSION['port_logic_id'] = $_SESSION['port_logic_id'] + $portsLogicId;
} else {
$_SESSION['port_logic_id'] = $portsLogicId;
}
//更新逻辑地址 //更新逻辑地址
foreach ($portsLogicId as $portId => $logicId) { foreach ($portsLogicId as $portId => $logicId) {
...@@ -229,6 +253,7 @@ class AccessController extends Controller ...@@ -229,6 +253,7 @@ class AccessController extends Controller
$remainTime = $orderState->getRemainChargerTime(); $remainTime = $orderState->getRemainChargerTime();
if ($remainTime > 0) { if ($remainTime > 0) {
$logicNum = sprintf('%02x', $order->getPortLogicId()); $logicNum = sprintf('%02x', $order->getPortLogicId());
$orderId = sprintf('%012x', $order->getId()); $orderId = sprintf('%012x', $order->getId());
...@@ -246,9 +271,6 @@ class AccessController extends Controller ...@@ -246,9 +271,6 @@ class AccessController extends Controller
$totalCount = sprintf('%02x', $totalCount); $totalCount = sprintf('%02x', $totalCount);
$orderCount = sprintf('%02x', count($responseOrder)); $orderCount = sprintf('%02x', count($responseOrder));
var_dump($logicStart);
$this->response->send('03', $logicStart . $count . $totalCount . $orderCount . implode('', $responseOrder));; $this->response->send('03', $logicStart . $count . $totalCount . $orderCount . implode('', $responseOrder));;
......
...@@ -62,14 +62,12 @@ class CertifyController extends Controller ...@@ -62,14 +62,12 @@ class CertifyController extends Controller
$clients = Gateway::getclientIdByUid($mac); $clients = Gateway::getclientIdByUid($mac);
foreach ($clients as $client) { foreach ($clients as $client) {
var_dump('hello');
Gateway::closeClient($client); Gateway::closeClient($client);
} }
} }
Gateway::bindUid($this->clientId,$mac); Gateway::bindUid($this->clientId, $mac);
$this->response->send('01', $sign); $this->response->send('01', $sign);
......
...@@ -10,12 +10,16 @@ namespace Application\controller\business\charger; ...@@ -10,12 +10,16 @@ namespace Application\controller\business\charger;
use Application\controller\Controller; use Application\controller\Controller;
use Application\model\OrderExceptionModel;
use Application\model\OrderModel; use Application\model\OrderModel;
use Lib\cdz\order\Order; use Lib\cdz\order\Order;
use Lib\cdz\order\state\ChargerState; use Lib\cdz\order\state\ChargerState;
use Lib\cdz\order\state\ShedState; use Lib\cdz\order\state\ShedState;
use Lib\cdz\order\state\WaitingState; use Lib\cdz\order\state\WaitingState;
use Lib\Gateway;
use Lib\log\Log;
use Lib\StateCode; use Lib\StateCode;
use Lib\station\gateway\port\Port;
use Src\route\Route; use Src\route\Route;
class OverController extends Controller class OverController extends Controller
...@@ -47,20 +51,25 @@ class OverController extends Controller ...@@ -47,20 +51,25 @@ class OverController extends Controller
public function over() public function over()
{ {
$type = $this->request->get('type'); $type = $this->request->get('type');
$logicId = $this->request->get('logic_id'); $logicId = hexdec($this->request->get('logic_id'));
$state = hexdec($this->request->get('state')); $state = hexdec($this->request->get('state'));
$orderId = hexdec($this->request->get('order_id')); $orderId = hexdec($this->request->get('order_id'));
$capacity = hexdec($this->request->get('capacity')); $capacity = hexdec($this->request->get('capacity'));
$this->logRecord->setOrderId($orderId); $this->logRecord->setOrderId($orderId);
$order = new Order($orderId);
$order = new Order();
if ($order->getOrderCache(\Events::getRedis()) != false) { if ($order->getOrderCache(\Events::getRedis()) != false) {
$orderStateCode = $order->getStateCode(); $orderStateCode = $order->getStateCode();
$order->setEndCapacity($capacity); $order->setEndCapacity($capacity);
$order->setEndCode($state); $order->setEndCode($state);
if (Gateway::isUidOnline($order->getUserId()) === 1) {
Gateway::sendToUid($order->getUserId(), json_encode(['code' => 10000]));
}
Log::debug('order state code ' . $orderStateCode);
switch ($orderStateCode) { switch ($orderStateCode) {
case StateCode::WAITING: case StateCode::WAITING:
$orderState = new WaitingState($order); $orderState = new WaitingState($order);
...@@ -68,7 +77,7 @@ class OverController extends Controller ...@@ -68,7 +77,7 @@ class OverController extends Controller
case StateCode::PORT_CHARGER: case StateCode::PORT_CHARGER:
$orderState = new ChargerState($order); $orderState = new ChargerState($order);
break; break;
case StateCode::CHARGER_SHED: case StateCode::PORT_SHED:
$orderState = new ShedState($order); $orderState = new ShedState($order);
break; break;
default: default:
...@@ -78,24 +87,55 @@ class OverController extends Controller ...@@ -78,24 +87,55 @@ class OverController extends Controller
if (isset($orderState)) { if (isset($orderState)) {
switch ($state) { switch ($state) {
case StateCode::FINISH_USER: //用户主动结束 case StateCode::FINISH_USER: //用户主动结束
$this->logRecord->setDesc('用户主动结束充电');
$orderState->toUserFinish(); $orderState->toUserFinish();
break; break;
case StateCode::FINISH_SHED_TIMEOUT: //端口脱落超时 case StateCode::FINISH_SHED_TIMEOUT: //端口脱落超时
$this->logRecord->setDesc('端口脱落超时结束');
$orderState->toShedTimeoutState(); $orderState->toShedTimeoutState();
break; break;
case StateCode::FINISH_REFUND: //充电失败退款 case StateCode::FINISH_REFUND: //充电失败退款
$this->logRecord->setDesc('充电失败退款结束');
$orderState->toRefundFinish(); $orderState->toRefundFinish();
break; break;
case StateCode::FINISH_EXCEED: //功率超限 case StateCode::FINISH_EXCEED: //功率超限
$this->logRecord->setDesc('功率超限充电结束');
$orderState->toPowerExceedState(); $orderState->toPowerExceedState();
break; break;
case StateCode::FINISH_FULL: //充满自停 case StateCode::FINISH_FULL: //充满自停
$this->logRecord->setDesc('充满自停结束');
$orderState->toPowerFullState(); $orderState->toPowerFullState();
break; break;
case StateCode::FINISH_TIME_END: //充电时间结束 case StateCode::FINISH_TIME_END: //充电时间结束
$this->logRecord->setDesc('充电时间完结束');
$orderState->toTimeoutState(); $orderState->toTimeoutState();
break; break;
case StateCode::CHANGE_PORT:
if (isset($_SESSION['port_logic_id'])) {
$portId = isset($_SESSION['port_logic_id'][$logicId]) ? $_SESSION['port_logic_id'][$logicId] : 0;
$port = new Port($portId);
$port->setState(StateCode::PORT_ONLINE);
$port->setGatewayId($order->getGatewayId());
$port->setStationId($order->getStationId());
$port->freePort();
$orderExceptionModel = new OrderExceptionModel();
$orderExceptionModel->insertRow([
'order_id' => $orderId,
'created_at' => date('Y-m-d H:i:s'),
'state' => '-1' . StateCode::CHANGE_PORT,
'desc' => '更换口子,' . $portId . '关闭成功',
]);
$this->logRecord->setDesc('更换口子,' . $portId . '关闭成功');
}
$this->response->send('05', sprintf('%02x', $logicId) . sprintf('%012x', $orderId));
return;
default: default:
break; break;
...@@ -117,7 +157,7 @@ class OverController extends Controller ...@@ -117,7 +157,7 @@ class OverController extends Controller
} }
$this->response->send('05', $logicId . sprintf('%12x', $orderId)); $this->response->send('05', sprintf('%02x', $logicId) . sprintf('%012x', $orderId));
} }
......
...@@ -12,6 +12,8 @@ namespace Application\controller\business\charger; ...@@ -12,6 +12,8 @@ namespace Application\controller\business\charger;
use Application\controller\Controller; use Application\controller\Controller;
use Lib\cdz\order\Order; use Lib\cdz\order\Order;
use Lib\cdz\order\state\WaitingState; use Lib\cdz\order\state\WaitingState;
use Lib\Gateway;
use Lib\log\Log;
use Lib\StateCode; use Lib\StateCode;
class StartController extends Controller class StartController extends Controller
...@@ -21,9 +23,9 @@ class StartController extends Controller ...@@ -21,9 +23,9 @@ class StartController extends Controller
'04' => [ '04' => [
'type' => 1, 'type' => 1,
'logic_id' => 1, 'logic_id' => 1,
'state' => 1, 'state' => 1,
'order_id' => 6, 'order_id' => 6,
'capacity' => 4, 'capacity' => 4,
], ],
...@@ -43,11 +45,44 @@ class StartController extends Controller ...@@ -43,11 +45,44 @@ class StartController extends Controller
$logic = $this->getRequest()->get('logic_id'); $logic = $this->getRequest()->get('logic_id');
$state = hexdec($this->getRequest()->get('state')); $state = hexdec($this->getRequest()->get('state'));
$orderId = hexdec($this->getRequest()->get('order_id')); $orderId = hexdec($this->getRequest()->get('order_id'));
$this->logRecord->setOrderId($orderId);
$capacity = hexdec($this->getRequest()->get('capacity')); $capacity = hexdec($this->getRequest()->get('capacity'));
if ($type == 1) { if ($type == 1) {
$waitingState = new WaitingState(new Order($orderId));
$order = new Order($orderId);
if ($order->getOrderCache(\Events::getRedis()) == false) {
$this->response->send('04', sprintf('%012x', $orderId));
return;
}
$order->setStartCapacity($capacity);
if (Gateway::isUidOnline($order->getUserId()) === 1) {
Gateway::sendToUid($order->getUserId(), json_encode(['code' => 10000]));
}
if (isset($_SESSION['agent_id'])) {
Log::debug('agent_id' . $_SESSION['agent_id']);
Log::debug(Gateway::isUidOnline($_SESSION['agent_id']));
if (Gateway::isUidOnline($_SESSION['agent_id'])) {
$clientsId = Gateway::getClientIdByUid($_SESSION['agent_id']);
$clientId = $clientsId[0];
$uIds = Gateway::getUidByClientId($clientId);
var_dump($uIds);
Gateway::sendToUid($_SESSION['agent_id'], json_encode($order->getOrderCache(\Events::getRedis())));
} else {
Log::debug('agent is offline');
}
}
$waitingState = new WaitingState($order);
$portId = $waitingState->getOrder()->getPortId();
$this->logRecord->setPortId($portId);
switch ($state) { switch ($state) {
case StateCode::PORT_CHARGER: case StateCode::PORT_CHARGER:
...@@ -69,7 +104,7 @@ class StartController extends Controller ...@@ -69,7 +104,7 @@ class StartController extends Controller
} }
} }
$this->response->send('04',sprintf('%012x',$orderId)); $this->response->send('04', sprintf('%012x', $orderId));
} }
......
...@@ -10,6 +10,7 @@ namespace Application\controller\business\port; ...@@ -10,6 +10,7 @@ namespace Application\controller\business\port;
use Application\controller\Controller; use Application\controller\Controller;
use Application\model\ExceptionModel;
use Lib\StateCode; use Lib\StateCode;
use Lib\station\gateway\port\Port; use Lib\station\gateway\port\Port;
...@@ -29,7 +30,9 @@ class OfflineController extends Controller ...@@ -29,7 +30,9 @@ class OfflineController extends Controller
} }
/** /**
* * 口子离线
* 更新口子状态
* 记录离线记录
*/ */
public function offline() public function offline()
{ {
...@@ -38,30 +41,47 @@ class OfflineController extends Controller ...@@ -38,30 +41,47 @@ class OfflineController extends Controller
$portsLogicMac = []; $portsLogicMac = [];
$str = substr($this->message,$this->plc); $str = substr($this->message, $this->plc);
$tmp = str_split($str,18); $tmp = str_split($str, 18);
foreach ($tmp as $item) { foreach ($tmp as $item) {
$portsLogicMac[hexdec(substr($item,0,2))] = substr($item,2); $portsLogicMac[hexdec(substr($item, 0, 2))] = substr($item, 2);
} }
if (isset($_SESSION['port_mac_id'])) {
return;
}
$portsMacId = $_SESSION['port_mac_id']; $portsMacId = $_SESSION['port_mac_id'];
$port = new Port(); $port = new Port();
foreach ($portsLogicMac as $portLogic => $portMac) { $exceptionModel = new ExceptionModel();
if (!(isset($_SESSION['station_id']) && isset($_SESSION['gateway_id']))) {
return;
}
if(isset($portsMacId[$portMac])) foreach ($portsLogicMac as $portLogic => $portMac) {
{ if (isset($portsMacId[$portMac])) {
$port->setPortId($portsMacId[$portMac]); $portId = $portsMacId[$portMac];
$port->setPortId($portId);
$port->setStationId($_SESSION['station_id']);
$port->setGatewayId($_SESSION['gateway_id']);
$port->setState(StateCode::PORT_OFFLINE); $port->setState(StateCode::PORT_OFFLINE);
$port->updatePortState(); $port->updatePortState();
//todo 记录口子上线 // 记录口子离线
} $exceptionModel->insertRow([
'message' => '口子离线',
'gateway_id' => isset($_SESSION['gateway_id']) ? $_SESSION['gateway_id'] : '',
'station_id' => isset($_SESSION['stationg_id']) ? $_SESSION['station_id'] : '',
'port_id' => $portId,
'created_at' => date('Y-m-d H:i:s'),
]);
}
} }
} }
......
...@@ -10,6 +10,7 @@ namespace Application\controller\business\port; ...@@ -10,6 +10,7 @@ namespace Application\controller\business\port;
use Application\controller\Controller; use Application\controller\Controller;
use Application\model\ExceptionModel;
use Lib\StateCode; use Lib\StateCode;
use Lib\station\gateway\port\Port; use Lib\station\gateway\port\Port;
...@@ -36,28 +37,48 @@ class OnlineController extends Controller ...@@ -36,28 +37,48 @@ class OnlineController extends Controller
$portsLogicMac = []; $portsLogicMac = [];
$str = substr($this->message,$this->plc); $str = substr($this->message, $this->plc);
$tmp = str_split($str,18); $tmp = str_split($str, 18);
foreach ($tmp as $item) { foreach ($tmp as $item) {
$portsLogicMac[hexdec(substr($item,0,2))] = substr($item,2); $portsLogicMac[hexdec(substr($item, 0, 2))] = substr($item, 2);
} }
if (isset($_SESSION['port_mac_id']) === false) {
return;
}
$portsMacId = $_SESSION['port_mac_id']; $portsMacId = $_SESSION['port_mac_id'];
$port = new Port(); $port = new Port();
$exceptionModel = new ExceptionModel();
if (!(isset($_SESSION['station_id']) && isset($_SESSION['gateway_id']))) {
return;
}
foreach ($portsLogicMac as $portLogic => $portMac) { foreach ($portsLogicMac as $portLogic => $portMac) {
if (isset($portsMacId[$portMac])) {
if(isset($portsMacId[$portMac])) $portId = $portsMacId[$portMac];
{ $port->setPortId($portId);
$port->setPortId($portsMacId[$portMac]); $port->setStationId($_SESSION['station_id']);
$port->setGatewayId($_SESSION['gateway_id']);
$port->setState(StateCode::PORT_ONLINE); $port->setState(StateCode::PORT_ONLINE);
$port->updatePortState(); $port->updatePortState();
//todo 记录口子上线
// 记录口子上线
$exceptionModel->insertRow([
'port_id' => $portId,
'gateway_id' => isset($_SESSION['gateway_id']) ? $_SESSION['gateway_id'] : '',
'station_id' => isset($_SESSION['station_id']) ? $_SESSION['station_id'] : '',
'created_at' => date('Y-m-d H:i:s'),
]);
} }
} }
......
...@@ -15,6 +15,9 @@ use Lib\cdz\order\state\ChargerState; ...@@ -15,6 +15,9 @@ use Lib\cdz\order\state\ChargerState;
use Lib\cdz\order\state\ExceptionState; use Lib\cdz\order\state\ExceptionState;
use Lib\cdz\order\state\PowerExceedState; use Lib\cdz\order\state\PowerExceedState;
use Lib\cdz\order\state\ShedState; use Lib\cdz\order\state\ShedState;
use Lib\cdz\order\state\WaitingState;
use Lib\Gateway;
use Lib\log\Log;
use Lib\StateCode; use Lib\StateCode;
use Lib\station\gateway\port\Port; use Lib\station\gateway\port\Port;
...@@ -23,7 +26,7 @@ class StateController extends Controller ...@@ -23,7 +26,7 @@ class StateController extends Controller
protected $parameterMap = [ protected $parameterMap = [
'0b' => [ '0B' => [
'port_logic' => 1, 'port_logic' => 1,
'mac' => 8, 'mac' => 8,
'state' => 1, 'state' => 1,
...@@ -39,23 +42,36 @@ class StateController extends Controller ...@@ -39,23 +42,36 @@ class StateController extends Controller
{ {
$portLogic = $this->request->get('port_logic'); $portLogic = $this->request->get('port_logic');
$mac = $this->request->get('mac'); $mac = $this->request->get('mac');
$state = $this->request->get('state'); $state = hexdec($this->request->get('state'));
$portsMacId = $_SESSION['port_mac_id']; $portsMacId = $_SESSION['port_mac_id'];
if (isset($portsMacId[$mac]) === false) {
return;
}
$portId = $portsMacId[$mac]; $portId = $portsMacId[$mac];
$port = new Port($portId); $port = new Port($portId);
$usingOrder = $port->getPortUsingOrderId(); $usingOrderId = $port->getPortUsingOrderId();
if ($usingOrder == false || $usingOrder = '') { if ($usingOrderId == false || $usingOrderId == '') {
$port->setState($state); $port->setState($state);
$port->updatePortState(); if (isset($_SESSION['gateway_id']) && isset($_SESSION['station_id'])) {
$port->setGatewayId($_SESSION['gateway_id']);
$port->setStationId($_SESSION['station_id']);
$port->updatePortState();
} else {
Log::error('can not find station_id or gateway_id from session (change state)');
}
} else { } else {
$order = new Order($usingOrder); $this->logRecord->setOrderId($usingOrderId);
$this->logRecord->setPortId($portId);
$order = new Order((int)$usingOrderId);
if ($order->getOrderCache(\Events::getRedis()) == false) { if ($order->getOrderCache(\Events::getRedis()) == false) {
$port->setState($state); $port->setState($state);
...@@ -63,12 +79,17 @@ class StateController extends Controller ...@@ -63,12 +79,17 @@ class StateController extends Controller
return; return;
} }
// if (Gateway::isUidOnline($order->getUserId()) === 1) {
// Gateway::sendToUid($order->getUserId(), json_encode(['code' => 10000]));
// }
Log::debug('order last state ' . $order->getStateCode());
switch ($order->getStateCode()) { switch ($order->getStateCode()) {
case StateCode::PORT_CHARGER: case StateCode::PORT_CHARGER:
$orderState = new ChargerState($order); $orderState = new ChargerState($order);
break; break;
case StateCode::CHARGER_SHED: case StateCode::PORT_SHED:
$orderState = new ShedState($order); $orderState = new ShedState($order);
break; break;
case StateCode::FINISH_EXCEED: case StateCode::FINISH_EXCEED:
...@@ -79,11 +100,15 @@ class StateController extends Controller ...@@ -79,11 +100,15 @@ class StateController extends Controller
case StateCode::PORT_EXCEPTION: case StateCode::PORT_EXCEPTION:
$orderState = new ExceptionState($order); $orderState = new ExceptionState($order);
break; break;
case StateCode::WAITING:
$orderState = new WaitingState($order);
break;
default: default:
return; break;
} }
Log::debug('now state' . $state);
switch ($state) { switch ($state) {
case StateCode::PORT_CHARGER: case StateCode::PORT_CHARGER:
$orderState->toChargerState(); $orderState->toChargerState();
...@@ -92,6 +117,11 @@ class StateController extends Controller ...@@ -92,6 +117,11 @@ class StateController extends Controller
$orderState->toPowerExceedState(); $orderState->toPowerExceedState();
break; break;
case StateCode::PORT_SHED:
$orderState->toShedState();
break;
default : default :
break; break;
} }
......
...@@ -14,6 +14,7 @@ use Application\model\OrderModel; ...@@ -14,6 +14,7 @@ use Application\model\OrderModel;
use Application\model\OrderPowerModel; use Application\model\OrderPowerModel;
use Lib\cdz\order\Order; use Lib\cdz\order\Order;
use Lib\cdz\order\save\OrderSaveRedis; use Lib\cdz\order\save\OrderSaveRedis;
use Lib\log\Log;
use Lib\station\gateway\port\Port; use Lib\station\gateway\port\Port;
class PowerController extends Controller class PowerController extends Controller
...@@ -48,13 +49,14 @@ class PowerController extends Controller ...@@ -48,13 +49,14 @@ class PowerController extends Controller
$capacity = hexdec($this->request->get('capacity')); $capacity = hexdec($this->request->get('capacity'));
if (isset($_SESSION['port_id_logic']) == false) {
if (isset($_SESSION['port_logic_id']) == false) {
return; return;
} }
$portsLogicId = array_flip($_SESSION['port_id_logic']);
$portsLogicId = $_SESSION['port_logic_id'];
if (isset($portsLogicId[$logicId])) { if (isset($portsLogicId[$logicId])) {
$portId = $portsLogicId[$logicId]; $portId = $portsLogicId[$logicId];
$port = new Port($portId); $port = new Port($portId);
...@@ -63,6 +65,8 @@ class PowerController extends Controller ...@@ -63,6 +65,8 @@ class PowerController extends Controller
if ($orderId == false || $orderId == '') { if ($orderId == false || $orderId == '') {
return; return;
} }
$this->logRecord->setOrderId($orderId);
$this->logRecord->setPortId($portId);
$order = new Order($orderId); $order = new Order($orderId);
if ($order->getOrderCache(\Events::getRedis()) != false) { if ($order->getOrderCache(\Events::getRedis()) != false) {
...@@ -80,6 +84,7 @@ class PowerController extends Controller ...@@ -80,6 +84,7 @@ class PowerController extends Controller
} }
$orderPowerModel = new OrderPowerModel(); $orderPowerModel = new OrderPowerModel();
$orderPowerModel->insertRow([ $orderPowerModel->insertRow([
'order_id' => $orderId, 'order_id' => $orderId,
'capacity' => $capacity, 'capacity' => $capacity,
...@@ -89,6 +94,10 @@ class PowerController extends Controller ...@@ -89,6 +94,10 @@ class PowerController extends Controller
]); ]);
} else {
Log::debug('no port_id');
} }
...@@ -97,6 +106,88 @@ class PowerController extends Controller ...@@ -97,6 +106,88 @@ class PowerController extends Controller
public function plural() public function plural()
{ {
$logicId = hexdec($this->request->get('logic_id'));
$startTime = hexdec($this->request->get('start_time'));
$intervalTime = hexdec($this->request->get('interval_time')) * 60;
$count = $this->request->get('count');
$powers = substr($this->message, $this->plc, $count * 4);
$this->plc += ($count * 4);
$capacitys = substr($this->message, $this->plc, $count * 8);
$powers = explode($powers, 4);
$capacitys = explode($capacitys, 8);
if (count($powers) != $count || count($capacitys) != $count) {
Log::error('plural miss power or capacity,less than count ');
return;
}
if (isset($_SESSION['port_id_logic']) == false) {
return;
}
$portsLogicId = array_flip($_SESSION['port_logic_id']);
if (isset($portsLogicId[$logicId])) {
$portId = $portsLogicId[$logicId];
$port = new Port($portId);
$orderId = $port->getPortUsingOrderId();
if ($orderId == false || $orderId == '') {
Log::error('power data can not find order_id', [
'logic_id' => $logicId,
'message' => $this->message,
]);
return;
}
$this->logRecord->setPortId($portId);
$this->logRecord->setOrderId($orderId);
$orderPowerModel = new OrderPowerModel();
for ($i = 0; $i < $count; $i++) {
$orderPowerModel->insertRow([
'created_at' => date('Y-m-d H:i:s', $startTime),
'order_id' => $orderId,
'port_id' => $portId,
'power' => $powers[$i],
'capacity' => $capacitys[$i],
]);
$startTime += $intervalTime;
}
}
} }
} }
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: banice
* Date: 2018/8/28
* Time: 上午9:56
*/
namespace Application\controller\card;
use Application\controller\Controller;
use Application\model\CardModel;
class BalanceController extends Controller
{
protected $parameterMap = [
'32' => [
'card_id' => 6
]
];
/**
* 获取卡的余额
*/
public function get()
{
$cardId = $this->request->get('card_id');
$cardModel = new CardModel();
$balance = $cardModel->getColumn('balance', 'card_number = ' . $cardId);
$balance = isset($balance) ? $balance : 0;
$balance = sprintf('%04x', $balance);
var_dump($balance);
$this->response->send('32', $cardId . $balance);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: banice
* Date: 2018/8/28
* Time: 上午9:52
*/
namespace Application\controller\card;
use Application\controller\Controller;
use Application\model\BillTmpModel;
use GatewayWorker\Lib\Gateway;
class PayRuleController extends Controller
{
protected $parameterMap = [
'31' => [
]
];
/**
* 获取扣费套餐
*/
public function get()
{
$billingTmp = new BillTmpModel();
if (isset($_SESSION['station_id']) == false) {
Gateway::closeClient($this->clientId);
}
$rule = $billingTmp->getColumn('context', 'id = ' . $_SESSION['station_id']);
if (isset($rule)) {
$rule = json_decode($rule, true);
$back = [];
$count = count($rule);
foreach ($rule as $item) {
$time = sprintf('%02x', $item['time']);
$price = sprintf('%02x', $item['price']);
array_push($back, $time . $price);
}
$this->response->send('31', sprintf('%02x', $count) . implode($back));
}
}
}
\ No newline at end of file
...@@ -18,7 +18,7 @@ class SettingController extends Controller ...@@ -18,7 +18,7 @@ class SettingController extends Controller
protected $parameterMap = [ protected $parameterMap = [
'0a' => [] '0A' => []
]; ];
public function __construct(string $clientId, string $message, string $command) public function __construct(string $clientId, string $message, string $command)
......
<?php
/**
* Created by PhpStorm.
* User: banice
* Date: 2018/8/28
* Time: 上午9:54
*/
namespace Application\model;
class BillTmpModel extends Model
{
protected $table = 'billing_tmps';
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: banice
* Date: 2018/8/28
* Time: 上午9:57
*/
namespace Application\model;
class CardModel extends Model
{
protected $table = 'cards';
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: banice
* Date: 2018/8/24
* Time: 上午10:15
*/
namespace Application\model;
class ExceptionModel extends Model
{
protected $table = 'exception';
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: banice
* Date: 2018/8/23
* Time: 下午7:46
*/
namespace Application\model;
class ParkModel extends Model
{
protected $table = 'parks';
}
\ No newline at end of file
...@@ -14,4 +14,5 @@ class StationModel extends Model ...@@ -14,4 +14,5 @@ class StationModel extends Model
protected $table = 'stations'; protected $table = 'stations';
} }
\ No newline at end of file
...@@ -22,7 +22,7 @@ class Api ...@@ -22,7 +22,7 @@ class Api
$this->add('04','business\charger\StartController@start'); $this->add('04','business\charger\StartController@start');
$this->add('05','business\charger\OverController@over'); $this->add('05','business\charger\OverController@over');
$this->add('0b','business\port\StateController@change'); $this->add('0B','business\port\StateController@change');
$this->add('07','business\power\PowerController@plural'); $this->add('07','business\power\PowerController@plural');
$this->add('17','business\power\PowerController@one'); $this->add('17','business\power\PowerController@one');
...@@ -33,8 +33,8 @@ class Api ...@@ -33,8 +33,8 @@ class Api
$this->add('08','business\port\OnlineController@online'); $this->add('08','business\port\OnlineController@online');
$this->add('09','business\port\OfflineController@offline'); $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('0A','setting\SettingController@get');
} }
......
<?php <?php
namespace Lib; namespace Lib;
use \Exception; use \Exception;
/** /**
* This file is part of workerman. * This file is part of workerman.
* *
...@@ -19,7 +21,6 @@ use \Exception; ...@@ -19,7 +21,6 @@ use \Exception;
* 数据发送相关 * 数据发送相关
* @version 3.0.10 * @version 3.0.10
*/ */
class Gateway class Gateway
{ {
/** /**
...@@ -34,7 +35,7 @@ class Gateway ...@@ -34,7 +35,7 @@ class Gateway
* *
* @var string * @var string
*/ */
public static $registerAddress = 'webapppush.default:1240'; public static $registerAddress = 'webapppush.default:1239';
//public static $registerAddress = '127.0.0.1:1236'; //public static $registerAddress = '127.0.0.1:1236';
...@@ -59,17 +60,17 @@ class Gateway ...@@ -59,17 +60,17 @@ class Gateway
/** /**
* 向所有客户端连接(或者 client_id_array 指定的客户端连接)广播消息 * 向所有客户端连接(或者 client_id_array 指定的客户端连接)广播消息
* *
* @param string $message 向客户端发送的消息 * @param string $message 向客户端发送的消息
* @param array $client_id_array 客户端 id 数组 * @param array $client_id_array 客户端 id 数组
* @param array $exclude_client_id 不给这些client_id发 * @param array $exclude_client_id 不给这些client_id发
* @param bool $raw 是否发送原始数据(即不调用gateway的协议的encode方法) * @param bool $raw 是否发送原始数据(即不调用gateway的协议的encode方法)
* @return void * @return void
* @throws Exception * @throws Exception
*/ */
public static function sendToAll($message, $client_id_array = null, $exclude_client_id = null, $raw = false) public static function sendToAll($message, $client_id_array = null, $exclude_client_id = null, $raw = false)
{ {
$gateway_data = GatewayProtocol::$empty; $gateway_data = GatewayProtocol::$empty;
$gateway_data['cmd'] = GatewayProtocol::CMD_SEND_TO_ALL; $gateway_data['cmd'] = GatewayProtocol::CMD_SEND_TO_ALL;
$gateway_data['body'] = $message; $gateway_data['body'] = $message;
if ($raw) { if ($raw) {
$gateway_data['flag'] |= GatewayProtocol::FLAG_NOT_CALL_ENCODE; $gateway_data['flag'] |= GatewayProtocol::FLAG_NOT_CALL_ENCODE;
...@@ -86,7 +87,7 @@ class Gateway ...@@ -86,7 +87,7 @@ class Gateway
if ($client_id_array) { if ($client_id_array) {
if (!is_array($client_id_array)) { if (!is_array($client_id_array)) {
echo new \Exception('bad $client_id_array:'.var_export($client_id_array, true)); echo new \Exception('bad $client_id_array:' . var_export($client_id_array, true));
return; return;
} }
$data_array = array(); $data_array = array();
...@@ -96,12 +97,12 @@ class Gateway ...@@ -96,12 +97,12 @@ class Gateway
} }
$address = Context::clientIdToAddress($client_id); $address = Context::clientIdToAddress($client_id);
if ($address) { if ($address) {
$key = long2ip($address['local_ip']) . ":{$address['local_port']}"; $key = long2ip($address['local_ip']) . ":{$address['local_port']}";
$data_array[$key][$address['connection_id']] = $address['connection_id']; $data_array[$key][$address['connection_id']] = $address['connection_id'];
} }
} }
foreach ($data_array as $addr => $connection_id_list) { foreach ($data_array as $addr => $connection_id_list) {
$the_gateway_data = $gateway_data; $the_gateway_data = $gateway_data;
$the_gateway_data['ext_data'] = json_encode(array('connections' => $connection_id_list)); $the_gateway_data['ext_data'] = json_encode(array('connections' => $connection_id_list));
static::sendToGateway($addr, $the_gateway_data); static::sendToGateway($addr, $the_gateway_data);
} }
...@@ -120,7 +121,7 @@ class Gateway ...@@ -120,7 +121,7 @@ class Gateway
if (static::$businessWorker) { if (static::$businessWorker) {
foreach (static::$businessWorker->gatewayConnections as $address => $gateway_connection) { foreach (static::$businessWorker->gatewayConnections as $address => $gateway_connection) {
$gateway_data['ext_data'] = isset($address_connection_array[$address]) ? $gateway_data['ext_data'] = isset($address_connection_array[$address]) ?
json_encode(array('exclude'=> $address_connection_array[$address])) : ''; json_encode(array('exclude' => $address_connection_array[$address])) : '';
/** @var TcpConnection $gateway_connection */ /** @var TcpConnection $gateway_connection */
$gateway_connection->send($gateway_data); $gateway_connection->send($gateway_data);
} }
...@@ -133,7 +134,7 @@ class Gateway ...@@ -133,7 +134,7 @@ class Gateway
} }
foreach ($all_addresses as $address) { foreach ($all_addresses as $address) {
$gateway_data['ext_data'] = isset($address_connection_array[$address]) ? $gateway_data['ext_data'] = isset($address_connection_array[$address]) ?
json_encode(array('exclude'=> $address_connection_array[$address])) : ''; json_encode(array('exclude' => $address_connection_array[$address])) : '';
static::sendToGateway($address, $gateway_data); static::sendToGateway($address, $gateway_data);
} }
} }
...@@ -143,7 +144,7 @@ class Gateway ...@@ -143,7 +144,7 @@ class Gateway
/** /**
* 向某个client_id对应的连接发消息 * 向某个client_id对应的连接发消息
* *
* @param int $client_id * @param int $client_id
* @param string $message * @param string $message
* @return void * @return void
*/ */
...@@ -175,14 +176,14 @@ class Gateway ...@@ -175,14 +176,14 @@ class Gateway
if (!$address_data) { if (!$address_data) {
return 0; return 0;
} }
$address = long2ip($address_data['local_ip']) . ":{$address_data['local_port']}"; $address = long2ip($address_data['local_ip']) . ":{$address_data['local_port']}";
if (isset(static::$businessWorker)) { if (isset(static::$businessWorker)) {
if (!isset(static::$businessWorker->gatewayConnections[$address])) { if (!isset(static::$businessWorker->gatewayConnections[$address])) {
return 0; return 0;
} }
} }
$gateway_data = GatewayProtocol::$empty; $gateway_data = GatewayProtocol::$empty;
$gateway_data['cmd'] = GatewayProtocol::CMD_IS_ONLINE; $gateway_data['cmd'] = GatewayProtocol::CMD_IS_ONLINE;
$gateway_data['connection_id'] = $address_data['connection_id']; $gateway_data['connection_id'] = $address_data['connection_id'];
return (int)static::sendAndRecv($address, $gateway_data); return (int)static::sendAndRecv($address, $gateway_data);
} }
...@@ -209,12 +210,12 @@ class Gateway ...@@ -209,12 +210,12 @@ class Gateway
{ {
$gateway_data = GatewayProtocol::$empty; $gateway_data = GatewayProtocol::$empty;
if (!$group) { if (!$group) {
$gateway_data['cmd'] = GatewayProtocol::CMD_GET_ALL_CLIENT_SESSIONS; $gateway_data['cmd'] = GatewayProtocol::CMD_GET_ALL_CLIENT_SESSIONS;
} else { } else {
$gateway_data['cmd'] = GatewayProtocol::CMD_GET_CLINET_SESSUONS_BY_GROUP; $gateway_data['cmd'] = GatewayProtocol::CMD_GET_CLINET_SESSUONS_BY_GROUP;
$gateway_data['ext_data'] = $group; $gateway_data['ext_data'] = $group;
} }
$status_data = array(); $status_data = array();
$all_buffer_array = static::getBufferFromAllGateway($gateway_data); $all_buffer_array = static::getBufferFromAllGateway($gateway_data);
foreach ($all_buffer_array as $local_ip => $buffer_array) { foreach ($all_buffer_array as $local_ip => $buffer_array) {
foreach ($buffer_array as $local_port => $data) { foreach ($buffer_array as $local_port => $data) {
...@@ -288,11 +289,11 @@ class Gateway ...@@ -288,11 +289,11 @@ class Gateway
*/ */
public static function getClientIdCountByGroup($group = '') public static function getClientIdCountByGroup($group = '')
{ {
$gateway_data = GatewayProtocol::$empty; $gateway_data = GatewayProtocol::$empty;
$gateway_data['cmd'] = GatewayProtocol::CMD_GET_CLIENT_COUNT_BY_GROUP; $gateway_data['cmd'] = GatewayProtocol::CMD_GET_CLIENT_COUNT_BY_GROUP;
$gateway_data['ext_data'] = $group; $gateway_data['ext_data'] = $group;
$total_count = 0; $total_count = 0;
$all_buffer_array = static::getBufferFromAllGateway($gateway_data); $all_buffer_array = static::getBufferFromAllGateway($gateway_data);
foreach ($all_buffer_array as $local_ip => $buffer_array) { foreach ($all_buffer_array as $local_ip => $buffer_array) {
foreach ($buffer_array as $local_port => $count) { foreach ($buffer_array as $local_port => $count) {
if ($count) { if ($count) {
...@@ -380,11 +381,11 @@ class Gateway ...@@ -380,11 +381,11 @@ class Gateway
*/ */
public static function getClientIdByUid($uid) public static function getClientIdByUid($uid)
{ {
$gateway_data = GatewayProtocol::$empty; $gateway_data = GatewayProtocol::$empty;
$gateway_data['cmd'] = GatewayProtocol::CMD_GET_CLIENT_ID_BY_UID; $gateway_data['cmd'] = GatewayProtocol::CMD_GET_CLIENT_ID_BY_UID;
$gateway_data['ext_data'] = $uid; $gateway_data['ext_data'] = $uid;
$client_list = array(); $client_list = array();
$all_buffer_array = static::getBufferFromAllGateway($gateway_data); $all_buffer_array = static::getBufferFromAllGateway($gateway_data);
foreach ($all_buffer_array as $local_ip => $buffer_array) { foreach ($all_buffer_array as $local_ip => $buffer_array) {
foreach ($buffer_array as $local_port => $connection_id_array) { foreach ($buffer_array as $local_port => $connection_id_array) {
if ($connection_id_array) { if ($connection_id_array) {
...@@ -478,7 +479,7 @@ class Gateway ...@@ -478,7 +479,7 @@ class Gateway
*/ */
public static function getUidByClientId($client_id) public static function getUidByClientId($client_id)
{ {
$data = static::select(array('uid'), array('client_id'=>array($client_id))); $data = static::select(array('uid'), array('client_id' => array($client_id)));
foreach ($data as $local_ip => $buffer_array) { foreach ($data as $local_ip => $buffer_array) {
foreach ($buffer_array as $local_port => $items) { foreach ($buffer_array as $local_port => $items) {
//$items = ['connection_id'=>['uid'=>x, 'group'=>[x,x..], 'session'=>[..]], 'client_id'=>[..], ..]; //$items = ['connection_id'=>['uid'=>x, 'group'=>[x,x..], 'session'=>[..]], 'client_id'=>[..], ..];
...@@ -496,10 +497,10 @@ class Gateway ...@@ -496,10 +497,10 @@ class Gateway
*/ */
public static function getAllGroupIdList() public static function getAllGroupIdList()
{ {
$gateway_data = GatewayProtocol::$empty; $gateway_data = GatewayProtocol::$empty;
$gateway_data['cmd'] = GatewayProtocol::CMD_GET_GROUP_ID_LIST; $gateway_data['cmd'] = GatewayProtocol::CMD_GET_GROUP_ID_LIST;
$group_id_list = array(); $group_id_list = array();
$all_buffer_array = static::getBufferFromAllGateway($gateway_data); $all_buffer_array = static::getBufferFromAllGateway($gateway_data);
foreach ($all_buffer_array as $local_ip => $buffer_array) { foreach ($all_buffer_array as $local_ip => $buffer_array) {
foreach ($buffer_array as $local_port => $group_id_array) { foreach ($buffer_array as $local_port => $group_id_array) {
if (is_array($group_id_array)) { if (is_array($group_id_array)) {
...@@ -531,7 +532,6 @@ class Gateway ...@@ -531,7 +532,6 @@ class Gateway
} }
/** /**
* 获取所有分组uid在线列表 * 获取所有分组uid在线列表
* *
...@@ -539,7 +539,7 @@ class Gateway ...@@ -539,7 +539,7 @@ class Gateway
*/ */
public static function getAllGroupUidList() public static function getAllGroupUidList()
{ {
$data = static::select(array('uid','groups')); $data = static::select(array('uid', 'groups'));
$group_uid_map = array(); $group_uid_map = array();
foreach ($data as $local_ip => $buffer_array) { foreach ($data as $local_ip => $buffer_array) {
foreach ($buffer_array as $local_port => $items) { foreach ($buffer_array as $local_port => $items) {
...@@ -550,7 +550,7 @@ class Gateway ...@@ -550,7 +550,7 @@ class Gateway
} }
$uid = $info['uid']; $uid = $info['uid'];
foreach ($info['groups'] as $group_id) { foreach ($info['groups'] as $group_id) {
if(!isset($group_uid_map[$group_id])) { if (!isset($group_uid_map[$group_id])) {
$group_uid_map[$group_id] = array(); $group_uid_map[$group_id] = array();
} }
$group_uid_map[$group_id][$uid] = $uid; $group_uid_map[$group_id][$uid] = $uid;
...@@ -579,7 +579,7 @@ class Gateway ...@@ -579,7 +579,7 @@ class Gateway
} }
$client_id = Context::addressToClientId($local_ip, $local_port, $connection_id); $client_id = Context::addressToClientId($local_ip, $local_port, $connection_id);
foreach ($info['groups'] as $group_id) { foreach ($info['groups'] as $group_id) {
if(!isset($group_client_id_map[$group_id])) { if (!isset($group_client_id_map[$group_id])) {
$group_client_id_map[$group_id] = array(); $group_client_id_map[$group_id] = array();
} }
$group_client_id_map[$group_id][$client_id] = $client_id; $group_client_id_map[$group_id][$client_id] = $client_id;
...@@ -613,13 +613,13 @@ class Gateway ...@@ -613,13 +613,13 @@ class Gateway
* @param array $where * @param array $where
* @return array * @return array
*/ */
protected static function select($fields = array('session','uid','groups'), $where = array()) protected static function select($fields = array('session', 'uid', 'groups'), $where = array())
{ {
$t = microtime(true); $t = microtime(true);
$gateway_data = GatewayProtocol::$empty; $gateway_data = GatewayProtocol::$empty;
$gateway_data['cmd'] = GatewayProtocol::CMD_SELECT; $gateway_data['cmd'] = GatewayProtocol::CMD_SELECT;
$gateway_data['ext_data'] = array('fields' => $fields, 'where' => $where); $gateway_data['ext_data'] = array('fields' => $fields, 'where' => $where);
$gateway_data_list = array(); $gateway_data_list = array();
// 有client_id,能计算出需要和哪些gateway通讯,只和必要的gateway通讯能降低系统负载 // 有client_id,能计算出需要和哪些gateway通讯,只和必要的gateway通讯能降低系统负载
if (isset($where['client_id'])) { if (isset($where['client_id'])) {
$client_id_list = $where['client_id']; $client_id_list = $where['client_id'];
...@@ -664,8 +664,8 @@ class Gateway ...@@ -664,8 +664,8 @@ class Gateway
*/ */
protected static function generateAuthBuffer() protected static function generateAuthBuffer()
{ {
$gateway_data = GatewayProtocol::$empty; $gateway_data = GatewayProtocol::$empty;
$gateway_data['cmd'] = GatewayProtocol::CMD_GATEWAY_CLIENT_CONNECT; $gateway_data['cmd'] = GatewayProtocol::CMD_GATEWAY_CLIENT_CONNECT;
$gateway_data['body'] = json_encode(array( $gateway_data['body'] = json_encode(array(
'secret_key' => static::$secretKey, 'secret_key' => static::$secretKey,
)); ));
...@@ -685,7 +685,7 @@ class Gateway ...@@ -685,7 +685,7 @@ class Gateway
$auth_buffer = static::$secretKey ? static::generateAuthBuffer() : ''; $auth_buffer = static::$secretKey ? static::generateAuthBuffer() : '';
foreach ($gateway_data_array as $address => $gateway_data) { foreach ($gateway_data_array as $address => $gateway_data) {
if ($auth_buffer) { if ($auth_buffer) {
$gateway_buffer_array[$address] = $auth_buffer.GatewayProtocol::encode($gateway_data); $gateway_buffer_array[$address] = $auth_buffer . GatewayProtocol::encode($gateway_data);
} else { } else {
$gateway_buffer_array[$address] = GatewayProtocol::encode($gateway_data); $gateway_buffer_array[$address] = GatewayProtocol::encode($gateway_data);
} }
...@@ -749,23 +749,23 @@ class Gateway ...@@ -749,23 +749,23 @@ class Gateway
foreach ($gateway_buffer_array as $address => $gateway_buffer) { foreach ($gateway_buffer_array as $address => $gateway_buffer) {
$client = stream_socket_client("tcp://$address", $errno, $errmsg, static::$connectTimeout); $client = stream_socket_client("tcp://$address", $errno, $errmsg, static::$connectTimeout);
if ($client && strlen($gateway_buffer) === stream_socket_sendto($client, $gateway_buffer)) { if ($client && strlen($gateway_buffer) === stream_socket_sendto($client, $gateway_buffer)) {
$socket_id = (int)$client; $socket_id = (int)$client;
$client_array[$socket_id] = $client; $client_array[$socket_id] = $client;
$client_address_map[$socket_id] = explode(':', $address); $client_address_map[$socket_id] = explode(':', $address);
$receive_buffer_array[$socket_id] = ''; $receive_buffer_array[$socket_id] = '';
} }
} }
// 超时5秒 // 超时5秒
$timeout = 5; $timeout = 5;
$time_start = microtime(true); $time_start = microtime(true);
// 批量接收请求 // 批量接收请求
while (count($client_array) > 0) { while (count($client_array) > 0) {
$write = $except = array(); $write = $except = array();
$read = $client_array; $read = $client_array;
if (@stream_select($read, $write, $except, $timeout)) { if (@stream_select($read, $write, $except, $timeout)) {
foreach ($read as $client) { foreach ($read as $client) {
$socket_id = (int)$client; $socket_id = (int)$client;
$buffer = stream_socket_recvfrom($client, 65535); $buffer = stream_socket_recvfrom($client, 65535);
if ($buffer !== '' && $buffer !== false) { if ($buffer !== '' && $buffer !== false) {
$receive_buffer_array[$socket_id] .= $buffer; $receive_buffer_array[$socket_id] .= $buffer;
$receive_length = strlen($receive_buffer_array[$socket_id]); $receive_length = strlen($receive_buffer_array[$socket_id]);
...@@ -786,8 +786,8 @@ class Gateway ...@@ -786,8 +786,8 @@ class Gateway
} }
$format_buffer_array = array(); $format_buffer_array = array();
foreach ($receive_buffer_array as $socket_id => $buffer) { foreach ($receive_buffer_array as $socket_id => $buffer) {
$local_ip = ip2long($client_address_map[$socket_id][0]); $local_ip = ip2long($client_address_map[$socket_id][0]);
$local_port = $client_address_map[$socket_id][1]; $local_port = $client_address_map[$socket_id][1];
$format_buffer_array[$local_ip][$local_port] = unserialize(substr($buffer, 4)); $format_buffer_array[$local_ip][$local_port] = unserialize(substr($buffer, 4));
} }
return $format_buffer_array; return $format_buffer_array;
...@@ -810,7 +810,7 @@ class Gateway ...@@ -810,7 +810,7 @@ class Gateway
if (!$address_data) { if (!$address_data) {
return false; return false;
} }
$address = long2ip($address_data['local_ip']) . ":{$address_data['local_port']}"; $address = long2ip($address_data['local_ip']) . ":{$address_data['local_port']}";
return static::kickAddress($address, $address_data['connection_id'], $message); return static::kickAddress($address, $address_data['connection_id'], $message);
} }
} }
...@@ -870,7 +870,7 @@ class Gateway ...@@ -870,7 +870,7 @@ class Gateway
/** /**
* 将 client_id 与 uid 绑定 * 将 client_id 与 uid 绑定
* *
* @param int $client_id * @param int $client_id
* @param int|string $uid * @param int|string $uid
* @return void * @return void
*/ */
...@@ -882,7 +882,7 @@ class Gateway ...@@ -882,7 +882,7 @@ class Gateway
/** /**
* 将 client_id 与 uid 解除绑定 * 将 client_id 与 uid 解除绑定
* *
* @param int $client_id * @param int $client_id
* @param int|string $uid * @param int|string $uid
* @return void * @return void
*/ */
...@@ -894,7 +894,7 @@ class Gateway ...@@ -894,7 +894,7 @@ class Gateway
/** /**
* 将 client_id 加入组 * 将 client_id 加入组
* *
* @param int $client_id * @param int $client_id
* @param int|string $group * @param int|string $group
* @return void * @return void
*/ */
...@@ -907,7 +907,7 @@ class Gateway ...@@ -907,7 +907,7 @@ class Gateway
/** /**
* 将 client_id 离开组 * 将 client_id 离开组
* *
* @param int $client_id * @param int $client_id
* @param int|string $group * @param int|string $group
* *
* @return void * @return void
...@@ -929,8 +929,8 @@ class Gateway ...@@ -929,8 +929,8 @@ class Gateway
if (!static::isValidGroupId($group)) { if (!static::isValidGroupId($group)) {
return false; return false;
} }
$gateway_data = GatewayProtocol::$empty; $gateway_data = GatewayProtocol::$empty;
$gateway_data['cmd'] = GatewayProtocol::CMD_UNGROUP; $gateway_data['cmd'] = GatewayProtocol::CMD_UNGROUP;
$gateway_data['ext_data'] = $group; $gateway_data['ext_data'] = $group;
return static::sendToAllGateway($gateway_data); return static::sendToAllGateway($gateway_data);
...@@ -940,14 +940,14 @@ class Gateway ...@@ -940,14 +940,14 @@ class Gateway
* 向所有 uid 发送 * 向所有 uid 发送
* *
* @param int|string|array $uid * @param int|string|array $uid
* @param string $message * @param string $message
* *
* @return void * @return void
*/ */
public static function sendToUid($uid, $message) public static function sendToUid($uid, $message)
{ {
$gateway_data = GatewayProtocol::$empty; $gateway_data = GatewayProtocol::$empty;
$gateway_data['cmd'] = GatewayProtocol::CMD_SEND_TO_UID; $gateway_data['cmd'] = GatewayProtocol::CMD_SEND_TO_UID;
$gateway_data['body'] = $message; $gateway_data['body'] = $message;
if (!is_array($uid)) { if (!is_array($uid)) {
...@@ -962,10 +962,10 @@ class Gateway ...@@ -962,10 +962,10 @@ class Gateway
/** /**
* 向 group 发送 * 向 group 发送
* *
* @param int|string|array $group 组(不允许是 0 '0' false null array()等为空的值) * @param int|string|array $group 组(不允许是 0 '0' false null array()等为空的值)
* @param string $message 消息 * @param string $message 消息
* @param array $exclude_client_id 不给这些client_id发 * @param array $exclude_client_id 不给这些client_id发
* @param bool $raw 发送原始数据(即不调用gateway的协议的encode方法) * @param bool $raw 发送原始数据(即不调用gateway的协议的encode方法)
* *
* @return void * @return void
*/ */
...@@ -974,8 +974,8 @@ class Gateway ...@@ -974,8 +974,8 @@ class Gateway
if (!static::isValidGroupId($group)) { if (!static::isValidGroupId($group)) {
return false; return false;
} }
$gateway_data = GatewayProtocol::$empty; $gateway_data = GatewayProtocol::$empty;
$gateway_data['cmd'] = GatewayProtocol::CMD_SEND_TO_GROUP; $gateway_data['cmd'] = GatewayProtocol::CMD_SEND_TO_GROUP;
$gateway_data['body'] = $message; $gateway_data['body'] = $message;
if ($raw) { if ($raw) {
$gateway_data['flag'] |= GatewayProtocol::FLAG_NOT_CALL_ENCODE; $gateway_data['flag'] |= GatewayProtocol::FLAG_NOT_CALL_ENCODE;
...@@ -986,7 +986,7 @@ class Gateway ...@@ -986,7 +986,7 @@ class Gateway
} }
// 分组发送,没有排除的client_id,直接发送 // 分组发送,没有排除的client_id,直接发送
$default_ext_data_buffer = json_encode(array('group'=> $group, 'exclude'=> null)); $default_ext_data_buffer = json_encode(array('group' => $group, 'exclude' => null));
if (empty($exclude_client_id)) { if (empty($exclude_client_id)) {
$gateway_data['ext_data'] = $default_ext_data_buffer; $gateway_data['ext_data'] = $default_ext_data_buffer;
return static::sendToAllGateway($gateway_data); return static::sendToAllGateway($gateway_data);
...@@ -1002,7 +1002,7 @@ class Gateway ...@@ -1002,7 +1002,7 @@ class Gateway
if (static::$businessWorker) { if (static::$businessWorker) {
foreach (static::$businessWorker->gatewayConnections as $address => $gateway_connection) { foreach (static::$businessWorker->gatewayConnections as $address => $gateway_connection) {
$gateway_data['ext_data'] = isset($address_connection_array[$address]) ? $gateway_data['ext_data'] = isset($address_connection_array[$address]) ?
json_encode(array('group'=> $group, 'exclude'=> $address_connection_array[$address])) : json_encode(array('group' => $group, 'exclude' => $address_connection_array[$address])) :
$default_ext_data_buffer; $default_ext_data_buffer;
/** @var TcpConnection $gateway_connection */ /** @var TcpConnection $gateway_connection */
$gateway_connection->send($gateway_data); $gateway_connection->send($gateway_data);
...@@ -1016,7 +1016,7 @@ class Gateway ...@@ -1016,7 +1016,7 @@ class Gateway
} }
foreach ($addresses as $address) { foreach ($addresses as $address) {
$gateway_data['ext_data'] = isset($address_connection_array[$address]) ? $gateway_data['ext_data'] = isset($address_connection_array[$address]) ?
json_encode(array('group'=> $group, 'exclude'=> $address_connection_array[$address])) : json_encode(array('group' => $group, 'exclude' => $address_connection_array[$address])) :
$default_ext_data_buffer; $default_ext_data_buffer;
static::sendToGateway($address, $gateway_data); static::sendToGateway($address, $gateway_data);
} }
...@@ -1026,7 +1026,7 @@ class Gateway ...@@ -1026,7 +1026,7 @@ class Gateway
/** /**
* 更新 session,框架自动调用,开发者不要调用 * 更新 session,框架自动调用,开发者不要调用
* *
* @param int $client_id * @param int $client_id
* @param string $session_str * @param string $session_str
* @return bool * @return bool
*/ */
...@@ -1038,7 +1038,7 @@ class Gateway ...@@ -1038,7 +1038,7 @@ class Gateway
/** /**
* 设置 session,原session值会被覆盖 * 设置 session,原session值会被覆盖
* *
* @param int $client_id * @param int $client_id
* @param array $session * @param array $session
* *
* @return void * @return void
...@@ -1055,7 +1055,7 @@ class Gateway ...@@ -1055,7 +1055,7 @@ class Gateway
/** /**
* 更新 session,实际上是与老的session合并 * 更新 session,实际上是与老的session合并
* *
* @param int $client_id * @param int $client_id
* @param array $session * @param array $session
* *
* @return void * @return void
...@@ -1072,7 +1072,7 @@ class Gateway ...@@ -1072,7 +1072,7 @@ class Gateway
/** /**
* 获取某个client_id的session * 获取某个client_id的session
* *
* @param int $client_id * @param int $client_id
* @return mixed false表示出错、null表示用户不存在、array表示具体的session信息 * @return mixed false表示出错、null表示用户不存在、array表示具体的session信息
*/ */
public static function getSession($client_id) public static function getSession($client_id)
...@@ -1081,14 +1081,14 @@ class Gateway ...@@ -1081,14 +1081,14 @@ class Gateway
if (!$address_data) { if (!$address_data) {
return false; return false;
} }
$address = long2ip($address_data['local_ip']) . ":{$address_data['local_port']}"; $address = long2ip($address_data['local_ip']) . ":{$address_data['local_port']}";
if (isset(static::$businessWorker)) { if (isset(static::$businessWorker)) {
if (!isset(static::$businessWorker->gatewayConnections[$address])) { if (!isset(static::$businessWorker->gatewayConnections[$address])) {
return null; return null;
} }
} }
$gateway_data = GatewayProtocol::$empty; $gateway_data = GatewayProtocol::$empty;
$gateway_data['cmd'] = GatewayProtocol::CMD_GET_SESSION_BY_CLIENT_ID; $gateway_data['cmd'] = GatewayProtocol::CMD_GET_SESSION_BY_CLIENT_ID;
$gateway_data['connection_id'] = $address_data['connection_id']; $gateway_data['connection_id'] = $address_data['connection_id'];
return static::sendAndRecv($address, $gateway_data); return static::sendAndRecv($address, $gateway_data);
} }
...@@ -1096,8 +1096,8 @@ class Gateway ...@@ -1096,8 +1096,8 @@ class Gateway
/** /**
* 向某个用户网关发送命令和消息 * 向某个用户网关发送命令和消息
* *
* @param int $client_id * @param int $client_id
* @param int $cmd * @param int $cmd
* @param string $message * @param string $message
* @param string $ext_data * @param string $ext_data
* @return boolean * @return boolean
...@@ -1106,20 +1106,20 @@ class Gateway ...@@ -1106,20 +1106,20 @@ class Gateway
{ {
// 如果是发给当前用户则直接获取上下文中的地址 // 如果是发给当前用户则直接获取上下文中的地址
if ($client_id === Context::$client_id || $client_id === null) { if ($client_id === Context::$client_id || $client_id === null) {
$address = long2ip(Context::$local_ip) . ':' . Context::$local_port; $address = long2ip(Context::$local_ip) . ':' . Context::$local_port;
$connection_id = Context::$connection_id; $connection_id = Context::$connection_id;
} else { } else {
$address_data = Context::clientIdToAddress($client_id); $address_data = Context::clientIdToAddress($client_id);
if (!$address_data) { if (!$address_data) {
return false; return false;
} }
$address = long2ip($address_data['local_ip']) . ":{$address_data['local_port']}"; $address = long2ip($address_data['local_ip']) . ":{$address_data['local_port']}";
$connection_id = $address_data['connection_id']; $connection_id = $address_data['connection_id'];
} }
$gateway_data = GatewayProtocol::$empty; $gateway_data = GatewayProtocol::$empty;
$gateway_data['cmd'] = $cmd; $gateway_data['cmd'] = $cmd;
$gateway_data['connection_id'] = $connection_id; $gateway_data['connection_id'] = $connection_id;
$gateway_data['body'] = $message; $gateway_data['body'] = $message;
if (!empty($ext_data)) { if (!empty($ext_data)) {
$gateway_data['ext_data'] = $ext_data; $gateway_data['ext_data'] = $ext_data;
} }
...@@ -1130,7 +1130,7 @@ class Gateway ...@@ -1130,7 +1130,7 @@ class Gateway
/** /**
* 发送数据并返回 * 发送数据并返回
* *
* @param int $address * @param int $address
* @param mixed $data * @param mixed $data
* @return bool * @return bool
* @throws Exception * @throws Exception
...@@ -1166,7 +1166,7 @@ class Gateway ...@@ -1166,7 +1166,7 @@ class Gateway
} }
$recv_len = strlen($all_buffer); $recv_len = strlen($all_buffer);
if (!$pack_len && $recv_len >= 4) { if (!$pack_len && $recv_len >= 4) {
$pack_len= current(unpack('N', $all_buffer)); $pack_len = current(unpack('N', $all_buffer));
} }
// 回复的数据都是以\n结尾 // 回复的数据都是以\n结尾
if (($pack_len && $recv_len >= $pack_len + 4) || microtime(true) - $time_start > $timeout) { if (($pack_len && $recv_len >= $pack_len + 4) || microtime(true) - $time_start > $timeout) {
...@@ -1184,7 +1184,7 @@ class Gateway ...@@ -1184,7 +1184,7 @@ class Gateway
* 发送数据到网关 * 发送数据到网关
* *
* @param string $address * @param string $address
* @param array $gateway_data * @param array $gateway_data
* @return bool * @return bool
*/ */
protected static function sendToGateway($address, $gateway_data) protected static function sendToGateway($address, $gateway_data)
...@@ -1209,8 +1209,8 @@ class Gateway ...@@ -1209,8 +1209,8 @@ class Gateway
} }
// 非workerman环境 // 非workerman环境
$gateway_buffer = static::$secretKey ? static::generateAuthBuffer() . $gateway_buffer : $gateway_buffer; $gateway_buffer = static::$secretKey ? static::generateAuthBuffer() . $gateway_buffer : $gateway_buffer;
$flag = static::$persistentConnection ? STREAM_CLIENT_PERSISTENT | STREAM_CLIENT_CONNECT : STREAM_CLIENT_CONNECT; $flag = static::$persistentConnection ? STREAM_CLIENT_PERSISTENT | STREAM_CLIENT_CONNECT : STREAM_CLIENT_CONNECT;
$client = stream_socket_client("tcp://$address", $errno, $errmsg, static::$connectTimeout, $flag); $client = stream_socket_client("tcp://$address", $errno, $errmsg, static::$connectTimeout, $flag);
return strlen($gateway_buffer) == stream_socket_sendto($client, $gateway_buffer); return strlen($gateway_buffer) == stream_socket_sendto($client, $gateway_buffer);
} }
...@@ -1248,13 +1248,13 @@ class Gateway ...@@ -1248,13 +1248,13 @@ class Gateway
* 踢掉某个网关的 socket * 踢掉某个网关的 socket
* *
* @param string $address * @param string $address
* @param int $connection_id * @param int $connection_id
* @return bool * @return bool
*/ */
protected static function kickAddress($address, $connection_id, $message) protected static function kickAddress($address, $connection_id, $message)
{ {
$gateway_data = GatewayProtocol::$empty; $gateway_data = GatewayProtocol::$empty;
$gateway_data['cmd'] = GatewayProtocol::CMD_KICK; $gateway_data['cmd'] = GatewayProtocol::CMD_KICK;
$gateway_data['connection_id'] = $connection_id; $gateway_data['connection_id'] = $connection_id;
$gateway_data['body'] = $message; $gateway_data['body'] = $message;
return static::sendToGateway($address, $gateway_data); return static::sendToGateway($address, $gateway_data);
...@@ -1264,13 +1264,13 @@ class Gateway ...@@ -1264,13 +1264,13 @@ class Gateway
* 销毁某个网关的 socket * 销毁某个网关的 socket
* *
* @param string $address * @param string $address
* @param int $connection_id * @param int $connection_id
* @return bool * @return bool
*/ */
protected static function destroyAddress($address, $connection_id) protected static function destroyAddress($address, $connection_id)
{ {
$gateway_data = GatewayProtocol::$empty; $gateway_data = GatewayProtocol::$empty;
$gateway_data['cmd'] = GatewayProtocol::CMD_DESTROY; $gateway_data['cmd'] = GatewayProtocol::CMD_DESTROY;
$gateway_data['connection_id'] = $connection_id; $gateway_data['connection_id'] = $connection_id;
return static::sendToGateway($address, $gateway_data); return static::sendToGateway($address, $gateway_data);
} }
...@@ -1287,7 +1287,7 @@ class Gateway ...@@ -1287,7 +1287,7 @@ class Gateway
foreach ($client_id_array as $client_id) { foreach ($client_id_array as $client_id) {
$address_data = Context::clientIdToAddress($client_id); $address_data = Context::clientIdToAddress($client_id);
if ($address_data) { if ($address_data) {
$address = long2ip($address_data['local_ip']) . $address = long2ip($address_data['local_ip']) .
":{$address_data['local_port']}"; ":{$address_data['local_port']}";
$address_connection_array[$address][$address_data['connection_id']] = $address_data['connection_id']; $address_connection_array[$address][$address_data['connection_id']] = $address_data['connection_id'];
} }
...@@ -1314,9 +1314,9 @@ class Gateway ...@@ -1314,9 +1314,9 @@ class Gateway
protected static function getAllGatewayAddressesFromRegister() protected static function getAllGatewayAddressesFromRegister()
{ {
static $addresses_cache, $last_update, $last_register_address; static $addresses_cache, $last_update, $last_register_address;
$time_now = time(); $time_now = time();
$expiration_time = 1; $expiration_time = 1;
if(empty($addresses_cache) || $time_now - $last_update > $expiration_time || $last_register_address !== static::$registerAddress) { if (empty($addresses_cache) || $time_now - $last_update > $expiration_time || $last_register_address !== static::$registerAddress) {
$client = stream_socket_client('tcp://' . static::$registerAddress, $errno, $errmsg, static::$connectTimeout); $client = stream_socket_client('tcp://' . static::$registerAddress, $errno, $errmsg, static::$connectTimeout);
if (!$client) { if (!$client) {
throw new Exception('Can not connect to tcp://' . static::$registerAddress . ' ' . $errmsg); throw new Exception('Can not connect to tcp://' . static::$registerAddress . ' ' . $errmsg);
...@@ -1328,9 +1328,9 @@ class Gateway ...@@ -1328,9 +1328,9 @@ class Gateway
throw new Exception('getAllGatewayAddressesFromRegister fail. tcp://' . throw new Exception('getAllGatewayAddressesFromRegister fail. tcp://' .
static::$registerAddress . ' return ' . var_export($ret, true)); static::$registerAddress . ' return ' . var_export($ret, true));
} }
$last_update = $time_now; $last_update = $time_now;
$last_register_address = static::$registerAddress; $last_register_address = static::$registerAddress;
$addresses_cache = $data['addresses']; $addresses_cache = $data['addresses'];
} }
return $addresses_cache; return $addresses_cache;
} }
...@@ -1344,7 +1344,7 @@ class Gateway ...@@ -1344,7 +1344,7 @@ class Gateway
protected static function isValidGroupId($group) protected static function isValidGroupId($group)
{ {
if (empty($group)) { if (empty($group)) {
echo new \Exception('group('.var_export($group, true).') empty'); echo new \Exception('group(' . var_export($group, true) . ') empty');
return false; return false;
} }
return true; return true;
...@@ -1402,8 +1402,7 @@ class Context ...@@ -1402,8 +1402,7 @@ class Context
*/ */
public static function sessionEncode($session_data = '') public static function sessionEncode($session_data = '')
{ {
if($session_data !== '') if ($session_data !== '') {
{
return serialize($session_data); return serialize($session_data);
} }
return ''; return '';
...@@ -1426,7 +1425,7 @@ class Context ...@@ -1426,7 +1425,7 @@ class Context
public static function clear() public static function clear()
{ {
static::$local_ip = static::$local_port = static::$client_ip = static::$client_port = static::$local_ip = static::$local_port = static::$client_ip = static::$client_port =
static::$client_id = static::$connection_id = static::$old_session = null; static::$client_id = static::$connection_id = static::$old_session = null;
} }
/** /**
...@@ -1444,11 +1443,10 @@ class Context ...@@ -1444,11 +1443,10 @@ class Context
*/ */
public static function clientIdToAddress($client_id) public static function clientIdToAddress($client_id)
{ {
if(strlen($client_id) !== 20) if (strlen($client_id) !== 20) {
{
throw new \Exception("client_id $client_id is invalid"); throw new \Exception("client_id $client_id is invalid");
} }
return unpack('Nlocal_ip/nlocal_port/Nconnection_id' ,pack('H*', $client_id)); return unpack('Nlocal_ip/nlocal_port/Nconnection_id', pack('H*', $client_id));
} }
} }
...@@ -1545,17 +1543,18 @@ class GatewayProtocol ...@@ -1545,17 +1543,18 @@ class GatewayProtocol
*/ */
const HEAD_LEN = 28; const HEAD_LEN = 28;
public static $empty = array( public static $empty = array(
'cmd' => 0, 'cmd' => 0,
'local_ip' => 0, 'local_ip' => 0,
'local_port' => 0, 'local_port' => 0,
'client_ip' => 0, 'client_ip' => 0,
'client_port' => 0, 'client_port' => 0,
'connection_id' => 0, 'connection_id' => 0,
'flag' => 0, 'flag' => 0,
'gateway_port' => 0, 'gateway_port' => 0,
'ext_data' => '', 'ext_data' => '',
'body' => '', 'body' => '',
); );
/** /**
* 返回包长度 * 返回包长度
* *
...@@ -1570,6 +1569,7 @@ class GatewayProtocol ...@@ -1570,6 +1569,7 @@ class GatewayProtocol
$data = unpack("Npack_len", $buffer); $data = unpack("Npack_len", $buffer);
return $data['pack_len']; return $data['pack_len'];
} }
/** /**
* 获取整个包的 buffer * 获取整个包的 buffer
* *
...@@ -1583,8 +1583,8 @@ class GatewayProtocol ...@@ -1583,8 +1583,8 @@ class GatewayProtocol
$data['body'] = serialize($data['body']); $data['body'] = serialize($data['body']);
} }
$data['flag'] |= $flag; $data['flag'] |= $flag;
$ext_len = strlen($data['ext_data']); $ext_len = strlen($data['ext_data']);
$package_len = self::HEAD_LEN + $ext_len + strlen($data['body']); $package_len = self::HEAD_LEN + $ext_len + strlen($data['body']);
return pack("NCNnNnNCnN", $package_len, return pack("NCNnNnNCnN", $package_len,
$data['cmd'], $data['local_ip'], $data['cmd'], $data['local_ip'],
$data['local_port'], $data['client_ip'], $data['local_port'], $data['client_ip'],
...@@ -1592,6 +1592,7 @@ class GatewayProtocol ...@@ -1592,6 +1592,7 @@ class GatewayProtocol
$data['flag'], $data['gateway_port'], $data['flag'], $data['gateway_port'],
$ext_len) . $data['ext_data'] . $data['body']; $ext_len) . $data['ext_data'] . $data['body'];
} }
/** /**
* 从二进制数据转换为数组 * 从二进制数据转换为数组
* *
......
...@@ -52,5 +52,7 @@ class StateCode ...@@ -52,5 +52,7 @@ class StateCode
const FINISH_EXCEPTION_REFUND = 44; const FINISH_EXCEPTION_REFUND = 44;
const CHANGE_PORT = 47;
} }
\ No newline at end of file
...@@ -33,32 +33,34 @@ class Order ...@@ -33,32 +33,34 @@ class Order
/** /**
* @var int * @var int
*/ */
private $purchaseTime; private $purchaseTime = 0;
/** /**
* @var string * @var string
*/ */
private $startTime; private $startTime = '';
/** /**
* @var string * @var string
*/ */
private $finishTime; private $finishTime = '';
/** /**
* @var string * @var string
*/ */
private $shedTime; private $shedTime = '';
/** /**
* @var string * @var string
*/ */
private $offlineTime; private $offlineTime = '0';
/** /**
* @var string * @var string
*/ */
private $onlineTime; private $onlineTime = '';
/** /**
* 订单状态 * 订单状态
...@@ -80,7 +82,7 @@ class Order ...@@ -80,7 +82,7 @@ class Order
/** /**
* @var int * @var int
*/ */
private $portId; private $portId = 0;
/** /**
...@@ -120,6 +122,11 @@ class Order ...@@ -120,6 +122,11 @@ class Order
/** /**
* @var int * @var int
*/ */
private $stationId;
/**
* @var int
*/
private $startCapacity = -1; private $startCapacity = -1;
...@@ -154,7 +161,8 @@ class Order ...@@ -154,7 +161,8 @@ class Order
return isset($this->$name) ? $this->$name : ''; return isset($this->$name) ? $this->$name : '';
} }
public function __construct(int $orderId = 0) { public function __construct(int $orderId = 0)
{
$this->id = $orderId; $this->id = $orderId;
...@@ -182,8 +190,10 @@ class Order ...@@ -182,8 +190,10 @@ class Order
$this->orderCache = $redis->hGetAll($keyName); $this->orderCache = $redis->hGetAll($keyName);
var_dump($this->orderCache); if (count($this->orderCache) < 5) {
return false;
}
foreach ($this->orderCache as $key => $value) { foreach ($this->orderCache as $key => $value) {
$this->$key = $value; $this->$key = $value;
...@@ -196,6 +206,16 @@ class Order ...@@ -196,6 +206,16 @@ class Order
} }
/** /**
* 删除订单的缓存
* @param \Redis $redis
*/
public function delCache(\Redis $redis)
{
$keyName = $this->getCacheKeyName();
$redis->del($keyName);
}
/**
* @param \Redis $redis * @param \Redis $redis
* @return array|bool * @return array|bool
*/ */
...@@ -592,7 +612,21 @@ class Order ...@@ -592,7 +612,21 @@ class Order
$this->endCode = $endCode; $this->endCode = $endCode;
} }
/**
* @return int
*/
public function getStationId(): int
{
return $this->stationId;
}
/**
* @param int $stationId
*/
public function setStationId(int $stationId): void
{
$this->stationId = $stationId;
}
} }
\ No newline at end of file
...@@ -46,6 +46,9 @@ class OrderSaveRedis ...@@ -46,6 +46,9 @@ class OrderSaveRedis
$this->redis->hMset($this->order->getCacheKeyName(), $update); $this->redis->hMset($this->order->getCacheKeyName(), $update);
$this->redis->expire($this->order->getCacheKeyName(), 60 * 60 * 24);
} }
......
...@@ -13,9 +13,11 @@ use Application\model\OrderExceptionModel; ...@@ -13,9 +13,11 @@ use Application\model\OrderExceptionModel;
use Application\model\OrderModel; use Application\model\OrderModel;
use Lib\cdz\order\Order; use Lib\cdz\order\Order;
use Lib\cdz\order\save\OrderSaveRedis; use Lib\cdz\order\save\OrderSaveRedis;
use Lib\Gateway;
use Lib\log\Log; use Lib\log\Log;
use Lib\rabbitmq\PublishPortShed; use Lib\rabbitmq\PublishPortShed;
use Lib\remote\api\message\ChargerFullMessage; use Lib\remote\api\message\ChargerFullMessage;
use Lib\remote\api\message\ChargerShedMessage;
use Lib\remote\api\message\ChargerTimeoutMessage; use Lib\remote\api\message\ChargerTimeoutMessage;
use Lib\remote\api\message\FinishByUserMessage; use Lib\remote\api\message\FinishByUserMessage;
use Lib\remote\api\message\PowerExceedMessage; use Lib\remote\api\message\PowerExceedMessage;
...@@ -23,6 +25,7 @@ use Lib\remote\api\message\SendMessage; ...@@ -23,6 +25,7 @@ use Lib\remote\api\message\SendMessage;
use Lib\remote\api\message\ShedMessage; use Lib\remote\api\message\ShedMessage;
use Lib\StateCode; use Lib\StateCode;
use Lib\station\gateway\port\Port; use Lib\station\gateway\port\Port;
use Src\BroadcastToAgent;
class ChargerState extends State class ChargerState extends State
{ {
...@@ -42,23 +45,29 @@ class ChargerState extends State ...@@ -42,23 +45,29 @@ class ChargerState extends State
$orderModel->update([ $orderModel->update([
'is_stop' => $this->order->getEndCode(), 'is_stop' => $this->order->getEndCode(),
'end_capacity' => $this->order->getEndCapacity(), 'end_capacity' => $this->order->getEndCapacity(),
'updated_at' => date('Y-m-d H:i:s'), 'updated_at' => $this->nowDate,
'end_time' => $this->nowDate,
'state' => 1, 'state' => 1,
], 'id = ' . $this->order->getId()); ], 'id = ' . $this->order->getId());
$port = new Port(); $port = new Port();
$port->setState(StateCode::PORT_ONLINE);
$port->setPortId($this->order->getPortId()); $port->setPortId($this->order->getPortId());
$port->setGatewayId($this->order->getGatewayId());
$port->freePort(); $port->setStationId($this->order->getStationId());
//释放口子状态
$port->freePort($this->order->getId());
//删除订单的缓存
$this->order->delCache(\Events::getRedis());
//用户主动结束充电推送 //用户主动结束充电推送
$finishByUserMessage = new FinishByUserMessage(); $finishByUserMessage = new FinishByUserMessage();
$finishByUserMessage->setOrderId($this->order->getId()); $finishByUserMessage->setOrderId($this->order->getId());
$finishByUserMessage->setAddress($this->order->getStationName() . '--' . $this->order->getPortName()); $finishByUserMessage->setAddress($this->order->getStationName() . '--' . $this->order->getPortName());
$chargerTime = time() - $this->order->getStartTime(); $finishByUserMessage->setUserId($this->order->getUserId());
$chargerTime = (int)time() - (int)$this->order->getStartTime();
$chargerTime /= 60; $chargerTime /= 60;
$chargerTime = (int)$chargerTime; $chargerTime = (int)$chargerTime;
$finishByUserMessage->setChargerTime($chargerTime); $finishByUserMessage->setChargerTime($chargerTime);
$finishByUserMessage->setEndTime($this->nowDate); $finishByUserMessage->setEndTime($this->nowDate);
...@@ -71,7 +80,6 @@ class ChargerState extends State ...@@ -71,7 +80,6 @@ class ChargerState extends State
$orderException = new OrderExceptionModel(); $orderException = new OrderExceptionModel();
$orderException->insertRow([ $orderException->insertRow([
'order_id' => $this->order->getId(), 'order_id' => $this->order->getId(),
'state' => StateCode::PORT_CHARGER . StateCode::FINISH_USER, 'state' => StateCode::PORT_CHARGER . StateCode::FINISH_USER,
'desc' => '用户主动结束充电', 'desc' => '用户主动结束充电',
...@@ -96,6 +104,7 @@ class ChargerState extends State ...@@ -96,6 +104,7 @@ class ChargerState extends State
public function toExceptionState() public function toExceptionState()
{ {
// TODO: Implement toExceptionState() method. // TODO: Implement toExceptionState() method.
} }
...@@ -105,6 +114,7 @@ class ChargerState extends State ...@@ -105,6 +114,7 @@ class ChargerState extends State
* 推送消息 * 推送消息
* 更新口子状态释放订单 * 更新口子状态释放订单
* 记录订单异常 * 记录订单异常
* 推送给agentId
* *
* @throws \GuzzleHttp\Exception\GuzzleException * @throws \GuzzleHttp\Exception\GuzzleException
*/ */
...@@ -116,7 +126,7 @@ class ChargerState extends State ...@@ -116,7 +126,7 @@ class ChargerState extends State
$orderModel->update([ $orderModel->update([
'is_stop' => StateCode::FINISH_EXCEED, 'is_stop' => StateCode::FINISH_EXCEED,
'end_capacity' => $this->order->getEndCapacity(), 'end_capacity' => $this->order->getEndCapacity(),
'end_time' => date('Y-m-d H:i:s', $this->nowTimeStamp), 'end_time' => $this->nowDate,
'state' => 1, 'state' => 1,
], 'id = ' . $this->order->getId()); ], 'id = ' . $this->order->getId());
...@@ -144,7 +154,14 @@ class ChargerState extends State ...@@ -144,7 +154,14 @@ class ChargerState extends State
$port = new Port(); $port = new Port();
$port->setPortId($this->order->getPortId()); $port->setPortId($this->order->getPortId());
$port->freePort(); $port->setState(StateCode::PORT_ONLINE);
$port->setGatewayId($this->order->getGatewayId());
$port->setStationId($this->order->getStationId());
$port->freePort($this->order->getId());
$broadcastToAgent = new BroadcastToAgent();
$broadcastToAgent->broadcast($this->order->getOrderCache(\Events::getRedis()) + ['notice_exception_code' => StateCode::FINISH_EXCEED]);
} }
...@@ -187,7 +204,15 @@ class ChargerState extends State ...@@ -187,7 +204,15 @@ class ChargerState extends State
} }
$port = new Port(); $port = new Port();
$port->setPortId($this->order->getPortId()); $port->setPortId($this->order->getPortId());
$port->freePort(); $port->setState(StateCode::PORT_ONLINE);
$port->setGatewayId($this->order->getGatewayId());
$port->setStationId($this->order->getStationId());
$port->freePort($this->order->getId());
$broadcastToAgent = new BroadcastToAgent();
$broadcastToAgent->broadcast($this->order->getOrderCache(\Events::getRedis()) + ['notice_exception_code' => StateCode::FINISH_FULL]);
} }
/** /**
...@@ -196,6 +221,7 @@ class ChargerState extends State ...@@ -196,6 +221,7 @@ class ChargerState extends State
* 推送用户信息 * 推送用户信息
* 发布延时任务十分钟后检测端口 * 发布延时任务十分钟后检测端口
* *
*
* @throws \GuzzleHttp\Exception\GuzzleException * @throws \GuzzleHttp\Exception\GuzzleException
* @throws \AMQPConnectionException * @throws \AMQPConnectionException
* @throws \AMQPExchangeException * @throws \AMQPExchangeException
...@@ -230,13 +256,21 @@ class ChargerState extends State ...@@ -230,13 +256,21 @@ class ChargerState extends State
'created_at' => $this->nowDate, 'created_at' => $this->nowDate,
]); ]);
$shedMessage = new ShedMessage(); //更新端口状态和订单状态
$shedMessage->setOrderId($this->order->getId()); $port = new Port($this->order->getPortId());
$shedMessage->setPortName($this->order->getPortName()); $port->setState(StateCode::PORT_SHED);
$shedMessage->setStationName($this->order->getStationName()); $port->setGatewayId($this->order->getGatewayId());
$shedMessage->setTime($this->nowDate); $port->setStationId($this->order->getStationId());
$port->updatePortState($this->order->getId());
$chargerShedMessage = new ChargerShedMessage();
$chargerShedMessage->setStationName($this->order->getStationName());
$chargerShedMessage->setPortName($this->order->getPortName());
$chargerShedMessage->setUserId($this->order->getUserId());
$chargerShedMessage->setDate($this->nowDate);
$sendMessage = new SendMessage(); $sendMessage = new SendMessage();
if ($sendMessage->request($shedMessage) == false) { if ($sendMessage->request($chargerShedMessage) == false) {
Log::error('send port shed message fail'); Log::error('send port shed message fail');
} }
...@@ -249,7 +283,11 @@ class ChargerState extends State ...@@ -249,7 +283,11 @@ class ChargerState extends State
$publish->publishOrder([ $publish->publishOrder([
'order_id' => $this->order->getId(), 'order_id' => $this->order->getId(),
'shed_time' => $this->nowTimeStamp, 'shed_time' => $this->nowTimeStamp,
'port_id' => $this->order->getPortId() 'port_id' => $this->order->getPortId(),
'gateway_mac' => $this->order->getGatewayMac(),
'check_times' => 1,
'gateway_id' => $this->order->getGatewayId(),
'station_id' => $_SESSION['station_id'],
]); ]);
} catch (\Exception $exception) { } catch (\Exception $exception) {
...@@ -257,6 +295,9 @@ class ChargerState extends State ...@@ -257,6 +295,9 @@ class ChargerState extends State
} }
$broadcastToAgent = new BroadcastToAgent();
$broadcastToAgent->broadcast($this->order->getOrderCache(\Events::getRedis()) + ['notice_exception_code' => StateCode::PORT_SHED]);
} }
...@@ -280,18 +321,24 @@ class ChargerState extends State ...@@ -280,18 +321,24 @@ class ChargerState extends State
$orderModel->update([ $orderModel->update([
'is_stop' => StateCode::FINISH_TIME_END, 'is_stop' => StateCode::FINISH_TIME_END,
'end_capacity' => $this->order->getEndCapacity(), 'end_capacity' => $this->order->getEndCapacity(),
'end_time' => $this->nowDate,
'updated_at' => $this->nowDate, 'updated_at' => $this->nowDate,
'state' => 1,
], 'id = ' . $this->order->getId()); ], 'id = ' . $this->order->getId());
$port = new Port(); $port = new Port();
$port->setPortId($this->order->getId()); $port->setPortId($this->order->getPortId());
$port->freePort(); $port->setState(StateCode::PORT_ONLINE);
$port->setGatewayId($this->order->getGatewayId());
$port->setStationId($this->order->getStationId());
$port->freePort($this->order->getId());
$chargerTimeoutMessage = new ChargerTimeoutMessage(); $chargerTimeoutMessage = new ChargerTimeoutMessage();
$chargerTimeoutMessage->setStationName($this->order->getStationName()); $chargerTimeoutMessage->setStationName($this->order->getStationName());
$chargerTimeoutMessage->setPortName($this->order->getPortName()); $chargerTimeoutMessage->setPortName($this->order->getPortName());
$chargerTimeoutMessage->setOrderId($this->order->getId()); $chargerTimeoutMessage->setOrderId($this->order->getId());
$chargerTimeoutMessage->setEndTime($this->nowDate); $chargerTimeoutMessage->setEndTime($this->nowDate);
$chargerTimeoutMessage->setUserId($this->order->getUserId());
$chargerTime = $this->nowTimeStamp - $this->order->getStartTime(); $chargerTime = $this->nowTimeStamp - $this->order->getStartTime();
$chargerTime /= 60; $chargerTime /= 60;
...@@ -306,6 +353,14 @@ class ChargerState extends State ...@@ -306,6 +353,14 @@ class ChargerState extends State
} }
/**
* 关闭失败
*/
public function stopFail()
{
}
} }
......
...@@ -65,5 +65,10 @@ class ExceptionState extends State ...@@ -65,5 +65,10 @@ class ExceptionState extends State
// TODO: Implement toTimeoutState() method. // TODO: Implement toTimeoutState() method.
} }
public function stopFail()
{
// TODO: Implement stopFail() method.
}
} }
\ No newline at end of file
...@@ -11,6 +11,7 @@ namespace Lib\cdz\order\state; ...@@ -11,6 +11,7 @@ namespace Lib\cdz\order\state;
use Lib\cdz\order\NoticePortShed; use Lib\cdz\order\NoticePortShed;
use Lib\cdz\order\Order; use Lib\cdz\order\Order;
use Lib\log\Log;
class OfflineNetState extends State class OfflineNetState extends State
{ {
...@@ -27,11 +28,27 @@ class OfflineNetState extends State ...@@ -27,11 +28,27 @@ class OfflineNetState extends State
$startTime = $this->order->getStartTime(); $startTime = $this->order->getStartTime();
$purchaseTime = $this->order->getPurchaseTime(); if ($startTime === '' || $this->order->getOfflineTime() == '0') {
$this->remainChargerTime = (int)($this->order->getPurchaseTime());
} else {
$purchaseTime = $this->order->getPurchaseTime();
$this->remainChargerTime = $purchaseTime *60 - ((int)$this->order->getOnlineTime() - $startTime); Log::debug($purchaseTime * 60);
$this->remainChargerTime = (int)($this->remainChargerTime/60); Log::debug($this->order->getOfflineTime());
Log::debug($this->order->getStartTime());
$this->remainChargerTime = $purchaseTime * 60 - ((int)$this->order->getOnlineTime() - $startTime);
Log::debug('---');
Log::debug($this->remainChargerTime);
$this->remainChargerTime = (int)($this->remainChargerTime / 60);
Log::debug($this->remainChargerTime);
}
} }
...@@ -49,15 +66,13 @@ class OfflineNetState extends State ...@@ -49,15 +66,13 @@ class OfflineNetState extends State
public function toChargerState() public function toChargerState()
{ {
if($this->order->getIsRefund() === 1) if ($this->order->getIsRefund() === 1) {
{
//已经退款 下发结束充电命令 //已经退款 下发结束充电命令
$this->order->stop($this->order,$_SESSION['client_id'],43); $this->order->stop($this->order, $_SESSION['client_id'], 43);
return; return;
} }
} }
public function toExceptionState() public function toExceptionState()
...@@ -81,8 +96,7 @@ class OfflineNetState extends State ...@@ -81,8 +96,7 @@ class OfflineNetState extends State
*/ */
public function toShedState() public function toShedState()
{ {
if($this->remainChargerTime > 0) if ($this->remainChargerTime > 0) {
{
$this->publishPortShed($this->order); $this->publishPortShed($this->order);
} }
...@@ -115,6 +129,10 @@ class OfflineNetState extends State ...@@ -115,6 +129,10 @@ class OfflineNetState extends State
$this->remainChargerTime = $remainChargerTime; $this->remainChargerTime = $remainChargerTime;
} }
public function stopFail()
{
// TODO: Implement stopFail() method.
}
} }
\ No newline at end of file
...@@ -27,7 +27,7 @@ class OfflinePowerState extends State ...@@ -27,7 +27,7 @@ class OfflinePowerState extends State
/** /**
* @var int * @var int
*/ */
private $remainChargerTime =0; private $remainChargerTime = 0;
public function toWaitingState() public function toWaitingState()
{ {
...@@ -36,8 +36,7 @@ class OfflinePowerState extends State ...@@ -36,8 +36,7 @@ class OfflinePowerState extends State
public function toChargerState() public function toChargerState()
{ {
if($this->order->getIsRefund() === 1) if ($this->order->getIsRefund() === 1) {
{
//已经退款 下发结束充电命令 //已经退款 下发结束充电命令
//$this->order->stop($this->order,$_SESSION['client_id'],43); //$this->order->stop($this->order,$_SESSION['client_id'],43);
$this->remainChargerTime = 0; $this->remainChargerTime = 0;
...@@ -49,9 +48,9 @@ class OfflinePowerState extends State ...@@ -49,9 +48,9 @@ class OfflinePowerState extends State
$startTime = $this->order->getStartTime(); $startTime = $this->order->getStartTime();
$purchaseTime = $this->order->getPurchaseTime(); $purchaseTime = $this->order->getPurchaseTime();
$this->remainChargerTime = $purchaseTime *60- ($offlineTime - $startTime); $this->remainChargerTime = $purchaseTime * 60 - ($offlineTime - $startTime);
$this->remainChargerTime = (int)($this->remainChargerTime/60); $this->remainChargerTime = (int)($this->remainChargerTime / 60);
} }
...@@ -85,5 +84,10 @@ class OfflinePowerState extends State ...@@ -85,5 +84,10 @@ class OfflinePowerState extends State
// TODO: Implement toTimeoutState() method. // TODO: Implement toTimeoutState() method.
} }
public function stopFail()
{
// TODO: Implement stopFail() method.
}
} }
\ No newline at end of file
...@@ -64,5 +64,10 @@ class PowerExceedState extends State ...@@ -64,5 +64,10 @@ class PowerExceedState extends State
// TODO: Implement toTimeoutState() method. // TODO: Implement toTimeoutState() method.
} }
public function stopFail()
{
// TODO: Implement stopFail() method.
}
} }
\ No newline at end of file
...@@ -64,5 +64,10 @@ class PowerFullState extends State ...@@ -64,5 +64,10 @@ class PowerFullState extends State
// TODO: Implement toUserFinish() method. // TODO: Implement toUserFinish() method.
} }
public function stopFail()
{
// TODO: Implement stopFail() method.
}
} }
\ No newline at end of file
...@@ -9,8 +9,18 @@ ...@@ -9,8 +9,18 @@
namespace Lib\cdz\order\state; namespace Lib\cdz\order\state;
use Application\model\OrderExceptionModel;
use Application\model\OrderModel;
use Lib\cdz\order\Order; use Lib\cdz\order\Order;
use Lib\cdz\order\save\OrderSaveRedis;
use Lib\log\Log;
use Lib\remote\api\message\ChargerReloadMessage;
use Lib\remote\api\message\ChargerShedTimeOutMessage;
use Lib\remote\api\message\ChargerTimeoutMessage;
use Lib\remote\api\message\FinishByUserMessage;
use Lib\remote\api\message\SendMessage;
use Lib\StateCode;
use Lib\station\gateway\port\Port;
class ShedState extends State class ShedState extends State
{ {
...@@ -19,50 +29,245 @@ class ShedState extends State ...@@ -19,50 +29,245 @@ class ShedState extends State
parent::__construct($order); parent::__construct($order);
} }
/**
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function toUserFinish() public function toUserFinish()
{ {
// TODO: Implement toUserFinish() method. $orderModel = new OrderModel();
$orderModel->update([
'is_stop' => $this->order->getEndCode(),
'end_capacity' => $this->order->getEndCapacity(),
'updated_at' => $this->nowDate,
'end_time' => $this->nowDate,
'state' => 1,
], 'id = ' . $this->order->getId());
$port = new Port();
$port->setState(StateCode::PORT_ONLINE);
$port->setPortId($this->order->getPortId());
$port->setGatewayId($this->order->getGatewayId());
$port->setStationId($this->order->getStationId());
$port->freePort($this->order->getId());
//用户主动结束充电推送
$finishByUserMessage = new FinishByUserMessage();
$finishByUserMessage->setOrderId($this->order->getId());
$finishByUserMessage->setAddress($this->order->getStationName() . '--' . $this->order->getPortName());
$finishByUserMessage->setUserId($this->order->getUserId());
$chargerTime = (int)time() - (int)$this->order->getStartTime();
$chargerTime /= 60;
$chargerTime = (int)$chargerTime;
$finishByUserMessage->setChargerTime($chargerTime);
$finishByUserMessage->setEndTime($this->nowDate);
$finishByUserMessage->setOrderAmount($this->order->getPayAmount());
$sendMessage = new SendMessage();
if ($sendMessage->request($finishByUserMessage) == false) {
Log::error('send finish by user message fail');
}
$orderException = new OrderExceptionModel();
$orderException->insertRow([
'order_id' => $this->order->getId(),
'state' => StateCode::PORT_SHED . StateCode::FINISH_USER,
'desc' => '用户主动结束充电',
'created_at' => $this->nowDate,
]);
} }
public function toWaitingState() public function toWaitingState()
{ {
// TODO: Implement toWaitingState() method. Log::error('shed state can not change to waiting state');
} }
/**
* 更新订单状态
* 更新口子状态
* 推送微信消息
* 记录订单异常
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function toChargerState() public function toChargerState()
{ {
// TODO: Implement toChargerState() method. $this->order->setStateCode(StateCode::PORT_CHARGER);
$orderSaveRedis = new OrderSaveRedis($this->order);
$orderSaveRedis->save([
'stateCode',
]);
Log::debug('shed to charger');
$port = new Port($this->order->getPortId());
$port->setState(StateCode::PORT_CHARGER);
$port->updatePortState($this->order->getId());
$chargerReloadMessage = new ChargerReloadMessage();
$chargerReloadMessage->setUserId($this->order->getUserId());
$chargerReloadMessage->setOrderId($this->order->getId());
$chargerReloadMessage->setPortName($this->order->getPortName());
$chargerReloadMessage->setStationName($this->order->getStationName());
$sendMessage = new SendMessage();
if ($sendMessage->request($chargerReloadMessage) === false) {
Log::error('send order reload message fail');
}
$orderExceptionModel = new OrderExceptionModel();
$orderExceptionModel->insertRow(
[
'order_id' => $this->order->getId(),
'state' => StateCode::PORT_SHED . StateCode::PORT_CHARGER,
'created_at' => $this->nowDate,
'desc' => '订单口子脱落重新插上',
]
);
} }
public function toExceptionState() public function toExceptionState()
{ {
// TODO: Implement toExceptionState() method.
//todo
} }
public function toPowerExceedState() public function toPowerExceedState()
{ {
// TODO: Implement toPowerExceedState() method. Log::error('shed state can not change to power exceed state');
} }
public function toPowerFullState() public function toPowerFullState()
{ {
// TODO: Implement toPowerFullState() method. Log::error('shed state can not change to power full state');
} }
public function toShedState() public function toShedState()
{ {
// TODO: Implement toShedState() method. Log::error('shed state can not change to shed');
} }
/**
* 记录订单异常
* 释放口子
* 推送用户消息
* 更新订单记录,记录结束用电量
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function toShedTimeoutState() public function toShedTimeoutState()
{ {
// TODO: Implement toShedTimeoutState() method. $orderExceptionModel = new OrderExceptionModel();
$orderExceptionModel->insertRow([
'order_id' => $this->order->getId(),
'state' => StateCode::PORT_SHED . StateCode::FINISH_SHED_TIMEOUT,
'created_at' => $this->nowDate,
'desc' => '订单口子脱落超时结束',
]);
$orderModel = new OrderModel();
$orderModel->update([
'state' => 1,
'updated_at' => $this->nowDate,
'end_time' => $this->nowDate,
'is_stop' => StateCode::FINISH_SHED_TIMEOUT,
'end_capacity' => $this->order->getEndCapacity(),
], 'id = ' . $this->order->getId());
$port = new Port($this->order->getPortId());
$port->setState(StateCode::PORT_ONLINE);
$port->setStationId($this->order->getStationId());
$port->setGatewayId($this->order->getGatewayId());
$port->freePort($this->order->getId());
$shedTimeoutMessage = new ChargerShedTimeOutMessage();
$shedTimeoutMessage->setUserId($this->order->getUserId());
$shedTimeoutMessage->setPurchaseTime($this->order->getPurchaseTime());
$shedTimeoutMessage->setStartTime(date('Y-m-d H:i:s', $this->order->getStartTime()));
$shedTimeoutMessage->setEndTime($this->nowDate);
$sendMessage = new SendMessage();
if ($sendMessage->request($shedTimeoutMessage) === false) {
Log::error('send shed timeout message fail');
}
$orderModel = new OrderModel();
$orderModel->update([
'is_stop' => StateCode::FINISH_SHED_TIMEOUT,
'end_capacity' => $this->order->getEndCapacity(),
'state' => 1,
], 'id = ' . $this->order->getId());
} }
/**
* 记录订单异常
* 释放口子
* 推送结束消息
* 更新订单记录
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function toTimeoutState() public function toTimeoutState()
{ {
// TODO: Implement toTimeoutState() method. $orderExceptionModel = new OrderExceptionModel();
$orderExceptionModel->insertRow([
'order_id' => $this->order->getId(),
'state' => StateCode::PORT_SHED . StateCode::FINISH_TIME_END,
'created_at' => $this->nowDate,
'desc' => '订单充电时间结束',
]);
$orderModel = new OrderModel();
$orderModel->update([
'is_stop' => StateCode::FINISH_TIME_END,
'end_capacity' => $this->order->getEndCapacity(),
'state' => 1,
'updated_at' => $this->nowDate,
'end_time' => $this->nowDate,
], 'id = ' . $this->order->getId());
$port = new Port($this->order->getPortId());
$port->setState(StateCode::PORT_ONLINE);
$port->setStationId($this->order->getStationId());
$port->setGatewayId($this->order->getGatewayId());
$port->freePort($this->order->getId());
$chargerTimeoutMessage = new ChargerTimeoutMessage();
$chargerTimeoutMessage->setOrderAmount($this->order->getPayAmount());
$chargerTime = $this->nowTimeStamp - (int)$this->order->getStartTime();
$chargerTime /= 60;
$chargerTimeoutMessage->setChargerTime((int)$chargerTime);
$chargerTimeoutMessage->setEndTime($this->nowDate);
$chargerTimeoutMessage->setUserId($this->order->getUserId());
$chargerTimeoutMessage->setOrderId($this->order->getOutTradeNo());
$chargerTimeoutMessage->setPortName($this->order->getPortName());
$chargerTimeoutMessage->setStationName($this->order->getStationName());
$sendMessage = new SendMessage();
if ($sendMessage->request($chargerTimeoutMessage) === false) {
Log::error('shed state order send charger timeout message fail');
}
}
public function stopFail()
{
// TODO: Implement stopFail() method.
} }
......
...@@ -63,5 +63,10 @@ class ShedTimeoutState extends State ...@@ -63,5 +63,10 @@ class ShedTimeoutState extends State
// TODO: Implement toUserFinish() method. // TODO: Implement toUserFinish() method.
} }
public function stopFail()
{
// TODO: Implement stopFail() method.
}
} }
\ No newline at end of file
...@@ -62,5 +62,25 @@ abstract class State ...@@ -62,5 +62,25 @@ abstract class State
public abstract function toUserFinish(); public abstract function toUserFinish();
public abstract function stopFail();
/**
* @return Order
*/
public function getOrder(): Order
{
return $this->order;
}
/**
* @param Order $order
*/
public function setOrder(Order $order): void
{
$this->order = $order;
}
} }
\ No newline at end of file
...@@ -64,5 +64,10 @@ class TimeoutState extends State ...@@ -64,5 +64,10 @@ class TimeoutState extends State
// TODO: Implement toUserFinish() method. // TODO: Implement toUserFinish() method.
} }
public function stopFail()
{
// TODO: Implement stopFail() method.
}
} }
\ No newline at end of file
...@@ -58,7 +58,15 @@ class WaitingState extends State ...@@ -58,7 +58,15 @@ class WaitingState extends State
'is_stop' => StateCode::FINISH_REFUND, 'is_stop' => StateCode::FINISH_REFUND,
'end_capacity' => $this->order->getEndCapacity(), 'end_capacity' => $this->order->getEndCapacity(),
'end_time' => date('Y-m-d H:i:s'), 'end_time' => date('Y-m-d H:i:s'),
],'id = '.$this->order->getId()); ], 'id = ' . $this->order->getId());
$port = new Port();
$port->setState(StateCode::PORT_ONLINE);
$port->setPortId($this->order->getPortId());
$port->setStationId($this->order->getStationId());
$port->setGatewayId($this->order->getGatewayId());
$port->freePort($this->order->getId());
//释放端口 //释放端口
} }
...@@ -76,8 +84,7 @@ class WaitingState extends State ...@@ -76,8 +84,7 @@ class WaitingState extends State
public function toChargerState(): void public function toChargerState(): void
{ {
//订单已经退款则直接结束 //订单已经退款则直接结束
if($this->order->getIsRefund() == 1) if ($this->order->getIsRefund() == 1) {
{
//todo 下发结束充电命令 //todo 下发结束充电命令
$orderId = $this->order->getId(); $orderId = $this->order->getId();
$portLogic = $this->order->getPortLogicId(); $portLogic = $this->order->getPortLogicId();
...@@ -97,7 +104,7 @@ class WaitingState extends State ...@@ -97,7 +104,7 @@ class WaitingState extends State
$this->order->setStateCode(12); $this->order->setStateCode(12);
\Events::pipe(); \Events::pipe();
$orderSaveRedis = new OrderSaveRedis($this->order); $orderSaveRedis = new OrderSaveRedis($this->order);
$orderSaveRedis->save(['stateCode', 'startTime']); $orderSaveRedis->save(['stateCode', 'startTime', 'startCapacity']);
//更新口子状态 //更新口子状态
$port = new Port(); $port = new Port();
...@@ -105,7 +112,7 @@ class WaitingState extends State ...@@ -105,7 +112,7 @@ class WaitingState extends State
$port->setState(StateCode::PORT_CHARGER); $port->setState(StateCode::PORT_CHARGER);
$port->setGatewayId($this->order->getGatewayId()); $port->setGatewayId($this->order->getGatewayId());
$port->setStationId($_SESSION['station_id']); $port->setStationId($_SESSION['station_id']);
$port->updatePortState(); $port->updatePortState($this->order->getId());
\Events::exec(); \Events::exec();
...@@ -114,8 +121,7 @@ class WaitingState extends State ...@@ -114,8 +121,7 @@ class WaitingState extends State
$startMessage->setUserId($this->order->getUserId()); $startMessage->setUserId($this->order->getUserId());
$startMessage->setAmount($this->order->getPayAmount()); $startMessage->setAmount($this->order->getPayAmount());
$startMessage->setAddress($this->order->getStationName() . '--' . $this->order->getPortName()); $startMessage->setAddress($this->order->getStationName() . '--' . $this->order->getPortName());
$startMessage->setRemark($startMessage->getRemark() . sprintf('%012x', $this->order->getId())); $startMessage->setOrderId($this->order->getOutTradeNo());
$sendMessage = new SendMessage(); $sendMessage = new SendMessage();
if ($sendMessage->request($startMessage) === false) { if ($sendMessage->request($startMessage) === false) {
...@@ -128,7 +134,6 @@ class WaitingState extends State ...@@ -128,7 +134,6 @@ class WaitingState extends State
'is_charger' => StateCode::PORT_CHARGER, 'is_charger' => StateCode::PORT_CHARGER,
'start_time' => date('Y-m-d H:i:s', $this->order->getStartTime()), 'start_time' => date('Y-m-d H:i:s', $this->order->getStartTime()),
'start_capacity' => $this->order->getStartCapacity(), 'start_capacity' => $this->order->getStartCapacity(),
]; ];
$orderModel = new OrderModel(); $orderModel = new OrderModel();
...@@ -140,9 +145,9 @@ class WaitingState extends State ...@@ -140,9 +145,9 @@ class WaitingState extends State
//添加订单异常 //添加订单异常
$orderExceptionModel->insertRow([ $orderExceptionModel->insertRow([
'order_id' => $this->order->getId(), 'order_id' => $this->order->getId(),
'state' => '-1' . StateCode::PORT_CHARGER, 'state' => '-1' . StateCode::PORT_CHARGER,
'desc' => '开始充电', 'desc' => '开始充电',
'created_at' => date('Y-m-d H:i:s', $this->order->getStartTime()), 'created_at' => date('Y-m-d H:i:s', $this->order->getStartTime()),
]); ]);
...@@ -165,9 +170,9 @@ class WaitingState extends State ...@@ -165,9 +170,9 @@ class WaitingState extends State
$orderExceptionModel = new OrderExceptionModel(); $orderExceptionModel = new OrderExceptionModel();
$orderExceptionModel->insertRow([ $orderExceptionModel->insertRow([
'order_id' => $this->order->getId(), 'order_id' => $this->order->getId(),
'state' => '-1' . StateCode::PORT_EXCEPTION, 'state' => '-1' . StateCode::PORT_EXCEPTION,
'desc' => '打开口子失败', 'desc' => '打开口子失败',
'created_at' => date('Y-m-d H:i:s'), 'created_at' => date('Y-m-d H:i:s'),
]); ]);
//推送消息 //推送消息
...@@ -186,7 +191,7 @@ class WaitingState extends State ...@@ -186,7 +191,7 @@ class WaitingState extends State
$port->setPortId($this->order->getPortId()); $port->setPortId($this->order->getPortId());
$port->setState(StateCode::PORT_EXCEPTION); $port->setState(StateCode::PORT_EXCEPTION);
$port->updatePortState(); $port->updatePortState($this->order->getId());
// TODO: Implement toExceptionState() method. // TODO: Implement toExceptionState() method.
} }
...@@ -196,37 +201,37 @@ class WaitingState extends State ...@@ -196,37 +201,37 @@ class WaitingState extends State
*/ */
public function toPowerExceedState() public function toPowerExceedState()
{ {
Log::error('waiting state can not change to power exceed state');
// TODO: Implement toPowerExceedState() method.
} }
public function toPowerFullState() public function toPowerFullState()
{ {
Log::error('waiting state can not change to power full state'); Log::error('waiting state can not change to power full state');
// TODO: Implement toPowerFullState() method.
} }
public function toShedState() public function toShedState()
{ {
// TODO: Implement toShedState() method.
Log::error('waiting state can not change to shed state');
} }
public function toShedTimeoutState() public function toShedTimeoutState()
{ {
Log::error('waiting state can not change to shed timeout'); Log::error('waiting state can not change to shed timeout');
// TODO: Implement toShedTimeoutState() method.
} }
public function toTimeoutState() public function toTimeoutState()
{ {
Log::error('waiting state can not change to timeout state'); Log::error('waiting state can not change to timeout state');
// TODO: Implement toTimeoutState() method. }
public function stopFail()
{
// TODO: Implement stopFail() method.
} }
......
<?php
/**
* Created by PhpStorm.
* User: banice
* Date: 2018/7/6
* Time: 上午9:45
*/
namespace Lib\remote\api\message;
class ChargerReloadMessage extends Message
{
protected $templateId = 't_PyOGCKN_fmD0blw0EuIQs-8sS3qOTmpQay12haPZY';
private $first = '尊敬的用户,检测到插头插入,您的爱车已开始继续充电';
private $stationName = '';
private $portName = '';
private $time = '';
private $remark = '';
public function __construct()
{
$this->templateId = getenv('MESSAGE_RELOAD');
}
public function getPushJson(): string
{
return json_encode([
'first' => [
'value' => $this->first,
'color' => '#333',
],
'keyword1' => [
'value' => $this->stationName,
'color' => '#333',
],
'keyword2' => [
'value' => $this->portName,
'color' => '#333',
],
'keyword3' => [
'value' => date('Y-m-d H:i:s'),
'color' => '#333',
],
'remark' => [
'value' => '感谢你的使用',
'color' => '#333',
],
]);
// TODO: Implement getPushJson() method.
}
/**
* @return string
*/
public function getFirst(): string
{
return $this->first;
}
/**
* @param string $first
*/
public function setFirst(string $first): void
{
$this->first = $first;
}
/**
* @return string
*/
public function getStationName(): string
{
return $this->stationName;
}
/**
* @param string $stationName
*/
public function setStationName(string $stationName): void
{
$this->stationName = $stationName;
}
/**
* @return string
*/
public function getPortName(): string
{
return $this->portName;
}
/**
* @param string $portName
*/
public function setPortName(string $portName): void
{
$this->portName = $portName;
}
/**
* @return string
*/
public function getTime(): string
{
return $this->time;
}
/**
* @param string $time
*/
public function setTime(string $time): void
{
$this->time = $time;
}
/**
* @return string
*/
public function getRemark(): string
{
return $this->remark;
}
/**
* @param string $remark
*/
public function setRemark(string $remark): void
{
$this->remark = $remark;
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: banice
* Date: 2018/8/27
* Time: 下午5:04
*/
namespace Lib\remote\api\message;
/**
* Class ChargerShedMessage
* @package Lib\remote\api\message
*/
class ChargerShedMessage extends Message
{
protected $templateId = 'C0LvfETe-1rCR_IhOydDGPTUwwYkrWZxgfwMsETrhw8';
private $first = '尊敬的 户,充电端未检测到插头,请您在10分钟内接入。';
private $stationName = '';
private $portName = '';
private $date = '';
private $remark = '感谢您的使用。';
public function __construct()
{
$this->templateId = getenv('MESSAGE_CHARGER_SHED');
}
public function getPushJson(): string
{
return json_encode([
'first' => [
'value' => $this->first,
'color' => '#333',
],
'keyword1' => [
'value' => $this->stationName . '--' . $this->portName,
'color' => '#333',
],
'keyword2' => [
'value' => $this->date,
'color' => '#333',
],
'remark' => [
'value' => '感谢你的使用',
'color' => '#333',
],
]);
}
/**
* @return string
*/
public function getFirst(): string
{
return $this->first;
}
/**
* @param string $first
*/
public function setFirst(string $first): void
{
$this->first = $first;
}
/**
* @return string
*/
public function getStationName(): string
{
return $this->stationName;
}
/**
* @param string $stationName
*/
public function setStationName(string $stationName): void
{
$this->stationName = $stationName;
}
/**
* @return string
*/
public function getPortName(): string
{
return $this->portName;
}
/**
* @param string $portName
*/
public function setPortName(string $portName): void
{
$this->portName = $portName;
}
/**
* @return string
*/
public function getDate(): string
{
return $this->date;
}
/**
* @param string $date
*/
public function setDate(string $date): void
{
$this->date = $date;
}
/**
* @return string
*/
public function getRemark(): string
{
return $this->remark;
}
/**
* @param string $remark
*/
public function setRemark(string $remark): void
{
$this->remark = $remark;
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: banice
* Date: 2018/7/19
* Time: 下午3:23
*/
namespace Lib\remote\api\message;
class ChargerShedTimeOutMessage extends Message
{
protected $templateId = 'rdzTNQ7t4uRXkP0SkuwW10WH77A_CIgYFiJykXJ0utU';
private $first = '尊敬的用户,您的爱车插头脱落,等待10分钟未检测到插头重新插入,本次充电已结束
';
/**
* @var string
*/
private $startTime = '';
/**
* @var string
*/
private $purchaseTime = '';
/**
* @var string
*/
private $endTime = '';
/**
* @var string
*/
private $remark = '温馨提示:您的爱车已停止充电,如有疑问您可以在公众号后台留言或直接拨打客服热线进行咨询。
感谢您的使用';
public function __construct()
{
$this->templateId = getenv('MESSAGE_SHED_TIMEOUT');
}
public function getPushJson(): string
{
return json_encode([
'first' => [
'value' => $this->first,
'color' => '#333',
],
'keyword1' => [
'value' => $this->startTime,
'color' => '#333',
],
'keyword2' => [
'value' => $this->purchaseTime,
'color' => '#333',
],
'keyword3' => [
'value' => $this->endTime,
'color' => '#333',
],
'remark' => [
'value' => $this->remark,
'color' => '#333',
],
]);
}
/**
* @return string
*/
public function getTemplateId(): string
{
return $this->templateId;
}
/**
* @return string
*/
public function getFirst(): string
{
return $this->first;
}
/**
* @param string $first
*/
public function setFirst(string $first): void
{
$this->first = $first;
}
/**
* @return string
*/
public function getStartTime(): string
{
return $this->startTime;
}
/**
* @param string $startTime
*/
public function setStartTime(string $startTime): void
{
$this->startTime = $startTime;
}
/**
* @return string
*/
public function getPurchaseTime(): string
{
return $this->purchaseTime;
}
/**
* @param string $purchaseTime
*/
public function setPurchaseTime(string $purchaseTime): void
{
$this->purchaseTime = $purchaseTime;
}
/**
* @return string
*/
public function getEndTime(): string
{
return $this->endTime;
}
/**
* @param string $endTime
*/
public function setEndTime(string $endTime): void
{
$this->endTime = $endTime;
}
/**
* @return string
*/
public function getRemark(): string
{
return $this->remark;
}
/**
* @param string $remark
*/
public function setRemark(string $remark): void
{
$this->remark = $remark;
}
}
\ No newline at end of file
...@@ -24,11 +24,6 @@ class FailMessage extends Message ...@@ -24,11 +24,6 @@ class FailMessage extends Message
/** /**
* @var string * @var string
*/ */
private $orderId = '';
/**
* @var string
*/
private $address = ''; private $address = '';
/** /**
...@@ -71,7 +66,7 @@ class FailMessage extends Message ...@@ -71,7 +66,7 @@ class FailMessage extends Message
'value' => number_format($this->amount / 100.0, 2), 'value' => number_format($this->amount / 100.0, 2),
'color' => '#333', 'color' => '#333',
], ],
'remark' => [ 'remark' => [
'value' => $this->remark, 'value' => $this->remark,
'color' => '#333', 'color' => '#333',
], ],
...@@ -80,7 +75,6 @@ class FailMessage extends Message ...@@ -80,7 +75,6 @@ class FailMessage extends Message
} }
/** /**
* @return string * @return string
*/ */
...@@ -97,21 +91,6 @@ class FailMessage extends Message ...@@ -97,21 +91,6 @@ class FailMessage extends Message
$this->first = $first; $this->first = $first;
} }
/**
* @return string
*/
public function getOrderId(): string
{
return $this->orderId;
}
/**
* @param string $orderId
*/
public function setOrderId(string $orderId): void
{
$this->orderId = $orderId;
}
/** /**
* @return string * @return string
......
...@@ -37,23 +37,25 @@ class SendMessage ...@@ -37,23 +37,25 @@ class SendMessage
{ {
$client = new Client([ $client = new Client([
'base_uri' => $this->uri, 'base_uri' => $this->uri,
'http_errors' => false, 'http_errors' => false,
]); ]);
$response = $client->request('POST', $this->uri, [ $response = $client->request('POST', $this->path, [
'form_params' => [ 'form_params' => [
'userId' => $message->getUserId(), 'userId' => $message->getUserId(),
'templateId' => $message->getTemplateId(), 'templateId' => $message->getTemplateId(),
'data' => $message->getPushJson(), 'data' => $message->getPushJson(),
], ],
]); ]);
if ($response->getStatusCode() === 200) { if ($response->getStatusCode() === 200) {
Log::debug('发送模版消息'); Log::debug('发送模版消息');
} else {
Log::error('send wx message fail ', ['http_code' => $response->getStatusCode()]);
} }
......
...@@ -77,8 +77,8 @@ class StartMessage extends Message ...@@ -77,8 +77,8 @@ class StartMessage extends Message
'value' => number_format($this->amount / 100, 2), 'value' => number_format($this->amount / 100, 2),
'color' => '#333', 'color' => '#333',
], ],
'remark' => [ 'remark' => [
'value' => $this->remark . '\n' . "($this->orderId)", 'value' => $this->remark . "($this->orderId)",
'color' => '#333', 'color' => '#333',
], ],
]); ]);
...@@ -135,6 +135,4 @@ class StartMessage extends Message ...@@ -135,6 +135,4 @@ class StartMessage extends Message
} }
} }
\ No newline at end of file
...@@ -20,12 +20,12 @@ class Gateway ...@@ -20,12 +20,12 @@ class Gateway
* @param int $state * @param int $state
* @return int * @return int
*/ */
public function setState(int $gatewayId,int $state) public function setState(int $gatewayId, int $state)
{ {
$redis = \Events::getRedis(); $redis = \Events::getRedis();
return $redis->zAdd(self::GATEWAY_STATE,$state,$gatewayId); return $redis->zAdd(self::GATEWAY_STATE, $state, $gatewayId);
} }
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
namespace Lib\station\gateway\port; namespace Lib\station\gateway\port;
use Application\model\DeviceModel;
use Lib\log\Log;
use Lib\StateCode; use Lib\StateCode;
use Lib\station\gateway\Gateway; use Lib\station\gateway\Gateway;
use Lib\station\Station; use Lib\station\Station;
...@@ -22,13 +24,14 @@ class Port ...@@ -22,13 +24,14 @@ class Port
/** /**
* 端口正在充电的订单号 * 端口正在充电的订单号
* cdz:port:using:order_id:hash
*/ */
const USING_ORDER_ID = 'cdz:port:using:order_id:hash'; const USING_ORDER_ID = 'cdz:port:using:order_id:hash';
/** /**
* 端口正在使用的用户号 * 端口正在使用的用户号
*/ */
const USING_USER_ID = 'cdz:port:using_user_id:zset'; const USING_USER_ID = 'cdz:port:using:user_id:zset';
/** /**
* 端口状态有序集合 * 端口状态有序集合
...@@ -58,12 +61,12 @@ class Port ...@@ -58,12 +61,12 @@ class Port
/** /**
* @var int * @var int
*/ */
private $gatewayId; private $gatewayId = 0;
/** /**
* @var int * @var int
*/ */
private $stationId; private $stationId = 0;
public function __construct(int $portId = 0) public function __construct(int $portId = 0)
{ {
...@@ -73,17 +76,36 @@ class Port ...@@ -73,17 +76,36 @@ class Port
/** /**
* 更新端口状态 * 更新端口状态
* @param int $orderId
*/ */
public function updatePortState() public function updatePortState(int $orderId = 0)
{ {
$redis = \Events::getRedis(); $redis = \Events::getRedis();
$redis->zAdd(self::PORT_STATE, $this->state, $this->portId); $redis->zAdd(self::PORT_STATE, $this->state, $this->portId);
if ($this->stationId === 0 || $this->gatewayId === 0) {
if (isset($_SESSION['gateway_id']) && isset($_SESSION['station_id'])) {
$this->stationId = $_SESSION['station_id'];
$this->gatewayId = $_SESSION['gateway_id'];
} else {
Log::error('can not find gateway_id or station_id from session');
return;
}
}
$redis->zAdd(sprintf(Gateway::GATEWAY_PORT_STATE, $this->gatewayId), $this->state, $this->portId); $redis->zAdd(sprintf(Gateway::GATEWAY_PORT_STATE, $this->gatewayId), $this->state, $this->portId);
$redis->zAdd(sprintf(Station::STATION_PORT_STATE, $this->stationId), $this->state, $this->portId); $redis->zAdd(sprintf(Station::STATION_PORT_STATE, $this->stationId), $this->state, $this->portId);
$portModel = new DeviceModel();
$portModel->update([
'state' => $this->state,
'updated_at' => date('Y-m-d H:i:s')
], 'id = ' . $this->portId);
if ($orderId !== 0) {
$redis->zAdd('cdz:order:state:zset', $this->state, $orderId);
}
} }
...@@ -100,8 +122,9 @@ class Port ...@@ -100,8 +122,9 @@ class Port
/** /**
* 释放口子,更新口子状态为空闲 * 释放口子,更新口子状态为空闲
* @param int $orderId
*/ */
public function freePort() public function freePort(int $orderId = 0)
{ {
\Events::pipe(); \Events::pipe();
...@@ -109,8 +132,12 @@ class Port ...@@ -109,8 +132,12 @@ class Port
$this->state = StateCode::PORT_ONLINE; $this->state = StateCode::PORT_ONLINE;
$this->updatePortState(); $this->updatePortState($orderId);
if ($orderId != 0) {
$redis->zRem('cdz:order:state:zset', $orderId);
$redis->del('cdz:order:state:' . $orderId);
}
$redis->zDelete(self::USING_USER_ID, $this->portId); $redis->zDelete(self::USING_USER_ID, $this->portId);
$redis->hDel(self::USING_ORDER_ID, $this->portId); $redis->hDel(self::USING_ORDER_ID, $this->portId);
...@@ -120,6 +147,7 @@ class Port ...@@ -120,6 +147,7 @@ class Port
} }
/** /**
* 释放端口的订单,布更新端口的状态 * 释放端口的订单,布更新端口的状态
*/ */
......
<?php
/**
* Created by PhpStorm.
* User: banice
* Date: 2018/8/23
* Time: 下午7:55
*/
namespace Src;
use Lib\Gateway;
class BroadcastToAgent
{
private $agentId = '';
public function __construct()
{
if (isset($_SESSION['agent_id'])) {
$this->agentId = $_SESSION['agent_id'];
}
}
public function broadcast(array $data)
{
if ($this->agentId !== '') {
Gateway::sendToUid($this->agentId, json_encode($data));
return true;
} else {
return false;
}
}
}
\ No newline at end of file
...@@ -15,8 +15,6 @@ class Test ...@@ -15,8 +15,6 @@ class Test
public function __destruct() public function __destruct()
{ {
var_dump('i am test');
// TODO: Implement __destruct() method. // TODO: Implement __destruct() method.
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment