Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="tempListView">传递过来的显示条件</param>
        /// <param name="BelongToA"></param>
        /// <param name="BelongToB"></param>
        /// <param name="BelongToApp"></param>
        /// <param name="BelongsToRan"></param>
        /// <param name="BelongsToSim"></param>
        public void init(ListView tempListView, bool BelongToA, bool BelongToB, bool BelongToApp, bool BelongsToRan, bool BelongsToSim)
        {
            this._belongToA    = BelongToA;
            this._belongToApp  = BelongToApp;
            this._belongToB    = BelongToB;
            this._BelongsToRan = BelongsToRan;
            this._BelongsToSim = BelongsToSim;
            OilDataSearchRowAccess oilDataRowAccess = new OilDataSearchRowAccess();

            this._oilDataRowEntityList = oilDataRowAccess.Get("1=1");
            comRangeandSimilarBind();

            if (tempListView != null && tempListView.Items.Count > 0)
            {
                for (int i = 0; i < tempListView.Items.Count; i++)
                {
                    ListViewItem item = new ListViewItem();
                    for (int colIndex = 0; colIndex < this.listView1.Columns.Count; colIndex++)
                    {
                        ListViewItem.ListViewSubItem temp = new ListViewItem.ListViewSubItem();
                        temp.Name = tempListView.Columns[colIndex].Name;
                        item.SubItems.Add(temp);
                    }
                    //item.Tag = "true";//表示不能删除的项
                    item.SubItems[0].Text = tempListView.Items[i].SubItems[0].Text;
                    item.SubItems[1].Text = ":";
                    item.SubItems[2].Text = tempListView.Items[i].SubItems[2].Text;

                    item.SubItems[0].Tag = tempListView.Items[i].SubItems[0].Tag;
                    item.SubItems[2].Tag = tempListView.Items[i].SubItems[2].Tag;
                    this.listView1.Items.Add(item);
                }
            }

            #region ""
            //this._TemplistView = ListView;//传递过来的查询条件

            //if (ListView.Items.Count > 0)
            //{
            //    for (int i = 0; i < ListView.Items.Count; i++)
            //    {
            //        ListViewItem item = new ListViewItem();
            //        for (int colIndex = 0; colIndex < this.listView1.Columns.Count; colIndex++)
            //        {
            //            ListViewItem.ListViewSubItem temp = new ListViewItem.ListViewSubItem();
            //            temp.Name = ListView.Columns[colIndex].Name;
            //            item.SubItems.Add(temp);
            //        }
            //        item.Tag = "true";//表示不能删除的项
            //        item.SubItems[0].Text = ListView.Items[i].SubItems[1].Text;
            //        item.SubItems[1].Text = ":";
            //        item.SubItems[2].Text = ListView.Items[i].SubItems[3].Text;

            //        item.SubItems[0].Tag = ListView.Items[i].SubItems[1].Tag;
            //        item.SubItems[2].Tag = ListView.Items[i].SubItems[3].Tag;
            //        this.listView1.Items.Add(item);
            //    }
            //}
            #endregion
        }
Example #2
0
        /// <summary>
        /// 相似查找的信息表名称下拉菜单选择事件,目的是为了向物性下拉菜单中添加查找物性
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public override void cmbSimilarFraction_SelectedIndexChanged(object sender, EventArgs e)
        {
            /*根据cmbOilInfoselect从数据库中提取对应的下拉菜单数据*/
            OilDataSearchRowAccess        oilDataRowAccess     = new OilDataSearchRowAccess();
            List <OilDataSearchRowEntity> oilDataRowEntityList = oilDataRowAccess.Get("1=1");

            var selectedItem = (OilDataSearchColEntity)this.cmbSimilarFraction.SelectedItem;//确定当前菜单中的数据
            List <OilDataSearchRowEntity> cmb_OilDataRowList = oilDataRowEntityList.Where(o => o.OilDataColID == selectedItem.ID && o.BelongsToB == true).ToList();

            if (null != this.cmbSimilarItem.Items)
            {
                this.cmbSimilarItem.Items.Clear();              //将上一次所选择的内容清零
                this.cmbSimilarItem.DisplayMember = "ItemName"; //设置显示名称
                this.cmbSimilarItem.ValueMember   = "ItemCode"; //设置保存代码
            }
            int ColID = ((OilDataSearchColEntity)this.cmbSimilarFraction.SelectedItem).OilTableColID;

            if (cmb_OilDataRowList != null && 0 != cmb_OilDataRowList.Count)//存在返回的数据不为空
            {
                foreach (OilDataSearchRowEntity row in cmb_OilDataRowList)
                {
                    this.cmbSimilarItem.Items.Add(row.OilTableRow);
                }

                this.cmbSimilarItem.SelectedIndex   = 0;   //选择第一个选项
                this.txtSimilarFoundationValue.Text = "";  //将基础值置零
                this.txtSimilarWeight.Text          = "1"; //将权重值置一
            }
            selectOilData();
        }
Example #3
0
        /// <summary>
        /// cmbRangeFraction下拉菜单的变化显示
        ///范围查询馏分段的Combox的选择事件处理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public override void cmbRangeFraction_SelectedIndexChanged(object sender, EventArgs e)
        {
            /*根据cmbRangeFraction从数据库中提取对应的下拉菜单数据*/
            OilDataSearchRowAccess        oilDataRowAccess     = new OilDataSearchRowAccess();
            List <OilDataSearchRowEntity> oilDataRowEntityList = oilDataRowAccess.Get("1=1");

            var selectedItem = (OilDataSearchColEntity)this.cmbRangeFraction.SelectedItem;//确定当前菜单中的数据
            List <OilDataSearchRowEntity> cmb_OilDataRowList = oilDataRowEntityList.Where(o => o.OilDataColID == selectedItem.ID && o.BelongsToB == true).ToList();

            if ("原油信息".Equals(cmbRangeFraction.Text))
            {
                OilinfItemList oilinfItemList = new OilinfItemList();    //数据源

                OilinfItemList newOilinfItemList = new OilinfItemList(); //处理过的数据源
                newOilinfItemList.oilinfItems.Clear();

                if (cmb_OilDataRowList != null)        //存在返回的数据不为空
                {
                    if (0 != cmb_OilDataRowList.Count) //返回的数据不为空
                    {
                        for (int i = 0; i < cmb_OilDataRowList.Count; i++)
                        {
                            for (int j = 0; j < oilinfItemList.oilinfItems.Count; j++)
                            {
                                if (cmb_OilDataRowList[i].OilTableRow.itemCode == oilinfItemList.oilinfItems[j].itemCode)
                                {
                                    newOilinfItemList.oilinfItems.Add(oilinfItemList.oilinfItems[j]);
                                }
                            }
                        }
                    }
                }
                this.label4.Visible  = false;
                this.rangEnd.Visible = false;
                if (null != this.cmbRangeItem.Items)
                {
                    this.cmbRangeItem.Items.Clear();//将上一次所选择的内容清零
                    this.cmbRangeItem.DisplayMember = "itemName";
                    this.cmbRangeItem.ValueMember   = "fieldName";
                }
                for (int i = 0; i < newOilinfItemList.oilinfItems.Count; i++)
                {
                    this.cmbRangeItem.Items.Add(newOilinfItemList.oilinfItems[i]);
                }
                this.cmbRangeItem.SelectedIndex = 0;
            }
            else
            {
                if (null != this.cmbRangeItem.Items)
                {
                    this.cmbRangeItem.Items.Clear();              //将上一次所选择的内容清零
                    this.cmbRangeItem.DisplayMember = "ItemName"; //设置显示名称
                    this.cmbRangeItem.ValueMember   = "ItemCode"; //设置保存代码
                }
                this.label4.Visible  = true;
                this.rangEnd.Visible = true;
                //int ColID = ((OilDataColEntity)this.cmbOilInfoselect.SelectedItem).OilTableColID;
                if (cmb_OilDataRowList != null)        //存在返回的数据不为空
                {
                    if (0 != cmb_OilDataRowList.Count) //返回的数据不为空
                    {
                        for (int i = 0; i < cmb_OilDataRowList.Count; i++)
                        {
                            this.cmbRangeItem.Items.Add(cmb_OilDataRowList[i].OilTableRow);
                        }
                        this.cmbRangeItem.SelectedIndex = 0;  //选择第一个选项
                        this.rangStart.Text             = ""; //将范围空间置零
                        this.rangEnd.Text = "";
                    }
                }
            }
        }
