schangxiang@126.com
2025-09-17 60dd1afc3e8f94aa1b23211b6738d35b47294382
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
using iWareCc.Conveyor.Entity;
using iWareCc.Srm.Entity;
using iWareCcTest.OpcWcfService;
using iWareCommon.Common.Entity;
using iWareCommon.Utils;
using iWareDataCore.BASE.Entity;
using iWareDataCore.BASE.Service;
using iWareDataCore.DEV.Entity;
using iWareDataCore.DEV.EnumType;
using iWareDataCore.DEV.Service;
using iWareDataCore.ORM;
using iWareDataCore.TASK.Entity;
using iWareDataCore.TASK.EnumType;
using iWareDataCore.TASK.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace iWareCc.Cache.Entity
{
   public  class CacheEntity
    {
       
 
        private static object StackerLock = new object();
 
        private static List<StackerEntity> stackers = null;
        public static List<StackerEntity> Stackers
        {
            get
            {
                if (stackers == null)
                {
                    lock (StackerLock)
                    {
                        if (stackers == null)
                        {
                            string msg;
                            stackers = new List<StackerEntity>();
                            var equips = EquipmentService.GetInstance().QueryByParam(new QueryParam { Filter = new Dictionary<string, object> { { "TypeId", (int)EEquipmentType.堆垛机 } } }, out msg);
                            equips.ForEach(x => stackers.Add(new StackerEntity(x)));
                        }
                    }
                }
                return CacheEntity.stackers;
            }
            set { CacheEntity.stackers = value; }
        }
 
        private static object ConveyorLock = new object();
 
        private static List<ConveyorEntity> conveyors = null;
        public static List<ConveyorEntity> Conveyors
        {
            get
            {
                if (conveyors == null)
                {
                    lock (ConveyorLock)
                    {
                        if (conveyors == null)
                        {
                            using (var dbModel = new DbModelCore())
                            {
                                try
                                {
                                    conveyors = new List<ConveyorEntity>();
                                    var equipments = dbModel.DEVEquipments.Where(x => x.typeid == (int)EEquipmentType.输送机).ToList();
                                    var equipNames = new List<string>();
                                    var conveyorDict = new Dictionary<string, ConveyorEntity>();
                                    equipments.ForEach(x =>
                                    {
                                        equipNames.Add(x.equipname);
                                        var conveyor = new ConveyorEntity(new EquipmentEntity(x));
                                        conveyors.Add(conveyor);
                                        conveyorDict.Add(x.equipname, conveyor);
                                    });
                                    var places = dbModel.BASEPlaceViews.Where(x => equipNames.Contains(x.placetyperemark)).ToList();
                                    places.ForEach(x =>
                                    {
                                        if (conveyorDict.ContainsKey(x.placetyperemark))
                                        {
                                            conveyorDict[x.placetyperemark].Gates.Add(new GateEntity(new PlaceViewEntity(x)));
                                        }
                                    });
                                }
                                catch (Exception ex) {
 
                                }
                            }
                        }
                    }
                }
                return CacheEntity.conveyors;
            }
            set { CacheEntity.conveyors = value; }
        }
 
        private static object EquipmentLock = new object();
 
        private static List<EquipmentEntity> equipments = null;
 
        public static List<EquipmentEntity> Equipments
        {
            get
            {
                if (equipments == null)
                {
                    lock (EquipmentLock)
                    {
                        if (equipments == null)
                        {
                            string msg;
                            equipments = EquipmentService.GetInstance().QueryByParam(new QueryParam(), out msg);
                        }
                    }
                }
 
                return equipments;
            }
            set { equipments = value; }
        }
 
        private static object PlaceLock = new object();
 
        private static List<PlaceViewEntity> places = null;
 
        public static List<PlaceViewEntity> Places
        {
            get
            {
                if (places == null)
                {
                    lock (PlaceLock)
                    {
                        if (places == null)
                        {
                            string msg;
                            places = PlaceViewService.GetInstance().QueryByParam(new QueryParam(), out msg);
                        }
                    }
                }
                return places;
            }
            set { places = value; }
        }
 
 
        private static object DeviceRunningModeLock = new object();
        private static DeviceRunningModeEntity deviceRunningMode = null;
 
        public static DeviceRunningModeEntity DeviceRunningMode
        {
            get
            {
                if (deviceRunningMode == null)
                {
                    lock (DeviceRunningModeLock)
                    {
                        if (deviceRunningMode == null)
                        {
                            string msg;
                            string stackerCnName = Enum.GetName(typeof(EEquipmentCnName), EEquipmentCnName.stacker1);
                            var deviceRunningModes = DeviceRunningModeService.GetInstance().QueryByParam(new QueryParam(), out msg);
                            deviceRunningMode = deviceRunningModes.Count < 1 ? new DeviceRunningModeEntity { Mode = (int)EDeviceMode.单堆垛机模式, EquipmentName = stackerCnName } : deviceRunningModes[0];
                        }
                    }
                }
                return deviceRunningMode;
            }
            set { deviceRunningMode = value; }
        }
 
 
 
        /// <summary>
        /// 是否是自动分解任务
        /// </summary>
        private static bool isAutoMode = true;
 
        public static bool IsAutoMode
        {
            get { return CacheEntity.isAutoMode; }
            set { CacheEntity.isAutoMode = value; }
        }
 
        /// <summary>
        /// 是否自动处理任务
        /// </summary>
        private static bool isAutoHandle = true;
 
        public static bool IsAutoHandle
        {
            get { return CacheEntity.isAutoHandle; }
            set { CacheEntity.isAutoHandle = value; }
        }
 
 
 
        /// <summary>
        /// 是否自动执行任务
        /// </summary>
        private static bool isAutoRun = true;
 
        public static bool IsAutoRun
        {
            get { return CacheEntity.isAutoRun; }
            set { CacheEntity.isAutoRun = value; }
        }
 
 
        /// <summary>
        /// 是否执行批次任务
        /// </summary>
        private static bool isLots = false;
 
        public static bool IsLots
        {
            get { return CacheEntity.isLots; }
            set { CacheEntity.isLots = value; }
        }
 
 
        /// <summary>
        /// 是否是真实环境
        /// </summary>
        private static bool isRealMode = true;
 
        public static bool IsRealMode
        {
            get { return CacheEntity.isRealMode; }
            set { CacheEntity.isRealMode = value; }
        }
 
        /// <summary>
        /// 是否判断rfid
        /// </summary>
        private static bool isRfid = true;
 
        public static bool IsRfid
        {
            get { return CacheEntity.isRfid; }
            set { CacheEntity.isRfid = value; }
        }
 
        /// <summary>
        /// 是否已视觉检验结果为准
        /// </summary>
        private static bool isVisualMode = false;
 
        public static bool IsVisualMode
        {
            get { return CacheEntity.isVisualMode; }
            set { CacheEntity.isVisualMode = value; }
        }
 
        private static object OpcWcfServiceLock = new object();
 
        private static OpcWcfServiceClient opcWcfServiceClient = null;
 
        public static OpcWcfServiceClient OpcWcfServiceClient
        {
            get
            {
                if (opcWcfServiceClient == null)
                {
                    lock (OpcWcfServiceLock)
                    {
                        if (opcWcfServiceClient == null)
                        {
                            opcWcfServiceClient = new OpcWcfServiceClient();
                        }
                    }
                }
                return CacheEntity.opcWcfServiceClient;
            }
            set { CacheEntity.opcWcfServiceClient = value; }
        }
 
        private static object IpDictLock = new object();
        private static Dictionary<string, string> ipDict = null;
 
        public static Dictionary<string, string> IpDict
        {
            get
            {
                if (ipDict == null)
                {
                    lock (IpDictLock)
                    {
                        if (ipDict == null)
                        {
                            ipDict = new Dictionary<string, string>();
                        }
                    }
                }
                return CacheEntity.ipDict;
            }
            set { CacheEntity.ipDict = value; }
        }
    }
}