diff --git a/Service/Mgr/SysFileMgr.cs b/Service/Mgr/SysFileMgr.cs index a5e5664..4b10475 100644 --- a/Service/Mgr/SysFileMgr.cs +++ b/Service/Mgr/SysFileMgr.cs @@ -6,7 +6,9 @@ using Entity.DbModel.System; using HybirdFrameworkCore.Autofac.Attribute; using HybirdFrameworkCore.Configuration; using Microsoft.AspNetCore.Http; +using Npgsql.TypeHandlers; using Repository.System; +using Yitter.IdGenerator; namespace Service.Mgr { @@ -49,7 +51,7 @@ namespace Service.Mgr // 判断是否重复上传的文件 var sizeKb = (long)(file.Length / 1024.0); // 大小KB - var fileMd5 = string.Empty; + var fileMd5 = string.Empty; if (_uploadOptions.EnableMd5) { using (var fileStream = file.OpenReadStream()) @@ -86,11 +88,12 @@ namespace Service.Mgr throw new ArgumentException($"文件超过允许大小"); // 获取文件后缀 var suffix = Path.GetExtension(file.FileName).ToLower(); // 后缀 + suffix ="."+ file.ContentType.Split("/")[1]; if (string.IsNullOrWhiteSpace(suffix)) throw new ArgumentException($"文件后缀错误"); var newFile = new SysFile { - //Id = YitIdHelper.NextId(), + Id = DateTime.Now.Millisecond, FileName = Path.GetFileNameWithoutExtension(file.FileName), Suffix = suffix, diff --git a/Service/Station/MonitorService.cs b/Service/Station/MonitorService.cs index ba00688..bba4867 100644 --- a/Service/Station/MonitorService.cs +++ b/Service/Station/MonitorService.cs @@ -21,12 +21,12 @@ namespace Service.Station; [Scope("SingleInstance")] public class MonitorService { - private static readonly ILog Log = LogManager.GetLogger(typeof(MonitorService)); public BinInfoRepository BinInfoRepository { get; set; } public SwapOrderRepository SwapOrderRepository { get; set; } public ChargeOrderRepository ChargeOrderRepository { get; set; } public PlcTaskMgr PlcTaskMgr { get; set; } + public Result GetSwapMonitorData() { var configBinInfo = @@ -102,14 +102,14 @@ public class MonitorService /// 连接状态类 /// /// - public Result GetDeviceState() + public async Task> GetDeviceState() { - var isConnected = TBoxApi.IsConnected(); + var isConnected = await TBoxApi.IsConnected(); DeviceStateResp resp = new() { - BoxConnectFlag = isConnected.Result != null ? isConnected.Result : false, - CloudConnectFlag = CloudClientMgr.CloudClient.Connected, - PlcConnectFlag = PlcMgr.PlcClient.Connected + BoxConnectFlag = isConnected != null ? isConnected : false, + CloudConnectFlag = CloudClientMgr.CloudClient==null? false:CloudClientMgr.CloudClient.Connected, + PlcConnectFlag = PlcMgr.PlcClient==null? false:PlcMgr.PlcClient.Connected }; return Result.Success(resp); @@ -175,9 +175,9 @@ public class MonitorService result = PlcMgr.HoldOn(); if (!result) { - return Result.Fail(); } + Log.Info($"battery move task Manual removeBinNo={removeBinNo}, putBinNo={putBinNo} "); var queryPlcTask = PlcTaskMgr.QueryPlcTask(2, 1200, 1201); @@ -206,8 +206,8 @@ public class MonitorService removeBin.Soh = -1; BinInfoRepository.Update(removeBin); } - return Result.Success(); + return Result.Success(); return Result.Success(); diff --git a/WebStarter/Controllers/SwapMonitorController.cs b/WebStarter/Controllers/SwapMonitorController.cs index 7102d55..5b2e0b2 100644 --- a/WebStarter/Controllers/SwapMonitorController.cs +++ b/WebStarter/Controllers/SwapMonitorController.cs @@ -34,7 +34,7 @@ public class SwapMonitorController : ControllerBase [HttpPost("GetDeviceState")] public async Task> GetDeviceState() { - return _swapMonitorService.GetDeviceState(); + return await _swapMonitorService.GetDeviceState(); } ///