Example #4
0
        /// <summary>
        /// 初始化表格格式
        /// </summary>
        private void initDataGridView()
        {
            OilDataSearchColAccess        oilDataColAccess = new OilDataSearchColAccess();
            List <OilDataSearchColEntity> OilDataCols      = oilDataColAccess.Get("1=1");

            OilDataSearchRowAccess        oilDataRowAccess = new OilDataSearchRowAccess();
            List <OilDataSearchRowEntity> OilDataRows      = oilDataRowAccess.Get("1=1");

            OilDataSearchAccess        oilDataSearchAccess = new OilDataSearchAccess();
            List <OilDataSearchEntity> allDatas            = oilDataSearchAccess.Get("oilInfoID = " + this._oilInfoID).ToList();

            #region "原油信息"
            //List<OilDataSearchColEntity> oilInfoCols = OilDataCols.Where(o =>o.OilTableName == "原油信息").ToList();
            //List<OilDataSearchRowEntity> oilInfoRows = OilDataRows.Where(o => o.OilDataColID == oilInfoCols[0].ID).ToList();

            //List<OilTableRowEntity> oilInfoTableRows = new List<OilTableRowEntity>();
            //for (int i = 0; i < oilInfoRows.Count; i++)
            //{
            //    OilTableRowEntity oilTableRow = OilTableRowBll._OilTableRow.Where(o => o.ID == oilInfoRows[i].OilTableRowID).FirstOrDefault();
            //    oilInfoTableRows.Add(oilTableRow);
            //}

            //#region "做列字典和行字典"
            ////Dictionary<int, OilDataSearchColEntity> colDic = new Dictionary<int, OilDataSearchColEntity>();//判断有多少列
            ////foreach (var temp in oilInfoCols)
            ////{
            ////    if (!colDic.Keys.Contains(temp.OilTableColID))
            ////    {
            ////        colDic.Add(temp.OilTableColID, temp);
            ////    }
            ////}

            //Dictionary<string, int> rowIDDic = new Dictionary<string, int>();//表的行和oiltableRowID对应
            //int rowID = 0;//设置行ID=0
            //foreach (var temp in oilInfoTableRows)
            //{
            //    if (!rowIDDic.Keys.Contains(temp.itemCode))
            //    {
            //        rowIDDic.Add(temp.itemCode, rowID);
            //        rowID++;
            //    }
            //}
            //#endregion

            //#region "初列:序号,项目,代码"
            //this.dataGridView1.Columns.Clear();

            //DataGridViewTextBoxColumn colID = new DataGridViewTextBoxColumn()
            //{
            //    Name = "序号",
            //    AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells,
            //    ReadOnly = true
            //};
            //DataGridViewTextBoxColumn Code = new DataGridViewTextBoxColumn()
            //{
            //    Name = "itemCode",
            //    AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells,
            //    ReadOnly = true
            //};
            //DataGridViewTextBoxColumn Name = new DataGridViewTextBoxColumn()
            //{
            //    Name = "itemName",
            //    AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells,
            //    ReadOnly = true
            //};

            //this.dataGridView1.Columns.Add(colID);
            //this.dataGridView1.Columns.Add(Code);
            //this.dataGridView1.Columns.Add(Name);

            //foreach (var temp in oilInfoCols)
            //{
            //    DataGridViewTextBoxColumn column = new DataGridViewTextBoxColumn
            //    {
            //        HeaderText = temp.OilTableName,
            //        Name = temp.OilTableName,
            //        AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells,
            //        Width = 200,
            //        Tag = temp.OilTableColID
            //    };
            //    this.dataGridView1.Columns.Add(column);
            //}
            //#endregion

            //#region "初始化所有行"
            //this.dataGridView1.Rows.Clear();
            //int col = 0;
            //foreach (OilTableRowEntity temp in oilInfoTableRows)
            //{
            //    int index = this.dataGridView1.Rows.Add();
            //    this.dataGridView1.Rows[index].Cells["序号"].Value = col;
            //    this.dataGridView1.Rows[index].Cells["itemCode"].Value = temp.itemCode;
            //    this.dataGridView1.Rows[index].Cells["itemName"].Value = temp.itemName;
            //    this.dataGridView1.Rows[index].Tag = temp.ID;
            //    col++;
            //}
            //#endregion

            //this.dataGridView1.Rows[rowIDDic["CNA"]].Cells[oilInfoCols[0].OilTableName].Value = oilInfoB.crudeName;
            //this.dataGridView1.Rows[rowIDDic["ENA"]].Cells[oilInfoCols[0].OilTableName].Value = oilInfoB.englishName;
            //this.dataGridView1.Rows[rowIDDic["IDC"]].Cells[oilInfoCols[0].OilTableName].Value = oilInfoB.crudeIndex;
            //this.dataGridView1.Rows[rowIDDic["COU"]].Cells[oilInfoCols[0].OilTableName].Value = oilInfoB.country;
            //this.dataGridView1.Rows[rowIDDic["GRC"]].Cells[oilInfoCols[0].OilTableName].Value = oilInfoB.region;
            //this.dataGridView1.Rows[rowIDDic["ADA"]].Cells[oilInfoCols[0].OilTableName].Value = oilInfoB.receiveDate;
            //this.dataGridView1.Rows[rowIDDic["ALA"]].Cells[oilInfoCols[0].OilTableName].Value = oilInfoB.assayLab;

            //this.dataGridView1.Rows[rowIDDic["AER"]].Cells[oilInfoCols[0].OilTableName].Value = oilInfoB.assayer;
            //this.dataGridView1.Rows[rowIDDic["SR"]].Cells[oilInfoCols[0].OilTableName].Value = oilInfoB.sourceRef;
            //this.dataGridView1.Rows[rowIDDic["ASC"]].Cells[oilInfoCols[0].OilTableName].Value = oilInfoB.assayCustomer;
            //this.dataGridView1.Rows[rowIDDic["RIN"]].Cells[oilInfoCols[0].OilTableName].Value = oilInfoB.reportIndex;
            //this.dataGridView1.Rows[rowIDDic["CLA"]].Cells[oilInfoCols[0].OilTableName].Value = oilInfoB.type;
            //this.dataGridView1.Rows[rowIDDic["TYP"]].Cells[oilInfoCols[0].OilTableName].Value = oilInfoB.classification;
            //this.dataGridView1.Rows[rowIDDic["SCL"]].Cells[oilInfoCols[0].OilTableName].Value = oilInfoB.sulfurLevel;
            //InitStyle(this.dataGridView1);
            #endregion

            InitDataGridView("原油信息", this.dataGridView1, OilDataCols, OilDataRows, allDatas);
            InitDataGridView("原油性质", this.dataGridView2, OilDataCols, OilDataRows, allDatas);
            InitDataGridView("石脑油", this.dataGridView3, OilDataCols, OilDataRows, allDatas);
            InitDataGridView("航煤", this.dataGridView4, OilDataCols, OilDataRows, allDatas);
            InitDataGridView("柴油", this.dataGridView5, OilDataCols, OilDataRows, allDatas);
            InitDataGridView("VGO", this.dataGridView6, OilDataCols, OilDataRows, allDatas);
            InitDataGridView("渣", this.dataGridView7, OilDataCols, OilDataRows, allDatas);
        }
