Пример #1
0
        public PowerInfo[] GetPowerLuSu(string DianYuanID)
        {
            PowerSwithConfigEFModel vPowerSwithConfigEFModel = new PowerSwithConfigEFModel()
            {
                DianYuanID = DianYuanID ?? ""
            };

            PowerSwithConfigEFModel[] vSelectResult = m_BasicDBClass.SelectRecordsEx(vPowerSwithConfigEFModel);
            PowerInfo[] vResult = new PowerInfo[vSelectResult.Length];

            for (int i = 0; i < vSelectResult.Length; i++)
            {
                vResult[i] = new PowerInfo()
                {
                    LuHao     = vSelectResult[i].LuHao ?? 0,
                    MingCheng = vSelectResult[i].MinCheng
                };
            }

            return(vResult);
        }
Пример #2
0
        /// <summary>
        /// 获取某路开关的用电量(日)
        /// </summary>
        /// <param name="DianYuanID"></param>
        /// <param name="LuHao"></param>
        /// <returns></returns>
        public PowerInfo[] GetYongDianLiang_Ri(string DianYuanID, int LuHao)
        {
            PowerInfo[] vResult   = null;
            DateTime    vKaiShiSJ = DateTime.Now;
            DateTime    vJieShuSJ = DateTime.Now;
            string      vSql      = string.Format("Select MAX(DianNeng) as MaxDianNeng,Time From `电源数据` where unix_timestamp( Time ) "
                                                  + "between unix_timestamp( '{0:yyyy-MM-dd 00:00:00}') and unix_timestamp('{1:yyyy-MM-dd 23:59:59}') "
                                                  + "and DianYuanID='{2}' and LuHao={3} GROUP BY HOUR(Time)", vKaiShiSJ, vJieShuSJ, DianYuanID, LuHao);

            PowerDataViewEFModel[] vSelectResult = m_BasicDBClass.SelectCustomEx <PowerDataViewEFModel>(vSql);
            if (vSelectResult.Length > 0)
            {
                vResult = new PowerInfo[vSelectResult.Length + 1];
            }
            double vOldDianNeng = 0;

            for (int i = 0; i < vSelectResult.Length; i++)
            {
                if (i == 0)
                {
                    vResult[i] = new PowerInfo()
                    {
                        DianNeng   = 0,
                        ShiJian    = new DateTime(vSelectResult[i].Time.Value.Year, vSelectResult[i].Time.Value.Month, vSelectResult[i].Time.Value.Day, 0, 0, 0),
                        ShiJianStr = string.Format("{0}\r点", 0)
                    };
                    vOldDianNeng = (vSelectResult[i].MaxDianNeng ?? 0) * 0.1;
                }

                vResult[i + 1] = new PowerInfo()
                {
                    DianNeng   = (vSelectResult[i].MaxDianNeng ?? 0) * 0.1 - vOldDianNeng,
                    ShiJian    = vSelectResult[i].Time,
                    ShiJianStr = vSelectResult[i].Time == null ? "" : string.Format("{0}\r点", vSelectResult[i].Time.Value.Hour)
                };
                vOldDianNeng = (vSelectResult[i].MaxDianNeng ?? 0) * 0.1;
            }
            return(vResult);
        }