huangxiaoqiang
7 天以前 c3877b2ebec19f473f45e8c2245926f65d2a3948
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
using LogLibrary.Log;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_DTO.AGV;
using WIDESEA_IServices;
using WIDESEA_IStorageBasicRepository;
using WIDESEA_IStorageSocketServices;
using WIDESEA_IStorageTaskRepository;
using WIDESEA_IStorageTaskServices;
using WIDESEA_IStoragIntegrationServices;
using WIDESEA_Model.Models.AGV;
using WIDESEA_Repository;
using WIDESEA_StorageSocketServices;
using WIDESEAWCS_BasicInfoRepository;
using WIDESEAWCS_Model.Models;
using static WIDESEAWCS_BasicInfoService.Dt_StationManagerService;
 
namespace WIDESEA_StoragIntegrationServices
{
    public partial class AGVService : IAGVService
    {
        private readonly ILocationInfoRepository _locationRepository;
        private readonly IDt_TaskRepository BaseDal;
        private readonly IDt_TaskService _taskService;
        private readonly IDt_StationManagerRepository _stationManagerRepository;
        private readonly LogFactory LogFactory = new LogFactory();
        public SocketClientService _Socket { get; set; }
        private readonly IMapper _mapper;
        private readonly IDt_DeviceInfoRepository _deviceInfoRepository;
        private readonly IDt_HandAutomaticRepository _handAutomaticRepository;
        private readonly IDt_ErrorDescriptionRepository _descriptionRepository;
 
        public AGVService(ILocationInfoRepository locationRepository, IDt_TaskRepository taskRepository, IDt_StationManagerRepository stationManagerRepository, IDt_DeviceInfoRepository deviceInfoRepository, IMapper mapper, SocketClientService socketClientService, IDt_TaskService taskService, IDt_HandAutomaticRepository handAutomaticRepository, IDt_ErrorDescriptionRepository descriptionRepository)
        {
            _locationRepository = locationRepository;
            BaseDal = taskRepository;
            _stationManagerRepository = stationManagerRepository;
            _deviceInfoRepository = deviceInfoRepository;
            _mapper = mapper;
            _Socket = socketClientService;
            _taskService = taskService;
            _handAutomaticRepository = handAutomaticRepository;
            _descriptionRepository = descriptionRepository;
        }
        #region 外部接口方法
 
        /// <summary>
        /// 请求入库任务
        /// </summary>
        /// <param name="PallteCode"></param>
        /// <param name="SourceAddress"></param>
        /// <returns></returns>
        public WebResponseContent RequestInTask(AGVDTO aGVDTO)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                var location = _locationRepository.QueryData(x => x.LocationStatus == (int)LocationEnum.Free).ToList();
                if (location.Count == 0)
                {
                    return content.Error("库内无可用库位");
                }
                Dt_StationManager Instation = _stationManagerRepository.QueryFirst(x => x.stationName == aGVDTO.SourceAddress && x.stationType == 1);
                List<Dt_StationManager> Outstation = _stationManagerRepository.QueryData(x => x.stationType == 2).ToList();
                if (Instation == null)
                {
                    return content.Error("未找到入库站台信息");
                }
                Dt_Task task = BaseDal.QueryFirst(x => x.PalletCode == aGVDTO.PalletCode);
                if (task != null)
                {
                    return content.Error("该托盘已存在任务");
                }
                //StationStatus stationOut = _Socket.GetStationStatus("B001");
                List<OutStationStatus> outStationStatus = new List<OutStationStatus>();
                //List<OutStationStatus> outStationStatus = _Socket.GetOutStationStatus(stationOut);
                #region
                var taskOutStationO = BaseDal.QueryFirst(x => x.SourceAddress == "B001::1" || x.TargetAddress == "B001::1");
                var taskOutStationT = BaseDal.QueryFirst(x => x.SourceAddress == "B001::2" || x.TargetAddress == "B001::2");
                outStationStatus.Add(new OutStationStatus()
                {
                    StationName = "04",
                    StationEnable = aGVDTO.WorkstationO == "1" ? "0" : "1",
                    IsDistributionTask = taskOutStationO == null ? "0" : "1",
                    Spare1 = "00"
                });
                outStationStatus.Add(new OutStationStatus()
                {
                    StationName = "03",
                    StationEnable = aGVDTO.WorkstationT == "1" ? "0" : "1",
                    IsDistributionTask = taskOutStationT == null ? "0" : "1",
                    Spare1 = "00",
 
                });
                #endregion
                AGVStatusRespone status = _Socket.GetAGVStatus();
                HOSTAGVStatus AgvStatus = new HOSTAGVStatus()
                {
                    RuntimeStatus = _Socket.CapitalizeFirstLetter(status.RuntimeStatus),
                    AutoStatus = status.AutoStatus == "MaintenanceMode" ? "1" : "0",
                    Ready = status.AutoStatus == "MaintenanceMode" ? "0" : "1",
                };
                InStationStatus inStationStatus = new InStationStatus()
                {
                    StationName = Instation.HostName,
                    StationEnable = "0",
                    IsDistributionTask = "0",
                    PallteCode = aGVDTO.PalletCode,
                };
                _Socket.DeviceRequestInbound(AgvStatus, outStationStatus, inStationStatus);
 
