//objectList[0] public Dictionary<string, decimal> GetSingleItemCodeByObjectNew(QueryContrastPeriods query, string itemcode, TimePeriod time, int isCoal) { // var result = new ResultIndexLineChart { DatePick = new List<string>(), DatePickEnery = new List<decimal>() }; var eneryDataList = new Dictionary<string, decimal>(); var model = new BaseQueryModel(); List<Model.BaseLayerObject> objectList = new NTS.WEB.BLL.BaseLayerObject().GetBaseLayerObjectList(string.Format(" and layerobjectid={0}", query.AreaId), " order by LayerObjectID"); model.IsDevice = 0; if (query.ObjType == AreaType.Area) { objectList = new NTS.WEB.BLL.BaseLayerObject().GetBaseLayerObjectList(string.Format(" and layerobjectid={0}", query.AreaId), " order by LayerObjectID"); } else { objectList = new NTS.WEB.BLL.BaseLayerObject().GetBaseFuncLayerObjectList(string.Format(" and layerobjectid={0}", query.AreaId), " order by LayerObjectID"); } model.ObjectList = (from p in objectList select p.LayerObjectID).ToList<int>(); model.ItemCode = itemcode; model.Unit = BaseTool.GetChartUnit(query.particle); model.Starttime = time.StartTime; model.Endtime = time.EndTime; model.areaType = query.ObjType; var resList = contsDal.GetBaseEneryDataListNew(model); for (int iCount = 0; iCount < query.PeriodLst.Count; iCount++) { TimePeriod tpTime = query.PeriodLst[iCount]; //if (!eneryDataList.ContainsKey(d.DatePick)) //{ // eneryDataList.Add(d.DatePick, isCoal == 0 ? d.DataValue : d.CoalDataValue); //} //else //{ // eneryDataList[d.DatePick] += isCoal == 0 ? d.DataValue : d.CoalDataValue; //} } foreach (var d in objectList.SelectMany(o => resList.BaseLayerObjectResults[o.LayerObjectID.ToString(CultureInfo.InvariantCulture)].Datas)) { if (!eneryDataList.ContainsKey(d.DatePick)) { switch (query.QueryType) { case QueryOrderType.CarbanOut: eneryDataList.Add(d.DatePick, d.Co2DataValue); break; case QueryOrderType.ConvCoal: eneryDataList.Add(d.DatePick, d.CoalDataValue); break; case QueryOrderType.Renminbi: eneryDataList.Add(d.DatePick, d.MoneyDataValue); break; default: eneryDataList.Add(d.DatePick, d.DataValue); break; } } else { eneryDataList[d.DatePick] += isCoal == 0 ? d.DataValue : d.CoalDataValue; switch (query.QueryType) { case QueryOrderType.CarbanOut: eneryDataList[d.DatePick] += d.Co2DataValue; break; case QueryOrderType.ConvCoal: eneryDataList[d.DatePick] += d.CoalDataValue; break; case QueryOrderType.Renminbi: eneryDataList[d.DatePick] += d.MoneyDataValue; break; default: eneryDataList[d.DatePick] += d.DataValue; break; } } } //foreach (var e in eneryDataList) //{ // result.DatePick.Add(e.Key); // result.DatePickEnery.Add(e.Value); //} return eneryDataList; }
public ResultItemCode GetPersonNumPeriodsQueryLineChart(QueryContrastPeriods query, TimePeriod time) { #region 定义区 var resultList = new ResultView.ResultItemCode { ObjectName = new List<string>(), Enery = new Dictionary<string, List<decimal>>(), Dept = new List<string>() }; #endregion var dept = string.Empty; var objectList = new BLL.BaseLayerObject().GetBaseLayerObjectList( string.Format(" and layerobjectid={0}", query.AreaId), " order by LayerObjectID"); var itList = new BLL.Itemcode().GetItemcodeList(" and ItemCodeNumber='" + query.ItemCode + "'", " order by ItemcodeID"); if (itList.Count > 0) { dept = itList[0].Unit; } dept = query.ItemCode == "00000" ? "T" : dept; if (query.ItemCode == "00000") { // resultList.Dept = new List<string>() { "T" }; var itemList = new BLL.Itemcode().GetItemcodeList(" and ParentID=0", " order by ItemcodeID"); var eneryDataListTotal = new Dictionary<string, Dictionary<string, decimal>>(); var maxcode = "01000"; var count = 0; foreach (var itemcode in itemList) { var lineChart = GetPersonNumSingleItemCodeByObject(query, itemcode.ItemCodeNumber, time, 1); if (count < lineChart.Count) { count = lineChart.Count; maxcode = itemcode.ItemCodeNumber; } eneryDataListTotal.Add(itemcode.ItemCodeNumber, lineChart); // resultList.Enery.Add(itemcode.ItemCodeName, lineChart.DatePickEnery); } // 重新赋值 foreach (var itemcode in itemList) { var itemcode1 = itemcode; foreach (var max in eneryDataListTotal[maxcode].Where(max => !eneryDataListTotal[itemcode1.ItemCodeNumber].ContainsKey(max.Key))) { eneryDataListTotal[itemcode.ItemCodeNumber].Add(max.Key, 0); } var temp = eneryDataListTotal[itemcode.ItemCodeNumber].OrderBy(p => Convert.ToDateTime(p.Key)); var tempOrder = temp.ToDictionary(keyValuePair => keyValuePair.Key, keyValuePair => keyValuePair.Value); eneryDataListTotal[itemcode.ItemCodeNumber] = tempOrder; resultList.Enery.Add(itemcode.ItemCodeName, eneryDataListTotal[itemcode.ItemCodeNumber].Values.ToList()); } resultList.ObjectName = eneryDataListTotal[maxcode].Select(p => p.Key.ToString(CultureInfo.InvariantCulture)).ToList(); } else { var item = new BLL.Itemcode().GetItemcodeList(" and ItemCodeNumber='" + query.ItemCode + "'", " order by ItemcodeID")[0]; var lineChart = GetSingleItemCodeByObjectNew(query, query.ItemCode, time, 0); // resultList.Dept = new List<string>() {item.Unit}; resultList.ObjectName = lineChart.Select(p => p.Key.ToString()).ToList(); resultList.Enery.Add(item.ItemCodeName, lineChart.Select(p => decimal.Parse(p.Value.ToString())).ToList()); } foreach (var baseLayerObject in resultList.ObjectName) { resultList.Dept.Add(dept); } return resultList; }