1
dengjunjie
2026-02-26 8d88e4d037aa5b6ce032f0b71417baa2845bb5d6
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_DTO;
using WIDESEAWCS_Model.Models;
 
namespace WIDESEAWCS_Tasks
{
    public partial class TaskJob
    {
        #region 下发任务
        /// <summary>
        /// 下发任务
        /// </summary>
        public void SendTask()
        {
            try
            {
                var newTasks = _taskService.Db.Queryable<Dt_Task>().Where(x => x.TaskState == (int)TaskStatusEnum.New).ToList();
                if (newTasks.Count > 0)
                {
                    #region 查找凯乐士任务
                    var Tasks = newTasks.Where(x => x.TaskType == (int)TaskTypeEnum.MLInbound || x.TaskType == (int)TaskTypeEnum.MLOutbound).ToList();
                    if (Tasks.Count > 0) SendGALAXISTask(Tasks);
                    #endregion
                }
            }
            catch (Exception ex)
            {
                WriteError(nameof(TaskJob), ex.Message, ex);
            }
        }
        #endregion
 
        #region 下发待执行任务
        /// <summary>
        /// 下发待执行任务
        /// </summary>
        public void SendWaitToTask()
        {
            try
            {
 
            }
            catch (Exception ex)
            {
                WriteError(nameof(TaskJob), ex.Message, ex);
            }
        }
        #endregion
 
        #region 下发凯乐士AGV任务
        public void SendGALAXISTask(List<Dt_Task> tasks)
        {
            GALAXISTaskInfo gALAXISTaskInfo = new GALAXISTaskInfo();
            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>();
                if (agvContent.success)
                {
                    if (agvContent.data.returnStatus != 0) throw new Exception(agvContent.data.returnInfo);
                    tasks.ForEach(task =>
                    {
                        task.TaskState = (int)TaskStatusEnum.Execut;
                    });
                    _taskService.UpdateData(tasks);
                }
            }
            catch (Exception ex)
            {
                WriteError(nameof(TaskJob), ex.Message, ex);
            }
        }
        #endregion
 
        #region 下发四向车任务
        public void SendRGVTask(List<Dt_Task> tasks)
        {
 
        }
        #endregion
 
        #region 下发海康AGV任务
        public void SendHIKROBOTTask(List<Dt_Task> tasks)
        {
 
        }
        #endregion
    }
}