}//实时数据 /// <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> /// 是否超过一小时 /// </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="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); } }
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> /// 取得自定义图表的数据 /// </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); }
/// <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> 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> 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); }
/// <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)); } } }