Ejemplo n.º 1
0
        public ActionResult Overview(int id)
        {
            User  curUser = UserUtil.getCurUser();
            Plant plant   = PlantService.GetInstance().GetPlantInfoById(id);

            return(View(plant));
        }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
0
        public ActionResult DefinedPlantChartList(int id, string cid)
        {
            int temp = 0;

            int.TryParse(cid, out temp);
            Plant plant = PlantService.GetInstance().GetPlantInfoById(id);

            SetDeviceList(plant);
            SetMI(null);
            CustomChart cus = null;

            if (string.IsNullOrEmpty(cid))
            {
                cus         = new CustomChart();
                cus.groupId = 0;
                cus.plantId = plant.id;
            }
            else
            {
                cus = CustomChartService.GetInstance().Get(new CustomChart()
                {
                    id = temp
                });
                Analysis(ref cus);
            }
            ViewData["charts"] = CustomChartService.GetInstance().GetListByPlant(cus.plantId);
            return(View("CustomChartList", cus));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 取得某个电站跨小时的功率图表
        /// </summary>
        /// <param name="pid"></param>
        /// <param name="startYYYYMMDD"></param>
        /// <param name="endYYYYMMDD"></param>
        /// <returns></returns>
        public ActionResult PlantDayChart(int pid, string startYYYYMMDDHH, string endYYYYMMDDHH, string chartType, string lan)
        {
            setlan(lan);

            if (string.IsNullOrEmpty(chartType))
            {
                chartType = ChartType.column;
            }
            Plant plant = PlantService.GetInstance().GetPlantInfoById(pid);
            //获得报表业务逻辑类
            PlantChartService reportService = PlantChartService.GetInstance();
            //获得报表js代码
            int         monitorCode = MonitorType.PLANT_MONITORITEM_POWER_CODE;//发电量测点
            MonitorType Mt          = MonitorType.getMonitorTypeByCode(monitorCode);
            string      unit        = Mt.unit;
            string      chartName   = LanguageUtil.getDesc("CHART_DAY_POWER_CHART");
            string      reportData  = string.Empty;

            if (plant != null)
            {
                Cn.Loosoft.Zhisou.SunPower.Common.ChartData chartData = reportService.PlantDayChart(plant, chartName, startYYYYMMDDHH, endYYYYMMDDHH, chartType, unit, monitorCode, intervalTime);
                reportData = JsonUtil.convertToJson(chartData, typeof(Cn.Loosoft.Zhisou.SunPower.Common.ChartData));
            }
            else
            {
                AppError appError = new AppError(AppError.plantnoexist, Resources.SunResource.CHART_PLANT_DONT_EXISTED);
                reportData = JsonUtil.convertToJson(appError, typeof(AppError));
            }
            return(Content(reportData));
        }
Ejemplo n.º 5
0
        public ActionResult Device()
        {
            String pid   = Request.QueryString["pid"];
            Plant  plant = PlantService.GetInstance().GetPlantInfoById(Convert.ToInt32(pid));

            return(View(plant));
        }
Ejemplo n.º 6
0
        public ActionResult PlantData(int plantId)
        {
            Plant plant = PlantService.GetInstance().GetPlantInfoById(plantId);

            Cn.Loosoft.Zhisou.SunPower.Common.vo.PlantVO plantVO = new Cn.Loosoft.Zhisou.SunPower.Common.vo.PlantVO();

            User user = UserService.GetInstance().Get((int)plant.userID);

            plantVO.plantName          = plant.name;
            plantVO.CQ2reduce          = plant.Reductiong.ToString();
            plantVO.CQ2reduceUnit      = plant.ReductiongUnit;
            plantVO.curPower           = plant.DisplayTodayTotalPower;
            plantVO.curPowerUnit       = plant.TodayTotalPowerUnit;
            plantVO.dayEnergy          = plant.DisplayTotalDayEnergy;
            plantVO.dayEnergyUnit      = plant.TotalDayEnergyUnit;
            plantVO.solarIntensity     = plant.Sunstrength == null ? "" : plant.Sunstrength.ToString();
            plantVO.solarIntensityUnit = MonitorType.getMonitorTypeByCode(MonitorType.PLANT_MONITORITEM_LINGT_CODE).unit;
            //add by qhb in 20120106 for 增加逆变器数量
            IList <Device> inverterDevices = plant.typeDevices(DeviceData.INVERTER_CODE);

            plantVO.inverterCount   = inverterDevices.Count.ToString();
            plantVO.inverterTypeStr = getMainType(inverterDevices, 3);
            plantVO.installDate     = plant.installdate.ToString("yyyy-MM-dd");
            plantVO.DesignPower     = plant.design_power + " kWp";
            plantVO.Country         = plant.country;
            plantVO.City            = plant.city;
            plantVO.organize        = user.organize;
            plantVO.totalEnergy     = plant.DisplayTotalEnergy;
            plantVO.totalEnergyUnit = plant.TotalEnergyUnit;
            plantVO.imageArray      = "http://" + Request.Url.Authority + (string.IsNullOrEmpty(plant.onePic) ? "/bigscreen/images/plant_img.jpg":"/ufile/" + plant.onePic);
            plantVO.temprature      = getPlantTemp(plant).ToString();
            plantVO.tempratureUnit  = user.TemperatureType.ToUpper();
            return(Json(plantVO, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 7
0
        public ActionResult MonthDDChart(int plantId)
        {
            string reportCode = string.Empty;
            Plant  plant      = PlantService.GetInstance().GetPlantInfoById(plantId);

            if (plant != null)
            {
                string unit          = "kWh";
                string startYYYYMMDD = DateTime.Now.ToString("yyyyMM01");
                string endYYYYMMDD   = new DateTime(DateTime.Now.Year, DateTime.Now.Month + 1, 1).AddDays(-1).ToString("yyyyMMdd");
                //ChartData chartData = PlantChartService.GetInstance().MMDDChartBypList(new List<Plant> { plant }, startYYYYMMDD, endYYYYMMDD, "column", unit);
                ChartData chartData = PlantChartService.GetInstance().MonthDDChartBypList(new List <Plant> {
                    plant
                }, 1.0F, LanguageUtil.getDesc("CHART_TITLE_MONTH_ENERGY"), null, startYYYYMMDD, endYYYYMMDD, ChartType.column, unit, false);
                foreach (YData yd in chartData.series)
                {
                    if (yd.max == 0)
                    {
                        yd.max = 10;
                    }
                }
                reportCode = JsonUtil.convertToJson(chartData, typeof(ChartData));
            }
            else
            {
                return(Content("error:" + Resources.SunResource.NODATA));
            }
            return(Content(reportCode));
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 加载图表页面
        /// </summary>
        /// <returns></returns>
        public ActionResult Chart(int pId, int dId)
        {
            Plant  plant  = PlantService.GetInstance().GetPlantInfoById(pId);
            Device device = DeviceService.GetInstance().get(dId);

            ViewData["device"] = device;
            ViewData["Plant"]  = plant;
            FillPlantYears(pId.ToString());
            if (device.deviceTypeCode == DeviceData.INVERTER_CODE)
            {
                return(View(@"InverterChart", plant));
            }
            else if (device.deviceTypeCode == DeviceData.HUILIUXIANG_CODE)
            {
                return(View(@"HlxChart", plant));
            }
            else if (device.deviceTypeCode == DeviceData.CABINET_CODE)
            {
                return(View(@"CabinetChart", plant));
            }
            else if (device.deviceTypeCode == DeviceData.AMMETER_CODE)
            {
                return(View(@"AmmeterChart", plant));
            }
            else
            {
                return(View(@"DetectorChart", plant));
            }
        }
Ejemplo n.º 9
0
        public ActionResult YearMMChart(int plantId)
        {
            string reportCode = string.Empty;

            if (plantId > 0)
            {
                string unit  = "kWh";
                Plant  plant = PlantService.GetInstance().GetPlantInfoById(plantId);
                //ChartData chartData = PlantChartService.GetInstance().YearMMChartByPlant(plant, DateTime.Now.Year, ChartType.column, unit);
                string chartName = LanguageUtil.getDesc("CHART_TITLE_YEARLYENERGYCHART");
                //if (startYearMM.Substring(0, 4).Equals(endYearMM.Substring(0, 4)) && startYearMM.Substring(4, 2).Equals("01") && endYearMM.Substring(4, 2).Equals("12")) {
                //chartName = startYearMM.Substring(0, 4) + chartName;
                //}
                string    startYearMM = DateTime.Now.Year + "01";
                string    endYearMM   = DateTime.Now.Year + "12";
                ChartData chartData   = PlantChartService.GetInstance().YearMMChartBypList(new List <Plant> {
                    plant
                }, 1.0F, chartName, null, startYearMM, endYearMM, ChartType.column, unit, true);
                foreach (YData yd in chartData.series)
                {
                    if (yd.max == 0)
                    {
                        yd.max = 10;
                    }
                }
                reportCode = JsonUtil.convertToJson(chartData, typeof(ChartData));
            }
            else
            {
                return(Content("error:" + Resources.SunResource.NODATA));
            }
            return(Content(reportCode));
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 取得工作年份,待完善
        ///
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        private IList <string> getWorkYears(List <DeviceStuct> list)
        {
            IList <int>    workYears    = new List <int>();
            IList <string> newWorkYears = new List <string>();

            foreach (DeviceStuct ds in list)
            {
                if (ds.deviceType == ChartDeviceType.PLANT)
                {
                    Plant plant = PlantService.GetInstance().GetPlantInfoById(int.Parse(ds.deviceId));
                    workYears = CollectorYearDataService.GetInstance().GetWorkYears(plant);
                }
            }
            if (workYears.Count > 0)
            {
                foreach (int year in workYears)
                {
                    newWorkYears.Add(year.ToString());
                }
            }
            else
            {
                newWorkYears.Add(DateTime.Now.Year.ToString());
            }
            return(newWorkYears);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 加载首页数据,抽取出来供首页加载方法和首页登录方法调用
        /// author:hbqian in 2013/02/21
        /// </summary>
        private void loadIndexData()
        {
            //取得最新加入的电站
            IList <Plant> newPlants = PlantService.GetInstance().GetNewPlantInfoList(4);
            User          userinfo  = UserService.GetInstance().GetUserByName(UserUtil.demousername);

            if (userinfo != null)
            {
                IList <PlantUser> plant = PlantUserService.GetInstance().GetAllPlantUserByUserID(new PlantUser {
                    userID = userinfo.id
                });
                ViewData["examplePlant"] = plant;
            }
            ViewData["newPlants"] = newPlants;
            float co2Rate = ItemConfigService.GetInstance().getCO2Config();

            ViewData["AllPlant"] = PlantService.GetInstance().GetPlantNum();

            double alltotalenergy = DeviceRunDataService.GetInstance().GetAllTotalEnergy();
            //modify by hbqian at 2013-08-02 for 同一时刻 2个值结果不一致 ,首页和内部所有电站日发电量统计值不一致
            //double dayEnergy = CollectorRunDataService.GetInstance().GetAllDayEnergy();
            double dayEnergy = getAllPlantTodayEnergy();
            //modify by hbqian at 2013-08-02 for 同一时刻 2个值结果不一致 ,首页和内部所有电站日发电量统计值不一致 end
            double co2Value = alltotalenergy * co2Rate;

            ViewData["co2Unit"]           = Util.upCo2Unit(co2Value);
            ViewData["energyUnit"]        = Util.upEnergyUnit(alltotalenergy);
            ViewData["dayenergyUnit"]     = Util.upEnergyUnit(dayEnergy);
            ViewData["AllTotalEnergy"]    = StringUtil.formatDouble(Util.upDigtal(alltotalenergy));
            ViewData["AlldayTotalEnergy"] = StringUtil.formatDouble(Util.upDigtal(dayEnergy));
            ViewData["AllCO2"]            = StringUtil.formatDouble(Util.upDigtal(co2Value));
            getPPics();
            getAdPics();
        }
Ejemplo n.º 12
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));
        }
Ejemplo n.º 13
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());
        }
Ejemplo n.º 14
0
        public ActionResult SavePlant(Plant plant)
        {
            string long1     = Request.Form["long1"];
            string long2     = Request.Form["long2"];
            string long3     = Request.Form["long3"];
            double value     = 0;
            double longValue = 0;

            double.TryParse(long1, out longValue);
            value += longValue;
            double.TryParse(long2, out longValue);
            value += (longValue / 60);

            double.TryParse(long3, out longValue);
            value += (longValue / 3600);

            plant.longitude = value;
            value           = 0;
            longValue       = 0;
            string lat1 = Request.Form["lat1"];

            double.TryParse(lat1, out longValue);
            value += longValue;

            string lat2 = Request.Form["lat2"];

            double.TryParse(lat2, out longValue);
            value += (longValue / 60);

            string lat3 = Request.Form["lat3"];

            double.TryParse(lat3, out longValue);
            value                += (longValue / 3600);
            plant.latitude        = value;
            plant.longitudeString = string.Format("{0},{1},{2}", long1, long2, long3);
            plant.latitudeString  = string.Format("{0},{1},{2}", lat1, lat2, lat3);
            if (string.IsNullOrEmpty(plant.pic))
            {
                plant.pic = string.Empty;
            }
            plant.userID = UserUtil.getCurUser().id;
            CountryCity area = CountryCityService.GetInstance().GetCity(plant.country);

            plant.area = area == null ? string.Empty : area.weather_code;
            int plantid = plant.id;

            if (plant.id > 0)
            {
                PlantService.GetInstance().UpdatePlantInfo(plant);
            }
            else
            {
                plantid = PlantService.GetInstance().AddPlantInfo(plant);
                PlantUserService.GetInstance().AddPlantUser(new PlantUser {
                    plantID = plantid, userID = int.Parse(plant.userID.ToString())
                });                                                                                                                           //添加电站时,向电站用户关系表中加记录
            }
            UserUtil.ResetLogin(UserUtil.getCurUser());
            return(Redirect("/newregister/addplantcontrol?plantid=" + plantid));
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 电站的月天数据
        /// </summary>
        /// <param name="pid"></param>
        /// <param name="startYYYYMMDD"></param>
        /// <param name="endYYYYMMDD"></param>
        /// <param name="chartType"></param>
        /// <returns></returns>
        public ActionResult PlantMonthDayChart(int pid, string startYYYYMMDD, string endYYYYMMDD, string chartType, string lan)
        {
            setlan(lan);

            if (string.IsNullOrEmpty(chartType))
            {
                chartType = ChartType.column;
            }
            Plant  plant      = PlantService.GetInstance().GetPlantInfoById(pid);
            string reportData = string.Empty;

            if (plant != null)
            {
                MonitorType energyMt = MonitorType.getMonitorTypeByCode(MonitorType.PLANT_MONITORITEM_ENERGY_CODE);
                string      unit     = energyMt.unit;
                Cn.Loosoft.Zhisou.SunPower.Common.ChartData chartData = PlantChartService.GetInstance().MMDDChartBypList(new List <Plant> {
                    plant
                }, startYYYYMMDD, endYYYYMMDD, chartType, unit);
                reportData = JsonUtil.convertToJson(chartData, typeof(Cn.Loosoft.Zhisou.SunPower.Common.ChartData));
            }
            else
            {
                AppError appError = new AppError(AppError.plantnoexist, Resources.SunResource.CHART_PLANT_DONT_EXISTED);
                reportData = JsonUtil.convertToJson(appError, typeof(AppError));
            }
            return(Content(reportData));
        }
Ejemplo n.º 16
0
        public ActionResult IncludePlantrelationstruct(int id)
        {
            User           curUser = UserUtil.getCurUser();
            string         width = "100"; string height = "30";
            RelationConfig config = curUser.configs.Where(m => m.relationType.Equals(RelationConfig.VirtualPlant) && m.relationId.Equals(id)).FirstOrDefault <Cn.Loosoft.Zhisou.SunPower.Domain.RelationConfig>();

            if (config == null)
            {
                config = new RelationConfig {
                    width = "100", height = "30", config3 = "20", config4 = "15"
                }
            }
            ;
            width              = config.width;
            height             = config.height;
            ViewData["config"] = config;
            Plant  plant = PlantService.GetInstance().GetPlantInfoById(id);
            string jsstr = base.createPlantContructTree(new List <Plant> {
                plant
            }, -1, width, height);

            TempData["jsstr"] = jsstr;
            TempData["iSubtreeSeparation"] = config.config3;
            TempData["iSiblingSeparation"] = config.config4;
            return(View(plant));
        }
    }
Ejemplo n.º 17
0
        /// <summary>
        /// 取得电站详细信息
        /// </summary>
        /// <param name="pid"></param>
        /// <returns></returns>
        public ActionResult Plantinfo(int pid, string lan)
        {
            setlan(lan);

            string data;
            Plant  plant = PlantService.GetInstance().GetPlantInfoById(pid);

            if (plant == null)
            {
                AppError appError = new AppError(AppError.plantnoexist, Resources.SunResource.CHART_PLANT_DONT_EXISTED);
                data = JsonUtil.convertToJson(appError, typeof(AppError));
            }
            else
            {
                User        user     = UserService.GetInstance().Get((int)plant.userID);
                MonitorType energyMt = MonitorType.getMonitorTypeByCode(MonitorType.PLANT_MONITORITEM_ENERGY_CODE);
                MonitorType powerMt  = MonitorType.getMonitorTypeByCode(MonitorType.PLANT_MONITORITEM_POWER_CODE);
                PlantInfoVO plantvo  = new PlantInfoVO();

                plantvo.totalEnergy      = plant.upTotalEnergy;
                plantvo.todayEnergy      = plant.upTotalDayEnergy;
                plantvo.pId              = plant.id;
                plantvo.name             = plant.name;
                plantvo.co2Reduction     = plant.Reductiong;
                plantvo.revenue          = user.revenue * plantvo.totalEnergy;
                plantvo.designPower      = Math.Round(plant.design_power, 2);
                plantvo.powerUnit        = "KWp";
                plantvo.revenueUnit      = plant.currencies;
                plantvo.totalEnergyUnit  = plant.TotalEnergyUnit;
                plantvo.todayEnergyUnit  = plant.TotalDayEnergyUnit;
                plantvo.co2ReductionUnit = plant.ReductiongUnit;
                plantvo.pic              = base.getCurWebContext() + "/ufile/small/" + plant.onePic;
                plantvo.country          = plant.country;
                plantvo.city             = plant.city;
                plantvo.direction        = plant.direction;
                plantvo.installdate      = plant.installdate.ToString("yyyy-MM-dd");
                plantvo.angle            = plant.angle;
                plantvo.latitude         = plant.latitudeString;
                plantvo.location         = plant.location;
                plantvo.longitude        = plant.longitudeString;
                plantvo.street           = plant.street;
                plantvo.sunlight         = plant.Sunstrength.ToString();
                plantvo.temperature      = plant.Temperature.ToString();
                plantvo.weather          = "Sundy";
                plantvo.moduleType       = plant.module_type;
                plantvo.email            = plant.email;

                plantvo.manufacturer   = plant.manufacturer;
                plantvo.operatorPerson = plant.operater;
                plantvo.phone          = plant.phone;
                plantvo.revenueRate    = Math.Round(plant.revenueRate, 2).ToString();

                plantvo.timeZone = Cn.Loosoft.Zhisou.SunPower.Common.TimeZone.GetText(plant.timezone);
                plantvo.zipCode  = plant.postcode;

                data = JsonUtil.convertToJson(plantvo, typeof(PlantInfoVO));
            }
            return(Content(data));
        }
Ejemplo n.º 18
0
        /// <summary>
        /// 单个电站的工作年份
        /// </summary>
        /// <param name="plantId"></param>
        protected void FillPlantYears(int plantId)
        {
            Plant                  plant          = PlantService.GetInstance().GetPlantInfoById(plantId);
            IList <int>            yearList       = collectorYearDataService.GetWorkYears(plant);
            IList <SelectListItem> plantYearsList = Currencies.FillYearItems(yearList);

            ViewData[ComConst.WorkYears] = plantYearsList;
        }
Ejemplo n.º 19
0
        public ActionResult Logs()
        {
            string pageIndexStr = Request.QueryString["page"];
            int    pageindex    = 0;

            int.TryParse(pageIndexStr, out pageindex);
            string pidStr = Request.QueryString["pid"];
            int    pid    = 0;

            int.TryParse(pidStr, out pid);
            #region 将查询时间设为23点59分59秒
            DateTime startTime = Convert.ToDateTime(DateTime.Now.ToShortDateString());
            DateTime endTime   = Convert.ToDateTime(DateTime.Now.AddDays(1).ToShortDateString());
            #endregion

            #region 获取电站所有采集器ID字符串
            string collectorString = string.Empty;
            {
                Plant curPlant = PlantService.GetInstance().GetPlantInfoById(pid);
                foreach (PlantUnit unit in curPlant.plantUnits)
                {
                    collectorString += string.Format("{0},", unit.collector.id);
                }
            }
            if (collectorString.Length > 1)
            {
                collectorString = collectorString.Substring(0, collectorString.Length - 1);
            }
            #endregion

            //错误项目字符串
            string inforank = ErrorType.ERROR_TYPE_INFORMATRION + "," + ErrorType.ERROR_TYPE_FAULT + "," + ErrorType.ERROR_TYPE_ERROR + "," + ErrorType.ERROR_TYPE_WARN;

            Hashtable table = new Hashtable();
            Pager     page  = new Pager()
            {
                PageIndex = pageindex, PageSize = 10
            };
            Fault fault = new Fault()
            {
                sendTime = startTime, confirmed = "0", inforank = inforank, collectorString = collectorString
            };
            table.Add("page", page);
            table.Add("fault", fault);
            table.Add("endTime", endTime);
            ViewData["page"] = table["page"];
            IList <Fault> logs = null;
            try
            {
                logs = logService.GetPlantLoglist(table);
            }
            catch
            {
                logs = new List <Fault>();
            }
            return(View(logs));
        }
Ejemplo n.º 20
0
        /// <summary>
        /// 加载PR图表页面
        /// </summary>
        /// <returns></returns>
        public ActionResult PRChart(int pId, int dId)
        {
            Plant  plant  = PlantService.GetInstance().GetPlantInfoById(pId);
            Device device = DeviceService.GetInstance().get(dId);

            ViewData["device"] = device;
            ViewData["Plant"]  = plant;
            FillPlantYears(pId.ToString());
            return(View(@"InverterPRChart", plant));
        }
Ejemplo n.º 21
0
        /// <summary>
        /// 取得所有统计数据
        /// </summary>
        /// <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 TotalInfo(string app_key, string call_id, string sig, string v, string format, string username, string lan)
        {
            setlan(lan);
            TotalInfo tinfo = new TotalInfo();

            if (string.IsNullOrEmpty(username))
            {
                double allTotalEnergy = DeviceRunDataService.GetInstance().GetAllTotalEnergy();
                double allDayEnergy   = CollectorRunDataService.GetInstance().GetAllDayEnergy();
                double allDayPower    = CollectorRunDataService.GetInstance().getAllPower();
                tinfo.totalDayEnergy      = Util.upDigtal(allDayEnergy);
                tinfo.totalDayEnergyUnit  = Util.upEnergyUnit(allDayEnergy);
                tinfo.plantsCount         = PlantService.GetInstance().GetPlantInfoList().Count();
                tinfo.totalCO2Reduce      = Util.upDigtal(ItemConfig.reductionRate * allTotalEnergy);
                tinfo.totalCO2ReduceUnit  = Util.upCo2Unit(ItemConfig.reductionRate * allTotalEnergy);
                tinfo.totalEnergy         = Util.upDigtal(allTotalEnergy);
                tinfo.totalEnergyUnit     = Util.upEnergyUnit(allTotalEnergy);
                tinfo.totalTodayPower     = Util.upDigtal(allDayPower);
                tinfo.totalTodayPowerUnit = Util.upPowerUnit(allDayPower);
                double top = PlantService.GetInstance().getTotalPower();
                tinfo.totalPower     = Util.upDigtal(top);
                tinfo.totalPowerUnit = Util.upPowerUnit(top);
                tinfo.treeNum        = (allTotalEnergy / 40).ToString("0");
            }
            else
            {
                User user = UserService.GetInstance().GetUserByName(username);
                if (user != null)
                {
                    double allTotalEnergy = user.TotalEnergy;
                    double allDayEnergy   = user.TotalDayEnergy;
                    double allDayPower    = user.TotalPower;
                    tinfo.totalDayEnergy      = Util.upDigtal(allDayEnergy);
                    tinfo.totalDayEnergyUnit  = Util.upEnergyUnit(allDayEnergy);
                    tinfo.plantsCount         = user.plants.Count;
                    tinfo.totalCO2Reduce      = Util.upDigtal(ItemConfig.reductionRate * allTotalEnergy);
                    tinfo.totalCO2ReduceUnit  = Util.upCo2Unit(ItemConfig.reductionRate * allTotalEnergy);
                    tinfo.totalEnergy         = Util.upDigtal(allTotalEnergy);
                    tinfo.totalEnergyUnit     = Util.upEnergyUnit(allTotalEnergy);
                    tinfo.totalTodayPower     = Util.upDigtal(allDayPower);
                    tinfo.totalTodayPowerUnit = Util.upPowerUnit(allDayPower);
                    double top = 0;
                    foreach (Plant p in user.plants)
                    {
                        top += p.design_power;
                    }
                    tinfo.totalPower     = Util.upDigtal(top);
                    tinfo.totalPowerUnit = Util.upPowerUnit(top);
                    tinfo.treeNum        = (allTotalEnergy / 40).ToString("0");
                }
            }
            string data = JsonUtil.convertToJson(tinfo, typeof(TotalInfo));

            return(Content(data));
        }
Ejemplo n.º 22
0
        /// <summary>
        /// 计算所有一级电站的总今日发电量
        /// </summary>
        /// <returns></returns>
        private double getAllPlantTodayEnergy()
        {
            double        totalTotayEnergy = 0;
            IList <Plant> plants           = PlantService.GetInstance().GetPlantInfoList();

            foreach (Plant plant in plants)
            {
                totalTotayEnergy += plant.TotalDayEnergy;
            }
            return(totalTotayEnergy);
        }
Ejemplo n.º 23
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));
        }
