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

1.新增ChargeSystemID 欄位

Jessica Tseng 3 жил өмнө
parent
commit
3d0d12d73d

+ 33 - 30
EVCB_OCPP.WEBAPI/Models/WebAPI/Dto/EVSE.cs

@@ -1,31 +1,34 @@
-using Newtonsoft.Json;
-using Newtonsoft.Json.Converters;
-using System;
-using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
-using System.Linq;
-using System.Web;
-
-namespace EVCB_OCPP.WEBAPI.Models.WebAPI.Dto
-{
-    public class EVSE
-    {
-        [MaxLength(25)]
-        public string ChargeBoxId { set; get; }
-
-        public int StationId { set; get; }
-
-        public int RatedPower { set; get; }
-
-        public List<Connector> Connectors { set; get; }
-
-        [JsonConverter(typeof(StringEnumConverter))]
-        public Status Status { set; get; }
-
-        public GeoLocation Coordinates { set; get; }

-        public DateTime LastUpdated { set; get; }
-
-        [JsonIgnore]
-        public int NumberofConnectors { set; get; }
-    }
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Web;
+
+namespace EVCB_OCPP.WEBAPI.Models.WebAPI.Dto
+{
+    public class EVSE
+    {
+        [MaxLength(25)]
+        public string ChargeBoxId { set; get; }
+
+        public int StationId { set; get; }
+
+        public int RatedPower { set; get; }
+
+        public List<Connector> Connectors { set; get; }
+
+        [JsonConverter(typeof(StringEnumConverter))]
+        public Status Status { set; get; }
+
+        public GeoLocation Coordinates { set; get; }
+
+        public DateTime LastUpdated { set; get; }
+
+        [JsonIgnore]
+        public int NumberofConnectors { set; get; }
+
+        public string ChargeBoxSystemID { set; get; }
+    }
 }

+ 6 - 0
EVCB_OCPP.WEBAPI/Models/WebAPI/Dto/Machine.cs

@@ -64,6 +64,12 @@ namespace EVCB_OCPP.WEBAPI.Models.WebAPI.Dto
         /// </summary>      
         public string ConnectorPowerType { get; set; }
 
+        public string ChargePointSerialNumber { set; get; }
+
+        public string ChargePointModel { set; get; }
+
+        
+
 
     }
 }

+ 15 - 2
EVCB_OCPP.WEBAPI/Services/ChargePointService.cs

@@ -34,7 +34,19 @@ namespace EVCB_OCPP.WEBAPI.Services
                 parameters.Add("@MachineId", machineId, DbType.String, ParameterDirection.Input);
                 parameters.Add("@LastUpdatedTime", lastUpdatedOn, DbType.DateTime, ParameterDirection.Output);
                 conn.Execute("GetBasicInfoLastUpdatedTimeById", parameters, commandType: System.Data.CommandType.StoredProcedure);
-                lastUpdatedOn = DateTime.SpecifyKind(parameters.Get<DateTime>("@LastUpdatedTime"), DateTimeKind.Utc);
+                DateTime? time = null;
+                try
+                {
+                    time = parameters.Get<DateTime>("@LastUpdatedTime");
+
+                }
+                catch(Exception ex)
+                {
+                    time = DateTime.UtcNow;
+                }              
+              
+
+                lastUpdatedOn = DateTime.SpecifyKind(time.Value, DateTimeKind.Utc);
 
 
             }
@@ -96,11 +108,12 @@ namespace EVCB_OCPP.WEBAPI.Services
             {
                 var parameters = new DynamicParameters();
                 parameters.Add("@Id", machineId, DbType.String, ParameterDirection.Input);
-                string strSql = "Select ChargeBoxId,RatedPower,Online,OfflineOn ,GunAmt,Latitude,Longitude,ConnectorType from [dbo].[Machine] where Id=@Id and IsDelete=0; ";
+                string strSql = "Select ChargeBoxId,ChargePointSerialNumber,ChargePointModel,RatedPower,Online,OfflineOn ,GunAmt,Latitude,Longitude,ConnectorType from [dbo].[Machine] where Id=@Id and IsDelete=0; ";
                 _machine = conn.Query<Machine>(strSql, parameters).FirstOrDefault();
             }
             if (_machine != null)
             {
+                cp.ChargeBoxSystemID = _machine.ChargePointModel+_machine.ChargePointSerialNumber;
                 cp.ChargeBoxId = _machine.ChargeBoxId;
                 cp.NumberofConnectors = _machine.GunAmt;
                 cp.RatedPower = _machine.RatedPower;