TaskTemplate.cs
3.72 KB
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
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Rcs.Domain.Entities
{
/// <summary>
/// 任务模板实体类
/// </summary>
[Table("task_templates")]
public partial class TaskTemplate : Entity
{
/// <summary>
/// 系统ID
/// </summary>
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.None)]
[Column("template_id")]
public Guid TemplateId { get; set; }
/// <summary>
/// 模板编码(唯一标识)
/// </summary>
[Required]
[Column("template_code")]
[MaxLength(50)]
public string TemplateCode { get; set; } = string.Empty;
/// <summary>
/// 模板名称
/// </summary>
[Required]
[Column("template_name")]
[MaxLength(100)]
public string TemplateName { get; set; } = string.Empty;
/// <summary>
/// 模板描述
/// </summary>
[Column("description")]
[MaxLength(500)]
public string? Description { get; set; }
/// <summary>
/// 机器人类型(叉取型、潜伏型等)
/// </summary>
[Required]
[Column("robot_type")]
public RobotType RobotType { get; set; }
/// <summary>
/// 制造商
/// </summary>
[Column("manufacturer")]
[MaxLength(100)]
public string? Manufacturer { get; set; }
/// <summary>
/// 是否启用
/// </summary>
[Column("is_enabled")]
public bool IsEnabled { get; set; } = true;
/// <summary>
/// 是否为默认模板(同一机器人类型+制造商只能有一个默认模板)
/// @author zzy
/// </summary>
[Column("is_default")]
public bool IsDefault { get; set; } = false;
/// <summary>
/// 创建时间
/// </summary>
[Column("created_at", TypeName = "timestamp")]
public DateTime? CreatedAt { get; set; }
/// <summary>
/// 更新时间
/// </summary>
[Column("updated_at", TypeName = "timestamp")]
public DateTime? UpdatedAt { get; set; }
#region 导航属性
/// <summary>
/// 任务步骤列表
/// </summary>
public virtual ICollection<TaskStep> TaskSteps { get; set; } = new List<TaskStep>();
#endregion
public static TaskTemplate Create(string templateCode, string templateName, RobotType robotType, string? description, string? manufacturer, bool isEnabled, bool isDefault = false)
{
return new TaskTemplate
{
TemplateId = Guid.NewGuid(),
TemplateCode = templateCode,
TemplateName = templateName,
RobotType = robotType,
Description = description,
Manufacturer = manufacturer,
IsEnabled = isEnabled,
IsDefault = isDefault,
CreatedAt = DateTime.Now,
UpdatedAt = DateTime.Now
};
}
public void Update(string templateCode, string templateName, RobotType robotType, string? description, string? manufacturer, bool isEnabled, bool isDefault = false)
{
if(!string.IsNullOrWhiteSpace(templateCode)) TemplateCode = templateCode;
if(!string.IsNullOrWhiteSpace(templateName)) TemplateName = templateName;
RobotType = robotType;
Description = description;
Manufacturer = manufacturer;
IsEnabled = isEnabled;
IsDefault = isDefault;
UpdatedAt = DateTime.Now;
}
}
}