dengjunjie
2026-03-12 38072f522dd49da33b22f604fb6b262e884b8a32
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Metadata;
using System.Text;
using System.Threading.Tasks;
using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_DTO;
using WIDESEAWCS_DTO.RGV.FOURBOT;
using WIDESEAWCS_Model.Models;
 
namespace WIDESEAWCS_Tasks
{
    public partial class TaskJob
    {
 
        #region 下发凯乐士AGV任务
        public void SendGALAXISTask(List<Dt_Task> tasks)
        {
            WebResponseContent content = new WebResponseContent(); // 创建响应对象
            GALAXISTaskInfo gALAXISTaskInfo = new();
            try
            {
                gALAXISTaskInfo.groupId = DateTime.Now.ToString("yyMMddHHmmss");
                gALAXISTaskInfo.msgTime = DateTime.Now.ToString();
                gALAXISTaskInfo.tasks = new List<GALAXISTask>();
                foreach (var task in tasks)
                {
                    GALAXISTask gALAXISTask = new GALAXISTask()
                    {
                        taskId = task.WMSTaskNum,
                        taskType = task.TaskType == (int)TaskTypeEnum.MLInbound ? 0 : 1,
                        barCode = task.PalletCode,
                        endNode = task.TargetAddress,
                        startNode = task.SourceAddress,
                        priorityCode = task.Grade
                    };
                    gALAXISTaskInfo.tasks.Add(gALAXISTask);
                }
                Dt_ApiInfo? apiInfo = _apiInfoService.Repository.QueryFirst(x => x.ApiCode == nameof(GALAXISTaskInfo)) ?? throw new Exception("未找到凯乐士AGV任务下发接口配置信息!请检查接口配置");
                string response = HttpHelper.Post(apiInfo.ApiAddress, gALAXISTaskInfo.Serialize());
                GALAXISReturn agvContent = response.DeserializeObject<GALAXISReturn>();
                content.OK(data: agvContent);
                if (agvContent.success)
                {
                    if (agvContent.data.returnStatus != 0) throw new Exception(agvContent.data.returnInfo);
                    tasks.ForEach(task =>
                    {
                        task.TaskState = (int)TaskStatusEnum.Execut;
                    });
                    content.OK();
                    _taskService.UpdateData(tasks);
                }
            }
            catch (Exception ex)
            {
                content.Error(ex.Message);
                //WriteError(nameof(TaskJob), ex.Message, ex);
            }
            finally
            {
                _trackloginfoService.AddTrackLog(gALAXISTaskInfo, content, "下发凯乐士AGV任务","","");
                //dt_trackloginfoService.Instance.AddTrackLog(outTaskInfo, content, "接收宇航WMS出库任务下发", "", $"{msg},变更结果:{content.Status}");
            }
        }
        #endregion
    }
}