Beispiel #1
0
        /// <summary>
        /// 相似查找的确定按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public override void btnSimilarSubmit_Click(object sender, EventArgs e)
        {
            if (this.similarListView.Items.Count <= 0)
            {
                return;
            }
            try
            {
                this.StartWaiting();
                this._similarSearchList = new List <OilSimilarSearchEntity>();
                #region "相似查找实体集合"
                OilDataSearchAccess oilDataSearchAccess = new OilDataSearchAccess();
                foreach (ListViewItem item in this.similarListView.Items)
                {
                    OilSimilarSearchEntity similarSearch = new OilSimilarSearchEntity();
                    similarSearch.ItemCode         = item.Tag.ToString();
                    similarSearch.LeftParenthesis  = item.SubItems[0].Tag.ToString();
                    similarSearch.OilTableColID    = Convert.ToInt32(item.SubItems[1].Tag.ToString());
                    similarSearch.OilTableRowID    = Convert.ToInt32(item.SubItems[3].Tag.ToString());
                    similarSearch.Fvalue           = Convert.ToSingle(item.SubItems[5].Tag.ToString());
                    similarSearch.Weight           = Convert.ToSingle(item.SubItems[7].Tag.ToString());
                    similarSearch.RightParenthesis = item.SubItems[8].Tag.ToString();
                    similarSearch.FracitonName     = item.SubItems[1].Text;
                    similarSearch.ItemName         = item.SubItems[3].Text;


                    string sqlWhere = "oilTableRowID='" + similarSearch.OilTableRowID.ToString() + "'" + " and oilTableColId='" + similarSearch.OilTableColID + "'" + " and calData!=''";
                    List <OilDataSearchEntity> oilDataSearchEntityList = oilDataSearchAccess.Get(sqlWhere);//获取对应物性的校正值

                    float?MaxValue = float.MinValue, MinValue = float.MaxValue;
                    if (oilDataSearchEntityList.Count > 0)
                    {
                        MaxValue = oilDataSearchEntityList.Max(o => o.fCal);
                        MinValue = oilDataSearchEntityList.Min(o => o.fCal);

                        MaxValue = MaxValue > similarSearch.Fvalue ? MaxValue : similarSearch.Fvalue; //如果最大值比基础值要小,则最大值取基础值
                        MinValue = MinValue < similarSearch.Fvalue ? MinValue : similarSearch.Fvalue; //如果最小值比基础值要大,则最小值取基础值
                    }

                    if (!MaxValue.Equals(float.MinValue) && !MinValue.Equals(float.MaxValue) && MaxValue != null && MinValue != null)
                    {
                        similarSearch.Diff = MaxValue.Value - MinValue.Value;
                    }
                    else
                    {
                        similarSearch.Diff = 0;
                    }

                    if (this.similarListView.Items.Count == 1)
                    {
                        similarSearch.IsAnd = true;
                    }
                    else
                    {
                        similarSearch.IsAnd = item.SubItems[9].Tag.ToString() == "And" ? true : false;
                    }
                    this._similarSearchList.Add(similarSearch);
                }
                #endregion

                #region "当前显示原油的集合"
                List <CrudeIndexIDAEntity> currentCrudeIndexIDList = new List <CrudeIndexIDAEntity>();
                foreach (DataGridViewRow row in this.gridList.Rows)
                {
                    CrudeIndexIDAEntity tempCrudeIndexIDAEntity = new CrudeIndexIDAEntity();
                    tempCrudeIndexIDAEntity.ID         = Convert.ToInt32(row.Cells["ID"].Value.ToString());
                    tempCrudeIndexIDAEntity.crudeIndex = row.Cells["原油编号"].Value.ToString();
                    tempCrudeIndexIDAEntity.crudeName  = row.Cells["原油名称"].Value.ToString();
                    currentCrudeIndexIDList.Add(tempCrudeIndexIDAEntity);
                }
                #endregion

                OilBll oilBll = new OilBll();

                IDictionary <string, double> CrudeIndexSumDic = oilBll.GetOilSimInfoCrudeIndex(this._similarSearchList); //从C库获取满足条件的原油编号

                GetSimSearchResult(CrudeIndexSumDic, currentCrudeIndexIDList);                                           //绑定控件
            }
            catch (Exception ex)
            {
                Log.Error("原油B库相似查找错误:" + ex.ToString());
                return;
            }
            finally
            {
                this.StopWaiting();
            }
        }