试压看板增加排序和单位工程的试压包完成率
This commit is contained in:
@@ -680,9 +680,63 @@ namespace BLL
|
||||
if (!(totalJointNum > totalWeldingJointNum) && !(notCloseBatch > 0) && !(allPointJointNum > allOKCheckNum))
|
||||
passCount = result.TotalPipelines;
|
||||
}
|
||||
// 计算是否具备试压条件:全通过数量 == 管线数量且管线数>0
|
||||
result.CanPressureTest = (result.TotalPipelines > 0 && passCount == result.TotalPipelines);
|
||||
result.PassPipelines = passCount;// 全通过管线数
|
||||
// 计算管线通过率
|
||||
result.PipelinePassPercent = result.TotalPipelines > 0 ? Math.Round((decimal)passCount / result.TotalPipelines * 100, 2) : 0M;
|
||||
// 设置试压条件状态:>=100% -> 已具备;>=80% and <100% -> 易具备;<80% -> 未具备
|
||||
if (result.PipelinePassPercent >= 100M)
|
||||
{
|
||||
result.CanPressureTest = "已具备";
|
||||
}
|
||||
else if (result.PipelinePassPercent >= 80M)
|
||||
{
|
||||
result.CanPressureTest = "易具备";
|
||||
}
|
||||
else
|
||||
{
|
||||
result.CanPressureTest = "未具备";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取单位工程下已完成试压包的通过率(完成试压包的通过数/总数*100,保留两位小数)
|
||||
/// </summary>
|
||||
/// <param name="projectId">项目ID</param>
|
||||
/// <param name="unitWorkId">单位工程ID</param>
|
||||
/// <returns>完成率百分比</returns>
|
||||
public static decimal GetTestPackagePassPercentByUnitWorkId(string projectId, string unitWorkId)
|
||||
{
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
// 获取该单位工程下所有试压包
|
||||
int totalPipelines = db.PTP_TestPackage.Count(x => x.ProjectId == projectId && x.UnitWorkId == unitWorkId) ;
|
||||
if (totalPipelines == 0)
|
||||
return 0M;
|
||||
int finishedPipelines = db.PTP_TestPackage.Count(x => x.ProjectId == projectId && x.UnitWorkId == unitWorkId&&x.FinishDate.HasValue);
|
||||
if (totalPipelines == 0)
|
||||
return 0M;
|
||||
return Math.Round((decimal)finishedPipelines / totalPipelines * 100, 2);
|
||||
}
|
||||
public static Dictionary<string, decimal> GetTestPackagePassPercentByProjectId(string projectId)
|
||||
{
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
Dictionary<string, decimal> dic = new Dictionary<string, decimal>();
|
||||
// 获取该项目下所有单位工程分组统计
|
||||
var groupQuery = db.PTP_TestPackage
|
||||
.Where(x => x.ProjectId == projectId)
|
||||
.GroupBy(x => x.UnitWorkId)
|
||||
.Select(g => new {
|
||||
UnitWorkId = g.Key,
|
||||
Total = g.Count(),
|
||||
Finished = g.Count(t => t.FinishDate.HasValue)
|
||||
}).ToList();
|
||||
foreach (var item in groupQuery)
|
||||
{
|
||||
decimal percent = item.Total > 0 ? Math.Round((decimal)item.Finished / item.Total * 100, 2) : 0M;
|
||||
dic[item.UnitWorkId] = percent;
|
||||
}
|
||||
return dic;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user