Example #5
0
        /// <summary>
        /// cmbRangeFraction下拉菜单的变化显示
        ///范围查询馏分段的Combox的选择事件处理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public override void cmbRangeFraction_SelectedIndexChanged(object sender, EventArgs e)
        {
            /*根据cmbRangeFraction从数据库中提取对应的下拉菜单数据*/
            //if (this.cmbRangeFraction.Created)
            //{
            OilDataSearchRowAccess        oilDataRowAccess     = new OilDataSearchRowAccess();
            List <OilDataSearchRowEntity> oilDataRowEntityList = oilDataRowAccess.Get("1=1");

            var selectedItem = (OilDataSearchColEntity)this.cmbRangeFraction.SelectedItem;    //确定馏分段的菜单中的数据
            List <OilDataSearchRowEntity> cmbRangeItemList = oilDataRowEntityList.Where(o => o.OilDataColID == selectedItem.ID && o.BelongsToA == true).OrderBy(o => o.OilTableRow.itemOrder).ToList();

            //InitCol(selectedItem, cmb_OilDataRowList);

            if ("原油信息".Equals(cmbRangeFraction.Text))
            {
                #region "原油信息的性质空间的绑定"
                OilinfItemList oilinfItemList    = new OilinfItemList(); //数据源
                OilinfItemList newOilinfItemList = new OilinfItemList(); //处理过的数据源
                newOilinfItemList.oilinfItems.Clear();

                if (cmbRangeItemList != null && 0 != cmbRangeItemList.Count)    //存在返回的数据不为空
                {
                    foreach (OilDataSearchRowEntity row in cmbRangeItemList)
                    {
                        OilinfItem tempOilinfItem = oilinfItemList.oilinfItems.Where(o => o.itemCode == row.OilTableRow.itemCode).FirstOrDefault();
                        if (tempOilinfItem == null)
                        {
                            continue;
                        }

                        newOilinfItemList.oilinfItems.Add(tempOilinfItem);
                    }
                }
                this.label4.Visible  = false;
                this.rangEnd.Visible = false;

                #region "范围查询物性数据绑定"
                if (null != this.cmbRangeItem.Items)
                {
                    this.cmbRangeItem.Items.Clear();    //将上一次所选择的内容清零
                }
                this.cmbRangeItem.DisplayMember = "itemName";
                this.cmbRangeItem.ValueMember   = "fieldName";
                foreach (OilinfItem item in newOilinfItemList.oilinfItems)
                {
                    this.cmbRangeItem.Items.Add(item);
                }

                this.cmbRangeItem.SelectedIndex = 0;
                this.rangEnd.Clear();
                this.rangStart.Clear();
                #endregion

                #endregion
            }
            else if (!"原油信息".Equals(cmbRangeFraction.Text))
            {
                #region  "性质控件的绑定"
                if (null != this.cmbRangeItem.Items)
                {
                    this.cmbRangeItem.Items.Clear();          //将上一次所选择的内容清零
                }
                this.cmbRangeItem.DisplayMember = "ItemName"; //设置显示名称
                this.cmbRangeItem.ValueMember   = "ItemCode"; //设置保存代码
                this.label4.Visible             = true;
                this.rangEnd.Visible            = true;
                if (cmbRangeItemList != null && 0 != cmbRangeItemList.Count)    //存在返回的数据不为空
                {
                    foreach (OilDataSearchRowEntity row in cmbRangeItemList)
                    {
                        this.cmbRangeItem.Items.Add(row.OilTableRow);
                    }

                    this.cmbRangeItem.SelectedIndex = 0;  //选择第一个选项
                    this.rangStart.Text             = ""; //将范围空间置空
                    this.rangEnd.Text = "";               //将范围空间置空
                }

                #endregion
            }
            // }
        }
