yanjinhui
15 小时以前 52ba6b195a4126df405ef453d52ba6eaab6521da
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskMethods.cs
@@ -3,6 +3,7 @@
using NetTaste;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Net.NetworkInformation;
@@ -101,28 +102,39 @@
                                //入提升机
                                if (task.TaskType == TaskTypeEnum.RK3F.ObjToInt() && task.TaskState == (int)TaskStatusEnum.CheckPalletCodeFinish)
                                {
                                    var device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "TSJ") as OtherDevice;
                                    if (device == null) task.ExceptionMessage = "未找到提升机信息";
                                    else
                                    if (task.CurrentAddress==task.TargetAddress)
                                    {
                                        bool Work = false;
                                        if (device.IsConnected)
                                        var device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "TSJ") as OtherDevice;
                                        if (device == null) task.ExceptionMessage = "未找到提升机信息";
                                        else
                                        {
                                            int i = 0;
                                            while (!Work && i <= 3)
                                            bool Work = false;
                                            try
                                            {
                                                i++;
                                                Work = device.SetValue(HoistEnum.Inboundboxon, 1, task.TargetAddress);
                                                Thread.Sleep(500);
                                                if (device.IsConnected)
                                                {
                                                    int i = 0;
                                                    while (!Work && i <= 3)
                                                    {
                                                        i++;
                                                        Work = device.SetValue(HoistEnum.Inboundboxon, 1, task.CurrentAddress);
                                                        Thread.Sleep(500);
                                                    }
                                                }
                                                if (!Work)
                                                {
                                                    task.ExceptionMessage = $"【{task.CurrentAddress}】写入3楼入库箱放到位失败";
                                                    task.Remark = $"{device.DeviceCode}_Inboundboxon_{1}_{task.CurrentAddress}";
                                                }
                                            }
                                            catch (Exception ex)
                                            {
                                                task.ExceptionMessage = $"【{task.CurrentAddress}】写入3楼入库箱放到位失败!{ex.Message}";
                                                task.Remark = $"{device.DeviceCode}_Inboundboxon_{1}_{task.CurrentAddress}";
                                            }
                                        }
                                        if (!Work)
                                        {
                                            task.ExceptionMessage = $"【{task.TargetAddress}】写入3楼入库箱放到位失败";
                                            task.Remark = $"{device.DeviceCode}_Inboundboxon_{1}_{task.TargetAddress}";
                                        }
                                        BaseDal.UpdateData(task);
                                    }
                                    BaseDal.UpdateData(task);
                                }
                                //3 å‡ºæå‡æœº ä¹‹å‰æ˜¯AGV_ToExecute
@@ -133,21 +145,30 @@
                                    else
                                    {
                                        bool Work = false;
                                        if (device.IsConnected)
                                        try
                                        {
                                            int i = 0;
                                            while (!Work && i <= 3)
                                            if (device.IsConnected)
                                            {
                                                i++;
                                                Work = device.SetValue(HoistEnum.Outboundboxon, 1, task.SourceAddress);//出库完成
                                                Thread.Sleep(500);
                                                int i = 0;
                                                while (!Work && i <= 3)
                                                {
                                                    i++;
                                                    Work = device.SetValue(HoistEnum.Outboundboxon, 1, task.SourceAddress);//出库完成
                                                    Thread.Sleep(500);
                                                }
                                            }
                                            if (!Work)
                                            {
                                                task.ExceptionMessage = $"【{task.SourceAddress}】写入3楼出库箱放到位失败";
                                                task.Remark = $"{device.DeviceCode}_Outboundboxon_{1}_{task.SourceAddress}";
                                            }
                                        }
                                        if (!Work)
                                        catch (Exception ex)
                                        {
                                            task.ExceptionMessage = $"【{task.SourceAddress}】写入3楼出库箱放到位失败";
                                            task.Remark = $"{device.DeviceCode}_Outboundboxon_{1}_{task.SourceAddress}";
                                            task.ExceptionMessage = $"【{task.SourceAddress}】写入3楼出库箱放到位失败{ex.Message}";
                                            task.Remark = $"{device.DeviceCode}_Outboundboxon_{1}_{task.SourceAddress}"; throw;
                                        }
                                    }
                                    BaseDal.UpdateData(task);
                                }
@@ -159,21 +180,31 @@
                                    else
                                    {
                                        bool Work = false;
                                        if (device.IsConnected)
                                        try
                                        {
                                            int i = 0;
                                            while (!Work && i <= 3)
                                            if (device.IsConnected)
                                            {
                                                i++;
                                                Work = device.SetValue(HoistEnum.Emptyboxplacedinposition, 1, task.TargetAddress);
                                                Thread.Sleep(500);
                                                int i = 0;
                                                while (!Work && i <= 3)
                                                {
                                                    i++;
                                                    Work = device.SetValue(HoistEnum.Emptyboxplacedinposition, 1, task.TargetAddress);
                                                    Thread.Sleep(500);
                                                }
                                            }
                                            if (!Work)
                                            {
                                                task.ExceptionMessage = $"【{task.TargetAddress}】写入4楼空箱放到位失败";
                                                task.Remark = $"{device.DeviceCode}_Emptyboxplacedinposition_{1}_{task.TargetAddress}";
                                            }
                                        }
                                        if (!Work)
                                        catch (Exception ex)
                                        {
                                            task.ExceptionMessage = $"【{task.TargetAddress}】写入4楼空箱放到位失败";
                                            task.ExceptionMessage = $"【{task.TargetAddress}】写入4楼空箱放到位失败{ex.Message}";
                                            task.Remark = $"{device.DeviceCode}_Emptyboxplacedinposition_{1}_{task.TargetAddress}";
                                        }
                                    }
                                    BaseDal.UpdateData(task);
                                }
