大数据数据绑定
This commit is contained in:
@@ -26,7 +26,8 @@ namespace BLL
|
||||
/// 定义变量
|
||||
/// </summary>
|
||||
private static IQueryable<Model.Base_Project> getDataLists = from x in db.Base_Project
|
||||
select x;
|
||||
where x.ProjectState == Const.ProjectState_1
|
||||
select x;
|
||||
|
||||
/// <summary>
|
||||
/// 质量数据仓库
|
||||
@@ -38,7 +39,7 @@ namespace BLL
|
||||
/// <returns></returns>
|
||||
public static IEnumerable getDataDWList( string projectId, DateTime? startTime, DateTime? endTime, Grid Grid1)
|
||||
{
|
||||
var getDataList = from x in Funs.DB.Base_Project select x;
|
||||
IQueryable<Model.Base_Project> getDataList = getDataLists;
|
||||
if (!string.IsNullOrEmpty(projectId) && projectId != Const._Null)
|
||||
{
|
||||
getDataList = getDataList.Where(x => x.ProjectId == projectId);
|
||||
@@ -56,13 +57,87 @@ namespace BLL
|
||||
x.ProjectId,
|
||||
x.ProjectName,
|
||||
x.ProjectCode,
|
||||
Rate1 = "0%", //质量验收问题整改率
|
||||
Rate2 = "0%", //控制点完成率
|
||||
Rate3 = "0%", //质量检查问题整改率
|
||||
Rate4 = "0%", //管道焊接一次合格率
|
||||
Rate1 = getSpotCheckRate(x.ProjectId), //质量验收问题整改率
|
||||
Rate2 = getSpotCheckDataRate(x.ProjectId), //控制点完成率
|
||||
Rate3 = getCheckControlStates(x.ProjectId), //质量检查问题整改率
|
||||
Rate4 = getFirstPassRate(x.ProjectId), //管道焊接一次合格率
|
||||
};
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 质量验收问题整改率
|
||||
/// </summary>
|
||||
/// <param name="projectId"></param>
|
||||
/// <returns></returns>
|
||||
public static string getSpotCheckRate(string projectId)
|
||||
{
|
||||
|
||||
//// 实体验收 资料验收
|
||||
var getSpotCheckDetail = from x in Funs.DB.Check_SpotCheckDetail
|
||||
join y in Funs.DB.Check_SpotCheck on x.SpotCheckCode equals y.SpotCheckCode
|
||||
where (y.ProjectId == projectId || projectId == null) && y.State == "8"
|
||||
select x;
|
||||
int all = getSpotCheckDetail.Count();
|
||||
// this.lbSpotCheck1.Text = all.ToString();
|
||||
int onesOKCount = getSpotCheckDetail.Where(x => x.IsOnesOK == true).Count(); //一次合格
|
||||
// this.lbSpotCheck2.Text= okCount.ToString();
|
||||
|
||||
return all > 0 ? Math.Round(onesOKCount * 100.0 / (all * 1.0)).ToString() + "%" : "0%";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 控制点完成率
|
||||
/// </summary>
|
||||
/// <param name="projectId"></param>
|
||||
/// <returns></returns>
|
||||
public static string getSpotCheckDataRate(string projectId)
|
||||
{
|
||||
var getSpotCheckDetail = from x in Funs.DB.Check_SpotCheckDetail
|
||||
join y in Funs.DB.Check_SpotCheck on x.SpotCheckCode equals y.SpotCheckCode
|
||||
where (y.ProjectId == projectId || projectId == null) && y.State == "8"
|
||||
select x;
|
||||
/// 资料验收合格项目
|
||||
var getOKSpotCheckDetail = getSpotCheckDetail.Where(x => x.IsOK == true);
|
||||
int okYSCount = getOKSpotCheckDetail.Count(); //验收合格
|
||||
int okDateCount = getSpotCheckDetail.Where(x => x.IsDataOK == "1").Count(); //资料合格
|
||||
return okYSCount > 0 ? Math.Round(okDateCount * 100.0 / (okYSCount * 1.0)).ToString() + "%" : "0%";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 质量检查问题整改率
|
||||
/// </summary>
|
||||
/// <param name="projectId"></param>
|
||||
/// <returns></returns>
|
||||
public static string getCheckControlStates(string projectId)
|
||||
{
|
||||
var getCheck_CheckControl = from x in Funs.DB.Check_CheckControl
|
||||
where (x.ProjectId == projectId || projectId == null)
|
||||
select x;
|
||||
int allCheckControlCount = getCheck_CheckControl.Count();
|
||||
int okCheckControlCount = getCheck_CheckControl.Where(x => x.State == "7").Count(); ///已整改
|
||||
return allCheckControlCount > 0 ? Math.Round(okCheckControlCount * 100.0 / (allCheckControlCount * 1.0)).ToString() + "%" : "0%";
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 管道焊接一次合格率
|
||||
/// </summary>
|
||||
/// <param name="projectId"></param>
|
||||
/// <returns></returns>
|
||||
public static string getFirstPassRate(string projectId)
|
||||
{
|
||||
var getJots = from x in Funs.DB.HJGL_Batch_NDEItem
|
||||
join y in Funs.DB.HJGL_Batch_BatchTrustItem on x.TrustBatchItemId equals y.TrustBatchItemId
|
||||
join z in Funs.DB.HJGL_Batch_PointBatchItem on y.PointBatchItemId equals z.PointBatchItemId
|
||||
join a in Funs.DB.HJGL_Batch_NDE on x.NDEID equals a.NDEID
|
||||
where z.PointDate != null && z.PointState == "1" && y.RepairRecordId == null
|
||||
&& (a.ProjectId == projectId || projectId == null)
|
||||
select x;
|
||||
int allHJCount = getJots.Count();
|
||||
var getOk = getJots.Where(x => x.CheckResult == "1");
|
||||
int okHJCount = getOk.Count();
|
||||
return allHJCount > 0 ? Math.Round(okHJCount * 100.0 / (allHJCount * 1.0)).ToString() + "%" : "0%";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,8 @@ namespace BLL
|
||||
/// 定义变量
|
||||
/// </summary>
|
||||
private static IQueryable<Model.Base_Project> getDataLists = from x in db.Base_Project
|
||||
select x;
|
||||
where x.ProjectState == Const.ProjectState_1
|
||||
select x;
|
||||
|
||||
/// <summary>
|
||||
/// 安全数据仓库
|
||||
@@ -38,7 +39,7 @@ namespace BLL
|
||||
/// <returns></returns>
|
||||
public static IEnumerable getDataDWList( string projectId, DateTime? startTime, DateTime? endTime, Grid Grid1)
|
||||
{
|
||||
var getDataList = from x in Funs.DB.Base_Project select x;
|
||||
IQueryable<Model.Base_Project> getDataList = getDataLists;
|
||||
if (!string.IsNullOrEmpty(projectId) && projectId != Const._Null)
|
||||
{
|
||||
getDataList = getDataList.Where(x => x.ProjectId == projectId);
|
||||
@@ -56,13 +57,48 @@ namespace BLL
|
||||
x.ProjectId,
|
||||
x.ProjectName,
|
||||
x.ProjectCode,
|
||||
Count1=0, //人员数量
|
||||
Count2 =0, //安全人工时
|
||||
Count3 =0, //安全培训次数
|
||||
ProblemRate = "0%", //安全巡检整改率
|
||||
Count1=db.SitePerson_Person.Where(p=>p.ProjectId == x.ProjectId && p.States == Const.ProjectPersonStates_1).Count(), //人员数量
|
||||
Count2 = getProjecctSafeHours(x.ProjectId), //安全人工时
|
||||
Count3 =db.EduTrain_TrainRecord.Where(p => p.ProjectId == x.ProjectId && p.States == BLL.Const.State_2).Count(), //安全培训次数
|
||||
ProblemRate = getProblemRate(x.ProjectId), //安全巡检整改率
|
||||
};
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 安全人工时
|
||||
/// </summary>
|
||||
/// <param name="projectId"></param>
|
||||
/// <returns></returns>
|
||||
public static int getProjecctSafeHours(string projectId)
|
||||
{
|
||||
int count = 0;
|
||||
var getPersonInOutNumber = (from x in Funs.DB.SitePerson_PersonInOutNumber
|
||||
where (x.ProjectId == projectId || projectId == null)
|
||||
select x).OrderByDescending(x => x.InOutDate).FirstOrDefault();
|
||||
if (getPersonInOutNumber != null)
|
||||
{
|
||||
count = getPersonInOutNumber.WorkHours ?? 0;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 安全问题整改率
|
||||
/// </summary>
|
||||
/// <param name="projectId"></param>
|
||||
/// <returns></returns>
|
||||
public static string getProblemRate(string projectId)
|
||||
{
|
||||
var getAllHazardRegister = from x in Funs.DB.HSSE_Hazard_HazardRegister
|
||||
where (x.ProjectId == projectId || projectId == null)
|
||||
&& x.States != null && x.States != "4" && x.States != "0"
|
||||
select x;
|
||||
int allHazardCount = getAllHazardRegister.Count();
|
||||
int cHazardCount = getAllHazardRegister.Where(x => x.States == "3").Count();
|
||||
return allHazardCount > 0 ? Math.Round(cHazardCount * 100.0 / (allHazardCount * 1.0)).ToString() + "%" : "0%";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ namespace BLL
|
||||
/// 定义变量
|
||||
/// </summary>
|
||||
private static IQueryable<Model.Base_Project> getDataLists = from x in db.Base_Project
|
||||
select x;
|
||||
select x;
|
||||
|
||||
/// <summary>
|
||||
/// 进度数据仓库
|
||||
@@ -36,7 +36,7 @@ namespace BLL
|
||||
/// <param name="endTime"></param>
|
||||
/// <param name="Grid1"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable getDataDWList( string projectId, DateTime? startTime, DateTime? endTime, Grid Grid1)
|
||||
public static IEnumerable getDataDWList(string projectId, DateTime? startTime, DateTime? endTime, Grid Grid1)
|
||||
{
|
||||
var getDataList = from x in Funs.DB.Base_Project select x;
|
||||
if (!string.IsNullOrEmpty(projectId) && projectId != Const._Null)
|
||||
@@ -56,10 +56,44 @@ namespace BLL
|
||||
x.ProjectId,
|
||||
x.ProjectName,
|
||||
x.ProjectCode,
|
||||
JDRate = "0%", //项目进度完成百分比
|
||||
JDRate = getJDRate(x.ProjectId, startTime, endTime), //项目进度完成百分比
|
||||
};
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 进度百分比
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string getJDRate(string projectId, DateTime? startTime, DateTime? endTime)
|
||||
{
|
||||
double totalSJCost = 0; ////累计实际费用
|
||||
decimal totalPlanCost = 0; ////计划费用
|
||||
var getViewWorkPackageParentDetail = from x in Funs.DB.View_WBS_WorkPackageParentDetail
|
||||
where (x.ProjectId == projectId || projectId == null) && (x.ParentId == "1" || x.ParentId == "2")
|
||||
select x;
|
||||
if (startTime.HasValue)
|
||||
{
|
||||
getViewWorkPackageParentDetail = getViewWorkPackageParentDetail.Where(x => x.Months >= startTime);
|
||||
}
|
||||
if (endTime.HasValue)
|
||||
{
|
||||
getViewWorkPackageParentDetail = getViewWorkPackageParentDetail.Where(x => x.Months <= endTime);
|
||||
}
|
||||
if (getViewWorkPackageParentDetail.Count() > 0)
|
||||
{
|
||||
totalSJCost = getViewWorkPackageParentDetail.Sum(x => x.TotalThisValue ?? 0);
|
||||
}
|
||||
|
||||
var getUnitWork = from x in Funs.DB.WBS_UnitWork where x.ProjectId == projectId select x;
|
||||
if (getUnitWork.Count() > 0)
|
||||
{
|
||||
totalPlanCost = getUnitWork.Sum(x => x.PlanCost ?? 0);
|
||||
}
|
||||
|
||||
///项目进度完成百分比
|
||||
decimal s = Convert.ToDecimal(totalSJCost);
|
||||
return totalPlanCost > 0 ? Math.Round(s / totalPlanCost).ToString() + "%" : "0%";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user