Commit 3baf527c by banice

修改充满自停的开始时间格式

parent 840b5072
......@@ -31,5 +31,6 @@ MESSAGE_CHARGER_TIMEOUT=f0DDXSxvRTbHyzkCnwnYijtgteFTdfdUR7J8REwTYJ8
MESSAGE_RELOAD=t_PyOGCKN_fmD0blw0EuIQs-8sS3qOTmpQay12haPZY
MESSAGE_SHED_TIMEOUT=rdzTNQ7t4uRXkP0SkuwW10WH77A_CIgYFiJykXJ0utU
MESSAGE_CHARGER_SHED=C0LvfETe-1rCR_IhOydDGPTUwwYkrWZxgfwMsETrhw8
DOWNLOAD_HOST=https://cdzpay.test.senthink.com
LOW_POWER_LIMIT=30
REDIS_HOST=redis.staging.senthink.com
REGISTER_IP=127.0.0.1
REGISTER_IP=100.109.192.7
REGISTER_PORT=1239
GATEWAY_PORT=8282
GATEWAY_IP=127.0.0.1
GATEWAY_COUNT=4
GATEWAY_START_PORT=1230
START_FILE=business|gateway|register
START_FILE=business
DB_HOST=db.staging.senthink.com
DB_USERNAME=senthink
......
......@@ -56,6 +56,7 @@ class AccessController extends Controller
{
$mac = $this->request->get('mac');
$_SESSION['gateway_mac'] = $mac;
$gatewayModel = new GatewayModel();
......@@ -68,7 +69,8 @@ class AccessController extends Controller
$gatewayModelResult = $gatewayModel->getColumns([
'station_id',
'id',
'name'
'name',
'type_id'
], 'mac_address = ' . "'$mac'");
if ($gatewayModelResult == false) {
......@@ -83,6 +85,8 @@ class AccessController extends Controller
$_SESSION['gateway_id'] = $gatewayModelResult['id'];
$_SESSION['gateway_type'] = $gatewayModelResult['type_id'];
//日志记录
$this->logRecord->setGatewayId($gatewayId);
......@@ -263,8 +267,9 @@ class AccessController extends Controller
$order->setOnlineTime(time());
if ($offlineReason == 1) {
} else {
$orderState = new OfflineNetState($order);
} else {
$orderState = new OfflinePowerState($order);
}
$remainTime = $orderState->getRemainChargerTime();
......
<?php
/**
* Created by PhpStorm.
* User: banice
* Date: 2018/9/17
* Time: 上午10:52
*/
namespace Application\controller\update;
use Application\controller\Controller;
use Application\model\GatewayModel;
use Application\model\GatewayUpdateModel;
use GatewayWorker\Lib\Gateway;
use Lib\log\Log;
class QueryController extends Controller
{
protected $parameterMap = [
'D1' => [
'hardware_version' => 4,
'software_version' => 4,
]
];
public function __construct(string $clientId, string $message, string $command)
{
parent::__construct($clientId, $message, $command);
}
public function __destruct()
{
parent::__destruct();
}
/**
* @throws \Exception
*/
public function check()
{
$hardwareVersion = $this->request->get('hardware_version');
$softwareVersion = $this->request->get('software_version');
$response = '';
Log::debug('session', Gateway::getSession($this->clientId));
$gatewayType = isset($_SESSION['gateway_type']) ? $_SESSION['gateway_type'] : false;
if ($gatewayType === false) {
Log::debug('can not find gateway type');
return;
}
$gatewayUpdateModel = new GatewayUpdateModel();
$updateInfo = $gatewayUpdateModel->getColumns(['hardware_version', 'software_version'], 'gateway_type = ' . $gatewayType);
if (count($updateInfo) !== 0) {
$updateHardwareVersion = $updateInfo['hardware_version'];
// $updateSoftwareVersion = sprintf('%08x', $updateInfo['software_version']);
$updateSoftwareVersion = sprintf($updateInfo['software_version']);
if ($updateHardwareVersion == $hardwareVersion && $updateSoftwareVersion == $softwareVersion) {
$returnCode = '10';
} else {
//todo 检查下载资源
$returnCode = '12';
$host = getenv('DOWNLOAD_HOST');
if ($host === false) {
throw new \Exception('can not find download host');
}
$downloadUrl = $host . '/update/' . $updateHardwareVersion . $updateSoftwareVersion . '.bin';
$urlHex = '';
for ($i = 0; $i < strlen($downloadUrl); $i++) {
$hex = sprintf('%02x', ord($downloadUrl[$i]));
$urlHex .= $hex;
}
$this->response->send('d1', $returnCode . $updateHardwareVersion . $updateSoftwareVersion . $urlHex);
}
}
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: banice
* Date: 2018/9/17
* Time: 上午11:10
*/
namespace Application\model;
class GatewayUpdateModel extends Model
{
protected $table = 'gateway_update';
}
\ No newline at end of file
......@@ -43,7 +43,7 @@ class Api
$this->add('35', 'card\charger\OverController@over');
$this->add('0E', 'setting\DeviceMacController@getAll');
$this->add('D1', 'update\QueryController@check');
}
......
......@@ -202,13 +202,15 @@ class ChargerState extends State
$orderExceptionModel->insertRow([
'order_id' => $this->order->getId(),
'state' => StateCode::PORT_CHARGER . StateCode::FINISH_FULL,
'desc' => '订单充电自停',
'desc' => '订单充满自停',
'created_at' => $this->nowDate,
]);
Log::debug('充满自停状态');
$chargerFullMessage = new ChargerFullMessage();
$chargerFullMessage->setEndTime($this->nowDate);
$chargerFullMessage->setStartTime($this->order->getStartTime());
$chargerFullMessage->setStartTime(date('Y-m-d H:i:s',$this->order->getStartTime()));
$chargerFullMessage->setPurchaseTime($this->order->getPurchaseTime());
$chargerFullMessage->setUserId($this->order->getUserId());
$chargerFullMessage->setRemark($chargerFullMessage->getRemark() . '\n' . sprintf('%012x', $this->order->getId()));
......
......@@ -51,6 +51,7 @@ class Log
} else {
static::$log = new Logger($logName);
static::$log->pushHandler(new RotatingFileHandler($logName, 30));
}
}
......@@ -63,13 +64,7 @@ class Log
public static function __callStatic($name, $arguments)
{
$gatewayMac = isset($_SESSION['gateway_mac']) ? $_SESSION['gateway_mac'] : 'null mac';
$handle = new RotatingFileHandler(self::LOG_NAME, 30);
$output = "[%datetime%] [%$gatewayMac%].%level_name%: %message% %context% %extra%\n";
$handle->setFormatter(new LineFormatter($output, 'Y-m-d H:i:s'));
static::bootLog();
return call_user_func_array([static::$log, $name], $arguments);
......
......@@ -24,6 +24,11 @@ class ChargerFullMessage extends Message
private $remark = '温馨提示:您的爱车已停止充电,如有疑问您可以在公众号后台留言或直接拨打客服热线进行咨询。
感谢您的使用';
public function __construct()
{
$this->templateId = getenv('MESSAGE_CHARGER_FULL');
}
public function getPushJson(): string
{
......@@ -64,13 +69,6 @@ class ChargerFullMessage extends Message
return $this->templateId;
}
/**
* @param string $templateId
*/
public function setTemplateId(string $templateId): void
{
$this->templateId = $templateId;
}
/**
* @return string
......
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