Example #6
0
        /// <summary>
        /// 接口方式三
        /// </summary>
        /// <param name="oilPropertyAPIEntity">定制的获取性质</param>
        /// <param name="cutMotheds">定制切割方案</param>
        /// <returns>原油数据</returns>
        public OilInfoBEntity GetCutResultAPI(OilPropertyAPIEntity oilPropertyAPIEntity, List <CutMothedAPIEntity> cutMotheds)
        {
            List <CutMothedEntity> cutMothedList = new List <CutMothedEntity>();

            for (int index = 0; index < cutMotheds.Count; index++)
            {
                CutMothedEntity cutMothed = new CutMothedEntity();
                cutMothed.ICP  = cutMotheds[index].ICP;
                cutMothed.ECP  = cutMotheds[index].ECP;
                cutMothed.Name = cutMotheds[index].Name.GetDescription();
                cutMothedList.Add(cutMothed);
            }
            OilDataSearchColAccess        oilDataColAccess = new OilDataSearchColAccess();
            List <OilDataSearchColEntity> OilDataCols      = oilDataColAccess.Get("1=1");
            OilDataSearchRowAccess        oilDataRowAccess = new OilDataSearchRowAccess();
            List <OilDataSearchRowEntity> OilDataRows      = oilDataRowAccess.Get("1=1");

            IList <OilSimilarSearchEntity> oilSimilarSearchList = new List <OilSimilarSearchEntity>();
            OilDataSearchColEntity         wholeCol             = OilDataCols.Where(o => o.OilTableName.Contains("原油性质")).FirstOrDefault();

            if (wholeCol != null)
            {
                #region "原油性质"
                OilDataSearchRowEntity D20SearchRow = OilDataRows.Where(o => o.OilTableRow.itemCode == "D20" && o.OilDataColID == wholeCol.ID).FirstOrDefault();
                OilDataSearchRowEntity WAXSearchRow = OilDataRows.Where(o => o.OilTableRow.itemCode == "WAX" && o.OilDataColID == wholeCol.ID).FirstOrDefault();
                OilDataSearchRowEntity SULSearchRow = OilDataRows.Where(o => o.OilTableRow.itemCode == "SUL" && o.OilDataColID == wholeCol.ID).FirstOrDefault();
                OilDataSearchRowEntity N2SearchRow  = OilDataRows.Where(o => o.OilTableRow.itemCode == "N2" && o.OilDataColID == wholeCol.ID).FirstOrDefault();
                OilDataSearchRowEntity CCRSearchRow = OilDataRows.Where(o => o.OilTableRow.itemCode == "CCR" && o.OilDataColID == wholeCol.ID).FirstOrDefault();

                if (D20SearchRow != null && !oilPropertyAPIEntity.D20.Equals(float.NaN))
                {
                    OilSimilarSearchEntity D20OilSimilarSearch = new OilSimilarSearchEntity();
                    oilSimilarSearchList.Add(D20OilSimilarSearch);
                    D20OilSimilarSearch.Fvalue        = oilPropertyAPIEntity.D20;
                    D20OilSimilarSearch.Weight        = 10;
                    D20OilSimilarSearch.ItemCode      = "D20";
                    D20OilSimilarSearch.OilTableColID = wholeCol.OilTableColID;
                    D20OilSimilarSearch.OilTableRowID = D20SearchRow.OilTableRowID;
                }

                if (WAXSearchRow != null && !oilPropertyAPIEntity.WAX.Equals(float.NaN))
                {
                    OilSimilarSearchEntity WAXOilSimilarSearch = new OilSimilarSearchEntity();
                    oilSimilarSearchList.Add(WAXOilSimilarSearch);
                    WAXOilSimilarSearch.Fvalue        = oilPropertyAPIEntity.WAX;
                    WAXOilSimilarSearch.Weight        = 1;
                    WAXOilSimilarSearch.ItemCode      = "WAX";
                    WAXOilSimilarSearch.OilTableColID = wholeCol.OilTableColID;
                    WAXOilSimilarSearch.OilTableRowID = WAXSearchRow.OilTableRowID;
                }

                if (SULSearchRow != null && !oilPropertyAPIEntity.SUL.Equals(float.NaN))
                {
                    OilSimilarSearchEntity SULOilSimilarSearch = new OilSimilarSearchEntity();
                    oilSimilarSearchList.Add(SULOilSimilarSearch);
                    SULOilSimilarSearch.Fvalue        = oilPropertyAPIEntity.SUL;
                    SULOilSimilarSearch.Weight        = 1;
                    SULOilSimilarSearch.ItemCode      = "SUL";
                    SULOilSimilarSearch.OilTableColID = wholeCol.OilTableColID;
                    SULOilSimilarSearch.OilTableRowID = SULSearchRow.OilTableRowID;
                }

                if (N2SearchRow != null && !oilPropertyAPIEntity.N2.Equals(float.NaN))
                {
                    OilSimilarSearchEntity N2OilSimilarSearch = new OilSimilarSearchEntity();
                    oilSimilarSearchList.Add(N2OilSimilarSearch);
                    N2OilSimilarSearch.Fvalue        = oilPropertyAPIEntity.N2;
                    N2OilSimilarSearch.Weight        = 1;
                    N2OilSimilarSearch.ItemCode      = "N2";
                    N2OilSimilarSearch.OilTableColID = wholeCol.OilTableColID;
                    N2OilSimilarSearch.OilTableRowID = N2SearchRow.OilTableRowID;
                }

                if (CCRSearchRow != null && !oilPropertyAPIEntity.CCR.Equals(float.NaN))
                {
                    OilSimilarSearchEntity CCROilSimilarSearch = new OilSimilarSearchEntity();
                    oilSimilarSearchList.Add(CCROilSimilarSearch);
                    CCROilSimilarSearch.Fvalue        = oilPropertyAPIEntity.CCR;
                    CCROilSimilarSearch.Weight        = 1;
                    CCROilSimilarSearch.ItemCode      = "CCR";
                    CCROilSimilarSearch.OilTableColID = wholeCol.OilTableColID;
                    CCROilSimilarSearch.OilTableRowID = CCRSearchRow.OilTableRowID;
                }
                #endregion
            }

            OilDataSearchColEntity Col15_140  = OilDataCols.Where(o => o.ICP == 15 && o.ECP == 140).FirstOrDefault();
            OilDataSearchColEntity Col15_180  = OilDataCols.Where(o => o.ICP == 15 && o.ECP == 180).FirstOrDefault();
            OilDataSearchColEntity Col140_240 = OilDataCols.Where(o => o.ICP == 140 && o.ECP == 240).FirstOrDefault();
            OilDataSearchColEntity Col240_350 = OilDataCols.Where(o => o.ICP == 240 && o.ECP == 350).FirstOrDefault();
            #region "TWY"
            if (Col15_140 != null)
            {
                OilDataSearchRowEntity DSearchRow15_140 = OilDataRows.Where(o => o.OilTableRow.itemCode == "TWY" && o.OilDataColID == Col15_140.ID).FirstOrDefault();
                if (DSearchRow15_140 != null && !oilPropertyAPIEntity.TWY140.Equals(float.NaN))
                {
                    OilSimilarSearchEntity TWY15_140OilSimilarSearch = new OilSimilarSearchEntity();
                    oilSimilarSearchList.Add(TWY15_140OilSimilarSearch);
                    TWY15_140OilSimilarSearch.Fvalue        = oilPropertyAPIEntity.TWY140;
                    TWY15_140OilSimilarSearch.Weight        = 1;
                    TWY15_140OilSimilarSearch.ItemCode      = "TWY15_140";
                    TWY15_140OilSimilarSearch.OilTableColID = Col15_140.OilTableColID;
                    TWY15_140OilSimilarSearch.OilTableRowID = DSearchRow15_140.OilTableRowID;
                }
            }

            if (Col15_180 != null)
            {
                OilDataSearchRowEntity DSearchRow15_180 = OilDataRows.Where(o => o.OilTableRow.itemCode == "TWY" && o.OilDataColID == Col15_180.ID).FirstOrDefault();
                if (DSearchRow15_180 != null && !oilPropertyAPIEntity.TWY180.Equals(float.NaN))
                {
                    OilSimilarSearchEntity TWY15_180OilSimilarSearch = new OilSimilarSearchEntity();
                    oilSimilarSearchList.Add(TWY15_180OilSimilarSearch);
                    TWY15_180OilSimilarSearch.Fvalue        = oilPropertyAPIEntity.TWY180;
                    TWY15_180OilSimilarSearch.Weight        = 1;
                    TWY15_180OilSimilarSearch.ItemCode      = "TWY15_180";
                    TWY15_180OilSimilarSearch.OilTableColID = Col15_180.OilTableColID;
                    TWY15_180OilSimilarSearch.OilTableRowID = DSearchRow15_180.OilTableRowID;
                }
            }

            if (Col140_240 != null)
            {
                OilDataSearchRowEntity DSearchRow140_240 = OilDataRows.Where(o => o.OilTableRow.itemCode == "TWY" && o.OilDataColID == Col140_240.ID).FirstOrDefault();
                if (DSearchRow140_240 != null && !oilPropertyAPIEntity.TWY240.Equals(float.NaN))
                {
                    OilSimilarSearchEntity TWY140_240OilSimilarSearch = new OilSimilarSearchEntity();
                    oilSimilarSearchList.Add(TWY140_240OilSimilarSearch);
                    TWY140_240OilSimilarSearch.Fvalue        = oilPropertyAPIEntity.TWY240;
                    TWY140_240OilSimilarSearch.Weight        = 1;
                    TWY140_240OilSimilarSearch.ItemCode      = "TWY140_240";
                    TWY140_240OilSimilarSearch.OilTableColID = Col140_240.OilTableColID;
                    TWY140_240OilSimilarSearch.OilTableRowID = DSearchRow140_240.OilTableRowID;
                }
            }

            if (Col240_350 != null)
            {
                OilDataSearchRowEntity DSearchRow240_350 = OilDataRows.Where(o => o.OilTableRow.itemCode == "TWY" && o.OilDataColID == Col240_350.ID).FirstOrDefault();
                if (DSearchRow240_350 != null && !oilPropertyAPIEntity.TWY350.Equals(float.NaN))
                {
                    OilSimilarSearchEntity TWY240_350OilSimilarSearch = new OilSimilarSearchEntity();
                    oilSimilarSearchList.Add(TWY240_350OilSimilarSearch);
                    TWY240_350OilSimilarSearch.Fvalue        = oilPropertyAPIEntity.TWY350;
                    TWY240_350OilSimilarSearch.Weight        = 1;
                    TWY240_350OilSimilarSearch.ItemCode      = "TWY240_350";
                    TWY240_350OilSimilarSearch.OilTableColID = Col240_350.OilTableColID;
                    TWY240_350OilSimilarSearch.OilTableRowID = DSearchRow240_350.OilTableRowID;
                }
            }
            #endregion

            OilApplyBll    oilApplyBll = new OilApplyBll();
            OilInfoBEntity oilB        = oilApplyBll.GetCutResult(oilSimilarSearchList, cutMothedList);
            List <OilDataTableBAPIEntity> OilDataTableBAPIEntityList = new List <OilDataTableBAPIEntity>();

            if (oilB != null)
            {
                if (oilB.CutDataEntityList != null)
                {
                    #region "数据格式转换"
                    foreach (CutDataEntity cutData in oilB.CutDataEntityList)
                    {
                        string strCal = cutData.CutData != null?cutData.CutData.ToString() : string.Empty;

                        float fData = 0;

                        if (strCal != string.Empty && float.TryParse(strCal, out fData))
                        {
                            OilDataTableBAPIEntity oilDataTable = new OilDataTableBAPIEntity();
                            OilDataTableBAPIEntityList.Add(oilDataTable);
                            oilDataTable.CalData  = fData;
                            oilDataTable.ItemCode = cutData.YItemCode;
                            #region "CutTableName"
                            CutTableName cutName = CutTableName.ChaiYou;
                            string       strName = cutData.CutName;
                            if (strName == CutTableName.ChaiYou.GetDescription())
                            {
                                cutName = CutTableName.ChaiYou;
                            }
                            else if (strName == CutTableName.LaYou.GetDescription())
                            {
                                cutName = CutTableName.LaYou;
                            }
                            else if (strName == CutTableName.MeiYou.GetDescription())
                            {
                                cutName = CutTableName.MeiYou;
                            }
                            else if (strName == CutTableName.ShiNaoYou.GetDescription())
                            {
                                cutName = CutTableName.ShiNaoYou;
                            }
                            else if (strName == CutTableName.YuanYouXingZhi.GetDescription())
                            {
                                cutName = CutTableName.YuanYouXingZhi;
                            }
                            else if (strName == CutTableName.ZhaYou.GetDescription())
                            {
                                cutName = CutTableName.ZhaYou;
                            }
                            #endregion
                            oilDataTable.cutTableName = cutName;
                        }
                    }
                    #endregion
                }
                oilB.OilDataTableBAPIEntityList = OilDataTableBAPIEntityList;
            }
            return(oilB);
        }
