private void button1_Click(object sender, EventArgs e) { CutOilRateEntity cutOilRate = new CutOilRateEntity(); cutOilRate.crudeIndex = "test原油1"; cutOilRate.rate = 100; _cutOilRates.Add(cutOilRate); CutMothedEntity cutMothed = new CutMothedEntity(200, 300, "Cut1"); _cutMotheds.Add(cutMothed); DateTime start = DateTime.Now; OilApplyBll oilApplyBll = new OilApplyBll(); oilApplyBll.GetCutResult(_cutOilRates, _cutMotheds); DateTime end = DateTime.Now; TimeSpan a = end.Subtract(start); this.label7.Text = a.TotalMilliseconds.ToString() + "毫秒"; }
/// <summary> /// 获取切割方案 /// </summary> private bool getCutMotheds() { List <string> NameList = new List <string>(); foreach (DataGridViewRow row in this.gridListCut.Rows) { CutMothedEntity cutMothed = new CutMothedEntity(); #region "条件判断" object objICP = row.Cells["ICP"].Value; object objECP = row.Cells["ECP"].Value; object objName = row.Cells["Name"].Value; object objCutType = row.Cells["CutType"].Value; float tempICP = 0; float tempECP = 0; string strName = string.Empty; string strCutType = string.Empty; if (objICP == null && objECP == null && objName == null) { return(true); } if (objICP == null && objECP == null) { MessageBox.Show("馏分段数据不能为空!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } if (objName == null) { MessageBox.Show("馏分段名称不能为空!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } if (objICP != null) { if (float.TryParse(objICP.ToString(), out tempICP)) { //MessageBox.Show(row.Cells["馏分段名称"].Value.ToString() + "馏分段的初馏点为不正常数据!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information); //return; } else { MessageBox.Show(objName.ToString() + "馏分段的初留点为非数据!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } } else { //if (this._frmMain.Oil.ICP0 != string.Empty) //tempICP = Convert.ToSingle (this._frmMain.Oil.ICP0); tempICP = -2000; } if (objECP != null) { if (float.TryParse(objECP.ToString(), out tempECP)) { //MessageBox.Show(row.Cells["馏分段名称"].Value.ToString() + "馏分段的初馏点为不正常数据!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information); //return; } else { MessageBox.Show(objName.ToString() + "馏分段的终留点为非数据!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } } else { tempECP = 2000; } #endregion if (tempICP >= tempECP) { MessageBox.Show("终馏点的值应大于初馏点的值", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } if (NameList.Contains(objName.ToString())) { MessageBox.Show("馏分段名称不能重复", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } else if (!NameList.Contains(objName.ToString()) && tempICP < tempECP) { NameList.Add(objName.ToString()); cutMothed.ICP = tempICP; cutMothed.ECP = tempECP; cutMothed.Name = objName.ToString(); cutMothed.CutType = objCutType == null ? string.Empty : objCutType.ToString(); this._CutMotheds.Add(cutMothed); } } return(true); }
/// <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> /// <returns></returns> private static List <CutMothedEntity> OilSearchCutMothed() { List <CutMothedEntity> cutMothedEntityList = new List <CutMothedEntity>(); #region CutMothedEntity cutMethedEntity1 = new CutMothedEntity() { ICP = 15, ECP = 140, Name = "15-140馏分(石脑油)" }; CutMothedEntity cutMethedEntity2 = new CutMothedEntity() { ICP = 15, ECP = 180, Name = "15-180馏分(石脑油)" }; CutMothedEntity cutMethedEntity3 = new CutMothedEntity() { ICP = 140, ECP = 240, Name = "140-240馏分(航煤)" }; CutMothedEntity cutMethedEntity4 = new CutMothedEntity() { ICP = 180, ECP = 350, Name = "180-350馏分(柴油)" }; CutMothedEntity cutMethedEntity5 = new CutMothedEntity() { ICP = 240, ECP = 350, Name = "240-350馏分(柴油)" }; CutMothedEntity cutMethedEntity6 = new CutMothedEntity() { ICP = 350, ECP = 540, Name = "350-540馏分(VGO)" }; CutMothedEntity cutMethedEntity7 = new CutMothedEntity() { ICP = 350, ECP = 2000, Name = ">350(常渣)" }; CutMothedEntity cutMethedEntity8 = new CutMothedEntity() { ICP = 540, ECP = 2000, Name = ">540(减渣)" }; cutMothedEntityList.Add(cutMethedEntity1); cutMothedEntityList.Add(cutMethedEntity2); cutMothedEntityList.Add(cutMethedEntity3); cutMothedEntityList.Add(cutMethedEntity4); cutMothedEntityList.Add(cutMethedEntity5); cutMothedEntityList.Add(cutMethedEntity6); cutMothedEntityList.Add(cutMethedEntity7); cutMothedEntityList.Add(cutMethedEntity8); #endregion return(cutMothedEntityList); }
/// <summary> /// 初始化普通切割曲线数据 /// </summary> /// <param name="dataGridView"></param> /// <param name="Datas"></param> private void initData(DataGridView dataGridView, List <ShowCurveEntity> showCurves, IList <CutMothedEntity> cutMotheds) { if (showCurves == null) { return; } #region "设置列实体 " Dictionary <string, int> rowIDDic = new Dictionary <string, int>(); //表的行和oiltableRowID对应 int rowID = 0; //设置行ID=0 foreach (var temp in showCurves) { if (!rowIDDic.Keys.Contains(temp.PropertyY)) { rowIDDic.Add(temp.PropertyY, rowID); rowID++; } } #endregion Dictionary <string, string> rowDic = new Dictionary <string, string>(); #region "初列:序号、项目、代码" dataGridView.ReadOnly = true; dataGridView.Columns.Clear(); DataGridViewTextBoxColumn colID = new DataGridViewTextBoxColumn() { Name = "序号", AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells, ReadOnly = true }; DataGridViewTextBoxColumn Code = new DataGridViewTextBoxColumn() { Name = "代码", AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells, ReadOnly = true }; DataGridViewTextBoxColumn Name = new DataGridViewTextBoxColumn() { Name = "名称", AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells, ReadOnly = true }; dataGridView.Columns.Add(colID); dataGridView.Columns.Add(Code); dataGridView.Columns.Add(Name); rowDic.Add("序号", null); rowDic.Add("代码", null); rowDic.Add("名称", null); foreach (var temp in cutMotheds) { DataGridViewTextBoxColumn column = new DataGridViewTextBoxColumn { HeaderText = temp.Name, Name = temp.Name, Tag = temp.Name }; dataGridView.Columns.Add(column); rowDic.Add(temp.Name, string.Empty); } #endregion #region "初始化所有行" dataGridView.Rows.Clear(); List <string> KeyList = rowDic.Keys.ToList(); foreach (string strKey in KeyList) { if (strKey.Equals("序号")) { rowDic[strKey] = "0"; } else if (strKey.Equals("代码")) { rowDic[strKey] = "ICP"; } else if (strKey.Equals("名称")) { rowDic[strKey] = "初切点"; } else { CutMothedEntity cutMothed = cutMotheds.Where(o => o.Name == strKey).FirstOrDefault(); rowDic[strKey] = cutMothed.ICP == -2000 ? string.Empty : cutMothed.ICP.ToString(); } } dataGridView.Rows.Add(rowDic.Values.ToArray()); foreach (string strKey in KeyList) { if (strKey.Equals("序号")) { rowDic[strKey] = "1"; } else if (strKey.Equals("代码")) { rowDic[strKey] = "ECP"; } else if (strKey.Equals("名称")) { rowDic[strKey] = "终切点"; } else { CutMothedEntity cutMothed = cutMotheds.Where(o => o.Name == strKey).FirstOrDefault(); rowDic[strKey] = cutMothed.ECP == 2000 ? string.Empty : cutMothed.ECP.ToString(); } } dataGridView.Rows.Add(rowDic.Values.ToArray()); #endregion #region "赋值" for (int i = 0; i < showCurves.Count; i++) { foreach (string strKey in KeyList) { if (strKey.Equals("序号")) { rowDic[strKey] = (i + 2).ToString(); } else if (strKey.Equals("代码")) { rowDic[strKey] = showCurves[i].PropertyY; } else if (strKey.Equals("名称")) { rowDic[strKey] = showCurves[i].ItemName; } else { CutDataEntity cutData = showCurves[i].CutDatas.Where(o => o.CutName == strKey).FirstOrDefault(); rowDic[strKey] = cutData == null ? string.Empty : cutData.ShowCutData; } } dataGridView.Rows.Add(rowDic.Values.ToArray()); } #endregion }