///未测试
        /// <summary>
        /// 吨油耗水-全区
        /// </summary>
        public void GetDyhsData()
        {
            ///先计算水量劈分
            SlpfDAL slpf = new SlpfDAL();

            slpf.GetSlpfData();
            if (!SlpfDAL.dtSLPF.Columns.Contains("DYHS"))
            {
                SlpfDAL.dtSLPF.Columns.Add("DYHS", System.Type.GetType("System.Double"));
            }
            ConnDatabaseUtil cdu = new ConnDatabaseUtil();
            string           jhy = string.Empty, jhs = string.Empty;

            string strSQL = string.Empty;

            strSQL = "select jh, ny, round((ycyl+ycsl) * 30 / scts, 4) as ycyl1 from DBA04 where scts <> 0 and ny between '" + MainForm.strStartDate + "' and '" + MainForm.strEndDate + "' order by jh asc, ny asc"; // 在油井库里将油井按井号 年月排序
            DataTable dtYCYL = cdu.SelectDatabase(strSQL);

            foreach (DataRow dr in dtYCYL.Rows)
            {
                if (Convert.ToDouble(dr["YCYL1"]) > 0)
                {
                    DataRow[] drSLPF = SlpfDAL.dtSLPF.Select("JH = '" + dr["JH"] + "' AND NY = '" + dr["NY"] + "'");
                    if (drSLPF.Count() > 0)
                    {
                        drSLPF[0]["DYHS"] = Convert.ToDouble(drSLPF[0]["SLPF"]) / Convert.ToDouble(dr["YCYL1"]);
                    }
                }
            }
        }
Exemple #2
0
        public void GirdViewResultSource()
        {
            cmbEndDate.Properties.Items.Clear();
            cmbStartDate.Properties.Items.Clear();
            //layoutCWSB.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;

            try
            {
                dockDate.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible;
                DataTable dtNY = cdu.SelectDatabase("select distinct ny from T_WELL_TRACER");
                for (int i = 0; i < dtNY.Rows.Count; i++)
                {
                    cmbStartDate.Properties.Items.Add(dtNY.Rows[i]["NY"]);
                    cmbEndDate.Properties.Items.Add(dtNY.Rows[i]["NY"]);
                }
            }
            catch (Exception)
            {
            }
        }
