Browse Source

1.是否上報StopTransaction給客戶標準 InstantStopTxReport=0

Jessica Tseng 3 years ago
parent
commit
d38590ce79

+ 1 - 1
EVCB_OCPP.TaskScheduler/Jobs/StopTransacionReportJob.cs

@@ -27,7 +27,7 @@ namespace EVCB_OCPP.TaskScheduler.Jobs
             List<Task> tList = new List<Task>();
 
             ICustomerService cs = new CommonCustomerService();
-            var cList = cs.GetCallPartnerCustomers();
+            var cList = cs.GetNotifyStopTransactionCustomers();
 
             foreach (var customerId in cList)
             {

+ 9 - 2
EVCB_OCPP.TaskScheduler/Services/CommonCustomerService.cs

@@ -44,6 +44,11 @@ namespace EVCB_OCPP.TaskScheduler.Services
             return _dbService.GetCallParterAPICustomers();
         }
 
+        public List<Guid> GetNotifyStopTransactionCustomers()
+        {
+            return _dbService.GetNotifyStopTransactionCustomers();
+        }
+
 
 
 
@@ -114,7 +119,8 @@ namespace EVCB_OCPP.TaskScheduler.Services
                                 SessionId = r.Id,
                                 MeterStart = r.MeterStart,
                                 IdTag = r.StartIdTag,
-                                StartTime = r.StartTime.ToString(DefaultSetting.UTC_DATETIMEFORMAT)
+                                StartTime = r.StartTime.ToString(DefaultSetting.UTC_DATETIMEFORMAT),
+                                ReservationId = r.ReservationId
                             };
 
                             var response = await httpClient.Post(_partnerAPIRoot + "start_session", new Dictionary<string, string>()
@@ -164,7 +170,8 @@ namespace EVCB_OCPP.TaskScheduler.Services
         }
 
         async public Task ReportStopTransaction()
-        {
+        {         
+            
             var items = _dbService.GetNeedReportSession(customerId, false, 1000);
 
             Stopwatch watch = new Stopwatch();

+ 21 - 1
EVCB_OCPP.TaskScheduler/Services/DatabaseService.cs

@@ -107,6 +107,26 @@ namespace EVCB_OCPP.TaskScheduler.Services
             return result;
         }
 
+        internal List<Guid> GetNotifyStopTransactionCustomers()
+        {
+            List<Guid> result = new List<Guid>();
+            try
+            {
+                using (var dbConn = new SqlConnection(mainDBConnectString))
+                {
+                    dbConn.Open();
+                    result = dbConn.Query<Guid>("SELECT Id FROM [dbo].[Customer] where CallPartnerApiOnSchedule=1 and InstantStopTxReport=0").ToList();
+                }
+
+            }
+            catch (Exception ex)
+            {
+                logger.Error("Query Data Error " + ex.ToString());
+            }
+
+            return result;
+        }
+
 
         internal List<Transaction> GetNeedReportSession(Guid customerId, bool isgoing, int size)
         {
@@ -129,7 +149,7 @@ namespace EVCB_OCPP.TaskScheduler.Services
                     {
                         if (customerId == new Guid("009E603C-79CD-4620-A2B8-D9349C0E8AD8"))
                         {
-                            sqlString = "SELECT Top(" + size + ") Id,ChargeBoxId,ConnectorId,StartTime,StopTime,MeterStart,MeterStop,StartIdTag ,StopReasonId,Receipt,Cost,Fee FROM [dbo].[TransactionRecord] where CustomerId=@CustomerId and StopTime!='1991/1/1' and StopTransactionReportedOn='1991/1/1' and  UploadedtoTTIA=1";
+                            sqlString = "SELECT Top(" + size + ") Id,ChargeBoxId,ConnectorId,StartTime,StopTime,MeterStart,MeterStop,StartIdTag ,StopReasonId,Receipt,Cost,Fee FROM [dbo].[TransactionRecord] where CustomerId=@CustomerId and StopTime!='1991/1/1' and StopTransactionReportedOn='1991/1/1' and  BillingDone=1";
                         }
                         else
                         {

+ 2 - 0
EVCB_OCPP.TaskScheduler/Services/ICustomerService.cs

@@ -8,6 +8,8 @@ namespace EVCB_OCPP.TaskScheduler.Services
 {
     public interface ICustomerService
     {
+        List<Guid> GetNotifyStopTransactionCustomers();     
+        
         List<Guid> GetCallPartnerCustomers();
 
         Task ReportStartTransaction();