Commit fc3261c9 by yangsh

修改13异常,agent推送data问题

parent a4647a89
REDIS_HOST=redis.staging.senthink.com
REGISTER_IP=100.109.192.7
REGISTER_IP=100.119.192.19
REGISTER_PORT=1239
GATEWAY_PORT=8282
GATEWAY_IP=127.0.0.1
GATEWAY_IP=100.119.192.36
GATEWAY_COUNT=4
GATEWAY_START_PORT=1230
START_FILE=business
......
......@@ -50,96 +50,6 @@ class AccessController extends Controller
}
// private function test($mac)
// {
//
//
// Gateway::bindUid($this->clientId, $mac);
//
// $_SESSION['gateway_mac'] = $mac;
// $gatewayModel = new GatewayModel();
//
//
// if (isset($_SESSION['gateway_mac'])) {
// if ($_SESSION['gateway_mac'] != $mac) {
// Gateway::closeClient($this->clientId);
//
// }
//
// $gatewayModelResult = $gatewayModel->getColumns([
// 'station_id',
// 'id',
// 'name',
// 'type_id'
// ], 'mac_address = ' . "'$mac'");
//
// if ($gatewayModelResult == false) {
// Gateway::closeClient($this->clientId);
// return;
// }
// $stationId = $gatewayModelResult['station_id'];
//
// $gatewayId = $gatewayModelResult['id'];
//
// $_SESSION['gateway_name'] = $gatewayModelResult['name'];
//
// $_SESSION['gateway_id'] = $gatewayModelResult['id'];
//
// $_SESSION['gateway_type'] = $gatewayModelResult['type_id'];
//
// $stationModel = new StationModel();
// $stationData = $stationModel->getColumns([
// 'park_id',
// 'name',
// ], 'id = ' . $stationId);
//
// if (isset($stationData['park_id']) && isset($stationData['name'])) {
// $parkId = $stationData['park_id'];
// $_SESSION['station_name'] = $stationData['name'];
// 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();
//
// $deviceModelResult = $deviceModel->getAllColumns([
//
// 'id',
// 'device_mac',
// 'name',
// 'status_id',
// ], 'gateway_id = ' . $gatewayId);
//
// $tmp = [];
// $portsIdName = [];
// $portsStatus = [];
// foreach ($deviceModelResult as $item) {
//
// $tmp[$item['device_mac']] = $item['id'];
// $portsIdName[$item['id']] = $item['name'];
// $portsStatus[$item['id']] = $item['status_id'];
// }
// $_SESSION['port_id_status'] = $portsStatus;
// $_SESSION['port_id_name'] = $portsIdName;
// $_SESSION['port_mac_id'] = $tmp;
// $_SESSION['port_id_mac'] = array_flip($tmp);
//
// $_SESSION['station_id'] = $stationId;
// $_SESSION['gateway_id'] = $gatewayId;
// $_SESSION['client_id'] = $this->clientId;
//
// }
// }
/**
* 请求入网
* 网关下的所有端口id和mac写如session
......
......@@ -49,6 +49,7 @@ class ChargerState extends State
'updated_at' => $this->nowDate,
'end_time' => $this->nowDate,
'state' => 1,
'is_exception' => 1,
], 'id = ' . $this->order->getId());
$port = new Port();
......@@ -129,6 +130,7 @@ class ChargerState extends State
'end_capacity' => $this->order->getEndCapacity(),
'end_time' => $this->nowDate,
'state' => 1,
'is_exception' => 1,
], 'id = ' . $this->order->getId());
$orderExceptionModel = new OrderExceptionModel();
......@@ -196,6 +198,7 @@ class ChargerState extends State
'end_time' => $this->nowDate,
'end_capacity' => $this->order->getEndCapacity(),
'state' => 1,
'is_exception' => 1,
], 'id = ' . $this->order->getId());
$orderExceptionModel = new OrderExceptionModel();
......@@ -260,6 +263,7 @@ class ChargerState extends State
$orderModel->update([
'updated_at' => $this->nowDate,
'shed_time' => $this->nowDate,
'is_exception' => 1,
], 'id = ' . $this->order->getId());
$orderExceptionModel = new OrderExceptionModel();
......
......@@ -39,18 +39,10 @@ class OfflineNetState extends State
$stateCode = $this->order->getStateCode();
if ($startTime === '') {
Log::debug('time equal purchase time');
$this->remainChargerTime = (int)($this->order->getPurchaseTime());
} else {
$purchaseTime = $this->order->getPurchaseTime();
$this->remainChargerTime = $purchaseTime * 60 - ((int)$this->order->getOnlineTime() - $startTime);
Log::debug('off net');
Log::debug($this->order->getOnlineTime());
Log::debug($startTime . 'start_time');
Log::debug('remain charger time' . $this->remainChargerTime);
Log::debug('remain time' . ceil($this->remainChargerTime / 60));
$this->remainChargerTime = ceil($this->remainChargerTime / 60);
......
......@@ -41,6 +41,7 @@ class ShedState extends State
'updated_at' => $this->nowDate,
'end_time' => $this->nowDate,
'state' => 1,
'is_exception' => 1,
], 'id = ' . $this->order->getId());
$port = new Port();
......@@ -181,9 +182,11 @@ class ShedState extends State
'end_time' => $this->nowDate,
'is_stop' => StateCode::FINISH_SHED_TIMEOUT,
'end_capacity' => $this->order->getEndCapacity(),
'is_exception' => 1,
], 'id = ' . $this->order->getId());
$port = new Port($this->order->getPortId());
$port->setState(StateCode::PORT_ONLINE);
$port->setStationId($this->order->getStationId());
......
......@@ -59,6 +59,7 @@ class WaitingState extends State
'is_stop' => StateCode::FINISH_REFUND,
'end_capacity' => $this->order->getEndCapacity(),
'end_time' => date('Y-m-d H:i:s'),
'is_exception' => 1,
], 'id = ' . $this->order->getId());
$port = new Port();
......@@ -175,6 +176,7 @@ class WaitingState extends State
$orderModel->update([
'is_charger' => StateCode::PORT_EXCEPTION,
'start_capacity' => $this->order->getStartCapacity(),
'is_exception' => 1,
], 'id = ' . $this->order->getId());
//添加订单异常
......@@ -208,10 +210,7 @@ class WaitingState extends State
$port->updatePortState($this->order->getId());
$broadcastToAgent = new BroadcastToAgent();
$broadcastToAgent->broadcast([
'data' => $this->order->getOrderCache(\Events::getRedis()),
'notice_exception_code' => StateCode::PORT_EXCEPTION,
]);
$broadcastToAgent->broadcast($this->order->getOrderCache(\Events::getRedis()) + ['notice_exception_code' => StateCode::PORT_EXCEPTION]);
// TODO: Implement toExceptionState() method.
}
......
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