heshaofeng
8 天以前 4fb7183b79af9c245a33a00d3e1d753b324389f1
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
602
603
604
605
606
607
608
609
610
611
612
613
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Reflection.Metadata;
using System.Text;
using System.Threading.Tasks;
 
namespace WIDESEA_DTO.Basic
{
    public class ContainerArrivalRequest
    {
        /// <summary>
        /// 调用ID
        /// </summary>
        [JsonProperty("callid")]
        
        public string CallId { get; set; }
 
        /// <summary>
        /// 槽位代码
        /// </summary>
        [JsonProperty("slotCode")]
        
        public string SlotCode { get; set; }
 
        /// <summary>
        /// 容器代码
        /// </summary>
        [JsonProperty("containerCode")]
        
        public string ContainerCode { get; set; }
 
        /// <summary>
        /// 容器属性
        /// </summary>
        [JsonProperty("containerAttribute")]
        
        public ContainerAttribute ContainerAttribute { get; set; } = new ContainerAttribute();
 
    
    }
    /// <summary>
    /// 容器属性模型
    /// </summary>
    public class ContainerAttribute
    {
        /// <summary>
        /// 高度
        /// </summary>
        [JsonProperty("height")]
       
        [Range(1, int.MaxValue, ErrorMessage = "高度必须大于0")]
        public int Height { get; set; }
 
        /// <summary>
        /// 长度
        /// </summary>
        [JsonProperty("length")]
       
        [Range(1, int.MaxValue, ErrorMessage = "长度必须大于0")]
        public int Length { get; set; }
 
        /// <summary>
        /// 宽度
        /// </summary>
        [JsonProperty("width")]
       
        [Range(1, int.MaxValue, ErrorMessage = "宽度必须大于0")]
        public int Width { get; set; }
 
        /// <summary>
        /// 重量
        /// </summary>
        [JsonProperty("weight")]
       
        [Range(0.1, double.MaxValue, ErrorMessage = "重量必须大于0")]
        public double Weight { get; set; }
 
        /// <summary>
        /// 材质
        /// 1-塑料, 2-金属, 3-木材, 4-纸板
        /// </summary>
        [JsonProperty("material")]
       
        [Range(1, 4, ErrorMessage = "材质值必须在1-4范围内")]
        public int Material { get; set; }
 
        /// <summary>
        /// 方向
        /// </summary>
        [JsonProperty("orientation")]
        public string Orientation { get; set; } = string.Empty;
 
        /// <summary>
        /// 二维码
        /// </summary>
        [JsonProperty("qrcode")]
        public string QRCode { get; set; } = string.Empty;
 
        /// <summary>
        /// 异常原因
        /// </summary>
        [JsonProperty("abnormalReason")]
        public string AbnormalReason { get; set; } = string.Empty;
 
  
    }
 
 
 
 
    public class ContainerArrivalResponseData
    {
        public string? direction { get; set; }
    }
 
    public class MoveContainerRequest
    {
 
        /// <summary>
        /// 输送线节点编码。 必填
        /// </summary>
        public string slotCode { get; set; }
        /// <summary>
        /// 容器编码。 必填
        /// </summary>
        public string containerCode { get; set; }
        public string? direction { get; set; } = "100";
    }
 
    public class ApiResponse<T>
    {
        [JsonProperty("code")]
        public int Code { get; set; }
 
        [JsonProperty("msg")]
        public string? Msg { get; set; }
 
        [JsonProperty("data")]
        public T? Data { get; set; }
 
        public static ApiResponse<T> Success(T data)
            => new ApiResponse<T> { Code = 0, Msg = "success", Data = data };
 
        public static ApiResponse<T> Error(int code, string msg)
            => new ApiResponse<T> { Code = code, Msg = msg };
    }
 
    public class TaskDescribeType
    {
        public string containerCode { get; set; }
 
        public string containerType { get; set; }
 
        public string storageTag { get; set; }
 
        public string fromLocationCode { get; set; }
 
        public string toStationCode { get; set; }
 
        public string toLocationCode { get; set; }
 
        public int deadline { get; set; }
 
    }
 
    public class TasksType
    {
        public string taskCode { get; set; }
 
        public int taskPriority { get; set; }
 
        public TaskDescribeType taskDescribe { get; set; }
 
    }
 
    public class TaskModel
    {
        //入库 "taskType": "putaway" , 出库 "taskType": "carry"
        public string taskType { get; set; }
 
        public string taskGroupCode { get; set; }
 
        public int groupPriority { get; set; }
 
        public List<TasksType> tasks { get; set; }
 
    }
 
    public class ErrTasks
    {
        public string errorCode { get; set; }
 
        public string message { get; set; }
 
        public string taskCode { get; set; }
 
    }
    public class TasksData
    {
        public List<ErrTasks> tasks { get; set; }
 
    }
    [JsonConverter(typeof(StringEnumConverter))]
    public enum AbnormalEventType
    {
        //工作位异常
        [JsonProperty("location_abnormal")]
        LocationAbnormal,
        //机器人异常
        [JsonProperty("robot_abnormal")]
        RobotAbnormal
    }
 
