Example #1
0
 /// <summary>
 /// 范围的构造函数
 /// </summary>
 /// <param name="gridOil">需要检查的表</param>
 /// <param name="tableType">设置检查表的类型</param>
 public OilDataAccountCheck(GridOilViewA wholeGridOil, GridOilViewA narrowGridOil, GridOilViewA wideGridOil, GridOilViewA residueGridOil)
 {
     this._wholeGridOil   = wholeGridOil;
     this._narrowGridOil  = narrowGridOil;
     this._wideGridOil    = wideGridOil;
     this._residueGridOil = residueGridOil;
 }
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="wholeGridOil"></param>
        /// <param name="lightGridOil"></param>
        /// <param name="GCGridOil"></param>
        /// <param name="narrowGridOil"></param>
        /// <param name="wideGridOil"></param>
        /// <param name="residueGridOil"></param>
        public void Init(GridOilViewA wholeGridOil, GridOilViewA lightGridOil, GridOilViewA GCGridOil, GridOilViewA narrowGridOil, GridOilViewA wideGridOil, GridOilViewA residueGridOil)
        {
            this._wholeGridOil   = wholeGridOil;
            this._lightGridOil   = lightGridOil;
            this._gcGridOil      = GCGridOil;
            this._narrowGridOil  = narrowGridOil;
            this._wideGridOil    = wideGridOil;
            this._residueGridOil = residueGridOil;

            this.comboBox1.DataSource    = GetComboBoxDropItems();
            this.comboBox1.DisplayMember = "calData";
            this.comboBox1.ValueMember   = "ColumnIndex";

            this.comboBox2.DataSource    = GetComboBoxDropItems();
            this.comboBox2.DisplayMember = "calData";
            this.comboBox2.ValueMember   = "ColumnIndex";

            this.comboBox3.DataSource    = GetComboBoxDropItems();
            this.comboBox3.DisplayMember = "calData";
            this.comboBox3.ValueMember   = "ColumnIndex";
        }
Example #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="NarrowGridOil"></param>
 public void init(GridOilViewA NarrowGridOil)
 {
     this._NarrowGridOil = NarrowGridOil;
 }
Example #4
0
        /// <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>
        /// 通过窄馏分的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);
        }
        /// <summary>
        /// 通过宽馏分的ICP和ECP在窄馏分中查找对应的两个ICP和ECP列,并且找出指定物性WY/VY累积和(不允许存在空值)
        /// </summary>
        /// <param name="wideGridOil">宽馏分</param>
        /// <param name="strICP">宽馏分的ICP</param>
        /// <param name="strECP">宽馏分的ECP</param>
        /// <param name="itemCode">指定物性WY/VY</param>
        /// <returns>宽馏分中查找对应的两个ICP和ECP列,并且返回指定物性的累积和 ,SUM_POR</returns>
        public static Dictionary <string, float> getWYVYCumuationValueNotAllowEmptyFromWide(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;
                }
                else
                {
                    float wyCal = 0;
                    if (float.TryParse(oilDataItemCode.calData, out wyCal))
                    {
                        ReturnDic.Add(itemCode, wyCal);
                        break;
                    }
                    else
                    {
                        continue;
                    }
                }
            }
            #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);
        }
        /// <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);
        }
Example #10
0
        /// <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);
        }
Example #11
0
        /// <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);
        }
Example #12
0
        /// <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);
        }
Example #13
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="gridOil">需要检查的表</param>
 /// <param name="tableType">设置检查表的类型</param>
 public OilDataTrendCheck(GridOilViewA narrowGridOil, GridOilViewA wideGridOil, GridOilViewA residueGridOil)
 {
     this._narrowGridOil  = narrowGridOil;
     this._wideGridOil    = wideGridOil;
     this._residueGridOil = residueGridOil;
 }