1
huangxiaoqiang
2 天以前 2190be42c0d77be84fed82d387f2a34da7fe4acc
ÏîÄ¿´úÂë/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Service/DeviceInfoService.cs
@@ -22,8 +22,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Common.Log;
using WIDESEAWCS_BasicInfoRepository;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.BaseRepository;
@@ -73,6 +75,7 @@
        public WebResponseContent StackerHandTask(HandTask stackerhand)
        {
            WriteLog.GetLog("堆垛机手动任务").Write(JsonConvert.SerializeObject(stackerhand), "堆垛机手动任务");
            WebResponseContent content = new WebResponseContent();
            try
            {
@@ -90,8 +93,8 @@
                    if (sourceCodes.Length == 3)
                    {
                        stackerCraneTaskCommand.StartRow = (byte)Convert.ToSByte(GetRowCode(Convert.ToInt32(sourceCodes[0])));
                        stackerCraneTaskCommand.StartColumn = (byte)Convert.ToSByte(sourceCodes[1]);
                        stackerCraneTaskCommand.StartLayer = (byte)Convert.ToSByte(sourceCodes[2]);
                        stackerCraneTaskCommand.StartColumn = (byte)Convert.ToSByte(sourceCodes[2]);
                        stackerCraneTaskCommand.StartLayer = (byte)Convert.ToSByte(sourceCodes[1]);
                    }
                    else
                    {
@@ -102,8 +105,8 @@
                    if (targetCodes.Length == 3)
                    {
                        stackerCraneTaskCommand.EndRow = (byte)Convert.ToSByte(GetRowCode(Convert.ToInt32(targetCodes[0])));
                        stackerCraneTaskCommand.EndColumn = (byte)Convert.ToSByte(targetCodes[1]);
                        stackerCraneTaskCommand.EndLayer = (byte)Convert.ToSByte(targetCodes[2]);
                        stackerCraneTaskCommand.EndColumn = (byte)Convert.ToSByte(targetCodes[2]);
                        stackerCraneTaskCommand.EndLayer = (byte)Convert.ToSByte(targetCodes[1]);
                    }
                    else
                    {
@@ -117,8 +120,8 @@
                    if (sourceCodes.Length == 3)
                    {
                        stackerCraneTaskCommand.StartRow = (byte)Convert.ToSByte(GetRowCode(Convert.ToInt32(sourceCodes[0])));
                        stackerCraneTaskCommand.StartColumn = (byte)Convert.ToSByte(sourceCodes[1]);
                        stackerCraneTaskCommand.StartLayer = (byte)Convert.ToSByte(sourceCodes[2]);
                        stackerCraneTaskCommand.StartColumn = (byte)Convert.ToSByte(sourceCodes[2]);
                        stackerCraneTaskCommand.StartLayer = (byte)Convert.ToSByte(sourceCodes[1]);
                    }
                    else
                    {
@@ -128,8 +131,8 @@
                    if (targetCodes.Length == 3)
                    {
                        stackerCraneTaskCommand.EndRow = (byte)Convert.ToSByte(GetRowCode(Convert.ToInt32(targetCodes[0])));
                        stackerCraneTaskCommand.EndColumn = (byte)Convert.ToSByte(targetCodes[1]);
                        stackerCraneTaskCommand.EndLayer = (byte)Convert.ToSByte(targetCodes[2]);
                        stackerCraneTaskCommand.EndColumn = (byte)Convert.ToSByte(targetCodes[2]);
                        stackerCraneTaskCommand.EndLayer = (byte)Convert.ToSByte(targetCodes[1]);
                    }
                    else
                    {
@@ -143,8 +146,8 @@
                    if (sourceCodes.Length == 3)
                    {
                        stackerCraneTaskCommand.StartRow = (byte)Convert.ToSByte(GetRowCode(Convert.ToInt32(sourceCodes[0])));
                        stackerCraneTaskCommand.StartColumn = (byte)Convert.ToSByte(sourceCodes[1]);
                        stackerCraneTaskCommand.StartLayer = (byte)Convert.ToSByte(sourceCodes[2]);
                        stackerCraneTaskCommand.StartColumn = (byte)Convert.ToSByte(sourceCodes[2]);
                        stackerCraneTaskCommand.StartLayer = (byte)Convert.ToSByte(sourceCodes[1]);
                    }
                    else
                    {
@@ -155,8 +158,8 @@
                    if (targetCodes.Length == 3)
                    {
                        stackerCraneTaskCommand.EndRow = (byte)Convert.ToSByte(GetRowCode(Convert.ToInt32(targetCodes[0])));
                        stackerCraneTaskCommand.EndColumn = (byte)Convert.ToSByte(targetCodes[1]);
                        stackerCraneTaskCommand.EndLayer = (byte)Convert.ToSByte(targetCodes[2]);
                        stackerCraneTaskCommand.EndColumn = (byte)Convert.ToSByte(targetCodes[2]);
                        stackerCraneTaskCommand.EndLayer = (byte)Convert.ToSByte(targetCodes[1]);
                    }
                    else
                    {
@@ -170,8 +173,8 @@
                    if (sourceCodes.Length == 3)
                    {
                        stackerCraneTaskCommand.StartRow = (byte)Convert.ToSByte(GetRowCode(Convert.ToInt32(sourceCodes[0])));
                        stackerCraneTaskCommand.StartColumn = (byte)Convert.ToSByte(sourceCodes[1]);
                        stackerCraneTaskCommand.StartLayer = (byte)Convert.ToSByte(sourceCodes[2]);
                        stackerCraneTaskCommand.StartColumn = (byte)Convert.ToSByte(sourceCodes[2]);
                        stackerCraneTaskCommand.StartLayer = (byte)Convert.ToSByte(sourceCodes[1]);
                        stackerCraneTaskCommand.EndRow = (byte)Convert.ToSByte(0);
                        stackerCraneTaskCommand.EndColumn = (byte)Convert.ToSByte(0);
@@ -193,8 +196,8 @@
                        stackerCraneTaskCommand.StartLayer = (byte)Convert.ToSByte(0);
                        stackerCraneTaskCommand.EndRow = (byte)Convert.ToSByte(GetRowCode(Convert.ToInt32(targetCodes[0])));
                        stackerCraneTaskCommand.EndColumn = (byte)Convert.ToSByte(targetCodes[1]);
                        stackerCraneTaskCommand.EndLayer = (byte)Convert.ToSByte(targetCodes[2]);
                        stackerCraneTaskCommand.EndColumn = (byte)Convert.ToSByte(targetCodes[2]);
                        stackerCraneTaskCommand.EndLayer = (byte)Convert.ToSByte(targetCodes[1]);
                    }
                    else
                    {
@@ -205,8 +208,10 @@
                {
                    return content.Error("未找到任务命令");
                }
                StackerSendCommand(stackerCraneTaskCommand, stackerhand.DeviceCode);
                return content;
                return content.OK("命令下发成功!");
            }
            catch (Exception ex)
            {
@@ -216,6 +221,7 @@
        public WebResponseContent StackerReset(string DeviceCode)
        {
            WriteLog.GetLog("堆垛机手动任务").Write($"【复位命令】{JsonConvert.SerializeObject(DeviceCode)}", "堆垛机手动任务");
            WebResponseContent content = new WebResponseContent();
            try
            {
@@ -225,7 +231,7 @@
                {
                    CommonStackerCrane commonStackerCrane = (CommonStackerCrane)device;
                    commonStackerCrane.SetValue(StackerCraneDBName.TaskType, Convert.ToSByte(2));
                    commonStackerCrane.SetValue(StackerCraneDBName.WorkType, Convert.ToSByte(2));
                    return content.OK();
                }
                else
@@ -241,6 +247,7 @@
        public WebResponseContent StackerEmergencyStop(string DeviceCode)
        {
            WriteLog.GetLog("堆垛机手动任务").Write($"【急停命令】{JsonConvert.SerializeObject(DeviceCode)}", "堆垛机手动任务");
            WebResponseContent content = new WebResponseContent();
            try
            {
@@ -250,7 +257,7 @@
                {
                    CommonStackerCrane commonStackerCrane = (CommonStackerCrane)device;
                    commonStackerCrane.SetValue(StackerCraneDBName.TaskType, Convert.ToSByte(2));
                    commonStackerCrane.SetValue(StackerCraneDBName.WorkType, Convert.ToSByte(2));
                    return content.OK();
                }
                else
@@ -282,7 +289,7 @@
                    commonStackerCrane.SetValue(StackerCraneDBName.StartColumn, command.StartColumn);
                    Thread.Sleep(100);
                    commonStackerCrane.SetValue(StackerCraneDBName.StartColumn, command.StartLayer);
                    commonStackerCrane.SetValue(StackerCraneDBName.StartLayer, command.StartLayer);
                    Thread.Sleep(100);
                    commonStackerCrane.SetValue(StackerCraneDBName.EndRow, command.EndRow);
@@ -292,11 +299,11 @@
                    Thread.Sleep(100);
                    commonStackerCrane.SetValue(StackerCraneDBName.EndLayer, command.EndLayer);
                    Thread.Sleep(100);
                    commonStackerCrane.SetValue(StackerCraneDBName.TaskType, Convert.ToSByte(command.WorkType));
                    commonStackerCrane.SetValue(StackerCraneDBName.WorkType, Convert.ToSByte(command.WorkType));
                }
                else
                {
                    throw new Exception("请在堆垛机联机模式、待机状态、无故障的情况下下发任务");
                    throw new Exception($"请在{commonStackerCrane.DeviceName}联机模式、待机状态、无故障的情况下下发任务");
                }
            }
            else
@@ -540,6 +547,7 @@
        public WebResponseContent ConveyorLineHandTask(HandTask ConveyorLinehand)
        {
            WriteLog.GetLog("输送线手动任务").Write(JsonConvert.SerializeObject(ConveyorLinehand), "输送线手动任务");
            WebResponseContent content = new WebResponseContent();
            try
            {
@@ -554,6 +562,12 @@
                    if (device != null)
                    {
                        CommonConveyorLine conveyorLine = (CommonConveyorLine)device;
                        short x = conveyorLine.GetValue<ConveyorLineDBName, short>(ConveyorLineDBName.InteractiveSignal, stationManager.stationChildCode);
                        var structs = BitConverter.GetBytes(x).ToArray().ToBoolArray();
                        if (!structs[2])
                        {
                            return content.Error($"请在{stationManager.stationChildCode}输送线就绪情况下下发命令");
                        }
                        //入库
                        if (ConveyorLinehand.TaskType == "1")
                        {
@@ -590,6 +604,7 @@
        public WebResponseContent ConveyorLineReset(string DeviceChildCode)
        {
            WriteLog.GetLog("输送线手动任务").Write($"【复位命令】{JsonConvert.SerializeObject(DeviceChildCode)}", "输送线手动任务");
            WebResponseContent content = new WebResponseContent();
            try
            {
@@ -614,6 +629,7 @@
        public WebResponseContent ConveyorLineEmergencyStop(string DeviceChildCode)
        {
            WriteLog.GetLog("输送线手动任务").Write($"【急停命令】{JsonConvert.SerializeObject(DeviceChildCode)}", "输送线手动任务");
            WebResponseContent content = new WebResponseContent();
            try
            {
@@ -637,6 +653,7 @@
        }
        public WebResponseContent ConveyorLineReturn(string DeviceChildCode)
        {
            WriteLog.GetLog("输送线手动任务").Write($"【退回命令】{JsonConvert.SerializeObject(DeviceChildCode)}", "输送线手动任务");
            WebResponseContent content = new WebResponseContent();
            try
            {
@@ -660,6 +677,7 @@
        }
        public WebResponseContent ConveyorLineCancel(string DeviceChildCode)
        {
            WriteLog.GetLog("输送线手动任务").Write($"【取消命令】{JsonConvert.SerializeObject(DeviceChildCode)}", "输送线手动任务");
            WebResponseContent content = new WebResponseContent();
            try
            {
@@ -683,6 +701,7 @@
        }
        public WebResponseContent ConveyorLineInitialize(string DeviceChildCode)
        {
            WriteLog.GetLog("输送线手动任务").Write($"【初始化命令】{JsonConvert.SerializeObject(DeviceChildCode)}", "输送线手动任务");
            WebResponseContent content = new WebResponseContent();
            try
            {
@@ -723,6 +742,7 @@
            13 => "预留4",
            14 => "预留5",
            15 => "预留6",
            _ => $"未知报警({Alarm})"
        };
        public enum ConveyorLineDBName
@@ -750,6 +770,7 @@
        #region  RGV手动命令
        public WebResponseContent RGVHandTask(HandTask RGVhand)
        {
            WriteLog.GetLog("RGV手动任务").Write(JsonConvert.SerializeObject(RGVhand), "RGV手动任务");
            WebResponseContent content = new WebResponseContent();
            try
            {
@@ -763,227 +784,241 @@
                    if (RGVhand.DeviceCode == "RGV01" || RGVhand.DeviceCode == "RGV02")
                    {
                        CommonRGV_FirstFloor RGVcommand = (CommonRGV_FirstFloor)device;
                        if (RGVhand.TaskType == "1")
                        if (RGVcommand.GetValue<RGVDBName, bool>(RGVDBName.Automatic) && !RGVcommand.GetValue<RGVDBName, bool>(RGVDBName.Fault) && !RGVcommand.GetValue<RGVDBName, bool>(RGVDBName.Running))
                        {
                            if (RGVhand.SourceAddress != null)
                            if (RGVhand.TaskType == "1")
                            {
                                RGVTaskCommand command = new RGVTaskCommand()
                                if (RGVhand.SourceAddress != null)
                                {
                                    PickupLocation = (byte)Convert.ToSByte(RGVhand.SourceAddress),
                                    TaskType = (byte)Convert.ToSByte(RGVhand.TaskType),
                                };
                                SendCommandFirstFloor(RGVcommand, command);
                                return content.OK($"{device.DeviceName}取定位命令下发成功");
                            }
                            else
                            {
                                return content.Error($"{device.DeviceName}取定位命令取货位不能为空");
                            }
                                    RGVTaskCommand command = new RGVTaskCommand()
                                    {
                                        PickupLocation = (byte)Convert.ToSByte(RGVhand.SourceAddress),
                                        TaskType = (byte)Convert.ToSByte(RGVhand.TaskType),
                                    };
                                    SendCommandFirstFloor(RGVcommand, command);
                                    return content.OK($"{device.DeviceName}取定位命令下发成功");
                                }
                                else
                                {
                                    return content.Error($"{device.DeviceName}取定位命令取货位不能为空");
                                }
                        }
                        else if (RGVhand.TaskType == "2")
                        {
                            if (RGVhand.TargetAddress != null)
                            }
                            else if (RGVhand.TaskType == "2")
                            {
                                RGVTaskCommand command = new RGVTaskCommand()
                                if (RGVhand.TargetAddress != null)
                                {
                                    PutcargoLocation = (byte)Convert.ToSByte(RGVhand.TargetAddress),
                                    TaskType = (byte)Convert.ToSByte(RGVhand.TaskType),
                                };
                                SendCommandFirstFloor(RGVcommand, command);
                                return content.OK($"{device.DeviceName}放定位命令下发成功");
                                    RGVTaskCommand command = new RGVTaskCommand()
                                    {
                                        PutcargoLocation = (byte)Convert.ToSByte(RGVhand.TargetAddress),
                                        TaskType = (byte)Convert.ToSByte(RGVhand.TaskType),
                                    };
                                    SendCommandFirstFloor(RGVcommand, command);
                                    return content.OK($"{device.DeviceName}放定位命令下发成功");
                                }
                                else
                                {
                                    return content.Error($"{device.DeviceName}放定位命令放货位不能为空");
                                }
                            }
                            else if (RGVhand.TaskType == "3")
                            {
                                if (RGVhand.SourceAddress != null)
                                {
                                    RGVTaskCommand command = new RGVTaskCommand()
                                    {
                                        PickupLocation = (byte)Convert.ToSByte(RGVhand.SourceAddress),
                                        TaskType = (byte)Convert.ToSByte(RGVhand.TaskType),
                                    };
                                    SendCommandFirstFloor(RGVcommand, command);
                                    return content.OK($"{device.DeviceName}取货命令下发成功");
                                }
                                else
                                {
                                    return content.Error($"{device.DeviceName}取货命令取货位不能为空");
                                }
                            }
                            else if (RGVhand.TaskType == "4")
                            {
                                if (RGVhand.TargetAddress != null)
                                {
                                    RGVTaskCommand command = new RGVTaskCommand()
                                    {
                                        PutcargoLocation = (byte)Convert.ToSByte(RGVhand.TargetAddress),
                                        TaskType = (byte)Convert.ToSByte(RGVhand.TaskType),
                                    };
                                    SendCommandFirstFloor(RGVcommand, command);
                                    return content.OK($"{device.DeviceName}放货命令下发成功");
                                }
                                else
                                {
                                    return content.Error($"{device.DeviceName}放货命令放货位不能为空");
                                }
                            }
                            else if (RGVhand.TaskType == "5")
                            {
                                if (RGVhand.TargetAddress != null && RGVhand.TargetAddress != null)
                                {
                                    RGVTaskCommand command = new RGVTaskCommand()
                                    {
                                        PickupLocation = (byte)Convert.ToSByte(RGVhand.SourceAddress),
                                        PutcargoLocation = (byte)Convert.ToSByte(RGVhand.TargetAddress),
                                        TaskType = (byte)Convert.ToSByte(RGVhand.TaskType),
                                    };
                                    SendCommandFirstFloor(RGVcommand, command);
                                    return content.OK($"{device.DeviceName}取放货命令下发成功");
                                }
                                else
                                {
                                    return content.Error($"{device.DeviceName}取放货命令放货位和取货位不能为空");
                                }
                            }
                            else if (RGVhand.TaskType == "6")
                            {
                                if (RGVhand.TargetAddress != null)
                                {
                                    RGVTaskCommand command = new RGVTaskCommand()
                                    {
                                        PutcargoLocation = (byte)Convert.ToSByte(RGVhand.TargetAddress),
                                        TaskType = (byte)Convert.ToSByte(4),
                                    };
                                    SendCommandFirstFloor(RGVcommand, command);
                                    return content.OK($"{device.DeviceName}退命令下发成功");
                                }
                                else
                                {
                                    return content.Error($"{device.DeviceName}退回命令放货位不能为空");
                                }
                            }
                            else
                            {
                                return content.Error($"{device.DeviceName}放定位命令放货位不能为空");
                            }
                        }
                        else if (RGVhand.TaskType == "3")
                        {
                            if (RGVhand.SourceAddress != null)
                            {
                                RGVTaskCommand command = new RGVTaskCommand()
                                {
                                    PickupLocation = (byte)Convert.ToSByte(RGVhand.SourceAddress),
                                    TaskType = (byte)Convert.ToSByte(RGVhand.TaskType),
                                };
                                SendCommandFirstFloor(RGVcommand, command);
                                return content.OK($"{device.DeviceName}取货命令下发成功");
                            }
                            else
                            {
                                return content.Error($"{device.DeviceName}取货命令取货位不能为空");
                            }
                        }
                        else if (RGVhand.TaskType == "4")
                        {
                            if (RGVhand.TargetAddress != null)
                            {
                                RGVTaskCommand command = new RGVTaskCommand()
                                {
                                    PutcargoLocation = (byte)Convert.ToSByte(RGVhand.TargetAddress),
                                    TaskType = (byte)Convert.ToSByte(RGVhand.TaskType),
                                };
                                SendCommandFirstFloor(RGVcommand, command);
                                return content.OK($"{device.DeviceName}放货命令下发成功");
                            }
                            else
                            {
                                return content.Error($"{device.DeviceName}放货命令放货位不能为空");
                            }
                        }
                        else if (RGVhand.TaskType == "5")
                        {
                            if (RGVhand.TargetAddress != null && RGVhand.TargetAddress != null)
                            {
                                RGVTaskCommand command = new RGVTaskCommand()
                                {
                                    PickupLocation = (byte)Convert.ToSByte(RGVhand.SourceAddress),
                                    PutcargoLocation = (byte)Convert.ToSByte(RGVhand.TargetAddress),
                                    TaskType = (byte)Convert.ToSByte(RGVhand.TaskType),
                                };
                                SendCommandFirstFloor(RGVcommand, command);
                                return content.OK($"{device.DeviceName}取放货命令下发成功");
                            }
                            else
                            {
                                return content.Error($"{device.DeviceName}取放货命令放货位和取货位不能为空");
                            }
                        }
                        else if (RGVhand.TaskType == "6")
                        {
                            if (RGVhand.TargetAddress != null)
                            {
                                RGVTaskCommand command = new RGVTaskCommand()
                                {
                                    PutcargoLocation = (byte)Convert.ToSByte(RGVhand.TargetAddress),
                                    TaskType = (byte)Convert.ToSByte(4),
                                };
                                SendCommandFirstFloor(RGVcommand, command);
                                return content.OK($"{device.DeviceName}退命令下发成功");
                            }
                            else
                            {
                                return content.Error($"{device.DeviceName}退回命令放货位不能为空");
                                return content.Error($"{device.DeviceName}未知任务命令");
                            }
                        }
                        else
                        {
                            return content.Error($"{device.DeviceName}未知任务命令");
                            return content.Error($"请在联机模式、无故障、待机状态时再下发{RGVcommand.DeviceName}命令");
                        }
                    }
                    else
                    {
                        CommonRGV RGVcommand = (CommonRGV)device;
                        if (RGVhand.TaskType == "1")
                        if (RGVcommand.GetValue<RGVDBName, bool>(RGVDBName.Automatic) && !RGVcommand.GetValue<RGVDBName, bool>(RGVDBName.Fault) && !RGVcommand.GetValue<RGVDBName, bool>(RGVDBName.Running))
                        {
                            if (RGVhand.SourceAddress != null)
                            if (RGVhand.TaskType == "1")
                            {
                                RGVTaskCommand command = new RGVTaskCommand()
                                if (RGVhand.SourceAddress != null)
                                {
                                    PickupLocation = (byte)Convert.ToSByte(RGVhand.SourceAddress),
                                    TaskType = (byte)Convert.ToSByte(RGVhand.TaskType),
                                };
                                SendCommandSecondFloor(RGVcommand, command);
                                return content.OK($"{device.DeviceName}取定位命令下发成功");
                            }
                            else
                            {
                                return content.Error($"{device.DeviceName}取定位命令取货位不能为空");
                            }
                                    RGVTaskCommand command = new RGVTaskCommand()
                                    {
                                        PickupLocation = (byte)Convert.ToSByte(RGVhand.SourceAddress),
                                        TaskType = (byte)Convert.ToSByte(RGVhand.TaskType),
                                    };
                                    SendCommandSecondFloor(RGVcommand, command);
                                    return content.OK($"{device.DeviceName}取定位命令下发成功");
                                }
                                else
                                {
                                    return content.Error($"{device.DeviceName}取定位命令取货位不能为空");
                                }
                        }
                        else if (RGVhand.TaskType == "2")
                        {
                            if (RGVhand.TargetAddress != null)
                            }
                            else if (RGVhand.TaskType == "2")
                            {
                                RGVTaskCommand command = new RGVTaskCommand()
                                if (RGVhand.TargetAddress != null)
                                {
                                    PutcargoLocation = (byte)Convert.ToSByte(RGVhand.TargetAddress),
                                    TaskType = (byte)Convert.ToSByte(RGVhand.TaskType),
                                };
                                SendCommandSecondFloor(RGVcommand, command);
                                return content.OK($"{device.DeviceName}放定位命令下发成功");
                                    RGVTaskCommand command = new RGVTaskCommand()
                                    {
                                        PutcargoLocation = (byte)Convert.ToSByte(RGVhand.TargetAddress),
                                        TaskType = (byte)Convert.ToSByte(RGVhand.TaskType),
                                    };
                                    SendCommandSecondFloor(RGVcommand, command);
                                    return content.OK($"{device.DeviceName}放定位命令下发成功");
                                }
                                else
                                {
                                    return content.Error($"{device.DeviceName}放定位命令放货位不能为空");
                                }
                            }
                            else if (RGVhand.TaskType == "3")
                            {
                                if (RGVhand.SourceAddress != null)
                                {
                                    RGVTaskCommand command = new RGVTaskCommand()
                                    {
                                        PickupLocation = (byte)Convert.ToSByte(RGVhand.SourceAddress),
                                        TaskType = (byte)Convert.ToSByte(RGVhand.TaskType),
                                    };
                                    SendCommandSecondFloor(RGVcommand, command);
                                    return content.OK($"{device.DeviceName}取货命令下发成功");
                                }
                                else
                                {
                                    return content.Error($"{device.DeviceName}取货命令取货位不能为空");
                                }
                            }
                            else if (RGVhand.TaskType == "4")
                            {
                                if (RGVhand.TargetAddress != null)
                                {
                                    RGVTaskCommand command = new RGVTaskCommand()
                                    {
                                        PutcargoLocation = (byte)Convert.ToSByte(RGVhand.TargetAddress),
                                        TaskType = (byte)Convert.ToSByte(RGVhand.TaskType),
                                    };
                                    SendCommandSecondFloor(RGVcommand, command);
                                    return content.OK($"{device.DeviceName}放货命令下发成功");
                                }
                                else
                                {
                                    return content.Error($"{device.DeviceName}放货命令放货位不能为空");
                                }
                            }
                            else if (RGVhand.TaskType == "5")
                            {
                                if (RGVhand.TargetAddress != null && RGVhand.TargetAddress != null)
                                {
                                    RGVTaskCommand command = new RGVTaskCommand()
                                    {
                                        PickupLocation = (byte)Convert.ToSByte(RGVhand.SourceAddress),
                                        PutcargoLocation = (byte)Convert.ToSByte(RGVhand.TargetAddress),
                                        TaskType = (byte)Convert.ToSByte(RGVhand.TaskType),
                                    };
                                    SendCommandSecondFloor(RGVcommand, command);
                                    return content.OK($"{device.DeviceName}取放货命令下发成功");
                                }
                                else
                                {
                                    return content.Error("取放货命令放货位和取货位不能为空");
                                }
                            }
                            else if (RGVhand.TaskType == "6")
                            {
                                if (RGVhand.TargetAddress != null)
                                {
                                    RGVTaskCommand command = new RGVTaskCommand()
                                    {
                                        PutcargoLocation = (byte)Convert.ToSByte(RGVhand.TargetAddress),
                                        TaskType = (byte)Convert.ToSByte(RGVhand.TaskType),
                                    };
                                    SendCommandSecondFloor(RGVcommand, command);
                                    return content.OK($"{device.DeviceName}退回命令下发成功");
                                }
                                else
                                {
                                    return content.Error($"{device.DeviceName}退回命令放货位不能为空");
                                }
                            }
                            else
                            {
                                return content.Error($"{device.DeviceName}放定位命令放货位不能为空");
                            }
                        }
                        else if (RGVhand.TaskType == "3")
                        {
                            if (RGVhand.SourceAddress != null)
                            {
                                RGVTaskCommand command = new RGVTaskCommand()
                                {
                                    PickupLocation = (byte)Convert.ToSByte(RGVhand.SourceAddress),
                                    TaskType = (byte)Convert.ToSByte(RGVhand.TaskType),
                                };
                                SendCommandSecondFloor(RGVcommand, command);
                                return content.OK($"{device.DeviceName}取货命令下发成功");
                            }
                            else
                            {
                                return content.Error($"{device.DeviceName}取货命令取货位不能为空");
                            }
                        }
                        else if (RGVhand.TaskType == "4")
                        {
                            if (RGVhand.TargetAddress != null)
                            {
                                RGVTaskCommand command = new RGVTaskCommand()
                                {
                                    PutcargoLocation = (byte)Convert.ToSByte(RGVhand.TargetAddress),
                                    TaskType = (byte)Convert.ToSByte(RGVhand.TaskType),
                                };
                                SendCommandSecondFloor(RGVcommand, command);
                                return content.OK($"{device.DeviceName}放货命令下发成功");
                            }
                            else
                            {
                                return content.Error($"{device.DeviceName}放货命令放货位不能为空");
                            }
                        }
                        else if (RGVhand.TaskType == "5")
                        {
                            if (RGVhand.TargetAddress != null && RGVhand.TargetAddress != null)
                            {
                                RGVTaskCommand command = new RGVTaskCommand()
                                {
                                    PickupLocation = (byte)Convert.ToSByte(RGVhand.SourceAddress),
                                    PutcargoLocation = (byte)Convert.ToSByte(RGVhand.TargetAddress),
                                    TaskType = (byte)Convert.ToSByte(RGVhand.TaskType),
                                };
                                SendCommandSecondFloor(RGVcommand, command);
                                return content.OK($"{device.DeviceName}取放货命令下发成功");
                            }
                            else
                            {
                                return content.Error("取放货命令放货位和取货位不能为空");
                            }
                        }
                        else if (RGVhand.TaskType == "6")
                        {
                            if (RGVhand.TargetAddress != null)
                            {
                                RGVTaskCommand command = new RGVTaskCommand()
                                {
                                    PutcargoLocation = (byte)Convert.ToSByte(RGVhand.TargetAddress),
                                    TaskType = (byte)Convert.ToSByte(RGVhand.TaskType),
                                };
                                SendCommandSecondFloor(RGVcommand, command);
                                return content.OK($"{device.DeviceName}退回命令下发成功");
                            }
                            else
                            {
                                return content.Error($"{device.DeviceName}退回命令放货位不能为空");
                                return content.Error($"{device.DeviceName}未知任务命令");
                            }
                        }
                        else
                        {
                            return content.Error($"{device.DeviceName}未知任务命令");
                            return content.Error($"请在联机模式、无故障、待机状态时再下发{RGVcommand.DeviceName}命令");
                        }
                    }
                    }
                }
                return content.Error("未找到设备信息请联系IT");
            }
@@ -995,6 +1030,7 @@
        public WebResponseContent RGVReset(string DeviceCode)
        {
            WriteLog.GetLog("RGV手动任务").Write($"【复位命令】{JsonConvert.SerializeObject(DeviceCode)}", "RGV手动任务");
            WebResponseContent content = new WebResponseContent();
            try
            {
@@ -1004,12 +1040,12 @@
                    if (DeviceCode == "RGV01" || DeviceCode == "RGV02")
                    {
                        CommonRGV_FirstFloor commonRGV = (CommonRGV_FirstFloor)device;
                        commonRGV.SetValue(StackerCraneDBName.TaskType, Convert.ToSByte(9));
                        commonRGV.SetValue(RGVDBName.TaskType, Convert.ToSByte(9));
                    }
                    else
                    {
                        CommonRGV commonRGV = (CommonRGV)device;
                        commonRGV.SetValue(StackerCraneDBName.TaskType, Convert.ToSByte(9));
                        commonRGV.SetValue(RGVDBName.TaskType, Convert.ToSByte(9));
                    }
                    return content.OK($"{device.DeviceName}复位成功");
                }
@@ -1023,6 +1059,7 @@
        public WebResponseContent RGVEmergencyStop(string DeviceCode)
        {
            WriteLog.GetLog("RGV手动任务").Write($"【急停命令】{JsonConvert.SerializeObject(DeviceCode)}", "RGV手动任务");
            WebResponseContent content = new WebResponseContent();
            try
            {
@@ -1050,6 +1087,7 @@
        }
        public WebResponseContent RGVCancel(string DeviceCode)
        {
            WriteLog.GetLog("RGV手动任务").Write($"【取消任务命令】{JsonConvert.SerializeObject(DeviceCode)}", "RGV手动任务");
            WebResponseContent content = new WebResponseContent();
            try
            {
@@ -1077,6 +1115,7 @@
        }
        public WebResponseContent RGVInitialize(string DeviceCode)
        {
            WriteLog.GetLog("RGV手动任务").Write($"【初始化命令】{JsonConvert.SerializeObject(DeviceCode)}", "RGV手动任务");
            WebResponseContent content = new WebResponseContent();
            try
            {
@@ -1088,15 +1127,21 @@
                    {
                        CommonRGV_FirstFloor commonRGV = (CommonRGV_FirstFloor)device;
                        DeviceProDTO? devicePro = commonRGV.DeviceProDTOs.Where(x => x.DeviceChildCode == commonRGV.DeviceCode && x.DeviceProParamName == "TaskType").FirstOrDefault();
                        byte[] byt = Encoding.UTF8.GetBytes("08");
                        commonRGV.Communicator.Write(devicePro.DeviceProAddress, byt);
                        //byte[] byt = Encoding.UTF8.GetBytes("08");
                        byte valueToWrite = 8;
                        byte[] buffer = new byte[] { valueToWrite };
                        commonRGV.Communicator.Write(devicePro.DeviceProAddress, buffer);
                    }
                    else
                    {
                        CommonRGV commonRGV = (CommonRGV)device;
                        DeviceProDTO? devicePro = commonRGV.DeviceProDTOs.Where(x => x.DeviceChildCode == commonRGV.DeviceCode && x.DeviceProParamName == "TaskType").FirstOrDefault();
                        byte[] byt = Encoding.UTF8.GetBytes("8");
                        commonRGV.Communicator.Write(devicePro.DeviceProAddress, byt);
                        byte valueToWrite = 8;
                        byte[] buffer = new byte[] { valueToWrite };
                        commonRGV.Communicator.Write(devicePro.DeviceProAddress, buffer);
                    }
                    return content.OK($"{device.DeviceName}初始化成功");
                }
@@ -1110,6 +1155,7 @@
        public WebResponseContent RGVPause(string DeviceCode)
        {
            WriteLog.GetLog("RGV手动任务").Write($"【停止命令】{JsonConvert.SerializeObject(DeviceCode)}", "RGV手动任务");
            WebResponseContent content = new WebResponseContent();
            try
            {
@@ -1140,7 +1186,7 @@
        public void SendCommandFirstFloor(CommonRGV_FirstFloor commonRGV, RGVTaskCommand? rgvTaskCommand)
        {
            commonRGV.SetValue(StackerCraneDBName.TaskNum, Convert.ToInt16(1));
            commonRGV.SetValue(RGVDBName.TaskNum, Convert.ToInt16(1));
            Thread.Sleep(100);
            commonRGV.SetValue(StackerCraneDBName.PutcargoLocation, (byte)Convert.ToSByte(rgvTaskCommand.PutcargoLocation));
            Thread.Sleep(100);
@@ -1194,6 +1240,25 @@
            #endregion <Public Menber>
        }
        public enum RGVDBName
        {
            SendTask,
            Automatic,
            WorkCompleted,
            Running,
            Fault,
            InStock,
            RGVTargetAddress,
            RGVTaskNum,
            PickupLocation,
            PutcargoLocation,
            TaskType,
            TaskNum,
            LevelPoint,
            CurrentTaskNum,
            RGVAlarm,
        }
        #endregion
    }
}