Эх сурвалжийг харах

1. 補上結束充電一定會統計充電量 (MeasurandId=52)
2. StopTransaction Response 無法發送 紀錄原因在Log

Jessica Tseng 1 жил өмнө
parent
commit
81f71a29b0

+ 17 - 3
EVCB_OCPP.WSServer/Message/CoreProfileHandler.cs

@@ -612,11 +612,11 @@ namespace EVCB_OCPP.WSServer.Message
                                 {
                                     var transaction = db.TransactionRecord.Where(x => x.Id == stopRequest.transactionId
                                      && x.ChargeBoxId == session.ChargeBoxId).FirstOrDefault();
-                                  
+
                                     var businessService = BusinessServiceFactory.CreateBusinessService(session.CustomerId.ToString());
                                     idTagInfo = string.IsNullOrEmpty(stopRequest.idTag) ? null : (stopRequest.idTag == "Backend" ?
                                        new IdTagInfo() { expiryDate = DateTime.UtcNow.AddDays(1), status = AuthorizationStatus.Accepted } : (await businessService.Authorize(session.ChargeBoxId, stopRequest.idTag, transaction.ConnectorId)).IdTagInfo);
-                                                               
+
 
                                     #region PnC 邏輯
                                     if (!string.IsNullOrEmpty(stopRequest.idTag))
@@ -691,8 +691,19 @@ namespace EVCB_OCPP.WSServer.Message
                                         transaction.Receipt = string.Empty;
                                         transaction.Cost = session.IsBilling ? -1 : 0;
 
-                                        if (stopRequest.transactionData != null && stopRequest.transactionData.Count > 0)
+                                        if (stopRequest.transactionData == null || stopRequest.transactionData.Count == 0)
                                         {
+                                            Console.WriteLine("1**********************");
+                                            stopRequest.transactionData = new List<MeterValue>()
+                                            {
+                                                new MeterValue() {  timestamp= stopRequest.timestamp, sampledValue=new List<SampledValue>()}
+                                            };
+
+                                        }
+
+                                        if (stopRequest.transactionData != null && stopRequest.transactionData.Count >= 0)
+                                        {
+
                                             //清除 StopTransaction TransactionData 
                                             stopRequest.transactionData[0].sampledValue.Clear();
 
@@ -706,6 +717,8 @@ namespace EVCB_OCPP.WSServer.Message
                                                 measurand = Measurand.TotalEnergy,
                                                 value = decimal.Subtract(transaction.MeterStop, transaction.MeterStart).ToString()
                                             });
+
+                                            Console.WriteLine("3**********************");
                                         }
 
                                         await db.SaveChangesAsync();
@@ -751,6 +764,7 @@ namespace EVCB_OCPP.WSServer.Message
                                 {
                                     if (stopRequest.transactionData.Count > 0)
                                     {
+                                        Console.WriteLine("4**********************");
                                         using (var _meterDb = new MeterValueDBContext())
                                         {
                                             foreach (var item in stopRequest.transactionData)

+ 1 - 1
EVCB_OCPP.WSServer/Properties/AssemblyInfo.cs

@@ -35,4 +35,4 @@ using System.Runtime.InteropServices;
 [assembly: AssemblyVersion("1.2.1.0")]
 [assembly: AssemblyFileVersion("1.2.1.0")]
 
-[assembly: AssemblyInformationalVersion("64e71ca")]
+[assembly: AssemblyInformationalVersion("e37c009")]

+ 2 - 1
EVCB_OCPP.WSServer/ProtalServer.cs

@@ -753,6 +753,7 @@ namespace EVCB_OCPP.WSServer
                                 if (action == Actions.StopTransaction && replyResult.CallErrorMsg == "Reject Response Message")
                                 {
                                     //do nothing 
+                                    logger.Warn(replyResult.Exception.ToString());
                                 }
                                 else
                                 {
@@ -1030,7 +1031,7 @@ namespace EVCB_OCPP.WSServer
                             var result = await conn.QueryAsync<string>(strSql);
 
                             GlobalConfig.DenyModelNames = result.FirstOrDefault().Split(',').ToList();
-                            logger.Debug(string.Format("Current DenyList:[{0}]", string.Join(",", GlobalConfig.DenyModelNames)));
+                          //  logger.Debug(string.Format("Current DenyList:[{0}]", string.Join(",", GlobalConfig.DenyModelNames)));
                         }