Esempio n. 1
0
        /// <summary>
        /// 显示柱状图
        /// </summary>
        /// <param name="itemName"></param>
        /// <param name="chartObject"></param>
        /// <param name="chartDept"></param>
        /// <param name="dir"></param>
        /// <returns></returns>
        public static ResultContrast IndexContrastObjsChart(QueryCompare query, string itemName, string[] chartObject, string chartDept, Dictionary<string, List<decimal>> dir)
        {
            // var test = from r in dir select Math.Round(r.Value.ToArray(),2);

            //表格数据定义
            List<EnergyContrst> enerList = new List<EnergyContrst>();

            ResultContrast contrast = new ResultContrast();
            ExecuteProcess execu = new ExecuteProcess();
            if (chartObject.Length == 0)
            {
                execu.Success = false;
                execu.ExceptionMsg = "暂无数据信息";
                execu.ActionName = "";
                execu.ActionUser = "";
                execu.ActionTime = System.DateTime.Now;
            }
            else
            {
                execu.Success = true;
                execu.ExceptionMsg = "";
            }

            string sql = " and ItemCodeNumber = '" + query.ItemCode + "'";
            List<NTS.WEB.Model.Itemcode> itemList = Framework.Common.BaseWcf.CreateChannel<ServiceInterface.IEnergyContrastService>("EnergyContrastService")
                                 .GetItemCodeList(sql, "");

            contrast.ActionInfo = execu;

            #region 数据series
            LineJson lineJson = new LineJson();
            List<EneryCompare> compareList = new List<EneryCompare>();
            #endregion

            int Index = 0;
            StringBuilder chartNew = new StringBuilder();
            {
                foreach (var d in dir)
                {

                    EnergyContrst ener = new EnergyContrst();

                    EneryCompare compareItem = new EneryCompare();

                    if (itemList.Count == 0)
                    {
                        ener.EneType = "总能耗";
                    }
                    else
                    {
                        ener.EneType = itemList[0].ItemCodeName;
                    }

                    ener.Obj = d.Key;
                    ener.Tm = GetTimeTitleByStartTimeAndEndTime(query.StartTime, query.EndTime);
                    ener.Val = Math.Round(d.Value.Sum(), 2);
                    // 取小数点后2位
                    List<decimal> dirValue = new List<decimal>();
                    foreach (var item in d.Value)
                    {
                        dirValue.Add(Math.Round(item, 2));
                    }
                    compareItem.id = query.ObjectNum[Index].ToString();
                    compareItem.name = d.Key;
                    compareItem.data = dirValue;
                    compareList.Add(compareItem);

                    enerList.Add(ener);
                    Index++;
                }

                lineJson.Unit = chartDept;
                contrast.Unit = chartDept;

                lineJson.CompareType = "object";

                contrast.ContrastLst = enerList; // 表格数据。

                lineJson.series = compareList;
                contrast.lineJson = lineJson;

                //lineJson.series =
                return contrast;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 显示柱状图
        /// </summary>
        /// <param name="itemName"></param>
        /// <param name="chartObject"></param>
        /// <param name="chartDept"></param>
        /// <param name="dir"></param>
        /// <returns></returns>
        public static ResultObjLst IndexContrastObjsLst(QueryCompare query, string[] chartObject, string chartDept, Dictionary<string, List<decimal>> dir)
        {
            ResultObjLst lstReult = new ResultObjLst();

            ExecuteProcess execu = new ExecuteProcess();
            if (chartObject.Length == 0)
            {
                execu.Success = false;
                execu.ExceptionMsg = "暂无数据信息";
                execu.ActionName = "";
                execu.ActionUser = "";
                execu.ActionTime = System.DateTime.Now;
            }
            else
            {
                execu.Success = true;
                execu.ExceptionMsg = "";
            }

            lstReult.Unit = chartDept;

            lstReult.ActionInfo = execu;

            string sql = " and ItemCodeNumber = '" + query.ItemCode + "'";
            List<NTS.WEB.Model.Itemcode> itemList = Framework.Common.BaseWcf.CreateChannel<ServiceInterface.IEnergyContrastService>("EnergyContrastService")
                                 .GetItemCodeList(sql, "");

            #region 数据列表
            List<ObjRecord> objLst = new List<ObjRecord>();
            #endregion

            int Index = 0;
            StringBuilder chartNew = new StringBuilder();
            {
                foreach (var d in dir)
                {
                    ObjRecord record = new ObjRecord();

                    record.ObjTime = d.Key;
                    record.MaxValue = Math.Round(d.Value.Max(), 2);
                    record.MinValue = Math.Round(d.Value.Min(), 2);
                    record.TotalValue = Math.Round(d.Value.Sum(), 2);
                    record.AvgValue = Math.Round(d.Value.Average(), 2);
                    objLst.Add(record);
                }
            }
            lstReult.ObjLst = objLst;
            return lstReult;
        }
Esempio n. 3
0
        public ResultCompare GetCompareChart(QueryCompare query)
        {
            #region 定义区

            query.ClassId = 1;  // 给区域分类

            var resultList = new ResultView.ResultCompare
            {
                ObjectName = new List<string>(),
                Enery = new Dictionary<string, List<decimal>>(),
                Dept = new List<string>()
            };

            #endregion

            var olist = query.ObjectNum.Aggregate(string.Empty, (current, q) => current + ("," + q.ToString()));
            if (olist.Length > 0)
            {
                List<Model.BaseLayerObject> objectList;
                if (query.ClassId == 1)
                {
                    objectList = new BLL.BaseLayerObject().GetBaseLayerObjectList(
                           string.Format(" and layerobjectid in ({0})", olist.Substring(1)), " order by LayerObjectID");
                }
                else
                {
                    objectList = new BLL.BaseLayerObject().GetBaseFuncLayerObjectList(
                    string.Format(" and layerobjectid in ({0})", olist.Substring(1)), " order by LayerObjectID");
                }

                foreach (var o in objectList)
                {
                    var basicQuery = new BasicQuery
                    {
                        EndTime = query.EndTime,
                        StartTime = query.StartTime,
                        ItemCode = query.ItemCode,
                        Unit = query.Unit
                    };
                    basicQuery.ObjectNum = o.LayerObjectID;
                    var result = GetQueryLineChart(basicQuery);
                    resultList.ObjectName = result.ObjectName;
                    if (query.ItemCode != "00000")
                    {
                        var itemList = new BLL.Itemcode().GetItemcodeList(" and ItemCodeNumber='" + query.ItemCode + "'", " order by ItemcodeID")[0];
                        resultList.Enery.Add(o.LayerObjectName, result.Enery[itemList.ItemCodeName]);
                        for (int i = 0; i < result.Dept.Count; i++)
                        {
                            resultList.Dept.Add(itemList.Unit);
                        }
                    }
                    else
                    {
                        var tempValue = new decimal[result.Enery[result.Enery.Keys.First<string>()].Count];
                        foreach (var re in result.Enery)
                        {
                            for (var i = 0; i < re.Value.Count; i++)
                            {
                                tempValue[i] += re.Value[i];
                            }
                        }
                        for (int i = 0; i < result.Dept.Count; i++)
                        {
                            resultList.Dept.Add("T");
                        }
                        resultList.Enery.Add(o.LayerObjectName, tempValue.ToList());
                    }
                }

                return resultList;
            }
            return null;
        }
Esempio n. 4
0
 public ResultCompare GetCompareChart(QueryCompare query)
 {
     return new NTS.WEB.BLL.Charts().GetCompareChart(query);
 }
Esempio n. 5
0
        public string ExportQueryObjs()
        {
            var inputValue = _ntsPage.Request["inputs"]; ;
            var oderObject = Newtonsoft.Json.JsonConvert.DeserializeObject<QueryOrderObjects>(inputValue);

            //var inputValue = _ntsPage.Request.Form["Inputs"];
            //var tabId = int.Parse(_ntsPage.Request.Form["TabId"]);
            //var query = Newtonsoft.Json.JsonConvert.DeserializeObject<QueryCompare>(inputValue);
            //var result = new ResultCompare();

            QueryCompare query = new QueryCompare();
            query.StartTime = oderObject.StartTime;
            query.EndTime = oderObject.EndTime;
            query.ObjectNum = oderObject.AreaIdLst;
            query.ItemCode = oderObject.ItemCode;
            query.ObjType = oderObject.ObjType;
            query.Unit = oderObject.Particle;

            var result = new ResultCompare();
            switch (oderObject.QueryType)
            {
                case EnergyAnalyseQueryType.Default:
                    result = Framework.Common.BaseWcf.CreateChannel<ServiceInterface.IEnergyContrastService>("EnergyContrastService")
                                  .GetCompareChart(oderObject);
                    break;

                case EnergyAnalyseQueryType.UnitArea:
                    result = Framework.Common.BaseWcf.CreateChannel<ServiceInterface.IEnergyContrastService>("EnergyContrastService")
                                  .GetAreaCompareChart(oderObject);
                    break;

                case EnergyAnalyseQueryType.UnitPerson:
                    result = Framework.Common.BaseWcf.CreateChannel<ServiceInterface.IEnergyContrastService>("EnergyContrastService")
                                 .GetPersonNumCompareChart(oderObject); ;
                    break;
                default:
                    result = Framework.Common.BaseWcf.CreateChannel<ServiceInterface.IEnergyContrastService>("EnergyContrastService")
                                .GetCompareChart(oderObject);
                    break;
            }

            string strDepName = "";
            if (result.Dept.Count > 0)
            {
                strDepName = result.Dept[0].ToString();
            }
            else
            {
                throw new Exception("没有数据信息");
            }

            switch (oderObject.QueryType)
            {
                case EnergyAnalyseQueryType.Convert2Co2:
                    strDepName = "T";
                    break;
                case EnergyAnalyseQueryType.Convert2Coal:
                    strDepName = "T";
                    break;
                case EnergyAnalyseQueryType.Convert2Money:
                    strDepName = "元";
                    break;
            }

            ResultContrast resultCon = JsonForHightChartsNew.IndexContrastObjsChart(query, "对比柱状图", result.ObjectName.ToArray(), strDepName,
              result.Enery);
            try
            {
                if (resultCon.ContrastLst.Count > 0)
                {
                    DataTable dt = TableView.CreateContrastDataTable();
                    for (var r = 0; r < resultCon.ContrastLst.Count; r++)
                    {
                        DataRow dr = dt.NewRow();
                        dr[1] = resultCon.ContrastLst[r].Tm.ToString();
                        dr[2] = resultCon.ContrastLst[r].Obj;
                        dr[3] = resultCon.ContrastLst[r].EneType;
                        dr[4] = resultCon.ContrastLst[r].Val;
                        dt.Rows.Add(dr);
                    }
                    string temp_path = AppDomain.CurrentDomain.BaseDirectory + "temp_file\\";
                    if (!Directory.Exists(temp_path))
                    {
                        Directory.CreateDirectory(temp_path);
                        string[] files = Directory.GetFiles(temp_path);
                        foreach (string fn in files)
                        {
                            File.Delete(temp_path + fn);
                        }
                    }
                    string save_path = DateTime.Now.Ticks + ".xls";

                    string templatePath = AppDomain.CurrentDomain.BaseDirectory + "template\\能耗对比表.xls";

                    TemplateParam param = new TemplateParam("能耗对比表", new CellParam(0, 0), "", new CellParam(3, 0), false, new CellParam(4, 0));
                    //TemplateParam param = new TemplateParam("itemCodeName", new CellParam(1, 1),"",null, false, new CellParam(5, 0));
                    param.DataColumn = new[] { 0, 1, 2, 3, 4 };
                    param.ItemUnit = "(单位:" + result.Dept[0].ToString() + ")";
                    param.ItemUnitCell = new CellParam(3, 4);

                    param.SortColumn = 0;
                    dt.TableName = "能耗对比表";

                    ExportHelper.ExportExcel(dt, temp_path + save_path, templatePath, param);

                    return "{\"status\":\"success\",\"msg\":\"" + "/temp_file/" + save_path + "\"}";
                }
                else
                {
                    return "{\"status\":\"error\",\"msg\":\"导出失败:当前无任何数据\"}";
                }

            }
            catch (Exception ex)
            {
                return "{\"status\":\"error\",\"msg\":\"导出失败:由于当前无数据或其他原因导致" + ex.Message + "\"}";
            }
        }
Esempio n. 6
0
        public ResultObjLst IndexContrastObjsLst()
        {
            try
            {
                var inputValue = _ntsPage.Request["inputs"]; ;
                var oderObject = Newtonsoft.Json.JsonConvert.DeserializeObject<QueryOrderObjects>(inputValue);

                QueryCompare query = new QueryCompare();
                query.StartTime = oderObject.StartTime;
                query.EndTime = oderObject.EndTime;
                query.ObjectNum = oderObject.AreaIdLst;
                query.ItemCode = oderObject.ItemCode;
                query.ObjType = oderObject.ObjType;
                query.Unit = oderObject.Particle;

                if (oderObject.AreaIdLst.Count <= 1)
                {
                    throw new Exception("请选择多个对象进行比较!");
                }

                var result = new ResultCompare();
                switch (oderObject.QueryType)
                {
                    case EnergyAnalyseQueryType.Default:
                        result = Framework.Common.BaseWcf.CreateChannel<ServiceInterface.IEnergyContrastService>("EnergyContrastService")
                                      .GetCompareChart(oderObject);
                        break;

                    case EnergyAnalyseQueryType.UnitArea:
                        result = Framework.Common.BaseWcf.CreateChannel<ServiceInterface.IEnergyContrastService>("EnergyContrastService")
                                      .GetAreaCompareChart(oderObject);
                        break;

                    case EnergyAnalyseQueryType.UnitPerson:
                        result = Framework.Common.BaseWcf.CreateChannel<ServiceInterface.IEnergyContrastService>("EnergyContrastService")
                                     .GetPersonNumCompareChart(oderObject); ;
                        break;
                    default:
                        result = Framework.Common.BaseWcf.CreateChannel<ServiceInterface.IEnergyContrastService>("EnergyContrastService")
                                                  .GetCompareChart(oderObject);
                        break;
                }

                string strDepName = "";
                if (result.Dept.Count > 0)
                {
                    strDepName = result.Dept[0].ToString();
                }
                else
                {
                    throw new Exception("没有数据信息");
                }

                switch (oderObject.QueryType)
                {
                    case EnergyAnalyseQueryType.Convert2Co2:
                        strDepName = "T";
                        break;
                    case EnergyAnalyseQueryType.Convert2Coal:
                        strDepName = "T";
                        break;
                    case EnergyAnalyseQueryType.Convert2Money:
                        strDepName = "元";
                        break;
                }

                return JsonForHightChartsNew.IndexContrastObjsLst(query, result.ObjectName.ToArray(), strDepName,
                   result.Enery);
            }
            catch (Exception ex)
            {
                ResultObjLst lst = new ResultObjLst();
                ExecuteProcess process = new ExecuteProcess();
                process.ExceptionMsg = ex.Message;
                process.Success = false;
                lst.ActionInfo = process;
                return lst;
            }
        }