                LogFactory.GetLog("入库请求").InfoFormat(true, $"请求参数:{JsonConvert.SerializeObject(aGVDTO)}", "");
                return content.OK("已下发入库任务");
            }
            catch (Exception ex)
            {
                return content.Error(ex.Message);
            }
 
 
        }
 
        public WebResponseContent ReceiveAGVRuntimeStatus(AGVStatus Status)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                //var HandAutomatic = _handAutomaticRepository.QueryFirst(x => true && x.HandAutomatic == "Automatic");
                //if (HandAutomatic == null)
                //{
                //    _Socket.DeviceAutoStatusReport("1");
                //    return content.OK();
                //}
                Dt_DeviceInfo device = _deviceInfoRepository.QueryFirst(x => x.DeviceName == Status.AGVName);
                if (device != null)
                {
                    if (device.RuntimeStatus != Status.RuntimeStatus)
                    {
                        device.RuntimeStatus = Status.RuntimeStatus;
                        device.AutoStatus = Status.AutoStatus;
                        _deviceInfoRepository.UpdateData(device);
                        switch (Status.RuntimeStatus)
                        {
                            case "Run":
                                //运行
                                _Socket.DeviceStateReport("R");
                                Thread.Sleep(1000);
                                _Socket.JobReady("0");
                                break;
                            case "Idle":
                                //空闲
                                _Socket.DeviceStateReport("I");
                                _Socket.JobReady("1");
                                break;
                            case "Trouble":
                                //故障
                                _Socket.DeviceStateReport("T");
                                Thread.Sleep(1000);
                                _Socket.JobReady("0");
                                break;
                            case "Pause":
                                //暂停
                                _Socket.DeviceStateReport("S");
                                Thread.Sleep(1000);
                                _Socket.JobReady("0");
                                break;
                            case "Charge":
                                //充电
                                _Socket.DeviceStateReport("C");
                                Thread.Sleep(1000);
                                _Socket.JobReady("0");
                                break;
                            case "PowerOn":
                                //开机
                                _Socket.DeviceStateReport("P");
                                Thread.Sleep(1000);
                                _Socket.JobReady("0");
                                break;
                            case "PowerOFF":
                                //关机
                                _Socket.DeviceStateReport("O");
                                Thread.Sleep(1000);
                                _Socket.JobReady("0");
                                break;
                            default: break;
                        }
                    }
                    if (device.AutoStatus != Status.AutoStatus)
                    {
                        device.RuntimeStatus = Status.RuntimeStatus;
                        device.AutoStatus = Status.AutoStatus;
                        _deviceInfoRepository.UpdateData(device);
                        switch (Status.AutoStatus)
                        {
                            case "MaintenanceMode":
                                //手动
                                _Socket.DeviceAutoStatusReport("1");
                                Thread.Sleep(500);
                                break;
                            case "ControlMode":
                                //自动
                                _Socket.DeviceAutoStatusReport("0");
                                Thread.Sleep(500);
                                break;
                            default: break;
                        }
                    }
                }
                else
                {
                    Dt_DeviceInfo deviceInfo = new Dt_DeviceInfo()
                    {
                        DeviceName = Status.AGVName,
                        RuntimeStatus = Status.RuntimeStatus,
                        AutoStatus = Status.AutoStatus,
                    };
                    _deviceInfoRepository.AddData(deviceInfo);
                }
 
                LogFactory.GetLog("AGV状态变更").InfoFormat(true, $"请求参数:{JsonConvert.SerializeObject(Status)}", "");
                return content.OK();
            }
            catch (Exception ex)
            {
                return content.Error(ex.Message);
            }
        }
 
 
        public WebResponseContent AGVStartOrEndJob(AGVDTO aGVDTO)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == Convert.ToInt32(aGVDTO.TaskNum));
                if (task != null)
                {
                    switch (task.TaskType)
                    {
                        case (int)TaskInboundTypeEnum.Inbound:
                            //入库
                            var station = _stationManagerRepository.QueryFirst(x => x.stationName == task.SourceAddress);
                            if (aGVDTO.Status == "Start")
                            {
                                if (task.Roadway == "PDA")
                                {
                                    _taskService.TaskStatus(task);
                                    return content.OK();
                                }
                                else
                                {
                                    _Socket.JobStartOrEnd(aGVDTO.Status.Substring(0, 1), "0000" + station.HostName, task.TargetAddress, "I", task.PalletCode);
                                    task.TaskState = (int)TaskInStatusEnum.AGV_InExecuting;
                                }
 
                            }
                            else if (aGVDTO.Status == "Loadel")
                            {
                                _Socket.PalletActionReport(aGVDTO.Status.Substring(0, 1), "0000" + station.HostName, task.TargetAddress, "I", task.PalletCode);
                            }
                            else
                            {
                                if (task.Roadway == "PDA")
                                {
                                    _Socket.PalletActionReportPDA("0000" + station.HostName, task.TargetAddress, "I", task.PalletCode);
                                }
                                else
                                {
                                    _Socket.PalletActionReport(aGVDTO.Status.Substring(0, 1), "0000" + station.HostName, task.TargetAddress, "I", task.PalletCode);
                                    Thread.Sleep(2000);
                                    _Socket.PalletActionReport("0000" + station.HostName, task.TargetAddress, "I", task.PalletCode);
                                }
                                task.TaskState = (int)TaskInStatusEnum.AGV_InFinish;
                                _taskService.CompleteInboundTask(task);
                            }
                            break;
                        case (int)TaskOutboundTypeEnum.Outbound:
                            //出库
                            var stationOut = _stationManagerRepository.QueryFirst(x => x.stationName == task.TargetAddress);
                            if (aGVDTO.Status == "Start")
                            {
                                if (task.Roadway == "PDA")
                                {
                                    _taskService.TaskStatus(task);
                                    return content.OK();
                                }
                                else
                                {
                                    _Socket.JobStartOrEnd(aGVDTO.Status.Substring(0, 1), task.SourceAddress, "0000" + stationOut.HostName, "O", task.PalletCode);
                                    task.TaskState = (int)TaskOutStatusEnum.AGV_OutExecuting;
                                }
                            }
                            else if (aGVDTO.Status == "Loadel")
                            {
                                _Socket.PalletActionReport(aGVDTO.Status.Substring(0, 1), task.SourceAddress, "0000" + stationOut.HostName, "O", task.PalletCode);
                            }
                            else
                            {
                                if (task.Roadway == "PDA")
                                {
                                    _Socket.PalletActionReportPDA(task.SourceAddress, "0000" + stationOut.HostName, "O", task.PalletCode);
                                }
                                else
                                {
                                    _Socket.PalletActionReport(aGVDTO.Status.Substring(0, 1), task.SourceAddress, "0000" + stationOut.HostName, "O", task.PalletCode);
                                    Thread.Sleep(2000);
                                    _Socket.PalletActionReport(task.SourceAddress, "0000" + stationOut.HostName, "O", task.PalletCode);
                                }
                                task.TaskState = (int)TaskOutStatusEnum.AGV_OutFinish;
                                _taskService.CompleteOutboundTask(task);
                            }
                            break;
                        case (int)TaskRelocationTypeEnum.Relocation:
                            if (aGVDTO.Status == "Start")
                            {
                                if (task.Roadway == "PDA")
                                {
                                    _taskService.TaskStatus(task);
                                    return content.OK();
                                }
                                else
                                {
                                    _Socket.JobStartOrEnd(aGVDTO.Status.Substring(0, 1), task.SourceAddress, task.TargetAddress, "R", task.PalletCode);
                                    task.TaskState = (int)TaskRelocationStatusEnum.AGV_RelocationExecuting;
                                }
                            }
                            else if (aGVDTO.Status == "Loadel")
                            {
                                _Socket.PalletActionReport(aGVDTO.Status.Substring(0, 1), task.SourceAddress, task.TargetAddress, "R", task.PalletCode);
                            }
                            else
                            {
                                if (task.Roadway == "PDA")
                                {
                                    _Socket.PalletActionReportPDA(task.SourceAddress, task.TargetAddress, "R", task.PalletCode);
                                }
                                else
                                {
                                    _Socket.PalletActionReport(aGVDTO.Status.Substring(0, 1), task.SourceAddress, task.TargetAddress, "R", task.PalletCode);
                                    Thread.Sleep(2000);
                                    _Socket.PalletActionReport(task.SourceAddress, task.TargetAddress, "R", task.PalletCode);
                                }
                                task.TaskState = (int)TaskRelocationStatusEnum.AGV_RelocationFinish;
                                _taskService.CompleteRelocationboundTask(task);
                            }
                            break;
                        case (int)TaskStationTypeEnum.StationToStation:
                            var stationIn = _stationManagerRepository.QueryFirst(x => x.stationName == task.SourceAddress);
                            var stationout = _stationManagerRepository.QueryFirst(x => x.stationName == task.TargetAddress);
                            if (aGVDTO.Status == "Start")
                            {
                                if (task.Roadway == "PDA")
                                {
                                    _taskService.TaskStatus(task);
                                    return content.OK();
                                }
                                else
                                {
                                    _Socket.JobStartOrEnd(aGVDTO.Status.Substring(0, 1), "0000" + stationIn.HostName, "0000" + stationout.HostName, "S", task.PalletCode);
                                    task.TaskState = (int)TaskOutStatusEnum.AGV_OutExecuting;
                                }
                            }
                            else if (aGVDTO.Status == "Loadel")
                            {
                                _Socket.PalletActionReport(aGVDTO.Status.Substring(0, 1), "0000" + stationIn.HostName, "0000" + stationout.HostName, "S", task.PalletCode);
                            }
                            else
                            {
                                if (task.Roadway == "PDA")
                                {
                                    _Socket.PalletActionReportPDA("0000" + stationIn.HostName, "0000" + stationout.HostName, "S", task.PalletCode);
                                }
                                else
                                {
                                    _Socket.PalletActionReport(aGVDTO.Status.Substring(0, 1), "0000" + stationIn.HostName, "0000" + stationout.HostName, "S", task.PalletCode);
                                    Thread.Sleep(2000);
                                    _Socket.PalletActionReport("0000" + stationIn.HostName, "0000" + stationout.HostName, "S", task.PalletCode);
                                }
                                task.TaskState = (int)TaskOutStatusEnum.AGV_OutFinish;
                                _taskService.TaskMoveHty(task);
                            }
                            break;
                        case (int)TaskFireAlarmTypeEnum.FireAlarmOut:
                            if (aGVDTO.Status == "Start")
                            {
                                _taskService.AddStcokHty(task.PalletCode, task.SourceAddress);
                                task.TaskState = (int)TaskFireAlarmStatusEnum.AGV_FireAlarmExecuting;
                                BaseDal.Update(task);
                            }
                            else if (aGVDTO.Status == "Loadel")
                            {
 
                            }
                            else
                            {
 
                                var stationFireAlarm = _stationManagerRepository.QueryFirst(x => x.stationName == task.TargetAddress);
                                if (task.Roadway == "PDA")
                                {
                                    _Socket.PalletActionReportFrie(task.SourceAddress, "0000" + stationFireAlarm.HostName, "F", task.PalletCode); ;
                                }
                                task.TaskState = (int)TaskFireAlarmStatusEnum.AGV_FireAlarmFinish;
                                _taskService.TaskMoveHty(task);
                            }
                            break;
                        case (int)TaskOutboundTypeEnum.OutQuality:
                            //抽检
                            var stationC = _stationManagerRepository.QueryFirst(x => x.stationName == task.TargetAddress);
                            if (aGVDTO.Status == "Start")
                            {
                                if (task.Roadway == "PDA")
                                {
                                    _taskService.TaskStatus(task);
                                    return content.OK();
                                }
                                else
                                {
                                    _Socket.JobStartOrEnd(aGVDTO.Status.Substring(0, 1), task.SourceAddress, "0000" + stationC.HostName, "C", task.PalletCode);
                                    task.TaskState = (int)TaskOutStatusEnum.AGV_OutExecuting;
                                }
                            }
                            else if (aGVDTO.Status == "Loadel")
                            {
                                if (task.Roadway == "PDA")
                                {
                                    return content.OK();
                                }
                                _Socket.PalletActionReport(aGVDTO.Status.Substring(0, 1), task.SourceAddress, "0000" + stationC.HostName, "C", task.PalletCode);
                            }
                            else
                            {
                                if (task.Roadway == "PDA")
                                {
                                    _taskService.TaskComplete(task.TaskNum);
                                    _Socket.PalletActionReportPDA(task.SourceAddress, "0000" + stationC.HostName, "O", task.PalletCode);
                                }
                                else
                                {
                                    _Socket.PalletActionReport(aGVDTO.Status.Substring(0, 1), task.SourceAddress, "0000" + stationC.HostName, "C", task.PalletCode);
                                    Thread.Sleep(2000);
                                    _Socket.PalletActionReport(task.SourceAddress, "0000" + stationC.HostName, "C", task.PalletCode);
                                    task.TaskState = (int)TaskOutStatusEnum.AGV_OutFinish;
                                    _taskService.CompleteOutboundTask(task);
                                }
                            }
                            break;
                        case (int)TaskInboundTypeEnum.InQuality:
                            //抽检
                            if (aGVDTO.Status == "Start")
                            {
                                if (task.Roadway == "PDA")
                                {
                                    _taskService.TaskStatus(task);
                                    return content.OK();
                                }
                            }
                            else if (aGVDTO.Status == "Loadel")
                            {
                                return content.OK();
                            }
                            else
                            {
                                if (task.Roadway == "PDA")
                                {
                                    _taskService.TaskComplete(task.TaskNum);
                                }
                            }
                            break;
                        default: break;
                    }
                    BaseDal.Update(task);
                    LogFactory.GetLog("AGV动作状态变更").InfoFormat(true, $"请求参数:{JsonConvert.SerializeObject(aGVDTO)}", "");
                    return content.OK();
                }
                else
                {
                    return content.Error("未找到任务!");
                }
            }
            catch (Exception ex)
            {
                return content.Error(ex.Message);
            }
        }
 
 
        public WebResponseContent DeviceErrorResponse(AGVDTO aGVDTO)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                LogFactory.GetLog("AGV异常信息").InfoFormat(true, $"请求参数:{JsonConvert.SerializeObject(aGVDTO)}", "");
                var task = BaseDal.QueryFirst(x => x.TaskNum == Convert.ToInt32(aGVDTO.TaskNum));
                if (task != null)
                {
 
                    string HostType = string.Empty;
                    if (task.TaskType == (int)TaskInboundTypeEnum.Inbound)
                    {
                        HostType = "I";
                    }
                    else if (task.TaskType == (int)TaskOutboundTypeEnum.Outbound)
                    {
                        HostType = "O";
                    }
                    else if (task.TaskType == (int)TaskOutboundTypeEnum.OutQuality)
                    {
                        HostType = "C";
                    }
                    else if (task.TaskType == (int)TaskRelocationTypeEnum.Relocation)
                    {
                        HostType = "R";
                    }
                    else if (task.TaskType == (int)TaskStationTypeEnum.StationToStation)
                    {
                        HostType = "S";
                    }
                    switch (aGVDTO.Message)
                    {
                        //空出库
                        case "0000400":
                            _Socket.EmptyOutBound(task.SourceAddress, "0000" + StationParse(task.TargetAddress), task.PalletCode);
                            _taskService.AddStcokHty(task.PalletCode, task.SourceAddress);
                            _taskService.TaskMoveHty(task);
                            _Socket.AddErrorMessage("2101", "AGV", "");
                            break;
                        //重入库
                        case "0000200":
                            _Socket.RecreateGetLocation("0000" + StationParse(task.SourceAddress), task.TargetAddress, HostType, task.PalletCode);
                            _Socket.AddErrorMessage("2100", "AGV", "");
                            break;
                        default: break;
                    }
                }
                return content.OK();
            }
            catch (Exception ex)
            {
                LogFactory.GetLog("AGV异常信息").InfoFormat(true, $"请求参数:{JsonConvert.SerializeObject(ex.Message)}", "");
                return content.Error(ex.Message);
            }
        }
 
        public string StationParse(string station)
        {
            var Station = SqlSugarHelper.DbWMS.Queryable<Dt_StationManager>().Where(x => x.stationName == station).First();
            if (Station != null)
            {
                return Station.HostName;
            }
            else
            {
                return "";
            }
        }
        private static readonly SemaphoreSlim _semaphoreUpdate = new SemaphoreSlim(1, 1);
        public async Task<WebResponseContent> DeviceWarning(AGVDTO DTO)
        {
            await _semaphoreUpdate.WaitAsync();
            WebResponseContent content = new WebResponseContent();
            try
            {
                LogFactory.GetLog("AG上传报警信息").InfoFormat(true, $"请求参数:{JsonConvert.SerializeObject(DTO)}", "");
                if (DTO.Message != null)
                {
                    Dt_ErrorDescription description = _descriptionRepository.QueryFirst(x => x.Type == DTO.Message);
                    if (description != null)
                    {
                        _Socket.ErrorReport(description.ErrorCode, "A", "00");
                        _Socket.AddErrorMessage(description.ErrorCode, "AGV", "");
                        return content.OK();
                    }
                    else
                    {
                        return content.Error("未识别报警源");
                    }
                }
                else
                {
                    return content.Error("未接收到异常信息");
                }
            }
            catch (Exception ex)
            {
                LogFactory.GetLog("AG上传报警信息").InfoFormat(true, $"请求参数:{JsonConvert.SerializeObject(ex.Message)}", "");
                return content.Error(ex.Message);
            }
            finally
            {
                _semaphoreUpdate.Release();
            }
 
        }
        #endregion 外部接口方法
    }
}