刘磊
2024-12-24 e2bb2738c6ddb1d013837924dc639b0f6f63662b
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Partial/TaskService.cs
@@ -13,6 +13,7 @@
using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_QuartzJob.Models;
using System.Drawing;
namespace WIDESEAWCS_TaskInfoService
{
@@ -93,21 +94,73 @@
                var result = await HttpHelper.PostAsync(wmsIpAddrss, new { palletCode = palletCode, EquiCodeMOM = stationManager.stationEquipMOM, Roadways = stationManager.Roadway, area = stationManager.stationArea, Position = stationManager.stationChildCode }.ToJsonString());
                content = JsonConvert.DeserializeObject<WebResponseContent>(result);
                ConsoleHelper.WriteErrorLine($"{stationManager.stationChildCode}站台请求响应信息:{content.ToJsonString()}");
                if (!content.Status)
                {
                    // wms失败返回去NG口任务
                    //if (stationManager.stationChildCode != stationManager.stationNGChildCode)
                    //{
                    //    WMSTaskDTO taskDTO = new WMSTaskDTO()
                    //    {
                    //        Grade = 8,
                    //        PalletCode = palletCode,
                    //        SourceAddress = stationManager.stationLocation,
                    //        TargetAddress = stationManager.stationNGLocation,
                    //        RoadWay = stationManager.Roadway,
                    //        TaskNum = 1000,
                    //        TaskState = (int)TaskOutStatusEnum.OutNew,
                    //        TaskType = (int)TaskOutboundTypeEnum.InToOut
                    //    };
                    //}
                    return content;
                }
                var task = JsonConvert.DeserializeObject<WMSTaskDTO>(content.Data.ToString());
                ConsoleHelper.WriteSuccessLine(content.Data.ToString());
                return ReceiveByWMSTask(task);
            }
            catch (Exception ex)
            {
                return WebResponseContent.Instance.Error(ex.Message);
            }
        }
        public async Task<WebResponseContent> RequestOutTaskToBZAsync(Dt_StationManager stationManager)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
                var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE)?.ConfigValue;
                var requestTask = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.RequestOutTaskToBZ)?.ConfigValue;
                if (wmsBase == null || requestTask == null)
                {
                    throw new InvalidOperationException("WMS IP 未配置");
                }
                var wmsIpAddrss = wmsBase + requestTask;
                var result = await HttpHelper.PostAsync(wmsIpAddrss, new { Position = stationManager.stationChildCode }.ToJsonString());
                content = JsonConvert.DeserializeObject<WebResponseContent>(result);
                if (!content.Status)
                {
                    //无满足条件可出库至包装的库存
                    return content;
                }
                var task = JsonConvert.DeserializeObject<WMSTaskDTO>(content.Data.ToString());
                ConsoleHelper.WriteSuccessLine(content.Data.ToString());
                content = ReceiveByBZOtuTask(task);
                //if (content.Status)
                //{
                //    //相应的在途数据+1
                //   // _taskNeedBarcodeRepository.UpdateData();
                //}
                return content;
            }
            catch (Exception ex)
            {
                return content.Error(ex.Message);
            }
        }
@@ -146,6 +199,15 @@
                    task.NextAddress = stationinfo.stationChildCode;
                    task.TargetAddress = taskDTO.TargetAddress;
                }
                else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.RelocationGroup)
                {
                    task.TaskState = (int)TaskStatus.Created;
                    task.SourceAddress = taskDTO.SourceAddress;
                    task.CurrentAddress = taskDTO.SourceAddress;
                    task.NextAddress = taskDTO.TargetAddress;
                    task.TargetAddress = taskDTO.TargetAddress;
                }
                BaseDal.AddData(task);
                _taskExecuteDetailService.AddTaskExecuteDetail(task.WMSId, "接收WMS任务");
@@ -158,6 +220,46 @@
            }
            return content;
        }
        /// <summary>
        /// 接收WMS任务信息
        /// </summary>
        /// <param name="taskDTOs">WMS任务对象集合</param>
        /// <returns>返回处理结果</returns>
        public WebResponseContent ReceiveByBZOtuTask([NotNull] WMSTaskDTO taskDTO)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                if (BaseDal.QueryFirst(x => x.TaskNum == taskDTO.TaskNum || x.PalletCode == taskDTO.PalletCode) != null)
                {
                    return content.OK();
                }
                Dt_Task task = _mapper.Map<Dt_Task>(taskDTO);
                task.Creater = "WMS";
                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 = stationinfo.stationChildCode;
                    task.NextAddress = stationinfo.stationChildCode;
                    task.SourceAddress = taskDTO.SourceAddress;
                    task.TargetAddress = taskDTO.TargetAddress;
                }
                BaseDal.AddData(task);
                _taskExecuteDetailService.AddTaskExecuteDetail(task.WMSId, "接收WMS任务");
                content = WebResponseContent.Instance.OK("成功");
            }
            catch (Exception ex)
            {
                content = WebResponseContent.Instance.Error($"任务接收错误,错误信息:{ex.Message}");
            }
            return content;
        }
        /// <summary>
        /// 高温出库
@@ -236,7 +338,7 @@
        }
        /// <summary>
        /// 根据托盘号和设备号查询入库任务
        /// 根据托盘号和设备号查询任务
        /// </summary>
        /// <param name="taskNum">任务号</param>
        /// <param name="currentAddress">当前地址</param>