<pre name="code" class="csharp"> /// <summary>
/// 根据条件获取公司级别实际完成接替率
/// </summary>
/// <param name="startYear">起始年份</param>
/// <param name="endYear">终止年份</param>
/// <returns>实际完成接替率数据</returns>
private List<ReplacementRateModel> GetCompanyActualReplacementRateBy(int startYear, int endYear)
{
List<ReplacementRateModel> models = new List<ReplacementRateModel>();//ReplacementRateModel是一个视图模型
string sqlOil = GetSqlFromXml.GetSqlBy("GetCompanyActualReplacementRateBy", fileName, "select");//通过xml找到对应的sql语句
string sqlOilSelect = string.Format(sqlOil, startYear, endYear);//将对应的参数填充到sql语句中去
DataTable dtCompany = helper.ExecDataTable(sqlOilSelect);//执行sql语句
foreach (DataRow row in dtCompany.Rows)//验证数据并做运算处理
{
int year = CommOp.ToInt(row["ACTIVITYYEAR"]);
if(year==startYear)
{
continue;
}
DataRow tempRow = year == 0 ? null : PerformanceTransfer.GetLastReserves(year, dtCompany);
double lastOilReserves = tempRow == null ? 0 : CommOp.ToDouble(tempRow["OILRESERVES"]);
double lastGasReserves = tempRow == null ? 0 :CommOp.ToDouble(tempRow["GASRESERVES"]);
double dangOilReserves = CommOp.ToDouble(row["OILRESERVES"]);
double oilProduction = CommOp.ToDouble(row["OILSJNCL"]);
double dangGasReserves = CommOp.ToDouble(row["GASRESERVES"]);
double gasProduction = CommOp.ToDouble(row["GASJNCL"]);
models.Add(new ReplacementRateModel
{
Year = year,
DangOilReserves = Math.Round(dangOilReserves,2),
OilProduction = Math.Round(oilProduction,2),
LastOilReserves =Math.Round( lastOilReserves,2),
OilAddReserves = Math.Round(dangOilReserves + oilProduction - lastOilReserves, 2),//石油新增证实储量
OilReplacementRate = oilProduction == 0 ? 0.00 : Math.Round((dangOilReserves + oilProduction - lastOilReserves) / oilProduction,2),
DangGasReserves = Math.Round(dangGasReserves,2),
GasProduction = Math.Round(gasProduction,2),
LastGasReserves =Math.Round( lastGasReserves,2),
GasAddReserves = Math.Round(dangGasReserves + gasProduction - lastGasReserves, 2),//天然气新增证实储量
GasReplacementRate = gasProduction == 0 ? 0.00 : Math.Round((dangGasReserves + gasProduction - lastGasReserves) / gasProduction, 2)
});
}
return models;//返回视图模型,以供页面显示
}
07-22
07-22
07-22
07-22