wangxinhui
3 天以前 a0a0df2e824b6fe7e5a3c0afce78127fecf84fc9
ÏîÄ¿´úÂë/WCS/WCSServices/WIDESEAWCS_Tasks/èì¼Ü/TrussCartonJob.cs
@@ -62,39 +62,46 @@
        public Task Execute(IJobExecutionContext context)
        {
            bool flag = context.JobDetail.JobDataMap.TryGetValue("JobParams", out object? value);
            if (flag && value != null)
            try
            {
                OtherDevice device = (OtherDevice)value;
                List<Dt_StationManger> stationMangers = _stationMangerRepository.QueryData(x => x.StationDeviceCode == device.DeviceCode);
                //获取协议
                DeviceProDTO? deviceProRead = device.DeviceProDTOs.Where(x => x.DeviceChildCode == device.DeviceCode && x.DeviceProParamType == nameof(R_TrussCartonDB)).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
                DeviceProDTO? deviceProWrite = device.DeviceProDTOs.Where(x => x.DeviceChildCode == device.DeviceCode && x.DeviceProParamType == nameof(W_TrussCartonDB)).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
                //判断协议是否满足
                if (deviceProRead!=null && deviceProWrite!=null)
                bool flag = context.JobDetail.JobDataMap.TryGetValue("JobParams", out object? value);
                if (flag && value != null)
                {
                    foreach (var item in stationMangers)
                    OtherDevice device = (OtherDevice)value;
                    List<Dt_StationManger> stationMangers = _stationMangerRepository.QueryData(x => x.StationDeviceCode == device.DeviceCode);
                    //获取协议
                    DeviceProDTO? deviceProRead = device.DeviceProDTOs.Where(x => x.DeviceChildCode == device.DeviceCode && x.DeviceProParamType == nameof(R_TrussCartonDB)).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
                    DeviceProDTO? deviceProWrite = device.DeviceProDTOs.Where(x => x.DeviceChildCode == device.DeviceCode && x.DeviceProParamType == nameof(W_TrussCartonDB)).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
                    //判断协议是否满足
                    if (deviceProRead != null && deviceProWrite != null)
                    {
                        //码垛状态
                        bool Call = device.GetValue<R_TrussCartonDB, bool>(GetCartonCall(item.StackerCraneStationCode), item.StackerCraneCode);
                        if (Call && item.IsOccupied == 0)
                        device.SetValue(W_TrussCartonDB.W_CartonHeart, false, device.DeviceCode);
                        //写入心跳
                        foreach (var item in stationMangers)
                        {
                            //请求WMS叫料任务
                            //码垛状态
                            bool Call = device.GetValue<R_TrussCartonDB, bool>(GetCartonCall(item.StackerCraneStationCode), item.StackerCraneCode);
                            if (Call && item.IsOccupied == 0)
                            {
                                //请求WMS叫料任务
                            }
                            else if (Call && item.IsOccupied == 1)
                            {
                                //请求WMS空托叠盘任务
                            }
                        }
                        else if (Call && item.IsOccupied==1)
                        {
                            //请求WMS空托叠盘任务
                        }
                        device.SetValue(W_TrussCartonDB.W_CartonHeart, true, device.DeviceCode);
                    }
                    else
                    {
                        WriteError(device.DeviceCode, $"未找到设备编号{device.DeviceCode}的协议信息");
                    }
                }
                else
                {
                    WriteError(device.DeviceCode, $"未找到设备编号{device.DeviceCode}的协议信息");
                }
            }
            catch (Exception ex)
            {
                WriteError(nameof(TrussCartonJob),ex.Message);
            }
            return Task.CompletedTask;
        }