Ejemplo n.º 24
0
        /// <summary>
        /// 将单元列表转换成
        /// </summary>
        /// <param name="plants"></param>
        /// <returns></returns>
        private IList <SimpleUnitVO> convertToSUnitVOs(IList <PlantUnit> units)
        {
            IList <SimpleUnitVO> splants = new List <SimpleUnitVO>();
            Plant plant = null;

            foreach (PlantUnit unit in units)
            {
                plant = PlantService.GetInstance().GetPlantInfoById(unit.plantID);
                splants.Add(new SimpleUnitVO(unit.id, unit.displayname, unit.isWork(plant.timezone) ? "true" : "false", unit.displayDevices.Count));
            }
            return(splants);
        }
Ejemplo n.º 25
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());
        }
Ejemplo n.º 26
0
        public ActionResult IncludeOverview(int id)
        {
            User  curUser = UserUtil.getCurUser();
            Plant plant   = PlantService.GetInstance().GetPlantInfoById(id);

            if (plant == null)
            {
                return(RedirectToAction("portal", "user"));
            }
            else if (!plant.isVirtualPlant && plant.allFactUnits.Count == 0)
            {
                return(RedirectToAction("bind", "unit", new { @id = id }));
            }

            string startYM = (DateTime.Now.Year - 1) + "" + DateTime.Now.Month.ToString("00");
            string endYM   = DateTime.Now.Year + "" + DateTime.Now.Month.ToString("00");

            //int monitorCode = 0;//发电量测点
            //string reportCode = PlantChartService.GetInstance().YearMMChartBypList(base.getCurUser().plants, startYM, endYM, ChartType.line, "kWh", monitorCode);
            //ViewData[ComConst.ReportCode] = reportCode;

            ViewData[ComConst.PlantName] = plant.name;
            plant.currencies             = curUser.currencies;
            ViewData["temp"]             = Math.Round(plant.Temperature, 1);
            if (double.IsNaN((double)ViewData["temp"]))
            {
                CityCodeService codeService = CityCodeService.GetInstance();
                ViewData["temp"] = codeService.GetTemperature(plant.city);
            }
            if (!double.IsNaN(((double)ViewData["temp"])))
            {
                User user = UserUtil.getCurUser();
                if (user != null && !user.TemperatureType.ToLower().Equals("c"))
                {
                    ViewData["temp"] = Math.Round(32 + ((double)ViewData["temp"] * 1.8), 1);
                }
            }
            else
            {
                ViewData["temp"] = "";
            }

            IList <int> yearList = collectorYearDataService.GetWorkYears(plant);

            IList <SelectListItem> plantYearsList = Currencies.FillYearItems(yearList);

            ViewData["plantYear"] = plantYearsList;

            return(View(plant));
        }