    [JsonConverter(typeof(StringEnumConverter))]
    public enum Direction
    {
        Forward = 100,
        Backward = 200
    }
    /// <summary>
    /// 异常上报
    /// </summary>
    public class AbnormalReportRequest
    {
        [JsonProperty("eventType")]
        public AbnormalEventType EventType { get; set; }
 
        [JsonProperty("robotCode")]
        public string? RobotCode { get; set; }
 
        [JsonProperty("stationCode")]
        public string? StationCode { get; set; }
 
        [JsonProperty("locationCode")]
        public string? LocationCode { get; set; }
 
        [JsonProperty("containerCode")]
        public string? ContainerCode { get; set; }
 
        [JsonProperty("message")]
        public string? Message { get; set; }
 
        [JsonProperty("updateTime")]
        public long UpdateTime { get; set; }
    }
 
    /// <summary>
    /// 事件类型枚举
    /// </summary>
    public enum EventType
    {
        /// <summary>
        /// 任务状态变化
        /// </summary>
        task,
 
        /// <summary>
        /// 任务分配
        /// </summary>
        task_allocated,
 
        /// <summary>
        /// 取箱状态
        /// </summary>
        tote_load,
 
        /// <summary>
        /// 放箱状态
        /// </summary>
        tote_unload,
 
        /// <summary>
        /// 机器人到达工作站
        /// </summary>
        robot_reach
    }
 
    /// <summary>
    /// 任务状态枚举
    /// </summary>
    public enum TaskStatus
    {
        /// <summary>
        /// 成功
        /// </summary>
        success,
 
        /// <summary>
        /// 失败
        /// </summary>
        fail,
 
        /// <summary>
        /// 取消
        /// </summary>
        cancel,
 
        /// <summary>
        /// 挂起
        /// </summary>
        suspend
    }
 
    /// <summary>
    /// 容器朝向枚举
    /// </summary>
    public enum ContainerFace
    {
        /// <summary>
        /// 0度
        /// </summary>
        A = 0,
 
        /// <summary>
        /// 90度
        /// </summary>
        B = 90,
 
        /// <summary>
        /// 180度
        /// </summary>
        C = 180,
 
        /// <summary>
        /// 270度
        /// </summary>
        D = 270
    }
 
    /// <summary>
    /// 任务状态回调请求模型
    /// </summary>
    public class StatusCallbackRequest
    {
        /// <summary>
        /// 一次回调唯一标识
        /// </summary>
        [JsonProperty("callId", Required = Required.Always)]
        public string CallId { get; set; }
 
        /// <summary>
        /// 业务任务号
        /// 当eventType为robot_reach时不填,其他值时必填
        /// </summary>
        [JsonProperty("taskCode")]
        public string TaskCode { get; set; }
 
        /// <summary>
        /// 上报事件类型
        /// </summary>
        [JsonProperty("eventType", Required = Required.Always)]
        public EventType EventType { get; set; }
 
        /// <summary>
        /// 任务状态
        /// </summary>
        [JsonProperty("status", Required = Required.Always)]
        public TaskStatus Status { get; set; }
 
        /// <summary>
        /// 机器人编码
        /// </summary>
        [JsonProperty("robotCode")]
        public string RobotCode { get; set; }
 
        /// <summary>
        /// 容器编码
        /// </summary>
        [JsonProperty("containerCode")]
        public string ContainerCode { get; set; }
 
        /// <summary>
        /// 工作位编码
        /// </summary>
        [JsonProperty("locationCode")]
        public string LocationCode { get; set; }
 
        /// <summary>
        /// 工作站编码
        /// </summary>
        [JsonProperty("stationCode")]
        public string StationCode { get; set; }
 
        /// <summary>
        /// 描述信息,描述异常原因/挂起原因等
        /// </summary>
        [JsonProperty("message")]
        public string Message { get; set; }
 
        /// <summary>
        /// 系统任务编码,用于任务挂起回调
        /// </summary>
        [JsonProperty("sysTaskCode")]
        public string SysTaskCode { get; set; }
 
        /// <summary>
        /// 库位是否有容器,eventType为task且为盘点任务时才会返回该值
        /// </summary>
        [JsonProperty("isLocationHasContainer")]
        public bool? IsLocationHasContainer { get; set; }
 
        /// <summary>
        /// 背签层叶,从0层开始,从下往上编号。64表示放在了货叉上
        /// 当eventType为task且为称重盘点任务或rfid盘点任务时才会返回该值
        /// </summary>
        [JsonProperty("trayLevel")]
        public int? TrayLevel { get; set; }
 
        /// <summary>
        /// 重量,单位为g。当eventType为task且为称重盘点任务时才会返回该值
        /// </summary>
        [JsonProperty("weight")]
        public int? Weight { get; set; }
 
