82 lines
2.6 KiB
C#
82 lines
2.6 KiB
C#
using FineUIPro;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Linq;
|
|
|
|
namespace BLL
|
|
{
|
|
/// <summary>
|
|
/// 合同管理数据仓库
|
|
/// </summary>
|
|
public static class HTGLDataDWService
|
|
{
|
|
#region 合同管理数据仓库
|
|
/// <summary>
|
|
/// 记录数
|
|
/// </summary>
|
|
public static int count
|
|
{
|
|
get;
|
|
set;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 定义变量
|
|
/// </summary>
|
|
private static IQueryable<Model.Base_Project> getDataLists = from x in Funs.DB.Base_Project
|
|
select x;
|
|
|
|
/// <summary>
|
|
/// 合同管理数据仓库
|
|
/// </summary>
|
|
/// <param name="projectId"></param>
|
|
/// <param name="startTime"></param>
|
|
/// <param name="endTime"></param>
|
|
/// <param name="Grid1"></param>
|
|
/// <returns></returns>
|
|
public static IEnumerable getDataDWList(string projectId, Grid Grid1)
|
|
{
|
|
var getDataList = from x in Funs.DB.Base_Project select x;
|
|
if (!string.IsNullOrEmpty(projectId) && projectId != Const._Null)
|
|
{
|
|
getDataList = getDataList.Where(x => x.ProjectId == projectId);
|
|
}
|
|
|
|
count = getDataList.Count();
|
|
if (count == 0)
|
|
{
|
|
return null;
|
|
}
|
|
getDataList = SortConditionHelper.SortingAndPaging(getDataList, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize);
|
|
return from x in getDataList
|
|
select new
|
|
{
|
|
x.ProjectId,
|
|
x.ProjectName,
|
|
x.ProjectCode,
|
|
Count1 = getTotalProfit(x.ProjectId),
|
|
};
|
|
}
|
|
#endregion
|
|
|
|
public static string getTotalProfit(string projectId)
|
|
{
|
|
decimal contractAmount = 0;
|
|
var getContract = Funs.DB.PHTGL_Contract.Where(x => x.ProjectId == projectId);
|
|
if (getContract.Count() > 0)
|
|
{
|
|
contractAmount = getContract.Sum(x => x.ContractAmount ?? 0);
|
|
}
|
|
|
|
decimal estimatedAmount = 0;
|
|
var getContractTrack = Funs.DB.PHTGL_ContractTrack.Where(x => x.ProjectId == projectId);
|
|
if (getContractTrack.Count() > 0)
|
|
{
|
|
estimatedAmount = getContractTrack.Sum(x => x.EstimatedAmount ?? 0);
|
|
}
|
|
|
|
return estimatedAmount > 0 ? Math.Round(contractAmount / estimatedAmount).ToString() + "%" : "0%";
|
|
|
|
}
|
|
}
|
|
} |