Browse Source

fix api "station"

Robert 1 year ago
parent
commit
9f853f989b
1 changed files with 4 additions and 3 deletions
  1. 4 3
      EVCB_OCPP.WEBAPI/Services/ChargePointService.cs

+ 4 - 3
EVCB_OCPP.WEBAPI/Services/ChargePointService.cs

@@ -216,8 +216,9 @@ namespace EVCB_OCPP.WEBAPI.Services
                 var result = await conn.QueryAsync<Machine>(strSql, parameters);
                 _machines = result.ToDictionary(x => x.Id, x => x);
             }
+            var chargeBoxIds = _machines.Values.Select(x => x.ChargeBoxId);
 
-            var MachineConnectors = await GetConnectorStatusAsync(machineIds);
+            var MachineConnectors = await GetConnectorStatusAsync(chargeBoxIds);
 
             foreach (var machineId in machineIds)
             {
@@ -227,7 +228,7 @@ namespace EVCB_OCPP.WEBAPI.Services
                     continue;
                 }
 
-                var _machine = _machines[machineId];
+                Machine _machine = _machines[machineId];
                 EVSE cp = new();
 
                 cp.ChargeBoxSystemID = _machine.ChargePointModel + _machine.ChargePointSerialNumber;
@@ -239,7 +240,7 @@ namespace EVCB_OCPP.WEBAPI.Services
                 cp.Coordinates = new GeoLocation() { Latitude = _machine.Latitude, Longitude = _machine.Longitude };
                 cp.Connectors = new List<Connector>();
                 //var _Connectors = await GetConnectorStatusAsync(_machine.ChargeBoxId);
-                var _Connectors = MachineConnectors[machineId];
+                var _Connectors = MachineConnectors[_machine.ChargeBoxId];
                 for (int i = 1; i <= _machine.GunAmt; i++)
                 {
                     var _RefConnector = _Connectors.Where(x => x.ConnectorId == i).FirstOrDefault();