From cb40c1af86a50608ac7ccac0da3f0f88af8239dc Mon Sep 17 00:00:00 2001 From: hwh <332078369@qq.com> Date: 星期一, 02 九月 2024 13:25:58 +0800 Subject: [PATCH] 添加设备、点位上的字段 --- Admin.NET/WCS.Application/Service/WcsDevice/WcsDeviceService.cs | 38 +++++++++++++++++++++++++------------- 1 files changed, 25 insertions(+), 13 deletions(-) diff --git a/Admin.NET/WCS.Application/Service/WcsDevice/WcsDeviceService.cs b/Admin.NET/WCS.Application/Service/WcsDevice/WcsDeviceService.cs index b52d4b1..9c32c01 100644 --- a/Admin.NET/WCS.Application/Service/WcsDevice/WcsDeviceService.cs +++ b/Admin.NET/WCS.Application/Service/WcsDevice/WcsDeviceService.cs @@ -41,6 +41,7 @@ { Id = u.Id, PlcId = u.PlcId, + DeviceType = (DeviceTypeEnum)u.DeviceType, PlcIdIP = plcid.IP, Level = (DeviceLevelEnum)u.Level, DbNumber = u.DbNumber, @@ -121,19 +122,6 @@ } /// <summary> - /// 鑾峰彇璁惧淇℃伅鍒楄〃 - /// </summary> - /// <param name="input"></param> - /// <returns></returns> - [HttpGet] - [ApiDescriptionSettings(Name = "List")] - [DisplayName("鑾峰彇璁惧淇℃伅鍒楄〃")] - public async Task<List<WcsDeviceOutput>> List([FromQuery] PageWcsDeviceInput input) - { - return await _wcsDeviceRep.AsQueryable().Select<WcsDeviceOutput>().ToListAsync(); - } - - /// <summary> /// 鑾峰彇PlcId鍒楄〃 /// </summary> /// <returns></returns> @@ -199,5 +187,29 @@ await _wcsDeviceRep.Context.Insertable(listPosition).ExecuteCommandAsync(); } + /// <summary> + /// 鑾峰彇璁惧淇℃伅鍒楄〃 + /// </summary> + /// <param name="input"></param> + /// <returns></returns> + [HttpGet] + [ApiDescriptionSettings(Name = "List")] + [DisplayName("鑾峰彇璁惧淇℃伅鍒楄〃")] + public async Task<List<WcsDeviceOutput>> List([FromQuery] PageWcsDeviceInput input) + { + var list = await _wcsDeviceRep.AsQueryable() + .LeftJoin<WcsPlc>((a, b) => a.PlcId == b.Id) + .Select<WcsDeviceOutput>((a, b) => new WcsDeviceOutput() { Type = b.Type }, true) + .ToListAsync(); + //鑾峰彇璺烘満鐨勭姸鎬� + var listConn = PLCTaskAction.listPlcConn; + foreach (var modDevice in list) + { + var modUtil = listConn.FirstOrDefault(s => s != null && s.PlcId == modDevice.PlcId); + modDevice.Status = modUtil == null ? false : modUtil.Connected; + } + + return list; + } } -- Gitblit v1.8.0