/// <summary> /// 导出excel数据 /// </summary> /// <param name="filename"></param> /// <param name="serieNo"></param> /// <returns></returns> public ActionResult ExportExcelChart(string filename, string serieNo) { ChartData chartData = null;// TempDataUtil.getChartData(serieNo+"_large"); if (chartData == null) { chartData = TempDataUtil.getChartData(serieNo); } IList<ExcelData> datas = new List<ExcelData>(); ExcelData data = new ExcelData(); string reportname = string.Empty; bool isMulti = false; if (chartData != null) { isMulti = ReportBuilder.isMulti(chartData.units); reportname = (filename.Equals("chart") ? "" : filename) + chartData.name.Replace("/", "").Replace(" ", ""); IList<string> xList = new List<string>(); string xname = Resources.SunResource.CUSTOMREPORT_CHART_TIME; if (chartData.names.Length > 0 && !string.IsNullOrEmpty(chartData.names[0])) { xname = chartData.names[0] + "[" + chartData.units[0] + "]"; } xList.Add(xname); int n = 1;// chartData.categories.Length > 100 ? 12 : 1; for (int k = 0; k < chartData.categories.Length; k = k + n) { string x = chartData.categories[k]; xList.Add(x); } data.Rows.Add(xList); IList<string> tmps = null; string[] series = new string[chartData.series.Count()]; for (int i = 0; i < chartData.series.Count(); i++) { if (i > 0 && isMulti) { data = new ExcelData(); } tmps = new List<string>(); string yname = chartData.series[i].name; tmps.Add(yname); for (int k = 0; k < chartData.series[i].data.Length; k = k + n) { float? f = chartData.series[i].data[k]; tmps.Add(f == null ? string.Empty : StringUtil.formatDouble(StringUtil.stringtoDouble(f.ToString()), "0.00")); } data.Rows.Add(tmps); if (isMulti) { int slen = yname.IndexOf("["); int endLen = yname.IndexOf("]"); if (slen > -1) { data.Title = yname.Substring(slen + 1, endLen - slen - 1); } else { data.Title = yname; } data.series = new String[] { chartData.series[i].name }; data.chartType = chartData.series[i].type; datas.Add(data); } else { series[i] = chartData.series[i].name; } } if (!isMulti && chartData.series.Count() > 0) { int slen = chartData.series[0].name.IndexOf("["); int endLen = chartData.series[0].name.IndexOf("]"); if (slen > -1) { data.Title = chartData.series[0].name.Substring(slen + 1, endLen - slen - 1); } else { data.Title = chartData.series[0].name; } data.series = series; data.chartType = chartData.series[0].type; datas.Add(data); } } ExcelStreamWriter xlsWriter = new ExcelStreamWriter(reportname, datas, chartData.units, reportname, "", isMulti); //散列图暂不生成 if (chartData.series.Length > 0 && "scatter".Equals(chartData.series[0].type)) { xlsWriter.Save(false); } else { xlsWriter.Save(true); } return File(xlsWriter.FullName, "text/xls; charset=UTF-8", urlcode(xlsWriter.FileName)); }
/// <summary> /// 导出excel数据 /// </summary> /// <param name="filename"></param> /// <param name="serieNo"></param> /// <returns></returns> public ActionResult DownLoadExcelRunData(IList<string> allmts, IDictionary<string, IDictionary<string, string>> timemtMap, string filename) { IList<ExcelData> datas = new List<ExcelData>(); ExcelData data = new ExcelData(); bool isMulti = false; //标题行 IList<string> xList = new List<string>(); xList.Add(" " + filename + " "); xList.Add(Resources.SunResource.REPORT_TIME); foreach (string key in timemtMap.Keys) { xList.Add(key); } data.Rows.Add(xList); datas.Add(data); IList<string> tmps = null; foreach (string mtkey in allmts) { data = new ExcelData(); tmps = new List<string>(); tmps.Add(" "); tmps.Add(mtkey); foreach (string key in timemtMap.Keys) { //第一列是时间 tmps.Add(timemtMap[key][mtkey]); } data.Rows.Add(tmps); datas.Add(data); } ExcelStreamWriter xlsWriter = new ExcelStreamWriter(filename, datas, new string[] { }, "", "", isMulti); xlsWriter.Save(false); return File(xlsWriter.FullName, "text/xls; charset=UTF-8", urlcode(xlsWriter.FileName)); }
private ExcelData BuildPlantDetails(IList<Plant> plants, string items, string estartdate, string eenddate) { ExcelData eData = new ExcelData(); IList<string> rowData = new List<string>(); double reductionRate = ItemConfigService.GetInstance().getCO2Config(); double dayEnergySum = 0; double totalEnergySum = 0; double dayPowerSum = 0; double installPowerSum = 0; double todayCo2Sum = 0; double totalCo2Sum = 0; double todayRevenuesum = 0; string[] strArray = null; if (items.Contains(',')) strArray = items.Split(','); else strArray = new string[] { }; rowData.Add("名称"); rowData.Add("国家"); rowData.Add("城市"); rowData.Add("创建时间"); #region Excel列名 foreach (string s in strArray) { switch (s) { case "1"://日发电量 rowData.Add("日发电量"); break; case "46"://累计发电量 rowData.Add("累计发电量" + estartdate + "/" + eenddate + " (kWh)"); break; case "2"://总发电量 rowData.Add("总发电量(kWh)"); break; case "3"://日功率 rowData.Add("日功率(kW)"); break; case "4"://总功率 rowData.Add("总功率(kW)"); break; case "5"://安装功率 rowData.Add("安装功率(kW)"); break; case "6"://今日CO2减排 rowData.Add("今日CO2减排(kg)"); break; case "7"://累计CO2减排 rowData.Add("累计CO2减排(kg)"); break; case "8"://今日收益 rowData.Add("今日收益"); break; case "9"://温度 rowData.Add("温度 (℃) "); break; case "10"://日照强度 rowData.Add("日照强度 (W/m2)"); break; case "44"://总每KWP发电量 rowData.Add("总每KWP发电量 (kWh/kWp)"); break; case "45"://日每KWP发电量 rowData.Add("日每KWP发电量 (kWh/kWp)"); break; default: break; } } rowData.Add("编号:是否实例电站:是否推荐电站");//最后一列显示编号 后面删除电站使用 #endregion eData.Rows.Add(rowData); foreach (Plant plant in plants) { rowData = new List<string>(); dayEnergySum += (plant.TotalDayEnergy); dayPowerSum += plant.TodayTotalPower; installPowerSum += plant.design_power; todayCo2Sum += (plant.TotalDayEnergy * reductionRate); totalCo2Sum += (plant.TotalEnergy * reductionRate); todayRevenuesum += (plant.TotalDayEnergy * plant.revenueRate); User user = UserService.GetInstance().Get((int)plant.userID); plant.currencies = user == null ? "$" : user.currencies; rowData.Add(plant.name); rowData.Add(plant.country); rowData.Add(plant.city); rowData.Add(plant.createDate.ToString("yyyy/MM/dd")); foreach (string s in strArray) { switch (s) { case "1"://日发电量 rowData.Add(string.Format("{0}", plant.TotalDayEnergy)); break; case "46"://累计发电量 double value = plantService.GetEnergy(plant, estartdate, eenddate); rowData.Add(string.Format("{0:0.00}", value)); totalEnergySum += value; break; case "2"://总发电量 rowData.Add(string.Format("{0:0.00}", plant.TotalEnergy)); break; case "3"://日功率 rowData.Add(string.Format("{0}", plant.TodayTotalPower)); break; case "4"://总功率 rowData.Add(string.Format("{0}", plant.TodayTotalPower)); break; case "5"://安装功率 rowData.Add(string.Format("{0}", plant.design_power)); break; case "6"://今日CO2减排 rowData.Add(string.Format("{0}", plant.TodayReductiong)); break; case "7"://累计CO2减排 rowData.Add(string.Format("{0:0} ", plant.TotalEnergy * reductionRate)); break; case "8"://今日收益 rowData.Add(string.Format("{0} {1}", plant.DisplayTodayRevenue, plant.currencies)); break; case "9"://温度 rowData.Add(double.IsNaN(plant.Temperature) ? "" : plant.Temperature.ToString("0")); break; case "10"://日照强度 rowData.Add(plant.Sunstrength == null ? "" : ((double)plant.Sunstrength).ToString("0.00")); break; case "44"://每KWP发电量 if (plant.design_power.Equals(0)) rowData.Add("0.00"); else rowData.Add((plant.TotalEnergy / plant.design_power).ToString("0.00")); break; case "45"://日每KWP发电量 if (plant.design_power.Equals(0)) rowData.Add("0.00"); else rowData.Add((plant.TotalDayEnergy / plant.design_power).ToString("0.00")); break; default: break; } } rowData.Add(string.Format("{0}:{1}:{2}", plant.id, plant.example_plant, plant.isNewPlant)); eData.Rows.Add(rowData); } rowData = new List<string>(); rowData.Add(string.Empty); rowData.Add(string.Empty); rowData.Add("电站总数:<br /> ∑ " + plants.Count); foreach (string s in strArray) { switch (s) { case "1"://日发电量汇总 rowData.Add("日发电量统计:<br /> ∑ " + computeEnergyUnit(dayEnergySum)); break; case "2"://总发电量汇总 rowData.Add("总发电量统计:<br /> ∑ " + computeEnergyUnit(plants.Sum(m => m.TotalEnergy))); break; case "44"://总每KWP发电量 double totalPlantEnergy = plants.Sum(m => m.TotalEnergy); double totalPlantDesignPower = plants.Sum(m => m.design_power); if (totalPlantEnergy == 0 || totalPlantDesignPower == 0) rowData.Add("总每KWP发电量:<br /> ∑ " + "0.00 kWh/kWp"); else rowData.Add("总每KWP发电量:<br /> ∑ " + (totalPlantEnergy / totalPlantDesignPower).ToString("0.00") + "kWh/kWp"); break; case "45"://日每KWP发电量 double totalDayEnergy = plants.Sum(m => m.TotalDayEnergy); double totalDesignPower = plants.Sum(m => m.design_power); if (totalDayEnergy == 0 || totalDesignPower == 0) rowData.Add("日每KWP发电量:<br /> ∑ " + " 0.00 kWh/kWp"); else rowData.Add("日每KWP发电量:<br /> ∑ " + (totalDayEnergy / totalDesignPower).ToString("0.00") + "kWh/kWp"); break; case "5"://安装功率汇总 rowData.Add("总安装功率:<br /> ∑ " + computeEnergyUnit(plants.Sum(m => m.design_power))); break; case "6"://今日CO2减排汇总 rowData.Add("今日CO2减排统计:<br /> ∑ " + computeReduceUnit(todayCo2Sum)); break; case "7"://累计CO2减排汇总 rowData.Add("累计CO2减排统计:<br /> ∑ " + computeReduceUnit(totalCo2Sum)); break; case "46"://累计发电量 rowData.Add(string.Format("累计发电量 :{0}-{1}<br />∑ {2}", estartdate, eenddate, computeEnergyUnit(totalEnergySum))); break; default: break; } } eData.Rows.Add(rowData); return eData; }
public ActionResult Collector_Output(string id, string sd, string ed) { Hashtable hashpara = new Hashtable(); hashpara["sd"] = sd; hashpara["ed"] = ed; int no = 0; int.TryParse(id, out no); Pager page = new Pager() { PageSize = ComConst.PageSize, PageIndex = no }; hashpara["page"] = page; CollectorInfoService collectorInfoService = CollectorInfoService.GetInstance(); IList<Collector> collectorInfos = collectorInfoService.GetCollectorsByPage(hashpara); IList<ExcelData> eDatas = new List<ExcelData>(); ExcelData data = new ExcelData(); IList<string> temp = new List<string>(); temp.Add("采集器编号"); temp.Add("密码"); temp.Add("分配电站"); temp.Add("电站时间"); temp.Add("导入时间"); temp.Add("是否启用"); temp.Add("工作状态"); data.Rows.Add(temp); foreach (Collector collector in collectorInfos) { if (collector.plantID.Equals(0) == false) collector.plant = plantService.GetPlantInfoById(collector.plantID); else collector.plant = null; temp = new List<string>(); temp.Add(collector.code); temp.Add(collector.password); temp.Add(collector.plant == null ? "未分配电站" : collector.plant.name); temp.Add(collector.plant == null ? "未分配电站" : DateTime.Now.AddHours(collector.plant.timezone).ToString("yy/MM/dd HH:mm")); temp.Add(collector.importDate.ToString("yy/MM/dd HH:mm")); temp.Add(collector.isUsed.Equals(true) ? "yes" : "no"); temp.Add(collector.plant == null ? "停止" : (collector.plant.isWork ? "工作" : "停止")); data.Rows.Add(temp); } eDatas.Add(data); ExcelStreamWriter writer = new ExcelStreamWriter(eDatas); writer.align = true; writer.Save("采集器列表"); return File(writer.FullName, "text/xlsx; charset=UTF-8", urlcode(writer.FileName)); }
public ActionResult Users_Output(string id) { int no = 0; int.TryParse(id, out no); Pager page = new Pager() { PageSize = ComConst.PageSize, PageIndex = no }; UserService userInfoService = UserService.GetInstance(); Hashtable para = new Hashtable(); para["page"] = page; para["startDate"] = Request.QueryString["sd"]; para["endDate"] = Request.QueryString["ed"]; para["hasplants"] = Request.QueryString["hasplants"]; IList<User> users = userInfoService.GetUsersByPage(para); IList<ExcelData> eDatas = new List<ExcelData>(); ExcelData data = new ExcelData(); IList<string> temp = new List<string>(); temp.Add("用户名"); temp.Add("注册电站"); temp.Add("国家"); temp.Add("性别"); temp.Add("创建时间"); data.Rows.Add(temp); foreach (User user in users) { temp = new List<string>(); temp.Add(user.username); temp.Add(user.HasPlantsStr); temp.Add(user.country); temp.Add(user.sex.Equals("0") ? "男" : "女"); temp.Add(user.createDate.ToString(ComConst.DateFormat)); data.Rows.Add(temp); } eDatas.Add(data); ExcelStreamWriter writer = new ExcelStreamWriter(eDatas); writer.align = true; writer.Save("用户列表"); return File(writer.FullName, "text/xlsx; charset=UTF-8", urlcode(writer.FileName)); }
private ExcelData BuildInvDetails(IList<Device> devices, string items, string estartdate, string eenddate) { ExcelData eData = new ExcelData(); double totalEnergy = 0; IList<string> rowData = new List<string>(); string[] strArray = null; if (items.Contains(',')) strArray = items.Split(','); else strArray = new string[] { }; rowData.Add("所属电站"); rowData.Add("设备名称"); rowData.Add("设备型号"); #region Excel列名 foreach (string s in strArray) { switch (s) { #region 标题 case "43"://累计发电量 rowData.Add(string.Format("累计发电量 {1}/{2}({0})", "kWh", estartdate, eenddate)); break; case "14"://机内空气温度 rowData.Add(string.Format("机内空气温度 ({0})", MonitorType.getMonitorTypeByCode(MonitorType.MIC_INVERTER_JNKQTEMPRATURE).unit)); break; case "15"://机内变压器温度 rowData.Add(string.Format("机内变压器温度 ({0})", MonitorType.getMonitorTypeByCode(MonitorType.MIC_INVERTER_JNBYQTEMPRATURE).unit)); break; case "16"://机内散热器温度 rowData.Add(string.Format("机内散热器温度 ({0})", MonitorType.getMonitorTypeByCode(MonitorType.MIC_INVERTER_JNSRQTEMPRATURE).unit)); break; case "17"://直流电压1 rowData.Add(string.Format("直流电压1 ({0})", MonitorType.getMonitorTypeByCode(MonitorType.MIC_INVERTER_DV1).unit)); break; case "18"://直流电流1 rowData.Add(string.Format("直流电流1 ({0})", MonitorType.getMonitorTypeByCode(MonitorType.MIC_INVERTER_DC1).unit)); break; case "19"://直流电压2 rowData.Add(string.Format("直流电压2 ({0})", MonitorType.getMonitorTypeByCode(MonitorType.MIC_INVERTER_DV2).unit)); break; case "20"://直流电流2 rowData.Add(string.Format("直流电流2 ({0})", MonitorType.getMonitorTypeByCode(MonitorType.MIC_INVERTER_DC2).unit)); break; case "21"://直流电压3 rowData.Add(string.Format("直流电压3 ({0})", MonitorType.getMonitorTypeByCode(MonitorType.MIC_INVERTER_DV3).unit)); break; case "22"://直流电流3 rowData.Add(string.Format("直流电流3 ({0})", MonitorType.getMonitorTypeByCode(MonitorType.MIC_INVERTER_DC3).unit)); break; case "23"://总直流功率 rowData.Add(string.Format("总直流功率 ({0})", MonitorType.getMonitorTypeByCode(MonitorType.MIC_INVERTER_TOTALDPOWER).unit)); break; case "24"://A相电压 rowData.Add(string.Format("A相电压 ({0})", MonitorType.getMonitorTypeByCode(MonitorType.MIC_INVERTER_ADIRECTVOLT).unit)); break; case "25"://相电压 rowData.Add(string.Format("B相电压 ({0})", MonitorType.getMonitorTypeByCode(MonitorType.MIC_INVERTER_BDIRECTVOLT).unit)); break; case "26"://C相电压 rowData.Add(string.Format("C相电压 ({0})", MonitorType.getMonitorTypeByCode(MonitorType.MIC_INVERTER_CDIRECTVOLT).unit)); break; case "27"://A相电流 rowData.Add(string.Format("A相电流 ({0})", MonitorType.getMonitorTypeByCode(MonitorType.MIC_INVERTER_ADIRECTCURRENT).unit)); ; break; case "28"://B相电流 rowData.Add(string.Format("B相电流 ({0})", MonitorType.getMonitorTypeByCode(MonitorType.MIC_INVERTER_BDIRECTCURRENT).unit)); break; case "29"://C相电流 rowData.Add(string.Format("C相电流 ({0})", MonitorType.getMonitorTypeByCode(MonitorType.MIC_INVERTER_CDIRECTCURRENT).unit)); break; case "30"://A相有功功率 rowData.Add(string.Format("A相有功功率 ({0})", MonitorType.getMonitorTypeByCode(MonitorType.MIC_INVERTER_ADIRECTPOWER).unit)); break; case "31"://B相有功功率 rowData.Add(string.Format("B相有功功率 ({0})", MonitorType.getMonitorTypeByCode(MonitorType.MIC_INVERTER_BDIRECTPOWER).unit)); break; case "32":// C相有功功率 rowData.Add(string.Format("C相有功功率 ({0})", MonitorType.getMonitorTypeByCode(MonitorType.MIC_INVERTER_CDIRECTPOWER).unit)); break; case "33"://总有功功率 rowData.Add(string.Format("总有功功率 ({0})", MonitorType.getMonitorTypeByCode(MonitorType.MIC_INVERTER_TOTALYGPOWER).unit)); break; case "34"://总无功功率 rowData.Add(string.Format("总无功功率 ({0})", MonitorType.getMonitorTypeByCode(MonitorType.MIC_INVERTER_TOTALWGPOWER).unit)); break; case "35"://总功率因数 rowData.Add(string.Format("总功率因数 ({0})", MonitorType.getMonitorTypeByCode(MonitorType.MIC_INVERTER_TOTALPOWERFACTOR).unit)); break; case "36"://电网频率 rowData.Add(string.Format("电网频率 ({0})", MonitorType.getMonitorTypeByCode(MonitorType.MIC_INVERTER_DWPL).unit)); break; case "37"://逆变器效率 rowData.Add(string.Format("逆变器效率 ({0})", MonitorType.getMonitorTypeByCode(MonitorType.MIC_INVERTER_INVERTERXL).unit)); break; case "38"://安装功率 rowData.Add(string.Format("安装功率 ({0})", "kW")); break; case "39"://逆变器效率 rowData.Add(string.Format("逆变器效率 ({0})", MonitorType.getMonitorTypeByCode(MonitorType.MIC_INVERTER_INVERTERXL).unit)); break; case "40"://今日发电量 rowData.Add(string.Format("今日发电量 ({0})", "kWh")); break; case "41"://本月发电量 rowData.Add(string.Format("本月发电量 ({0})", "kWh")); break; case "42"://本月每KWP发电量 rowData.Add(string.Format("本月每KWP发电量 ({0})", "kWh/kWp")); break; case "13"://总发电量 rowData.Add(string.Format("总发电量 ({0})", "kWh")); break; default: break; #endregion } } #endregion #region 内容 eData.Rows.Add(rowData); float curMonthEnergyTotal = 0; foreach (Device d in devices) { float curMonthEnergy = DeviceMonthDayDataService.GetInstance().GetDeviceMonthDayData(DateTime.Now.Year, d.id, DateTime.Now.Month).count(); curMonthEnergyTotal += curMonthEnergy; rowData = new List<string>(); rowData.Add(d.plant.name); rowData.Add(d.fullName); rowData.Add(d.xinhaoName); foreach (string s in strArray) { switch (s) { case "43"://累计发电量 double value = deviceService.GetEnergy(d.id, estartdate, eenddate); totalEnergy += value; rowData.Add(value.ToString("0.00")); break; case "14"://机内空气温度 if (d.runData == null) rowData.Add("0"); else rowData.Add(d.runData.getMonitorValueWithStatus(MonitorType.MIC_INVERTER_JNKQTEMPRATURE)); break; case "15"://机内变压器温度 if (d.runData == null) rowData.Add("0"); else rowData.Add(d.runData.getMonitorValueWithStatus(MonitorType.MIC_INVERTER_JNBYQTEMPRATURE)); break; case "16"://机内散热器温度 if (d.runData == null) rowData.Add("0"); else rowData.Add(d.runData.getMonitorValueWithStatus(MonitorType.MIC_INVERTER_JNSRQTEMPRATURE)); break; case "17"://直流电压1 if (d.runData == null) rowData.Add("0"); else rowData.Add(d.runData.getMonitorValueWithStatus(MonitorType.MIC_INVERTER_DV1)); break; case "18"://直流电流1 if (d.runData == null) rowData.Add("0"); else rowData.Add(d.runData.getMonitorValueWithStatus(MonitorType.MIC_INVERTER_DC1)); break; case "19"://直流电压2 if (d.runData == null) rowData.Add("0"); else rowData.Add(d.runData.getMonitorValueWithStatus(MonitorType.MIC_INVERTER_DV2)); break; case "20"://直流电流2 if (d.runData == null) rowData.Add("0"); else rowData.Add(d.runData.getMonitorValueWithStatus(MonitorType.MIC_INVERTER_DC2)); break; case "21"://直流电压3 if (d.runData == null) rowData.Add("0"); else rowData.Add(d.runData.getMonitorValueWithStatus(MonitorType.MIC_INVERTER_DV3)); break; case "22"://直流电流3 if (d.runData == null) rowData.Add("0"); else rowData.Add(d.runData.getMonitorValueWithStatus(MonitorType.MIC_INVERTER_DC3)); break; case "23"://总直流功率 if (d.runData == null) rowData.Add("0"); else rowData.Add(d.runData.getMonitorValueWithStatus(MonitorType.MIC_INVERTER_TOTALDPOWER)); break; case "24"://A相电压 if (d.runData == null) rowData.Add("0"); else rowData.Add(d.runData.getMonitorValueWithStatus(MonitorType.MIC_INVERTER_ADIRECTVOLT)); break; case "25"://相电压 if (d.runData == null) rowData.Add("0"); else rowData.Add(d.runData.getMonitorValueWithStatus(MonitorType.MIC_INVERTER_BDIRECTVOLT)); break; case "26"://C相电压 if (d.runData == null) rowData.Add("0"); else rowData.Add(d.runData.getMonitorValueWithStatus(MonitorType.MIC_INVERTER_CDIRECTVOLT)); break; case "27"://A相电流 if (d.runData == null) rowData.Add("0"); else rowData.Add(d.runData.getMonitorValueWithStatus(MonitorType.MIC_INVERTER_ADIRECTCURRENT)); break; case "28"://B相电流 if (d.runData == null) rowData.Add("0"); else rowData.Add(d.runData.getMonitorValueWithStatus(MonitorType.MIC_INVERTER_BDIRECTCURRENT)); break; case "29"://C相电流 if (d.runData == null) rowData.Add("0"); else rowData.Add(d.runData.getMonitorValueWithStatus(MonitorType.MIC_INVERTER_CDIRECTCURRENT)); break; case "30"://A相有功功率 if (d.runData == null) rowData.Add("0"); else rowData.Add(d.runData.getMonitorValueWithStatus(MonitorType.MIC_INVERTER_ADIRECTPOWER)); break; case "31"://B相有功功率 if (d.runData == null) rowData.Add("0"); else rowData.Add(d.runData.getMonitorValueWithStatus(MonitorType.MIC_INVERTER_BDIRECTPOWER)); break; case "32":// C相有功功率 if (d.runData == null) rowData.Add("0"); else rowData.Add(d.runData.getMonitorValueWithStatus(MonitorType.MIC_INVERTER_CDIRECTPOWER)); break; case "33"://总有功功率 if (d.runData == null) rowData.Add("0"); else rowData.Add(d.runData.getMonitorValueWithStatus(MonitorType.MIC_INVERTER_TOTALYGPOWER)); break; case "34"://总无功功率 if (d.runData == null) rowData.Add("0"); else rowData.Add(d.runData.getMonitorValueWithStatus(MonitorType.MIC_INVERTER_TOTALWGPOWER)); break; case "35"://总功率因数 if (d.runData == null) rowData.Add("0"); else rowData.Add(d.runData.getMonitorValueWithStatus(MonitorType.MIC_INVERTER_TOTALPOWERFACTOR)); break; case "36"://电网频率 if (d.runData == null) rowData.Add("0"); else rowData.Add(d.runData.getMonitorValueWithStatus(MonitorType.MIC_INVERTER_DWPL)); break; case "37"://逆变器效率 if (d.runData == null) rowData.Add("0"); else rowData.Add(d.runData.getMonitorValueWithStatus(MonitorType.MIC_INVERTER_INVERTERXL)); break; case "38"://安装功率 if (d.runData == null) rowData.Add("0"); else rowData.Add(d.designPower.ToString("0.00")); break; case "39"://逆变器效率 if (d.runData == null) rowData.Add("0"); else rowData.Add(d.runData.getMonitorValueWithStatus(MonitorType.MIC_INVERTER_INVERTERXL)); break; case "40"://今日发电量 if (d.runData == null) rowData.Add("0"); else rowData.Add(d.TodayEnergy(d.plant.timezone).ToString("0.00")); break; case "41"://本月发电量 rowData.Add(curMonthEnergy.ToString("0.00")); break; case "42"://本月每KWP发电量 rowData.Add(Math.Round(curMonthEnergy / d.chartPower, 2).ToString("0.00")); break; case "13"://总发电量 rowData.Add(d.TotalEnergy.ToString("0.00")); break; default: break; } } eData.Rows.Add(rowData); } #endregion #region 统计 rowData = new List<string>(); rowData.Add(string.Empty); rowData.Add(string.Empty); rowData.Add(string.Format("{0}:<br /> ∑{1}", "总设备数", devices.Count)); foreach (string s in strArray) { switch (s) { case "40"://今日发电量 rowData.Add(string.Format("{0}:<br />∑{1}", "今日发电量统计", computeEnergyUnit(devices.Where(m => m.runData != null).Sum(m => m.TodayEnergy(m.plant.timezone))))); break; case "41"://本月发电量 rowData.Add(string.Format("{0}:<br />∑{1}", "本月发电量统计", computeEnergyUnit(curMonthEnergyTotal))); break; case "13"://总发电量 rowData.Add(string.Format("{0}:<br />∑{1}", "总发电量统计", computeEnergyUnit(devices.Sum(m => m.TotalEnergy)))); break; case "43"://累计发电量 rowData.Add(string.Format("{0}:{2}-{3}<br />∑{1}", "累计发电量", computeEnergyUnit(totalEnergy), estartdate, eenddate)); break; default: break; } } eData.Rows.Add(rowData); #endregion return eData; }
public ActionResult Plants_Output(string id) { int no; int.TryParse(id, out no); Pager page = new Pager() { PageSize = ComConst.PageSize, PageIndex = no }; PlantService service = PlantService.GetInstance(); IList<Plant> plants = service.GetPlantByPage(page); IList<ExcelData> eDatas = new List<ExcelData>(); ExcelData data = new ExcelData(); IList<string> temp = new List<string>(); temp.Add("名称"); temp.Add("国家"); temp.Add("城市"); temp.Add("电话"); temp.Add("制造商"); temp.Add("型号类型"); data.Rows.Add(temp); foreach (Plant plant in plants) { temp = new List<string>(); temp.Add(plant.name); temp.Add(plant.country); temp.Add(plant.city); temp.Add(plant.phone); temp.Add(plant.manufacturer); temp.Add(plant.module_type); data.Rows.Add(temp); } eDatas.Add(data); ExcelStreamWriter writer = new ExcelStreamWriter(eDatas); writer.Save("电站列表"); return File(writer.FullName, "text/xlsx; charset=UTF-8", urlcode(writer.FileName)); }
public ActionResult Down_Device_HLX(string pname, string mname, string orderby) { IList<ExcelData> eDatas = new List<ExcelData>(); ExcelData eData = new ExcelData(); IList<string> rowData = null; rowData = new List<string>(); rowData.Add("所属电站"); rowData.Add("名称"); rowData.Add("设备型号"); rowData.Add("国家"); rowData.Add("城市"); rowData.Add("接入传感器路数"); rowData.Add("直流母线电压 "); rowData.Add("总电流"); eData.Rows.Add(rowData); IList<Device> devices = load_device(pname, mname, string.Empty, DeviceData.HUILIUXIANG_CODE, false, orderby); foreach (Device d in devices) { rowData = new List<string>(); rowData.Add(d.plant.name); rowData.Add(string.IsNullOrEmpty(d.name) ? d.fullName : d.name); rowData.Add(d.xinhaoName); rowData.Add(d.plant.country); rowData.Add(d.plant.city); rowData.Add(d.getMonitor(MonitorType.MIC_BUSBAR_CGQLINENUM)); rowData.Add(d.getMonitor(MonitorType.MIC_BUSBAR_DCUXVOLT)); rowData.Add(d.getMonitor(MonitorType.MIC_BUSBAR_TOTALCURRENT)); eData.Rows.Add(rowData); } eDatas.Add(eData); ExcelStreamWriter writer = new ExcelStreamWriter(eDatas); writer.align = true; writer.Save("汇流箱列表"); return File(writer.FullName, "text/xlsx; charset=UTF-8", urlcode(writer.FileName)); }
public ActionResult Down_Device_EM(string pname, string mname, string orderby) { IList<ExcelData> eDatas = new List<ExcelData>(); ExcelData eData = new ExcelData(); IList<string> rowData = null; rowData = new List<string>(); rowData.Add("所属电站"); rowData.Add("名称"); rowData.Add("设备型号"); rowData.Add("国家"); rowData.Add("城市"); rowData.Add("当前日照"); rowData.Add("当前风速"); eData.Rows.Add(rowData); IList<Device> devices = load_device(pname, mname, string.Empty, DeviceData.ENVRIOMENTMONITOR_CODE, false, orderby); foreach (Device d in devices) { rowData = new List<string>(); rowData.Add(d.plant.name); rowData.Add(string.IsNullOrEmpty(d.name) ? d.fullName : d.name); rowData.Add(d.xinhaoName); rowData.Add(d.plant.country); rowData.Add(d.plant.city); rowData.Add(d.getMonitor(MonitorType.MIC_DETECTOR_SUNLINGHT)); rowData.Add(d.getMonitor(MonitorType.MIC_DETECTOR_WINDSPEED)); eData.Rows.Add(rowData); } eDatas.Add(eData); ExcelStreamWriter writer = new ExcelStreamWriter(eDatas); writer.align = true; writer.Save("环境检测仪列表"); return File(writer.FullName, "text/xlsx; charset=UTF-8", urlcode(writer.FileName)); }
public ActionResult Down_Device_Ammeter(string pname, string mname, string orderby) { IList<ExcelData> eDatas = new List<ExcelData>(); ExcelData eData = new ExcelData(); IList<string> rowData = null; rowData = new List<string>(); rowData.Add("所属电站"); rowData.Add("名称"); rowData.Add("设备型号"); rowData.Add("国家"); rowData.Add("城市"); rowData.Add("正向有功电度"); eData.Rows.Add(rowData); IList<Device> devices = load_device(pname, mname, string.Empty, DeviceData.AMMETER_CODE, false, orderby); foreach (Device d in devices) { rowData = new List<string>(); rowData.Add(d.plant.name); rowData.Add(string.IsNullOrEmpty(d.name) ? d.fullName : d.name); rowData.Add(d.xinhaoName); rowData.Add(d.plant.country); rowData.Add(d.plant.city); rowData.Add(d.getMonitor(MonitorType.MIC_AMMETER_POSITIVEACTIVEPOWERDEGREE)); eData.Rows.Add(rowData); } eDatas.Add(eData); ExcelStreamWriter writer = new ExcelStreamWriter(eDatas); writer.align = true; writer.Save("电表列表"); return File(writer.FullName, "text/xlsx; charset=UTF-8", urlcode(writer.FileName)); }
public ActionResult Users_Output(string id) { int no = 0; int.TryParse(id, out no); Pager page = new Pager() { PageSize = ComConst.PageSize, PageIndex = no }; UserService userInfoService = UserService.GetInstance(); IList<User> users = userInfoService.GetUsersByPage(page); IList<ExcelData> eDatas = new List<ExcelData>(); ExcelData data = new ExcelData(); IList<string> temp = new List<string>(); temp.Add("用户名"); temp.Add("国家"); temp.Add("性别"); data.Rows.Add(temp); foreach (User user in users) { temp = new List<string>(); temp.Add(user.username); temp.Add(user.country); temp.Add(user.sex.Equals("0") ? "男" : "女"); data.Rows.Add(temp); } eDatas.Add(data); ExcelStreamWriter writer = new ExcelStreamWriter(eDatas); writer.Save("用户列表"); return File(writer.FullName, "text/xlsx; charset=UTF-8", urlcode(writer.FileName)); }