        /// <summary>
        /// RFID盘点信息。当eventType为task且为rfid盘点任务时才会返回该值
        /// </summary>
        [JsonProperty("rfids")]
        public List<string> Rfids { get; set; }
 
        /// <summary>
        /// 机器人类型编码。当eventType为robot_reach时才会返回该值
        /// </summary>
        [JsonProperty("robotTypeCode")]
        public string RobotTypeCode { get; set; }
 
        /// <summary>
        /// 托盘信息。当eventType为robot_reach时才会返回该值
        /// </summary>
        [JsonProperty("trays")]
        public List<TrayItem> Trays { get; set; }
    }
 
    /// <summary>
    /// 托盘信息模型
    /// </summary>
    public class TrayItem
    {
        /// <summary>
        /// 容器编码
        /// </summary>
        [JsonProperty("containerCode")]
        public string ContainerCode { get; set; }
 
        /// <summary>
        /// 背签层叶,从0层开始,从下往上编号。64表示容器放在了货叉上
        /// </summary>
        [JsonProperty("trayLevel", Required = Required.Always)]
        public int TrayLevel { get; set; }
 
        /// <summary>
        /// 位置编码,由机器人编码和背签层数组成,即机器人id#层数
        /// </summary>
        [JsonProperty("positionCode", Required = Required.Always)]
        public string PositionCode { get; set; }
 
        /// <summary>
        /// 目标容器朝向,取值为枚举值A、B、C、D
        /// </summary>
        [JsonProperty("containerFace")]
        public ContainerFace? ContainerFace { get; set; }
    }
 
    /// <summary>
    /// 状态回调响应模型
    /// </summary>
    public class StatusCallbackResponse
    {
        /// <summary>
        /// 响应状态码
        /// 0: 正常
        /// 4560: 异常
        /// </summary>
        [JsonProperty("code", Required = Required.Always)]
        public int Code { get; set; }
 
        /// <summary>
        /// 响应消息补充说明,success或其他异常消息
        /// </summary>
        [JsonProperty("msg", Required = Required.Always)]
        public string Msg { get; set; }
 
        /// <summary>
        /// 返回的数据
        /// </summary>
        [JsonProperty("data", Required = Required.Always)]
        public object Data { get; set; }
 
        /// <summary>
        /// 创建成功响应
        /// </summary>
        public static StatusCallbackResponse Success()
        {
            return new StatusCallbackResponse
            {
                Code = 0,
                Msg = "success",
                Data = new { }
            };
        }
 
        /// <summary>
        /// 创建错误响应
        /// </summary>
        public static StatusCallbackResponse Error(string message)
        {
            return new StatusCallbackResponse
            {
                Code = 4560,
                Msg = message,
                Data = new { }
            };
        }
    }
 
 
    /// <summary>
    /// 机器人异常事件请求模型
    /// </summary>
    public class RobotAbnormalEventRequest
    {
        /// <summary>
        /// 事件类型
        /// </summary>
        [JsonProperty("eventType")]
       
        public string EventType { get; set; } = "robot_abnormal";
 
        /// <summary>
        /// 机器人代码
        /// </summary>
        [JsonProperty("robotCode")]
       
        public string RobotCode { get; set; }
 
        /// <summary>
        /// 站台代码
        /// </summary>
        [JsonProperty("stationCode")]
      
        public string StationCode { get; set; } = string.Empty;
 
        /// <summary>
        /// 位置代码
        /// </summary>
        [JsonProperty("locationCode")]
       
        public string LocationCode { get; set; }
 
        /// <summary>
        /// 容器代码
        /// </summary>
        [JsonProperty("containerCode")]
      
        public string ContainerCode { get; set; }
 
        /// <summary>
        /// 异常消息
        /// </summary>
        [JsonProperty("message")]
        
        public string Message { get; set; }
 
        /// <summary>
        /// 更新时间(Unix时间戳,毫秒)
        /// </summary>
        [JsonProperty("updateTime")]
        
        public long UpdateTime { get; set; }
 
        /// <summary>
        /// 获取DateTime类型的更新时间
        /// </summary>
        [JsonIgnore]
        public DateTime UpdateDateTime
        {
            get
            {
                return DateTimeOffset.FromUnixTimeMilliseconds(UpdateTime).DateTime;
            }
            set
            {
                UpdateTime = new DateTimeOffset(value).ToUnixTimeMilliseconds();
            }
        }
 
      
 
        /// <summary>
        /// 设置当前时间为更新时间
        /// </summary>
        public void SetCurrentTime()
        {
            UpdateTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
        }
 
        /// <summary>
        /// 创建成功响应
        /// </summary>
        public override string ToString()
        {
            return $"RobotAbnormalEvent: Robot={RobotCode}, Location={LocationCode}, Container={ContainerCode}, Time={UpdateDateTime:yyyy-MM-dd HH:mm:ss}";
        }
    }
 
 
 
 
    }