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}";
|
}
|
}
|
|
|
|
|
}
|