/// <summary> /// 根据列索引,获取该列的全部数据 /// </summary> /// <param name="columnIndex"></param> /// <returns></returns> public List <OilDataEntity> GetDataByColumnIndex(int columnIndex) { List <OilDataEntity> ls = new List <OilDataEntity>(); if (_rows == null || _cols == null || _rows.Count == 0 || _cols.Count == 0 || columnIndex < 0 || columnIndex >= columnList.Count) { return(ls); } var column = columnList[columnIndex]; for (int rowIndex = 0; rowIndex < RowCount; rowIndex++) { var row = _rows[rowIndex]; var col = _cols[columnIndex]; OilDataEntity data = null; data = new OilDataEntity(); data.RowIndex = rowIndex; data.ColumnIndex = columnIndex; data.oilInfoID = Oil.ID; data.OilTableCol = col; data.oilTableColID = col.ID; data.OilTableRow = row; data.oilTableRowID = row.ID; ls.Add(data); } return(ls); }
/// <summary> /// 根据行编码和列号,获取单元格数据 /// </summary> /// <param name="rowItemCode"></param> /// <param name="columnIndex"></param> /// <returns></returns> public OilDataEntity GetDataByRowItemCodeColumnIndex(string rowItemCode, int columnIndex) { if (string.IsNullOrWhiteSpace(rowItemCode) || _rows == null || _cols == null || _rows.Count == 0 || _cols.Count == 0 || columnIndex < 0 || columnIndex >= _cols.Count) { return(null); } var row = _rows.FirstOrDefault(o => o.itemCode == rowItemCode); if (row == null) { return(null); } int rowIndex = _rows.IndexOf(row); var column = columnList[columnIndex]; var col = _cols[columnIndex]; OilDataEntity data = null; data = new OilDataEntity(); data.RowIndex = rowIndex; data.ColumnIndex = columnIndex; data.oilInfoID = Oil.ID; data.OilTableCol = col; data.oilTableColID = col.ID; data.OilTableRow = row; data.oilTableRowID = row.ID; return(data); }
/// <summary> /// /// </summary> /// <returns></returns> private List <OilDataEntity> GetComboBoxDropItems() { #region "数据筛选" List <OilDataEntity> DropList = new List <OilDataEntity>();//制作下拉菜单数据列 List <OilDataEntity> residueOilDataList = this._residueGridOil.GetAllData(); if (residueOilDataList.Count <= 0) { return(DropList); } List <OilDataEntity> oilDataList = residueOilDataList.Where(o => o.calData != string.Empty).ToList(); List <OilDataEntity> ICPOilDataList = oilDataList.Where(o => o.OilTableRow.itemCode == "ICP").ToList(); foreach (OilDataEntity oilDataICP in ICPOilDataList) { string ICP = oilDataICP == null ? "" : oilDataICP.calData;; if (ICP != string.Empty) { OilDataEntity temp = new OilDataEntity(); temp.calData = ICP; temp.ColumnIndex = oilDataICP.ColumnIndex; DropList.Add(temp); } } #endregion return(DropList); }
/// <summary> /// 通过宽馏分的ICP和ECP在窄馏分中查找对应的两个ICP和ECP列,并且找出指定物性的累积和(不允许存在空值) /// </summary> /// <param name="strICP">宽馏分的ICP</param> /// <param name="strECP">宽馏分的ECP</param> /// <param name="itemCode">计算的物性</param> /// <returns>宽馏分中查找对应的两个ICP和ECP列,并且返回指定物性的累积和 ,SUM_POR、 SUM_WY</returns> public static Dictionary <string, float> getItemCodeCumuationValueAllowEmptyFromResidue(GridOilViewA residueGridOil, string strICP, string itemCode) { float SUM_POR = 0; //定义返回变量的两个值 Dictionary <string, float> ReturnDic = new Dictionary <string, float>(); #region "输入判断" if (strICP == string.Empty || itemCode == string.Empty)//不存在此行则返回空 { return(ReturnDic); } List <OilDataEntity> ICPList = residueGridOil.GetDataByRowItemCode("ICP").Where(o => o.calShowData == strICP).ToList(); List <OilDataEntity> WYList = residueGridOil.GetDataByRowItemCode("WY").Where(o => o.calData != string.Empty).ToList(); List <OilDataEntity> itemCodeList = residueGridOil.GetDataByRowItemCode(itemCode).Where(o => o.calData != string.Empty).ToList(); if (ICPList == null || WYList == null) { return(ReturnDic); } if (ICPList.Count <= 0 || WYList.Count <= 0) { return(ReturnDic); } #endregion #region "计算SUM_POR = 0; float SUM_WY = 0" foreach (OilDataEntity ICP in ICPList) { OilDataEntity oilDataWY = WYList.Where(o => o.OilTableCol.colCode == ICP.OilTableCol.colCode).FirstOrDefault(); float wyCal = 0; if (oilDataWY != null && float.TryParse(oilDataWY.calData, out wyCal)) { ReturnDic.Add("WY", wyCal); } if (itemCodeList == null) { continue; } OilDataEntity oilDataItemCode = itemCodeList.Where(o => o.OilTableCol.colCode == ICP.OilTableCol.colCode).FirstOrDefault(); if (oilDataWY != null && oilDataItemCode != null && float.TryParse(oilDataWY.calData, out wyCal)) { string strTemp = BaseFunction.IndexFunItemCode(oilDataItemCode.calData, itemCode); float fTtemp = 0; if (strTemp != string.Empty && float.TryParse(strTemp, out fTtemp)) { SUM_POR = wyCal * fTtemp; ReturnDic.Add(itemCode, SUM_POR); break; } } } #endregion return(ReturnDic); }
/// <summary> /// 宽馏分中查找对应ICP和ECP,并且找出指定物性的值(允许存在空值) /// </summary> /// <param name="wideGridOil">宽馏分表</param> /// <param name="strICP">宽馏分的ICP</param> /// <param name="strECP">宽馏分的ECP</param> /// <param name="itemCode">计算的物性</param> /// <returns>宽馏分中查找对应的两个ICP和ECP列,并且返回指定物性值 ,itemCode</returns> public static Dictionary <string, float> getWYVYCumuationValueAllowEmptyFromWide(GridOilViewA wideGridOil, string strICP, string strECP, string itemCode) { Dictionary <string, float> ReturnDic = new Dictionary <string, float>(); #region "输入条件判断" if (strICP == string.Empty || strECP == string.Empty || itemCode == string.Empty)//不存在此行则返回空 { return(ReturnDic); } List <OilDataEntity> ICPList = wideGridOil.GetDataByRowItemCode("ICP").Where(o => o.calShowData == strICP).ToList(); List <OilDataEntity> ECPList = wideGridOil.GetDataByRowItemCode("ECP").Where(o => o.calShowData == strECP).ToList(); if (ICPList == null || ECPList == null)//如果ICP和ECP数据不存在则返回空 { MessageBox.Show("找不到初切点为" + strICP + "终切点" + strECP + "对应的馏分!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(ReturnDic); } if (ICPList.Count <= 0 || ECPList.Count <= 0)//如果ICP和ECP数据不存在则返回空 { MessageBox.Show("找不到初切点为" + strICP + "终切点" + strECP + "对应的馏分!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(ReturnDic); } List <OilDataEntity> itemCodeList = wideGridOil.GetDataByRowItemCode(itemCode).Where(o => o.calData != string.Empty).ToList(); if (itemCodeList == null)//如果查找的数据不存在则返回空 { return(ReturnDic); } #endregion #region "ICP--ECP" foreach (OilDataEntity ICPData in ICPList) { OilDataEntity ECPData = ECPList.Where(o => o.OilTableCol.colOrder == ICPData.OilTableCol.colOrder).FirstOrDefault(); if (ECPData == null) { continue; } OilDataEntity oilDataItemCode = itemCodeList.Where(o => o.OilTableCol.colOrder == ICPData.OilTableCol.colOrder).FirstOrDefault(); if (oilDataItemCode == null) { continue; } float itemCodeCal = 0; if (oilDataItemCode.calShowData != string.Empty && float.TryParse(oilDataItemCode.calData, out itemCodeCal)) { ReturnDic.Add(itemCode, itemCodeCal); break; } } #endregion return(ReturnDic); }
/// <summary> /// 通过宽馏分的ICP和ECP在窄馏分中查找对应的两个ICP和ECP列,并且找出指定物性的累积和(不允许存在空值) /// </summary> /// <param name="strICP">宽馏分的ICP</param> /// <param name="strECP">宽馏分的ECP</param> /// <param name="strItemCode">计算的物性</param> /// <returns>宽馏分中查找对应的两个ICP和ECP列,并且返回指定物性的累积和 ,SUM_POR、 SUM_WY</returns> public static Dictionary <string, float> getWYVYCumuationValueNotAllowEmptyFromResidue(GridOilViewA residueGridOil, string strICP, string itemCode) { Dictionary <string, float> ReturnDic = new Dictionary <string, float>(); #region "输入判断" if (strICP == string.Empty || itemCode == string.Empty)//不存在此行则返回空 { return(ReturnDic); } List <OilDataEntity> ICPList = residueGridOil.GetDataByRowItemCode("ICP").Where(o => o.calShowData == strICP).ToList(); if (ICPList == null)//如果查找的数据不存在则返回空 { MessageBox.Show("找不到初切点为" + strICP + "的渣油!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(ReturnDic); } if (ICPList.Count <= 0)//如果查找的数据不存在则返回空 { MessageBox.Show("找不到初切点为" + strICP + "的渣油!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(ReturnDic); } List <OilDataEntity> ItemCodeoDatas = residueGridOil.GetDataByRowItemCode(itemCode).Where(o => o.calData != string.Empty).ToList(); if (ItemCodeoDatas == null)//如果查找的数据不存在则返回空 { return(ReturnDic); } #endregion #region "计算SUM_POR = 0; float SUM_WY = 0" foreach (OilDataEntity ICP in ICPList) { OilDataEntity oilDataItemCode = ItemCodeoDatas.Where(o => o.OilTableCol.colCode == ICP.OilTableCol.colCode).FirstOrDefault(); if (oilDataItemCode == null) { continue;//计算过程不能为空,为空则跳出 } else { float wyCal = 0; if (float.TryParse(oilDataItemCode.calData, out wyCal)) { ReturnDic.Add(itemCode, wyCal); break; } else { continue; } } } #endregion return(ReturnDic); }
private void button2_Click(object sender, EventArgs e) { int num = Convert.ToInt32(txbNum2.Text); int rep = Convert.ToInt32(txbRep2.Text); this.button2.Text = "Working"; this.button2.Enabled = false; ThreadStart start2 = () => { OilInfoAccess oc = new OilInfoAccess(); var oil = new OilInfoEntity() { crudeIndex = DateTime.Now.ToString("yyyyMMddHHmmssfff"), crudeName = DateTime.Now.ToString("yyyyMMddHHmmssfff") }; oil.ID = oc.Insert(oil); for (int i = 0; i < num; i++) { var item = new OilDataEntity() { calData = RIPP.Lib.Security.SecurityTool.MyEncrypt(i.ToString()), labData = i.ToString(), oilInfoID = oil.ID, oilTableColID = i, oilTableRowID = i }; oil.OilDatas.Add(item); } OilBll.saveTables(oil); this.richTextBox2.AppendText(string.Format("已经插入一条原油数据到数据库 {0}\n", DateTime.Now.ToString())); double[] r = new double[rep]; for (int k = 0; k < rep; k++) { DateTime dt = DateTime.Now; var ooo = OilBll.GetOilById(oil.ID); foreach (var d in ooo.OilDatas) { var ssss = RIPP.Lib.Security.SecurityTool.MyDecrypt(d.calData); } r[k] = (DateTime.Now - dt).TotalMilliseconds; } for (int k = 0; k < rep; k++) { this.richTextBox2.AppendText(string.Format("读取并解密 {0} 条, 第 {2} 次花费 {1} ms \n", num, r[k], k + 1)); } this.button2.Text = "Run"; this.button2.Enabled = true; this.richTextBox2.AppendText("\n"); }; this.Invoke(start2); }
/// <summary> /// 胶质、沥青质 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void comboBox3_SelectedIndexChanged(object sender, EventArgs e) { OilDataEntity temp = (OilDataEntity)this.comboBox3.SelectedItem; if (temp != null) { GlobalResiduDataSupplementDialog._APHDrop = temp.ColumnIndex; } }
protected override void OnTableLayoutInitialized() { base.OnTableLayoutInitialized(); if (columnList == null || columnList.Count == 0) { return; } var column = columnList[0]; var columnIndex = column.LabColumn.Index; for (int i = 0; i < columnIndex; i++) { Columns[i].Visible = false; } column.LabColumn.ReadOnly = true; column.LabColumn.HeaderText = "X"; column.LabColumn.Width = 100; column.CalcColumn.HeaderText = "Y"; column.CalcColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet; column.CalcColumn.Width = 100; //if (_datas == null) // _datas = new List<OilDataEntity>(); ////_datas.Clear(); var ls = new List <OilDataEntity>(); for (int i = 0; i < RowCount; i++) { var cell = _datas.FirstOrDefault(o => o.RowIndex == i && o.ColumnIndex == 0); if (cell == null) { cell = new OilDataEntity() { ColumnIndex = 0, RowIndex = i, }; ls.Add(cell); } cell.labData = i.ToString(); } SetData(ls, GridOilColumnType.Lab, false); if (_datas != null && _rows != null) { for (int i = 0; i < _rows.Count; i++) { var row = _rows[i]; var cell = _datas.FirstOrDefault(o => o.oilTableRowID == row.ID && o.oilTableColID == column.ColumnEntity.ID); if (cell != null) { cell.labData = i.ToString(); } } } }
private void button2_Click(object sender, EventArgs e) { int num = Convert.ToInt32(txtNum2.Text); int rep = Convert.ToInt32(txtRep2.Text); //先搞一条原油数据 OilInfoAccess oc = new OilInfoAccess(); this.button2.Text = "Working"; this.button2.Enabled = false; ThreadStart start2 = () => { double[] r = new double[rep]; for (int k = 0; k < rep; k++) { var oil = new OilInfoEntity() { crudeIndex = DateTime.Now.ToString("yyyyMMddHHmmssfff"), crudeName = DateTime.Now.ToString("yyyyMMddHHmmssfff") }; oil.ID = oc.Insert(oil); DateTime dt = DateTime.Now; for (int i = 0; i < num; i++) { var item = new OilDataEntity() { calData = i.ToString(), labData = i.ToString(), oilInfoID = oil.ID, oilTableColID = i, oilTableRowID = i }; oil.OilDatas.Add(item); } OilBll.saveTables(oil); r[k] = (DateTime.Now - dt).TotalMilliseconds; } for (int k = 0; k < rep; k++) { this.richTextBox2.AppendText(string.Format("插入 {0} 条, 第 {2} 次花费 {1} ms \n", num, r[k], k + 1)); } this.button2.Text = "Run"; this.button2.Enabled = true; this.richTextBox2.AppendText("\n"); }; this.Invoke(start2); }
/// <summary> /// 确定 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { if (this.radioButton1.Checked) { GlobalLightDialog.YesNo = System.Windows.Forms.DialogResult.Yes; OilDataEntity WYOilData = this._NarrowGridOil.GetDataByRowItemCodeColumnIndex("WY", 0); string strWY = WYOilData == null ? string.Empty : WYOilData.calData; float tempWY = 0; if (strWY != string.Empty) { if (float.TryParse(strWY, out tempWY)) { GlobalLightDialog.LightWY = tempWY; } } } else if (this.radioButton2.Checked) { GlobalLightDialog.YesNo = System.Windows.Forms.DialogResult.No; float tempWY = 0; if (this.textBox1.Text != string.Empty) { if (float.TryParse(this.textBox1.Text, out tempWY)) { if (tempWY > 100 || tempWY < 0) { MessageBox.Show("轻端的质量收率必须在0到100之间"); this.textBox1.Focus(); return; } else { GlobalLightDialog.LightWY = tempWY; } } } else { MessageBox.Show("请输入轻端的质量收率"); this.textBox1.Focus(); return; } } //this.Close(); }
/// <summary> /// 获取表格数据 /// </summary> /// <returns></returns> public List <OilDataEntity> GetAllData() { if (_rows == null || _cols == null || _rows.Count == 0 || _cols.Count == 0) { return(new List <OilDataEntity>()); } IsBusy = true; try { int columnIndex = 0; _datas.Clear(); foreach (var column in columnList) { if (columnIndex >= _cols.Count) { continue; } var col = _cols[columnIndex]; for (int rowIndex = 0; rowIndex < RowCount && rowIndex < _rows.Count; rowIndex++) { var row = _rows[rowIndex]; OilDataEntity data = null; var cell = this[column.LabColumn.Index, rowIndex] as GridOilCellItem; data = new OilDataEntity(); data.RowIndex = rowIndex; data.ColumnIndex = columnIndex; data.oilInfoID = Oil.ID; data.OilTableCol = col; data.oilTableColID = col.ID; data.OilTableRow = row; data.oilTableRowID = row.ID; _datas.Add(data); } columnIndex++; } List <OilDataEntity> ls = new List <OilDataEntity>(_datas); return(ls); } finally { IsBusy = false; } }
/// <summary> /// 根据行编码获取行数据 /// </summary> /// <param name="rowItemCode"></param> /// <returns></returns> public List <OilDataEntity> GetDataByRowItemCode(string rowItemCode) { List <OilDataEntity> ls = new List <OilDataEntity>(); if (string.IsNullOrWhiteSpace(rowItemCode) || _rows == null || _cols == null || _rows.Count == 0 || _cols.Count == 0) { return(ls); } var row = _rows.FirstOrDefault(o => o.itemCode == rowItemCode); if (row == null) { return(ls); } int rowIndex = _rows.IndexOf(row); int columnIndex = 0; foreach (var column in columnList) { if (columnIndex >= _cols.Count) { continue; } var col = _cols[columnIndex]; OilDataEntity data = null; var cell = this[column.LabColumn.Index, rowIndex] as GridOilCellItem; data = new OilDataEntity(); data.RowIndex = rowIndex; data.ColumnIndex = columnIndex; data.oilInfoID = Oil.ID; data.OilTableCol = col; data.oilTableColID = col.ID; data.OilTableRow = row; data.oilTableRowID = row.ID; ls.Add(data); columnIndex++; } return(ls); }
/// <summary> /// 为OilInfoEntity的原油数据赋值 /// </summary> /// <param name="oilInfoEntity">OilInfoEntity实体</param> /// <param name="oilInfoOut">OilInfoOut</param> /// <param name="oilTableRows">OilInfoOut的行</param> /// <param name="oilTableCols">OilInfoOut的列</param> public void toOilDatas(ref OilInfoEntity oilInfoEntity, OilInfoOut oilInfoOut, List <OilTableRowOut> oilTableRows, List <OilTableColOut> oilTableCols) { OilTableRowBll rowBll = new OilTableRowBll(); OilTableColBll colBll = new OilTableColBll(); foreach (OilDataOut oilDataOut in oilInfoOut.oilDatas) //插入原油数据 { OilDataEntity oilData = new OilDataEntity(); 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"; 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); } } }
private List <OilDataEntity> GetComboBoxDropItems() { #region "数据筛选" List <OilDataEntity> dsWCT = _gdvWide.GetDataByRowItemCode("WCT").Where(o => o.calData == "石脑油" || o.calData == "重整料").ToList(); //原油类型 List <OilDataEntity> DropList = new List <OilDataEntity>(); //制作下拉菜单数据列 DropList.Add(new OilDataEntity() { ColumnIndex = -1, calData = "无" }); if (dsWCT != null)//下拉列表中添加石脑油 { foreach (OilDataEntity oildata in dsWCT) { OilDataEntity oilDataICP = _gdvWide.GetDataByRowItemCodeColumnIndex("ICP", oildata.ColumnIndex); OilDataEntity oilDataECP = _gdvWide.GetDataByRowItemCodeColumnIndex("ECP", oildata.ColumnIndex); string ICP = oilDataICP == null ? "" : oilDataICP.calData; string ECP = oilDataECP == null ? "" : oilDataECP.calData; var have = DropList.Exists(o => o.ColumnIndex == oildata.ColumnIndex); if (!have && ICP != string.Empty && ECP != string.Empty) { OilDataEntity temp = new OilDataEntity(); temp.calData = ICP + "-" + ECP; temp.ColumnIndex = oildata.ColumnIndex; DropList.Add(temp); } } } #endregion return(DropList); }
/// <summary> /// 窄馏分表趋势审查 /// </summary> /// <param name="tableType"></param> /// <param name="gridOil"></param> /// <returns></returns> private StringBuilder narrowTrendCheck(EnumTableType tableType, GridOilViewA gridOil) { StringBuilder sbAlert = new StringBuilder(); if (gridOil == null) { return(sbAlert); } int rowCount = gridOil.RowCount; int colCount = gridOil.ColumnCount; gridOil.ClearRemarkFlat(); List <OilTableRowEntity> rowList = gridOil.Oil.OilTableRows.Where(o => o.oilTableTypeID == (int)EnumTableType.Narrow && (o.trend == "+" || o.trend == "-")).ToList(); List <OilDataEntity> dataList = gridOil.GetAllData().Where(o => o.calData != string.Empty || o.labData != string.Empty).ToList(); if (rowList.Count <= 0 || dataList.Count <= 0) { return(sbAlert); } foreach (OilTableRowEntity row in rowList) { #region "MCP和其他物性的数据合并" List <OilDataEntity> MCPDataList = dataList.Where(o => o.OilTableRow.itemCode == "MCP" && o.calData != string.Empty).ToList(); //对数进行合并升序 List <OilDataEntity> ItemCodeDataList = dataList.Where(o => o.OilTableRow.itemCode == row.itemCode && o.calData != string.Empty).ToList(); //对数进行合并升序 if (ItemCodeDataList.Count <= 1 || MCPDataList.Count <= 1) { continue; } Dictionary <float, OilDataEntity> MCPDic = new Dictionary <float, OilDataEntity>(); //对ICP进行升序和数值变换 foreach (OilDataEntity MCPData in MCPDataList) //数据转换 { string strCal = MCPData.calData; float f_Cal = 0; if (float.TryParse(strCal, out f_Cal)) { if (!MCPDic.Keys.Contains(f_Cal)) { MCPDic.Add(f_Cal, MCPData);//数据转换后存储 } } } var temps = from item in MCPDic orderby item.Key select item.Value;//升序排序 MCPDataList.Clear(); MCPDataList = temps.ToList();//转换为列表形式 #endregion #region "对其他物性进行升序和数值变换" Dictionary <float, OilDataEntity> ItemCodeDic = new Dictionary <float, OilDataEntity>(); //对其他物性进行升序和数值变换 foreach (OilDataEntity MCPData in MCPDataList) //数据转换 { OilDataEntity itemCodeData = ItemCodeDataList.Where(o => o.oilTableColID == MCPData.oilTableColID).FirstOrDefault(); if (itemCodeData == null) { continue; } string strCal = itemCodeData.calData; float f_Cal = 0; if (float.TryParse(strCal, out f_Cal)) { if (!ItemCodeDic.Keys.Contains(f_Cal)) { ItemCodeDic.Add(f_Cal, itemCodeData);//数据转换后存储 } } } if (ItemCodeDic.Count <= 1) { continue; } #endregion List <float> fKeys = ItemCodeDic.Keys.ToList(); //List<OilDataEntity> OilDataEntityValues = ItemCodeDic.Values.ToList(); #region "错误判断" if (row.trend == "+")//升序 { for (int indexKey = 0; indexKey < fKeys.Count - 1; indexKey++) { if (fKeys[indexKey] > fKeys[indexKey + 1])//不符合要求 { string str = DataCheck.OilDataCheck.ExperienceTrendCheckMetion(tableType, ItemCodeDic[fKeys[indexKey + 1]].OilTableRow, ItemCodeDic[fKeys[indexKey]].OilTableCol, ItemCodeDic[fKeys[indexKey + 1]].OilTableCol); sbAlert.Append(str); int colIndex = ItemCodeDic[fKeys[indexKey]].ColumnIndex; gridOil.SetRemarkFlag(row.itemCode, Color.Green, colIndex, true); } } } else if (row.trend == "-") { for (int indexKey = 0; indexKey < fKeys.Count - 1; indexKey++) { if (fKeys[indexKey] < fKeys[indexKey + 1])//不符合要求 { string str = DataCheck.OilDataCheck.ExperienceTrendCheckMetion(tableType, ItemCodeDic[fKeys[indexKey + 1]].OilTableRow, ItemCodeDic[fKeys[indexKey]].OilTableCol, ItemCodeDic[fKeys[indexKey + 1]].OilTableCol); sbAlert.Append(str); int colIndex = ItemCodeDic[fKeys[indexKey + 1]].ColumnIndex; gridOil.SetRemarkFlag(row.itemCode, Color.Green, colIndex, true, GridOilColumnType.Calc); } } } #endregion } return(sbAlert); }
/// <summary> /// 获取对应类型的字典类型 /// </summary> /// <param name="XItemcode"></param> /// <param name="PropertyY"></param> /// <param name="oilTableTypeID"></param> /// <returns></returns> public static Dictionary <ZedGraphOilDataEntity, ZedGraphOilDataEntity> getDictionary(OilInfoEntity oilInfoA, CurveTypeCode typeCode, string XItemCode, string YItemCode, EnumTableType tableType, Color narrowColor, Color wideColor) { Dictionary <ZedGraphOilDataEntity, ZedGraphOilDataEntity> result = new Dictionary <ZedGraphOilDataEntity, ZedGraphOilDataEntity>(); if (oilInfoA == null) { return(result); } if (typeCode == CurveTypeCode.RESIDUE) { #region "添加原油性质数据" OilDataEntity oilData = oilInfoA.OilDatas.Where(c => c.OilTableTypeID == (int)EnumTableType.Whole && c.OilTableRow.itemCode == YItemCode).FirstOrDefault(); if (oilData != null && oilData.calData != string.Empty) { double D_calDataY = 0; if (double.TryParse(oilData.calData, out D_calDataY)) { ZedGraphOilDataEntity key = new ZedGraphOilDataEntity() { ParticipateInCalculation = "true", ColumnIndex = FrmCurveAGlobal._dataColStart, labData = "100", calData = "100", D_CalShowData = 100, D_CalData = 100 }; ZedGraphOilDataEntity value = new ZedGraphOilDataEntity() { ParticipateInCalculation = "true", ColumnIndex = FrmCurveAGlobal._dataColStart, labData = oilData.calData, calData = oilData.calData, D_CalShowData = D_calDataY, D_CalData = D_calDataY }; result.Add(key, value); } } #endregion } List <OilDataEntity> oilDatasAll = oilInfoA.OilDatas.Where(o => o.OilTableTypeID == (int)tableType && o.calData != string.Empty).ToList(); if (oilDatasAll.Count <= 0) { return(result); } List <OilDataEntity> oilDatas = oilDatasAll.Where(c => c.OilTableRow.itemCode == XItemCode || c.OilTableRow.itemCode == YItemCode).ToList(); if (oilDatas.Count() <= 0) { return(result); } List <OilDataEntity> xList = oilDatas.Where(o => o.OilTableRow.itemCode == XItemCode).ToList(); //x轴的坐标集合 List <OilDataEntity> yList = oilDatas.Where(o => o.OilTableRow.itemCode == YItemCode).ToList(); //y轴的坐标集合 if (xList == null || yList == null) { return(result); } foreach (var xItem in xList) { #region "添加数据" OilDataEntity yItem = yList.Where(o => o.OilTableCol.colCode == xItem.OilTableCol.colCode).FirstOrDefault();//保证数据对应 if (yItem == null) { continue; } double d_calDataX = 0, d_calDataY = 0; double d_calShowDataX = 0, d_calShowDataY = 0; if (double.TryParse(yItem.calShowData, out d_calShowDataY) && double.TryParse(xItem.calShowData, out d_calShowDataX) && double.TryParse(yItem.calData, out d_calDataY) && double.TryParse(xItem.calData, out d_calDataX)) { ZedGraphOilDataEntity key = new ZedGraphOilDataEntity() { //ID = xItem.ID, //oilInfoID = xItem.oilInfoID, //oilTableColID = xItem.oilTableColID, //oilTableRowID = xItem.oilTableRowID, ParticipateInCalculation = "true", labData = xItem.labData, calData = xItem.calData, D_CalData = d_calDataX, D_CalShowData = d_calShowDataX, Cell_Color = tableType == EnumTableType.Narrow ? narrowColor : wideColor }; ZedGraphOilDataEntity value = new ZedGraphOilDataEntity() { //ID = yItem.ID, //oilInfoID = yItem.oilInfoID, //oilTableColID = yItem.oilTableColID, //oilTableRowID = yItem.oilTableRowID, ParticipateInCalculation = "true", labData = yItem.labData, calData = yItem.calData, D_CalData = d_calDataY, D_CalShowData = d_calShowDataY, Cell_Color = tableType == EnumTableType.Narrow ? narrowColor : wideColor }; result.Add(key, value); } #endregion } return(result); }
/// <summary> /// 将宽馏分的列数据写入原油 /// </summary> /// <param name="oilA"></param> /// <param name="Data"></param> /// <param name="tableType"></param> private static void WriteToOilA(ref OilInfoEntity oilA, List <WCol> Data, EnumTableType tableType) { try { int colNum = 0; foreach (var col in Data) { #region "获取列ID" colNum++; int oilTableColID = 0; try { oilTableColID = _colCache["Cut" + colNum.ToString(), tableType].ID; } catch { MessageBox.Show("获取不到colID" + colNum.ToString()); } #endregion #region "添加ICP ECP" if (tableType == EnumTableType.Narrow || tableType == EnumTableType.Wide || tableType == EnumTableType.Residue) { if (tableType == EnumTableType.Narrow || tableType == EnumTableType.Wide)//添加icp ecp { #region var oilTableICPRowID = _rowCache["ICP", tableType].ID; OilDataEntity oilDataICP = new OilDataEntity(); oilDataICP.oilInfoID = oilA.ID; oilDataICP.oilTableColID = oilTableColID; oilDataICP.oilTableRowID = oilTableICPRowID; string data = col.ICP == 0 ? "" : col.ICP.ToString(); oilDataICP.labData = data; oilDataICP.calData = data; oilA.OilDatas.Add(oilDataICP); var oilTableECPRowID = _rowCache["ECP", tableType].ID; OilDataEntity oilDataECP = new OilDataEntity(); oilDataECP.oilInfoID = oilA.ID; oilDataECP.oilTableColID = oilTableColID; oilDataECP.oilTableRowID = oilTableECPRowID; data = col.ECP == 0 ? "" : col.ECP.ToString(); oilDataECP.labData = data; oilDataECP.calData = data; oilA.OilDatas.Add(oilDataECP); #endregion } if (tableType == EnumTableType.Residue)//添加icp ecp { #region var ICProw = _rowCache["ICP", tableType]; OilDataEntity oilDataICP = new OilDataEntity(); oilDataICP.oilInfoID = oilA.ID; oilDataICP.oilTableColID = oilTableColID; oilDataICP.oilTableRowID = ICProw.ID; string data = col.ICP.ToString(); oilDataICP.labData = data; oilDataICP.calData = data; oilA.OilDatas.Add(oilDataICP); #endregion } } #endregion #region "添加ICP ECP" if (tableType == EnumTableType.Wide || tableType == EnumTableType.Residue) //如果是“宽馏分”和“渣油” 温度判断是什么油 ,宽 和 渣 才有 WCT { string oilType = GetOilType(col.ICP, col.ECP); //得到wct的种类 S_ParmBll s_ParmBll = new S_ParmBll(); List <S_ParmEntity> wCutTypes; //todo 如果是“渣油”变为rct if (tableType == EnumTableType.Residue) { wCutTypes = s_ParmBll.GetParms("RCT"); } else { wCutTypes = s_ParmBll.GetParms("WCT"); } string WCT = ""; try { WCT = wCutTypes.Where(c => c.parmName == oilType).FirstOrDefault().parmValue; } catch { MessageBox.Show("ICP:" + col.ICP + "ECP:" + col.ECP + "未找到对应原油类型"); } //宽馏分的wct行 var rowWCT = _rowCache["WCT", tableType]; OilDataEntity oilDataWCT = new OilDataEntity(); oilDataWCT.oilInfoID = oilA.ID; oilDataWCT.oilTableColID = oilTableColID; oilDataWCT.oilTableRowID = rowWCT.ID; string data = WCT; if (data.Length > 12) { data = data.Substring(0, 12); } oilDataWCT.labData = data; oilDataWCT.calData = data; oilA.OilDatas.Add(oilDataWCT); } #endregion #region "其他数据赋值" foreach (var item in col.Cells) { OilTableRowEntity rowEntity = null;//根据itemcode得到行id try { if (item.ItemCode == "TYP") { //rowEntity = _rowCache["TYP", EnumTableType.Info]; oilA.type = item.LabData; //更新原油信息 OilBll.saveInfo(oilA); continue; } else { rowEntity = _rowCache[item.ItemCode, tableType]; } if (rowEntity == null) { continue; } } catch { MessageBox.Show("rowEntity获取失败"); } OilDataEntity oilData = new OilDataEntity(); oilData.oilInfoID = oilA.ID; oilData.oilTableColID = oilTableColID; oilData.oilTableRowID = rowEntity.ID; string labData; try { OilTools tools = new OilTools(); if (rowEntity.decNumber != null) { labData = tools.calDataDecLimit(item.LabData, rowEntity.decNumber + 2, rowEntity.valDigital);//输入Execl表的过程中转换数据精度 } else { labData = tools.calDataDecLimit(item.LabData, rowEntity.decNumber, rowEntity.valDigital);//输入Execl表的过程中转换数据精度 } } catch { MessageBox.Show("lab:" + item.LabData); } oilData.labData = item.LabData; oilData.calData = item.LabData; oilA.OilDatas.Add(oilData); } #endregion } } catch (Exception ex) { Log.Error("erro:" + ex); } }
/// <summary> /// GC计算 /// </summary> /// <param name="GCLevelDataList">GC标准表的数据集合</param> /// <param name="ECP_TWYCurve">已经存在的ECP—TWY绘图曲线</param> /// <param name="B_X">馏分曲线中的已知的18个点数据集合</param> /// <param name="itemCode">判断哪个物性进行GC内插计算</param> /// <returns>表格中需要填充的数据,和B_X数据对应</returns> public static Dictionary <float, float> getGCInterpolationDIC(List <OilDataEntity> GCLevelDataList, CurveEntity ECP_TWYCurve, List <float> B_X, string itemCode) { Dictionary <float, float> DIC = new Dictionary <float, float>();//GC字典 #region "输入处理" if (GCLevelDataList.Count <= 0) { return(DIC); } if (ECP_TWYCurve == null) { return(DIC); } if (ECP_TWYCurve.curveDatas.Count <= 0) { return(DIC); } if (B_X.Count <= 0) { return(DIC); } OilDataEntity ICPEntity = GCLevelDataList.Where(o => o.OilTableRow.itemCode == "ICP").FirstOrDefault(); OilDataEntity ECPEntity = GCLevelDataList.Where(o => o.OilTableRow.itemCode == "ECP").FirstOrDefault(); if (ICPEntity == null || ECPEntity == null) { return(DIC); } if (ICPEntity.calData == string.Empty || ECPEntity.calData == string.Empty) { return(DIC); } float TotalICP = 0, TotalECP = 0; if (!(float.TryParse(ICPEntity.calData, out TotalICP) && float.TryParse(ECPEntity.calData, out TotalECP))) { return(DIC); } #endregion List <float> XList = B_X.Where(o => o >= TotalICP && o <= TotalECP).ToList(); if (XList.Count <= 0) { return(DIC); } if (XList.Count == 1) { float CUTICP = TotalICP; float CUTECP = XList[0]; } else if (XList.Count > 1) { for (int i = 1; i < XList.Count; i++) { float CUTICP = XList[i - 1]; float CUTECP = XList[i]; CurveDataEntity ICPData = ECP_TWYCurve.curveDatas.Where(o => o.xValue == CUTICP).FirstOrDefault(); CurveDataEntity ECPData = ECP_TWYCurve.curveDatas.Where(o => o.xValue == CUTECP).FirstOrDefault(); if (ICPData == null || ECPData == null) { continue; } if (ICPData.yValue.Equals(float.NaN) || ECPData.yValue.Equals(float.NaN)) { continue; } float WY = ECPData.yValue - ICPData.yValue; Dictionary <string, float> gcDIC = OilApplyBll.getGCInterpolationDIC(GCLevelDataList, CUTICP, CUTECP, WY); List <float> tempList = gcDIC.Values.ToList(); float sum = 0; foreach (string key in gcDIC.Keys) { sum += gcDIC[key]; } float?result = null; switch (itemCode) { case "D20": result = OilApplySupplement.getGC_D20Value(gcDIC, WY); break; case "MW": result = OilApplySupplement.getGC_MWValue(gcDIC, WY); break; case "RNC": result = OilApplySupplement.getGC_RNCValue(gcDIC, WY); break; case "PAN": result = OilApplySupplement.getGC_PANValue(gcDIC, WY); break; case "PAO": result = OilApplySupplement.getGC_PAOValue(gcDIC, WY); break; case "NAH": result = OilApplySupplement.getGC_NAHValue(gcDIC, WY); break; case "MON": result = OilApplySupplement.getGC_MONValue(gcDIC, WY); break; case "ARM": result = OilApplySupplement.getGC_ARMValue(gcDIC, WY); break; case "ARP": result = OilApplySupplement.getGC_ARPValue(gcDIC, WY); break; case "RVP": // result = OilApplySupplement.getGC_RVPValue(gcDIC, WY); break; } if (!DIC.Keys.Contains(CUTECP) && result != null) { DIC.Add(CUTECP, result.Value); } } } return(DIC); }
/// <summary> /// 通过窄馏分的ICP和ECP在窄馏分中查找对应的两个ICP和ECP列,并且找出指定物性的WY/VY累积和(允许存在空值) /// </summary> /// <param name="strICP"></param> /// <param name="strECP"></param> /// <param name="itemCode">WY/VY</param> /// <returns>窄馏分中查找对应的两个ICP和ECP列,并且返回指定物性的累积和 ,itemCode</returns> public static Dictionary <string, float> getWYVYCumuationValueAllowEmptyFromNarrow(GridOilViewA narrowGridOil, string strICP, string strECP, string itemCode) { float SUM_ItemCode = 0; //定义返回变量的两个值 Dictionary <string, float> ReturnDic = new Dictionary <string, float>(); #region "输入判断" if (strICP == string.Empty || strECP == string.Empty || itemCode == string.Empty)//不存在此行则返回空 { return(ReturnDic); } List <OilDataEntity> ICPList = narrowGridOil.GetDataByRowItemCode("ICP").Where(o => o.calData != string.Empty).ToList(); List <OilDataEntity> ECPList = narrowGridOil.GetDataByRowItemCode("ECP").Where(o => o.calData != string.Empty).ToList(); if (ICPList == null || ECPList == null)//如果窄馏分数据表不存在则返回空 { return(ReturnDic); } if (ICPList.Count <= 0 || ECPList.Count <= 0)//如果窄馏分数据表中ICP和ECP不存在则返回空 { return(ReturnDic); } OilDataEntity oilDataICP = ICPList.Where(o => o.calShowData == strICP).FirstOrDefault(); if (oilDataICP == null)//如果查找的数据不存在则返回空 { MessageBox.Show("找不到初切点为" + strICP + "对应的馏分!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(ReturnDic); } OilDataEntity oilDataECP = ECPList.Where(o => o.calShowData == strECP).FirstOrDefault(); if (oilDataECP == null)//如果查找的数据不存在则返回空 { MessageBox.Show("找不到终切点为" + strECP + "对应的馏分!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(ReturnDic); } List <OilDataEntity> ItemCodeList = narrowGridOil.GetDataByRowItemCode(itemCode); if (ItemCodeList == null)//如果查找的数据不存在则返回空 { return(ReturnDic); } if (ItemCodeList.Count <= 0)//如果查找的数据不存在则返回空 { return(ReturnDic); } if (oilDataICP.OilTableCol.colOrder > oilDataECP.OilTableCol.colOrder)//根据对应的ICP和ECP对应列来计算累积和 { return(ReturnDic); } #endregion bool Bbreak = false;//判断中间数据是否空(允许存在空值) for (int index = oilDataICP.OilTableCol.colOrder; index <= oilDataECP.OilTableCol.colOrder; index++) { OilDataEntity ItemCodeOilData = ItemCodeList.Where(o => o.OilTableCol.colOrder == index).FirstOrDefault(); float itemCodeCal = 0; if (ItemCodeOilData != null && float.TryParse(ItemCodeOilData.calData, out itemCodeCal)) { Bbreak = true; SUM_ItemCode += itemCodeCal; } } if (Bbreak) { ReturnDic.Add(itemCode, SUM_ItemCode); } return(ReturnDic); }
/// <summary> /// 通过宽馏分的ICP和ECP在窄馏分中查找对应的两个ICP和ECP列,并且找出指定物性的累积和(不允许存在空值) /// </summary> /// <param name="strICP">宽馏分的ICP</param> /// <param name="strECP">宽馏分的ECP</param> /// <param name="strItemCode">计算的物性</param> /// <returns>宽馏分中查找对应的两个ICP和ECP列,并且返回指定物性的累积和 ,SUM_POR、 SUM_WY</returns> public static Dictionary <string, float> getItemCodeCumuationValueAllowEmptyFromWide(GridOilViewA wideGridOil, string strICP, string strECP, string itemCode) { Dictionary <string, float> ReturnDic = new Dictionary <string, float>(); float SUM_POR = 0; //定义返回变量的两个值 #region "输入条件判断" if (strICP == string.Empty || strECP == string.Empty || itemCode == string.Empty)//不存在此行则返回空 { return(ReturnDic); } List <OilDataEntity> ICPList = wideGridOil.GetDataByRowItemCode("ICP").Where(o => o.calShowData == strICP).ToList(); List <OilDataEntity> ECPList = wideGridOil.GetDataByRowItemCode("ECP").Where(o => o.calShowData == strECP).ToList(); List <OilDataEntity> WYList = wideGridOil.GetDataByRowItemCode("WY").Where(o => o.calData != string.Empty).ToList(); List <OilDataEntity> itemCodeList = wideGridOil.GetDataByRowItemCode(itemCode).Where(o => o.calData != string.Empty).ToList(); if (ICPList == null || ECPList == null || WYList == null) { return(ReturnDic); } if (ICPList.Count <= 0 || ECPList.Count <= 0 || WYList.Count <= 0) { return(ReturnDic); } OilDataEntity oilDataICP = ICPList.Where(o => o.calShowData == strICP).FirstOrDefault(); OilDataEntity oilDataECP = ECPList.Where(o => o.calShowData == strECP).FirstOrDefault(); if (oilDataICP == null)//如果查找的数据不存在则返回空 { MessageBox.Show("找不到初切点为" + strICP + "对应的馏分!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(ReturnDic); } if (oilDataECP == null)//如果查找的数据不存在则返回空 { MessageBox.Show("找不到终切点为" + strECP + "对应的馏分!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(ReturnDic); } #endregion #region "ICP--ECP" foreach (OilDataEntity ICPData in ICPList) { OilDataEntity ECPData = ECPList.Where(o => o.OilTableCol.colOrder == ICPData.OilTableCol.colOrder).FirstOrDefault(); if (ECPData == null) { continue; } OilDataEntity oilDataWY = WYList.Where(o => o.OilTableCol.colOrder == ICPData.OilTableCol.colOrder).FirstOrDefault(); float wyCal = 0; if (oilDataWY != null && float.TryParse(oilDataWY.calData, out wyCal)) { ReturnDic.Add("WY", wyCal); } if (itemCodeList == null) { continue; } OilDataEntity oilDataItemCode = itemCodeList.Where(o => o.OilTableCol.colOrder == ICPData.OilTableCol.colOrder).FirstOrDefault(); if (oilDataWY != null && oilDataItemCode != null && float.TryParse(oilDataWY.calData, out wyCal)) { string strTemp = BaseFunction.IndexFunItemCode(oilDataItemCode.calData, itemCode); float fTtemp = 0; if (strTemp != string.Empty && float.TryParse(strTemp, out fTtemp)) { SUM_POR = wyCal * fTtemp; ReturnDic.Add(itemCode, SUM_POR); break; } } } #endregion return(ReturnDic); }
/// <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> /// <returns>错误提示字符串</returns> public string rangeCheck(EnumTableType tableType) { this._tableType = tableType; if (tableType == EnumTableType.Whole) { this._gridOil = this._wholeGridOil; } if (tableType == EnumTableType.Narrow) { this._gridOil = this._narrowGridOil; } else if (tableType == EnumTableType.Wide) { this._gridOil = this._wideGridOil; } else if (tableType == EnumTableType.Residue) { this._gridOil = this._residueGridOil; } StringBuilder sbAlert = new StringBuilder();//返回的审查语句 OilDataCheck dataCheck = new OilDataCheck(); List <OilTableRowEntity> rows = OilTableRowBll._OilTableRow; List <OilDataEntity> datas = this._gridOil.GetAllData().Where(o => o.calData != string.Empty).ToList(); OilTableTypeComparisonTableAccess oilTableTypeComparisonTableAccess = new OilTableTypeComparisonTableAccess(); List <OilTableTypeComparisonTableEntity> OilTableTypeComparisonTableList = oilTableTypeComparisonTableAccess.Get("1=1"); RangeParmTableAccess trendParmTableAccess = new RangeParmTableAccess(); List <RangeParmTableEntity> trendParmList = trendParmTableAccess.Get("1=1"); this._gridOil.ClearRemarkFlat(); if (this._tableType == EnumTableType.Whole) { #region "原油性质" List <OilDataEntity> wholeDatas = datas.Where(o => o.OilTableTypeID == (int)EnumTableType.Whole).ToList(); //原油性质表的范围审查数据 List <OilTableRowEntity> wholeRows = rows.Where(o => o.oilTableTypeID == (int)EnumTableType.Whole).ToList(); //宽馏分表的行实体 foreach (OilTableRowEntity row in wholeRows) { List <OilDataEntity> wholeItemCodeDatas = wholeDatas.Where(o => o.OilTableRow.itemCode == row.itemCode).ToList(); foreach (OilDataEntity wholeData in wholeItemCodeDatas) { OilTableTypeComparisonTableEntity wholeTrendComparisonTableEntity = OilTableTypeComparisonTableList.Where(o => o.tableName == enumCheckTrendType.Whole.GetDescription()).FirstOrDefault(); List <RangeParmTableEntity> wholeTrendParmList = trendParmList.Where(o => o.OilTableTypeComparisonTableID == wholeTrendComparisonTableEntity.ID).ToList(); RangeParmTableEntity wholeTrendParm = wholeTrendParmList.Where(o => o.itemCode == wholeData.OilTableRow.itemCode).FirstOrDefault(); string str = cellRangeCheck(wholeData, wholeTrendParm, enumCheckExpericencType.Limit); if (str != string.Empty) { int colIndex = wholeData.ColumnIndex; this._gridOil.SetRemarkFlag(row.itemCode, Color.Green, colIndex, true, GridOilColumnType.Calc); sbAlert.Append(str); } } } #endregion } else if (this._tableType == EnumTableType.Narrow) { List <OilDataEntity> narrowDatas = datas.Where(o => o.OilTableTypeID == (int)EnumTableType.Narrow).ToList(); //窄馏分表的范围审查数据 List <OilDataEntity> ECPList = narrowDatas.Where(o => o.OilTableRow.itemCode == "ECP" && o.calData != string.Empty).ToList(); // #region "窄馏分" foreach (OilDataEntity ecpData in ECPList) { float ECPValue = 0; if (float.TryParse(ecpData.calData, out ECPValue)) { if (ECPValue <= 140 && ECPValue > 15)//石脑油 { OilTableTypeComparisonTableEntity naphthaTrendComparisonTableEntity = OilTableTypeComparisonTableList.Where(o => o.tableName == enumCheckTrendType.Naphtha.GetDescription()).FirstOrDefault(); List <RangeParmTableEntity> naphthaTrendParmList = trendParmList.Where(o => o.OilTableTypeComparisonTableID == naphthaTrendComparisonTableEntity.ID).ToList(); RangeParmTableEntity naphthaTrendParm = naphthaTrendParmList.Where(o => o.itemCode == ecpData.OilTableRow.itemCode).FirstOrDefault(); string str = cellRangeCheck(ecpData, naphthaTrendParm, enumCheckExpericencType.Limit); if (str != string.Empty) { int colIndex = ecpData.ColumnIndex; this._gridOil.SetRemarkFlag("ECP", Color.Green, colIndex, true, GridOilColumnType.Calc); sbAlert.Append(str); } } else if (ECPValue <= 240 && ECPValue > 140)//航煤 { OilTableTypeComparisonTableEntity AviationKeroseneTrendComparisonTableEntity = OilTableTypeComparisonTableList.Where(o => o.tableName == enumCheckTrendType.AviationKerosene.GetDescription()).FirstOrDefault(); List <RangeParmTableEntity> AviationKeroseneTrendParmList = trendParmList.Where(o => o.OilTableTypeComparisonTableID == AviationKeroseneTrendComparisonTableEntity.ID).ToList(); RangeParmTableEntity AviationKeroseneTrendParm = AviationKeroseneTrendParmList.Where(o => o.itemCode == ecpData.OilTableRow.itemCode).FirstOrDefault(); string str = cellRangeCheck(ecpData, AviationKeroseneTrendParm, enumCheckExpericencType.Limit); if (str != string.Empty) { int colIndex = ecpData.ColumnIndex; this._gridOil.SetRemarkFlag("ECP", Color.Green, colIndex, true, GridOilColumnType.Calc); sbAlert.Append(str); } } else if (ECPValue <= 350 && ECPValue > 240)//柴油 { OilTableTypeComparisonTableEntity DieselOilTrendComparisonTableEntity = OilTableTypeComparisonTableList.Where(o => o.tableName == enumCheckTrendType.DieselOil.GetDescription()).FirstOrDefault(); List <RangeParmTableEntity> DieselOilTrendParmList = trendParmList.Where(o => o.OilTableTypeComparisonTableID == DieselOilTrendComparisonTableEntity.ID).ToList(); RangeParmTableEntity DieselOilTrendParm = DieselOilTrendParmList.Where(o => o.itemCode == ecpData.OilTableRow.itemCode).FirstOrDefault(); string str = cellRangeCheck(ecpData, DieselOilTrendParm, enumCheckExpericencType.Limit); if (str != string.Empty) { int colIndex = ecpData.ColumnIndex; this._gridOil.SetRemarkFlag("ECP", Color.Green, colIndex, true, GridOilColumnType.Calc); sbAlert.Append(str); } } else if (ECPValue > 350)//VGO { OilTableTypeComparisonTableEntity VGOTrendComparisonTableEntity = OilTableTypeComparisonTableList.Where(o => o.tableName == enumCheckTrendType.VGO.GetDescription()).FirstOrDefault(); List <RangeParmTableEntity> VGOTrendParmList = trendParmList.Where(o => o.OilTableTypeComparisonTableID == VGOTrendComparisonTableEntity.ID).ToList(); RangeParmTableEntity VGOTrendParm = VGOTrendParmList.Where(o => o.itemCode == ecpData.OilTableRow.itemCode).FirstOrDefault(); string str = cellRangeCheck(ecpData, VGOTrendParm, enumCheckExpericencType.Limit); if (str != string.Empty) { int colIndex = ecpData.ColumnIndex; this._gridOil.SetRemarkFlag("ECP", Color.Green, colIndex, true, GridOilColumnType.Calc); sbAlert.Append(str); } } } } #endregion } else if (this._tableType == EnumTableType.Wide) { #region "宽馏分" List <OilDataEntity> wideDatas = datas.Where(o => o.OilTableTypeID == (int)EnumTableType.Wide).ToList(); //窄馏分表的范围审查数据 List <OilTableRowEntity> wideRows = rows.Where(o => o.oilTableTypeID == (int)EnumTableType.Wide).ToList(); //宽馏分表的行实体 List <OilDataEntity> wideWCTDatas = wideDatas.Where(o => o.OilTableRow.itemCode == "WCT").ToList(); //宽馏分表的WCT数据 List <OilTableRowEntity> wideWCTOtherRows = wideRows.Where(o => o.itemCode != "WCT").ToList(); //宽馏分表的非WCT行实体 foreach (OilTableRowEntity row in wideWCTOtherRows) { List <OilDataEntity> wideItemCodeDatas = wideDatas.Where(o => o.OilTableRow.itemCode == row.itemCode).ToList(); foreach (OilDataEntity oilData in wideItemCodeDatas) { OilDataEntity wctOilData = wideWCTDatas.Where(o => o.OilTableCol.colCode == oilData.OilTableCol.colCode).FirstOrDefault(); if (wctOilData != null) { string str = wideCellRangeCheck(oilData, wctOilData, enumCheckExpericencType.Limit); if (str != string.Empty) { sbAlert.Append(str); int colIndex = oilData.ColumnIndex; this._gridOil.SetRemarkFlag(row.itemCode, Color.Green, colIndex, true, GridOilColumnType.Calc); } } } } #endregion } else if (this._tableType == EnumTableType.Residue) { #region "渣油" List <OilDataEntity> residueDatas = datas.Where(o => o.OilTableTypeID == (int)EnumTableType.Residue).ToList(); //渣油表的范围审查数据 List <OilTableRowEntity> residueRows = rows.Where(o => o.oilTableTypeID == (int)EnumTableType.Residue).ToList(); //渣油表的行实体 foreach (OilTableRowEntity row in residueRows) { List <OilDataEntity> residueItemCodeDatas = residueDatas.Where(o => o.OilTableRow.itemCode == row.itemCode).ToList(); foreach (OilDataEntity oilData in residueItemCodeDatas) { OilTableTypeComparisonTableEntity residueComparisonTableEntity = OilTableTypeComparisonTableList.Where(o => o.tableName == enumCheckTrendType.Residue.GetDescription()).FirstOrDefault(); List <RangeParmTableEntity> residueTrendParmList = trendParmList.Where(o => o.OilTableTypeComparisonTableID == residueComparisonTableEntity.ID).ToList(); RangeParmTableEntity wholeTrendParm = residueTrendParmList.Where(o => o.itemCode == oilData.OilTableRow.itemCode).FirstOrDefault(); string str = cellRangeCheck(oilData, wholeTrendParm, enumCheckExpericencType.Limit); if (str != string.Empty) { sbAlert.Append(str); int colIndex = oilData.ColumnIndex; this._gridOil.SetRemarkFlag(row.itemCode, Color.Green, colIndex, true, GridOilColumnType.Calc); } } } #endregion } return(sbAlert.ToString()); }
/// <summary> /// 单元格的范围判断 /// </summary> /// <param name="oilData"></param> /// <param name="row"></param> /// <param name="errType"></param> /// <returns></returns> private string wideCellRangeCheck(OilDataEntity oilData, OilDataEntity wctOilData, enumCheckExpericencType errType) { OilDataCheck oilDataCheck = new OilDataCheck(); Dictionary <string, string> WideWCTDic = new Dictionary <string, string>(); WideWCTDic.Add("石脑油", "石脑油表"); WideWCTDic.Add("重整料", "石脑油表"); WideWCTDic.Add("溶剂油", "石脑油表"); WideWCTDic.Add("乙烯料", "石脑油表"); WideWCTDic.Add("航煤", "航煤表"); WideWCTDic.Add("煤油", "航煤表"); WideWCTDic.Add("柴油", "柴油表"); WideWCTDic.Add("蜡油", "VGO表"); WideWCTDic.Add("脱蜡油", "VGO表"); WideWCTDic.Add("精制油1", "VGO表"); WideWCTDic.Add("精制油2", "VGO表"); WideWCTDic.Add("精制油3", "VGO表"); StringBuilder sbAlert = new StringBuilder(); string strEmpty = string.Empty; if (oilData == null || wctOilData == null) { return(strEmpty); } string strTableType = string.Empty; if (WideWCTDic.Keys.Contains(wctOilData.calData)) { strTableType = WideWCTDic[wctOilData.calData]; } else { return(strEmpty); } OilTableTypeComparisonTableAccess oilTableTypeComparisonTableAccess = new OilTableTypeComparisonTableAccess(); List <OilTableTypeComparisonTableEntity> OilTableTypeComparisonTableList = oilTableTypeComparisonTableAccess.Get("1=1"); RangeParmTableAccess trendParmTableAccess = new RangeParmTableAccess(); List <RangeParmTableEntity> trendParmList = trendParmTableAccess.Get("1=1"); OilTableTypeComparisonTableEntity comparisonTableEntity = OilTableTypeComparisonTableList.Where(o => o.tableName == strTableType).FirstOrDefault(); List <RangeParmTableEntity> trendParmTableList = trendParmList.Where(o => o.OilTableTypeComparisonTableID == comparisonTableEntity.ID).ToList(); RangeParmTableEntity TrendParm = trendParmTableList.Where(o => o.itemCode == oilData.OilTableRow.itemCode).FirstOrDefault(); if (TrendParm == null) { return(strEmpty); } float tempValue = 0; if (float.TryParse(oilData.calData, out tempValue)) //如果是浮点数 { float TrendParmAlertDownLimit = 0, TrendParmAlertUpLimit = 0; if (TrendParm.alertDownLimit == strEmpty && TrendParm.alertUpLimit != strEmpty) { if (float.TryParse(TrendParm.alertUpLimit, out TrendParmAlertUpLimit)) { if (tempValue <= TrendParmAlertUpLimit)//无下限,有上限,则校正值<=上限,数据正常;否则有疑问。 { return(strEmpty); } else { return(DataCheck.OilDataCheck.ExperienceCheckMetion((EnumTableType)oilData.OilTableTypeID, oilData.OilTableRow, oilData.OilTableCol, enumCheckExpericencType.Limit)); } } } else if (TrendParm.alertDownLimit != strEmpty && TrendParm.alertUpLimit == strEmpty) { if (float.TryParse(TrendParm.alertDownLimit, out TrendParmAlertDownLimit)) { if (tempValue >= TrendParmAlertDownLimit) //无上限,有下限,则校正值>=下限,数据正常;否则有疑问。 { return(strEmpty); } else { return(DataCheck.OilDataCheck.ExperienceCheckMetion((EnumTableType)oilData.OilTableTypeID, oilData.OilTableRow, oilData.OilTableCol, enumCheckExpericencType.Limit)); } } } else if (TrendParm.alertDownLimit != strEmpty && TrendParm.alertUpLimit != strEmpty) { if (float.TryParse(TrendParm.alertDownLimit, out TrendParmAlertDownLimit) && float.TryParse(TrendParm.alertUpLimit, out TrendParmAlertUpLimit)) { if (tempValue >= TrendParmAlertDownLimit && tempValue <= TrendParmAlertUpLimit) //有上、下限,则上限>=校正值>=下限,数据正常;否则有疑问。 { return(strEmpty); } else { return(DataCheck.OilDataCheck.ExperienceCheckMetion((EnumTableType)oilData.OilTableTypeID, oilData.OilTableRow, oilData.OilTableCol, enumCheckExpericencType.Limit)); } } } else if (TrendParm.alertDownLimit == strEmpty && TrendParm.alertUpLimit == strEmpty) { //无上、下限,则不作判断。 } } else { //return oilDataCheck.CheckMetion(oilData.OilTableRow.itemName, oilData.OilTableRow.RowIndex, enumCheckErrType.TypeError); } return(strEmpty); }
/// <summary> /// 单元格的范围判断 /// </summary> /// <param name="oilData"></param> /// <param name="row"></param> /// <param name="errType"></param> /// <returns></returns> private string cellRangeCheck(OilDataEntity oilData, RangeParmTableEntity TrendParm, enumCheckExpericencType errType) { StringBuilder sbAlert = new StringBuilder(); string strEmpty = string.Empty; float tempValue = 0; if (float.TryParse(oilData.calData, out tempValue)) //如果是浮点数 { float TrendParmAlertDownLimit = 0, TrendParmAlertUpLimit = 0; if (TrendParm.alertDownLimit == strEmpty && TrendParm.alertUpLimit != strEmpty) { if (float.TryParse(TrendParm.alertUpLimit, out TrendParmAlertUpLimit)) { if (tempValue <= TrendParmAlertUpLimit)//无下限,有上限,则校正值<=上限,数据正常;否则有疑问。 { return(strEmpty); } else { return(DataCheck.OilDataCheck.ExperienceCheckMetion((EnumTableType)oilData.OilTableTypeID, oilData.OilTableRow, oilData.OilTableCol, enumCheckExpericencType.Limit)); } } } else if (TrendParm.alertDownLimit != strEmpty && TrendParm.alertUpLimit == strEmpty) { if (float.TryParse(TrendParm.alertDownLimit, out TrendParmAlertDownLimit)) { if (tempValue >= TrendParmAlertDownLimit) //无上限,有下限,则校正值>=下限,数据正常;否则有疑问。 { return(strEmpty); } else { return(DataCheck.OilDataCheck.ExperienceCheckMetion((EnumTableType)oilData.OilTableTypeID, oilData.OilTableRow, oilData.OilTableCol, enumCheckExpericencType.Limit)); } } } else if (TrendParm.alertDownLimit != strEmpty && TrendParm.alertUpLimit != strEmpty) { if (float.TryParse(TrendParm.alertDownLimit, out TrendParmAlertDownLimit) && float.TryParse(TrendParm.alertUpLimit, out TrendParmAlertUpLimit)) { if (tempValue >= TrendParmAlertDownLimit && tempValue <= TrendParmAlertUpLimit) //有上、下限,则上限>=校正值>=下限,数据正常;否则有疑问。 { return(strEmpty); } else { return(DataCheck.OilDataCheck.ExperienceCheckMetion((EnumTableType)oilData.OilTableTypeID, oilData.OilTableRow, oilData.OilTableCol, enumCheckExpericencType.Limit)); } } } else if (TrendParm.alertDownLimit == strEmpty && TrendParm.alertUpLimit == strEmpty) { //无上、下限,则不作判断。 } } else { //return DataCheck.OilDataCheck.CheckMetion(oilData.OilTableRow.itemName, oilData.OilTableRow.RowIndex, enumCheckErrType.TypeError); } return(strEmpty); }
/// <summary> /// 通过窄馏分的ICP和ECP在窄馏分中查找对应的两个ICP和ECP列,并且找出指定物性的累积和(不允许存在空值) /// </summary> /// <param name="strICP">窄馏分的ICP</param> /// <param name="strECP">窄馏分的ECP</param> /// <param name="itemCode">计算的物性</param> /// <returns>窄馏分中查找对应的两个ICP和ECP列,并且返回指定物性的累积和 ,SUM_POR、 SUM_WY</returns> public static Dictionary <string, float> getItemCodeCumuationValueNotAllowEmptyFromNarrow(GridOilViewA narrowGridOil, string strICP, string strECP, string itemCode) { float SUM_POR = 0; float SUM_WY = 0;//定义返回变量的两个值 Dictionary <string, float> ReturnDic = new Dictionary <string, float>(); #region "输入判断" if (strICP == string.Empty || strECP == string.Empty || itemCode == string.Empty)//不存在此行则返回空 { return(ReturnDic); } List <OilDataEntity> ICPList = narrowGridOil.GetDataByRowItemCode("ICP").Where(o => o.calData != string.Empty).ToList(); List <OilDataEntity> ECPList = narrowGridOil.GetDataByRowItemCode("ECP").Where(o => o.calData != string.Empty).ToList(); List <OilDataEntity> WYList = narrowGridOil.GetDataByRowItemCode("WY").Where(o => o.calData != string.Empty).ToList(); List <OilDataEntity> itemCodeList = narrowGridOil.GetDataByRowItemCode(itemCode).Where(o => o.calData != string.Empty).ToList(); if (ICPList == null || ECPList == null || WYList == null)//如果窄馏分数据表不存在则返回空 { return(ReturnDic); } if (ICPList.Count <= 0 || ECPList.Count <= 0 || WYList.Count <= 0)//如果窄馏分数据表不存在则返回空 { return(ReturnDic); } OilDataEntity oilDataICP = ICPList.Where(o => o.calShowData == strICP).FirstOrDefault(); if (oilDataICP == null)//如果查找的数据不存在则返回空 { MessageBox.Show("找不到初切点为" + strICP + "对应的馏分!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(ReturnDic); } OilDataEntity oilDataECP = ECPList.Where(o => o.calShowData == strECP).FirstOrDefault(); if (oilDataECP == null)//如果查找的数据不存在则返回空 { MessageBox.Show("找不到终切点为" + strECP + "对应的馏分!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(ReturnDic); } if (oilDataICP.OilTableCol.colOrder > oilDataECP.OilTableCol.colOrder)//根据对应的ICP和ECP对应列来计算累积和 { return(ReturnDic); } #endregion bool Bbreak = false; for (int index = oilDataICP.OilTableCol.colOrder; index <= oilDataECP.OilTableCol.colOrder; index++) { OilDataEntity oilDataWY = WYList.Where(o => o.OilTableCol.colOrder == index).FirstOrDefault(); OilDataEntity oilDataItemCode = itemCodeList.Where(o => o.OilTableCol.colOrder == index).FirstOrDefault(); if (oilDataWY == null || oilDataItemCode == null) { Bbreak = true;//计算过程不能为空,为空则跳出 break; } else { float wyCal = 0; float itemCodeCal = 0; if (float.TryParse(oilDataWY.calData, out wyCal) && float.TryParse(oilDataItemCode.calData, out itemCodeCal)) { string strTemp = BaseFunction.IndexFunItemCode(oilDataItemCode.calData, itemCode); float fTtemp = 0; if (float.TryParse(strTemp, out fTtemp) && strTemp != string.Empty) { SUM_POR = SUM_POR + wyCal * fTtemp; SUM_WY = SUM_WY + wyCal; } else { Bbreak = true; break; } } else { Bbreak = true; break; } } } if (Bbreak) { return(ReturnDic); } else { ReturnDic.Add(itemCode, SUM_POR); ReturnDic.Add("WY", SUM_WY); } return(ReturnDic); }
/// <summary> /// 通过宽馏分的ICP和ECP在窄馏分中查找对应的两个ICP和ECP列,并且找出指定物性的累积和(不允许存在空值) /// </summary> /// <param name="residueGridOil"></param> /// <param name="strICP">宽馏分的ICP</param> /// <param name="strECP">宽馏分的ECP</param> /// <param name="strItemCode">计算的物性</param> /// <returns>宽馏分中查找对应的两个ICP和ECP列,并且返回指定物性的累积和 ,SUM_POR、 SUM_WY</returns> public static Dictionary <string, float> getItemCodeCumuationValueNotAllowEmptyFromResidue(GridOilViewA residueGridOil, string strICP, string itemCode) { float SUM_POR = 0; float SUM_WY = 0;//定义返回变量的两个值 Dictionary <string, float> ReturnDic = new Dictionary <string, float>(); #region "输入判断" if (strICP == string.Empty || itemCode == string.Empty)//不存在此行则返回空 { return(ReturnDic); } List <OilDataEntity> ICPList = residueGridOil.GetDataByRowItemCode("ICP").Where(o => o.calData != string.Empty).ToList(); List <OilDataEntity> WYList = residueGridOil.GetDataByRowItemCode("WY").Where(o => o.calData != string.Empty).ToList(); List <OilDataEntity> itemCodeList = residueGridOil.GetDataByRowItemCode(itemCode).Where(o => o.calData != string.Empty).ToList(); if (ICPList == null || WYList == null) { return(ReturnDic); } if (ICPList.Count <= 0 || WYList.Count <= 0) { return(ReturnDic); } OilDataEntity oilDataICP = ICPList.Where(o => o.calShowData == strICP).FirstOrDefault(); if (oilDataICP == null)//如果查找的数据不存在则返回空 { MessageBox.Show("找不到初切点为" + strICP + "的渣油!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(ReturnDic); } #endregion #region "计算SUM_POR = 0; float SUM_WY = 0" foreach (OilDataEntity ICP in ICPList) { OilDataEntity oilDataWY = WYList.Where(o => o.OilTableCol.colCode == ICP.OilTableCol.colCode).FirstOrDefault(); OilDataEntity oilDataItemCode = itemCodeList.Where(o => o.OilTableCol.colCode == ICP.OilTableCol.colCode).FirstOrDefault(); if (oilDataWY == null || oilDataItemCode == null) { continue;//计算过程不能为空,为空则跳出 } else { float wyCal = 0; if (float.TryParse(oilDataWY.calData, out wyCal)) { string strTemp = BaseFunction.IndexFunItemCode(oilDataItemCode.calData, itemCode); float fTtemp = 0; if (strTemp != string.Empty && float.TryParse(strTemp, out fTtemp)) { SUM_POR = wyCal * fTtemp; SUM_WY = wyCal; ReturnDic.Add(itemCode, SUM_POR); ReturnDic.Add("WY", SUM_WY); break; } else { continue; } } else { continue; } } } #endregion return(ReturnDic); }