Files
SGGL_SHJ/SGGL/BLL/DigData/WBSAnalysisService.cs
T
lpf 8efe030f47 refactor: 清理旧模块资源并整理人员服务目录
为收敛当前分支代码范围并统一人员服务目录,移除历史模块与静态资源,减少无效代码和目录分散带来的维护成本。
2026-09-19 13:45:38 +08:00

159 lines
6.4 KiB
C#

using FineUIPro;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace BLL
{
/// <summary>
/// WBS分析
/// </summary>
public static class WBSAnalysisService
{
#region WBS分析
/// <summary>
/// 记录数
/// </summary>
public static int count
{
get;
set;
}
/// <summary>
/// 定义变量
/// </summary>
private static IQueryable<Model.WBS_WorkPackageInit> getDataLists = from x in Funs.DB.WBS_WorkPackageInit
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 workPackageId, Grid Grid1)
{
var getDataList = getDataLists;
if (string.IsNullOrEmpty(workPackageId))
{
List<Model.WBS_WorkPackageInit> listWork = new List<Model.WBS_WorkPackageInit>();
Model.WBS_WorkPackageInit work1 = new Model.WBS_WorkPackageInit
{
WorkPackageCode = "Type1",
PackageContent = "建筑工程",
};
listWork.Add(work1);
Model.WBS_WorkPackageInit work2 = new Model.WBS_WorkPackageInit
{
WorkPackageCode = "Type2",
PackageContent = "安装工程",
};
listWork.Add(work2);
getDataList = listWork.AsQueryable();
}
else
{
if (workPackageId != "1" && workPackageId != "2")
{
getDataList = getDataList.Where(x => x.SuperWorkPack == workPackageId);
if (getDataList.Count() == 0)
{
getDataList = getDataLists.Where(x => x.WorkPackageCode == workPackageId);
}
}
else
{
getDataList = getDataList.Where(x => x.ProjectType == workPackageId && x.SuperWorkPack == null);
}
}
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.WorkPackageCode,
x.PackageContent,
Count1 = getWBSSpotCheckRate(null, x.WorkPackageCode),
Count2 = getWBSSpotCheckDataRate(null, x.WorkPackageCode),
Count3 = getWBSCheckControlCount(null, x.WorkPackageCode),
};
}
#endregion
/// <summary>
/// 实体验收一次合格率
/// </summary>
/// <param name="projectId"></param>
/// <returns></returns>
public static string getWBSSpotCheckRate(string projectId, string workPackageId)
{
var getSpotCheckDetail = from x in Funs.DB.Check_SpotCheckDetail
join y in Funs.DB.Check_SpotCheck on x.SpotCheckCode equals y.SpotCheckCode
where x.WorkPackageId.Contains(workPackageId) && (projectId == null || y.ProjectId == projectId)
&& y.State == "8"
select new { x.SpotCheckCode, y.ProjectId, x.IsDataOK, x.IsOnesOK };
if (!string.IsNullOrEmpty(projectId))
{
getSpotCheckDetail = getSpotCheckDetail.Where(x => x.ProjectId == projectId);
}
int all = getSpotCheckDetail.Count();
// this.lbSpotCheck1.Text = all.ToString();
int onesOKCount = getSpotCheckDetail.Where(x => x.IsOnesOK == true).Count(); //一次合格
return (all > 0 ? Math.Round(onesOKCount * 100.0 / (all * 1.0)).ToString() + "%" : "0%");
}
/// <summary>
/// 施工资料同步率
/// </summary>
/// <param name="projectId"></param>
/// <returns></returns>
public static string getWBSSpotCheckDataRate(string projectId, string workPackageId)
{
//// 实体验收 资料验收
var getSpotCheckDetail = from x in Funs.DB.Check_SpotCheckDetail
join y in Funs.DB.Check_SpotCheck on x.SpotCheckCode equals y.SpotCheckCode
where x.WorkPackageId.Contains(workPackageId)
&& y.State == "8"
select new { x.SpotCheckCode, y.ProjectId, x.IsDataOK, x.IsOnesOK, x.IsOK };
if (!string.IsNullOrEmpty(projectId))
{
getSpotCheckDetail = getSpotCheckDetail.Where(x => x.ProjectId == projectId);
}
/// 资料验收合格项目
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 int getWBSCheckControlCount(string projectId, string workPackageId)
{
var getCheck_CheckControl = from x in Funs.DB.Check_CheckControl
where x.WorkPackageId.Contains(workPackageId)
select x;
if (!string.IsNullOrEmpty(projectId))
{
getCheck_CheckControl = getCheck_CheckControl.Where(x => x.ProjectId == projectId);
}
return getCheck_CheckControl.Count();
}
}
}