增加施工月报
This commit is contained in:
@@ -776,5 +776,245 @@ namespace BLL
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 获取模拟树表格
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static DataTable GetAllTreeDataTableConstructionMonthReport(string projectId, string IsOut, DateTime startTime, DateTime endTime)
|
||||
{
|
||||
using (var db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
IQueryable<Model.WBS_WorkPackage> workPackages = from x in db.WBS_WorkPackage where x.ProjectId == projectId select x;
|
||||
IQueryable<Model.WBS_UnitWork> unitWorks = from x in db.WBS_UnitWork where x.ProjectId == projectId select x;
|
||||
IQueryable<Model.View_WBS_WorkPackageDetail> getDetails = from x in db.View_WBS_WorkPackageDetail where x.ProjectId == projectId select x;
|
||||
List<Model.View_WBS> getWBSs = (from x in db.View_WBS where x.ProjectId == projectId select x).ToList();
|
||||
List<Model.View_WBS> WBSList = new List<Model.View_WBS>();
|
||||
DateTime startDate, endDate, startMonth, endMonth;
|
||||
List<DateTime> months = new List<DateTime>();
|
||||
var project = Funs.DB.Base_Project.FirstOrDefault(x => x.ProjectId == projectId);
|
||||
if (project.StartDate != null)
|
||||
{
|
||||
startDate = Convert.ToDateTime(project.StartDate);
|
||||
endDate = DateTime.Now;
|
||||
if (project.EndDate != null)
|
||||
{
|
||||
endDate = Convert.ToDateTime(project.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);
|
||||
}
|
||||
DataTable table = new DataTable();
|
||||
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("WBSType", typeof(String)));
|
||||
table.Columns.Add(new DataColumn("ProjectId", typeof(String)));
|
||||
table.Columns.Add(new DataColumn("ShowId", typeof(String)));
|
||||
table.Columns.Add(new DataColumn("JDWeights", typeof(String)));
|
||||
table.Columns.Add(new DataColumn("Unit", typeof(String)));
|
||||
table.Columns.Add(new DataColumn("PlanProjectQuantity", typeof(String)));
|
||||
table.Columns.Add(new DataColumn("RealProjectQuantity", typeof(String)));
|
||||
table.Columns.Add(new DataColumn("PlanStartDate", typeof(DateTime)));
|
||||
table.Columns.Add(new DataColumn("PlanEndDate", typeof(DateTime)));
|
||||
table.Columns.Add(new DataColumn("RealStartDate", typeof(DateTime)));
|
||||
table.Columns.Add(new DataColumn("RealEndDate", typeof(DateTime)));
|
||||
table.Columns.Add(new DataColumn("IsMileStone", typeof(bool)));
|
||||
table.Columns.Add(new DataColumn("PlanCost", typeof(String)));
|
||||
table.Columns.Add(new DataColumn("PreWorkCode", typeof(String)));
|
||||
table.Columns.Add(new DataColumn("Code", 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)));
|
||||
}
|
||||
if (getWBSs.Count() > 0)
|
||||
{
|
||||
List<Model.View_WBS> newList = new List<Model.View_WBS>();
|
||||
var projectTypes = getWBSs.Where(x => x.WBSType == "ProjectType" && x.SupId == "0");
|
||||
int a = 1;
|
||||
foreach (var item in projectTypes)
|
||||
{
|
||||
item.Code = a.ToString();
|
||||
newList.Add(item);
|
||||
if (string.IsNullOrEmpty(IsOut))
|
||||
{
|
||||
AddDetail2(newList, getWBSs.ToList(), item.Id, a.ToString(), startTime, endTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddDetail2(newList, getWBSs.ToList(), item.Id, a.ToString(), string.Empty, startTime, endTime);
|
||||
}
|
||||
a++;
|
||||
}
|
||||
DataRow row;
|
||||
foreach (Model.View_WBS item in newList)
|
||||
{
|
||||
row = table.NewRow();
|
||||
row[0] = item.Id;
|
||||
row[1] = item.SupId;
|
||||
row[2] = item.Name;
|
||||
row[3] = item.WBSType;
|
||||
row[4] = item.ProjectId;
|
||||
if (item.WBSType == "WorkPackage")
|
||||
{
|
||||
var childWorkPackages = from x in workPackages where x.SuperWorkPackageId == item.Id && x.IsApprove == true select x;
|
||||
var workPackage = workPackages.FirstOrDefault(x => x.WorkPackageId == item.Id);
|
||||
if (workPackage != null)
|
||||
{
|
||||
if (childWorkPackages.Count() == 0)
|
||||
{
|
||||
row[5] = item.Id;
|
||||
if (workPackage.JDWeights != null)
|
||||
{
|
||||
row[6] = decimal.Round(Convert.ToDecimal(workPackage.JDWeights), 2);
|
||||
}
|
||||
row[7] = workPackage.Unit;
|
||||
if (workPackage.PlanProjectQuantity != null)
|
||||
{
|
||||
row[8] = decimal.Round(Convert.ToDecimal(workPackage.PlanProjectQuantity), 2);
|
||||
}
|
||||
if (workPackage.RealProjectQuantity != null)
|
||||
{
|
||||
row[9] = decimal.Round(Convert.ToDecimal(workPackage.RealProjectQuantity), 2);
|
||||
}
|
||||
if (workPackage.PlanStartDate != null)
|
||||
{
|
||||
row[10] = workPackage.PlanStartDate;
|
||||
}
|
||||
if (workPackage.PlanEndDate != null)
|
||||
{
|
||||
row[11] = workPackage.PlanEndDate;
|
||||
}
|
||||
if (workPackage.RealStartDate != null)
|
||||
{
|
||||
row[12] = workPackage.RealStartDate;
|
||||
}
|
||||
if (workPackage.RealEndDate != null)
|
||||
{
|
||||
row[13] = workPackage.RealEndDate;
|
||||
}
|
||||
if (workPackage.IsMileStone != null)
|
||||
{
|
||||
row[14] = workPackage.IsMileStone;
|
||||
}
|
||||
if (workPackage.PlanCost != null)
|
||||
{
|
||||
row[15] = decimal.Round(Convert.ToDecimal(workPackage.PlanCost), 2);
|
||||
}
|
||||
row[16] = workPackage.PreWorkCode;
|
||||
var details = getDetails.Where(x => x.WorkPackageId == item.Id).ToList();
|
||||
foreach (var item1 in details)
|
||||
{
|
||||
var index = months.FindIndex(x => x.Equals(item1.Months));
|
||||
if (item1.PlanNum != 0)
|
||||
{
|
||||
row[18 + index * 2] = decimal.Round(Convert.ToDecimal(item1.PlanNum), 2);
|
||||
}
|
||||
if (item1.ThisNum != 0)
|
||||
{
|
||||
row[19 + index * 2] = decimal.Round(Convert.ToDecimal(item1.ThisNum), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (workPackage.JDWeights != null)
|
||||
{
|
||||
row[6] = decimal.Round(Convert.ToDecimal(workPackage.JDWeights), 2);
|
||||
}
|
||||
if (workPackage.PlanStartDate != null)
|
||||
{
|
||||
row[10] = workPackage.PlanStartDate;
|
||||
}
|
||||
if (workPackage.PlanEndDate != null)
|
||||
{
|
||||
row[11] = workPackage.PlanEndDate;
|
||||
}
|
||||
if (workPackage.RealStartDate != null)
|
||||
{
|
||||
row[12] = workPackage.RealStartDate;
|
||||
}
|
||||
if (workPackage.RealEndDate != null)
|
||||
{
|
||||
row[13] = workPackage.RealEndDate;
|
||||
}
|
||||
if (workPackage.PlanCost != null)
|
||||
{
|
||||
row[15] = decimal.Round(Convert.ToDecimal(workPackage.PlanCost), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (item.WBSType == "UnitWork")
|
||||
{
|
||||
var unitWork = unitWorks.FirstOrDefault(x => x.UnitWorkId == item.Id);
|
||||
if (unitWork != null)
|
||||
{
|
||||
if (unitWork.JDWeights != null)
|
||||
{
|
||||
row[6] = decimal.Round(Convert.ToDecimal(unitWork.JDWeights), 2);
|
||||
}
|
||||
if (unitWork.PlanStartDate != null)
|
||||
{
|
||||
row[10] = unitWork.PlanStartDate;
|
||||
}
|
||||
if (unitWork.PlanEndDate != null)
|
||||
{
|
||||
row[11] = unitWork.PlanEndDate;
|
||||
}
|
||||
if (unitWork.RealStartDate != null)
|
||||
{
|
||||
row[12] = unitWork.RealStartDate;
|
||||
}
|
||||
if (unitWork.RealEndDate != null)
|
||||
{
|
||||
row[13] = unitWork.RealEndDate;
|
||||
}
|
||||
if (unitWork.PlanCost != null)
|
||||
{
|
||||
row[15] = decimal.Round(Convert.ToDecimal(unitWork.PlanCost), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
row[17] = item.Code;
|
||||
table.Rows.Add(row);
|
||||
}
|
||||
}
|
||||
return table;
|
||||
}
|
||||
}
|
||||
|
||||
private static void AddDetail2(List<Model.View_WBS> newList, List<Model.View_WBS> oldList, string id, string preCode, DateTime startTime, DateTime endTime)
|
||||
{
|
||||
var items = oldList.Where(x => x.SupId == id && x.PlanEndDate > startTime && x.PlanEndDate <= endTime).OrderBy(x => x.WBSCode);
|
||||
int b = 1;
|
||||
foreach (var item in items)
|
||||
{
|
||||
item.Code = preCode + "." + b.ToString();
|
||||
newList.Add(item);
|
||||
AddDetail2(newList, oldList, item.Id, item.Code, startTime, endTime);
|
||||
b++;
|
||||
}
|
||||
}
|
||||
|
||||
private static void AddDetail2(List<Model.View_WBS> newList, List<Model.View_WBS> oldList, string id, string preCode, string prefix, DateTime startTime, DateTime endTime)
|
||||
{
|
||||
var items = oldList.Where(x => x.SupId == id && x.PlanEndDate > startTime && x.PlanEndDate <= endTime).OrderBy(x => x.WBSCode);
|
||||
int b = 1;
|
||||
foreach (var item in items)
|
||||
{
|
||||
item.Code = preCode + "." + b.ToString();
|
||||
item.Name = prefix + "...." + item.Name;
|
||||
newList.Add(item);
|
||||
AddDetail2(newList, oldList, item.Id, item.Code, prefix + "....", startTime, endTime);
|
||||
b++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user