huangxiaoqiang
5 天以前 7f42a3ef9bc83bdc199317d12c1905d8696dac4f
ÏîÄ¿´úÂë/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/Task/RequestInbound.cs
@@ -5,10 +5,12 @@
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using WIDESEA_Common.Log;
using WIDESEAWCS_Common;
using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_DTO.StackerHandTask;
using WIDESEAWCS_DTO.TaskInfo;
using WIDESEAWCS_Model.BasicInfo;
using WIDESEAWCS_Model.Models;
@@ -54,41 +56,66 @@
        private async Task RequestTask(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, Dt_StationManager stationManager)
        {
            var hasTask = await _taskRepository.QueryFirstAsync(x => x.SourceAddress == childDeviceCode && x.TaskState < (int)TaskInStatusEnum.RGV_InExecutingFinish && x.TaskState >= (int)TaskInStatusEnum.InNew);
            if (hasTask != null)
            try
            {
                var log = $"【{conveyorLine._deviceName}】任务号:【{hasTask.TaskNum}】,托盘条码:【{hasTask.PalletCode}】已到达【{childDeviceCode}】输送线存在任务";
                var hasTask = await _taskRepository.QueryFirstAsync(x => x.SourceAddress == childDeviceCode && x.TaskState < (int)TaskInStatusEnum.RGV_InExecutingFinish && x.TaskState >= (int)TaskInStatusEnum.InNew);
                if (hasTask != null)
                {
                    var log = $"【{conveyorLine._deviceName}】任务号:【{hasTask.TaskNum}】,托盘条码:【{hasTask.PalletCode}】已到达【{childDeviceCode}】输送线存在任务";
                    ConsoleHelper.WriteWarningLine(log);
                    await _noticeService.Logs(userTokenIds, new { conveyorLine.DeviceName, log = log, time = DateTime.Now.ToString("G"), color = "red" });
                    WriteInfo(conveyorLine.DeviceName, log);
                    return;
                }
                var RGVName = string.Empty;
                if (stationManager.stationFloor == "1F")
                {
                    RGVName = stationManager.RGVName;
                }
                else
                {
                    RGVName = "RGV03";
                }
                int targetStation = 0;
                if (childDeviceCode == "1004" || childDeviceCode == "1039" || childDeviceCode == "1040" || childDeviceCode == "1013" || childDeviceCode == "1014")
                {
                    targetStation = 14;
                }
                else if (childDeviceCode == "1015" || childDeviceCode == "1016" || childDeviceCode == "1027" || childDeviceCode == "1028" || childDeviceCode == "1029" || childDeviceCode == "1030")
                {
                    targetStation = 1;
                }
                else
                {
                    targetStation = 0;
                }
                Dt_Task task = new Dt_Task()
                {
                    TaskNum = _taskRepository.GetTaskNo().Result,
                    TaskType = (int)TaskInboundTypeEnum.Inbound,
                    TaskState = (int)TaskInStatusEnum.InNew,
                    SourceAddress = childDeviceCode,
                    Dispatchertime = DateTime.Now,
                    Grade = 1,
                    Creater = "System",
                    Floor = stationManager.stationFloor,
                    RGVName = RGVName,
                    SourceStation = stationManager.remark,
                    TargetStation = targetStation,
                };
                _taskRepository.AddData(task);
            }
            catch (Exception ex)
            {
                var log = $"【{conveyorLine._deviceName}】输送线【{childDeviceCode}】【{ex.Message}】";
                ConsoleHelper.WriteWarningLine(log);
                await _noticeService.Logs(userTokenIds, new { conveyorLine.DeviceName, log = log, time = DateTime.Now.ToString("G"), color = "red" });
                WriteInfo(conveyorLine.DeviceName, log);
                return;
            }
            var RGVName = string.Empty;
            if (stationManager.stationFloor == "1F")
            {
                RGVName = stationManager.RGVName;
            }
            else
            {
                RGVName = "RGV03";
            }
            Dt_Task task = new Dt_Task()
            {
                TaskNum = _taskRepository.GetTaskNo().Result,
                TaskType = (int)TaskInboundTypeEnum.Inbound,
                TaskState = (int)TaskInStatusEnum.InNew,
                SourceAddress = childDeviceCode,
                Dispatchertime = DateTime.Now,
                Grade = 1,
                Creater = "System",
                Floor = stationManager.stationFloor,
                RGVName = RGVName,
                SourceStation = stationManager.remark,
                TargetStation = 0,
            };
            _taskRepository.AddData(task);
        }
        private void RequestWMSTask(CommonConveyorLine conveyorLine,  Dt_StationManager stationManager)
        {
@@ -145,6 +172,7 @@
                    }
                    var wmsIpAddress = wmsBase + requestTask;
                    var result = WIDESEA_Comm.Http.HttpHelper.PostAsync(wmsIpAddress, taskDTO.ToJsonString()).Result;
                    WriteLog.GetLog("WMS接口返回信息").Write(JsonConvert.SerializeObject(result), "WMS接口返回信息");
                }
            }
            else
@@ -153,6 +181,7 @@
                var x = conveyorLine.Communicator.Read(devicePro.DeviceProAddress, 10);
                string Barcode = Encoding.UTF8.GetString(x);
                if (Barcode == null || Barcode == "" || Barcode.Trim().Contains("\0"))
                {
                    conveyorLine.SetValue(ConveyorLineDBName.WriteInteractiveSignal, Convert.ToSByte(3), stationManager.stationChildCode);
@@ -160,7 +189,8 @@
                var task = _taskRepository.QueryFirst(x => x.PalletCode == Barcode);
                if (task != null)
                {
                    var log = $"【{conveyorLine._deviceName}】站台【{stationManager.stationChildCode}】请求取货、已存在任务任务号{task.TaskNum}";
                    LogAndWarn(conveyorLine.DeviceName, log);
                }
                else
                {
@@ -180,6 +210,7 @@
                    }
                    var wmsIpAddress = wmsBase + requestTask;
                    var result = WIDESEA_Comm.Http.HttpHelper.PostAsync(wmsIpAddress, taskDTO.ToJsonString()).Result;
                    WriteLog.GetLog("WMS接口返回信息").Write(JsonConvert.SerializeObject(result), "WMS接口返回信息");
                }
            } 
        }