Example #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cutDataList"></param>
        /// <returns></returns>
        private List <OilDataSearchEntity> findOilDataSearch(List <CutDataEntity> cutDataList)
        {
            List <OilDataSearchEntity> dataSearchList = new List <OilDataSearchEntity>();//需要返回的查找数据

            OilDataSearchRowAccess        dataSearchRowAccess = new OilDataSearchRowAccess();
            List <OilDataSearchRowEntity> dataSearchRows      = dataSearchRowAccess.Get("1=1").ToList();
            OilDataSearchColAccess        dataSearchColAccess = new OilDataSearchColAccess();
            List <OilDataSearchColEntity> dataSearchCols      = dataSearchColAccess.Get("1=1").ToList();

            #region "原油信息表的查找数据"
            List <OilDataSearchColEntity> infoDataSearchCols = dataSearchCols.Where(o => o.OilTableName == "原油信息").ToList();
            int infoOilTalbeColID = infoDataSearchCols[0].OilTableColID;
            List <OilDataSearchRowEntity> oilDataRowEntityList = dataSearchRows.Where(o => o.OilTableRow.oilTableTypeID == (int)EnumTableType.Info).ToList();

            foreach (OilDataSearchRowEntity e in oilDataRowEntityList)
            {
                OilDataSearchEntity wholeDataSearch = new OilDataSearchEntity();
                dataSearchList.Add(wholeDataSearch);
                wholeDataSearch.oilInfoID     = this._oilB.ID;
                wholeDataSearch.oilTableColID = infoOilTalbeColID;
                wholeDataSearch.oilTableRowID = e.OilTableRowID;
                #region
                if (e.OilTableRow.itemCode == "CNA")
                {
                    wholeDataSearch.calData = this._oilB.crudeName;
                }
                else if (e.OilTableRow.itemCode == "ENA")
                {
                    wholeDataSearch.calData = this._oilB.englishName;
                }
                else if (e.OilTableRow.itemCode == "IDC")
                {
                    wholeDataSearch.calData = this._oilB.crudeIndex;
                }
                else if (e.OilTableRow.itemCode == "COU")
                {
                    wholeDataSearch.calData = this._oilB.country;
                }
                else if (e.OilTableRow.itemCode == "GRC")
                {
                    wholeDataSearch.calData = this._oilB.region;
                }
                else if (e.OilTableRow.itemCode == "ADA")
                {
                    wholeDataSearch.calData = this._oilB.receiveDate != null?this._oilB.receiveDate.ToString() : string.Empty;
                }
                else if (e.OilTableRow.itemCode == "ALA")
                {
                    wholeDataSearch.calData = this._oilB.assayLab;
                }
                #endregion

                #region
                if (e.OilTableRow.itemCode == "AER")
                {
                    wholeDataSearch.calData = this._oilB.assayer;
                }
                else if (e.OilTableRow.itemCode == "SR")
                {
                    wholeDataSearch.calData = this._oilB.sourceRef;
                }
                else if (e.OilTableRow.itemCode == "ASC")
                {
                    wholeDataSearch.calData = this._oilB.assayCustomer;
                }
                else if (e.OilTableRow.itemCode == "RIN")
                {
                    wholeDataSearch.calData = this._oilB.reportIndex;
                }
                else if (e.OilTableRow.itemCode == "CLA")
                {
                    wholeDataSearch.calData = this._oilB.type;
                }
                else if (e.OilTableRow.itemCode == "TYP")
                {
                    wholeDataSearch.calData = this._oilB.classification;
                }
                else if (e.OilTableRow.itemCode == "SCL")
                {
                    wholeDataSearch.calData = this._oilB.sulfurLevel;
                }
                #endregion
            }
            #endregion

            #region "原油性质表的查找数据"
            OilDataSearchColEntity        wholeSearchCol = dataSearchCols.Where(o => o.OilTableName == "原油性质").FirstOrDefault();
            List <OilDataSearchRowEntity> wholeRowList   = wholeSearchCol.OilDataRowList;
            for (int wholeIndex = 0; wholeIndex < wholeRowList.Count; wholeIndex++)
            {
                OilDataBEntity wholeData = this._oilB.OilDatas.Where(o => o.oilTableRowID == wholeRowList[wholeIndex].OilTableRowID).FirstOrDefault();

                if (wholeData != null)
                {
                    OilDataSearchEntity wholeDataSearch = new OilDataSearchEntity();
                    dataSearchList.Add(wholeDataSearch);
                    wholeDataSearch.oilInfoID     = this._oilB.ID;
                    wholeDataSearch.oilTableColID = wholeSearchCol.OilTableColID;
                    wholeDataSearch.oilTableRowID = wholeRowList[wholeIndex].OilTableRowID;
                    wholeDataSearch.calData       = wholeData.calData;
                }
            }
            #endregion

            #region "宽馏分表和渣油表"
            for (int cutIndex = 0; cutIndex < this._cutMothedEntityList.Count; cutIndex++)
            {
                OilDataSearchColEntity        dataSearchCol      = dataSearchCols.Where(o => o.OilTableName == this._cutMothedEntityList[cutIndex].Name).FirstOrDefault();
                List <OilDataSearchRowEntity> wideDataSearchRows = dataSearchCol.OilDataRowList;

                for (int rowIndex = 0; rowIndex < wideDataSearchRows.Count; rowIndex++)
                {
                    CutDataEntity cutData = cutDataList.Where(o => o.CutName == this._cutMothedEntityList[cutIndex].Name && o.YItemCode == wideDataSearchRows[rowIndex].OilTableRow.itemCode).FirstOrDefault();

                    if (cutData != null && cutData.CutData != null)
                    {
                        OilDataSearchEntity wholeDataSearch = new OilDataSearchEntity();
                        dataSearchList.Add(wholeDataSearch);
                        wholeDataSearch.oilInfoID     = this._oilB.ID;
                        wholeDataSearch.oilTableColID = dataSearchCol.OilTableColID;
                        wholeDataSearch.oilTableRowID = wideDataSearchRows[rowIndex].OilTableRowID;
                        wholeDataSearch.calData       = cutData.CutData.ToString();
                    }
                }
            }
            #endregion

            return(dataSearchList);
        }
