0522-001
This commit is contained in:
@@ -2542,5 +2542,161 @@ namespace BLL
|
||||
AddDetail(newList, oldList, item.Id);
|
||||
}
|
||||
}
|
||||
|
||||
private static void AddDetailOut(List<Model.View_WBS_CostControlDetailStatistics> newList, List<Model.View_WBS_CostControlDetailStatistics> oldList, string id, string prefix)
|
||||
{
|
||||
var items = oldList.Where(x => x.SupId == id).OrderBy(x => x.Code);
|
||||
foreach (var item in items)
|
||||
{
|
||||
item.Name = prefix + "...." + item.Name;
|
||||
newList.Add(item);
|
||||
AddDetailOut(newList, oldList, item.Id, prefix + "....");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取模拟树表格
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static DataTable GetAllTreeDataTable(string projectId, string IsOut)
|
||||
{
|
||||
List<Model.View_WBS_CostControlDetailStatistics> CostControlDetailStatisticsList = new List<Model.View_WBS_CostControlDetailStatistics>();
|
||||
DataTable table = new DataTable();
|
||||
var installation = Funs.DB.Project_Installation.FirstOrDefault(x => x.SuperInstallationId == "0" && x.ProjectId == projectId);
|
||||
if (installation != null)
|
||||
{
|
||||
DateTime startDate, endDate, startMonth, endMonth;
|
||||
List<DateTime> months = new List<DateTime>();
|
||||
if (installation.StartDate != null && installation.EndDate != null)
|
||||
{
|
||||
startDate = Convert.ToDateTime(installation.StartDate);
|
||||
endDate = Convert.ToDateTime(installation.EndDate);
|
||||
startMonth = Convert.ToDateTime(startDate.Year + "-" + startDate.Month + "-01");
|
||||
endMonth = Convert.ToDateTime(endDate.Year + "-" + endDate.Month + "-01");
|
||||
do
|
||||
{
|
||||
months.Add(startMonth);
|
||||
startMonth = startMonth.AddMonths(1);
|
||||
} while (startMonth <= endMonth);
|
||||
}
|
||||
|
||||
table.Columns.Add(new DataColumn("Id", typeof(String)));
|
||||
table.Columns.Add(new DataColumn("SupId", typeof(String)));
|
||||
table.Columns.Add(new DataColumn("Name", typeof(String)));
|
||||
table.Columns.Add(new DataColumn("ProjectId", typeof(String)));
|
||||
table.Columns.Add(new DataColumn("Unit", typeof(String)));
|
||||
table.Columns.Add(new DataColumn("TotalNum", typeof(String)));
|
||||
table.Columns.Add(new DataColumn("RealPrice", typeof(String)));
|
||||
table.Columns.Add(new DataColumn("PlanPrice", typeof(String)));
|
||||
for (int i = 0; i < months.Count; i++)
|
||||
{
|
||||
table.Columns.Add(new DataColumn("PlanNum" + (i + 1).ToString(), typeof(String)));
|
||||
table.Columns.Add(new DataColumn("ThisNum" + (i + 1).ToString(), typeof(String)));
|
||||
}
|
||||
table.Columns.Add(new DataColumn("ShowId", typeof(String)));
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
var costControls = from x in db.WBS_CostControl where x.ProjectId == projectId select x;
|
||||
var details = from x in db.View_WBS_CostControlDetail where x.ProjectId == projectId select x;
|
||||
var parentDetails = from x in db.View_WBS_CostControlParentDetail select x;
|
||||
var wbsSets = from x in db.Wbs_WbsSet where x.ProjectId == projectId select x;
|
||||
var wbsSetInits = from x in db.WBS_WbsSetInit select x;
|
||||
var unitProjects = from x in db.Wbs_UnitProject where x.ProjectId == projectId select x;
|
||||
var unitProjectInits = from x in db.Wbs_UnitProjectInit select x;
|
||||
var cnProfessions = from x in db.WBS_CnProfession where x.ProjectId == projectId select x;
|
||||
var cnProfessionInits = from x in db.WBS_CnProfessionInit select x;
|
||||
var installations = from x in db.Project_Installation where x.ProjectId == projectId select x;
|
||||
CostControlDetailStatisticsList = (from x in db.View_WBS_CostControlDetailStatistics where x.ProjectId == projectId select x).Distinct().ToList();
|
||||
List<Model.View_WBS_CostControlDetailStatistics> newList = new List<Model.View_WBS_CostControlDetailStatistics>();
|
||||
var installationList = CostControlDetailStatisticsList.Where(x => x.WBSType == "Installation" && x.SupId == "0");
|
||||
foreach (var item in installationList)
|
||||
{
|
||||
newList.Add(item);
|
||||
if (string.IsNullOrEmpty(IsOut))
|
||||
{
|
||||
AddDetail(newList, CostControlDetailStatisticsList, item.Id);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddDetailOut(newList, CostControlDetailStatisticsList, item.Id, string.Empty);
|
||||
}
|
||||
}
|
||||
DataRow row;
|
||||
foreach (Model.View_WBS_CostControlDetailStatistics item in newList)
|
||||
{
|
||||
row = table.NewRow();
|
||||
row[0] = item.Id;
|
||||
row[1] = item.SupId;
|
||||
row[2] = item.Name;
|
||||
row[3] = item.ProjectId;
|
||||
Model.WBS_CostControl costControl = costControls.FirstOrDefault(x => x.CostControlId == item.Id);
|
||||
if (costControl != null)
|
||||
{
|
||||
row[4] = costControl.Unit;//单位
|
||||
if (costControl.TotalNum != null)
|
||||
{
|
||||
row[5] = decimal.Round(Convert.ToDecimal(costControl.TotalNum), 2);//合同工作量
|
||||
}
|
||||
if (costControl.RealPrice != null)
|
||||
{
|
||||
row[6] = decimal.Round(Convert.ToDecimal(costControl.RealPrice), 2);//成本单价
|
||||
}
|
||||
if (costControl.PlanPrice != null)
|
||||
{
|
||||
row[7] = decimal.Round(Convert.ToDecimal(costControl.PlanPrice), 2);//控制预算单价
|
||||
}
|
||||
for (int i = 0; i < months.Count; i++)
|
||||
{
|
||||
Model.View_WBS_CostControlDetail detail = details.FirstOrDefault(x => x.CostControlId == item.Id && x.Months == months[i]);
|
||||
if (detail != null)
|
||||
{
|
||||
if (detail.PlanNum != 0)
|
||||
{
|
||||
row[8 + i * 2] = decimal.Round(Convert.ToDecimal(detail.PlanNum), 2);
|
||||
}
|
||||
if (detail.ThisNum != 0)
|
||||
{
|
||||
row[9 + i * 2] = decimal.Round(Convert.ToDecimal(detail.ThisNum), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
row[10 + (months.Count-1) * 2] = item.Id;
|
||||
//row[10] = decimal.Round(Convert.ToDecimal(detail.ThisRealCost), 2);//本月实际成本
|
||||
//row[11] = decimal.Round(Convert.ToDecimal(detail.ThisPlanValue), 2);//本月计划完成预算
|
||||
//row[12] = decimal.Round(Convert.ToDecimal(detail.ThisPlanCost), 2);//本月完成预算
|
||||
//row[13] = decimal.Round(Convert.ToDecimal(detail.TotalPlanNum), 2);//累计计划完成量
|
||||
//row[14] = decimal.Round(Convert.ToDecimal(detail.TotalThisNum), 2);//累计完成量
|
||||
//row[15] = decimal.Round(Convert.ToDecimal(detail.TotalRealCost), 2);//累计完成成本
|
||||
//row[16] = decimal.Round(Convert.ToDecimal(detail.TotalPlanValue), 2);//累计计划完成预算
|
||||
//row[17] = decimal.Round(Convert.ToDecimal(detail.TotalPlanCost), 2);//累计完成预算
|
||||
}
|
||||
else
|
||||
{
|
||||
//Model.View_WBS_CostControlParentDetail parentDetail = parentDetails.FirstOrDefault(x => x.ParentId == item.Id && x.Months == months);
|
||||
//if (parentDetail != null)
|
||||
//{
|
||||
// row[10] = decimal.Round(Convert.ToDecimal(parentDetail.ThisRealCost), 2);//本月实际成本
|
||||
// row[11] = decimal.Round(Convert.ToDecimal(parentDetail.ThisPlanValue), 2);//本月计划完成预算
|
||||
// row[12] = decimal.Round(Convert.ToDecimal(parentDetail.ThisPlanCost), 2);//本月完成预算
|
||||
// row[15] = decimal.Round(Convert.ToDecimal(parentDetail.TotalRealCost), 2);//累计完成成本
|
||||
// row[16] = decimal.Round(Convert.ToDecimal(parentDetail.TotalPlanValue), 2);//累计计划完成预算
|
||||
// row[17] = decimal.Round(Convert.ToDecimal(parentDetail.TotalPlanCost), 2);//累计完成预算
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// Model.View_WBS_CostControlParentDetail parentLastDetail = parentDetails.OrderByDescending(x => x.Months).FirstOrDefault(x => x.ParentId == item.Id);
|
||||
// if (parentLastDetail != null && parentLastDetail.Months <= months)
|
||||
// {
|
||||
// row[15] = decimal.Round(Convert.ToDecimal(parentLastDetail.TotalRealCost), 2);//累计完成成本
|
||||
// row[16] = decimal.Round(Convert.ToDecimal(parentLastDetail.TotalPlanValue), 2);//累计计划完成预算
|
||||
// row[17] = decimal.Round(Convert.ToDecimal(parentLastDetail.TotalPlanCost), 2);//累计完成预算
|
||||
// }
|
||||
//}
|
||||
}
|
||||
table.Rows.Add(row);
|
||||
}
|
||||
}
|
||||
return table;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user