Ejemplo n.º 27
0
        public ActionResult AddPlant(string code, string password, string plantName)
        {
            CollectorInfoService collectorInfoService = CollectorInfoService.GetInstance();
            PlantService         plantInfoService     = PlantService.GetInstance();

            if (Session[ComConst.User] != null)
            {
                return(View());
            }
            else
            {
                return(RedirectToAction("login", "auth"));
            }
        }
Ejemplo n.º 28
0
        public ActionResult DeleteUnit(string plantId, string unitId)
        {
            try
            {
                int collectorId = Convert.ToInt32(unitId);
                //根据电站id和电站单元Id查询该电站是否有该单元
                PlantUnit plantUnit = plantUnitService.GetPlantUnitByPlantIdCollectorId(int.Parse(plantId), collectorId);
                if (plantUnit == null)
                {
                    return(RedirectToAction("list", "unit", new { @id = plantId }));
                }
                else
                {
                    Collector      collector = plantUnit.collector;
                    IList <Device> devices   = plantUnit.devices;
                    int            res       = plantUnitService.DeletePlantUnit(int.Parse(plantId), collectorId); //根据电站Id和电站单元Id删除电站单元
                    if (res > 0)                                                                                  //删除成功后将采集器的使用标识为false
                    {
                        collector.isUsed = false;
                        collectorInfoService.Save(collector);
                        //删除单元要将单元的物理设备的planunitid属性值null,即接触物理关系

                        foreach (Device device in devices)
                        {
                            if (device.plantUnitId != plantUnit.id)
                            {
                                continue;                                    //已有属主则不纳入该单元
                            }
                            device.parentId    = 0;
                            device.plantUnitId = null;
                            DeviceService.GetInstance().Save(device);
                        }
                    }
                }

                Plant plant = PlantService.GetInstance().GetPlantInfoById(int.Parse(plantId));
                if (plant.plantUnits.Count == 0)
                {
                    plant.BindCollector = false;
                    PlantService.GetInstance().Save(plant);//删除单元时,如果全部删除则修改BindCollector
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            return(RedirectToAction("list", "unit", new { @id = plantId }));
        }
Ejemplo n.º 29
0
        /// <summary>
        /// 日功率和日照散列图
        /// 此类型图表和其他取数方式有点不一样,其他都是多位测点数据公用一个时间坐标
        /// 这个是两个测点先按照同样的时间间隔取得数据后(同样的时间间隔取数是为了保证取得数据数组长度一致,能最终合并成对应的散列点)
        /// 将日照作为x轴,功率作为y轴数据,生成散列图表数据
        /// add by hbqian in 2013-03-23 for 生成设备功率和日照散列图
        /// </summary>
        /// <param name="pid"></param>
        /// <param name="startYYYYMMDDHH"></param>
        /// <param name="endYYYYMMDDHH"></param>
        /// <param name="chartType">只能有一个,其实是固定为scatter类型的</param>
        /// <param name="intervalMins">只能有一个</param>
        /// <returns></returns>
        public ActionResult PowerSunScatterCompare(int dId, string startYYYYMMDDHH, string endYYYYMMDDHH, string chartType, string intervalMins)
        {
            string reportCode = string.Empty;
            Device device     = DeviceService.GetInstance().get(dId);

            string[] intervals = intervalMins.Split(',');
            if (device != null)
            {
                //判断该测点是否有数据,有数据则增加关照对比
                Hashtable powerDataHash = DeviceDayDataService.GetInstance().GetDaydataList(device, startYYYYMMDDHH, endYYYYMMDDHH, int.Parse(intervals[0]), MonitorType.MIC_INVERTER_TOTALYGPOWER);
                if (powerDataHash.Count > 0 && device.plantUnit != null)
                {
                    string chartName = LanguageUtil.getDesc("PLANT_CHART_DAY_POWER_SUNLIGHT_COMPARE_CHART") + "(" + LanguageUtil.getDesc("CUSTOM_CHART_MONTH") + ")";

                    Plant  plant     = PlantService.GetInstance().GetPlantInfoById(device.plantUnit.plantID);
                    Device sundevice = plant.getFirstDetector();
                    //设备所属电站是否有环境检测仪
                    if (sundevice != null)
                    {
                        //取得日照数据
                        Hashtable sunDataHash = DeviceDayDataService.GetInstance().GetDaydataList(null, sundevice, startYYYYMMDDHH, endYYYYMMDDHH, int.Parse(intervals[0]), MonitorType.MIC_DETECTOR_SUNLINGHT);
                        if (sunDataHash.Keys.Count > 0)//有日照数据,则合并数据,将日照作为x,功率作为y,形成新的x.y散列点
                        {
                            MonitorType smt       = MonitorType.getMonitorTypeByCode(MonitorType.MIC_DETECTOR_SUNLINGHT);
                            MonitorType pmt       = MonitorType.getMonitorTypeByCode(MonitorType.MIC_INVERTER_TOTALYGPOWER);
                            ChartData   chartData = DeviceChartService.GetInstance().genNewScatter(smt, pmt, chartName, startYYYYMMDDHH, endYYYYMMDDHH, int.Parse(intervals[0]), sunDataHash, powerDataHash, "kW", chartType);
                            reportCode = JsonUtil.convertToJson(chartData, typeof(ChartData));
                        }
                        else
                        { //没有日照无法生成散列点则,返回无数据提示
                            return(Content("error:" + Resources.SunResource.NODATA));
                        }
                    }
                    else
                    {
                        return(Content("error:" + Resources.SunResource.NODATA));
                    }
                }
                else
                {
                    return(Content("error:" + Resources.SunResource.NODATA));
                }
            }
            else
            {
                return(Content("error:" + Resources.SunResource.NODATA));
            }
            return(Content(reportCode));
        }
Ejemplo n.º 30
0
        public ActionResult AllPlant()
        {
            User         user             = null;
            PlantService plantInfoService = PlantService.GetInstance();

            if (Session[ComConst.User] != null)
            {
                user = UserUtil.getCurUser();;
                ViewData["plantInfo"] = null;
                return(View());
            }
            else
            {
                return(RedirectToAction("login", "auth"));
            }
        }