| | |
| | | |
| | | using Admin.NET.Core.Service; |
| | | |
| | | namespace WCS.Application; |
| | | |
| | | /// <summary> |
| | |
| | | public class WcsPlcService : IDynamicApiController, ITransient |
| | | { |
| | | private readonly SqlSugarRepository<WcsPlc> _wcsPlcRep; |
| | | public WcsPlcService(SqlSugarRepository<WcsPlc> wcsPlcRep) |
| | | private readonly SysCacheService _sysCacheService; |
| | | public WcsPlcService(SqlSugarRepository<WcsPlc> wcsPlcRep, SysCacheService sysCacheService) |
| | | { |
| | | _wcsPlcRep = wcsPlcRep; |
| | | _sysCacheService = sysCacheService; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | return await _wcsPlcRep.AsQueryable().Select<WcsPlcOutput>().ToListAsync(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取PLC连接状态和服务状态 |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | | [HttpGet] |
| | | [ApiDescriptionSettings(Name = "ListStatus")] |
| | | [DisplayName("获取PLC连接状态")] |
| | | public async Task<dynamic> ListStatus([FromQuery] PageWcsPlcInput input) |
| | | { |
| | | var listPlc = await _wcsPlcRep.AsQueryable() |
| | | .Where(s => s.Type == PLCTypeEnum.StackingMachine || s.Type == PLCTypeEnum.ConveyorLine || s.Type == PLCTypeEnum.BoxConveyorLine) |
| | | .ToListAsync(); |
| | | foreach (var modPlc in listPlc) |
| | | { |
| | | if (_sysCacheService.ExistKey("PlcConn" + modPlc.Id)) |
| | | { |
| | | var cachePlc = _sysCacheService.Get<WcsPlc>("PlcConn" + modPlc.Id); |
| | | modPlc.IsConn = cachePlc.IsConn; |
| | | } |
| | | else |
| | | { |
| | | modPlc.IsConn = false; |
| | | } |
| | | } |
| | | //服务状态 |
| | | var modService = new { PLCTaskAction.boRunningState, PLCTaskAction.boOffline, PLCTaskAction.boRefresh }; |
| | | return new { listPlc, modService }; |
| | | } |
| | | /// <summary> |
| | | /// 获取位置上有没有东西 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [HttpGet] |
| | | [ApiDescriptionSettings(Name = "ListPosition")] |
| | | [DisplayName("获取位置上有没有东西")] |
| | | public List<PlcPositionInfo> ListPosition() |
| | | { |
| | | //测试用 |
| | | //return new List<PlcPositionInfo>() |
| | | //{ |
| | | // new PlcPositionInfo(){ Type=PLCTypeEnum.ConveyorLine, StationNum="147", BoHaveItem=true }, |
| | | // new PlcPositionInfo(){ Type=PLCTypeEnum.ConveyorLine, StationNum="143", BoHaveItem=true }, |
| | | |
| | | // new PlcPositionInfo(){ Type=PLCTypeEnum.StackingMachine, StationNum="002", BoxHeight=30 }, |
| | | //}; |
| | | |
| | | |
| | | |
| | | var list = PLCTaskAction.listPositionInfo.ToList(); |
| | | return list; |
| | | } |
| | | } |