1
yanjinhui
2026-03-24 24ac6e3688db3dbb68eb6a53dd6c6fc9f8e12d6b
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/HKTaskMethods.cs
@@ -13,6 +13,7 @@
using WIDESEAWCS_DTO;
using WIDESEAWCS_DTO.AGV.HIKROBOT;
using System.Diagnostics.CodeAnalysis;
using System.Reflection.PortableExecutable;
namespace WIDESEAWCS_TaskInfoService
{
@@ -180,7 +181,7 @@
                // åˆ›å»ºHeaders字典
                var headers = new Dictionary<string, string>
                {
                    { "X-lr-request-id", DateTimeOffset.Now.ToUnixTimeSeconds().ToString() }
                    { "X-lr-request-id", DateTimeOffset.Now.ToUnixTimeSeconds().ToString()+task.TaskNum }
                    // å¦‚果需要其他Header,可以继续添加
                    // { "Content-Type", "application/json" }
                };
@@ -220,7 +221,7 @@
            HIKROBOTTaskSubmit hIKROBOTTaskSubmit = new HIKROBOTTaskSubmit();
            try
            {
                var tasktype = (TaskTypeEnum)Enum.GetValues(typeof(TaskTypeEnum)).GetValue(task.TaskType-1);
                var tasktype = (TaskTypeEnum)Enum.GetValues(typeof(TaskTypeEnum)).GetValue(task.TaskType - 1);
                hIKROBOTTaskSubmit.initPriority = task.Grade;
                hIKROBOTTaskSubmit.robotTaskCode = task.WMSTaskNum;
@@ -244,6 +245,8 @@
                    case TaskTypeEnum.RK3F:
                    case TaskTypeEnum.CK3F:
                    case TaskTypeEnum.F02:
                    case TaskTypeEnum.F03:
                    case TaskTypeEnum.F04:
                        {
                            TargetRouteDto target = new TargetRouteDto()
                            {
@@ -322,5 +325,65 @@
            }
            return hIKROBOTTaskSubmit;
        }
        /// <summary>
        /// æµ·åº·AGV任务继续执行
        /// </summary>
        /// <param name="TaskCode">任务号</param>
        /// <returns></returns>
        public WebResponseContent Hikvisiontaskscontinue(string TaskCode, string Address = null)
        {
            WebResponseContent content = new WebResponseContent();
            HIKROBOTReturn hIKROBOTReturn = null;
            HIKROBOTTaskContinue hIKROBOTTaskContinue = null;
            try
            {
                // 1. å‚数验证
                if (string.IsNullOrWhiteSpace(TaskCode))
                {
                    throw new Exception("任务编码不能为空");
                }
                Dt_ApiInfo? apiInfo = _apiInfoService.Repository.QueryFirst(x => x.ApiCode == nameof(HIKROBOTTaskContinue)) ?? throw new Exception("未找到海康AGV继续执行接口配置信息!请检查接口配置");
                hIKROBOTTaskContinue = new HIKROBOTTaskContinue()
                {
                    triggerCode = TaskCode,
                    triggerType = "TASK",//固定值
                    targetRoute = string.IsNullOrEmpty(Address) ? null :
                    new TargetRouteDto()
                    {
                        code = Address,
                        type = "SITE",
                    }
                };
                var headers = new Dictionary<string, string>
                {
                    { "X-lr-request-id", DateTimeOffset.Now.ToUnixTimeSeconds().ToString()+TaskCode }
                };
                string response = HttpHelper.Post(apiInfo.ApiAddress, hIKROBOTTaskContinue.Serialize(), headers: headers);
                hIKROBOTReturn = response.DeserializeObject<HIKROBOTReturn>();
                if (hIKROBOTReturn.code == "SUCCESS")
                {
                    var data = hIKROBOTReturn.data.ToString().DeserializeObject<HIKROBOTReturnData>();
                    content.OK(data: data);
                }
                else
                {
                    throw new Exception(hIKROBOTReturn.message);
                }
            }
            catch (Exception ex)
            {
                content.Error(ex.Message);
            }
            finally
            {
                _trackloginfoService.AddTrackLog(hIKROBOTTaskContinue, content, "海康AGV继续执行任务", "", hIKROBOTReturn.message);
            }
            return content;
        }
    }
}