huangxiaoqiang
昨天 843cc2ea1b104ecdf9da61318a4136a5d4096411
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Partial/TaskService.cs
@@ -252,7 +252,7 @@
                // 发起请求获取入库任务
                content = await RequestInTask(palletCode, stationManager);
                ConsoleHelper.WriteErrorLine($"{stationManager.stationChildCode}站台请求响应信息:{content.ToJsonString()}");
                //ConsoleHelper.WriteErrorLine($"{stationManager.stationChildCode}站台请求响应信息:{content.ToJsonString()}");
                if (!content.Status)
                {
@@ -260,7 +260,7 @@
                }
                var task = JsonConvert.DeserializeObject<WMSTaskDTO>(content.Data.ToString());
                ConsoleHelper.WriteSuccessLine(content.Data.ToString());
                //ConsoleHelper.WriteSuccessLine(content.Data.ToString());
                return ReceiveByWMSTask(task);
            }
            catch (Exception ex)
@@ -399,23 +399,26 @@
                var wmsIpAddrss = wmsBase + requestTask;
                var result = await HttpHelper.PostAsync(wmsIpAddrss, new { Position = stationManager.stationChildCode }.ToJsonString());
                QuartzLogger.WriteLogToFile($"包装出库", $"返回参数【{JsonConvert.SerializeObject(result)}】{Environment.NewLine}{Environment.NewLine}");
                content = JsonConvert.DeserializeObject<WebResponseContent>(result);
                if (!content.Status)
                {
                    //无满足条件可出库至包装的库存
                    ConsoleHelper.WriteErrorLine(JsonConvert.SerializeObject(content));
                    QuartzLogger.WriteLogToFile($"包装出库", $"返回参数【{JsonConvert.SerializeObject(content)}】{Environment.NewLine}{Environment.NewLine}");
                    return content;
                }
                var task = JsonConvert.DeserializeObject<WMSTaskDTO>(content.Data.ToString());
                ConsoleHelper.WriteSuccessLine(content.Data.ToString());
                //_taskService.ReceiveWMSTask(new List<WMSTaskDTO> { taskDTO })‘
                content = ReceiveWMSTask(new List<WMSTaskDTO> { task });
                //content = ReceiveByBZOtuTask(task);
                //if (content.Status)
                //{
                //    //相应的在途数据+1
                //   // _taskNeedBarcodeRepository.UpdateData();
                //}
                QuartzLogger.WriteLogToFile($"包装出库", $"返回参数【{JsonConvert.SerializeObject(content)}】{Environment.NewLine}{Environment.NewLine}");
                ConsoleHelper.WriteErrorLine(JsonConvert.SerializeObject(content));
                return content;
            }
            catch (Exception ex)
@@ -443,12 +446,24 @@
                if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
                {
                    var stationinfo = _stationManagerRepository.QueryFirst(x => x.stationLocation == taskDTO.TargetAddress && x.Roadway == taskDTO.RoadWay);
                    task.TaskState = (int)TaskOutStatusEnum.OutNew;
                    task.CurrentAddress = taskDTO.RoadWay;
                    task.NextAddress = stationinfo.stationChildCode;
                    task.SourceAddress = taskDTO.SourceAddress;
                    task.TargetAddress = taskDTO.TargetAddress;
                    if (task.TaskType == (int)TaskOutboundTypeEnum.InToOut && taskDTO.RoadWay.Contains("CW"))
                    {
                        var stationinfo = _stationManagerRepository.QueryFirst(x => (x.stationPLC == "1017" ||x.stationPLC=="1024")&& x.stationType == 10 && x.Roadway == taskDTO.RoadWay);
                        task.TaskState = (int)TaskOutStatusEnum.OutNew;
                        task.CurrentAddress = taskDTO.SourceAddress;
                        task.NextAddress = stationinfo.stationChildCode;
                        task.SourceAddress = taskDTO.SourceAddress;
                        task.TargetAddress = taskDTO.TargetAddress;
                    }
                    else
                    {
                        var stationinfo = _stationManagerRepository.QueryFirst(x => x.stationLocation == taskDTO.TargetAddress && x.Roadway == taskDTO.RoadWay);
                        task.TaskState = (int)TaskOutStatusEnum.OutNew;
                        task.CurrentAddress = taskDTO.RoadWay;
                        task.NextAddress = stationinfo.stationChildCode;
                        task.SourceAddress = taskDTO.SourceAddress;
                        task.TargetAddress = taskDTO.TargetAddress;
                    }
                }
                else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup)
                {
@@ -544,6 +559,7 @@
                    task.NextAddress = "002-000-002";
                    task.SourceAddress = taskDTO.SourceAddress;
                    task.TargetAddress = taskDTO.TargetAddress;
                }
                BaseDal.AddData(task);
@@ -558,6 +574,44 @@
            return content;
        }
        public WebResponseContent ReceiveByWMSNGTask([NotNull] WMSTaskDTO taskDTO)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                var task = BaseDal.QueryFirst(x => x.TaskNum == taskDTO.TaskNum || x.PalletCode == taskDTO.PalletCode);
                if (task != null)
                {
                    var taskHty = task.Adapt<Dt_Task_Hty>();
                    _taskHtyRepository.AddData(taskHty);
                    BaseDal.DeleteData(task);
                }
                Dt_Task taskNew = _mapper.Map<Dt_Task>(taskDTO);
                taskNew.Creater = "WMS";
                if (taskNew.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
                {
                    taskNew.TaskState = (int)TaskOutStatusEnum.OutNew;
                    taskNew.CurrentAddress = taskDTO.SourceAddress;
                    taskNew.NextAddress = taskDTO.NextAddress;
                    taskNew.SourceAddress = taskDTO.SourceAddress;
                    taskNew.TargetAddress = taskDTO.TargetAddress;
                }
                BaseDal.AddData(taskNew);
                _taskExecuteDetailService.AddTaskExecuteDetail(taskNew.WMSId, "接收WMS任务");
                content = WebResponseContent.Instance.OK("成功");
            }
            catch (Exception ex)
            {
                content = WebResponseContent.Instance.Error($"任务接收错误,错误信息:{ex.Message}");
            }
            return content;
        }
        /// <summary>
        /// 接收WMS任务信息
        /// </summary>