Exemplo n.º 1
0
        /// <summary>
        /// 加载逆变器比较页面
        /// </summary>
        /// <returns></returns>
        public ActionResult UdeviceChart(int id)
        {
            PlantUnit unit  = PlantUnitService.GetInstance().GetPlantUnitById(id);
            Plant     plant = PlantService.GetInstance().GetPlantInfoById(unit.plantID);

            ViewData["plantUnit"]   = unit;
            ViewData["hashlx"]      = false;
            ViewData["hasinverter"] = false;

            foreach (Device dce in unit.devices)
            {
                if (dce.deviceTypeCode == DeviceData.HUILIUXIANG_CODE && !dce.isHidden)
                {
                    ViewData["hashlx"] = true;
                    break;
                }
            }

            foreach (Device dce in unit.devices)
            {
                if (dce.deviceTypeCode == DeviceData.INVERTER_CODE && !dce.isHidden)
                {
                    ViewData["hasinverter"] = true;
                    break;
                }
            }
            FillPlantYears(plant.id.ToString());
            return(View(plant));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 下载设备历史数据
        /// add by qhb in 20120917
        /// </summary>
        /// <param name="deviceId">设备id</param>
        /// <param name="yyyyMMdd"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public ActionResult DownLoadRundata(int deviceId, string yyyyMMdd, string type)
        {
            //设备
            Device device   = DeviceService.GetInstance().get(deviceId);
            string unitName = PlantUnitService.GetInstance().GetPlantUnitByCollectorId(device.collectorID).displayname;
            //或者数据
            IList <string> allmts = new List <string>();//所有测点
            IDictionary <string, IDictionary <string, string> > timemtMap = DeviceDayDataService.GetInstance().handleDayData(allmts, device, yyyyMMdd);
            string filename = string.Empty;

            if (yyyyMMdd.Length >= 8)
            {
                filename = string.Format("{5} {0} {1}-{2}-{3} {4}", device.fullName, yyyyMMdd.Substring(0, 4), yyyyMMdd.Substring(4, 2), yyyyMMdd.Substring(6, 2), Resources.SunResource.DEVICE_HISTORYRUN_DATA, unitName);//下载文件名称
            }
            else
            {
                filename = unitName + device.fullName + yyyyMMdd + Resources.SunResource.DEVICE_HISTORYRUN_DATA;//下载文件名称
            }
            //判断类型
            if (type_csv.Equals(type))
            {
                return(DownLoadCsvRunData(allmts, timemtMap, filename));
            }
            else if (type_xls.Equals(type))
            {
                return(DownLoadExcelRunData(allmts, timemtMap, filename));
            }
            else
            {
                return(DownLoadPdfRunData(allmts, timemtMap, filename));
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 单元下多个逆变器年kwp发电量对比
        /// </summary>
        /// <param name="uId"></param>
        /// <param name="startYYYYMMDDHH"></param>
        /// <param name="endYYYYMMDDHH"></param>
        /// <param name="chartType"></param>
        /// <param name="intervalMins"></param>
        /// <returns></returns>
        public ActionResult CompareYearkWpChartByUnit(int uId, string startYYYYMM, string endYYYYMM, string chartType)
        {
            string         reportCode = string.Empty;
            PlantUnit      unit       = PlantUnitService.GetInstance().GetPlantUnitById(uId);
            IList <Device> deviceList = unit.displayDevices;

            if (deviceList != null && deviceList.Count > 0)
            {
                IList <DeviceStuct> devices = new List <DeviceStuct>();
                foreach (Device device in deviceList)
                {
                    if (device.deviceTypeCode != DeviceData.INVERTER_CODE)
                    {
                        continue;
                    }
                    float rate = 1 / device.chartPower;
                    devices.Add(new DeviceStuct()
                    {
                        deviceId = device.id.ToString(), rate = rate, name = device.fullName, unit = "kWh/kWp", chartType = chartType, monitorType = MonitorType.getMonitorTypeByCode(MonitorType.MIC_INVERTER_TODAYENERGY), cVal = ComputeType.Avg, deviceType = ChartDeviceType.DEVICE
                    });
                }

                string chartName = LanguageUtil.getDesc("YEARLY_INVEST_INCOME_COMPARE_CHART_NAME");
                //取得用户年度发电量图表数据
                ChartData chartData = CompareChartService.GetInstance().compareYearMMMultiDeviceMultiMonitor(chartName, devices, startYYYYMM, endYYYYMM, ComputeType.Avg);
                reportCode = JsonUtil.convertToJson(chartData, typeof(ChartData));
            }
            else
            {
                reportCode = "error:" + Resources.SunResource.NODATA;
            }
            return(Content(reportCode));
        }
Exemplo n.º 4
0
        public ActionResult RemoveUnit(string plantId, string unitId)
        {
            try
            {
                //根据电站id和电站单元Id查询该电站是否有该单元
                PlantUnit plantUnit = PlantUnitService.GetInstance().GetPlantUnitByPlantIdPlantUnitId(int.Parse(plantId), Convert.ToInt32(unitId));
                if (plantUnit == null)
                {
                    return(Content(false.ToString()));
                }
                else
                {
                    PlantUnitService.GetInstance().DeletePlantUnit(int.Parse(plantId), int.Parse(unitId));        //根据电站Id和电站单元Id删除电站单元
                    Collector collector = CollectorInfoService.GetInstance().GetClollectorByCodePass(plantUnit.collector.code, plantUnit.collector.password);
                    PlantUnit plantunit = PlantUnitService.GetInstance().GetPlantUnitByCollectorId(collector.id); //查找在单元表里是否绑定了该采集器
                    if (plantunit != null)
                    {
                        collector.isUsed = true;//如果采集器已经和单元绑定了就为已用状态
                    }
                    else
                    {
                        collector.isUsed = false;
                    }
                    CollectorInfoService.GetInstance().Save(collector);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            return(Content(true.ToString()));
        }
Exemplo n.º 5
0
        /// <summary>
        /// 单元下多个汇流箱日总电流对比
        /// </summary>
        /// <param name="uId"></param>
        /// <param name="startYYYYMMDDHH"></param>
        /// <param name="endYYYYMMDDHH"></param>
        /// <param name="chartType"></param>
        /// <param name="intervalMins"></param>
        /// <returns></returns>
        public ActionResult CompareDayCurrentChartByUnit(int uId, string startYYYYMMDDHH, string endYYYYMMDDHH, string chartType, int intervalMins)
        {
            string         reportCode = string.Empty;
            PlantUnit      unit       = PlantUnitService.GetInstance().GetPlantUnitById(uId);
            IList <Device> deviceList = unit.typeDevices(DeviceData.HUILIUXIANG_CODE, false);
            MonitorType    mt         = MonitorType.getMonitorTypeByCode(MonitorType.MIC_BUSBAR_TOTALCURRENT);

            if (deviceList != null && deviceList.Count > 0)
            {
                IList <DeviceStuct> devices = new List <DeviceStuct>();
                foreach (Device device in deviceList)
                {
                    float rate = 1.0F;
                    devices.Add(new DeviceStuct()
                    {
                        deviceId = device.id.ToString(), rate = rate, name = device.fullName, unit = mt.unit, chartType = chartType, monitorType = mt, cVal = ComputeType.Avg, deviceType = ChartDeviceType.DEVICE, intervalMins = intervalMins
                    });
                }

                string chartName = LanguageUtil.getDesc("DEVICE_DAY_TOTALCURRENT_COMPARE");
                //取得用户年度发电量图表数据
                ChartData chartData = CompareChartService.GetInstance().compareDayHHMultiDeviceMultiMonitor(chartName, devices, startYYYYMMDDHH, endYYYYMMDDHH, intervalMins, ComputeType.Avg);
                reportCode = JsonUtil.convertToJson(chartData, typeof(ChartData));
            }
            else
            {
                reportCode = "error:" + Resources.SunResource.NODATA;
            }
            return(Content(reportCode));
        }
Exemplo n.º 6
0
        /// <summary>
        /// 按照sn取得对应时区
        /// add by qhb in 20120831
        /// </summary>
        /// <param name="sn">sn</param>
        /// <param name="app_key">第三方应用唯一key</param>
        /// <param name="call_id">请求序号</param>
        /// <param name="sig">签名</param>
        /// <param name="v">api版本</param>
        /// <param name="format">返回结果格式,暂时值支持json</param>
        /// <param name="lan">语言环境,暂时只支持中英文</param>
        /// <returns></returns>
        public ActionResult SnTimezone(string sn, string app_key, string call_id, string sig, string v, string format, string lan)
        {
            setlan(lan);

            int       collectorId = CollectorInfoService.GetInstance().getCollectorIdbyCode(sn);
            PlantUnit plantUnit   = PlantUnitService.GetInstance().GetPlantUnitByCollectorId(collectorId);
            string    reportData  = string.Empty;

            if (plantUnit != null)
            {
                Plant plant = PlantService.GetInstance().GetPlantInfoById(plantUnit.plantID);
                if (plant == null)
                {
                    ApiError appError = new ApiError(ApiError.plantnoexist, Resources.SunResource.CHART_PLANT_DONT_EXISTED);
                    reportData = JsonUtil.convertToJson(appError, typeof(ApiError));
                }
                else
                {
                    PlantTimezoneVo plantTimezoneVo = new PlantTimezoneVo();
                    plantTimezoneVo.plantId      = plant.id.ToString();
                    plantTimezoneVo.plantName    = plant.name;
                    plantTimezoneVo.timezoneCode = plant.timezone.ToString();
                    plantTimezoneVo.timezoneName = Cn.Loosoft.Zhisou.SunPower.Common.TimeZone.GetText(plant.timezone);
                    reportData = JsonUtil.convertToJson(plantTimezoneVo, typeof(PlantTimezoneVo));
                }
            }
            else
            {
                ApiError appError = new ApiError(ApiError.plantnoexist, Resources.SunResource.CHART_PLANT_DONT_EXISTED);
                reportData = JsonUtil.convertToJson(appError, typeof(ApiError));
            }
            return(Content(reportData));
        }
Exemplo n.º 7
0
        public ActionResult RunData(int id)
        {
            Device device = DeviceService.GetInstance().get(id);
            IList <IList <KeyValuePair <MonitorType, string> > > rundatas = device.runData.convertRunstrToList(true, device.deviceTypeCode);

            ViewData["rundatas"] = rundatas;
            ViewData["device"]   = device;
            PlantUnit plantUnit = PlantUnitService.GetInstance().GetPlantUnitByCollectorId(device.collectorID);
            Plant     plant     = PlantService.GetInstance().GetPlantInfoById(plantUnit.plantID);

            ViewData["plant"] = plant;

            //add by qhb in 20120825 for显示测点详细
            int displayHxlroute = 0;

            try
            {
                displayHxlroute = int.Parse(device.getMonitorValue(MonitorType.MIC_BUSBAR_MAXLINE).ToString());
            }catch (Exception e) {
                displayHxlroute = 0;
            }
            if (displayHxlroute == 0)
            {
                displayHxlroute = 16;                      //如果未传路数则默认用16路
            }
            ViewData["displayHxlroute"]    = displayHxlroute;
            ViewData["digitalinputdetail"] = getDetails(device, MonitorType.MIC_BUSBAR_DIGITALINPUT, displayHxlroute);
            ViewData["workstatusdetail"]   = getDetails(device, MonitorType.MIC_BUSBAR_STATUS, displayHxlroute);

            return(View());
        }
Exemplo n.º 8
0
        public void handleData()
        {
            Console.WriteLine("开始上传一批数据");
            FileLogUtil.info("------------------开始上传一批数据" + DateTime.Now.ToString() + "-------------------");
            //循环所有单元
            IList <PlantUnit> allUnits = PlantUnitService.GetInstance().getAllUnits();

            foreach (PlantUnit pu in allUnits)
            {
                FileLogUtil.info("-----开始" + pu.displayname + "-------------");
                try
                {
                    handleUnitDevice(pu);
                }
                catch (Exception e)
                {
                    FileLogUtil.info("-----" + pu.displayname + "处理失败" + e.Message + "-------------");
                    Console.WriteLine("-----" + pu.displayname + "处理失败" + e.Message + "-------------");
                }
                FileLogUtil.info("-----结束" + pu.displayname + "-------------");
                FileLogUtil.info("");
            }
            FileLogUtil.info("------------------结束上传一批数据-------------------");
            Console.WriteLine("------------------结束上传一批数据,时间:" + DateTime.Now.ToString() + "-------------------");
        }
Exemplo n.º 9
0
        /// <summary>
        /// 电站ID获取电站下所有采集器ID
        /// </summary>
        /// <param name="pid"></param>
        /// <returns></returns>
        private string PidToCids(int pid)
        {
            string            str   = string.Empty;
            IList <PlantUnit> units = PlantUnitService.GetInstance().GetAllPlantUnitsByPlantId(pid);

            foreach (PlantUnit unit in units)
            {
                str += string.Format("{0},", unit.collectorID);
            }
            return(str = str.Length > 1 ? str.Substring(0, str.Length - 1) : "-1");
        }
Exemplo n.º 10
0
        /// <summary>
        /// 电站日功率和关照对比
        /// </summary>
        /// <param name="startYYYYMMDDHH"></param>
        /// <param name="endYYYYMMDDHH"></param>
        /// <param name="chartType"></param>
        /// <param name="intervalMins"></param>
        /// <returns></returns>
        private ActionResult CompareDayChartWithSun(int dId, string startYYYYMMDDHH, string endYYYYMMDDHH, string chartType, string intervalMins)
        {
            string reportCode = string.Empty;
            Device device     = DeviceService.GetInstance().get(dId);

            if (device != null)
            {
                string[]            intervals  = intervalMins.Split(',');
                string[]            chartTypes = chartType.Split(',');
                IList <DeviceStuct> devices    = new List <DeviceStuct>();
                float       rate = 1.0F;
                MonitorType mt   = MonitorType.getMonitorTypeByCode(MonitorType.MIC_INVERTER_TOTALYGPOWER);
                devices.Add(new DeviceStuct()
                {
                    deviceId = device.id.ToString(), rate = rate, comareObj = device.fullName, name = "", unit = "", chartType = chartTypes[0], monitorType = mt, cVal = ComputeType.Avg, deviceType = ChartDeviceType.DEVICE, intervalMins = int.Parse(intervals[0])
                });
                //判断该测点是否有数据,有数据则增加关照对比
                Hashtable dataHash = DeviceDayDataService.GetInstance().GetDaydataList(device, startYYYYMMDDHH, endYYYYMMDDHH, int.Parse(intervals[0]), mt.code);

                string chartName = LanguageUtil.getDesc("DAY_COMPARE_CHART_NAME_POWER");
                if (dataHash.Count > 0)
                {
                    //Collector collector = CollectorInfoService.GetInstance().Get(device.collectorID);
                    PlantUnit pu        = PlantUnitService.GetInstance().GetPlantUnitByCollectorId(device.collectorID);
                    Plant     plant     = PlantService.GetInstance().GetPlantInfoById(pu.plantID);
                    Device    sundevice = plant.getFirstDetector();
                    if (sundevice != null)
                    {
                        dataHash = DeviceDayDataService.GetInstance().GetDaydataList(null, sundevice, startYYYYMMDDHH, endYYYYMMDDHH, int.Parse(intervals[1]), MonitorType.MIC_DETECTOR_SUNLINGHT);
                        if (dataHash.Keys.Count > 0)    //有日照数据
                        {
                            chartName = LanguageUtil.getDesc("DAY_COMPARE_CHART_NAME");
                            rate      = 1F;
                            MonitorType smt = MonitorType.getMonitorTypeByCode(MonitorType.MIC_DETECTOR_SUNLINGHT);
                            devices.Add(new DeviceStuct()
                            {
                                deviceId = sundevice.id.ToString(), rate = rate, comareObj = device.fullName, name = smt.name, unit = "", chartType = chartTypes[1], monitorType = smt, cVal = ComputeType.Avg, deviceType = ChartDeviceType.DEVICE, intervalMins = int.Parse(intervals[1])
                            });
                        }
                    }
                }
                else
                {
                    return(Content("error:" + Resources.SunResource.NODATA));
                }


                //取得用户年度发电量图表数据
                ChartData chartData = CompareChartService.GetInstance().compareDayHHMultiDeviceMultiMonitor(chartName, devices, startYYYYMMDDHH, endYYYYMMDDHH, int.Parse(intervals[0]));
                reportCode = JsonUtil.convertToJson(chartData, typeof(ChartData));
            }
            return(Content(reportCode));
        }
Exemplo n.º 11
0
        public ActionResult RunData(int did)
        {
            Device device = DeviceService.GetInstance().get(did);
            IList <IList <KeyValuePair <MonitorType, string> > > rundatas = device.runData.convertRunstrToList(true, device.deviceTypeCode);

            ViewData["rundatas"] = rundatas;
            ViewData["device"]   = device;
            PlantUnit plantUnit = PlantUnitService.GetInstance().GetPlantUnitByCollectorId(device.collectorID);
            Plant     plant     = PlantService.GetInstance().GetPlantInfoById(plantUnit.plantID);

            ViewData["plant"] = plant;
            return(View());
        }
Exemplo n.º 12
0
        public ActionResult Units_Output(int id)
        {
            Plant             plant      = FindPlant(id);
            IList <PlantUnit> plantUnits = PlantUnitService.GetInstance().GetAllPlantUnitsByPlantId(id);
            CsvStreamWriter   writer     = new CsvStreamWriter();
            IList <string>    listData   = new List <string>();

            listData.Add(string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},", Resources.SunResource.PLANT_UNIT_LIST_STATUS, Resources.SunResource.PLANT_UNIT_DATA_SOURCE_CODE
                                       , Resources.SunResource.PLANT_UNIT_LIST_UNIT_NAME,
                                       Resources.SunResource.PLANT_UNIT_LIST_POWER + "(kW)",
                                       Resources.SunResource.PLANT_UNIT_LIST_YEAR_ENERGY + "(kWh)",
                                       Resources.SunResource.PLANT_UNIT_LIST_ENERGY + "(kWh)",
                                       Resources.SunResource.PLANT_UNIT_LIST_MONTH_ENERGY + "(kWh)",
                                       Resources.SunResource.PLANT_UNIT_LIST_MONTH_ENERGY_KWP + "(kWh/kWp)",
                                       Resources.SunResource.PLANT_UNIT_LIST_YEAR_ENERGY_KWP + "(kWh/kWp)"
                                       ));

            CollectorMonthDayData cmData = null;
            CollectorYearData     cyData = null;

            foreach (PlantUnit unit in plantUnits)
            {
                float currentMonthEnergy = 0;
                float currentYearEnergy  = 0;
                cmData             = CollectorMonthDayDataService.GetInstance().GetCollectorMonthDayData(DateTime.Now.Year, unit.collector.id, DateTime.Now.Month);
                currentMonthEnergy = cmData == null ? 0 : cmData.count();
                cyData             = CollectorYearDataService.GetInstance().GetCollectorYearData(unit.collector.id, DateTime.Now.Year);
                currentYearEnergy  = cyData == null ? 0 : cyData.dataValue;
                listData.Add(string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},", unit.isWork(plant.timezone) ? Resources.SunResource.MONITORITEM_WORKING : Resources.SunResource.MONITORITEM_STOPPED, string.Format("\t{0}", unit.collector.code)
                                           , string.Format("\t{0}", unit.displayname),
                                           unit.TodayPower(plant.timezone).ToString(),
                                           currentYearEnergy.ToString(),
                                           unit.displayTotalEnergy.ToString(),
                                           currentMonthEnergy.ToString(),
                                           Math.Round(currentMonthEnergy / unit.chartPower, 2).Equals(double.NaN) ? "0" : Math.Round(currentMonthEnergy / unit.chartPower, 2).ToString(),
                                           Math.Round(currentYearEnergy / unit.chartPower, 2).Equals(double.NaN) ? "0" : Math.Round(currentYearEnergy / unit.chartPower, 2).ToString()
                                           ));
            }

            writer.AddStrDataList(listData);


            string fullFile = Server.MapPath("/") + "tempexportfile\\" + Resources.SunResource.PLANT_UNIT_LIST_FILENAME + ".csv";

            writer.Save(fullFile);
            //转化为csv格式的字符串
            ActionResult tmp = File(fullFile, "text/csv; charset=UTF-8", urlcode(Resources.SunResource.PLANT_UNIT_LIST_FILENAME) + ".csv");

            return(tmp);
        }
Exemplo n.º 13
0
        public ActionResult Detail(int id)
        {
            Plant plant = FindPlant(id);

            ViewData["plantid"] = id;
            IList <PlantUnit> plantUnits = PlantUnitService.GetInstance().GetAllPlantUnitsByPlantId(id);
            User user = UserService.GetInstance().Get(int.Parse(plant.userID.ToString()));

            if (plantUnits.Count == 0 && user.username != UserUtil.demousername)
            {
                return(RedirectToAction("bind", "unit", new { @id = id }));
            }
            ViewData["plantUnits"] = plantUnits;
            return(View(plant));
        }
Exemplo n.º 14
0
        public ActionResult UnitSave(string unitid, int plantid, string code, string password, string displayname)
        {
            int uid = 0;

            int.TryParse(unitid, out uid);
            if (uid > 0)
            {
                PlantUnitService.GetInstance().EditPlantUnit(new PlantUnit {
                    id = uid, displayname = displayname
                });                                                                                                 //修改电站单元
                return(Content(true.ToString()));
            }
            PlantUnit unit = new PlantUnit();

            unit.plantID   = plantid;
            unit.collector = new Collector()
            {
                code = code, password = password
            };
            unit.displayname = displayname;
            Collector collector = CollectorInfoService.GetInstance().GetClollectorByCodePass(code, password);

            if (collector != null && (collector.userId == 0 || collector.userId == UserUtil.getCurUser().id))
            {
                PlantUnit plantUnit = PlantUnitService.GetInstance().GetPlantUnitByCollectorId(collector.id);//根据collectorID去查询,该采集器是否已经绑定了电站
                if (plantUnit == null)
                {
                    unit.collector.id = collector.id;
                    unit.collectorID  = collector.id;
                    unit.collector    = collector;
                    PlantUnitService.GetInstance().AddPlantUnit(unit); //添加电站单元
                    collector.isUsed = true;                           //如果采集器已经和单元绑定了就为已用状态
                    CollectorInfoService.GetInstance().Save(collector);
                    return(Content(true.ToString()));
                }
                else
                {
                    collector.isUsed = true;//如果采集器已经和单元绑定了就为已用状态
                    CollectorInfoService.GetInstance().Save(collector);
                    return(Content(Resources.SunResource.PLANT_UNIT_BIND_COLLECTOR_BINDED));
                }
            }
            else
            {
                return(Content(Resources.SunResource.PLANT_UNIT_BIND_COLLECTOR_ERROR + "!"));
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// 单元下多个逆变器日kwp发电量对比
        /// </summary>
        /// <param name="uId"></param>
        /// <param name="startYYYYMMDDHH"></param>
        /// <param name="endYYYYMMDDHH"></param>
        /// <param name="chartType"></param>
        /// <param name="intervalMins"></param>
        /// <returns></returns>
        public ActionResult CompareDaykWpChartByUnit(int uId, string startYYYYMMDDHH, string endYYYYMMDDHH, string chartType, int intervalMins)
        {
            string         reportCode = string.Empty;
            PlantUnit      unit       = PlantUnitService.GetInstance().GetPlantUnitById(uId);
            IList <Device> deviceList = unit.displayDevices;

            if (deviceList != null && deviceList.Count > 0)
            {
                IList <DeviceStuct> devices = new List <DeviceStuct>();
                foreach (Device device in deviceList)
                {
                    if (device.deviceTypeCode != DeviceData.INVERTER_CODE)
                    {
                        continue;
                    }
                    float rate = 1 / device.chartPower;
                    devices.Add(new DeviceStuct()
                    {
                        deviceId = device.id.ToString(), rate = rate, name = device.fullName, unit = "kWh/kWp", chartType = chartType, monitorType = MonitorType.getMonitorTypeByCode(MonitorType.MIC_INVERTER_TODAYENERGY), cVal = ComputeType.Avg, deviceType = ChartDeviceType.DEVICE, intervalMins = intervalMins
                    });
                }

                string chartName = LanguageUtil.getDesc("MONTHLY_INVEST_INCOME_COMPARE_CHART_NAME");
                //取得用户年度发电量图表数据
                ChartData chartData = CompareChartService.GetInstance().compareDayHHMultiDeviceMultiMonitor(chartName, devices, startYYYYMMDDHH, endYYYYMMDDHH, intervalMins, ComputeType.Avg);
                //add by hbqian in 20130418 for过滤大于1的值
                //又出现大于1的没有过滤
                foreach (YData ydata in chartData.series)
                {
                    for (int i = 0; i < ydata.data.Length; i++)
                    {
                        if (ydata.data[i] >= 1)
                        {
                            ydata.data[i] = null;
                        }
                    }
                }

                reportCode = JsonUtil.convertToJson(chartData, typeof(ChartData));
            }
            else
            {
                reportCode = "error:" + Resources.SunResource.NODATA;
            }
            return(Content(reportCode));
        }
Exemplo n.º 16
0
        public ActionResult PlantUnitControl(string plantid)
        {
            int id = 0;

            int.TryParse(plantid, out id);
            Plant plant = FindPlant(id);

            ViewData["plantid"] = id;
            IList <PlantUnit> plantUnits = PlantUnitService.GetInstance().GetAllPlantUnitsByPlantId(id);
            User user = UserService.GetInstance().Get(int.Parse(plant.userID.ToString()));

            if (plantUnits.Count == 0 && user.username != UserUtil.demousername)
            {
                return(View(plant));
            }
            ViewData["plantUnits"] = plantUnits;
            return(View(plant));
        }
Exemplo n.º 17
0
        /// <summary>
        /// 删除单个电站设备
        /// </summary>
        /// <param name="plantId"></param>
        /// <param name="unitId"></param>
        /// <returns></returns>
        public ActionResult RemoveUnit(string plantId, string unitId)
        {
            try
            {
                //根据电站id和电站单元Id查询该电站是否有该单元
                PlantUnit plantUnit = PlantUnitService.GetInstance().GetPlantUnitByPlantIdCollectorId(int.Parse(plantId), Convert.ToInt32(unitId));
                if (plantUnit == null)
                {
                    return(Content(false.ToString()));
                }
                else
                {
                    PlantUnitService.GetInstance().DeletePlantUnit(int.Parse(plantId), int.Parse(unitId));        //根据电站Id和电站单元Id删除电站单元
                    Collector collector = CollectorInfoService.GetInstance().GetClollectorByCodePass(plantUnit.collector.code, plantUnit.collector.password);
                    PlantUnit plantunit = PlantUnitService.GetInstance().GetPlantUnitByCollectorId(collector.id); //查找在单元表里是否绑定了该采集器
                    if (plantunit != null)
                    {
                        collector.isUsed = true;//如果采集器已经和单元绑定了就为已用状态
                    }
                    else
                    {
                        collector.isUsed = false;
                    }
                    CollectorInfoService.GetInstance().Save(collector);
                    //删除单元要将单元的物理设备的planunitid属性值null,即接触物理关系
                    foreach (Device device in collector.devices)
                    {
                        if (device.plantUnitId != plantUnit.id)
                        {
                            continue;                                    //已有属主则不纳入该单元
                        }
                        device.parentId    = 0;
                        device.plantUnitId = null;
                        DeviceService.GetInstance().Save(device);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            return(Content(true.ToString()));
        }
Exemplo n.º 18
0
        public ActionResult unitDevice(int uid)
        {
            PlantUnit     unit = PlantUnitService.GetInstance().GetPlantUnitById(uid);
            StringBuilder html = new StringBuilder();

            html.Append("<select id='dces' name='dces' onchange='deviceChartInit()' style='width:150px'>");
            html.AppendFormat("<option value='{0}'>{1}</option>", -1, unit.displayname);
            foreach (var item in unit.displayDevices)
            {
                if (item.isFault())
                {
                    html.AppendFormat("<option value='{0}'  style='padding-left:15px; color:red;'>{1}</option>", item.id, item.fullName);
                }
                else
                {
                    html.AppendFormat("<option value='{0}'  style='padding-left:15px;'>{1}</option>", item.id, item.fullName);
                }
            }
            html.Append("</select>");
            return(Content(html.ToString()));
        }
Exemplo n.º 19
0
        /// <summary>
        /// 取得单元简要数据和设备列表
        /// </summary>
        /// <param name="uid"></param>
        /// <returns></returns>
        public ActionResult UnitDevices(int uid, string lan)
        {
            setlan(lan);

            string    data;
            PlantUnit unit = PlantUnitService.GetInstance().GetPlantUnitById(uid);

            if (unit == null)
            {
                AppError appError = new AppError(AppError.plantnoexist, Resources.SunResource.CHART_PLANT_DONT_EXISTED);
                data = JsonUtil.convertToJson(appError, typeof(AppError));
            }
            else
            {
                Plant        plant       = PlantService.GetInstance().GetPlantInfoById(unit.plantID);
                UnitDeviceVO userPlantVO = new UnitDeviceVO();
                userPlantVO.unitId = unit.id;
                userPlantVO.name   = unit.displayname;
                userPlantVO.units  = convertToSDeviceVOs(unit.displayDevices, plant);
                data = JsonUtil.convertToJson(userPlantVO, typeof(UnitDeviceVO));
            }
            return(Content(data));
        }
Exemplo n.º 20
0
        /// <summary>
        /// 将本次消息解析后的临时设备信息,转换成plant的业务对象存入list中已被批量处理程序处理的memcached和db
        /// 电站信息是无需从db或memcached还原的
        /// </summary>
        public void getDeviceInfos()
        {
            if (deviceInfos == null)
            {
                return;
            }
            //取得当前电站数据对应的采集器id
            int collectorId = this.GetCollectorId();
            int deviceId    = 0;

            foreach (DeviceInfo dinfo in this.deviceInfos)
            {
                deviceId = this.GetDeviceId(collectorId, dinfo.address.ToString());
                //新设备地址
                String newAddress   = dinfo.address.ToString();
                int    newModelCode = dinfo.typemodel;
                String newName      = dinfo.name;
                //add by qhb in 20120827 for 发送设备信息也添加设备
                if (deviceId == 0)
                {
                    //构造设备
                    Device device = new Device();
                    device.collectorID   = collectorId;
                    device.deviceAddress = newAddress;
                    if (DataType.deviceTypeNoMap.ContainsKey(newModelCode))
                    {
                        device.deviceTypeCode = DataType.deviceTypeNoMap[newModelCode];
                    }
                    device.name        = newName;
                    device.deviceModel = new DeviceModel()
                    {
                        code = newModelCode
                    };
                    device.status = "0";
                    try
                    {
                        PlantUnit pu = PlantUnitService.GetInstance().GetPlantUnitByCollectorId(collectorId);
                        if (pu != null)
                        {
                            device.plantUnitId = pu.id;
                        }
                    }
                    catch (Exception ee) { }
                    deviceId = DeviceService.GetInstance().Save(device);
                    LogUtil.info("has new device,collectorID is " + collectorId + ",deviceAddress is " + device.deviceAddress);
                    //有新设备要更新bank缓存
                    HttpClientUtil.requestUrl(bank_url);
                }
                else   //判断是否更新设备型号,地址和名称等
                {
                    Device device = DeviceService.GetInstance().get(deviceId);
                    //if (!(device.name!=null && device.name.Equals(newName)) || !device.deviceAddress.Equals(newAddress) || device.deviceModelCode != newModelCode)
                    //{
                    device.deviceAddress = newAddress;
                    if (DataType.deviceTypeNoMap.ContainsKey(newModelCode))
                    {
                        device.deviceTypeCode = DataType.deviceTypeNoMap[newModelCode];
                    }
                    device.name        = newName;
                    device.deviceModel = new DeviceModel()
                    {
                        code = newModelCode
                    };

                    deviceId = DeviceService.GetInstance().Save(device);
                    LogUtil.info("update device,collectorID is " + collectorId + ",deviceAddress is " + device.deviceAddress);
                    //有新设备要更新bank缓存
                    HttpClientUtil.requestUrl(bank_url);
                    //}
                }
                //add end
                dinfo.deviceid = deviceId;
                if (deviceInfoMap.ContainsKey(deviceId))
                {
                    deviceInfoMap[deviceId] = dinfo;
                }
                else
                {
                    deviceInfoMap.Add(deviceId, dinfo);
                }
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// 取得用户的所有故障列表
        /// </summary>
        /// <param name="userId">用户id</param>
        /// <param name="pagecount">第几页</param>
        /// <param name="pagesize">每页显示数量</param>
        /// <param name="errortype">告警类型:all是所有,error:错误,warning:警告,fault:故障,inf:信息</param>
        /// <param name="errorby">排序字段</param>
        /// <returns></returns>
        public ActionResult ErrorList(int userId, string pagecount, string pagesize, string errortype, string errorby, string lan)
        {
            setlan(lan);
            User        user      = UserService.GetInstance().Get(userId);
            IList <int> years     = CollectorYearDataService.GetInstance().GetWorkYears(user.plants);
            int         manyear   = years.Count > 0 ? years[0] : DateTime.Now.Year;
            DateTime    startTime = Convert.ToDateTime(string.Format("{0}-{1}", manyear, "01-01"));
            DateTime    endTime   = DateTime.Now;
            int         psize     = 0;

            int.TryParse(pagesize, out psize);
            FaultService service = FaultService.GetInstance();

            string inforank = "";

            if (errortype.Equals("all"))
            {
                inforank = ErrorType.ERROR_TYPE_ERROR + "," + ErrorType.ERROR_TYPE_FAULT + "," + ErrorType.ERROR_TYPE_INFORMATRION + "," + ErrorType.ERROR_TYPE_WARN;
            }
            if (errortype.Equals("error"))
            {
                inforank = ErrorType.ERROR_TYPE_ERROR.ToString();
            }
            if (errortype.Equals("warning"))
            {
                inforank = ErrorType.ERROR_TYPE_WARN.ToString();
            }
            if (errortype.Equals("fault"))
            {
                inforank = ErrorType.ERROR_TYPE_FAULT.ToString();
            }
            if (errortype.Equals("info"))
            {
                inforank = ErrorType.ERROR_TYPE_INFORMATRION.ToString();
            }

            Hashtable table = new Hashtable();
            Pager     page  = new Pager()
            {
                PageIndex = int.Parse(pagecount), PageSize = psize
            };

            table.Add("page", page);
            table.Add("user", user);
            table.Add("startTime", startTime);
            table.Add("endTime", endTime);
            table.Add("items", inforank);
            table.Add("state", "0");

            service.GetAllLogs(table);
            IList <Fault> faultList = (IList <Fault>)table["source"];

            FaultVoResult faultResult = new FaultVoResult();

            faultResult.totalpagecount = page.PageCount;

            IList <FaultVO> faults  = new List <FaultVO>();
            FaultVO         faultVO = null;

            PlantUnit tmpunit;

            foreach (Fault fault in faultList)
            {
                faultVO = new FaultVO();
                //faultVO.deviceAddress = fault.address;
                faultVO.deviceAddress = fault.device.xinhaoName + "#" + fault.address; //临时方案,设备地址字段放设备设备型号名称+地址,这样不用修改app
                //faultVO.deviceModel =  fault.device.xinhaoName;
                faultVO.deviceModel = fault.device.typeName;;                          //临时方案,设备型号字段放设备类型,这样不用修改app
                //faultVO.deviceType = fault.device.typeName;
                tmpunit             = PlantUnitService.GetInstance().GetPlantUnitByCollectorId(fault.collectorID);
                faultVO.deviceType  = tmpunit.displayname;//临时方案,设备类型字段放单元名称,这样不用修改app
                faultVO.faultDesc   = fault.content;
                faultVO.faultId     = fault.id;
                faultVO.isConfirmed = fault.confirm ? "true" : "false";
                faultVO.datetime    = fault.sendTime.ToString("yyyy-MM-dd HH:mm:ss");
                faultVO.errorType   = getAppErrorType(fault.errorTypeCode);
                faults.Add(faultVO);
            }

            faultResult.faults = faults;
            string data = JsonUtil.convertToJson(faultResult, typeof(FaultVoResult));

            return(Content(data));
        }
Exemplo n.º 22
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));
        }
Exemplo n.º 23
0
        /// <summary>
        /// 电站日kwp发电量对比
        /// </summary>
        /// <param name="startYYYYMMDDHH"></param>
        /// <param name="endYYYYMMDDHH"></param>
        /// <param name="chartType"></param>
        /// <param name="intervalMins"></param>
        /// <returns></returns>
        public ActionResult CompareDaykWpChart(int dId, string startYYYYMMDDHH, string endYYYYMMDDHH, string chartType, string intervalMins)
        {
            string reportCode = string.Empty;
            Device device     = DeviceService.GetInstance().get(dId);

            if (device != null)
            {
                string[]            intervals  = intervalMins.Split(',');
                string[]            chartTypes = chartType.Split(',');
                IList <DeviceStuct> devices    = new List <DeviceStuct>();
                float       rate = 1 / device.chartPower;
                MonitorType mt   = MonitorType.getMonitorTypeByCode(MonitorType.MIC_INVERTER_TODAYENERGY);
                devices.Add(new DeviceStuct()
                {
                    deviceId = device.id.ToString(), rate = rate, comareObj = device.fullName, name = "kWp" + mt.name, unit = "kWh/kWp", chartType = chartTypes[0], monitorType = mt, cVal = ComputeType.Avg, deviceType = ChartDeviceType.DEVICE, intervalMins = int.Parse(intervals[0])
                });
                //判断改测点是否有数据
                Hashtable dataHash  = DeviceDayDataService.GetInstance().GetDaydataList(device, startYYYYMMDDHH, endYYYYMMDDHH, int.Parse(intervals[0]), mt.code);
                string    chartName = LanguageUtil.getDesc("INVEST_INCOME_COMPARE_CHART_POWER");
                if (dataHash.Count > 0)
                {
                    //Collector collector = CollectorInfoService.GetInstance().Get(device.collectorID);
                    PlantUnit pu        = PlantUnitService.GetInstance().GetPlantUnitByCollectorId(device.collectorID);
                    Plant     plant     = PlantService.GetInstance().GetPlantInfoById(pu.plantID);
                    Device    sundevice = plant.getFirstDetector();
                    if (sundevice != null)
                    {
                        dataHash = DeviceDayDataService.GetInstance().GetDaydataList(null, sundevice, startYYYYMMDDHH, endYYYYMMDDHH, int.Parse(intervals[1]), MonitorType.MIC_DETECTOR_SUNLINGHT);
                        if (dataHash.Keys.Count > 0)  //有日照数据
                        {
                            chartName = LanguageUtil.getDesc("INVEST_INCOME_COMPARE_CHART");
                            rate      = 1F;
                            MonitorType smt = MonitorType.getMonitorTypeByCode(MonitorType.MIC_DETECTOR_SUNLINGHT);
                            devices.Add(new DeviceStuct()
                            {
                                deviceId = sundevice.id.ToString(), rate = rate, comareObj = device.fullName, name = smt.name, unit = "", chartType = chartTypes[1], monitorType = smt, cVal = ComputeType.Avg, deviceType = ChartDeviceType.DEVICE, intervalMins = int.Parse(intervals[1])
                            });
                        }
                    }
                }
                else
                {
                    return(Content("error:" + Resources.SunResource.NODATA));
                }


                //取得用户年度发电量图表数据
                ChartData chartData = CompareChartService.GetInstance().compareDayHHMultiDeviceMultiMonitor(chartName, devices, startYYYYMMDDHH, endYYYYMMDDHH, int.Parse(intervals[0]));
                //add by hbqian in 20130418 for过滤大于1的值
                //又出现大于1的没有过滤
                foreach (YData ydata in chartData.series)
                {
                    for (int i = 0; i < ydata.data.Length; i++)
                    {
                        if (ydata.data[i] >= 1)
                        {
                            ydata.data[i] = null;
                        }
                    }
                }
                reportCode = JsonUtil.convertToJson(chartData, typeof(ChartData));
            }
            return(Content(reportCode));
        }