You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

148 lines
3.8 KiB
C#

using System.ComponentModel;
using Newtonsoft.Json;
using SqlSugar;
namespace DS.WMS.Core.TaskInteraction.Entity
{
/// <summary>
/// 任务步骤表
/// </summary>
[SugarTable("business_task_step", "任务步骤表")]
public class TaskStep
{
/// <summary>
/// ID
/// </summary>
[SugarColumn(IsPrimaryKey = true)]
public long Id { get; set; }
/// <summary>
/// 任务ID
/// </summary>
[SugarColumn(ColumnDescription = "任务ID")]
public long TaskId { get; set; }
/// <summary>
/// 步骤类型
/// </summary>
[SugarColumn(ColumnDescription = "明细类型")]
public StepType Type { get; set; }
/// <summary>
/// 名称
/// </summary>
[SugarColumn(ColumnDescription = "名称", Length = 50, IsNullable = true)]
public string? Name { get; set; }
/// <summary>
/// 值
/// </summary>
[SugarColumn(ColumnDescription = "值", IsNullable = true)]
public string? Value { get; set; }
/// <summary>
/// 是否已完成
/// </summary>
[SugarColumn(ColumnDescription = "是否已完成")]
public bool IsCompleted { get; set; }
/// <summary>
/// 优先级
/// </summary>
[SugarColumn(ColumnDescription = "优先级")]
public int Priority { get; set; }
/// <summary>
/// 创建人
/// </summary>
[SugarColumn(ColumnDescription = "创建人", IsNullable = false)]
public long CreateBy { get; set; }
/// <summary>
/// 创建时间
/// </summary>
[SugarColumn(ColumnDescription = "创建时间", IsNullable = false)]
public DateTime CreateTime { get; set; }
/// <summary>
/// 更新人
/// </summary>
[SugarColumn(ColumnDescription = "更新人", IsNullable = true)]
public long? UpdateBy { get; set; }
/// <summary>
/// 更新时间
/// </summary>
[SugarColumn(ColumnDescription = "更新时间", IsNullable = true)]
public DateTime? UpdateTime { get; set; }
/// <summary>
/// 返回指定类型的值
/// </summary>
/// <typeparam name="T">值的类型</typeparam>
/// <returns></returns>
public T? GetValue<T>()
{
if (string.IsNullOrEmpty(Value))
return default;
var type = typeof(T);
if (type.IsEnum)
return (T)Enum.Parse(type, Value);
if (!type.IsClass)
return (T)Convert.ChangeType(Value, type);
return JsonConvert.DeserializeObject<T>(Value);
}
/// <summary>
/// 设置值
/// </summary>
/// <param name="value">要设置的值</param>
/// <returns></returns>
public void SetValue(object? value)
{
if (value == null)
return;
var type = value.GetType();
if (type.IsClass && type != typeof(string))
{
Value = JsonConvert.SerializeObject(value);
}
else
{
Value = value.ToString();
}
}
}
/// <summary>
/// 任务步骤类型
/// </summary>
public enum StepType
{
/// <summary>
/// 未指定
/// </summary>
[Description("未指定")]
NotSpecified = 0,
/// <summary>
/// 客户确认
/// </summary>
[Description("客户确认")]
CustomerConfirm = 1,
/// <summary>
/// 国外代理确认
/// </summary>
[Description("国外代理确认")]
ForeignAgentConfirm = 2,
}
}