From 9e3109cbcf5ba740a9946a68c77218316147891d Mon Sep 17 00:00:00 2001 From: lxw Date: Thu, 30 May 2024 11:31:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=93=E4=BD=8D=E5=85=85=E7=94=B5=20?= =?UTF-8?q?=E6=8D=A2=E7=94=B5=E5=90=AF=E7=94=A8=E7=A6=81=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WebStarter/Controllers/BinInfoController.cs | 71 +++++++++++++++++++ .../Controllers/SwapMonitorController.cs | 49 +++++++++---- WebStarter/appsettings.json | 5 +- 3 files changed, 110 insertions(+), 15 deletions(-) create mode 100644 WebStarter/Controllers/BinInfoController.cs diff --git a/WebStarter/Controllers/BinInfoController.cs b/WebStarter/Controllers/BinInfoController.cs new file mode 100644 index 0000000..70764f5 --- /dev/null +++ b/WebStarter/Controllers/BinInfoController.cs @@ -0,0 +1,71 @@ +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; + +/// +/// 换电大屏 +/// +[ApiController] +[Route("api/[controller]")] +public class BinInfoController : ControllerBase +{ + + private readonly BinInfoRepository _BinInfoRepository; + public BinInfoController(BinInfoRepository infoRepository) + { + _BinInfoRepository = infoRepository; + } + + /// + /// 启用禁用充电 : + /// id:仓位id + /// flag :1:启用 0:禁用 + /// + /// + /// + /// + [HttpGet("UpdateCanChargeFlag/{id}/{flag}")] + public async Task> UpdateCanChargeFlag(int id, int flag) + { + BinInfo binInfo = new BinInfo() + { + Id = id, + CanChargeFlag = flag + }; + _BinInfoRepository.Update(binInfo); + return Result.Success(); + } + + + /// + /// 启用禁用换电 : + /// id:仓位id + /// flag :1:启用 0:禁用 + /// + /// + /// + /// + [HttpGet("UpdateCanSwapFlag/{id}/{flag}")] + public async Task> UpdateCanSwapFlag(int id, int flag) + { + BinInfo binInfo = new BinInfo() + { + Id = id, + CanSwapFlag = flag + }; + _BinInfoRepository.Update(binInfo); + return Result.Success(); + } + + +} \ No newline at end of file diff --git a/WebStarter/Controllers/SwapMonitorController.cs b/WebStarter/Controllers/SwapMonitorController.cs index b1549cc..ce86e3f 100644 --- a/WebStarter/Controllers/SwapMonitorController.cs +++ b/WebStarter/Controllers/SwapMonitorController.cs @@ -3,6 +3,7 @@ using Entity.Constant; using HybirdFrameworkCore.Entity; using Microsoft.AspNetCore.Mvc; using Service.Execute; +using Service.Execute.Api; using Service.Init; using Service.Plc.Client; using Service.Station; @@ -56,6 +57,38 @@ public class SwapMonitorController : ControllerBase } + /// + /// 车辆手动上锁解锁 + /// + /// + [HttpPost("LockCar")] + public async Task> LockCar() + { + if (StationSoftMgr.SwappingStateMachine.RfidReadModel == null) + { + return Result.Fail("暂无车辆"); + } + + var success = await TBoxApi.LockCarManyTimes(StationSoftMgr.SwappingStateMachine.RfidReadModel.VelNo); + return success ? Result.Success() : Result.Fail(); + } + + /// + /// 车辆手动解锁 + /// + /// + [HttpPost("UnLockCar")] + public async Task> UnLockCar() + { + if (StationSoftMgr.SwappingStateMachine.RfidReadModel == null) + { + return Result.Fail("暂无车辆"); + } + + var success = await TBoxApi.UnLockCarManyTimes(StationSoftMgr.SwappingStateMachine.RfidReadModel.VelNo); + return success ? Result.Success() : Result.Fail(); + } + /// /// 获取充电监控大屏 充电次数 每五分钟获取一次 /// @@ -77,15 +110,6 @@ public class SwapMonitorController : ControllerBase } - /// - /// 设置换电方式:1:自动换电 2:手动换电 - /// - [HttpPost("SetSwapWay/{swapWay}")] - public async Task> SetSwapWay(int stationSwapWay) - { - StaticStationInfo.StationWay = stationSwapWay; - return Result.Success(); - } /// @@ -125,7 +149,7 @@ public class SwapMonitorController : ControllerBase [HttpPost("AllLightsOff")] public async Task> AllLightsOff() { - return PlcMgr.AllLightsOff()? Result.Success(true):Result.Fail(); + return PlcMgr.AllLightsOff() ? Result.Success(true) : Result.Fail(); } /// @@ -135,8 +159,9 @@ public class SwapMonitorController : ControllerBase [HttpPost("AllLightsOn")] public async Task> AllLightsOn() { - return PlcMgr.AllLightsOn()? Result.Success(true):Result.Fail(); + return PlcMgr.AllLightsOn() ? Result.Success(true) : Result.Fail(); } + /// /// 得到现在灯光状态 /// @@ -144,7 +169,7 @@ public class SwapMonitorController : ControllerBase [HttpPost("GetNowLightsOn")] public async Task> GetNowLightsOn() { - return Result.Success(PlcMgr.GetNowLightsOn()); + return Result.Success(PlcMgr.GetNowLightsOn()); } /// diff --git a/WebStarter/appsettings.json b/WebStarter/appsettings.json index f2a419d..5f58c13 100644 --- a/WebStarter/appsettings.json +++ b/WebStarter/appsettings.json @@ -2,8 +2,7 @@ "ConnectionStrings": { "ConfigId": "master", "DbType": "MySql", - "SqlConnection": //"server=192.168.2.2;Port=3306;Database=huanneng_dev;Uid=root;Pwd=Rszn123;Charset=utf8;", - "server=127.0.0.1;Port=3306;Database=huanneng_dev;Uid=root;Pwd=anyixing2023!@#;Charset=utf8;" + "SqlConnection": "server=192.168.2.2;Port=3306;Database=huanneng_dev;Uid=root;Pwd=Rszn123;Charset=utf8;" }, "Update": { "AutoUpdate": "false", @@ -68,6 +67,6 @@ }, "HttpContextRequest": { - "Scheme": "http://192.168.2.17:5034" + "Scheme": "http://0.0.0.0:5034" } }