Example #8
0
        /// <summary>
        /// 找出A库中已经存在的值不用计算
        /// </summary>
        /// <param name="cutDataList"></param>
        /// <returns></returns>
        private List <OilDataSearchEntity> findOilDataSearch(OilInfoEntity oilA, OilInfoBEntity oilB)
        {
            List <OilDataSearchEntity> dataSearchList = new List <OilDataSearchEntity>();//需要返回的查找数据

            OilDataSearchRowAccess        dataSearchRowAccess = new OilDataSearchRowAccess();
            List <OilDataSearchRowEntity> dataSearchRows      = dataSearchRowAccess.Get("1=1").ToList();
            OilDataSearchColAccess        dataSearchColAccess = new OilDataSearchColAccess();
            List <OilDataSearchColEntity> dataSearchCols      = dataSearchColAccess.Get("1=1").ToList();

            #region "A库中查找"
            #region "原油信息表的查找数据"
            List <OilDataSearchColEntity> infoDataSearchCols = dataSearchCols.Where(o => o.OilTableName == "原油信息").ToList();
            int infoOilTalbeColID = infoDataSearchCols[0].OilTableColID;
            List <OilDataSearchRowEntity> oilDataRowEntityList = dataSearchRows.Where(o => o.OilTableRow.oilTableTypeID == (int)EnumTableType.Info).ToList();

            foreach (OilDataSearchRowEntity e in oilDataRowEntityList)
            {
                OilDataSearchEntity infoDataSearch = new OilDataSearchEntity();
                dataSearchList.Add(infoDataSearch);
                infoDataSearch.oilInfoID     = this._oilB.ID;
                infoDataSearch.oilTableColID = infoOilTalbeColID;
                infoDataSearch.oilTableRowID = e.OilTableRowID;
                #region
                if (e.OilTableRow.itemCode == "CNA")
                {
                    infoDataSearch.calData = oilA.crudeName;
                }
                else if (e.OilTableRow.itemCode == "ENA")
                {
                    infoDataSearch.calData = oilA.englishName;
                }
                else if (e.OilTableRow.itemCode == "IDC")
                {
                    infoDataSearch.calData = oilA.crudeIndex;
                }
                else if (e.OilTableRow.itemCode == "COU")
                {
                    infoDataSearch.calData = oilA.country;
                }
                else if (e.OilTableRow.itemCode == "GRC")
                {
                    infoDataSearch.calData = oilA.region;
                }
                else if (e.OilTableRow.itemCode == "ADA")
                {
                    infoDataSearch.calData = oilA.receiveDate != null?oilA.assayDate.ToString() : string.Empty;
                }
                else if (e.OilTableRow.itemCode == "ALA")
                {
                    infoDataSearch.calData = oilA.assayLab;
                }
                #endregion

                #region
                else if (e.OilTableRow.itemCode == "AER")
                {
                    infoDataSearch.calData = oilA.assayer;
                }
                else if (e.OilTableRow.itemCode == "SR")
                {
                    infoDataSearch.calData = oilA.sourceRef;
                }
                else if (e.OilTableRow.itemCode == "ASC")
                {
                    infoDataSearch.calData = oilA.assayCustomer;
                }
                else if (e.OilTableRow.itemCode == "RIN")
                {
                    infoDataSearch.calData = oilA.reportIndex;
                }
                else if (e.OilTableRow.itemCode == "CLA")
                {
                    infoDataSearch.calData = oilA.type;
                }
                else if (e.OilTableRow.itemCode == "TYP")
                {
                    infoDataSearch.calData = oilA.classification;
                }
                else if (e.OilTableRow.itemCode == "SCL")
                {
                    infoDataSearch.calData = oilA.sulfurLevel;
                }
                #endregion
            }
            #endregion

            #region "原油性质表的查找数据"
            OilDataSearchColEntity        wholeSearchCol = dataSearchCols.Where(o => o.OilTableName == "原油性质").FirstOrDefault();
            List <OilDataSearchRowEntity> wholeRowList   = wholeSearchCol.OilDataRowList;
            foreach (OilDataSearchRowEntity wholeRow in wholeRowList)
            {
                OilDataEntity wholeData = oilA.OilDatas.Where(o => o.oilTableRowID == wholeRow.OilTableRowID).FirstOrDefault();
                float         temp      = 0;
                if (wholeData != null && !string.IsNullOrWhiteSpace(wholeData.calData) && float.TryParse(wholeData.calData, out temp))
                {
                    OilDataSearchEntity DataSearch = new OilDataSearchEntity();
                    dataSearchList.Add(DataSearch);
                    DataSearch.oilInfoID     = this._oilB.ID;
                    DataSearch.oilTableColID = wholeSearchCol.OilTableColID;
                    DataSearch.oilTableRowID = wholeRow.OilTableRowID;
                    DataSearch.calData       = wholeData.calData;
                }
            }
            #endregion

            #region "宽馏分表和渣油表"
            foreach (CutMothedEntity cutMothed in this._cutMothedEntityList)
            {
                int oilTableColID = 0;
                #region "取出列代码"
                if (cutMothed.ECP <= 1500)
                {
                    List <OilDataEntity> ICPList = oilA.OilDatas.Where(o => o.OilTableRow.itemCode == "ICP" && o.calShowData.ToString() == cutMothed.ICP.ToString() && o.OilTableTypeID == (int)EnumTableType.Wide).ToList();
                    List <OilDataEntity> ECPList = oilA.OilDatas.Where(o => o.OilTableRow.itemCode == "ECP" && o.calShowData.ToString() == cutMothed.ECP.ToString() && o.OilTableTypeID == (int)EnumTableType.Wide).ToList();

                    foreach (OilDataEntity ICP in ICPList)
                    {
                        foreach (OilDataEntity ECP in ECPList)
                        {
                            if (ICP.OilTableCol.colCode == ECP.OilTableCol.colCode)
                            {
                                oilTableColID = ECP.oilTableColID;
                                break;
                            }
                        }
                    }
                }
                else if (cutMothed.ECP > 1500)
                {
                    OilDataEntity ICP = oilA.OilDatas.Where(o => o.OilTableRow.itemCode == "ICP" && o.calShowData == cutMothed.ICP.ToString() && o.OilTableTypeID == (int)EnumTableType.Residue).FirstOrDefault();
                    if (ICP != null)
                    {
                        oilTableColID = ICP.oilTableColID;
                    }
                }
                #endregion

                OilDataSearchColEntity        dataSearchCol      = dataSearchCols.Where(o => o.OilTableName == cutMothed.Name).FirstOrDefault();
                List <OilDataSearchRowEntity> wideDataSearchRows = dataSearchCol.OilDataRowList;
                if (oilTableColID > 0)
                {
                    foreach (OilDataSearchRowEntity dataSearchRow in wideDataSearchRows)
                    {
                        OilDataEntity data = oilA.OilDatas.Where(o => o.oilTableRowID == dataSearchRow.OilTableRowID && o.oilTableColID == oilTableColID).FirstOrDefault();
                        float         temp = 0;
                        if (data != null && !string.IsNullOrWhiteSpace(data.calData) && float.TryParse(data.calData, out temp))
                        {
                            OilDataSearchEntity DataSearch = new OilDataSearchEntity();
                            dataSearchList.Add(DataSearch);
                            DataSearch.oilInfoID     = this._oilB.ID;
                            DataSearch.oilTableColID = dataSearchCol.OilTableColID;
                            DataSearch.oilTableRowID = dataSearchRow.OilTableRowID;
                            DataSearch.calData       = data.calData;
                        }
                    }
                }
            }
            #endregion
            #endregion

            #region "B库中查找"
            #region "原油信息表的查找数据"

            foreach (OilDataSearchRowEntity e in oilDataRowEntityList)
            {
                OilDataSearchEntity dataSearchEntity = dataSearchList.Where(o => o.oilTableColID == infoOilTalbeColID && o.oilTableRowID == e.OilTableRowID).FirstOrDefault();

                if (dataSearchEntity == null)
                {
                    OilDataSearchEntity wholeDataSearch = new OilDataSearchEntity();
                    dataSearchList.Add(wholeDataSearch);
                    wholeDataSearch.oilInfoID     = this._oilB.ID;
                    wholeDataSearch.oilTableColID = infoOilTalbeColID;
                    wholeDataSearch.oilTableRowID = e.OilTableRowID;


                    #region
                    if (e.OilTableRow.itemCode == "CNA")
                    {
                        wholeDataSearch.calData = oilB.crudeName;
                    }
                    else if (e.OilTableRow.itemCode == "ENA")
                    {
                        wholeDataSearch.calData = oilB.englishName;
                    }
                    else if (e.OilTableRow.itemCode == "IDC")
                    {
                        wholeDataSearch.calData = oilB.crudeIndex;
                    }
                    else if (e.OilTableRow.itemCode == "COU")
                    {
                        wholeDataSearch.calData = oilB.country;
                    }
                    else if (e.OilTableRow.itemCode == "GRC")
                    {
                        wholeDataSearch.calData = oilB.region;
                    }
                    else if (e.OilTableRow.itemCode == "ADA")
                    {
                        wholeDataSearch.calData = oilB.receiveDate != null?oilB.receiveDate.ToString() : string.Empty;
                    }
                    else if (e.OilTableRow.itemCode == "ALA")
                    {
                        wholeDataSearch.calData = oilB.assayLab;
                    }
                    #endregion

                    #region
                    if (e.OilTableRow.itemCode == "AER")
                    {
                        wholeDataSearch.calData = oilB.assayer;
                    }
                    else if (e.OilTableRow.itemCode == "SR")
                    {
                        wholeDataSearch.calData = oilB.sourceRef;
                    }
                    else if (e.OilTableRow.itemCode == "ASC")
                    {
                        wholeDataSearch.calData = oilB.assayCustomer;
                    }
                    else if (e.OilTableRow.itemCode == "RIN")
                    {
                        wholeDataSearch.calData = oilB.reportIndex;
                    }
                    else if (e.OilTableRow.itemCode == "CLA")
                    {
                        wholeDataSearch.calData = oilB.type;
                    }
                    else if (e.OilTableRow.itemCode == "TYP")
                    {
                        wholeDataSearch.calData = oilB.classification;
                    }
                    else if (e.OilTableRow.itemCode == "SCL")
                    {
                        wholeDataSearch.calData = oilB.sulfurLevel;
                    }
                    #endregion
                }
                else if (dataSearchEntity != null && string.IsNullOrWhiteSpace(dataSearchEntity.calData))
                {
                    OilDataSearchEntity wholeDataSearch = new OilDataSearchEntity();
                    dataSearchList.Add(wholeDataSearch);
                    wholeDataSearch.oilInfoID     = this._oilB.ID;
                    wholeDataSearch.oilTableColID = infoOilTalbeColID;
                    wholeDataSearch.oilTableRowID = e.OilTableRowID;


                    #region
                    if (e.OilTableRow.itemCode == "CNA")
                    {
                        wholeDataSearch.calData = oilB.crudeName;
                    }
                    else if (e.OilTableRow.itemCode == "ENA")
                    {
                        wholeDataSearch.calData = oilB.englishName;
                    }
                    else if (e.OilTableRow.itemCode == "IDC")
                    {
                        wholeDataSearch.calData = oilB.crudeIndex;
                    }
                    else if (e.OilTableRow.itemCode == "COU")
                    {
                        wholeDataSearch.calData = oilB.country;
                    }
                    else if (e.OilTableRow.itemCode == "GRC")
                    {
                        wholeDataSearch.calData = oilB.region;
                    }
                    else if (e.OilTableRow.itemCode == "ADA")
                    {
                        wholeDataSearch.calData = oilB.receiveDate != null?oilB.receiveDate.ToString() : string.Empty;
                    }
                    else if (e.OilTableRow.itemCode == "ALA")
                    {
                        wholeDataSearch.calData = oilB.assayLab;
                    }
                    #endregion

                    #region
                    if (e.OilTableRow.itemCode == "AER")
                    {
                        wholeDataSearch.calData = oilB.assayer;
                    }
                    else if (e.OilTableRow.itemCode == "SR")
                    {
                        wholeDataSearch.calData = oilB.sourceRef;
                    }
                    else if (e.OilTableRow.itemCode == "ASC")
                    {
                        wholeDataSearch.calData = oilB.assayCustomer;
                    }
                    else if (e.OilTableRow.itemCode == "RIN")
                    {
                        wholeDataSearch.calData = oilB.reportIndex;
                    }
                    else if (e.OilTableRow.itemCode == "CLA")
                    {
                        wholeDataSearch.calData = oilB.type;
                    }
                    else if (e.OilTableRow.itemCode == "TYP")
                    {
                        wholeDataSearch.calData = oilB.classification;
                    }
                    else if (e.OilTableRow.itemCode == "SCL")
                    {
                        wholeDataSearch.calData = oilB.sulfurLevel;
                    }
                    #endregion
                }
            }
            #endregion

            #region "原油性质表的查找数据"
            for (int wholeIndex = 0; wholeIndex < wholeRowList.Count; wholeIndex++)
            {
                OilDataSearchEntity dataSearchEntity = dataSearchList.Where(o => o.oilTableColID == wholeSearchCol.OilTableColID && o.oilTableRowID == wholeRowList[wholeIndex].OilTableRowID).FirstOrDefault();

                OilDataBEntity wholeData = oilB.OilDatas.Where(o => o.oilTableRowID == wholeRowList[wholeIndex].OilTableRowID).FirstOrDefault();
                if (dataSearchEntity == null)
                {
                    if (wholeData != null && !string.IsNullOrWhiteSpace(wholeData.calData))
                    {
                        OilDataSearchEntity wholeDataSearch = new OilDataSearchEntity();
                        dataSearchList.Add(wholeDataSearch);
                        wholeDataSearch.oilInfoID     = this._oilB.ID;
                        wholeDataSearch.oilTableColID = wholeSearchCol.OilTableColID;
                        wholeDataSearch.oilTableRowID = wholeRowList[wholeIndex].OilTableRowID;
                        wholeDataSearch.calData       = wholeData.calData;
                    }
                }
                else if (dataSearchEntity != null && string.IsNullOrWhiteSpace(dataSearchEntity.calData))
                {
                    if (wholeData != null && !string.IsNullOrWhiteSpace(wholeData.calData))
                    {
                        dataSearchEntity.oilInfoID     = this._oilB.ID;
                        dataSearchEntity.oilTableColID = wholeSearchCol.OilTableColID;
                        dataSearchEntity.oilTableRowID = wholeRowList[wholeIndex].OilTableRowID;
                        dataSearchEntity.calData       = wholeData.calData;
                    }
                }
            }
            #endregion

            #region "宽馏分表和渣油表"
            for (int cutIndex = 0; cutIndex < this._cutMothedEntityList.Count; cutIndex++)
            {
                OilDataSearchColEntity        dataSearchCol      = dataSearchCols.Where(o => o.OilTableName == this._cutMothedEntityList[cutIndex].Name).FirstOrDefault();
                List <OilDataSearchRowEntity> wideDataSearchRows = dataSearchCol.OilDataRowList;
                if (dataSearchCol.OilTableColID > 0)
                {
                    for (int rowIndex = 0; rowIndex < wideDataSearchRows.Count; rowIndex++)
                    {
                        CutDataEntity       cutData          = oilB.CutDataEntityList.Where(o => o.CutName == this._cutMothedEntityList[cutIndex].Name && o.YItemCode == wideDataSearchRows[rowIndex].OilTableRow.itemCode).FirstOrDefault();
                        OilDataSearchEntity dataSearchEntity = dataSearchList.Where(o => o.oilTableColID == dataSearchCol.OilTableColID && o.oilTableRowID == wideDataSearchRows[rowIndex].OilTableRowID).FirstOrDefault();
                        if (dataSearchEntity == null)
                        {
                            if (cutData != null && cutData.CutData != null)
                            {
                                OilDataSearchEntity DataSearch = new OilDataSearchEntity();
                                dataSearchList.Add(DataSearch);
                                DataSearch.oilInfoID     = this._oilB.ID;
                                DataSearch.oilTableColID = dataSearchCol.OilTableColID;
                                DataSearch.oilTableRowID = wideDataSearchRows[rowIndex].OilTableRowID;
                                DataSearch.calData       = cutData.CutData.ToString();
                            }
                        }
                        else if (dataSearchEntity != null && string.IsNullOrWhiteSpace(dataSearchEntity.calData))
                        {
                            if (cutData != null && cutData.CutData != null)
                            {
                                OilDataSearchEntity DataSearch = new OilDataSearchEntity();
                                dataSearchList.Add(DataSearch);
                                DataSearch.oilInfoID     = this._oilB.ID;
                                DataSearch.oilTableColID = dataSearchCol.OilTableColID;
                                DataSearch.oilTableRowID = wideDataSearchRows[rowIndex].OilTableRowID;
                                DataSearch.calData       = cutData.CutData.ToString();
                            }
                        }
                    }
                }
            }
            #endregion

            #endregion
            return(dataSearchList);
        }
