Ejemplo n.º 1
0
        public ResultContrast IndexContrastChart()
        {
            ResultContrast refResutl = new ResultContrast();

            try
            {
                int inputValue = int.Parse(_ntsPage.Request["cType"]);
                switch (inputValue)
                {
                case 1:
                    refResutl = IndexContrastObjsChart();
                    break;

                case 2:
                    refResutl = IndexContrastPeriodsChart();
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                ResultContrast con     = new ResultContrast();
                ExecuteProcess process = new ExecuteProcess();
                process.ExceptionMsg = ex.Message;
                process.Success      = false;
                con.ActionInfo       = process;
                return(con);
            }
            return(refResutl);
        }
Ejemplo n.º 2
0
        public static ResultContrast ShowEnergyAnalyseLineChart(QueryAnalyse queryAnalyse, string[] chartObject, string[] chartDept, Dictionary <string, List <decimal> > dir)
        {
            //表格数据定义
            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 = '" + queryAnalyse.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  = queryAnalyse.StartTime.ToString();
                    ener.Val = Math.Round(d.Value.Sum(), 2);

                    compareItem.name = d.Key;
                    compareItem.data = d.Value;
                    compareList.Add(compareItem);

                    enerList.Add(ener);
                    Index++;
                }
                if (chartDept.Length > 0)
                {
                    lineJson.Unit = chartDept[0];
                    contrast.Unit = chartDept[0];
                }
                lineJson.CompareType = "object";

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

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

                //lineJson.series =
                return(contrast);
            }
        }
Ejemplo n.º 3
0
        public string ExportQueryPeriod()
        {
            var inputValue = _ntsPage.Request["inputs"];;
            var query      = Newtonsoft.Json.JsonConvert.DeserializeObject <QueryContrastPeriods>(inputValue);

            var result = new ResultCompare();

            switch (query.QueryType)
            {
            case QueryOrderType.Default:
                result = Framework.Common.BaseWcf.CreateChannel <ServiceInterface.IEnergyContrastService>("EnergyContrastService")
                         .GetPeriodsCompareChart(query);
                break;

            case QueryOrderType.UnitArea:
                result = Framework.Common.BaseWcf.CreateChannel <ServiceInterface.IEnergyContrastService>("EnergyContrastService")
                         .GetPeriodsCompareChart(query);
                break;

            case QueryOrderType.UnitPerson:
                result = Framework.Common.BaseWcf.CreateChannel <ServiceInterface.IEnergyContrastService>("EnergyContrastService")
                         .GetPersonNumPeriodsCompareChart(query);;
                break;

            default:
                result = Framework.Common.BaseWcf.CreateChannel <ServiceInterface.IEnergyContrastService>("EnergyContrastService")
                         .GetPeriodsCompareChart(query);
                break;
            }
            string strAreaName = "";
            var    listObject  = dal.GetBaseLayerObjectList(" and layerobjectid = " + query.AreaId, "");

            if (listObject.Count > 0)
            {
                strAreaName = listObject[0].LayerObjectName;
            }
            string strDepName = "";

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

            switch (query.QueryType)
            {
            case QueryOrderType.CarbanOut:
                strDepName = "T";
                break;

            case QueryOrderType.ConvCoal:
                strDepName = "T";
                break;

            case QueryOrderType.Renminbi:
                strDepName = "元";
                break;
            }

            ResultContrast resultCon = JsonForHightChartsNew.IndexPeriodsContrastObjsChart(query, strAreaName, 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 + "\"}");
            }
        }
Ejemplo n.º 4
0
        public ResultContrast IndexContrastPeriodsChart()
        {
            try
            {
                var inputValue = _ntsPage.Request["inputs"];;
                var query      = Newtonsoft.Json.JsonConvert.DeserializeObject <QueryContrastPeriods>(inputValue);

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

                case QueryOrderType.UnitArea:
                    result = Framework.Common.BaseWcf.CreateChannel <ServiceInterface.IEnergyContrastService>("EnergyContrastService")
                             .GetAreaPeriodsCompareChart(query);
                    break;

                case QueryOrderType.UnitPerson:
                    result = Framework.Common.BaseWcf.CreateChannel <ServiceInterface.IEnergyContrastService>("EnergyContrastService")
                             .GetPersonNumPeriodsCompareChart(query);;
                    break;

                default:
                    result = Framework.Common.BaseWcf.CreateChannel <ServiceInterface.IEnergyContrastService>("EnergyContrastService")
                             .GetPeriodsCompareChart(query);
                    break;
                }

                string strAreaName = "";
                var    listObject  = dal.GetBaseLayerObjectList(" and layerobjectid = " + query.AreaId, "");
                if (listObject.Count > 0)
                {
                    strAreaName = listObject[0].LayerObjectName;
                }
                string strDepName = "";
                if (result.Dept.Count > 0)
                {
                    strDepName = result.Dept[0].ToString();
                }
                else
                {
                    throw new Exception("没有数据信息");
                }

                switch (query.QueryType)
                {
                case QueryOrderType.CarbanOut:
                    strDepName = "T";
                    break;

                case QueryOrderType.ConvCoal:
                    strDepName = "T";
                    break;

                case QueryOrderType.Renminbi:
                    strDepName = "元";
                    break;
                }
                return(JsonForHightChartsNew.IndexPeriodsContrastObjsChart(query, strAreaName, result.ObjectName.ToArray(), strDepName,
                                                                           result.Enery));
            }
            catch (Exception ex)
            {
                ResultContrast con     = new ResultContrast();
                ExecuteProcess process = new ExecuteProcess();
                process.ExceptionMsg = ex.Message;
                process.Success      = false;
                con.ActionInfo       = process;
                return(con);
            }
        }
Ejemplo n.º 5
0
        public ResultContrast IndexContrastObjsChart()
        {
            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("请选择多个对象进行比较!");
                }

                EnergyAnalyseQueryType typeItemCode = oderObject.QueryType;
                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.IndexContrastObjsChart(query, "对比柱状图", result.ObjectName.ToArray(), strDepName,
                                                                    result.Enery));
            }
            catch (Exception ex)
            {
                ResultContrast con     = new ResultContrast();
                ExecuteProcess process = new ExecuteProcess();
                process.ExceptionMsg = ex.Message;
                process.Success      = false;
                con.ActionInfo       = process;
                return(con);
            }
        }