Exemple #3
0
        public DataTable GetDeWell()
        {
            int       flag  = 0;
            DataTable dtOil = cdu.SelectDatabase("select a.jh, a.k, a.rcsl ccs, b.rcsl mcs, a.rcyl1 ccye, b.rcyl1 mcye, a.hs chs, b.hs mhs, (a.rcyl-b.rcyl) cz from T_WELL_OIL a, T_WELL_OIL b where a.ny = '" + MainForm.strStartDate + "' and b.ny = '" + MainForm.strEndDate + "' and a.jh = b.jh and a.k = b.k and(a.rcyl-b.rcyl)> 0 order by jh,cz desc");

            //DataTable dtDeLayer = dtOil.Clone();
            dtOil.Columns.Add("Reason", System.Type.GetType("System.String"));
            DataTable dtJH = dtOil.DefaultView.ToTable(true, "jh");

            for (int i = 0; i < dtJH.Rows.Count; i++)
            {
                double comp = 0;
                flag = 0;
                DataRow[] drOilDeK = dtOil.Select("jh = '" + dtJH.Rows[i]["JH"] + "'");
                double    dblSum   = Convert.ToDouble(drOilDeK.CopyToDataTable().Compute("sum(cz)", ""));

                foreach (DataRow dr in drOilDeK)
                {
                    //dr["下降比例"] = Convert.ToDouble(dr["cz"]) / dblSum;
                    comp += Convert.ToDouble(dr["cz"]) / dblSum;
                    if (comp >= 0.7)
                    {
                        flag++;
                        if (flag == 2)
                        {
                            break;
                        }
                    }

                    double dblM = (Convert.ToDouble(dr["ccye"]) - Convert.ToDouble(dr["mcye"])) / (1 - Convert.ToDouble(dr["chs"]));
                    double dblN = Convert.ToDouble(dr["ccye"]) * (Convert.ToDouble(dr["mhs"]) - Convert.ToDouble(dr["chs"]));


                    if (dblM > dblN)
                    {
                        dr["Reason"] = "供液不足";
                    }
                    else
                    {
                        dr["Reason"] = "含水上升";
                    }
                }
            }
            DataTable dtDeK = dtOil.Select("Reason is not Null").CopyToDataTable();

            return(dtDeK);
        }
        /// <summary>
        /// 读取示踪剂文件
        /// </summary>
        public void GetTracer(string strPath, string strTrace)
        {
            FileStream   fs = new FileStream(strPath, FileMode.Open);
            StreamReader sr = new StreamReader(fs);

            try
            {
                GetTraceJH gtj = new GetTraceJH();

                DataTable dtTracerJH = gtj.GetTraceJHMethod(strTrace);

                DateUtil du = new DateUtil();
                //string strStartDate = du.DateTimeCovertToString(DateTime.ParseExact((MainForm.strStartDate), "yyyyMM", null));
                //string strEndDate = du.DateTimeCovertToString(DateTime.ParseExact((MainForm.strEndDate), "yyyyMM", null).AddMonths(1));

                string strReadLine;
                string strJH     = string.Empty;
                string strDate   = string.Empty;
                string strTracer = string.Empty;
                bool   isWell    = false;
                bool   isRead    = false;
                bool   isWater   = false;
                bool   isDate    = false;


                List <TracerModel> lstTM     = new List <TracerModel>();
                List <OilModel>    lstOilM   = new List <OilModel>();
                List <WaterModel>  lstWaterM = new List <WaterModel>();
                DataTable          dtOil     = ListToDataTableUtil.ListToDataTable(lstOilM);
                DataTable          dtWater   = ListToDataTableUtil.ListToDataTable(lstWaterM);
                DataTable          dtTracer  = ListToDataTableUtil.ListToDataTable(lstTM);
                strReadLine = sr.ReadLine().Replace(":", " ").Replace(",", " ");
                string trim = strReadLine.Trim();
                while (strReadLine != null)
                {
                    trim = strReadLine.Trim();

                    string[] strArray = Regex.Split(trim, @"\s+");

                    if (((strArray.Length == 12) && (strArray[0].Equals("STEP")) && (strArray[8].Equals("REPT"))) || ((strArray.Length == 11) && (strArray[0].Equals("STEP")) && (strArray[7].Equals("REPT"))))
                    {
                        strDate = strArray[strArray.Length - 1];
                        //isDate = true;
                        //if (strDate.Equals(strStartDate))
                        //{
                        //    isDate = true;
                        //}
                        if (strDate.Equals("(1-NOV-2014)"))
                        {
                            isDate = true;
                        }
                        //if (strDate.Equals(strEndDate))
                        //{
                        //    isDate = false;
                        //    break;

                        //}
                    }
                    if (isDate)
                    {
                        if (strArray[0].Equals("TRACER") && strArray.Count() == 6 && strArray[5].Equals("PASSIVE") && strArray[3].Equals("WATER") && strArray[4].Equals("PHASE"))
                        {
                            DataRow[] drTracer = dtTracerJH.Select("trace = '" + strArray[2] + "'");
                            {
                                if (drTracer.Count() > 0)
                                {
                                    strTracer = drTracer[0]["smjh"].ToString();
                                }
                            }
                        }


                        if (((strArray.Count() == 11) && strArray[3].Equals("PROD")) || ((strArray.Count() == 11) && strArray[3].Equals("WINJ")) || ((strArray.Count() == 10) && strArray[0].Equals("BLOCK")))
                        {
                            if ((strArray.Count() == 11) && strArray[3].Equals("PROD"))
                            {
                                isWater = false;
                            }
                            else if ((strArray.Count() == 11) && strArray[3].Equals("WINJ"))
                            {
                                isWater = true;
                            }
                            if (!strArray[0].Equals("BLOCK"))
                            {
                                strJH = strArray[0];
                            }
                            isWell = true;
                            while (isWell)
                            {
                                strArray = Regex.Split(trim, @"\s+");
                                if (strArray[0].Equals("BLOCK"))
                                {
                                    if (isWater)
                                    {
                                        /*
                                         * if (!strArray[4].Equals("SHUT"))
                                         * {
                                         *  //if (Convert.ToDouble(strArray[4]) > 0)
                                         *  //{
                                         *  DataRow drTracer = dtTracer.NewRow();
                                         *  drTracer["jhy"] = "";
                                         *  drTracer["jhs"] = strJH;
                                         *
                                         *  drTracer["mncs"] = Convert.ToDouble(strArray[4]);
                                         *  drTracer["szj"] = strTracer;
                                         *  drTracer["szjnd"] = Convert.ToDouble(strArray[7]);
                                         *  drTracer["ny"] = du.TextDateStringCovertToDateTime(strDate).ToString("yyyyMM");
                                         *  drTracer["x"] = Convert.ToInt32(strArray[1]);
                                         *  drTracer["y"] = Convert.ToInt32(strArray[2]);
                                         *  drTracer["k"] = Convert.ToInt32(strArray[3]);
                                         *  dtTracer.Rows.Add(drTracer);
                                         *  // }
                                         * }
                                         * else
                                         * {
                                         *  DataRow drTracer = dtTracer.NewRow();
                                         *  drTracer["jhy"] = "";
                                         *  drTracer["jhs"] = strJH;
                                         *
                                         *  drTracer["mncs"] = Convert.ToDouble(strArray[5]);
                                         *  drTracer["szj"] = strTracer;
                                         *  drTracer["szjnd"] = Convert.ToDouble(strArray[8]);
                                         *  drTracer["ny"] = du.TextDateStringCovertToDateTime(strDate).ToString("yyyyMM");
                                         *  drTracer["x"] = Convert.ToInt32(strArray[1]);
                                         *  drTracer["y"] = Convert.ToInt32(strArray[2]);
                                         *  drTracer["k"] = Convert.ToInt32(strArray[3]);
                                         *  dtTracer.Rows.Add(drTracer);
                                         * }
                                         */
                                    }

                                    else

                                    {
                                        if (!strArray[4].Equals("SHUT"))
                                        {
                                            //if (Convert.ToDouble(strArray[5]) > 0)
                                            //{
                                            DataRow drTracer = dtTracer.NewRow();
                                            drTracer["jhy"] = strJH;
                                            drTracer["jhs"] = "";

                                            drTracer["mncs"]  = Convert.ToDouble(strArray[5]);
                                            drTracer["szj"]   = strTracer;
                                            drTracer["szjnd"] = Convert.ToDouble(strArray[7]);
                                            drTracer["ny"]    = du.TextDateStringCovertToDateTime(strDate).ToString("yyyyMM");
                                            drTracer["x"]     = Convert.ToInt32(strArray[1]);
                                            drTracer["y"]     = Convert.ToInt32(strArray[2]);
                                            drTracer["k"]     = Convert.ToInt32(strArray[3]);
                                            dtTracer.Rows.Add(drTracer);
                                            //}
                                        }
                                        else
                                        {
                                            DataRow drTracer = dtTracer.NewRow();
                                            drTracer["jhy"] = strJH;
                                            drTracer["jhs"] = "";

                                            drTracer["mncs"]  = Convert.ToDouble(strArray[6]);
                                            drTracer["szj"]   = strTracer;
                                            drTracer["szjnd"] = Convert.ToDouble(strArray[8]);
                                            drTracer["ny"]    = du.TextDateStringCovertToDateTime(strDate).ToString("yyyyMM");
                                            drTracer["x"]     = Convert.ToInt32(strArray[1]);
                                            drTracer["y"]     = Convert.ToInt32(strArray[2]);
                                            drTracer["k"]     = Convert.ToInt32(strArray[3]);
                                            dtTracer.Rows.Add(drTracer);
                                        }
                                    }

                                    strReadLine = sr.ReadLine();
                                    if (strReadLine != null)
                                    {
                                        strReadLine = strReadLine.Replace(":", " ").Replace(",", " ");
                                        trim        = strReadLine.Trim();
                                    }
                                }

                                else
                                {
                                    isWell = false;
                                }
                            }
                        }

                        else
                        {
                            if (trim.Equals("INJECTION  REPORT"))
                            {
                                isRead  = true;
                                isWater = true;
                            }
                            else if (trim.Equals("PRODUCTION REPORT"))
                            {
                                isRead  = true;
                                isWater = false;
                            }
                            else if (trim.Equals("CUMULATIVE PRODUCTION/INJECTION TOTALS"))
                            {
                                isRead = false;
                            }

                            if (isRead)
                            {
                                trim = strReadLine.Trim();

                                strArray = Regex.Split(trim, @"\s+");
                                if (isWater)
                                {
                                    if ((strArray.Count() >= 12) && (strArray.Count() <= 13))
                                    {
                                        if (strArray.Count() == 12 || strArray[4].Equals("SHUT"))
                                        {
                                            if (strArray[0].Length > 0)
                                            {
                                                if (!strArray[0].Equals("BLOCK"))
                                                {
                                                    strJH = strArray[0];
                                                }
                                                isWell = true;
                                                if (strArray[1].Equals("GROUP") || strArray[0].Equals("REPORT"))
                                                {
                                                    isWell = false;
                                                }
                                                while (isWell)
                                                {
                                                    strArray = Regex.Split(trim, @"\s+");
                                                    if (strArray[0].Equals("BLOCK"))
                                                    {
                                                        if (!strArray[4].Equals("SHUT"))
                                                        {
                                                            DataRow drWater = dtWater.NewRow();
                                                            drWater["jh"] = strJH;
                                                            if (Convert.ToDouble(strArray[5]) < 0)
                                                            {
                                                                drWater["rzsl"] = 0;
                                                            }
                                                            else
                                                            {
                                                                drWater["rzsl"] = Convert.ToDouble(strArray[5]);
                                                            }
                                                            drWater["ny"]  = du.TextDateStringCovertToDateTime(strDate).ToString("yyyyMM");
                                                            drWater["x"]   = Convert.ToInt32(strArray[1]);
                                                            drWater["y"]   = Convert.ToInt32(strArray[2]);
                                                            drWater["bhp"] = Convert.ToDouble(strArray[8]);
                                                            drWater["k"]   = Convert.ToInt32(strArray[3]);
                                                            dtWater.Rows.Add(drWater);
                                                        }
                                                        strReadLine = sr.ReadLine().Replace(":", " ").Replace(",", " ");
                                                        trim        = strReadLine.Trim();
                                                    }

                                                    else
                                                    {
                                                        isWell = false;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    if (strArray.Count() >= 16)
                                    {
                                        if (strArray.Count() == 16 || strArray[4].Equals("SHUT"))
                                        {
                                            if (strArray[0].Length > 0)
                                            {
                                                if (!strArray[0].Equals("BLOCK"))
                                                {
                                                    strJH = strArray[0];
                                                }
                                                isWell = true;
                                                if (strArray[1].Equals("GROUP") || strArray[0].Equals("REPORT"))
                                                {
                                                    isWell = false;
                                                }
                                                while (isWell)
                                                {
                                                    strArray = Regex.Split(trim, @"\s+");
                                                    if (strArray[0].Equals("BLOCK"))
                                                    {
                                                        if (!strArray[4].Equals("SHUT"))
                                                        {
                                                            DataRow drOil = dtOil.NewRow();
                                                            drOil["jh"] = strJH;
                                                            if (Convert.ToDouble(strArray[7]) < 0)
                                                            {
                                                                drOil["rcyl1"] = 0;
                                                            }
                                                            else
                                                            {
                                                                drOil["rcyl1"] = Convert.ToDouble(strArray[7]);
                                                            }
                                                            drOil["hs"]   = Convert.ToDouble(strArray[8]);
                                                            drOil["rcsl"] = Convert.ToDouble(strArray[8]) * Convert.ToDouble(drOil["rcyl1"]);
                                                            drOil["rcyl"] = Convert.ToDouble(drOil["rcyl1"]) * (1 - Convert.ToDouble(strArray[8]));
                                                            drOil["ny"]   = du.TextDateStringCovertToDateTime(strDate).ToString("yyyyMM");
                                                            drOil["x"]    = Convert.ToInt32(strArray[1]);
                                                            drOil["y"]    = Convert.ToInt32(strArray[2]);
                                                            drOil["bhp"]  = Convert.ToDouble(strArray[11]);
                                                            drOil["k"]    = Convert.ToInt32(strArray[3]);
                                                            dtOil.Rows.Add(drOil);
                                                        }
                                                        strReadLine = sr.ReadLine().Replace(":", " ").Replace(",", " ");
                                                        trim        = strReadLine.Trim();
                                                    }
                                                    else
                                                    {
                                                        isWell = false;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    strReadLine = sr.ReadLine();
                    if (strReadLine != null)
                    {
                        strReadLine = strReadLine.Replace(":", " ").Replace(",", " ");
                    }
                    //break;
                }



                ConnDatabaseUtil cdu = new ConnDatabaseUtil();

                string strTableName = "T_WELL_OIL";

                string    strSQL  = "select count(*) as count from user_tables where table_name = '" + strTableName.ToUpper() + "'";
                DataTable dtExist = cdu.SelectDatabase(strSQL);
                if (Convert.ToInt32(dtExist.Rows[0]["Count"]) > 0)
                {
                    strSQL = "drop table " + strTableName.ToUpper();
                    cdu.CreateOrDeleteDatabase(strSQL);
                }
                strSQL = "create table " + strTableName.ToUpper() + " (jh    VARCHAR2(16),  ny VARCHAR2(6),  x     NUMBER(3),  y     NUMBER(3),  k     NUMBER(2),  rcsl  NUMBER(17, 2),  rcyl  NUMBER(17, 2),  rcyl1 NUMBER(17, 2),  hs    NUMBER(17, 3),  bhp   NUMBER(17, 2))";
                cdu.CreateOrDeleteDatabase(strSQL);
                cdu.InsertDatabase(dtOil, strTableName.ToUpper());



                strTableName = "T_WELL_WATER";

                strSQL  = "select count(*) as count from user_tables where table_name = '" + strTableName.ToUpper() + "'";
                dtExist = cdu.SelectDatabase(strSQL);
                if (Convert.ToInt32(dtExist.Rows[0]["Count"]) > 0)
                {
                    strSQL = "drop table " + strTableName.ToUpper();
                    cdu.CreateOrDeleteDatabase(strSQL);
                }
                strSQL = "create table " + strTableName.ToUpper() + " (jh    VARCHAR2(16),  ny VARCHAR2(6),  x     NUMBER(3),  y     NUMBER(3),  k     NUMBER(2),  rzsl  NUMBER(17, 2),  bhp   NUMBER(17, 2))";
                cdu.CreateOrDeleteDatabase(strSQL);
                cdu.InsertDatabase(dtWater, strTableName.ToUpper());

                strTableName = "T_WELL_TRACER";

                strSQL  = "select count(*) as count from user_tables where table_name = '" + strTableName.ToUpper() + "'";
                dtExist = cdu.SelectDatabase(strSQL);
                if (Convert.ToInt32(dtExist.Rows[0]["Count"]) > 0)
                {
                    strSQL = "drop table " + strTableName.ToUpper();
                    cdu.CreateOrDeleteDatabase(strSQL);
                }
                strSQL = "create table " + strTableName.ToUpper() + " (jhy    VARCHAR2(16), jhs    VARCHAR2(16),szj    VARCHAR2(16), szjnd  NUMBER(17, 5), ny VARCHAR2(6),  x     NUMBER(3),  y     NUMBER(3),  k     NUMBER(2),  mncs  NUMBER(17, 2))";
                cdu.CreateOrDeleteDatabase(strSQL);
                cdu.InsertDatabase(dtTracer, strTableName.ToUpper());
            }
            catch (Exception)
            {
            }
            finally
            {
                sr.Close();
                fs.Close();
            }
        }
        public void GetGldData()
        {
            if (dtGLD.Rows.Count == 0)
            {
                if (dtGLD.Columns.Count == 0)
                {
                    dtGLD.Columns.Add("JHS", System.Type.GetType("System.String"));
                    dtGLD.Columns.Add("JHY", System.Type.GetType("System.String"));
                    dtGLD.Columns.Add("GLD", System.Type.GetType("System.Double"));
                }
                ConnDatabaseUtil cdu = new ConnDatabaseUtil();
                string           jhy = string.Empty, jhs = string.Empty;

                string strSQL = string.Empty;

                double fz = 0;           //分子
                double yfm = 0, sfm = 0; //油分母,水分母

                strSQL = "select jh, ny, round((ycyl+ycsl) * 30 / scts, 4) as ycyl1 from DBA04 where scts <> 0 and ny between '" + MainForm.strStartDate + "' and '" + MainForm.strEndDate + "' order by jh asc, ny asc";
                DataTable dtYCYL   = cdu.SelectDatabase(strSQL);
                DataTable dtYCYLJH = dtYCYL.DefaultView.ToTable(true, "JH");
                for (int i = 0; i < dtYCYLJH.Rows.Count; i++)
                {
                    double    ya       = Convert.ToDouble(dtYCYL.Compute("AVG(YCYL1)", "JH = '" + dtYCYLJH.Rows[i]["JH"] + "'")); //油井月产液量平均值
                    DataTable dtDjYCYL = dtYCYL.Select("JH = '" + dtYCYLJH.Rows[i]["JH"] + "'", "NY ASC").CopyToDataTable();      //当前单井月产液量
                    int       cntYNY   = Convert.ToInt32(dtDjYCYL.Compute("COUNT(NY)", ""));                                      //当前油井月份数
                    strSQL = "select distinct * from " + MainForm.strLTKName + " where jhy = '" + dtYCYLJH.Rows[i]["JH"] + "'";
                    DataTable dtLTWater = cdu.SelectDatabase(strSQL);
                    for (int j = 0; j < dtLTWater.Rows.Count; j++)
                    {
                        strSQL = "select d.jh, d.ny, round(d.yzsl * 30 / d.scts, 4) as yzsl1 from DBA05 d where d.scts <> 0 and jh = '" + dtLTWater.Rows[j]["JHS"] + "' and ny between '" + MainForm.strStartDate + "' and '" + MainForm.strEndDate + "' order by jh asc, ny asc";
                        DataTable dtYZSL = cdu.SelectDatabase(strSQL);
                        if (dtYZSL.Rows.Count > 0)
                        {
                            double sa = Convert.ToDouble(dtYZSL.Compute("AVG(YZSL1)", ""));//水井月注水量平均值

                            for (int k = 0; k < cntYNY; k++)
                            {
                                DataRow[] sny = dtYZSL.Select("NY = '" + dtDjYCYL.Rows[k]["NY"] + "'");
                                if (sny.Count() > 0)
                                {
                                    fz  += (Convert.ToDouble(sny[0]["YZSL1"]) - sa) * (Convert.ToDouble(dtDjYCYL.Rows[k]["YCYL1"]) - ya);
                                    sfm += Math.Pow((Convert.ToDouble(sny[0]["YZSL1"]) - sa), 2);
                                    yfm += Math.Pow((Convert.ToDouble(dtDjYCYL.Rows[k]["YCYL1"]) - ya), 2);
                                }
                            }
                            sfm = Math.Pow(sfm, 0.5);
                            yfm = Math.Pow(yfm, 0.5);
                            double r = fz / (sfm * yfm);
                            fz  = 0;
                            sfm = 0;
                            yfm = 0;
                            DataRow dr = dtGLD.NewRow();
                            dr["JHS"] = dtLTWater.Rows[j]["JHS"];
                            dr["JHY"] = dtYCYLJH.Rows[i]["JH"];
                            dr["GLD"] = r;
                            dtGLD.Rows.Add(dr);
                        }
                    }
                }
            }
        }
Exemple #6
0
        public DataTable GetYJCS(DataTable dtSLBH)
        {
            //如果不能运行在下面语句中的avg()函数前加round保留小数
            DataTable dtYJCS = cdu.SelectDatabase("select b.*, a.*, round(b.平均剩余储量 / a.pjsy, 4) sybl, round(b.平均含油饱和度 / a.pjhy, 4) hybl,round(b.平均圧力 / a.pjyl, 4) ylbl from (select t.层位, avg(t.平均含油饱和度) pjhy, avg(t.平均圧力) pjyl, avg(t.平均剩余储量) pjsy from (select distinct * from T_WELL_ENDFACTOR) t group by t.层位) a,(select distinct * from T_WELL_ENDFACTOR) b where a.层位 = b.层位");

            dtSLBH.Columns.Add("YJCS", System.Type.GetType("System.String"));
            foreach (DataRow dr in dtSLBH.Rows)
            {
                DataRow[] drYJCS = dtYJCS.Select("油井 = '" + dr["JHY"] + "' and 水井 = '" + dr["SZJ"] + "' and K = " + dr["K"]);
                if (drYJCS.Count() > 0)
                {
                    if ((Convert.ToDouble(dr["hybl"]) < 0.9) && (Convert.ToDouble(dr["sybl"]) < 0.9) && (Convert.ToDouble(dr["ylbl"]) < 0.9))
                    {
                        dr["YJCS"] = "水井调油井堵或油井控";
                    }
                    else if ((Convert.ToDouble(dr["hybl"]) < 0.9) && (Convert.ToDouble(dr["sybl"]) <= 1.1) && (Convert.ToDouble(dr["ylbl"]) >= 0.9 && Convert.ToDouble(dr["ylbl"]) <= 1.1))
                    {
                        dr["YJCS"] = "油水井控";
                    }
                    else if ((Convert.ToDouble(dr["hybl"]) < 0.9) && (Convert.ToDouble(dr["sybl"]) <= 1.1) && (Convert.ToDouble(dr["ylbl"]) > 1.1))
                    {
                        dr["YJCS"] = "水井控";
                    }

                    else if ((Convert.ToDouble(dr["hybl"]) < 0.9) && (Convert.ToDouble(dr["sybl"]) >= 0.9) && (Convert.ToDouble(dr["ylbl"]) < 0.9))
                    {
                        dr["YJCS"] = "油井控";
                    }
                    else if ((Convert.ToDouble(dr["hybl"]) < 0.9) && (Convert.ToDouble(dr["sybl"]) > 1.1) && (Convert.ToDouble(dr["ylbl"]) > 1.1))
                    {
                        dr["YJCS"] = "水井挖+综合挖潜";
                    }
                    else if ((Convert.ToDouble(dr["hybl"]) < 0.9) && (Convert.ToDouble(dr["sybl"]) > 1.1) && (Convert.ToDouble(dr["ylbl"]) >= 0.9 && Convert.ToDouble(dr["ylbl"]) <= 1.1))
                    {
                        dr["YJCS"] = "稳";
                    }
                    else if ((Convert.ToDouble(dr["hybl"]) >= 0.9 && Convert.ToDouble(dr["hybl"]) <= 1.1) && (Convert.ToDouble(dr["sybl"]) < 0.9) && (Convert.ToDouble(dr["ylbl"]) < 0.9))
                    {
                        dr["YJCS"] = "水井提压";
                    }
                    else if ((Convert.ToDouble(dr["hybl"]) >= 0.9 && Convert.ToDouble(dr["hybl"]) <= 1.1) && (Convert.ToDouble(dr["ylbl"]) >= 0.9 && Convert.ToDouble(dr["ylbl"]) <= 1.1))
                    {
                        dr["YJCS"] = "稳";
                    }
                    else if ((Convert.ToDouble(dr["hybl"]) >= 0.9 && Convert.ToDouble(dr["hybl"]) <= 1.1) && (Convert.ToDouble(dr["sybl"]) < 0.9) && (Convert.ToDouble(dr["ylbl"]) > 1.1))
                    {
                        dr["YJCS"] = "油井压或油井提";
                    }
                    else if ((Convert.ToDouble(dr["hybl"]) >= 0.9 && Convert.ToDouble(dr["hybl"]) <= 1.1) && (Convert.ToDouble(dr["sybl"]) >= 0.9 && Convert.ToDouble(dr["sybl"]) <= 1.1) && (Convert.ToDouble(dr["ylbl"]) < 0.9))
                    {
                        dr["YJCS"] = "油井控";
                    }
                    else if ((Convert.ToDouble(dr["hybl"]) >= 0.9 && Convert.ToDouble(dr["hybl"]) <= 1.1) && (Convert.ToDouble(dr["sybl"]) >= 0.9 && Convert.ToDouble(dr["sybl"]) <= 1.1) && (Convert.ToDouble(dr["ylbl"]) > 1.1))
                    {
                        dr["YJCS"] = "水井控";
                    }
                    else if ((Convert.ToDouble(dr["hybl"]) >= 0.9 && Convert.ToDouble(dr["hybl"]) <= 1.1) && (Convert.ToDouble(dr["sybl"]) > 1.1) && (Convert.ToDouble(dr["ylbl"]) < 0.9))
                    {
                        dr["YJCS"] = "水井提";
                    }
                    else if ((Convert.ToDouble(dr["hybl"]) >= 0.9 && Convert.ToDouble(dr["hybl"]) <= 1.1) && (Convert.ToDouble(dr["sybl"]) > 1.1) && (Convert.ToDouble(dr["ylbl"]) > 1.1))
                    {
                        dr["YJCS"] = "水井挖 + 综合挖潜";
                    }
                    else if ((Convert.ToDouble(dr["hybl"]) > 1.1) && (Convert.ToDouble(dr["sybl"]) <= 1.1) && (Convert.ToDouble(dr["ylbl"]) < 0.9))
                    {
                        dr["YJCS"] = "水井提压结合";
                    }
                    else if ((Convert.ToDouble(dr["hybl"]) > 1.1) && (Convert.ToDouble(dr["sybl"]) < 0.9) && (Convert.ToDouble(dr["ylbl"]) >= 0.9 && Convert.ToDouble(dr["ylbl"]) <= 1.1))
                    {
                        dr["YJCS"] = "油水井提压结合";
                    }
                    else if ((Convert.ToDouble(dr["hybl"]) > 1.1) && (Convert.ToDouble(dr["sybl"]) < 0.9) && (Convert.ToDouble(dr["ylbl"]) > 1.1))
                    {
                        dr["YJCS"] = "油井压或油井提";
                    }
                    else if ((Convert.ToDouble(dr["hybl"]) > 1.1) && (Convert.ToDouble(dr["sybl"]) >= 0.9 && Convert.ToDouble(dr["sybl"]) <= 1.1) && (Convert.ToDouble(dr["ylbl"]) >= 0.9 && Convert.ToDouble(dr["ylbl"]) <= 1.1))
                    {
                        dr["YJCS"] = "油水井提";
                    }
                    else if ((Convert.ToDouble(dr["hybl"]) > 1.1) && (Convert.ToDouble(dr["sybl"]) >= 0.9 && Convert.ToDouble(dr["sybl"]) <= 1.1) && (Convert.ToDouble(dr["ylbl"]) > 1.1))
                    {
                        dr["YJCS"] = "油井提";
                    }
                    else if ((Convert.ToDouble(dr["hybl"]) > 1.1) && (Convert.ToDouble(dr["sybl"]) > 1.1) && (Convert.ToDouble(dr["ylbl"]) < 0.9))
                    {
                        dr["YJCS"] = "厚层水井提,薄层水井提压结合";
                    }
                    else if ((Convert.ToDouble(dr["hybl"]) > 1.1) && (Convert.ToDouble(dr["sybl"]) > 1.1) && (Convert.ToDouble(dr["ylbl"]) < 0.9))
                    {
                        dr["YJCS"] = "厚层水井提,薄层水井提压结合";
                    }
                    else if ((Convert.ToDouble(dr["hybl"]) > 1.1) && (Convert.ToDouble(dr["sybl"]) > 1.1) && (Convert.ToDouble(dr["ylbl"]) >= 0.9 && Convert.ToDouble(dr["ylbl"]) <= 1.1))
                    {
                        dr["YJCS"] = "厚层油井提,薄层油水井提压结合";
                    }
                    else if ((Convert.ToDouble(dr["hybl"]) > 1.1) && (Convert.ToDouble(dr["sybl"]) > 1.1) && (Convert.ToDouble(dr["ylbl"]) > 1.1))
                    {
                        dr["YJCS"] = "水井挖 + 综合挖潜";
                    }
                }
            }
            return(dtYJCS);
        }
Exemple #7
0
        public DataTable GetSlbhDAL(DataTable dtYJ)
        {
            DataTable dtSLBH = new DataTable();

            dtSLBH.Columns.Add("JHY", System.Type.GetType("System.String"));
            dtSLBH.Columns.Add("SZJ", System.Type.GetType("System.String"));
            dtSLBH.Columns.Add("CSL", System.Type.GetType("System.Double"));
            dtSLBH.Columns.Add("MSL", System.Type.GetType("System.Double"));
            dtSLBH.Columns.Add("BH", System.Type.GetType("System.Double"));
            dtSLBH.Columns.Add("K", System.Type.GetType("System.Int32"));
            for (int i = 0; i < dtYJ.Rows.Count; i++)
            {
                DataTable dtSJYJH = cdu.SelectDatabase("select * from dyjh where smjh = '" + dtYJ.Rows[i]["jh"] + "'");
                if (dtSJYJH.Rows.Count > 0)
                {
                    DataTable dtLtjhs = cdu.SelectDatabase("select * from ltk where jh = '" + dtSJYJH.Rows[0]["sjjh"] + "'");
                    if (dtLtjhs.Rows.Count > 0)
                    {
                        int dbjs = Convert.ToInt32(dtLtjhs.Rows[0]["dbjs"]);
                        for (int j = 1; j <= dbjs; j++)
                        {
                            DataTable dtSMSJH = cdu.SelectDatabase("select * from dyjh where sjjh = '" + dtLtjhs.Rows[0]["dbjh" + j] + "'");
                            if (dtSMSJH.Rows.Count > 0)
                            {
                                double    dblCsl = 0;
                                double    dblMsl = 0;
                                DataTable dtCSZJ = cdu.SelectDatabase("select a.jhy, a.szj, a.k, a.szjnd cnd from T_WELL_TRACER a where a.jhy = '" + dtYJ.Rows[i]["jh"] + "' and a.szj = '" + dtSMSJH.Rows[0]["smjh"] + "' and a.ny = '" + MainForm.strStartDate + "' and a.K = " + dtYJ.Rows[i]["K"]);
                                DataTable dtMSZJ = cdu.SelectDatabase("select a.jhy, a.szj, a.k, a.szjnd mnd from T_WELL_TRACER a where a.jhy = '" + dtYJ.Rows[i]["jh"] + "' and a.szj = '" + dtSMSJH.Rows[0]["smjh"] + "' and a.ny = '" + MainForm.strEndDate + "' and a.K = " + dtYJ.Rows[i]["K"]);
                                if (dtCSZJ.Rows.Count > 0)
                                {
                                    dblCsl = Convert.ToDouble(dtYJ.Rows[i]["ccs"]) * Convert.ToDouble(dtCSZJ.Rows[0]["cnd"]);//初水量
                                }
                                if (dtMSZJ.Rows.Count > 0)
                                {
                                    dblMsl = Convert.ToDouble(dtYJ.Rows[i]["mcs"]) * Convert.ToDouble(dtMSZJ.Rows[0]["mnd"]);//末水量
                                }
                                DataRow drSLBH = dtSLBH.NewRow();
                                drSLBH["JHY"] = dtYJ.Rows[i]["jh"];
                                drSLBH["K"]   = dtYJ.Rows[i]["K"];
                                drSLBH["CSL"] = dblCsl;
                                drSLBH["MSL"] = dblMsl;
                                drSLBH["SZJ"] = dtSMSJH.Rows[0]["smjh"];
                                drSLBH["BH"]  = dblCsl - dblMsl;
                                dtSLBH.Rows.Add(drSLBH);
                            }
                        }
                    }
                    else
                    {
                        for (int j = 1; j <= connNumber; j++)
                        {
                            string strColumnName = "DBJH" + j;
                            dtLtjhs = cdu.SelectDatabase("select * from LTK where " + strColumnName + " = '" + dtSJYJH.Rows[0]["sjjh"] + "'");
                            foreach (DataRow drLtjhs in dtLtjhs.Rows)
                            {
                                DataTable dtSMSJH = cdu.SelectDatabase("select * from dyjh where sjjh = '" + drLtjhs["jh"] + "'");
                                if (dtSMSJH.Rows.Count > 0)
                                {
                                    double    dblCsl = 0;
                                    double    dblMsl = 0;
                                    DataTable dtCSZJ = cdu.SelectDatabase("select a.jhy, a.szj, a.k, a.szjnd cnd from T_WELL_TRACER a where a.jhy = '" + dtYJ.Rows[i]["jh"] + "' and a.szj = '" + dtSMSJH.Rows[0]["smjh"] + "' and a.ny = '" + MainForm.strStartDate + "' and a.K = " + dtYJ.Rows[i]["K"]);
                                    DataTable dtMSZJ = cdu.SelectDatabase("select a.jhy, a.szj, a.k, a.szjnd mnd from T_WELL_TRACER a where a.jhy = '" + dtYJ.Rows[i]["jh"] + "' and a.szj = '" + dtSMSJH.Rows[0]["smjh"] + "' and a.ny = '" + MainForm.strEndDate + "' and a.K = " + dtYJ.Rows[i]["K"]);
                                    if (dtCSZJ.Rows.Count > 0)
                                    {
                                        dblCsl = Convert.ToDouble(dtYJ.Rows[i]["ccs"]) * Convert.ToDouble(dtCSZJ.Rows[0]["cnd"]);//初水量
                                    }
                                    if (dtMSZJ.Rows.Count > 0)
                                    {
                                        dblMsl = Convert.ToDouble(dtYJ.Rows[i]["mcs"]) * Convert.ToDouble(dtMSZJ.Rows[0]["mnd"]);//末水量
                                    }
                                    DataRow drSLBH = dtSLBH.NewRow();
                                    drSLBH["JHY"] = dtYJ.Rows[i]["jh"];
                                    drSLBH["SZJ"] = dtSMSJH.Rows[0]["smjh"];
                                    drSLBH["K"]   = dtYJ.Rows[i]["K"];
                                    drSLBH["BH"]  = dblCsl - dblMsl;
                                    drSLBH["CSL"] = dblCsl;
                                    drSLBH["MSL"] = dblMsl;
                                    dtSLBH.Rows.Add(drSLBH);
                                }
                            }
                        }
                    }
                }
            }


            DataTable dtSLXJ = dtSLBH.Select("BH > 0").CopyToDataTable();//水量下降
            DataView  dv     = dtSLXJ.DefaultView;

            dv.Sort = "BH  DESC";
            dtSLXJ  = dv.ToTable();
            DataTable dtJH = dtSLXJ.DefaultView.ToTable(true, "jhy");

            for (int i = 0; i < dtJH.Rows.Count; i++)
            {
                int       flag   = 0;
                double    comp   = 0;
                DataRow[] drSjh  = dtSLXJ.Select("jhy = '" + dtJH.Rows[i]["jhy"] + "'");
                double    dblSum = Convert.ToDouble(drSjh.CopyToDataTable().Compute("sum(BH)", ""));

                foreach (DataRow dr in drSjh)
                {
                    //dr["下降比例"] = Convert.ToDouble(dr["cz"]) / dblSum;
                    comp += Convert.ToDouble(dr["bh"]) / dblSum;
                    if (comp >= 0.7)
                    {
                        flag++;
                        if (flag >= 2)
                        {
                            dtSLXJ.Rows.Remove(dr);
                        }
                    }
                }
            }
            return(dtSLXJ);
        }
        public void GetLTJInf(string strDate)
        {
            DataTable          dtOil   = new DataTable();
            DataTable          dtWater = new DataTable();
            List <ResultModel> lstRm   = new List <ResultModel>();

            dtResult = ListToDataTableUtil.ListToDataTable(lstRm);

            dtOil = cdu.SelectDatabase("select * from yjjh");
            for (int i = 0; i < dtOil.Rows.Count; i++)
            {
                //DataTable dtSMYJH = ConnDatabaseUtil.SelectDBF("select * from 井号 where 实际井号 = '" + dtOil.Rows[i]["jh"] + "'");
                DataTable dtSMYJH = cdu.SelectDatabase("select * from dyjh where sjjh = '" + dtOil.Rows[i]["jh"] + "'");
                if (dtSMYJH.Rows.Count > 0)
                {
                    DataRow[] drJHY = LocationDAL.dtSK.Select("jh = '" + dtSMYJH.Rows[0]["smjh"] + "'");

                    foreach (DataRow dr in drJHY)
                    {
                        DataTable dtLtjhs = cdu.SelectDatabase("select * from ltk where jh = '" + dtOil.Rows[i]["jh"] + "'");
                        if (dtLtjhs.Rows.Count > 0)
                        {
                            int dbjs = Convert.ToInt32(dtLtjhs.Rows[0]["dbjs"]);
                            for (int j = 1; j <= dbjs; j++)
                            {
                                DataTable dtIsSJ = cdu.SelectDatabase("select * from sjjh where jh = '" + dtLtjhs.Rows[0]["dbjh" + j] + "'");
                                if (dtIsSJ.Rows.Count > 0)
                                {
                                    //DataTable dtSMSJH = ConnDatabaseUtil.SelectDBF("select * from 井号 where 实际井号 = '" + dtLtjhs.Rows[0]["dbjh" + j] + "'");
                                    DataTable dtSMSJH = cdu.SelectDatabase("select * from dyjh where sjjh = '" + dtLtjhs.Rows[0]["dbjh" + j] + "'");
                                    if (dtSMSJH.Rows.Count > 0)
                                    {
                                        WellModel jhs = ld.GetSingleLocation(dtSMSJH.Rows[0]["smjh"].ToString(), Convert.ToInt32(dr["k"]));
                                        GetLTOilJH(jhs, strDate, dtLtjhs.Rows[0]["dbjh" + j].ToString());
                                    }
                                }
                            }
                        }
                        else
                        {
                            for (int j = 1; j <= connNumber; j++)
                            {
                                string strColumnName = "DBJH" + j;
                                dtLtjhs = cdu.SelectDatabase("select * from LTK where " + strColumnName + " = '" + dtOil.Rows[i]["jh"] + "'");
                                foreach (DataRow drLtjhs in dtLtjhs.Rows)
                                {
                                    DataTable dtIsSJ = cdu.SelectDatabase("select * from sjjh where jh = '" + drLtjhs["jh"] + "'");
                                    if (dtIsSJ.Rows.Count > 0)
                                    {
                                        //DataTable dtSMSJH = ConnDatabaseUtil.SelectDBF("select * from 井号 where 实际井号 = '" + drLtjhs["jh"] + "'");
                                        DataTable dtSMSJH = cdu.SelectDatabase("select * from dyjh where sjjh = '" + drLtjhs["jh"] + "'");
                                        if (dtSMSJH.Rows.Count > 0)
                                        {
                                            WellModel jhs = ld.GetSingleLocation(dtSMSJH.Rows[0]["smjh"].ToString(), Convert.ToInt32(dr["k"]));
                                            GetLTOilJH(jhs, strDate, drLtjhs["jh"].ToString());
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                GC.Collect();
            }


            try
            {
                ConnDatabaseUtil cdu = new ConnDatabaseUtil();

                string strTableName = "T_WELL_ENDFACTOR";

                string    strSQL  = "select count(*) as count from user_tables where table_name = '" + strTableName.ToUpper() + "'";
                DataTable dtExist = cdu.SelectDatabase(strSQL);
                if (Convert.ToInt32(dtExist.Rows[0]["Count"]) > 0)
                {
                    strSQL = "drop table " + strTableName.ToUpper();
                    cdu.CreateOrDeleteDatabase(strSQL);
                }
                strSQL = "create table " + strTableName.ToUpper() + " (油井    VARCHAR2(16),  日期 VARCHAR2(6),  层位    NUMBER(2),  水井 VARCHAR2(16),  平均剩余储量  NUMBER(17, 10),  平均圧力 NUMBER(17, 10),  平均含油饱和度    NUMBER(17, 10))";
                cdu.CreateOrDeleteDatabase(strSQL);
                cdu.InsertDatabase(dtResult, strTableName.ToUpper());
            }
            catch (Exception)
            {
            }
        }