@@ -185,21 +216,31 @@
                                    else
                                    {
                                        bool Work = false;
                                        if (device.IsConnected)
                                        try
                                        {
                                            int i = 0;
                                            while (!Work && i <= 3)
                                            if (device.IsConnected)
                                            {
                                                i++;
                                                Work = device.SetValue(HoistEnum.Outboundboxretrievalcompleted, 1, task.SourceAddress);
                                                Thread.Sleep(500);
                                                int i = 0;
                                                while (!Work && i <= 3)
                                                {
                                                    i++;
                                                    Work = device.SetValue(HoistEnum.Outboundboxretrievalcompleted, 1, task.SourceAddress);
                                                    Thread.Sleep(500);
                                                }
                                            }
                                            if (!Work)
                                            {
                                                task.ExceptionMessage = $"【{task.SourceAddress}】写入4楼出库取箱完成失败";
                                                task.Remark = $"{device.DeviceCode}_Outboundboxretrievalcompleted_{1}_{task.SourceAddress}";
                                            }
                                        }
                                        if (!Work)
                                        catch (Exception ex)
                                        {
                                            task.ExceptionMessage = $"【{task.SourceAddress}】写入4楼出库取箱完成失败";
                                            task.ExceptionMessage = $"【{task.SourceAddress}】写入4楼出库取箱完成失败{ex.Message}";
                                            task.Remark = $"{device.DeviceCode}_Outboundboxretrievalcompleted_{1}_{task.SourceAddress}";
                                        }
                                    }
                                    BaseDal.UpdateData(task);
                                }
@@ -212,21 +253,31 @@
                                    {
                                        bool Wok = false;
                                        var Address = task.TaskType == TaskTypeEnum.Q3RK.ObjToInt() ? task.TargetAddress : task.SourceAddress;
                                        if (device.IsConnected)
                                        try
                                        {
                                            int i = 0;
                                            while (!Wok && i <= 3)
                                            if (device.IsConnected)
                                            {
                                                i++;
                                                Wok = device.SetValue(QualityInspectionCommandEnum.RequestToEnter, false, Address);
                                                Thread.Sleep(500);
                                                int i = 0;
                                                while (!Wok && i <= 3)
                                                {
                                                    i++;
                                                    Wok = device.SetValue(QualityInspectionCommandEnum.RequestToEnter, false, Address);
                                                    Thread.Sleep(500);
                                                }
                                            }
                                            if (!Wok)
                                            {
                                                task.ExceptionMessage = $"【{Address}】关闭请求进入失败!";
                                                task.Remark = $"{device.DeviceCode}_RequestToEnter_{false}_{Address}";
                                            }
                                        }
                                        if (!Wok)
                                        catch (Exception ex)
                                        {
                                            task.ExceptionMessage = $"【{Address}】关闭请求进入失败!";
                                            task.ExceptionMessage = $"【{Address}】关闭请求进入失败!{ex.Message}";
                                            task.Remark = $"{device.DeviceCode}_RequestToEnter_{false}_{Address}";
                                        }
                                    }
                                    BaseDal.UpdateData(task);
                                }
@@ -246,21 +297,31 @@
                                else
                                {
                                    bool Wok = false;
                                    if (device.IsConnected)
                                    try
                                    {
                                        int i = 0;
                                        while (!Wok && i <= 3)
                                        if (device.IsConnected)
                                        {
                                            i++;
                                            Wok = device.SetValue<HoistEnum, short>(HoistEnum.Codereadingtriggered, 1, "TSJR3F");
                                            Thread.Sleep(500);
                                            int i = 0;
                                            while (!Wok && i <= 3)
                                            {
                                                i++;
                                                Wok = device.SetValue<HoistEnum, short>(HoistEnum.Codereadingtriggered, 1, "TSJR3F");
                                                Thread.Sleep(500);
                                            }
                                        }
                                        if (!Wok)
                                        {
                                            task.ExceptionMessage = $"【TSJR3F】3楼读码触发失败!";
                                            task.Remark = $"{device.DeviceCode}_Codereadingtriggered_{1}_TSJR3F";
                                        }
                                    }
                                    if (!Wok)
                                    catch (Exception ex)
                                    {
                                        task.ExceptionMessage = $"【TSJR3F】3楼读码触发失败!";
                                        task.ExceptionMessage = $"【TSJR3F】3楼读码触发失败!{ex.Message}";
                                        task.Remark = $"{device.DeviceCode}_Codereadingtriggered_{1}_TSJR3F";
                                    }
                                }
                                task.TaskState = (int)TaskStatusEnum.CheckPalletCodeing;
                                BaseDal.UpdateData(task);
@@ -626,7 +687,7 @@
                    {
                        if (locationStatusEnum == LocationStatusEnum.Free) //如果起点完成就给货位赋值托盘号
                        {
                            stationManger.Remark = "";
                            stationManger.Remark ="";
                            stationManger.IsOccupied = LocationStatusEnum.Free.ObjToInt();
                        }
                        else