/// <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 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="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)); }
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; } } } }