224 lines
9.3 KiB
C#
224 lines
9.3 KiB
C#
using FineUIPro;
|
|
using Microsoft.SqlServer.Dts.Runtime;
|
|
using NPOI.SS.Formula.Functions;
|
|
using Org.BouncyCastle.Crypto.Tls;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace BLL
|
|
{
|
|
/// <summary>
|
|
/// WBS分析
|
|
/// </summary>
|
|
public static class WBSAnalysisService
|
|
{
|
|
public static Model.SGGLDB db = Funs.DB;
|
|
|
|
#region WBS分析
|
|
/// <summary>
|
|
/// 记录数
|
|
/// </summary>
|
|
public static int count
|
|
{
|
|
get;
|
|
set;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 定义变量
|
|
/// </summary>
|
|
private static IQueryable<Model.WBS_WorkPackageInit> getDataLists = from x in 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= getWBSExpertArgumentCount(null, x.WorkPackageCode),
|
|
Count2 = getWBSAccidentCount(null,x.WorkPackageCode),
|
|
Count3 = getWBSHSEProblemCount(null, x.WorkPackageCode),
|
|
Count4 = getWBSSpotCheckRate(null, x.WorkPackageCode),
|
|
Count5 = getWBSSpotCheckDataRate(null, x.WorkPackageCode),
|
|
Count6 = getWBSCheckControlCount(null, x.WorkPackageCode),
|
|
};
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 危大工程数量
|
|
/// </summary>
|
|
/// <param name="projectId"></param>
|
|
/// <returns></returns>
|
|
public static int getWBSExpertArgumentCount(string projectId,string workPackageId)
|
|
{
|
|
var getLargerHazardListItem = from x in Funs.DB.Solution_LargerHazardListItem
|
|
join y in Funs.DB.Solution_LargerHazardList on x.LargerHazardListId equals y.LargerHazardListId
|
|
where x.WorkPackageId.Contains(workPackageId)
|
|
&& y.States == Const.State_1
|
|
select new {x.LargerHazardListItemId,y.LargerHazardListId,y.ProjectId,x.WorkPackageId };
|
|
if (!string.IsNullOrEmpty(projectId))
|
|
{
|
|
getLargerHazardListItem = getLargerHazardListItem.Where(x => x.ProjectId == projectId);
|
|
}
|
|
|
|
return getLargerHazardListItem.Count();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 安全事故数量
|
|
/// </summary>
|
|
/// <param name="projectId"></param>
|
|
/// <returns></returns>
|
|
public static int getWBSAccidentCount(string projectId, string workPackageId)
|
|
{
|
|
var getAccidentPersonRecord = from x in Funs.DB.Accident_AccidentPersonRecord
|
|
where x.WorkPackageId.Contains(workPackageId)
|
|
&& x.States == Const.State_2
|
|
select x;
|
|
if (!string.IsNullOrEmpty(projectId))
|
|
{
|
|
getAccidentPersonRecord = getAccidentPersonRecord.Where(x => x.ProjectId == projectId);
|
|
}
|
|
|
|
return getAccidentPersonRecord.Count();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 安全巡检问题总数
|
|
/// </summary>
|
|
/// <param name="projectId"></param>
|
|
/// <returns></returns>
|
|
public static int getWBSHSEProblemCount(string projectId, string workPackageId)
|
|
{
|
|
var getHazardRegister = from x in Funs.DB.HSSE_Hazard_HazardRegister
|
|
where x.States != "4" && x.States != "0"
|
|
&& x.WorkPackageId.Contains(workPackageId)
|
|
select x;
|
|
if (!string.IsNullOrEmpty(projectId))
|
|
{
|
|
getHazardRegister = getHazardRegister.Where(x => x.ProjectId == projectId);
|
|
}
|
|
|
|
return getHazardRegister.Count();
|
|
}
|
|
|
|
/// <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();
|
|
}
|
|
}
|
|
} |