diff --git a/WebStarter/Controllers/BinInfoController.cs b/WebStarter/Controllers/BinInfoController.cs index 6ab334c..d14b1a8 100644 --- a/WebStarter/Controllers/BinInfoController.cs +++ b/WebStarter/Controllers/BinInfoController.cs @@ -1,14 +1,8 @@ -using Entity.Api.Resp; -using Entity.Constant; using Entity.DbModel.Station; using HybirdFrameworkCore.Entity; using Microsoft.AspNetCore.Mvc; using Repository.Station; -using Service.Execute; -using Service.Execute.Api; -using Service.Init; using Service.Plc.Client; -using Service.Station; namespace WebStarter.Controllers; @@ -20,7 +14,7 @@ namespace WebStarter.Controllers; public class BinInfoController : ControllerBase { private readonly BinInfoRepository _BinInfoRepository; - + private readonly EquipInfoRepository _equipInfoRepository; public BinInfoController(BinInfoRepository infoRepository,EquipInfoRepository equipInfoRepository) @@ -82,7 +76,7 @@ public class BinInfoController : ControllerBase { return PlcMgr.AirBlowerControl(cmd) ? Result.Success() : Result.Fail(); } - + /// /// 查询风机状态 /// 0:无状态 @@ -95,7 +89,7 @@ public class BinInfoController : ControllerBase { return Result.Success(PlcMgr.BlowerStatus()); } - + /// /// 获取仓位充电功率 /// @@ -104,8 +98,16 @@ public class BinInfoController : ControllerBase [HttpGet("ChargePower/{code}")] public Result ChargePower(string code) { - string _code = _BinInfoRepository.QueryByClause(i => i.Code == code).ChargerNo; - EquipInfo equipInfo = _equipInfoRepository.QueryByClause(i => i.Code == _code); + BinInfo binInfo = _BinInfoRepository.QueryByClause(it => it.No == code); + if (binInfo == null) + { + return Result.Fail("仓位不存在"); + } + EquipInfo equipInfo = _equipInfoRepository.QueryByClause(i => i.Code == binInfo.ChargerNo); + if (equipInfo == null) + { + return Result.Fail("充电机不存在"); + } float? chargePower = equipInfo.ChargePower; if (chargePower == null) @@ -116,4 +118,5 @@ public class BinInfoController : ControllerBase return Result.Success((float)chargePower); } -} \ No newline at end of file +} +