using WIDESEAWCS_BasicInfoRepository;
|
using WIDESEAWCS_Core;
|
using WIDESEAWCS_Core.BaseServices;
|
using WIDESEAWCS_ISystemServices;
|
using WIDESEAWCS_Model.Models;
|
using WIDESEAWCS_QuartzJob;
|
using WIDESEAWCS_Tasks.ConveyorLineJob;
|
|
namespace WIDESEAWCS_Tasks
|
{
|
public class GetStationService : ServiceBase<Dt_StationManager, IDt_StationManagerRepository>, IGetStationService
|
{
|
//private readonly IDt_StationManagerRepository _stationManagerRepository;
|
|
public GetStationService(IDt_StationManagerRepository BaseDal, ISys_ConfigService sys_ConfigService) : base(BaseDal)
|
{
|
}
|
|
public WebResponseContent GetStationHasPallet(List<string> stations)
|
{
|
var content = new WebResponseContent();
|
|
try
|
{
|
int palletCount = 0; // 用于记录没有托盘的站点数量
|
var stationManagers = BaseDal.QueryData(s => stations.Contains(s.stationChildCode)); // 查询相关站点管理信息
|
|
foreach (var station in stationManagers)
|
{
|
if (IsStationValid(station))
|
{
|
var hasPallet = ReadPalletStatus(station); // 获取托盘状态
|
if (hasPallet == 0) // 如果没有托盘
|
{
|
palletCount++;
|
}
|
}
|
}
|
|
content.OK(data: palletCount); // 返回结果
|
}
|
catch (Exception ex)
|
{
|
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));
|
}
|
}
|
}
|