1
huangxiaoqiang
2025-02-16 67844d0b962e62d65e5c118d3251aeeeda50810f
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Partial/TaskService.cs
@@ -14,6 +14,9 @@
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_QuartzJob.Models;
using System.Drawing;
using WIDESEAWCS_ITaskInfoService;
using Mapster;
using AngleSharp.Io;
namespace WIDESEAWCS_TaskInfoService
{
@@ -82,6 +85,48 @@
                {
                    return content.Error("当前托盘存在任务");
                }
                var Station = await _stationManagerRepository.QueryFirstAsync(x => x.stationType == 6 && x.productLine == stationManager.productLine && x.stationArea == stationManager.stationArea);
               var tasks= await BaseDal.QueryFirstAsync(x => x.TaskType == (int)TaskOutboundTypeEnum.InToOut && x.TargetAddress == stationManager.stationLocation && x.CurrentAddress == Station.stationChildCode);
                if(tasks!=null)
                {
                    ConsoleHelper.WriteErrorLine($"【{stationManager.stationChildCode}】已存在直接出库任务任务");
                    return content.Error($"【{stationManager.stationChildCode}】已存在直接出库任务任务");
                }
                if (stationManager.stationType == 7)
                {
                    var runTask = await BaseDal.QueryFirstAsync(x => x.CurrentAddress == Station.stationChildCode && x.TaskState == (int)TaskInStatusEnum.Line_InFinish && x.TaskType == (int)TaskInboundTypeEnum.InTray);
                    if (runTask != null)
                    {
                        runTask.TargetAddress = stationManager.stationLocation;
                        runTask.NextAddress = stationManager.stationChildCode;
                        runTask.Grade = 3;
                        runTask.TaskType = (int)TaskOutboundTypeEnum.InToOut;
                        runTask.TaskState = (int)TaskOutStatusEnum.OutNew;
                        var config1 = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
                        var wmsBase1 = config1.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE)?.ConfigValue;
                        var requestTask1 = config1.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.SetEmptyOutbyInToOutAsync)?.ConfigValue;
                        if (wmsBase1 == null || requestTask1 == null)
                        {
                            throw new InvalidOperationException("WMS IP 未配置");
                        }
                        var wmsIpAddrss1 = wmsBase1 + requestTask1;
                        var result1 = await HttpHelper.PostAsync(wmsIpAddrss1, new { palletCode = runTask.PalletCode, EquiCodeMOM = stationManager.stationEquipMOM, Roadways = stationManager.Roadway, area = stationManager.stationArea, Position = Station.stationChildCode }.ToJsonString());
                        content = JsonConvert.DeserializeObject<WebResponseContent>(result1);
                        if (content.Status)
                        {
                            await BaseDal.UpdateDataAsync(runTask);
                            ConsoleHelper.WriteSuccessLine($"【{runTask.PalletCode}直接出库至二封】");
                            return content.OK("成功");
                        }
                        else
                            ConsoleHelper.WriteErrorLine(content.Message);
                    }
                    else
                        ConsoleHelper.WriteErrorLine($"【{Station.stationChildCode}】未找到空托盘入库任务");
                }
                var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
                var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE)?.ConfigValue;
@@ -149,7 +194,9 @@
                var task = JsonConvert.DeserializeObject<WMSTaskDTO>(content.Data.ToString());
                ConsoleHelper.WriteSuccessLine(content.Data.ToString());
                content = ReceiveByBZOtuTask(task);
                //_taskService.ReceiveWMSTask(new List<WMSTaskDTO> { taskDTO })‘
                content = ReceiveWMSTask(new List<WMSTaskDTO> { task });
                //content = ReceiveByBZOtuTask(task);
                //if (content.Status)
                //{
                //    //相应的在途数据+1
@@ -418,6 +465,8 @@
                if (content.Status)
                {
                    task.TaskState = 1;  //任务完成
                    var taskHty = task.Adapt<Dt_Task_Hty>();
                    _taskHtyRepository.AddData(taskHty);
                    BaseDal.DeleteData(task);
                }