helongyang
14 小时以前 dc06f58d8ed537555fd529551180f43a0586ec3f
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
using Autofac.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_DTO.Agv;
using WIDESEAWCS_Common.APIEnum;
using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_DTO.Agv;
 
namespace WIDESEAWCS_TaskInfoService
{
    public partial class TaskService
    {
        /// <summary>
        /// 发送AGV任务 
        /// </summary>
        /// <param name="taskModel"></param>
        /// <returns></returns>
        public WebResponseContent AgvSendTask(AgvTaskDTO taskModel, APIEnum SendTask = APIEnum.Agv_CSJSendTask)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                string? apiAddress = apiInfos.FirstOrDefault(x => x.ApiCode == SendTask.ToString())?.ApiAddress;
                if (string.IsNullOrEmpty(apiAddress))
                    return WebResponseContent.Instance.Error($"未找到发送AGV任务接口,请检查接口配置");
                string response = HttpHelper.Post(apiAddress, taskModel.Serialize());
                AgvResponseContent agvContent = response.DeserializeObject<AgvResponseContent>();
                if (agvContent.Code == "0")
                {
                    content.OK(data: agvContent.Data);
                }
                else
                {
                    content.Error(agvContent.Message);
                }
            }
            catch (Exception ex)
            {
                content.Error(ex.Message);
            }
            return content;
        }
        /// <summary>
        /// 安全信号申请 AGV-WCS
        /// </summary>
        public AgvResponseContent AgvSecureApply(AgvSecureApplyDTO secureApplyModel)
        {
            return new AgvResponseContent();
        }
        /// <summary>
        /// 安全信号回复 WCS-AGV  //AGV任务继续执行
        /// </summary>
        /// <param name="secureModel"></param>
        /// <returns></returns>
        public WebResponseContent AgvSecureReply(AgvSecureReplyDTO secureReplyModel, APIEnum SecureReply = APIEnum.Agv_CSJSecureReply)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                string? apiAddress = apiInfos.FirstOrDefault(x => x.ApiCode == SecureReply.ToString())?.ApiAddress;
                if (string.IsNullOrEmpty(apiAddress))
                    return WebResponseContent.Instance.Error($"未找到发送AGV任务接口,请检查接口配置");
                string response = HttpHelper.Post(apiAddress, secureReplyModel.Serialize());
                AgvResponseContent agvContent = response.DeserializeObject<AgvResponseContent>();
                if (agvContent.Code == "0")
                {
                    content.OK(agvContent.Message);
                }
                else
                {
                    content.Error(agvContent.Message);
                }
            }
            catch (Exception ex)
            {
                content.Error(ex.Message);
            }
            return content;
        }
        /// <summary>
        /// CTU取消任务
        /// </summary>
        public WebResponseContent AgvBoxApplyPass(AgvCTUCancelDTO applyPassDTO, APIEnum SecureReply = APIEnum.AGV_CTUCancelTask)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                string? apiAddress = apiInfos.FirstOrDefault(x => x.ApiCode == SecureReply.ToString())?.ApiAddress;
                if (string.IsNullOrEmpty(apiAddress))
                    return WebResponseContent.Instance.Error($"未找到AGV取消任务接口,请检查接口配置");
                string response = HttpHelper.Post(apiAddress, applyPassDTO.Serialize());
                AgvResponseContent agvContent = response.DeserializeObject<AgvResponseContent>();
                if (agvContent.Code == "0")
                {
                    content.OK(agvContent.Message);
                }
                else
                {
                    content.Error(agvContent.Message);
                }
            }
            catch (Exception ex)
            {
                content.Error(ex.Message);
            }
            return content;
        }
        /// <summary>
        /// AGV成品取放货通知
        /// </summary>
        public WebResponseContent AgvBoxApplyPass(AGVBoxApplyPassDTO applyPassDTO, APIEnum SecureReply = APIEnum.AGV_CPBoxApplyPass)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                string? apiAddress = apiInfos.FirstOrDefault(x => x.ApiCode == SecureReply.ToString())?.ApiAddress;
                if (string.IsNullOrEmpty(apiAddress))
                    return WebResponseContent.Instance.Error($"未找到发送AGV任务接口,请检查接口配置");
                string response = HttpHelper.Post(apiAddress, applyPassDTO.Serialize());
                AgvResponseContent agvContent = response.DeserializeObject<AgvResponseContent>();
                if (agvContent.Code == "0")
                {
                    content.OK(agvContent.Message);
                }
                else
                {
                    content.Error(agvContent.Message);
                }
            }
            catch (Exception ex)
            {
                content.Error(ex.Message);
            }
            return content;
        }
        public WebResponseContent AgvPreScheduleTask(AgvScheduleTaskDTO scheduleTaskDTO, APIEnum ScheduleTask = APIEnum.AGV_CTUScheduleTaskTask)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                string? apiAddress = apiInfos.FirstOrDefault(x => x.ApiCode == ScheduleTask.ToString())?.ApiAddress;
                if (string.IsNullOrEmpty(apiAddress))
                    return WebResponseContent.Instance.Error($"未找到发送AGV任务接口,请检查接口配置");
                string response = HttpHelper.Post(apiAddress, scheduleTaskDTO.Serialize());
                AgvResponseContent agvContent = response.DeserializeObject<AgvResponseContent>();
                if (agvContent.Code == "0")
                {
                    content.OK(agvContent.Message);
                }
                else
                {
                    content.Error(agvContent.Message);
                }
            }
            catch (Exception ex)
            {
                content.Error(ex.Message);
            }
            return content;
        }
        /// <summary>
        /// AGV任务状态刷新/AGV任务完成
        /// </summary>
        /// <param name="agvUpdateModel"></param>
        /// <returns></returns>
        public AgvResponseContent AgvUpdateTask(AgvUpdateDTO agvUpdateModel)
        {
            return new AgvResponseContent();
        }
        public WebResponseContent AgvPodBerthAndMat(AgvPodBerthAndMatDTO agvPodModel, APIEnum PodBerthAndMat = APIEnum.Agv_CSJPodBerthAndMat)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                string? apiAddress = apiInfos.FirstOrDefault(x => x.ApiCode == PodBerthAndMat.ToString())?.ApiAddress;
                if (string.IsNullOrEmpty(apiAddress))
                    return WebResponseContent.Instance.Error($"未找到发送AGV任务接口,请检查接口配置");
                string response = HttpHelper.Post(apiAddress, agvPodModel.Serialize());
                AgvResponseContent agvContent = response.DeserializeObject<AgvResponseContent>();
                if (agvContent.Code == "1")
                {
                    content.OK(agvContent.Message);
                }
                else
                {
                    content.Error(agvContent.Message);
                }
            }
            catch (Exception ex)
            {
                content.Error(ex.Message);
            }
            return content;
        }
    }
}