Base_Equipment.cs
3.21 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
123
124
125
using RCS.Model.Entity.PrimaryKey;
using System.Collections.Concurrent;
using System.ComponentModel.DataAnnotations.Schema;
namespace RCS.Model.Entity
{
[Table("t_base_equipment")]
public class Base_Equipment: IdEntity
{
/// <summary>
/// 设备编码
/// </summary>
public string Code { get; set; }
/// <summary>
/// CAD编码
/// </summary>
public string CADCode { get; set; }
/// <summary>
/// 设备名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 设备类型
/// </summary>
public string Type { get; set; }
/// <summary>
/// 设备IP
/// </summary>
public string Ip { get; set; }
/// <summary>
/// PLC类型
/// </summary>
public string PlcType { get; set; }
/// <summary>
/// 是否可用
/// </summary>
public bool IsEnable { get; set; }
/// <summary>
/// 是否连接
/// </summary>
[NotMapped]
public bool Online { get; set; } = false;
/// <summary>
/// 创建时间
/// </summary>
public DateTime Created { get; set; }
/// <summary>
/// 创建人
/// </summary>
public string CreatedBy { get; set; }
/// <summary>
/// 修改时间
/// </summary>
public DateTime Updated { get; set; }
/// <summary>
/// 修改人
/// </summary>
public string UpdatedBy { get; set; }
private ConcurrentBag<Base_EquipmentProp> equipmentProps = new ConcurrentBag<Base_EquipmentProp>();
/// <summary>
/// 逻辑外键实体-设备属性
/// </summary>
[NotMapped]
public ConcurrentBag<Base_EquipmentProp> EquipmentProps
{
get { return equipmentProps; }
set
{
equipmentProps = value;
//清空设备属性字典
propDic.Clear();
//把值添加到设备属性
foreach (var item in value)
{
//这里不做重复值检测,重复本来就该有异常
propDic.TryAdd(item.Code, item);
}
}
}
#region 添加数据字典 键值只需要执行一次初始化 后续不需要再Find
private ConcurrentDictionary<string, Base_EquipmentProp> propDic = new ConcurrentDictionary<string, Base_EquipmentProp>();
/// <summary>
/// 获取设备属性
/// </summary>
/// <param name="key">设备属性code </param>
/// <returns></returns>
[NotMapped]
public Base_EquipmentProp? this[string key]
{
get
{
propDic.TryGetValue(key, out Base_EquipmentProp? prop);
return prop;
}
}
[NotMapped]
public Base_EquipmentProp? this[Enum key]
{
get
{
propDic.TryGetValue(key.ToString(), out Base_EquipmentProp? prop);
return prop;
}
}
#endregion
}
}