| | |
| | | |
| | | using Admin.NET.Core.Service; |
| | | |
| | | namespace WCS.Application; |
| | | |
| | | /// <summary> |
| | |
| | | public class WcsDeviceService : IDynamicApiController, ITransient |
| | | { |
| | | private readonly SqlSugarRepository<WcsDevice> _wcsDeviceRep; |
| | | public WcsDeviceService(SqlSugarRepository<WcsDevice> wcsDeviceRep) |
| | | private readonly SysCacheService _sysCacheService; |
| | | public WcsDeviceService(SqlSugarRepository<WcsDevice> wcsDeviceRep, SysCacheService sysCacheService) |
| | | { |
| | | _wcsDeviceRep = wcsDeviceRep; |
| | | _sysCacheService = sysCacheService; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | .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; |
| | | if (_sysCacheService.ExistKey("PlcConn" + modDevice.PlcId)) |
| | | { |
| | | var cachePlc = _sysCacheService.Get<WcsPlc>("PlcConn" + modDevice.PlcId); |
| | | modDevice.Status = cachePlc.IsConn; |
| | | } |
| | | |
| | | else |
| | | { |
| | | modDevice.Status = false; |
| | | } |
| | | } |
| | | |
| | | return list; |
| | | } |