|
@@ -66,14 +66,13 @@ public class ID_ReaderStatus
|
|
internal partial class ProfileHandler
|
|
internal partial class ProfileHandler
|
|
{
|
|
{
|
|
private readonly ILogger logger;
|
|
private readonly ILogger logger;
|
|
- //private readonly BlockingTreePrintService blockingTreePrintService;
|
|
|
|
- //private readonly GoogleGetTimePrintService googleGetTimePrintService;
|
|
|
|
private readonly ServerMessageService messageService;
|
|
private readonly ServerMessageService messageService;
|
|
|
|
|
|
- //private readonly string webConnectionString;// = ConfigurationManager.ConnectionStrings[].ConnectionString;
|
|
|
|
|
|
+
|
|
private readonly IDbContextFactory<MainDBContext> maindbContextFactory;
|
|
private readonly IDbContextFactory<MainDBContext> maindbContextFactory;
|
|
private readonly ISqlConnectionFactory<WebDBConetext> webDbConnectionFactory;
|
|
private readonly ISqlConnectionFactory<WebDBConetext> webDbConnectionFactory;
|
|
private readonly MeterValueDbService meterValueDbService;
|
|
private readonly MeterValueDbService meterValueDbService;
|
|
|
|
+ private readonly ConnectorStatusDbService connectorStatusDbService;
|
|
|
|
|
|
//private readonly IDbContextFactory<MeterValueDBContext> metervaluedbContextFactory;
|
|
//private readonly IDbContextFactory<MeterValueDBContext> metervaluedbContextFactory;
|
|
private readonly IBusinessServiceFactory businessServiceFactory;
|
|
private readonly IBusinessServiceFactory businessServiceFactory;
|
|
@@ -84,27 +83,24 @@ internal partial class ProfileHandler
|
|
IConfiguration configuration,
|
|
IConfiguration configuration,
|
|
IDbContextFactory<MainDBContext> maindbContextFactory,
|
|
IDbContextFactory<MainDBContext> maindbContextFactory,
|
|
ISqlConnectionFactory<WebDBConetext> webDbConnectionFactory,
|
|
ISqlConnectionFactory<WebDBConetext> webDbConnectionFactory,
|
|
- //IDbContextFactory<MeterValueDBContext> metervaluedbContextFactory,
|
|
|
|
MeterValueDbService meterValueDbService,
|
|
MeterValueDbService meterValueDbService,
|
|
|
|
+ ConnectorStatusDbService connectorStatusDbService,
|
|
IBusinessServiceFactory businessServiceFactory,
|
|
IBusinessServiceFactory businessServiceFactory,
|
|
IMainDbService mainDbService,
|
|
IMainDbService mainDbService,
|
|
ILogger<ProfileHandler> logger,
|
|
ILogger<ProfileHandler> logger,
|
|
- //BlockingTreePrintService blockingTreePrintService,
|
|
|
|
- //GoogleGetTimePrintService googleGetTimePrintService,
|
|
|
|
ServerMessageService messageService,
|
|
ServerMessageService messageService,
|
|
OuterHttpClient httpClient)
|
|
OuterHttpClient httpClient)
|
|
{
|
|
{
|
|
- //webConnectionString = configuration.GetConnectionString("WebDBContext");
|
|
|
|
|
|
+
|
|
|
|
|
|
- this.logger = logger;
|
|
|
|
- //this.blockingTreePrintService = blockingTreePrintService;
|
|
|
|
- //this.googleGetTimePrintService = googleGetTimePrintService;
|
|
|
|
|
|
+ this.logger = logger;
|
|
this.messageService = messageService;
|
|
this.messageService = messageService;
|
|
this.maindbContextFactory = maindbContextFactory;
|
|
this.maindbContextFactory = maindbContextFactory;
|
|
this.webDbConnectionFactory = webDbConnectionFactory;
|
|
this.webDbConnectionFactory = webDbConnectionFactory;
|
|
this.meterValueDbService = meterValueDbService;
|
|
this.meterValueDbService = meterValueDbService;
|
|
|
|
+ this.connectorStatusDbService = connectorStatusDbService;
|
|
this.mainDbService = mainDbService;
|
|
this.mainDbService = mainDbService;
|
|
- //this.metervaluedbContextFactory = metervaluedbContextFactory;
|
|
|
|
|
|
+
|
|
this.businessServiceFactory = businessServiceFactory;
|
|
this.businessServiceFactory = businessServiceFactory;
|
|
this.httpClient = httpClient;
|
|
this.httpClient = httpClient;
|
|
}
|
|
}
|
|
@@ -294,10 +290,14 @@ internal partial class ProfileHandler
|
|
long s1 = 0, s2 = 0, s3 = 0, s4 = 0, s5 = 0;
|
|
long s1 = 0, s2 = 0, s3 = 0, s4 = 0, s5 = 0;
|
|
//只保留最新上報狀況
|
|
//只保留最新上報狀況
|
|
StatusNotificationRequest _request = request as StatusNotificationRequest;
|
|
StatusNotificationRequest _request = request as StatusNotificationRequest;
|
|
|
|
+
|
|
int preStatus = 0;
|
|
int preStatus = 0;
|
|
ConnectorStatus _oldStatus;
|
|
ConnectorStatus _oldStatus;
|
|
|
|
|
|
- _oldStatus = await mainDbService.GetConnectorStatus(session.ChargeBoxId, _request.connectorId);
|
|
|
|
|
|
+ await connectorStatusDbService.InsertAsync(session.ChargeBoxId,(byte) _request.connectorId, (int)_request.status, _request.timestamp.HasValue? _request.timestamp.Value.ToUniversalTime(): DateTime.UtcNow,
|
|
|
|
+ _request.info, _request.vendorId, _request.vendorErrorCode, (int)_request.errorCode);
|
|
|
|
+
|
|
|
|
+ _oldStatus = await mainDbService.GetConnectorStatus(session.ChargeBoxId, _request.connectorId);
|
|
|
|
|
|
s1 = statusNotificationTimer.ElapsedMilliseconds;
|
|
s1 = statusNotificationTimer.ElapsedMilliseconds;
|
|
|
|
|
|
@@ -307,7 +307,7 @@ internal partial class ProfileHandler
|
|
|
|
|
|
await mainDbService.UpdateConnectorStatus(_oldStatus.Id, new ConnectorStatus()
|
|
await mainDbService.UpdateConnectorStatus(_oldStatus.Id, new ConnectorStatus()
|
|
{
|
|
{
|
|
- CreatedOn = _request.timestamp.HasValue ? _request.timestamp.Value : DateTime.UtcNow,
|
|
|
|
|
|
+ CreatedOn = _request.timestamp.HasValue ? _request.timestamp.Value.ToUniversalTime() : DateTime.UtcNow,
|
|
Status = (int)_request.status,
|
|
Status = (int)_request.status,
|
|
ChargePointErrorCodeId = (int)_request.errorCode,
|
|
ChargePointErrorCodeId = (int)_request.errorCode,
|
|
ErrorInfo = string.IsNullOrEmpty(_request.info) ? string.Empty : _request.info,
|
|
ErrorInfo = string.IsNullOrEmpty(_request.info) ? string.Empty : _request.info,
|
|
@@ -318,12 +318,12 @@ internal partial class ProfileHandler
|
|
if (preStatus == (int)ChargePointStatus.Faulted)
|
|
if (preStatus == (int)ChargePointStatus.Faulted)
|
|
{
|
|
{
|
|
if (_request.status != ChargePointStatus.Faulted ||
|
|
if (_request.status != ChargePointStatus.Faulted ||
|
|
- (_oldStatus.ChargePointErrorCodeId != (int)_request.errorCode && _oldStatus.VendorErrorCode != _request.vendorErrorCode))
|
|
|
|
|
|
+ (_oldStatus.ChargePointErrorCodeId != (int)_request.errorCode || _oldStatus.VendorErrorCode != _request.vendorErrorCode))
|
|
{
|
|
{
|
|
await mainDbService.FillupFinishedTimetoMachineError(
|
|
await mainDbService.FillupFinishedTimetoMachineError(
|
|
ChargeBoxId: session.ChargeBoxId,
|
|
ChargeBoxId: session.ChargeBoxId,
|
|
ConnectorId: (byte)_request.connectorId,
|
|
ConnectorId: (byte)_request.connectorId,
|
|
- FinishedOn: _request.timestamp.HasValue ? _request.timestamp.Value : DateTime.UtcNow
|
|
|
|
|
|
+ FinishedOn: _request.timestamp.HasValue ? _request.timestamp.Value.ToUniversalTime() : DateTime.UtcNow
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -337,7 +337,7 @@ internal partial class ProfileHandler
|
|
await mainDbService.AddConnectorStatus(
|
|
await mainDbService.AddConnectorStatus(
|
|
ChargeBoxId: session.ChargeBoxId,
|
|
ChargeBoxId: session.ChargeBoxId,
|
|
ConnectorId: (byte)_request.connectorId,
|
|
ConnectorId: (byte)_request.connectorId,
|
|
- CreatedOn: _request.timestamp.HasValue ? _request.timestamp.Value : DateTime.UtcNow,
|
|
|
|
|
|
+ CreatedOn: _request.timestamp.HasValue ? _request.timestamp.Value.ToUniversalTime() : DateTime.UtcNow,
|
|
Status: (int)_request.status,
|
|
Status: (int)_request.status,
|
|
ChargePointErrorCodeId: (int)_request.errorCode,
|
|
ChargePointErrorCodeId: (int)_request.errorCode,
|
|
ErrorInfo: string.IsNullOrEmpty(_request.info) ? string.Empty : _request.info,
|
|
ErrorInfo: string.IsNullOrEmpty(_request.info) ? string.Empty : _request.info,
|
|
@@ -354,7 +354,7 @@ internal partial class ProfileHandler
|
|
if (isNeedAddMachineError)
|
|
if (isNeedAddMachineError)
|
|
{
|
|
{
|
|
await mainDbService.AddMachineError(ConnectorId: (byte)_request.connectorId,
|
|
await mainDbService.AddMachineError(ConnectorId: (byte)_request.connectorId,
|
|
- CreatedOn: _request.timestamp.HasValue ? _request.timestamp.Value : DateTime.UtcNow,
|
|
|
|
|
|
+ CreatedOn: _request.timestamp.HasValue ? _request.timestamp.Value.ToUniversalTime() : DateTime.UtcNow,
|
|
Status: (int)_request.status,
|
|
Status: (int)_request.status,
|
|
ChargeBoxId: session.ChargeBoxId,
|
|
ChargeBoxId: session.ChargeBoxId,
|
|
ErrorCodeId: (int)_request.errorCode,
|
|
ErrorCodeId: (int)_request.errorCode,
|
|
@@ -376,8 +376,8 @@ internal partial class ProfileHandler
|
|
ConnectorId = _request.connectorId,
|
|
ConnectorId = _request.connectorId,
|
|
ErrorCode = _request.errorCode,
|
|
ErrorCode = _request.errorCode,
|
|
Info = string.IsNullOrEmpty(_request.info) ? string.Empty : _request.info,
|
|
Info = string.IsNullOrEmpty(_request.info) ? string.Empty : _request.info,
|
|
- OCcuredOn = _request.timestamp ?? DateTime.UtcNow,
|
|
|
|
- VendorErrorCode = string.IsNullOrEmpty(_request.vendorErrorCode) ? string.Empty : _request.vendorErrorCode,
|
|
|
|
|
|
+ OCcuredOn = _request.timestamp.HasValue ? _request.timestamp.Value.ToUniversalTime() : DateTime.UtcNow,
|
|
|
|
+ VendorErrorCode = string.IsNullOrEmpty(_request.vendorErrorCode) ? string.Empty : _request.vendorErrorCode,
|
|
|
|
|
|
});
|
|
});
|
|
}
|
|
}
|
|
@@ -1157,6 +1157,10 @@ internal partial class ProfileHandler
|
|
|
|
|
|
if (tx.BillingDone) return result;
|
|
if (tx.BillingDone) return result;
|
|
|
|
|
|
|
|
+ if (feedto.StopTime != DefaultSetting.DefaultNullTime)
|
|
|
|
+ {
|
|
|
|
+ await mainDbService.InsertOrUpdateTransactionPeriodEnergy(txEnergy.TxId, txEnergy.PeriodEnergy);
|
|
|
|
+ }
|
|
|
|
|
|
var startTime = new DateTime(tx.StartTime.Year, tx.StartTime.Month, tx.StartTime.Day, tx.StartTime.Hour, 0, 0);
|
|
var startTime = new DateTime(tx.StartTime.Year, tx.StartTime.Month, tx.StartTime.Day, tx.StartTime.Hour, 0, 0);
|
|
List<ChargingBill> confirmbill = new List<ChargingBill>();
|
|
List<ChargingBill> confirmbill = new List<ChargingBill>();
|
|
@@ -1223,6 +1227,7 @@ internal partial class ProfileHandler
|
|
|
|
|
|
if (customerInfo != null && customerInfo.InstantStopTxReport)
|
|
if (customerInfo != null && customerInfo.InstantStopTxReport)
|
|
{
|
|
{
|
|
|
|
+ var PeriodEnergy = await mainDbService.GetTransactionPeriodEnergy(tx.Id);
|
|
|
|
|
|
var request = new
|
|
var request = new
|
|
{
|
|
{
|
|
@@ -1237,7 +1242,10 @@ internal partial class ProfileHandler
|
|
StopReason = tx.StopReasonId < 1 ? "Unknown" : (tx.StopReasonId > 12 ? "Unknown" : ((Reason)tx.StopReasonId).ToString()),
|
|
StopReason = tx.StopReasonId < 1 ? "Unknown" : (tx.StopReasonId > 12 ? "Unknown" : ((Reason)tx.StopReasonId).ToString()),
|
|
Receipt = tx.Receipt,
|
|
Receipt = tx.Receipt,
|
|
TotalCost = tx.Cost,
|
|
TotalCost = tx.Cost,
|
|
- Fee = tx.Fee
|
|
|
|
|
|
+ Fee = tx.Fee,
|
|
|
|
+ PeriodEnergy = PeriodEnergy,
|
|
|
|
+ StartSOC = int.TryParse(tx.StartSoc, out int StartSOCint) ? StartSOCint : (int?)null,
|
|
|
|
+ StopSOC = int.TryParse(tx.StopSoc, out int StopSOCint) ? StopSOCint : (int?)null
|
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
@@ -1785,8 +1793,9 @@ internal partial class ProfileHandler
|
|
energy = Decimal.Parse(energy.ToString("0.0000"));
|
|
energy = Decimal.Parse(energy.ToString("0.0000"));
|
|
return energy;
|
|
return energy;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
|
|
- private static bool CheckNeedAddMachineError(StatusNotificationRequest _request, ConnectorStatus _oldStatus)
|
|
|
|
|
|
+ private static bool CheckNeedAddMachineError(StatusNotificationRequest _request, ConnectorStatus _oldStatus)
|
|
{
|
|
{
|
|
if (_request.status != ChargePointStatus.Faulted)
|
|
if (_request.status != ChargePointStatus.Faulted)
|
|
{
|
|
{
|
|
@@ -1803,7 +1812,7 @@ internal partial class ProfileHandler
|
|
{
|
|
{
|
|
isNeedAddMachineError = true;
|
|
isNeedAddMachineError = true;
|
|
}
|
|
}
|
|
- else if (_oldStatus.ChargePointErrorCodeId != (int)_request.errorCode && _oldStatus.VendorErrorCode != _request.vendorErrorCode)
|
|
|
|
|
|
+ else if (_oldStatus.ChargePointErrorCodeId != (int)_request.errorCode || _oldStatus.VendorErrorCode != _request.vendorErrorCode)
|
|
{
|
|
{
|
|
isNeedAddMachineError = true;
|
|
isNeedAddMachineError = true;
|
|
}
|
|
}
|