SGGL_SHJ/SGGL/BLL/DigData/CQMSDataDWService .cs

141 lines
6.2 KiB
C#
Raw Normal View History

using FineUIPro;
using System;
using System.Collections;
using System.Linq;
namespace BLL
{
/// <summary>
/// 质量数据仓库
/// </summary>
public static class CQMSDataDWService
{
#region
/// <summary>
/// 记录数
/// </summary>
public static int count
{
get;
set;
}
/// <summary>
/// 定义变量
/// </summary>
2025-01-07 19:00:48 +08:00
private static IQueryable<Model.Base_Project> getDataLists = from x in Funs.DB.Base_Project
2023-09-18 13:47:38 +08:00
where x.ProjectState == Const.ProjectState_1
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 projectId, DateTime? startTime, DateTime? endTime, Grid Grid1)
{
2023-09-18 13:47:38 +08:00
IQueryable<Model.Base_Project> getDataList = getDataLists;
if (!string.IsNullOrEmpty(projectId) && projectId != Const._Null)
{
getDataList = getDataList.Where(x => x.ProjectId == projectId);
}
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.ProjectId,
x.ProjectName,
x.ProjectCode,
2023-09-18 13:47:38 +08:00
Rate1 = getSpotCheckRate(x.ProjectId), //质量验收问题整改率
Rate2 = getSpotCheckDataRate(x.ProjectId), //控制点完成率
Rate3 = getCheckControlStates(x.ProjectId), //质量检查问题整改率
Rate4 = getFirstPassRate(x.ProjectId), //管道焊接一次合格率
};
}
#endregion
2023-09-18 13:47:38 +08:00
/// <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%";
2023-09-18 13:47:38 +08:00
}
/// <summary>
/// 控制点完成率
/// </summary>
/// <param name="projectId"></param>
/// <returns></returns>
public static string getSpotCheckDataRate(string projectId)
2023-09-18 13:47:38 +08:00
{
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"
2023-09-18 13:47:38 +08:00
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%";
2023-09-18 13:47:38 +08:00
}
/// <summary>
/// 质量检查问题整改率
/// </summary>
/// <param name="projectId"></param>
/// <returns></returns>
public static string getCheckControlStates(string projectId)
{
var getCheck_CheckControl = from x in Funs.DB.Check_CheckControl
2023-09-18 13:47:38 +08:00
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%";
2023-09-18 13:47:38 +08:00
}
}
}