public SceneMonitor GetEnvironmentData(string ids, string organizationId, string sceneName) { IList <DataItem> dataItems = new List <DataItem>(); string[] iditems = ids.Split(','); int count = iditems.Count(); Dictionary <string, IList <string> > idDictionary = new Dictionary <string, IList <string> >(); for (int i = 0; i < count - 1; i++) { string[] itemArry = iditems[i].Split('>'); string providerType = "Environment"; string key = itemArry[0] + "," + providerType; if (!idDictionary.Keys.Contains(key)) { idDictionary.Add(key, new List <string>()); idDictionary[key].Add(itemArry[1]); } else { idDictionary[key].Add(itemArry[1]); } } int k = 0; foreach (var keyitem in idDictionary.Keys) { k++; string[] keyArry = keyitem.Split(','); string[] mvariableids = idDictionary[keyitem].ToArray(); if (Enum.IsDefined(typeof(DataItemProviderType), keyArry[1])) { IEnumerable <DataItem> items = DataItemProviderFactory.CreateDataItemProvider((DataItemProviderType)Enum.Parse(typeof(DataItemProviderType), keyArry[1])).GetDataItem(keyArry[0], mvariableids); foreach (var item in items) { dataItems.Add(item); } } } SceneMonitor result = new SceneMonitor(); result.Name = sceneName; result.time = DateTime.Now; result.DataSet = dataItems; return(result); }
public SceneMonitor GetRealTimeData(string ids, string organizationId, string sceneName) { //Monitor_shell.Infrastructure.Utility.DebugHelper.TestStart(); IList <DataItem> dataItems = new List <DataItem>(); string[] iditems = ids.Split(','); int count = iditems.Count(); Dictionary <string, IList <string> > idDictionary = new Dictionary <string, IList <string> >(); for (int i = 0; i < count - 1; i++) { string[] itemArry = iditems[i].Split('>'); if (itemArry.Count() == 3) { #region 单条产线的工序 //单条产线的工序 if (itemArry[2] == "Class" || itemArry[2] == "Day" || itemArry[2] == "Month") { string[] variableIdArry = itemArry[1].Split('_'); string providerType; //如果为电量、电耗或煤耗标签,用电量、电耗或煤耗后缀拼 if ("ElectricityQuantity" == variableIdArry[1] || "ElectricityConsumption" == variableIdArry[1] || "CoalConsumption" == variableIdArry[1]) { providerType = "ClassDayMonth" + variableIdArry[1]; } //如果为产量标签,统一用“ClassDayMonthMaterial” else { providerType = "ClassDayMonthMaterial"; } string key = itemArry[0] + "," + providerType; if (!idDictionary.Keys.Contains(key)) { idDictionary.Add(key, new List <string>()); idDictionary[key].Add(itemArry[1]); } else { idDictionary[key].Add(itemArry[1]); } } #endregion #region 如果为分厂级别的工序电耗(各产线工序电量之和/各产线工序产量之和) //如果为分厂级别的工序电耗(各产线工序电量之和/各产线工序产量之和) else if (itemArry[2] == "SumProcessClass" || itemArry[2] == "SumProcessDay" || itemArry[2] == "SumProcessMonth") { string[] variableIdArry = itemArry[1].Split('_'); string providerType; //如果为电量、电耗或煤耗标签,用电量、电耗或煤耗后缀拼 if ("ElectricityQuantity" == variableIdArry[1] || "ElectricityConsumption" == variableIdArry[1] || "CoalConsumption" == variableIdArry[1]) { providerType = "SumProcessClassDayMonth" + variableIdArry[1]; } //如果为产量标签,统一用“SumClassDayMonthMaterial” else { providerType = "SumProcessClassDayMonthMaterial"; } string key = itemArry[0] + "," + providerType; if (!idDictionary.Keys.Contains(key)) { idDictionary.Add(key, new List <string>()); idDictionary[key].Add(itemArry[1]); } else { idDictionary[key].Add(itemArry[1]); } } #endregion #region 亮哥综合电耗、煤耗 else if (itemArry[2] == "Comprehensive") { string key = itemArry[0] + ",Comprehensive"; if (!idDictionary.Keys.Contains(key)) { idDictionary.Add(key, new List <string>()); idDictionary[key].Add(itemArry[1]); } else { idDictionary[key].Add(itemArry[1]); } } #endregion //熟料综合电耗(熟料综合电耗=所有熟料电量之和/所有熟料产量之和) //水泥综合电耗(水泥综合电耗=(所有熟料电量之和+所有水泥产线电量之和)/水泥总产量) else if (itemArry[2] == "SumClass" || itemArry[2] == "SumDay" || itemArry[2] == "SumMonth") { string[] variableIdArry = itemArry[1].Split('_'); string providerType = ""; //如果为电耗或煤耗标签,用电耗或煤耗后缀拼 if ("ElectricityConsumption" == variableIdArry[1] || "CoalConsumption" == variableIdArry[1]) { providerType = "SumClassDayMonth" + variableIdArry[1]; } //如果为产量标签,统一用“ClassDayMonthMaterial” //else // providerType = "SumClassDayMonthMaterial"; string key = itemArry[0] + "," + providerType; if (!idDictionary.Keys.Contains(key)) { idDictionary.Add(key, new List <string>()); idDictionary[key].Add(itemArry[1]); } else { idDictionary[key].Add(itemArry[1]); } } else if (itemArry[2] == "Material") { string providerType = "MaterialConsumption"; string key = itemArry[0] + "," + providerType; if (!idDictionary.Keys.Contains(key)) { idDictionary.Add(key, new List <string>()); idDictionary[key].Add(itemArry[1]); } else { idDictionary[key].Add(itemArry[1]); } } else if (itemArry[2] == "Current") { string providerType = "Current"; string key = itemArry[0] + "," + providerType; if (!idDictionary.Keys.Contains(key)) { idDictionary.Add(key, new List <string>()); idDictionary[key].Add(itemArry[1]); } else { idDictionary[key].Add(itemArry[1]); } } //增加通过通信采集水流量的显示 else if (itemArry[2] == "WaterFlowRate") { string providerType = "WaterFlowRate"; string key = itemArry[0] + "," + providerType; if (!idDictionary.Keys.Contains(key)) { idDictionary.Add(key, new List <string>()); idDictionary[key].Add(itemArry[1]); } else { idDictionary[key].Add(itemArry[1]); } } //如果为DCS标签 else if (itemArry[2] == "DCS" || itemArry[2] == "BarGraph") { string providerType = "DCS"; string key = itemArry[0] + "," + providerType; if (!idDictionary.Keys.Contains(key)) { idDictionary.Add(key, new List <string>()); idDictionary[key].Add(itemArry[1]); } else { if (!idDictionary[key].Contains(itemArry[1]))//去除重复的标签 { idDictionary[key].Add(itemArry[1]); } } } else { string providerType = "Realtime" + itemArry[2]; string key = itemArry[0] + "," + providerType; if (!idDictionary.Keys.Contains(key)) { idDictionary.Add(key, new List <string>()); idDictionary[key].Add(itemArry[1]); } else { idDictionary[key].Add(itemArry[1]); } } } } //Monitor_shell.Infrastructure.Utility.DebugHelper.TestStop("准备工作花费时间:" ); foreach (var keyitem in idDictionary.Keys) { string[] keyArry = keyitem.Split(','); string[] mvariableids = idDictionary[keyitem].ToArray(); if (Enum.IsDefined(typeof(DataItemProviderType), keyArry[1])) { IEnumerable <DataItem> items = DataItemProviderFactory.CreateDataItemProvider((DataItemProviderType)Enum.Parse(typeof(DataItemProviderType), keyArry[1])).GetDataItem(keyArry[0], mvariableids); foreach (var item in items) { dataItems.Add(item); } } } SceneMonitor result = new SceneMonitor(); result.Name = sceneName; result.time = DateTime.Now; result.DataSet = dataItems; return(result); }