Example #9
0
        /// <summary>
        /// 转换
        /// </summary>
        /// <param name="oil"></param>
        /// <returns></returns>
        public static RefineryAssays ConvertFrom(OilInfoBEntity oil)
        {
            var r = new RefineryAssays();

            if (oil == null)
            {
                return(r);
            }

            var maps = Newtonsoft.Json.JsonConvert.DeserializeObject <RefineryAssaysMapItem[]>(File.ReadAllText("RefineryAssaysMaps.json"));

            #region 原油信息

            var name = $"{oil.crudeIndex} - {oil.englishName ?? oil.crudeName}";
            r.RefineryAssay = new RefineryAssaysRefineryAssay()
            {
                Name = name,
                RefineryAssayName      = name,
                SourceType             = oil.sourceRef,
                AssociatedFluidPackage = "Basis-1",
                PlantDataGroups        = new RefineryAssaysRefineryAssayPlantDataGroups()
                {
                    PlantDataGroup = new RefineryAssaysRefineryAssayPlantDataGroupsPlantDataGroup()
                    {
                        Name = "Plant Data Group-1",
                        PlantDataGroupName = "Plant Data Group-1"
                    },
                }
            };

            var ps = new List <RefineryAssaysRefineryAssayPlantDataGroupsPlantDataGroupPropertiesProperty>();

            foreach (var p in maps)
            {
                var tr = oil.OilTableRows.FirstOrDefault(o => o.itemCode == p.ripp_code);
                if (tr == null)
                {
                    continue;
                }
                var index = oil.OilTableRows.IndexOf(tr);
                var d     = oil.OilDatas[index];

                ps.Add(new RefineryAssaysRefineryAssayPlantDataGroupsPlantDataGroupPropertiesProperty()
                {
                    Name                   = p.name,
                    PropertyName           = p.property_name,
                    PropertyKey            = p.key,
                    PropertyQualifierValue = p.GetValue(d.calData),
                });
            }

            var plant = r.RefineryAssay.PlantDataGroups.PlantDataGroup;
            plant.Properties = ps;

            #endregion 原油信息

            #region 切割曲线

            OilDataSearchColAccess        oilDataColAccess = new OilDataSearchColAccess();
            List <OilDataSearchColEntity> OilDataCols      = oilDataColAccess.Get("1=1");

            OilDataSearchRowAccess        oilDataRowAccess = new OilDataSearchRowAccess();
            List <OilDataSearchRowEntity> OilDataRows      = oilDataRowAccess.Get("1=1");

            OilDataSearchAccess        oilDataSearchAccess = new OilDataSearchAccess();
            List <OilDataSearchEntity> allDatas            = oilDataSearchAccess.Get("oilInfoID = " + oil.ID).ToList();

            var cuts = new List <RefineryAssaysRefineryAssayPlantDataGroupsPlantDataGroupCutsCut>();

            BuildCut("石脑油", "15-140", "Naph");
            BuildCut("煤油", "140-240", "Kero");
            BuildCut("柴油", "240-350", "Disel");
            BuildCut("蜡油", "350-540", "VGO");
            BuildCut("渣油", ">540", "Reside");

            //构造切割曲线
            void BuildCut(string name1, string name2, string type)
            {
                var Cols = OilDataCols.Where(o => o.OilTableName.Contains(name1) && o.OilTableName.Contains(name2)).OrderBy(o => o.itemOrder).ToList();

                if (Cols.Count == 0)
                {
                    return;
                }
                var Rows = OilDataRows.Where(o => o.OilDataColID == Cols[0].ID).OrderBy(o => o.OilTableRow.itemOrder).ToList();

                if (Rows.Count == 0)
                {
                    return;
                }
                var TableRows = new List <OilTableRowEntity>();

                for (int i = 0; i < Rows.Count; i++)
                {
                    OilTableRowEntity oilTableRow = OilTableRowBll._OilTableRow.Where(o => o.ID == Rows[i].OilTableRowID).FirstOrDefault();
                    TableRows.Add(oilTableRow);
                }

                for (int i = 0; i < Cols.Count; i++)
                {
                    var Data = allDatas.Where(o => o.oilTableColID == Cols[i].OilTableColID).ToList();
                    if (Data?.Any() != true)
                    {
                        continue;
                    }

                    var cut = new RefineryAssaysRefineryAssayPlantDataGroupsPlantDataGroupCutsCut()
                    {
                        CutName = type,
                        Name    = type,
                        CutType = 0,
                    };

                    var ps2 = new List <RefineryAssaysRefineryAssayPlantDataGroupsPlantDataGroupCutsCutPropertiesProperty>();

                    foreach (var p in maps)
                    {
                        var tr = Data.FirstOrDefault(o => o.OilTableRow.itemCode == p.ripp_code);
                        if (tr == null)
                        {
                            continue;
                        }

                        ps2.Add(new RefineryAssaysRefineryAssayPlantDataGroupsPlantDataGroupCutsCutPropertiesProperty()
                        {
                            Name         = p.name,
                            PropertyName = p.property_name,
                            InputValue   = p.GetValue(tr.calData)
                        });
                    }

                    cut.Properties = ps2;
                    cuts.Add(cut);
                }
            }

            if (cuts.Any() == true)
            {
                plant.Cuts = cuts;
            }

            #endregion 切割曲线

            return(r);
        }