Ejemplo n.º 1
0
        ///未测试
        /// <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"]);
                    }
                }
            }
        }
        public void ShowHIImg(string strParentNodeText, string strNodeText)
        {
            ComputeHIDAL chid = new ComputeHIDAL();

            if (strParentNodeText.Equals("低效循环油井识别"))
            {
                if (strNodeText.Equals("一次筛选"))
                {
                    SlpfDAL slpf = new SlpfDAL();
                    slpf.GetSlpfData();
                    ComputeHIDAL.dtOilFirstFilterHI1.Clear();
                    ComputeHIDAL.dtOilFirstFilterHI2.Clear();
                    ComputeHIDAL.dtOilFirstFilterHI3.Clear();
                    ComputeHIDAL.dtOilFirstFilterHI4.Clear();
                    ComputeHIDAL.dtOilFirstFilterHI5.Clear();
                    ComputeHIDAL.dtOilFirstFilterHI6.Clear();
                    ComputeHIDAL.dtOilFirstFilterHI7.Clear();
                    ComputeHIDAL.dtOilFirstFilterHI8.Clear();
                    ComputeHIDAL.dtOilHI.Clear();
                    chid.ComputeOilHIMethod();
                }
                else if (strNodeText.Equals("二次筛选"))
                {
                    ComputeHIDAL.dtOilSecondFilterHI1.Clear();
                    ComputeHIDAL.dtOilSecondFilterHI2.Clear();
                    ComputeHIDAL.dtOilSecondFilterHI3.Clear();
                    ComputeHIDAL.dtOilSecondFilterHI4.Clear();
                    chid.OilSecondFilterHIMethod();
                }
            }
            else if (strParentNodeText.Equals("低效循环水井识别"))
            {
                if (strNodeText.Equals("一次筛选"))
                {
                    ComputeHIDAL.dtWaterFirstFilterHI1.Clear();
                    ComputeHIDAL.dtWaterFirstFilterHI2.Clear();
                    ComputeHIDAL.dtWaterFirstFilterHI3.Clear();
                    ComputeHIDAL.dtWaterFirstFilterHI4.Clear();
                    ComputeHIDAL.dtWaterHI.Clear();
                    chid.ComputeWaterHIMethod();
                }
            }
        }
        public void ComputeOilHIMethod()
        {
            //FileStream fs = new FileStream(@"F:\研究生\油工数据\五厂项目\20161107\一次筛选.txt", FileMode.Append);
            //StreamWriter sw = new StreamWriter(fs);
            if (dtOilHI.Rows.Count == 0)
            {
                if (dtOilHI.Columns.Count == 0)
                {
                    dtOilHI.Columns.Add("JH", System.Type.GetType("System.String"));
                    dtOilHI.Columns.Add("RCYLHI", System.Type.GetType("System.Double"));
                    dtOilHI.Columns.Add("RCSLHI", System.Type.GetType("System.Double"));
                    dtOilHI.Columns.Add("SLPFHI", System.Type.GetType("System.Double"));
                }


                ConnDatabaseUtil cdu = new ConnDatabaseUtil();

                string strSQL = string.Empty;

                double dblTotalRcylHI = 0, dblTotalRcslHI = 0, dblTotalSlpfHI = 0;
                double dblSlpfMax = 0, dblSlpfMin = 0;
                strSQL = "select jh, ny, rcsl, rcyl from dba04 where ny between '" + MainForm.strStartDate + "' and '" + MainForm.strEndDate + "' order by jh asc, ny asc"; // 在油井库里将油井按井号 年月排序
                DataTable dtDBA04 = cdu.SelectVFP(strSQL);
                //DataTable dtDBA04 = cdu.SelectDatabase(strSQL);
                DataTable dtDBA04JH = dtDBA04.DefaultView.ToTable(true, "JH");
                for (int i = 0; i < dtDBA04JH.Rows.Count; i++)
                {
                    DataRow[] rows = dtDBA04.Select("JH = '" + dtDBA04JH.Rows[i]["JH"] + "'");
                    if (rows.Count() > 0)
                    {
                        double dblRcylMax = GroupFunction(dtDBA04, "MAX", "RCYL", "JH = '" + dtDBA04JH.Rows[i]["JH"] + "'");
                        double dblRcylMin = GroupFunction(dtDBA04, "MIN", "RCYL", "JH = '" + dtDBA04JH.Rows[i]["JH"] + "'");
                        double dblRcslMax = GroupFunction(dtDBA04, "MAX", "RCSL", "JH = '" + dtDBA04JH.Rows[i]["JH"] + "'");
                        double dblRcslMin = GroupFunction(dtDBA04, "MIN", "RCSL", "JH = '" + dtDBA04JH.Rows[i]["JH"] + "'");
                        if (SlpfDAL.dtSLPF.Rows.Count > 0)
                        {
                            DataRow[] dr = SlpfDAL.dtSLPF.Select("JH = '" + dtDBA04JH.Rows[i]["JH"] + "' AND NY >= '" + MainForm.strStartDate + "' AND NY <= '" + MainForm.strEndDate + "'");
                            if (dr.Count() > 0)
                            {
                                dblSlpfMax = GroupFunction(SlpfDAL.dtSLPF, "MAX", "SLPF", "JH = '" + dtDBA04JH.Rows[i]["JH"] + "' AND NY >= '" + MainForm.strStartDate + "' AND NY <= '" + MainForm.strEndDate + "'");
                                dblSlpfMin = GroupFunction(SlpfDAL.dtSLPF, "MIN", "SLPF", "JH = '" + dtDBA04JH.Rows[i]["JH"] + "' AND NY >= '" + MainForm.strStartDate + "' AND NY <= '" + MainForm.strEndDate + "'");
                            }
                            else
                            {
                                continue;
                            }
                        }
                        else
                        {
                            SlpfDAL slpf = new SlpfDAL();
                            ///前台创建提示 先计算水量劈分
                            slpf.GetSlpfData();
                        }



                        if (((dblRcylMax - dblRcylMin) != 0) && ((dblRcslMax - dblRcslMin) != 0) && ((dblSlpfMax - dblSlpfMin) != 0))
                        {
                            foreach (DataRow dr in rows)
                            {
                                DataRow[] drSlpf = SlpfDAL.dtSLPF.Select("JH = '" + dr["JH"] + "' AND NY = '" + dr["NY"] + "'");
                                if (drSlpf.Count() > 0)
                                {
                                    double dblRcylAvg = GroupFunction(dtDBA04, "AVG", "RCYL", "NY = '" + dr["NY"] + "'");
                                    double dblRcslAvg = GroupFunction(dtDBA04, "AVG", "RCSL", "NY = '" + dr["NY"] + "'");
                                    double dblSlpfAvg = GroupFunction(SlpfDAL.dtSLPF, "AVG", "SLPF", "NY = '" + dr["NY"] + "'");

                                    dblTotalRcylHI += (Convert.ToDouble(dr["RCYL"]) - dblRcylAvg) / (dblRcylMax - dblRcylMin);
                                    dblTotalRcslHI += (Convert.ToDouble(dr["RCSL"]) - dblRcslAvg) / (dblRcslMax - dblRcslMin);
                                    dblTotalSlpfHI += (Convert.ToDouble(drSlpf[0]["SLPF"]) - dblSlpfAvg) / (dblSlpfMax - dblSlpfMin);
                                }
                            }
                            DataRow drHI = dtOilHI.NewRow();
                            drHI["JH"]     = dtDBA04JH.Rows[i]["JH"];
                            drHI["RCYLHI"] = dblTotalRcylHI;
                            drHI["RCSLHI"] = dblTotalRcslHI;
                            drHI["SLPFHI"] = dblTotalSlpfHI;
                            dtOilHI.Rows.Add(drHI);

                            dblTotalRcylHI = 0;
                            dblTotalRcslHI = 0;
                            dblTotalSlpfHI = 0;
                        }
                    }
                }
            }
            DataRow[] drTemp = dtOilHI.Select("RCSLHI > 0 AND RCYLHI >0 AND SLPFHI > 0");
            if (drTemp.Count() > 0)
            {
                dtOilFirstFilterHI1 = drTemp.CopyToDataTable();
            }
            drTemp = dtOilHI.Select("RCSLHI > 0 AND RCYLHI >0 AND SLPFHI < 0");
            if (drTemp.Count() > 0)
            {
                dtOilFirstFilterHI2 = drTemp.CopyToDataTable();
            }
            drTemp = dtOilHI.Select("RCSLHI < 0 AND RCYLHI >0 AND SLPFHI > 0");
            if (drTemp.Count() > 0)
            {
                dtOilFirstFilterHI3 = drTemp.CopyToDataTable();
            }
            drTemp = dtOilHI.Select("RCSLHI < 0 AND RCYLHI >0 AND SLPFHI < 0");
            if (drTemp.Count() > 0)
            {
                dtOilFirstFilterHI4 = drTemp.CopyToDataTable();
            }
            drTemp = dtOilHI.Select("RCSLHI < 0 AND RCYLHI < 0 AND SLPFHI > 0");
            if (drTemp.Count() > 0)
            {
                dtOilFirstFilterHI5 = drTemp.CopyToDataTable();
            }
            drTemp = dtOilHI.Select("RCSLHI < 0 AND RCYLHI <0 AND SLPFHI < 0");
            if (drTemp.Count() > 0)
            {
                dtOilFirstFilterHI6 = drTemp.CopyToDataTable();
            }
            drTemp = dtOilHI.Select("RCSLHI > 0 AND RCYLHI < 0 AND SLPFHI > 0");
            if (drTemp.Count() > 0)
            {
                dtOilFirstFilterHI7 = drTemp.CopyToDataTable();
                //foreach (DataRow dr in dtOilFirstFilterHI7.Rows)
                //{
                //    sw.WriteLine(dr["JH"] + " " + dr["RCSLHI"] + " " + dr["RCYLHI"] + " " + dr["SLPFHI"] + " ");
                //}
            }
            drTemp = dtOilHI.Select("RCSLHI > 0 AND RCYLHI <0 AND SLPFHI < 0");
            if (drTemp.Count() > 0)
            {
                dtOilFirstFilterHI8 = drTemp.CopyToDataTable();
            }
            //sw.Close();
            //fs.Close();
        }