/// <summary> /// 取得设备跨小时的测点数据 /// </summary> /// <param name="device">设备</param> /// <param name="startYYYYMMDDHH">开始时间 精确到小时 比如:2011062807</param> /// <param name="endYYYYMMDDHH">截止时间 精确到小时 比如:2011062817</param> /// <param name="intervalMins">数据统计的间隔时间,单位是分钟,比如60表示一小时</param> /// <param name="monitorCode">设备测点代码,参见MonitorType.cs</param> /// <returns>hashtable,key表示时间点 value是值</returns> public Hashtable GetDaydataList(IList <string> XAxis, Device device, string startYYYYMMDDHH, string endYYYYMMDDHH, int intervalMins, int monitorCode) { //累加多个单元的功率数据 Hashtable hhpowerHash = new Hashtable(); string startYYYYMM = startYYYYMMDDHH.Substring(0, 6); string endYYYYMM = endYYYYMMDDHH.Substring(0, 6); int startDD = int.Parse(startYYYYMMDDHH.Substring(6, 2)); int endDD = int.Parse(endYYYYMMDDHH.Substring(6, 2)); if (startYYYYMM.Equals(endYYYYMM)) { string year = startYYYYMM.Substring(0, 4); string month = startYYYYMM.Substring(4, 2); return(this.getMultiDayBetweenData(XAxis, device, year, month, startDD, endDD, intervalMins, monitorCode)); } else { string year = startYYYYMM.Substring(0, 4); string month = startYYYYMM.Substring(4, 2); int firstEndDD = CalenderUtil.getMonthDays(year + month); Hashtable firstHash = this.getMultiDayBetweenData(XAxis, device, year, month, startDD, firstEndDD, intervalMins, monitorCode); year = endYYYYMM.Substring(0, 4); month = endYYYYMM.Substring(4, 2); Hashtable secondHash = this.getMultiDayBetweenData(XAxis, device, year, month, 1, endDD, intervalMins, monitorCode); foreach (Object obj in secondHash.Keys) { firstHash.Add(obj, secondHash[obj]); } return(firstHash); } }
/// <summary> /// 今日发电量 /// 现为设备的累加起来 /// 原来是直接去采集器的实时数据中得今日发电量,那样不准确,因为那个实时数据中的发电量本来就不准确 /// </summary> public float TodayEnergy(int timezone) { float total = 0; if (devices == null) { return(total); } //if (this.collector.runData != null && CalenderUtil.formatDate(collector.runData.sendTime, "yyyyMMdd").Equals(CalenderUtil.curDateWithTimeZone(timezone, "yyyyMMdd"))) // total = collector.runData.dayEnergy; foreach (Device device in devices) { total += device.TodayEnergy(timezone); } //如果设备没有今日发电量则取下采集的实时数据中的今日发电量 if (total == 0) { if (this.collector != null && this.collector.runData != null && CalenderUtil.formatDate(collector.runData.sendTime, "yyyyMMdd").Equals(CalenderUtil.curDateWithTimeZone(timezone, "yyyyMMdd"))) { total = collector.runData.dayEnergy; } } return(StringUtil.stringtoFloat(Math.Round(total, 2).ToString())); }
/// <summary> /// 根据起始年月天取得横坐标 /// </summary> /// <param name="startYearMMDD"></param> /// <param name="endYearMMDD"></param> /// <returns></returns> public IList <String> getXseriesFromYYYYMMDD(string startYearMMDD, string endYearMMDD) { int startMM = int.Parse(startYearMMDD.Substring(4, 2)); int endMM = int.Parse(endYearMMDD.Substring(4, 2)); int startDD = int.Parse(startYearMMDD.Substring(6, 2)); int endDD = int.Parse(endYearMMDD.Substring(6, 2)); int startYYYY = int.Parse(startYearMMDD.Substring(0, 4)); int endYYYY = int.Parse(endYearMMDD.Substring(0, 4)); IList <string> resList = new List <string>(); for (int i = startYYYY; i <= endYYYY; i++) { for (int k = 1; k <= 12; k++) { if ((i == startYYYY && k < startMM) || (i == endYYYY && k > endMM)) { continue; } int monthDay = CalenderUtil.getMonthDays(i, k); for (int n = 1; n <= monthDay; n++) { if ((k == startMM && n < startDD) || (k == endMM && n > endDD)) { continue; } resList.Add(i + TableUtil.convertIntToMnthStr(k) + TableUtil.convertIntToMnthStr(n)); } } } return(resList); }
/// <summary> /// 将各个月度数据付给map /// </summary> /// <param name="monthDataMap"></param> /// <param name="unitYearData"></param> private void putMonthDayMap(Hashtable monthDataMap, CollectorMonthDayData unitMonthData) { int month = unitMonthData.month; int year = unitMonthData.year; //使用反射获得对象的号到最后一天的属性值 int days = CalenderUtil.getMonthDays(year, month); for (int i = 1; i <= days; i++) { string key = year + TableUtil.convertIntToMnthStr(month) + TableUtil.convertIntToMnthStr(i); System.Object obj = monthDataMap[key]; if (obj == null) { obj = 0; } object curValue = unitMonthData.GetType().GetProperty("d_" + i).GetValue(unitMonthData, null); if (curValue == null) { continue; } float value = StringUtil.stringtoFloat(curValue.ToString()); monthDataMap[key] = StringUtil.stringtoFloat(obj.ToString()) + value; } }
/// <summary> /// 根据起始年月天小时取得横坐标 /// </summary> /// <param name="startYearMMDDHH"></param> /// <param name="endYearMMDDHH"></param> /// <returns>天小时列表</returns> public IList <String> getXseriesFromYYYYMMDDHH(String startYearMMDDHH, string endYearMMDDHH, int intervalMins) { int startMM = int.Parse(startYearMMDDHH.Substring(4, 2)); int endMM = int.Parse(endYearMMDDHH.Substring(4, 2)); int startDD = int.Parse(startYearMMDDHH.Substring(6, 2)); int endDD = int.Parse(endYearMMDDHH.Substring(6, 2)); int startHH = int.Parse(startYearMMDDHH.Substring(8, 2)); int endHH = int.Parse(endYearMMDDHH.Substring(8, 2)); int startYYYY = int.Parse(startYearMMDDHH.Substring(0, 4)); int endYYYY = int.Parse(endYearMMDDHH.Substring(0, 4)); IList <string> resList = new List <string>(); for (int i = startYYYY; i <= endYYYY; i++) { for (int k = 1; k <= 12; k++) { if ((i == startYYYY && k < startMM) || (i == endYYYY && k > endMM)) { continue; } for (int n = 1; n <= CalenderUtil.getMonthDays(i, k); n++) { if ((k == startMM && n < startDD) || (k == endMM && n > endDD)) { continue; } for (int m = 0; m <= 23; m++) { //add by qianhb in 2011/12/17 去掉日中的5点之前和21点之后的 if (m > 21 || m < 5) { continue; } //add by qianhb in 2011/12/17 去掉日中的5点之前和21点之后的 end if ((n == startDD && m < startHH) || (n == endDD && m > endHH)) { continue; } if (intervalMins >= 60) { resList.Add(n.ToString("00") + m.ToString("00") + "00"); } else { for (int z = 0; z < 60; z = z + intervalMins) { resList.Add(n.ToString("00") + m.ToString("00") + z.ToString("00")); } } } } } } return(resList); }
/// <summary> /// 作者:鄢睿 /// 功能:通过电站列表获得单月天发电图表 /// 创建时间:2011年02月25日 /// 修改:胡圣忠 /// </summary> /// <param name="plantList">电站列表</param> /// <returns></returns> public ChartData MMDDChartBypList(IList <Plant> plantList, int year, int month, string chartType, string unit) { string monthstr = TableUtil.convertIntToMnthStr(month); string startYearMMDD = year + monthstr + "01"; string endYearMMDD = year + monthstr + CalenderUtil.getMonthDays(year, month); return(this.MMDDChartBypList(plantList, startYearMMDD, endYearMMDD, chartType, unit)); }
/// <summary> /// 是否超过一小时 /// </summary> /// <param name="tz"></param> /// <returns></returns> public bool Over1Hour(float tz) { if (runData == null) { return(true); } return((CalenderUtil.curDateWithTimeZone(tz) - runData.updateTime).TotalHours > 1); }
}//实时数据 /// <summary> /// 这里要加入时区来判断 /// 采集器停止发送数据时间 /// </summary> /// <param name="tz"></param> /// <returns>如果没有实时数据,则返回-1</returns> public int stopTime(float tz) { if (runData == null) { return(24); } return((int)(CalenderUtil.curDateWithTimeZone(tz) - runData.sendTime).TotalHours); }
/// <summary> /// 作者:鄢睿 /// 功能:取得设备多个年度的年月比较数据 /// 创建时间:2011年02月25日 /// </summary> /// <param name="device"></param> /// <param name="years"></param> /// <param name="monitorCode"></param> /// <param name="unit"></param> /// <param name="chartType"></param> /// <returns></returns> public ChartData DeviceMMCompare(Device device, IList <string> yearmms, MonitorType mt, string unit, string chartType, float rate) { ICollection <ICollection> keys = new List <ICollection>(); StringBuilder sb = new StringBuilder(); // foreach (string year in yearmms) //{ // sb.Append("," + year); //} string chartName = mt.name + " " + LanguageUtil.getDesc("CHART_TITLE_COMPARE"); IList <KeyValuePair <string, float?[]> > datas = new List <KeyValuePair <string, float?[]> >(); string[] chartTypes = new string[1] { chartType }; string[] units = new string[1] { unit }; string[] ynames = new string[1] { "" }; string[] ic = null; bool hasData = false; //取得多个年度的发电月数据 int i = 0; foreach (string yearMM in yearmms) { Hashtable dataHash = null; string curName = yearMM; dataHash = DeviceMonthDayDataService.GetInstance().DeviceYearMMDDList(device, yearMM, yearMM); string[] tmpic = base.getXseriesFromYYYYMMDD(yearMM + "01", yearMM + CalenderUtil.getMonthDays(yearMM).ToString("00")).ToArray(); if (ic == null || tmpic.Length > ic.Length) { ic = tmpic; } //如果有多个设备进行编辑,没有数据的时候也显示 //if (dataHash.Count > 0) //{ KeyValuePair <string, float?[]> data = GenerateChartData(curName, ic, dataHash, rate); datas.Add(data); //} //如果有数据则将有数据标识为true if (dataHash.Count > 0) { hasData = true; } i++; } if (!hasData) { //如果所有设备都没数据才清空数据,即图表中显示无数据提示 datas.Clear(); } string[] xAxis = formatXaxis(ic, ChartTimeType.MonthDay); return(ReportBuilder.createMultiJsonChartXY(chartName, xAxis, datas, ynames, chartTypes, units, fromApp)); }
/// <summary> /// 超过一小时 /// </summary> /// <param name="timezone"></param> /// <returns></returns> public bool over1Hour(int timezone) { if (this.collector == null || this.collector.runData == null) { return(true); } else { return((CalenderUtil.curDateWithTimeZone(timezone) - this.collector.runData.sendTime).TotalHours > 1); } }
/// <summary> /// 将不同类型报表所传时间转成起止时间 /// </summary> /// <param name="reportType"></param> /// <param name="datetime"></param> /// <returns></returns> public string[] convertToDateArr(int reportType, string datetime) { string[] dataArr = new string[2]; switch (reportType) { case DataReportType.TODAY_REPORT_CODE: dataArr[0] = datetime.Replace("-", "") + "07"; dataArr[1] = datetime.Replace("-", "") + "19"; break; case DataReportType.WEEK_REPORT_CODE: string[] darr1 = datetime.Split('-'); int year1 = int.Parse(darr1[0]); int month1 = int.Parse(darr1[1]); int day1 = int.Parse(darr1[2]); string bTime = new DateTime(year1, month1, day1).AddDays(-6).ToString("yyyy-MM-dd"); string[] darr2 = bTime.Split('-'); string year2 = darr2[0]; string month2 = darr2[1]; string day2 = darr2[2]; string beginTime = year2 + month2 + day2; string endTime = year1 + "" + month1.ToString("00") + "" + day1.ToString("00"); string[] t = new string[] { beginTime, endTime }; dataArr = t; break; case DataReportType.MONTH_REPORT_CODE: string[] darr = datetime.Split('-'); int year = int.Parse(darr[0]); int month = int.Parse(darr[1]); dataArr[0] = datetime.Replace("-", "") + "01"; dataArr[1] = datetime.Replace("-", "") + CalenderUtil.getMonthDays(year, month).ToString("00"); break; case DataReportType.YEAR_REPORT_CODE: dataArr[0] = datetime + "01"; dataArr[1] = datetime + "12"; break; case DataReportType.TOTAL_REPORT_CODE: dataArr = datetime.Split('-'); break; default: break; } return(dataArr); }
public ActionResult Execute(string id) { User user = UserUtil.getCurUser(); ViewData["logo"] = user.BigScreenLogoFomartPath; string value = string.Empty; if (string.IsNullOrEmpty(id) == false) { int pid = 0; int.TryParse(id, out pid); Plant plant = PlantService.GetInstance().GetPlantInfoById(pid); value = plant.id.ToString(); } else { //只有为到期的才显示 foreach (Plant plant in user.relatedPlants) { if (plant.PaymentLimitDate != null && plant.PaymentLimitDate < CalenderUtil.curDateWithTimeZone(plant.timezone)) { continue; } value += plant.id + ","; } } value = value.EndsWith(",") ? value.Substring(0, value.Length - 1) : value; ViewData["plantIds"] = value; ViewData["plantArray"] = value.Split(','); value = System.Configuration.ConfigurationManager.AppSettings["bigscreen_cache"]; if (string.IsNullOrEmpty(value)) { value = "5"; } ViewData["cacheminutes"] = value; value = System.Configuration.ConfigurationManager.AppSettings["bigscreen_page_interval"]; if (string.IsNullOrEmpty(value)) { value = "5000"; } ViewData["pageinterval"] = value; return(View()); }
/// <summary> /// 将各个月度数据付给map /// </summary> /// <param name="monthDataMap"></param> /// <param name="deviceMonthData"></param> /// <param name="rate">每个设备的rate可能不一样,所以要单独计算</param> private void putMonthDayMap(Hashtable monthDataMap, DeviceMonthDayData deviceMonthData, float rate) { int month = deviceMonthData.month; int year = deviceMonthData.year; //使用反射获得对象的号到最后一天的属性值 int days = CalenderUtil.getMonthDays(year, month); for (int i = 1; i <= days; i++) { string key = year + TableUtil.convertIntToMnthStr(month) + TableUtil.convertIntToMnthStr(i); System.Object obj = monthDataMap[key]; object tmpvalue = deviceMonthData.GetType().GetProperty("d_" + i).GetValue(deviceMonthData, null); float value = tmpvalue == null ? 0 : StringUtil.stringtoFloat(tmpvalue.ToString()); if (obj != null || tmpvalue != null) { monthDataMap[key] = (obj == null ? 0 : StringUtil.stringtoFloat(obj.ToString())) + value * rate; } } }
/// <summary> /// 取得自定义图表的数据 /// </summary> /// <param name="crt"></param> /// <returns></returns> private string GetCustomReport(CustomChart crt) { User user = UserUtil.getCurUser(); DateTime dt = CalenderUtil.curDateWithTimeZone(user.timezone); string ret = "sorry:" + Resources.SunResource.NODATA; if (crt != null) { Analysis(ref crt); ///多设备多测点单时间报表 List <DeviceStuct> list = new List <DeviceStuct>(); list = GetDeviceStucts(crt); string reportName = crt.reportName; switch (crt.timeInterval.Trim().ToUpper()) { case "YEAR": //if (crt.timeSlot.Trim().ToUpper().Equals("YEAR")) //{ ChartData chartData = CompareChartService.GetInstance().compareYearsMultiDeviceMultiMonitor(crt.reportName, list, getWorkYears(list)); ret = JsonUtil.convertToJson(chartData, typeof(ChartData)); //} break; case "MONTH": //if (crt.timeSlot.Trim().ToUpper().Equals("YEAR")) //{ //dtstart = dt.AddYears(-crt.tcounter.Value); //} //else if (crt.timeSlot.Trim().ToUpper().Equals("MONTH")) // { //dtstart = dt.AddMonths(-crt.tcounter.Value); //} chartData = CompareChartService.GetInstance().compareYearMMMultiDeviceMultiMonitor(crt.reportName, GetDeviceStucts(crt), crt.startTime, crt.endTime); ret = JsonUtil.convertToJson(chartData, typeof(ChartData)); break; case "DAY": //if (crt.timeSlot.Trim().ToUpper().Equals("DAY")) //{ //dtstart = dt.AddDays(-crt.tcounter.Value); // } //else if (crt.timeSlot.Trim().ToUpper().Equals("MONTH")) //{ //dtstart = dt.AddMonths(-crt.tcounter.Value); // } chartData = CompareChartService.GetInstance().compareMMDDMultiDeviceMultiMonitor(crt.reportName, GetDeviceStucts(crt), crt.startTime, crt.endTime); ret = JsonUtil.convertToJson(chartData, typeof(ChartData)); break; case "HOUR": //if (crt.timeSlot.Trim().ToUpper().Equals("DAY")) //{ // dtstart = dt.AddDays(-crt.tcounter.Value); //} //else if (crt.timeSlot.Trim().ToUpper().Equals("HOUR")) //{ // dtstart = dt.AddHours(-crt.tcounter.Value); //} int intervalMins = 5; chartData = CompareChartService.GetInstance().compareDayHHMultiDeviceMultiMonitor(crt.reportName, GetDeviceStucts(crt), crt.startTime, crt.endTime, intervalMins); ret = JsonUtil.convertToJson(chartData, typeof(ChartData)); break; default: break; } } return(ret); }
public void Run() { Init(); IList <Fault> faults = null; foreach (ReportConfig config in eventConfigs) { if (string.IsNullOrEmpty(config.email)) { Console.WriteLine("event report email is empty!"); continue; } //if ((DateTime.Now - config.lastSendTime).TotalMinutes < 30) // continue; Plant plant = PlantService.GetInstance().GetPlantInfoById(config.plantId); if (plant == null) { continue; } Console.WriteLine("start handle event report of " + plant.name + " last send time is :" + config.lastSendTime); //取出lastSendTime时间之后的日志 faults = LoadEventLogs(config.plantId, config.lastSendTime); //Console.WriteLine("fault count is :"+faults.Count); //if (faults == null || faults.Count < logLength) if (faults == null || faults.Count == 0) { continue; } string lang = "en-us"; User user = UserService.GetInstance().Get(int.Parse(config.sendMode)); if (user != null && user.Language != null && string.IsNullOrEmpty(user.Language.codename) == false) { lang = user.Language.codename.ToLower(); } Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(lang); int count = faults.Count; int index = 0; Console.WriteLine("start handle " + faults.Count + " fault"); while (true) { IList <Fault> temp = null; if (count >= logLength * (index + 1)) { temp = faults.Skip((index * logLength)).Take(logLength).ToList <Fault>(); index++; //Console.WriteLine("count >50 "); } else { temp = faults.Skip(index * logLength).Take((count % logLength)).ToList <Fault>(); // Console.WriteLine("get "+temp.Count+" record"); } EmailQueue queue = new EmailQueue(); object[] resArr = BulidContent(plant.name, temp, config.sendFormat == null ? "html" : config.sendFormat); queue.content = (string)resArr[0]; if (string.IsNullOrEmpty(queue.content)) { //Console.WriteLine("queue.content is empty "); continue; } //Console.WriteLine("put .content into queue "); queue.receiver = config.email; queue.state = 0; queue.title = plant.name + " event report " + CalenderUtil.formatDate(DateTime.Now, "yyyy-MM-dd"); queue.sender = "*****@*****.**"; if (Save(queue)) { Console.WriteLine(string.Format("a event report has been created {0}", DateTime.Now)); } else { Console.WriteLine("fail insert"); } config.lastSendTime = (DateTime)resArr[1];//将最近的一个日志时间作为上次处理时间,后续再从这个时间之后的日志处理 Thread.Sleep(1000); if (faults.Last().id.Equals(temp.Last().id)) { UPdateReportLastSendTime(config); break; } } } }
/// <summary> /// 取得设备详细信息 /// </summary> /// <param name="pid"></param> /// <returns></returns> public ActionResult Deviceinfo(int did, string lan) { setlan(lan); string data; Device device = DeviceService.GetInstance().get(did); int timezone = 0; try { PlantUnit plantUnit = PlantUnitService.GetInstance().GetPlantUnitByCollectorId(device.collectorID); Plant plant = PlantService.GetInstance().GetPlantInfoById(plantUnit.plantID); timezone = plant.timezone; } catch (Exception ee) { LogUtil.error(ee.Message); } if (device == null) { AppError appError = new AppError(AppError.devicenoexist, Resources.SunResource.CHART_DEVICE_DONT_EXISTED); data = JsonUtil.convertToJson(appError, typeof(AppError)); } else { DeviceInfoVO vo = new DeviceInfoVO(); vo.deviceId = device.id; vo.deviceModel = device.xinhaoName; vo.deviceType = device.typeName; vo.deviceName = device.fullName; vo.address = device.deviceAddress; vo.deviceTypeCode = device.deviceTypeCode.ToString(); if (device.deviceTypeCode == DeviceData.ENVRIOMENTMONITOR_CODE) { MonitorType mt = MonitorType.getMonitorTypeByCode(MonitorType.MIC_DETECTOR_SUNLINGHT); string str = mt.name + " :" + device.Sunlight + " " + mt.unit; mt = MonitorType.getMonitorTypeByCode(MonitorType.MIC_DETECTOR_ENRIONMENTTEMPRATURE); float tempr = device.runData == null ? 0 : device.runData.getMonitorValue(MonitorType.MIC_DETECTOR_ENRIONMENTTEMPRATURE); str += "," + mt.name + " :" + tempr + " " + mt.unit; mt = MonitorType.getMonitorTypeByCode(MonitorType.MIC_DETECTOR_WINDSPEED); double windspeed = device.getMonitorValue(MonitorType.MIC_DETECTOR_WINDSPEED); str += "," + mt.name + " :" + windspeed + " " + mt.unit; vo.displayField = str; } else if (device.deviceTypeCode == DeviceData.HUILIUXIANG_CODE || device.deviceTypeCode == DeviceData.CABINET_CODE) { MonitorType mt = MonitorType.getMonitorTypeByCode(MonitorType.MIC_BUSBAR_TOTALCURRENT); double totalCurrent = device.getMonitorValue(mt.code); string str = mt.name + " :" + totalCurrent + " " + mt.unit; mt = MonitorType.getMonitorTypeByCode(MonitorType.MIC_BUSBAR_JNTEMPRATURE); double tempr = device.getMonitorValue(mt.code); str += "," + mt.name + " :" + tempr + " " + mt.unit; vo.displayField = str; } else if (device.deviceTypeCode == DeviceData.AMMETER_CODE) { MonitorType mt = MonitorType.getMonitorTypeByCode(MonitorType.MIC_AMMETER_POSITIVEACTIVEPOWERDEGREE); float totalCurrent = device.runData == null ? 0 : device.runData.getMonitorValue(mt.code); string str = mt.name + " :" + totalCurrent + " " + mt.unit; //mt = MonitorType.getMonitorTypeByCode(MonitorType.MIC_BUSBAR_JNTEMPRATURE); //float tempr = device.runData == null ? 0 : float.Parse(device.runData.getMonitorValue(mt.code)); //str += "," + mt.name + " :" + tempr + " " + mt.unit; vo.displayField = str; } else { MonitorType TotalEmt = MonitorType.getMonitorTypeByCode(MonitorType.MIC_INVERTER_TOTALENERGY); MonitorType TodayEmt = MonitorType.getMonitorTypeByCode(MonitorType.MIC_INVERTER_TODAYENERGY); MonitorType mt = MonitorType.getMonitorTypeByCode(MonitorType.MIC_INVERTER_TOTALYGPOWER); string str = TodayEmt.name + " :" + device.TodayEnergy(timezone) + " " + TodayEmt.unit; str += "," + TotalEmt.name + " :" + device.TotalEnergy + " " + TotalEmt.unit; str += "," + mt.name + " :" + device.TotalPower + " " + mt.unit; vo.displayField = str; } vo.workStatus = device.status; vo.lastUpdateTime = CalenderUtil.formatDate(device.runData.updateTime, "yyyy-MM-dd HH:mm:ss"); vo.hasChart = (device.deviceTypeCode == DeviceData.INVERTER_CODE || device.deviceTypeCode == DeviceData.ENVRIOMENTMONITOR_CODE || device.deviceTypeCode == DeviceData.HUILIUXIANG_CODE || device.deviceTypeCode == DeviceData.AMMETER_CODE || device.deviceTypeCode == DeviceData.CABINET_CODE) ? "true" : "false"; vo.datas = convertToSPlantVOs(device.runData.convertRunstrToList(true, device.deviceTypeCode)); data = JsonUtil.convertToJson(vo, typeof(DeviceInfoVO)); } return(Content(data)); }
/// <summary> /// 是否有增量日照测点 /// </summary> public bool isRenderSunlight(string yyyyMMdd) { if (this.deviceTypeCode == DeviceData.ENVRIOMENTMONITOR_CODE && runData != null && CalenderUtil.formatDate(runData.updateTime, "yyyyMMdd").Equals(yyyyMMdd)) { return(runData.hasMonitor(MonitorType.MIC_DETECTOR_DAYRADIATION)); } return(false); }
/// <summary> /// 逆变器设备的今日发电量 /// </summary> public float TodayEnergy(string yyyyMMdd) { if (this.deviceTypeCode == DeviceData.INVERTER_CODE && runData != null && CalenderUtil.formatDate(runData.updateTime, "yyyyMMdd").Equals(yyyyMMdd)) { float tmp = runData.getMonitorValue(MonitorType.MIC_INVERTER_TODAYENERGY); return(float.IsNaN(tmp) ? 0 : tmp); } return(0); }
/// <summary> /// 逆变器设备的今日发电量 /// </summary> public float TodayEnergy(int timezone) { if (this.deviceTypeCode == DeviceData.INVERTER_CODE && runData != null && CalenderUtil.formatDate(runData.updateTime, "yyyyMMdd").Equals(CalenderUtil.curDateWithTimeZone(timezone, "yyyyMMdd"))) { float res = runData.getMonitorValue(MonitorType.MIC_INVERTER_TODAYENERGY); return(float.IsNaN(res) ? 0 : res); } return(0); }
/// <summary> /// 真正处理报表数据和返回视图的地方,预览和查看公用 /// </summary> /// <param name="report"></param> /// <param name="cTime"></param> /// <param name="pId"></param> /// <returns></returns> private ActionResult HandleViewReport(DefineReport report, int tId, string cTime, string pId, string type) { ViewData["Culture"] = Session["Culture"]; ViewData["rId"] = report.Id; ViewData["tId"] = tId.ToString(); ViewData["cTime"] = cTime; ViewData["pId"] = pId; if (!(string.IsNullOrEmpty(pId))) { if (string.IsNullOrEmpty(cTime)) { cTime = CalenderUtil.curDateWithTimeZone(report.plant.timezone, "yyyyMMdd"); } } else { if (string.IsNullOrEmpty(cTime)) { cTime = CalenderUtil.curDateWithTimeZone(report.user.timezone, "yyyyMMdd"); } } ViewData["time"] = cTime; if (tId == DataReportType.TOTAL_REPORT_CODE) { IList <int> workYears = null; if (!(string.IsNullOrEmpty(pId))) { workYears = collectorYearDataService.GetWorkYears(report.plant); cTime = CalenderUtil.curDateWithTimeZone(report.plant.timezone, "yyyy"); } else { workYears = collectorYearDataService.GetWorkYears(report.user.displayPlants); cTime = CalenderUtil.curDateWithTimeZone(report.user.timezone, "yyyy"); } if (workYears.Count > 0) { cTime = workYears[0] + "-" + workYears[workYears.Count - 1]; ViewData["time"] = cTime; } else { cTime += "-" + cTime; ViewData["time"] = Resources.SunResource.NO_WORK_YEARS; } } else if (tId == DataReportType.WEEK_REPORT_CODE) { string[] wTime = reportService.convertToDateArr(tId, cTime); int year1 = int.Parse(wTime[0].Substring(0, 4)); int mm1 = int.Parse(wTime[0].Substring(4, 2)); int dd1 = int.Parse(wTime[0].Substring(6, 2)); int year2 = int.Parse(wTime[1].Substring(0, 4)); int mm2 = int.Parse(wTime[1].Substring(4, 2)); int dd2 = int.Parse(wTime[1].Substring(6, 2)); string weekTime = year1 + "/" + mm1 + "/" + dd1 + "-" + year2 + "/" + mm2 + "/" + dd2; ViewData["time"] = weekTime; } else if (tId == DataReportType.MONTH_REPORT_CODE) { cTime = cTime.Split('-').Length > 2 ? cTime.Substring(0, cTime.LastIndexOf("-")) : cTime; ViewData["time"] = cTime; } else if (tId == DataReportType.YEAR_REPORT_CODE) { cTime = cTime.Split('-').Length > 2 ? cTime.Substring(0, cTime.IndexOf("-")) : cTime; ViewData["time"] = cTime; } if (report != null) { IList <Object> datalist = reportService.getDatabyItemCodes(report, cTime); if (datalist.Count != 0) { ViewData["deviceHash"] = (Hashtable)datalist[2]; ViewData["plantItemCodes"] = addIntNumtoList((IList <int>)datalist[0]); ViewData["plantHash"] = (Hashtable)datalist[1]; ViewData["deviceItemCodes"] = (IList <int>)datalist[3]; } else { ViewData["NoData"] = LanguageUtil.getDesc("NODATA"); } } else { ViewData["NoData"] = LanguageUtil.getDesc("NODATA"); } if (!(string.IsNullOrEmpty(pId))) { base.FillPlantYears(int.Parse(pId)); string yyyy = ViewData["cTime"] != null ? ViewData["cTime"] as string : DateTime.Now.Year.ToString(); yyyy = yyyy.Length >= 4 ? yyyy.Substring(0, 4) : yyyy; if (ViewData[ComConst.WorkYears] != null && (ViewData[ComConst.WorkYears] as IList <SelectListItem>).Count > 0) { foreach (SelectListItem item in ViewData[ComConst.WorkYears] as IList <SelectListItem> ) { item.Selected = false; item.Selected = item.Text.Equals(yyyy); } } if (tId == DataReportType.TODAY_REPORT_CODE) { if (string.IsNullOrEmpty(type)) { return(View("ViewDayReport", report)); } else { return(View("EmailViewDayReport", report)); } } else { if (string.IsNullOrEmpty(type)) { return(View("ViewNotDayReport", report)); } else { return(View("EmailViewNotDayReport", report)); } } } else { base.FillAllPlantYears(report.user); string yyyy = ViewData["cTime"] != null ? ViewData["cTime"] as string : DateTime.Now.Year.ToString(); yyyy = yyyy.Length >= 4 ? yyyy.Substring(0, 4) : yyyy; if (ViewData[ComConst.WorkYears] != null && (ViewData[ComConst.WorkYears] as IList <SelectListItem>).Count > 0) { foreach (SelectListItem item in ViewData[ComConst.WorkYears] as IList <SelectListItem> ) { item.Selected = false; item.Selected = item.Text.Equals(yyyy); } } if (string.IsNullOrEmpty(type)) { return(View("ViewUserReport", report)); } else { return(View("EmailViewUserReport", report)); } } }
/// <summary> /// 今日功率 /// </summary> public float TodayPower(int timezone) { float total = 0; //功率也去相差1小时的范围的值 if (this.collector != null && this.collector.runData != null && this.collector.runData.sendTime.AddHours(1) >= CalenderUtil.curDateWithTimeZone(timezone)) { total = collector.runData.power; } return(total); }