コード例 #1
0
 private object getPlantTemp(Plant plant)
 {
     if (plant.getFirstDetector() != null)
     {
         return(plant.getFirstDetector().getMonitorValue(MonitorType.MIC_DETECTOR_ENRIONMENTTEMPRATURE).ToString());
     }
     else
     {
         object temperature = plant.Temperature;
         if (double.IsNaN((double)temperature))
         {
             CityCodeService codeService = CityCodeService.GetInstance();
             temperature = codeService.GetTemperature(plant.city);
         }
         //修正了温度不存在显示0的问题
         if (!double.IsNaN(((double)temperature)) && temperature != null)
         {
             User user = UserUtil.getCurUser();
             if (user != null && !user.TemperatureType.ToLower().Equals("c"))
             {
                 temperature = Math.Round(32 + ((double)temperature * 1.8), 1);
             }
             else
             {
                 temperature = Math.Round((double)temperature, 1);
             }
         }
         else
         {
             temperature = "";
         }
         return(temperature);
     }
 }
コード例 #2
0
ファイル: VirtualController.cs プロジェクト: codingsf/loosoft
        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));
        }
コード例 #3
0
        /// <summary>
        /// 获取电站信息
        /// </summary>
        /// <param name="pid">电站id</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 plantinfo(int pid, string app_key, string call_id, string sig, string v, string format, string lan)
        {
            setlan(lan);
            Plant   plant = PlantService.GetInstance().GetPlantInfoById(pid);
            PlantVO vo    = new PlantVO();

            if (plant != null)
            {
                vo.CQ2reduce     = plant.Reductiong.ToString();
                vo.CQ2reduceUnit = plant.ReductiongUnit;
                vo.curPower      = plant.TodayTotalPower.ToString();
                vo.curPowerUnit  = "kW";
                vo.dayEnergy     = plant.DisplayTotalDayEnergy;
                vo.dayEnergyUnit = plant.TotalDayEnergyUnit;
                IList <int> workYears = CollectorYearDataService.GetInstance().GetWorkYears(new List <Plant>()
                {
                    plant
                });
                vo.logCount = FaultService.GetInstance().getNewLogNums(new List <Plant>()
                {
                    plant
                }, workYears);
                vo.plantId            = pid;
                vo.plantName          = plant.name;
                vo.solarIntensity     = plant.Sunstrength.ToString();
                vo.solarIntensityUnit = MonitorType.getMonitorTypeByCode(MonitorType.PLANT_MONITORITEM_LINGT_CODE).unit;
                //add by qhb in 20120106 for 增加逆变器数量
                IList <Device> inverterDevices = plant.typeDevices(DeviceData.INVERTER_CODE);
                vo.inverterCount   = inverterDevices.Count.ToString();
                vo.inverterTypeStr = getMainType(inverterDevices, 3);
                string ts   = "";
                double t    = plant.Temperature;
                User   user = UserService.GetInstance().Get((int)plant.userID);
                if (t == 0)
                {
                    CityCodeService codeService = CityCodeService.GetInstance();
                    t = codeService.GetTemperature(plant.city);
                    if (!double.IsNaN(t))
                    {
                        ts = t.ToString("0.0");
                    }
                }
                else
                {
                    ts = t.ToString("0.0");
                }
                if (user != null && !user.TemperatureType.ToLower().Equals("c"))
                {
                    t  = (32 + (t * 1.8));
                    ts = t.ToString("0.0");
                }
                vo.temprature      = ts;
                vo.tempratureUnit  = user.TemperatureType.ToUpper();
                vo.totalEnergy     = plant.DisplayTotalEnergy;
                vo.totalEnergyUnit = plant.TotalEnergyUnit;
                vo.imageArray      = "http://" + Request.Url.Authority + "/ufile/" + (string.IsNullOrEmpty(plant.onePic) ? "Nopic/nopico02.gif" : plant.onePic);
                vo.DesignPower     = plant.design_power + " kWp";
                vo.Country         = plant.country;
                vo.City            = plant.city;
                vo.organize        = user.organize;
                vo.installDate     = plant.installdate.ToString("yyyy-MM-dd");
            }
            string data = JsonUtil.convertToJson(vo, typeof(PlantVO));

            return(Content(data));
        }