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 stackers = null; public static List Stackers { get { if (stackers == null) { lock (StackerLock) { if (stackers == null) { string msg; stackers = new List(); var equips = EquipmentService.GetInstance().QueryByParam(new QueryParam { Filter = new Dictionary { { "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 conveyors = null; public static List Conveyors { get { if (conveyors == null) { lock (ConveyorLock) { if (conveyors == null) { using (var dbModel = new DbModelCore()) { try { conveyors = new List(); var equipments = dbModel.DEVEquipments.Where(x => x.typeid == (int)EEquipmentType.输送机).ToList(); var equipNames = new List(); var conveyorDict = new Dictionary(); 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 equipments = null; public static List 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 places = null; public static List 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; } } /// /// 是否是自动分解任务 /// private static bool isAutoMode = true; public static bool IsAutoMode { get { return CacheEntity.isAutoMode; } set { CacheEntity.isAutoMode = value; } } /// /// 是否自动处理任务 /// private static bool isAutoHandle = true; public static bool IsAutoHandle { get { return CacheEntity.isAutoHandle; } set { CacheEntity.isAutoHandle = value; } } /// /// 是否自动执行任务 /// private static bool isAutoRun = true; public static bool IsAutoRun { get { return CacheEntity.isAutoRun; } set { CacheEntity.isAutoRun = value; } } /// /// 是否执行批次任务 /// private static bool isLots = false; public static bool IsLots { get { return CacheEntity.isLots; } set { CacheEntity.isLots = value; } } /// /// 是否是真实环境 /// private static bool isRealMode = true; public static bool IsRealMode { get { return CacheEntity.isRealMode; } set { CacheEntity.isRealMode = value; } } /// /// 是否判断rfid /// private static bool isRfid = true; public static bool IsRfid { get { return CacheEntity.isRfid; } set { CacheEntity.isRfid = value; } } /// /// 是否已视觉检验结果为准 /// 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 ipDict = null; public static Dictionary IpDict { get { if (ipDict == null) { lock (IpDictLock) { if (ipDict == null) { ipDict = new Dictionary(); } } } return CacheEntity.ipDict; } set { CacheEntity.ipDict = value; } } } }