| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEAWCS_BasicInfoRepository; |
| | | using WIDESEAWCS_BasicInfoRepository; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.BaseServices; |
| | | using WIDESEAWCS_ISystemServices; |
| | |
| | | public GetStationService(IDt_StationManagerRepository BaseDal, ISys_ConfigService sys_ConfigService) : base(BaseDal) |
| | | { |
| | | } |
| | | |
| | | public WebResponseContent GetStationHasPallet(List<string> stations) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | var content = new WebResponseContent(); |
| | | |
| | | try |
| | | { |
| | | var x = 0; |
| | | var stationManagers = BaseDal.QueryData(x => stations.Contains(x.stationChildCode)); |
| | | foreach (var item in stationManagers) |
| | | { |
| | | if (Convert.ToInt32(item.stationPLC) > 1010) |
| | | { |
| | | CommonConveyorLine_GW commonConveyorLine_GW = Storage.Devices.FirstOrDefault(x => x.DeviceCode == item.stationPLC) as CommonConveyorLine_GW; |
| | | int palletCount = 0; // 用于记录没有托盘的站点数量 |
| | | var stationManagers = BaseDal.QueryData(s => stations.Contains(s.stationChildCode)); // 查询相关站点管理信息 |
| | | |
| | | var isHasPallet = Convert.ToInt32(commonConveyorLine_GW.ReadValue(ConveyorLineDBName_After.HasPallet, item.stationChildCode)); |
| | | if (isHasPallet == 0) x++; |
| | | foreach (var station in stationManagers) |
| | | { |
| | | if (IsStationValid(station)) |
| | | { |
| | | var hasPallet = ReadPalletStatus(station); // 获取托盘状态 |
| | | if (hasPallet == 0) // 如果没有托盘 |
| | | { |
| | | palletCount++; |
| | | } |
| | | } |
| | | content.OK(data: x); |
| | | } |
| | | |
| | | content.OK(data: palletCount); // 返回结果 |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | content.Error(ex.Message); // 捕获并返回错误信息 |
| | | } |
| | | |
| | | return content; |
| | | } |
| | | |
| | | // 验证站点是否有效 |
| | | private bool IsStationValid(Dt_StationManager station) |
| | | { |
| | | return Convert.ToInt32(station.stationPLC) > 1010; |
| | | } |
| | | |
| | | // 读取托盘状态 |
| | | private int ReadPalletStatus(Dt_StationManager station) |
| | | { |
| | | var commonConveyorLine_GW = Storage.Devices.FirstOrDefault(device => device.DeviceCode == station.stationPLC) as CommonConveyorLine_GW; |
| | | return Convert.ToInt32(commonConveyorLine_GW.ReadValue(ConveyorLineDBName_After.HasPallet, station.stationChildCode)); |
| | | } |
| | | } |
| | | } |