11
yanjinhui
2026-03-02 ef4e456bb392c7260f2d8af886d7786f471b6ae0
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskMethods.cs
@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Metadata;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
@@ -13,6 +14,7 @@
using WIDESEAWCS_Core.Enums;
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_DTO;
using WIDESEAWCS_DTO.WMS;
using WIDESEAWCS_Model.Models;
namespace WIDESEAWCS_TaskInfoService
@@ -30,11 +32,14 @@
        /// <exception cref="NotImplementedException"></exception>
        public WebResponseContent UpdateTaskStatus(object TaskDTO, DeviceTypeEnum deviceTypeEnum)
        {
            WebResponseContent content = new WebResponseContent();
            GALAXISUpdateTaskStatus gALAXIS = new();
            try
            {
                if (deviceTypeEnum == DeviceTypeEnum.GALAXIS)
                {
                    GALAXISUpdateTaskStatus? gALAXIS = TaskDTO.Serialize().DeserializeObject<GALAXISUpdateTaskStatus>();
                    //GALAXISUpdateTaskStatus? gALAXIS = TaskDTO.Serialize().DeserializeObject<GALAXISUpdateTaskStatus>();
                    if (gALAXIS == null) throw new Exception("参数转换失败!");
                    var task = BaseDal.QueryFirst(x => x.WMSTaskNum == gALAXIS.taskId);
                    if (task == null) throw new Exception($"未找到任务,任务编号【{gALAXIS.taskId}】");
@@ -64,9 +69,13 @@
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
                return WebResponseContent.Instance.Error(ex.Message);
            }
        }
            finally
            {
                _trackloginfoService.AddTrackLog(gALAXIS, content, "下发凯乐士AGV任务", "", "");
            }
        }
        #endregion
        #region ä»»åŠ¡çŠ¶æ€è½¬æ¢
@@ -85,6 +94,7 @@
                        6 => TaskStatusEnum.TaskTypeError,
                        7 => TaskStatusEnum.ParameterError,
                        8 => TaskStatusEnum.RCSError,
                        10 => TaskStatusEnum.Takeing,
                        13 => TaskStatusEnum.Cancel,
                        _ => throw new ArgumentOutOfRangeException(
                            nameof(status),
@@ -107,7 +117,7 @@
            {
                throw new Exception(ex.Message);
            }
        }
        }
        #endregion
        #region ä»»åŠ¡èµ·ç‚¹å®Œæˆ
@@ -133,7 +143,7 @@
                Db.Ado.RollbackTran();
                throw new Exception(ex.Message);
            }
        }
        }
        #endregion
        #region ä»»åŠ¡å®Œæˆ
@@ -147,10 +157,39 @@
        {
            try
            {
                WMSInOutBoundCompleteFeedback boundCompleteFeedback = new WMSInOutBoundCompleteFeedback();
                WMSReturn agvContent = null;
                dt_Task.TaskState = TaskStatusEnum.Finish.ObjToInt();
                Dt_ApiInfo? apiInfo = _apiInfoService.Repository.QueryFirst(x => x.ApiCode == nameof(WMSInOutBoundCompleteFeedback));
                if (apiInfo == null) dt_Task.ExceptionMessage = "未找到出入库完成反馈WMS接口配置信息!请检查接口配置";
                else
                {
                    boundCompleteFeedback.taskCode = dt_Task.WMSTaskNum;
                    boundCompleteFeedback.containerCode = dt_Task.PalletCode;
                    boundCompleteFeedback.fromStationCode = dt_Task.SourceAddress;
                    boundCompleteFeedback.toLocationCode = dt_Task.TargetAddress;
                    switch (deviceTypeEnum)
                    {
                        case DeviceTypeEnum.GALAXIS:
                            boundCompleteFeedback.businessType = 1;
                            break;
                        case DeviceTypeEnum.YuanLiJuHe:
                            boundCompleteFeedback.businessType = 2;
                            break;
                    }
                    boundCompleteFeedback.completeType = 1;
                    string response = HttpHelper.Post(apiInfo.ApiAddress, boundCompleteFeedback.Serialize());
                    agvContent = response.DeserializeObject<WMSReturn>();
                    if (agvContent.code != 0) dt_Task.ExceptionMessage = agvContent.msg;
                }
                Db.Ado.BeginTran();
                UpdateLocationStatus(dt_Task.TargetAddress, deviceTypeEnum, LocationStatusEnum.InStock);
                BaseDal.DeleteAndMoveIntoHty(dt_Task, OperateTypeEnum.自动完成);
                if (agvContent != null && agvContent.code == 0)
                    BaseDal.DeleteAndMoveIntoHty(dt_Task, OperateTypeEnum.自动完成);
                else
                    BaseDal.UpdateData(dt_Task);
                Db.Ado.CommitTran();
                return WebResponseContent.Instance.OK();
            }
@@ -159,7 +198,7 @@
                Db.Ado.RollbackTran();
                throw new Exception(ex.Message);
            }
        }
        }
        #endregion
        #region æ›´æ–°è´§ä½çŠ¶æ€
@@ -211,7 +250,7 @@
            {
                throw new Exception(ex.Message);
            }
        }
        }
        #endregion
    }
}