/// <summary> /// 获取收率曲线中各个ECP对应的TWY的值 /// </summary> /// <param name="itemCode"></param> /// <returns></returns> public static Dictionary <float, float> getECP_TWYDatasfromYIELD(OilInfoBEntity oilInfoB) //ECP-TWY { Dictionary <float, float> ECP_TWYDIC = new Dictionary <float, float>(); //存储终切点数据。 #region "ECP-TWY判断" CurveEntity ECP_TWYCurve = oilInfoB.curves.Where(o => o.propertyX == "ECP" && o.propertyY == "TWY").FirstOrDefault(); if (ECP_TWYCurve == null) { //MessageBox.Show(this._oilB.crudeName + "的收率曲线不存在!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); return(ECP_TWYDIC); } if (ECP_TWYCurve.curveDatas.Count <= 0) { //MessageBox.Show(this._oilB.crudeName + "的收率曲线数据不存在!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); return(ECP_TWYDIC); } #endregion var ECP_TWYDatas = ECP_TWYCurve.curveDatas.OrderBy(o => o.xValue);//升序 List <CurveDataEntity> ECP_TWYCurveDatas = ECP_TWYDatas.ToList(); #region "存储终切点数据" for (int index = 0; index < ECP_TWYCurveDatas.Count; index++) { if (!ECP_TWYDIC.Keys.Contains(ECP_TWYCurveDatas[index].xValue)) { ECP_TWYDIC.Add(ECP_TWYCurveDatas[index].xValue, ECP_TWYCurveDatas[index].yValue);//ECP-TWY } } #endregion return(ECP_TWYDIC); }
/// <summary> /// 将导入的B库数据变为曲线数据 /// </summary> /// <param name="oilInfoBEntity"></param> /// <param name="curves"></param> /// <param name="curveTypes"></param> public void toCurve(ref OilInfoBEntity oilInfoBEntity, List <CurveEntity> curves, List <CurveTypeEntity> curveTypes) { //保存曲线 // oilInfoEntity.curveTypes = _outLib.curveTypes; CurveTypeAccess curveTypeAccess = new CurveTypeAccess(); oilInfoBEntity.curves = new List <CurveEntity>(); foreach (CurveEntity curveEntity in curves) { string typeCode = curveTypes.Where(c => c.ID == curveEntity.curveTypeID).FirstOrDefault().typeCode; CurveTypeEntity curveType = curveTypeAccess.Get("typeCode='" + typeCode + "'").FirstOrDefault(); curveEntity.curveTypeID = curveType.ID; curveEntity.oilInfoID = oilInfoBEntity.ID; CurveAccess acess = new CurveAccess(); int curveID = acess.Insert(curveEntity); //保存曲线,并获取ID curveEntity.ID = curveID; foreach (CurveDataEntity curveData in curveEntity.curveDatas) { curveData.curveID = curveID; } oilInfoBEntity.curves.Add(curveEntity); } }
private void button1_Click(object sender, EventArgs e) { List <OilSimilarSearchEntity> list = new List <OilSimilarSearchEntity>(); /*添加第一个物性选项*/ OilSimilarSearchEntity item = new OilSimilarSearchEntity(); item.ItemName = textBox2.Text.Trim(); item.Fvalue = float.Parse(textBox3.Text.Trim()); list.Add(item); //添加第二个物性选项 item = new OilSimilarSearchEntity(); item.ItemName = textBox5.Text.Trim(); item.Fvalue = float.Parse(textBox6.Text.Trim()); list.Add(item); oilName _oilName = new oilName(); string crudeIndex = _oilName.GetOilName(list);//原油名称 if (crudeIndex == "") { //this.dataGridView1.ClearSelection(); MessageBox.Show("未查询到对应的原油", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } OilInfoBEntity _oil = new OilInfoBEntity(); //新建一条原油 OilApplyBll oilApplyBll = new OilApplyBll(); //_oil = oilApplyBll.GetCutResult(crudeIndex); //_oil = oilApplyBll.GetCutResult(crudeIndex); this.dataGridView1.DataSource = _oil.dataTable; //List<OilDataTableBEntity> OilDataTableBEntityList = _oil.OilDataTableBEntityList ;//返回类型 }
/// <summary> /// 鼠标双击-打开一条原油 /// </summary> public override void openOil() { int oilInfoID = this.gridList.CurrentRow != null?int.Parse(this.gridList.CurrentRow.Cells["ID"].Value.ToString()) : -1; OilInfoBEntity oil = OilBll.GetOilBByID(oilInfoID); if (oil == null) { return; } if (isOilOpening) { return; } isOilOpening = true; try { FrmMain frmMain = this.MdiParent as FrmMain; DatabaseB.FrmOilDataB child = (DatabaseB.FrmOilDataB)frmMain.GetChildFrm(oil.crudeIndex + "B"); if (child == null) { FrmOilDataB form = new FrmOilDataB(oil); form.MdiParent = frmMain; form.Show(); } else { child.Activate(); } } finally { isOilOpening = false; } }
private CurveEntity _curve;//选择一条曲线 #endregion #region 构造函数 /// <summary> /// 构造函数 /// </summary> /// <param name="oil">一条原油</param> public FrmOilDataB(OilInfoBEntity oilB) { InitializeComponent(); this._oilB = oilB; initTab(); BindcmbType(); BindcmbCurve(Convert.ToInt32(this.cmbType.SelectedValue.ToString())); this.Text = "应用库原油数据-" + this._oilB.crudeIndex; this.Name = this._oilB.crudeIndex + "B"; //在打开操作时要根据该名称判断窗口是否存在 }
/// <summary> /// 为OilDataSearchEntity的快速查询库的数据赋值 /// </summary> /// <param name="oilInfoEntity"></param> /// <param name="oilInfoOut"></param> /// <param name="oilTableRows"></param> /// <param name="oilTableCols"></param> public void toOilDataSearchs(ref OilInfoBEntity oilInfoEntity, OilInfoOut oilInfoOut) { foreach (OilDataSearchOut oilDataSearchOut in oilInfoOut.oilDataSearchOuts) //插入原油数据 { OilDataSearchEntity oilDataSearch = new OilDataSearchEntity(); //新建OilDataSearch实体 oilDataSearch.oilInfoID = oilInfoEntity.ID; oilDataSearch.oilTableColID = oilDataSearchOut.oilTableColID; oilDataSearch.oilTableRowID = oilDataSearchOut.oilTableRowID; oilDataSearch.labData = oilDataSearchOut.labData; oilDataSearch.calData = oilDataSearchOut.calData; oilInfoEntity.OilDataSearchs.Add(oilDataSearch); } }
/// <summary> /// 构造函数 /// </summary> /// <param name="oilInfoBEntity"></param> public ShowCutData(OilInfoBEntity oilInfoB, IList <CutMothedEntity> cutMotheds) { InitializeComponent(); this._oilInfoB = oilInfoB; this.tabControl1.SelectedTab = this.tabPage1; this._cutMotheds = cutMotheds; breakCutMotheds(cutMotheds); this._selectGridView = this.dataGridView1; oilEdit = new GridOilDataEdit(this._oilInfoB); initDataGridView(); this.tabControl1.TabPages.Remove(this.tabPage2); this.dataGridView1.ReadOnly = true; this.dataGridView2.ReadOnly = true; this.dataGridView3.ReadOnly = true; this.dataGridView4.ReadOnly = true; }
/// <summary> /// API 1,根据原油名称的切割方案获取数据 /// </summary> /// <param name="s"></param> /// <returns></returns> private OilInfoBEntity getByName(Specs s, BindResult pr, ref List <PropertyTable> result) { var r = pr.GetResult <IdentifyResult>(); if (r != null) { OilInfoBEntity oil = new OilInfoBEntity(); //新建一条原油 var oilApplyBll = new OilApplyAPIBll(); var cuts = new List <CutMothedAPIEntity>(); foreach (var t in this._initP) { if (t.Table == PropertyType.NIR) { continue; } cuts.Add(new CutMothedAPIEntity() { ICP = (int)t.BoilingStart, ECP = (int)t.BoilingEnd, Name = this.convertEnum(t.Table) }); } try { log.Info(r.Items.First().Spec.UUID); log.Info(string.Join(";", cuts.Select(d => string.Format("ICP={0},ECP={1},Name={2}", d.ICP, d.ECP, d.Name)))); oil = oilApplyBll.GetCutResultAPI(r.Items.First().Spec.UUID, cuts); if (oil != null) { var lst = oil.OilDataTableBAPIEntityList; convertEntity(lst, ref result, IntegrateModel.GetConfidence(r.Items.First().TQ, r.MinTQ, r.Items.First().SQ, r.MinSQ)); //写入值信度 } else { log.ErrorFormat("GetCutResultAPI({0})", r.Items.First().Spec.UUID); } return(oil); } catch (Exception ex) { log.Error(ex.ToString()); } } return(null); }
/// <summary> /// 将导入的B库数据变为OilData /// </summary> /// <param name="OilInfoBEntity"></param> /// <param name="OilInfoOut"></param> /// <param name="oilTableRows"></param> /// <param name="oilTableCols"></param> public void toOilDatas(ref OilInfoBEntity oilInfoEntity, OilInfoOut oilInfoOut, List <OilTableRowOut> oilTableRows, List <OilTableColOut> oilTableCols) { OilTableRowBll rowBll = new OilTableRowBll(); OilTableColBll colBll = new OilTableColBll(); foreach (OilDataOut oilDataOut in oilInfoOut.oilDatas) //插入原油数据 { OilDataBEntity oilData = new OilDataBEntity(); OilTableColOut oilTableColOut = oilTableCols.Where(c => c.ID == oilDataOut.oilTableColID).FirstOrDefault(); if (oilTableColOut == null) { continue; } string colCode = oilTableColOut.colCode; OilTableRowOut oilTableRowOut = oilTableRows.Where(c => c.ID == oilDataOut.oilTableRowID).FirstOrDefault(); if (oilTableRowOut == null) { continue; } string itemCode = oilTableRowOut.itemCode; //if (itemCode == "CLA" && oilTableRowOut.oilTableTypeID == 2) // continue; //if (itemCode == "A10" && oilTableRowOut.oilTableTypeID == 4) // itemCode = "10A"; try { OilTableColEntity col = colBll[colCode, (EnumTableType)oilTableRowOut.oilTableTypeID]; OilTableRowEntity row = rowBll[itemCode, (EnumTableType)oilTableRowOut.oilTableTypeID]; if (row != null && col != null) { oilData.oilInfoID = oilInfoEntity.ID; oilData.oilTableColID = col.ID; oilData.oilTableRowID = row.ID; oilData.labData = oilDataOut.labData; oilData.calData = oilDataOut.calData; oilInfoEntity.OilDatas.Add(oilData); } } catch (Exception ex) { Log.Error("导入应用库 :" + ex.ToString()); } } }
/// <summary> /// 显示相似查找的基础值 /// </summary> /// <param name="oil"></param> private void selectOilData() { string crudeIndex = this.gridList.CurrentRow != null ? this.gridList.CurrentRow.Cells["原油编号"].Value.ToString() : string.Empty; OilInfoBAccess oilInfoB = new OilInfoBAccess(); OilInfoBEntity tempOilInfoB = oilInfoB.Get("crudeIndex = '" + crudeIndex + "'").FirstOrDefault(); if (tempOilInfoB == null) { return; } int oilInfoID = tempOilInfoB.ID; OilTableRowEntity selectOiltableRowEntity = (OilTableRowEntity)cmbSimilarItem.SelectedItem; //获取物性下拉菜单选择项实体 int oilTableRowID = selectOiltableRowEntity.ID; OilDataSearchColEntity selectedItem = (OilDataSearchColEntity)this.cmbSimilarFraction.SelectedItem; //确定当前菜单中的数据 int oilTableColID = selectedItem.OilTableColID; OilDataSearchAccess oilDataSearchAccess = new OilDataSearchAccess(); OilDataSearchEntity oilData = oilDataSearchAccess.Get("oilInfoID = " + oilInfoID + " and oilTableColID = " + oilTableColID + " and oilTableRowID =" + oilTableRowID).FirstOrDefault(); if (oilData != null) { if (oilData.calData != string.Empty && oilData.calData != "非数字" && oilData.calData != "正无穷大" && oilData.calData != "负无穷大") { float temp = 0; if (float.TryParse(oilData.calData, out temp)) { this.txtSimilarFoundationValue.Text = oilData.calData; } else { this.txtSimilarFoundationValue.Text = string.Empty; } } else { this.txtSimilarFoundationValue.Text = string.Empty; } } else { this.txtSimilarFoundationValue.Text = string.Empty; } }
private void button1_Click(object sender, EventArgs e) { if (this.textBox1.Text.Trim() == "" || this.textBox3.Text.Trim() == "") { MessageBox.Show("原油名称不能为空", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (this.textBox2.Text.Trim() == "" || this.textBox4.Text.Trim() == "") { MessageBox.Show("切割比率不能为空", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if ((int.Parse(this.textBox2.Text.Trim()) + +int.Parse(this.textBox4.Text.Trim())) != 100) { MessageBox.Show("切割比率加和不等于100%!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } //切割比率 List <CutOilRateEntity> cutOilRates = new List <CutOilRateEntity>(); CutOilRateEntity CutOilRateEntity1 = new CutOilRateEntity(); CutOilRateEntity1.crudeIndex = this.textBox1.Text.Trim();//原油名称 CutOilRateEntity1.rate = int.Parse(this.textBox2.Text.Trim()); cutOilRates.Add(CutOilRateEntity1); CutOilRateEntity CutOilRateEntity2 = new CutOilRateEntity(); CutOilRateEntity2.crudeIndex = this.textBox3.Text.Trim();//原油名称 CutOilRateEntity2.rate = int.Parse(this.textBox4.Text.Trim()); cutOilRates.Add(CutOilRateEntity2); OilInfoBEntity _oil = new OilInfoBEntity(); //新建一条原油 OilApplyBll oilApplyBll = new OilApplyBll(); //_oil = oilApplyBll.GetCutResult(cutOilRates); this.dataGridView1.DataSource = _oil.dataTable; //List<OilDataTableBEntity> OilDataTableBEntityList = _oil.OilDataTableBEntityList; }
/// <summary> /// 转换为OilInfoBEntity /// </summary> /// <param name="oilInfoEntity">OilInfoBEntity实体</param> /// <param name="oilInfoOut">oilInfoOut</param> public void toOilInfoEntity(ref OilInfoBEntity oilInfoBEntity, OilInfoOut oilInfoOut) { oilInfoBEntity.crudeName = oilInfoOut.crudeName; oilInfoBEntity.englishName = oilInfoOut.englishName; oilInfoBEntity.crudeIndex = oilInfoOut.crudeIndex; oilInfoBEntity.country = oilInfoOut.country; oilInfoBEntity.region = oilInfoOut.region; oilInfoBEntity.fieldBlock = oilInfoOut.fieldBlock; oilInfoBEntity.sampleDate = oilInfoOut.sampleDate; oilInfoBEntity.receiveDate = oilInfoOut.receiveDate; oilInfoBEntity.sampleSite = oilInfoOut.sampleSite; oilInfoBEntity.assayDate = oilInfoOut.assayDate; oilInfoBEntity.updataDate = oilInfoOut.updataDate; oilInfoBEntity.sourceRef = oilInfoOut.sourceRef; oilInfoBEntity.assayLab = oilInfoOut.assayLab; oilInfoBEntity.assayer = oilInfoOut.assayer; oilInfoBEntity.assayCustomer = oilInfoOut.assayCustomer; oilInfoBEntity.reportIndex = oilInfoOut.reportIndex; oilInfoBEntity.summary = oilInfoOut.summary; oilInfoBEntity.type = oilInfoOut.type; oilInfoBEntity.classification = oilInfoOut.classification; oilInfoBEntity.sulfurLevel = oilInfoOut.sulfurLevel; oilInfoBEntity.acidLevel = oilInfoOut.acidLevel; oilInfoBEntity.corrosionLevel = oilInfoOut.corrosionLevel; oilInfoBEntity.processingIndex = oilInfoOut.processingIndex; oilInfoBEntity.BlendingType = oilInfoOut.BlendingType; oilInfoBEntity.NIRSpectrum = oilInfoOut.NIRSpectrum; oilInfoBEntity.DataQuality = oilInfoOut.DataQuality; oilInfoBEntity.Remark = oilInfoOut.Remark; oilInfoBEntity.S_01R = oilInfoOut.S_01R; oilInfoBEntity.S_02R = oilInfoOut.S_02R; oilInfoBEntity.S_03R = oilInfoOut.S_03R; oilInfoBEntity.S_04R = oilInfoOut.S_04R; oilInfoBEntity.S_05R = oilInfoOut.S_05R; oilInfoBEntity.S_06R = oilInfoOut.S_06R; oilInfoBEntity.S_07R = oilInfoOut.S_07R; oilInfoBEntity.S_08R = oilInfoOut.S_08R; oilInfoBEntity.S_09R = oilInfoOut.S_09R; oilInfoBEntity.S_10R = oilInfoOut.S_10R; oilInfoBEntity.DataSource = oilInfoOut.DataSource; oilInfoBEntity.ICP0 = oilInfoOut.ICP0; }
private void button1_Click(object sender, EventArgs e) { string crudeIndex = this.textBox1.Text.Trim();//原油名称 if (crudeIndex == "") { MessageBox.Show("原油名称不能为空", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } OilInfoBEntity _oil = new OilInfoBEntity(); //新建一条原油 //OilApplyBll oilApplyBll = new OilApplyBll(); //_oil = oilApplyBll.GetCutResult(crudeIndex); //this.dataGridView1.DataSource = _oil.dataTable; //List<OilDataTableBEntity> OilDataTableBEntityList = _oil.OilDataTableBEntityList ; }
/// <summary> /// 获取切割数据 /// </summary> /// <returns></returns> public List <OilDataSearchEntity> GetCutResult() { List <CutMothedEntity> cutMothedEntityList = OilSearchCutMothed();//切割方案 OilApplyBll oilApplyBll = new OilApplyBll(); OilInfoBEntity OilB = oilApplyBll.GetCutResult(this._oilB, cutMothedEntityList); List <OilDataSearchEntity> list = new List <OilDataSearchEntity> (); //List<CutDataEntity> D20List = OilB.CutDataEntityList.Where(o => o.YItemCode == "D20").ToList(); if (this._oilA == null) { list = findOilDataSearch(OilB.CutDataEntityList); } else { list = findOilDataSearch(this._oilA, OilB); } return(list); }
/// <summary> /// 向B库中保存A库的原油信息 /// </summary> /// <returns></returns> public int SaveInfoB(ref OilInfoBEntity oilInfoB) { ReadDataFromUI(); OilBll.InfoToInfoB(this._oilInfo, oilInfoB); oilInfoB.ID = OilBll.saveInfo(oilInfoB); if (oilInfoB.ID == -1) { OilInfoBAccess access = new OilInfoBAccess(); string sqlWhere = "crudeIndex='" + oilInfoB.crudeIndex + "'"; List <OilInfoBEntity> oilInfoBList = access.Get(sqlWhere).ToList(); oilInfoB.ID = oilInfoBList[0].ID; access.Update(oilInfoB, oilInfoB.ID.ToString()); OilDataBAccess oilDataAccess = new OilDataBAccess(); oilDataAccess.Delete("labData='' and calData='' and oilInfoID=" + oilInfoB.ID); //删除空的数据 return(oilInfoB.ID); } return(oilInfoB.ID); }
/// <summary> /// 重新开始 /// </summary> private void menuItemStart_Click(object sender, EventArgs e) { GridListSourceBind(); this._cutMotheds.Clear(); this._cutOilRates.Clear(); this._oilB = new OilInfoBEntity();//输出原油 this.gridListSelect.Rows.Clear(); this.gridListRate.Rows.Clear(); this.gridListCut.Rows.Clear(); this.panelStep1.Visible = false; this.panelStep2.Visible = false; this.panelStep3.Visible = false; this.panelStep4.Visible = false; this.panelStep6.Visible = false; this.butStep2.Enabled = false; this.butStep3.Enabled = false; this.butStep4.Enabled = false; this.btnStep5.Enabled = false; this.butStep6.Enabled = false; this.toolStripStatusLabel.Text = "再次切割"; }
/// <summary> /// 获取到用户选择的OilInfo /// </summary> /// <returns>用户选择的OilInfoBEntity的集合</returns> private List <OilInfoBEntity> getSelectedOil() { this.gridList.EndEdit(); List <OilInfoBEntity> result = new List <OilInfoBEntity>(); OilInfoBAccess access = new OilInfoBAccess(); int oilInfoId = -1; foreach (DataGridViewRow row in this.gridList.Rows) { if (row.Cells["select"].Value != null && bool.Parse(row.Cells["select"].Value.ToString()) == true) { oilInfoId = int.Parse(row.Cells["ID"].Value.ToString()); OilInfoBEntity oilEntity = access.Get(oilInfoId); if (null != oilEntity) { result.Add(oilEntity); } } } return(result); }
/// <summary> /// 构造函数 /// </summary> public OilCApplyBll(OilInfoEntity oilA, OilInfoBEntity oilB) { this._oilA = oilA; this._oilB = oilB; this._cutMothedEntityList = OilSearchCutMothed();//切割方案 }
/// <summary> /// 相似查找,返回对应的原油ID /// </summary> /// <param name="oilProperty">相似查找条件的实体集合OilSimilarSearchEntityList</param> /// <returns></returns> public IDictionary <string, double> GetOilSimInfoCrudeIndex(IList <OilSimilarSearchEntity> similarSearchEntityList) { IDictionary <string, double> crudeIndexSimDic = new Dictionary <string, double>(); #region "输入条件判断" IList <string> resultCrudeIndexList = new List <string>(); //存放满足条件的原油编号 if (similarSearchEntityList == null) //查找条件为空 { return(crudeIndexSimDic); } if (similarSearchEntityList.Count == 0)//查找条件为空 { return(crudeIndexSimDic); } #endregion #region "初始化判断条件" string sqlWhere = "select distinct(oilInfoID) from OilDataSearch"; OilDataSearchAccess oilDataSearchAccess = new OilDataSearchAccess(); List <int> oilDataSearchOilInfoIDList = oilDataSearchAccess.getId(sqlWhere); //获取OilDataSearch表中的所有oilInfoID foreach (int oilInfoBID in oilDataSearchOilInfoIDList) //从C库中查找到的原油编号 { OilInfoBEntity bEntity = OilBll.GetOilBByID(oilInfoBID); List <TempsimliarEntity> tempList = new List <TempsimliarEntity>(); if (bEntity != null) { tempSimliarDic[bEntity.crudeIndex] = tempList; } } #endregion #region "范围查找中And和or两种类型的判断的归类" IList <OilSimilarSearchEntity> searchAnd = new List <OilSimilarSearchEntity>(); //范围查找用(and条件) IList <OilSimilarSearchEntity> searchOr = new List <OilSimilarSearchEntity>(); //范围查找用(or条件) foreach (OilSimilarSearchEntity currentOilSimilarSearchEntity in similarSearchEntityList) { if (currentOilSimilarSearchEntity.IsAnd && currentOilSimilarSearchEntity.RightParenthesis.Trim() == "")//如果该条件是And,添加到searchAnd中去 { searchAnd.Add(currentOilSimilarSearchEntity); continue; } else if (!currentOilSimilarSearchEntity.IsAnd && currentOilSimilarSearchEntity.LeftParenthesis.Trim() == "(" && currentOilSimilarSearchEntity.RightParenthesis.Trim() == "")//如果该条件是Or,但不是最后一个Or,则添加到searchOr中去,暂时不进行计算 { searchOr.Add(currentOilSimilarSearchEntity); continue; } else if (!currentOilSimilarSearchEntity.IsAnd && currentOilSimilarSearchEntity.LeftParenthesis.Trim() == "" && currentOilSimilarSearchEntity.RightParenthesis.Trim() == "")//如果该条件是Or,但不是最后一个Or,则添加到searchOr中去,暂时不进行计算 { searchOr.Add(currentOilSimilarSearchEntity); continue; } else if (currentOilSimilarSearchEntity.RightParenthesis.Trim() == ")")////如果该条件是Or,且是括号中的最后一个Or,则添加到searchOr中去,并进行或的计算 { #region "Or的计算" searchOr.Add(currentOilSimilarSearchEntity); foreach (int ID in oilDataSearchOilInfoIDList)//根据ID循环每一条原油 { OilInfoBEntity infoB = OilBll.GetOilBByID(ID); if (!tempSimliarDic.Keys.Contains(infoB.crudeIndex)) { continue; } if (searchOr.Count <= 0) { continue; } TempsimliarEntity tempsimliarEntity = getDataFromOrSimilarSearchList(searchOr, ID); if (tempSimliarDic.Keys.Contains(infoB.crudeIndex)) { tempSimliarDic[infoB.crudeIndex].Add(tempsimliarEntity); } } searchOr.Clear();//该Or括号计算完后,情况OrList,用于后面的Or括号计算 continue; #endregion } } #endregion #region "处理And条件或计算的结果和And条件取交集" foreach (int oilInfoID in oilDataSearchOilInfoIDList)//根据ID循环每一条原油 { OilInfoBEntity infoB = OilBll.GetOilBByID(oilInfoID); if (!tempSimliarDic.Keys.Contains(infoB.crudeIndex)) { continue; } if (searchAnd.Count <= 0) { continue; } TempsimliarEntity tempsimliarEntity = getDataFromAndSimilarSearchList(searchAnd, oilInfoID); if (tempSimliarDic.Keys.Contains(infoB.crudeIndex)) { tempSimliarDic[infoB.crudeIndex].Add(tempsimliarEntity); } } #endregion foreach (string key in tempSimliarDic.Keys) { double sum = 0, sumWeight = 0; foreach (TempsimliarEntity tempsimliarEntity in tempSimliarDic[key]) { if (tempsimliarEntity.Match == 0 || tempsimliarEntity.Match.Equals(double.NaN)) { sum = double.NaN; sumWeight = tempsimliarEntity.Weight; } else { sum += tempsimliarEntity.Match; sumWeight += tempsimliarEntity.Weight; } } if (sumWeight != 0 && !sum.Equals(double.NaN)) { crudeIndexSimDic.Add(key, sum / sumWeight); } } return(crudeIndexSimDic); }
/// <summary> /// 范围查询-从C库查找满足条件的原油编号 /// </summary> /// <returns></returns> public static IDictionary <string, double> GetRangOilInfoCrudeIndex(IList <OilRangeSearchEntity> rangeSearchEntityList) { int count = 0; //输入条件的个数 IDictionary <string, double> crudeIndexRanDic = new Dictionary <string, double>(); //IList<string> resultCrudeIndexList = new List<string>();//存放满足条件的原油编号 #region "输入条件判断" if (rangeSearchEntityList == null)//查找条件为空 { return(crudeIndexRanDic); } if (rangeSearchEntityList.Count == 0)//查找条件为空 { return(crudeIndexRanDic); } #endregion #region "标志条件" Dictionary <string, int> oilInfoCrudeIndex_And_Result = new Dictionary <string, int>();//满足条件的原油对应值为1,不满足为0 string sqlWhere = "select distinct(oilInfoID) from OilDataSearch"; OilDataSearchAccess oilDataSearchAccess = new OilDataSearchAccess(); List <int> oilDataSearchOilInfoBIDList = oilDataSearchAccess.getId(sqlWhere); //获取OilDataSearch表中的所有oilInfoID foreach (int oilInfoBID in oilDataSearchOilInfoBIDList) //从C库中查找到的原油编号 { OilInfoBEntity bEntity = OilBll.GetOilBByID(oilInfoBID); if (bEntity != null) { oilInfoCrudeIndex_And_Result[bEntity.crudeIndex] = 0; } } #endregion #region "范围查找中And和or两种类型的判断的归类" IList <OilRangeSearchEntity> searchAnd = new List <OilRangeSearchEntity>(); //范围查找用(and条件) IList <OilRangeSearchEntity> searchOr = new List <OilRangeSearchEntity>(); //范围查找用(or条件) foreach (OilRangeSearchEntity currentOilRangeSearchEntity in rangeSearchEntityList) { if (currentOilRangeSearchEntity.IsAnd && currentOilRangeSearchEntity.RightParenthesis.Trim() == "")//如果该条件是And,添加到searchAnd中去 { searchAnd.Add(currentOilRangeSearchEntity); count++; continue; } else if (!currentOilRangeSearchEntity.IsAnd && currentOilRangeSearchEntity.RightParenthesis.Trim() != ")")//如果该条件是Or,但不是最后一个Or,则添加到searchOr中去,暂时不进行计算 { searchOr.Add(currentOilRangeSearchEntity); continue; } else if (currentOilRangeSearchEntity.RightParenthesis.Trim() == ")")////如果该条件是Or,且是括号中的最后一个Or,则添加到searchOr中去,并进行或的计算 { #region "Or的计算" searchOr.Add(currentOilRangeSearchEntity); foreach (int oilInfoBID in oilDataSearchOilInfoBIDList)//从C库中查找到的原油编号 { OilInfoBEntity infoB = OilBll.GetOilBByID(oilInfoBID); int temp = getDataFromOrRangeSearchList(searchOr, oilInfoBID); oilInfoCrudeIndex_And_Result[infoB.crudeIndex] += temp; } count++; searchOr.Clear();//该Or括号计算完后,情况OrList,用于后面的Or括号计算 continue; #endregion } } #endregion #region "处理And条件(或计算的结果和And条件取交集" foreach (int oilInfoBID in oilDataSearchOilInfoBIDList)//从C库中查找到的原油编号 { OilInfoBEntity infoB = OilBll.GetOilBByID(oilInfoBID); oilInfoCrudeIndex_And_Result[infoB.crudeIndex] += getDataFromAndRangeSearchList(searchAnd, oilInfoBID); } #endregion foreach (string key in oilInfoCrudeIndex_And_Result.Keys) { if (oilInfoCrudeIndex_And_Result[key] == count) { crudeIndexRanDic.Add(key, 0); } } searchAnd.Clear(); searchOr.Clear(); return(crudeIndexRanDic); }
public static void GetNIRData(Specs s, OilInfoBEntity oil, ref List <PropertyTable> lst) { if (s == null || s.Spec == null || s.Spec.Components == null) { return; } var cmps = s.Spec.Components; var t = lst.Where(d => d.Table == PropertyType.NIR).FirstOrDefault(); if (t != null) { if (oil != null) { t.OilInfoDetail = new OilInfo() { CrudeIndex = oil.crudeIndex, CrudeName = oil.crudeName } } ; double confidence = double.NaN; List <IntegrateResultItem> itgResult = null; switch (s.ResultObj.MethodType) { case PredictMethod.Identify: var r1 = s.ResultObj.GetResult <IdentifyResult>(); confidence = IntegrateModel.GetConfidence(r1.Items.First().TQ, r1.MinTQ, r1.Items.First().SQ, r1.MinSQ); break; case PredictMethod.Fitting: var r2 = s.ResultObj.GetResult <FittingResult>(); confidence = IntegrateModel.GetConfidence(r2.TQ, r2.MinTQ, r2.SQ, r2.MinSQ); break; case PredictMethod.PLSBind: confidence = 90; break; case PredictMethod.Integrate: itgResult = s.ResultObj.GetResult <List <IntegrateResultItem> >(); break; } foreach (var c in cmps) { var item = t.Datas.Where(d => d.Name == c.Name).FirstOrDefault(); if (item != null) { item.Value = c.PredictedValue; if (s.ResultObj.MethodType == PredictMethod.Integrate) { var itgitem = itgResult.Where(d => d.Comp.Name == c.Name).FirstOrDefault(); if (itgResult != null) { item.Confidence = itgitem.ConfidenceOutter; } } else { item.Confidence = confidence; } } } } }
public List <PropertyTable> GetData(Specs s, BindModel predictor) { using (var db = new NIRCeneterEntities()) { var r = s.OilData; if (r != null) { return(r); } if (s == null || s.ResultObj == null) { return(null); } var pr = s.ResultObj; if (s.ResultObj.MethodType == PredictMethod.Integrate && predictor != null) { var papi = predictor.PredictForAPI(s.Spec, true); if (papi.MethodType == PredictMethod.Fitting || papi.MethodType == PredictMethod.Identify) { pr = papi; } } r = Serialize.DeepClone <List <PropertyTable> >(this._initP); OilInfoBEntity oil = null; switch (pr.MethodType) { case NIR.Models.PredictMethod.Identify: oil = getByName(s, pr, ref r); break; case NIR.Models.PredictMethod.Fitting: oil = getByRate(s, pr, ref r); break; case NIR.Models.PredictMethod.PLSBind: oil = getByProperties(s, pr, ref r); break; default: break; } GetNIRData(s, oil, ref r); if (oil != null) { r = r.OrderBy(d => (int)d.Table).ToList(); db.OilData.AddObject(new OilData() { SID = s.ID, Data = Serialize.ObjectToByte(r) }); db.SaveChanges(); } else { foreach (var t in r) { foreach (var dd in t.Datas) { if (dd.Value == 0) { dd.Value = double.NaN; } } } } return(r); } }
/// <summary> /// B库数据导入功能 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void toolStripBtnIn_Click(object sender, EventArgs e) { this.dgvLibBIn.EndEdit(); OilInfoBAccess oilInfoBccess = new OilInfoBAccess(); //从B库进行原油查找 LibManageBll libManageBll = new LibManageBll(); //导入B库管理 string alert = "未导入的原油:"; foreach (DataGridViewRow row in this.dgvLibBIn.Rows) { if (bool.Parse(row.Cells["select"].Value.ToString()) == true) { int oilInfoId = int.Parse(row.Cells["ID"].Value.ToString()); OilInfoOut oilInfoOut = this._outLib.oilInfoOuts.Where(c => c.ID == oilInfoId).FirstOrDefault();//从库文件中获取数据 OilInfoBEntity oilInfoBEntity = new OilInfoBEntity(); libManageBll.toOilInfoEntity(ref oilInfoBEntity, oilInfoOut); //转换为OilInfoBEntity oilInfoBEntity.ID = OilBll.saveInfo(oilInfoBEntity); //将数据保存到原油应用模块 if (oilInfoBEntity.ID == -1) //原油已存在,提示是否更新数据 { DialogResult r = MessageBox.Show(oilInfoBEntity.crudeIndex + "原油已存在!是否要更新", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (r == DialogResult.Yes) { oilInfoBccess.Delete("crudeIndex='" + oilInfoBEntity.crudeIndex + "'"); //删除原油信息数据 oilInfoBEntity.ID = OilBll.save(oilInfoBEntity); //重新插入原油信息 libManageBll.toOilDatas(ref oilInfoBEntity, oilInfoOut, this._outLib.oilTableRows, this._outLib.oilTableCols); OilBll.saveTables(oilInfoBEntity); libManageBll.toOilDataSearchs(ref oilInfoBEntity, oilInfoOut); OilBll.saveSearchTable(oilInfoBEntity); libManageBll.toCurve(ref oilInfoBEntity, oilInfoOut.curves, _outLib.curveTypes); OilBll.saveCurves(oilInfoBEntity); if (this.ActiveMdiChild != null) { if (this.ActiveMdiChild.GetType().Name == "FrmMain")//如果打开窗体存在. { FrmMain frmMain = (FrmMain)this.ActiveMdiChild; if (frmMain != null) //如果打开原油库A的窗口存在,则更新 { frmMain.refreshGridList(); } } } MessageBox.Show(oilInfoBEntity.crudeName + "原油导入成功!"); } else { alert += oilInfoBEntity.crudeIndex + " "; MessageBox.Show(oilInfoBEntity.crudeName + "原油导入不成功!"); } } else//原油不存在 { try { libManageBll.toOilDatas(ref oilInfoBEntity, oilInfoOut, this._outLib.oilTableRows, this._outLib.oilTableCols); OilBll.saveTables(oilInfoBEntity); libManageBll.toOilDataSearchs(ref oilInfoBEntity, oilInfoOut); OilBll.saveSearchTable(oilInfoBEntity); libManageBll.toCurve(ref oilInfoBEntity, oilInfoOut.curves, _outLib.curveTypes); OilBll.saveCurves(oilInfoBEntity); if (this.ActiveMdiChild != null) { if (this.ActiveMdiChild.GetType().Name == "FrmMain")//如果打开窗体存在. { FrmMain frmMain = (FrmMain)this.ActiveMdiChild; if (frmMain != null) //如果打开原油库A的窗口存在,则更新 { frmMain.refreshGridList(); } } } MessageBox.Show(oilInfoBEntity.crudeName + "原油导入成功!"); } catch (Exception ex) { Log.Error("原油导入错误!" + ex.ToString()); MessageBox.Show(oilInfoBEntity.crudeName + "原油导入不成功!"); return; } } } } }
/// <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); }
/// <summary> /// 计算并输出计算结果到界面表格 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button4_Click(object sender, EventArgs e) { if (this._cutMotheds.Count <= 0 || this._cutOilRates.Count <= 0) { return; } try { this.StartWaiting(); this._oilB = oilApplyBll.GetCutResult(this._cutOilRates, this._cutMotheds); } catch (Exception ex) { Log.Error("原油切割错误:" + ex.ToString()); return; } finally { this.StopWaiting(); InitStep4(); this.panelStep4.Dock = DockStyle.Fill; this.panelStep4.Visible = true; this.toolStripStatusLabel.Text = "切割计算"; this.btnStep5.Enabled = true; } #region //ShowCutData newForm = new ShowCutData(this._oilB, this._cutMotheds); //newForm.Show(); //OilPropertyAPIEntity temp = new OilPropertyAPIEntity() //{ // D20 = 0.8612f, // CCR = 5.52f, // N2 = 1300f, // WAX = 3f, // SUL = 1.8f, // TWY140 = 15.44981f, // TWY180 = 22.57231f, // TWY240 = 32.58333f, // TWY350 = 51.37775f //}; //OilApplyAPIBll oilApplyAPIBll = new OilApplyAPIBll(); //CutMothedAPIEntity a = new CutMothedAPIEntity() //{ // ICP = 15, // ECP = 180, // Name = CutTableName.ShiNaoYou //}; //CutMothedAPIEntity b = new CutMothedAPIEntity() //{ // ICP = 140, // ECP = 240, // Name = CutTableName.MeiYou //}; //CutMothedAPIEntity c = new CutMothedAPIEntity() //{ // ICP = 180, // ECP = 350, // Name = CutTableName.ChaiYou //}; //CutMothedAPIEntity d = new CutMothedAPIEntity() //{ // ICP = 350, // ECP = 540, // Name = CutTableName.LaYou //}; ////CutMothedAPIEntity f = new CutMothedAPIEntity() ////{ //// ICP = 350, //// ECP = 1600, //// Name = CutTableName.YuanYouXingZhi ////}; //CutMothedAPIEntity g = new CutMothedAPIEntity() //{ // ICP = 540, // ECP = 1600, // Name = CutTableName.ZhaYou //}; //List<CutMothedAPIEntity> l = new List<CutMothedAPIEntity>(); //l.Add(a); //l.Add(b); //l.Add(c); //l.Add(d); ////l.Add(f); //l.Add(g); //List<CutMothedEntity> cutMothedList = new List<CutMothedEntity>(); //for (int index = 0; index < l.Count; index++) //{ // CutMothedEntity cutMothed = new CutMothedEntity(); // cutMothed.ICP = l[index].ICP; // cutMothed.ECP = l[index].ECP; // cutMothed.Name = l[index].Name.GetDescription(); // cutMothedList.Add(cutMothed); //} //List<string> crudeIndexList = new List<string>() { "RIPP0337", "RIPP0044", "RIPP0277", "RIPP0113", "RIPP0206", "RIPP0405" }; //List<float> cutRateList = new List<float>() { 81.56557f, 11.75237f, 2.040833f, 2.034374f, 1.848026f, 0.7588176f }; //List<CutOilRateEntity> rateList = new List<CutOilRateEntity>(); //for (int i = 0; i < crudeIndexList.Count; i++) //{ // CutOilRateEntity cutRateEntity = new CutOilRateEntity(); // cutRateEntity.crudeIndex = crudeIndexList[i]; // cutRateEntity.rate = cutRateList[i]; // rateList.Add(cutRateEntity); //} //this._oil = oilApplyAPIBll.GetCutResultAPI("RIPP0305 ", l); ////this._oil = oilApplyAPIBll.GetCutResultAPI(rateList, l); ////this._oil = oilApplyAPIBll.GetCutResultAPI(temp, l); ////ShowCutData newForm = new ShowCutData(this._oil, this._cutMotheds); //ShowCutData newForm = new ShowCutData(this._oil, cutMothedList); //newForm.Show(); #endregion }
/// <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); }
/// <summary> /// 接口方式一 /// </summary> /// <param name="crudeIndex">原油编号</param> /// <param name="cutMotheds">定制切割方案</param> /// <returns>原油数据</returns> public OilInfoBEntity GetCutResultAPI(string crudeIndex, List <CutMothedAPIEntity> cutMotheds) { if (string.IsNullOrWhiteSpace(crudeIndex)) { return(null); } if (cutMotheds.Count <= 0) { return(null); } 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); } OilApplyBll oilApplyBll = new OilApplyBll(); OilInfoBEntity oilB = oilApplyBll.GetCutResult(crudeIndex, 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); return(oilB); }
/// <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); }
/// <summary> /// 生成C库 /// </summary> public override void newC() { string strID = this.gridList.CurrentRow.Cells["ID"].Value.ToString(); string crudeIndex = this.gridList.CurrentRow.Cells["原油编号"].Value.ToString(); int ID = 0; if (int.TryParse(strID, out ID)) { OilDataSearchAccess dataSearchAccess = new OilDataSearchAccess(); List <OilDataSearchEntity> dataList = dataSearchAccess.Get("oilInfoID =" + ID).ToList(); if (dataList.Count > 0) { DialogResult r = MessageBox.Show("原油" + crudeIndex + "的查询库数据已经存在是否替换?", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (r == DialogResult.Yes) { dataSearchAccess.deleteData("Delete from OilDataSearch where oilInfoID =" + ID); OilInfoBEntity oilB = OilBll.GetOilByCrudeIndex(crudeIndex); OilInfoEntity oilA = OilBll.GetOilById(crudeIndex); if (oilA == null) { OilBll.SaveC(oilB); } else { OilBll.SaveC(oilA, oilB); } MessageBox.Show("原油" + crudeIndex + "生成查询库成功!", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information); FrmMain frmMain = this.MdiParent as FrmMain; DatabaseC.FrmOilDataC child = (DatabaseC.FrmOilDataC)frmMain.GetChildFrm(crudeIndex + "C"); if (child != null) { MessageBox.Show("原油" + crudeIndex + "的数据窗体需关闭重新打开才有效!", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information); } } } else { DialogResult r = MessageBox.Show("是否保存数据到快速查询库!", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (r == DialogResult.Yes) { dataSearchAccess.deleteData("Delete from OilDataSearch where oilInfoID =" + ID); OilInfoBEntity oilB = OilBll.GetOilByCrudeIndex(crudeIndex); OilInfoEntity oilA = OilBll.GetOilById(crudeIndex); if (oilA == null) { OilBll.SaveC(oilB); } else { OilBll.SaveC(oilA, oilB); } MessageBox.Show("原油" + crudeIndex + "生成查询库成功!", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information); FrmMain frmMain = this.MdiParent as FrmMain; DatabaseC.FrmOilDataC child = (DatabaseC.FrmOilDataC)frmMain.GetChildFrm(crudeIndex + "C"); if (child != null) { MessageBox.Show("原油" + crudeIndex + "的数据窗体需关闭重新打开才有效!", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information); } } } } else { MessageBox.Show("应用库无此条原油!", "警告信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
/// <summary> /// 导入到B库 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void toolStripBtnIn_Click(object sender, EventArgs e) { this.gridList.EndEdit(); OilInfoBAccess oilInfoAccess = new OilInfoBAccess(); LibManageBll libManageBll = new LibManageBll(); string alert = "未导入的原油:"; foreach (DataGridViewRow row in this.gridList.Rows) { if (bool.Parse(row.Cells["select"].Value.ToString()) == true) { int oilInfoId = int.Parse(row.Cells["ID"].Value.ToString()); OilInfoOut oilInfoOut = this._outLib.oilInfoOuts.Where(c => c.ID == oilInfoId).FirstOrDefault(); OilInfoBEntity oilInfoBEntity = new OilInfoBEntity(); libManageBll.toOilInfoEntity(ref oilInfoBEntity, oilInfoOut); //转换为OilInfoEntity oilInfoBEntity.ID = OilBll.saveInfo(oilInfoBEntity); if (oilInfoBEntity.ID == -1) { try { #region "原油冲突" DialogResult r = MessageBox.Show(oilInfoBEntity.crudeIndex + "原油已存在!是否要更新", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (r == DialogResult.Yes) { oilInfoAccess.Delete("crudeIndex='" + oilInfoBEntity.crudeIndex + "'"); //删除原油信息数据 oilInfoBEntity.ID = OilBll.save(oilInfoBEntity); //重新插入原油信息 libManageBll.toOilDatas(ref oilInfoBEntity, oilInfoOut, this._outLib.oilTableRows, this._outLib.oilTableCols); OilBll.saveTables(oilInfoBEntity); libManageBll.toCurve(ref oilInfoBEntity, oilInfoOut.curves, _outLib.curveTypes); OilBll.saveCurves(oilInfoBEntity); libManageBll.toOilDataSearchs(ref oilInfoBEntity, oilInfoOut); OilBll.saveSearchTable(oilInfoBEntity.OilDataSearchs); DatabaseB.FrmOpenB frmOpenB = (DatabaseB.FrmOpenB)GetChildFrm("frmOpenB"); if (frmOpenB != null) //如果打开原油库B的窗口存在,则更新 { frmOpenB.refreshGridList(false); } DatabaseC.FrmOpenC frmOpenC = (DatabaseC.FrmOpenC)GetChildFrm("frmOpenC"); if (frmOpenC != null) //如果打开原油库C的窗口存在,则更新 { frmOpenC.refreshGridList(); } } else { alert += oilInfoBEntity.crudeIndex + " "; } #endregion } catch (Exception ex) { Log.Error("原油导入错误!" + ex.ToString()); return; } MessageBox.Show(oilInfoBEntity.crudeName + "原油导入成功!"); } else { #region "原油无冲突" try { libManageBll.toOilDatas(ref oilInfoBEntity, oilInfoOut, this._outLib.oilTableRows, this._outLib.oilTableCols); OilBll.saveTables(oilInfoBEntity); libManageBll.toCurve(ref oilInfoBEntity, oilInfoOut.curves, _outLib.curveTypes); OilBll.saveCurves(oilInfoBEntity); libManageBll.toOilDataSearchs(ref oilInfoBEntity, oilInfoOut); OilBll.saveSearchTable(oilInfoBEntity.OilDataSearchs); DatabaseB.FrmOpenB frmOpenB = (DatabaseB.FrmOpenB)GetChildFrm("frmOpenB"); if (frmOpenB != null) //如果打开原油库A的窗口存在,则更新 { frmOpenB.refreshGridList(false); } } catch (Exception ex) { Log.Error("原油导入错误!" + ex.ToString()); return; } MessageBox.Show(oilInfoBEntity.crudeName + "原油导入成功!"); #endregion } } } }