|
@@ -13,6 +13,7 @@ using NLog;
|
|
|
using OCPPPackage.Profiles;
|
|
|
using OCPPServer.Protocol;
|
|
|
using System;
|
|
|
+using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Configuration;
|
|
|
using System.Data;
|
|
@@ -180,7 +181,7 @@ namespace EVCB_OCPP.WSServer.Message
|
|
|
}
|
|
|
|
|
|
confirm.status = DataTransferStatus.Accepted;
|
|
|
- confirm.data = JsonConvert.SerializeObject(new { certificateStatus = iso15118_token == "12345678901234" ? "Accepted" : "CertificateExpired", idTokenInfo = new { status = iso15118_token=="12345678901234"? "Accepted" : "Invalid" } });
|
|
|
+ confirm.data = JsonConvert.SerializeObject(new { certificateStatus = iso15118_token == "12345678901234" ? "Accepted" : "CertificateExpired", idTokenInfo = new { status = iso15118_token == "12345678901234" ? "Accepted" : "Invalid" } });
|
|
|
|
|
|
|
|
|
}
|
|
@@ -592,10 +593,11 @@ namespace EVCB_OCPP.WSServer.Message
|
|
|
int _ConnectorId = 0;
|
|
|
|
|
|
var businessService = BusinessServiceFactory.CreateBusinessService(session.CustomerId.ToString());
|
|
|
-
|
|
|
var _idTagInfo = string.IsNullOrEmpty(_request.idTag) ? null : (_request.idTag == "Backend" ?
|
|
|
new IdTagInfo() { expiryDate = DateTime.UtcNow.AddDays(1), status = AuthorizationStatus.Accepted } : (await businessService.Authorize(session.ChargeBoxId, _request.idTag)).IdTagInfo);
|
|
|
|
|
|
+
|
|
|
+
|
|
|
//特例****飛宏客戶旗下的電樁,若遇到Portal沒回應的狀況 ~允許充電
|
|
|
if (session.CustomerId.ToString().ToUpper() == "8456AED9-6DD9-4BF3-A94C-9F5DCB9506F7" && _idTagInfo != null && _idTagInfo.status == AuthorizationStatus.ConcurrentTx)
|
|
|
{
|
|
@@ -608,8 +610,27 @@ namespace EVCB_OCPP.WSServer.Message
|
|
|
var transaction = db.TransactionRecord.Where(x => x.Id == _request.transactionId
|
|
|
&& x.ChargeBoxId == session.ChargeBoxId).FirstOrDefault();
|
|
|
|
|
|
+ #region 加入Transaction Start/StopSOC
|
|
|
+ if (!session.IsAC && _request.transactionId > 0)
|
|
|
+ {
|
|
|
+ var SearchTime = transaction.StartTime;
|
|
|
+ var txStopTime = _request.timestamp;
|
|
|
+ List<int> SOCCollection = new List<int>();
|
|
|
|
|
|
+ while (SearchTime.Date <= txStopTime.Date)
|
|
|
+ {
|
|
|
+
|
|
|
+ var searchResults = await GetTransactionSOC(transaction.Id, SearchTime.Date);
|
|
|
+ SOCCollection.AddRange(searchResults);
|
|
|
+ SearchTime = SearchTime.AddDays(1);
|
|
|
+ }
|
|
|
|
|
|
+ SOCCollection.Sort();
|
|
|
+ logger.Debug(string.Format("SOCCollection:" + String.Join(",", SOCCollection.Select(x => x.ToString()).ToArray())));
|
|
|
+ transaction.StartSOC = SOCCollection.First().ToString("0");
|
|
|
+ transaction.StopSOC = SOCCollection.Last().ToString("0");
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
//遠傳太久以前的停止充電 直接拒絕 避免電樁持續重送~~~~~~~
|
|
|
if (_request.timestamp < new DateTime(2021, 11, 1))
|
|
|
{
|
|
@@ -878,7 +899,7 @@ namespace EVCB_OCPP.WSServer.Message
|
|
|
db.Entry(machine).Property(x => x.BoardVersions).IsModified = true;
|
|
|
await db.SaveChangesAsync();
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
if (_request.messageId == "ID_TxEnergy") //計費
|
|
|
{
|
|
@@ -1639,5 +1660,39 @@ namespace EVCB_OCPP.WSServer.Message
|
|
|
|
|
|
return money;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ async private Task<List<int>> GetTransactionSOC(int TxId, DateTime queryDate)
|
|
|
+ {
|
|
|
+ List<int> SOCCollection = new List<int>();
|
|
|
+ try
|
|
|
+ {
|
|
|
+ using (var _meterDb = new MeterValueDBContext())
|
|
|
+ {
|
|
|
+ var parameters = new DynamicParameters();
|
|
|
+ parameters.Add("@TransactionId", TxId, DbType.Int32, ParameterDirection.Input);
|
|
|
+
|
|
|
+ string strSql = "SELECT [TransactionId],Min(Value) as MinSoC,Max(Value) as MaxSoC " +
|
|
|
+ "FROM [dbo].ConnectorMeterValueRecord" + queryDate.Date.ToString("yyMMdd") + " where TransactionId=@TransactionId and MeasurandId=20 group by [TransactionId]";
|
|
|
+
|
|
|
+ var result = await _meterDb.Database.Connection.QueryFirstOrDefaultAsync<TransactionSoCDto>(strSql, parameters);
|
|
|
+ // SOCCollection = results.Select(decimal.Parse).ToList();
|
|
|
+
|
|
|
+ if(result != null)
|
|
|
+ {
|
|
|
+
|
|
|
+ SOCCollection.Add(result.MaxSoC);
|
|
|
+ SOCCollection.Add(result.MinSoC);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return SOCCollection;
|
|
|
+ }
|
|
|
}
|
|
|
}
|