dengjunjie
6 天以前 f56f8d4bf3bf088579a169519ef2547d40586f76
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/TSJJob.cs
@@ -30,7 +30,7 @@
{
    [DisallowConcurrentExecution]
    public class TSJJob : JobBase, IJob
    {
    {
        private readonly ITaskService _taskService;
        private readonly IStationMangerService _stationMangerService;
        public TSJJob(ITaskService taskService, IStationMangerService stationMangerService)
@@ -146,7 +146,7 @@
                                    }
                                    continue;
                                }
                                if (device.GetValue<HoistEnum, short>(HoistEnum.ROutScanningCompletionSignal, task.SourceAddress) != 1)
                                {
                                    if (task.ExceptionMessage != "4楼提升机出口扫码完成信号没有完成")
@@ -172,60 +172,80 @@
                            task.ExceptionMessage = "";
                            Uptasks.Add(task);
                        }
                    }
                    #region æ‰˜ç›˜å·ç¡®è®¤ä¸­
                    //查找三楼入库任务状态为CheckPalletCodeing的任务托盘号确认中
                    var RK3FTasks = _taskService.Repository.QueryFirst(x => x.TaskType == TaskTypeEnum.RK3F.ObjToInt() && x.TaskState == (int)TaskStatusEnum.CheckPalletCodeing);
                    if (RK3FTasks != null)
                    {
                        //检查3楼入库箱号是多少,然后传给wms
                        var BinNumber = device.GetValue<HoistEnum, string>(HoistEnum.Inboxnumber, RK3FTasks.TargetAddress);
                        BinNumber = BinNumber?.TrimEnd('\0')?.Substring(2);
                        if (device.GetValue<HoistEnum, short>(HoistEnum.RInScanningCompletionSignal, RK3FTasks.TargetAddress ) !=1 )
                        {
                            RK3FTasks.ExceptionMessage = "3楼扫码完成信号没有完成";
                        }
                        else //完成就把任务状态改成托盘号确认完成
                        {
                            //根据读到的箱号进行料箱检验,检验通过就触发读码器读取,如果不通过就抛出异常
                            //var Verification = _taskService.MaterialBoxInspection(RK3FTasks.WMSTaskNum, BinNumber.ToString());
                            //if (!Verification.Status)
                            //{
                            //    if (!(RK3FTasks.ExceptionMessage == Verification.Message))
                            //    {
                            //        RK3FTasks.ExceptionMessage = Verification.Message;
                            //        Uptasks.Add(RK3FTasks);
                            //    }
                            //    //料箱验证写好后,需要更改
                            //    RK3FTasks.TargetAddress = Verification.Data.ToString();
                            //}
                            //如果料箱检验成功就写入读码器的值
                            var result = _taskService.Hikvisiontaskscontinue(RK3FTasks.WMSTaskNum, RK3FTasks.TargetAddress);
                            if (result.Status == false)
                            {
                                if (RK3FTasks.ExceptionMessage != result.Message)
                                {
                                    RK3FTasks.ExceptionMessage = result.Message;
                                    Uptasks.Add(RK3FTasks);
                                }
                            }
                            RK3FTasks.ExceptionMessage = "";
                            RK3FTasks.TaskState = (int)TaskStatusEnum.CheckPalletCodeFinish;
                        }
                        Uptasks.Add(RK3FTasks);
                    }
                    #endregion
                    if (Uptasks.Count > 0)
                    {
                        _taskService.UpdateData(Uptasks);
                    }
                    WriteInfo(device.DeviceName, "infoLog");
                    WriteDebug(device.DeviceName, "debugLog");
                    #region æ‰˜ç›˜å·ç¡®è®¤ä¸­
                    //查找三楼入库任务状态为CheckPalletCodeing的任务托盘号确认中
                    var RK3FTask = _taskService.Repository.QueryFirst(x => x.TaskType == TaskTypeEnum.RK3F.ObjToInt() && x.TaskState == (int)TaskStatusEnum.CheckPalletCodeing);
                    if (RK3FTask != null)
                    {
                        if (device.GetValue<HoistEnum, short>(HoistEnum.RInScanningCompletionSignal, RK3FTask.TargetAddress) != 1)
                        {
                            RK3FTask.ExceptionMessage = "3楼扫码完成信号没有完成";
                            _taskService.UpdateData(RK3FTask);
                        }
                        else //完成就把任务状态改成托盘号确认完成
                        {
                            //检查3楼入库箱号是多少,然后传给wms
                            var BinNumber = device.GetValue<HoistEnum, string>(HoistEnum.Inboxnumber, RK3FTask.TargetAddress);
                            if (!string.IsNullOrEmpty(BinNumber))
                            {
                                BinNumber = BinNumber.TrimEnd('\0').Substring(2);
                                //根据读到的箱号进行料箱检验,检验通过就触发读码器读取,如果不通过就抛出异常
                                var Verification = _taskService.MaterialBoxInspection(RK3FTask.WMSTaskNum, BinNumber);
                                if (!Verification.Status)
                                {
                                    if (RK3FTask.ExceptionMessage != Verification.Message)
                                    {
                                        RK3FTask.ExceptionMessage = Verification.Message;
                                        _taskService.UpdateData(RK3FTask);
                                    }
                                }
                                else
                                {
                                    RK3FTask.CurrentAddress = RK3FTask.TargetAddress;
                                    if (!string.IsNullOrEmpty(Verification.Message)) RK3FTask.TargetAddress = Verification.Message;
                                    //如果料箱检验成功就写入读码器的值
                                    var result = _taskService.Hikvisiontaskscontinue(RK3FTask.WMSTaskNum, RK3FTask.TargetAddress);
                                    if (result.Status)
                                    {
                                        RK3FTask.ExceptionMessage = "";
                                        RK3FTask.TaskState = (int)TaskStatusEnum.CheckPalletCodeFinish;
                                        _taskService.UpdateData(RK3FTask);
                                    }
                                    else
                                    {
                                        if (RK3FTask.ExceptionMessage != result.Message)
                                        {
                                            RK3FTask.ExceptionMessage = result.Message;
                                            _taskService.UpdateData(RK3FTask);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    #endregion
                    #region 4F提升机出口托盘号上报WMS
                    var Address = "TSJC4F";
                    if (device.GetValue<HoistEnum, short>(HoistEnum.ROutScanningCompletionSignal, Address) == 1)
                    {
                        var BinNumber = device.GetValue<HoistEnum, string>(HoistEnum.Emptycontainernumber, Address);
                        if (!string.IsNullOrEmpty(BinNumber))
                        {
                            BinNumber = BinNumber.TrimEnd('\0').Substring(2);
                            _taskService.InboundElevatorExit(Address, BinNumber);
                        }
                    }
                    #endregion
                    //WriteInfo(device.DeviceName, "infoLog");
                    //WriteDebug(device.DeviceName, "debugLog");
                }
                catch (Exception ex)
                {
@@ -234,7 +254,7 @@
            }
            else
            {
                WriteError(nameof(TestJob), "参数错误,未传递设备参数或设备类型错误");
                WriteError(nameof(TSJJob), "参数错误,未传递设备参数或设备类型错误");
            }