较大隐患整改汇总数指标推送集团

This commit is contained in:
夏菊 2026-03-11 17:54:11 +08:00
parent b185fc4f09
commit f353e5b4cf
4 changed files with 188 additions and 5 deletions

View File

@ -0,0 +1,23 @@
IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'HSSEData_HSSE' AND COLUMN_NAME = 'LargerClosedNum')
BEGIN
ALTER TABLE HSSEData_HSSE ADD LargerClosedNum int;
ALTER TABLE HSSEData_HSSE ADD LargerNotClosedNum int;
EXEC sp_addextendedproperty 'MS_Description', N'较大隐患整改闭环项','SCHEMA', N'dbo','TABLE', N'HSSEData_HSSE','COLUMN', N'LargerClosedNum';
EXEC sp_addextendedproperty 'MS_Description', N'较大隐患未整改完成项','SCHEMA', N'dbo','TABLE', N'HSSEData_HSSE','COLUMN', N'LargerNotClosedNum';
END
GO
IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'Project_HSSEData_HSSE' AND COLUMN_NAME = 'LargerClosedNum')
BEGIN
ALTER TABLE Project_HSSEData_HSSE ADD LargerClosedNum int;
ALTER TABLE Project_HSSEData_HSSE ADD LargerNotClosedNum int;
EXEC sp_addextendedproperty 'MS_Description', N'较大隐患整改闭环项','SCHEMA', N'dbo','TABLE', N'Project_HSSEData_HSSE','COLUMN', N'LargerClosedNum';
EXEC sp_addextendedproperty 'MS_Description', N'较大隐患未整改完成项','SCHEMA', N'dbo','TABLE', N'Project_HSSEData_HSSE','COLUMN', N'LargerNotClosedNum';
END
GO

View File

@ -103,6 +103,8 @@ namespace BLL
LicensesCloseNum = newtable.LicensesCloseNum,
GeneralClosedNum = newtable.GeneralClosedNum,
GeneralNotClosedNum = newtable.GeneralNotClosedNum,
LargerClosedNum = newtable.LargerClosedNum,
LargerNotClosedNum = newtable.LargerNotClosedNum,
MajorClosedNum = newtable.MajorClosedNum,
MajorNotClosedNum = newtable.MajorNotClosedNum,
GeneralRiskNum = newtable.GeneralRiskNum,
@ -194,6 +196,9 @@ namespace BLL
item.GeneralNotClosedNum = dataHsse.GeneralNotClosedNum;
item.GeneralRate = "";
item.GeneralRiskNum = dataHsse.GeneralRiskNum;
item.LargerClosedNum = dataHsse.LargerClosedNum;
item.LargerNotClosedNum = dataHsse.LargerNotClosedNum;
item.LargerRate = "";
item.HeadOfficeFullTimeNum = dataHsse.HeadOfficeFullTimeNum;
item.HeadOfficeInspectorGeneralNum = dataHsse.HeadOfficeInspectorGeneralNum;
item.HighRiskNum = dataHsse.HighRiskNum;
@ -315,6 +320,9 @@ namespace BLL
item.GeneralNotClosedNum = dataHsse.GeneralNotClosedNum;
item.GeneralRate = "";
item.GeneralRiskNum = dataHsse.GeneralRiskNum;
item.LargerClosedNum = dataHsse.LargerClosedNum;
item.LargerNotClosedNum = dataHsse.LargerNotClosedNum;
item.LargerRate = "";
item.HeadOfficeFullTimeNum = dataHsse.HeadOfficeFullTimeNum;
item.HeadOfficeInspectorGeneralNum = dataHsse.HeadOfficeInspectorGeneralNum;
item.HighRiskNum = dataHsse.HighRiskNum;
@ -527,6 +535,8 @@ namespace BLL
LicensesCloseNum = projectData.Sum(x => x.LicensesCloseNum),
GeneralClosedNum = projectData.Sum(x => x.GeneralClosedNum),
GeneralNotClosedNum = projectData.Sum(x => x.GeneralNotClosedNum),
LargerClosedNum = projectData.Sum(x => x.LargerClosedNum),
LargerNotClosedNum = projectData.Sum(x => x.LargerNotClosedNum),
MajorClosedNum = projectData.Sum(x => x.MajorClosedNum),
MajorNotClosedNum = projectData.Sum(x => x.MajorNotClosedNum),
GeneralRiskNum = projectData.Sum(x => x.GeneralRiskNum),
@ -630,6 +640,7 @@ namespace BLL
var licensesTask = HSSEData_HSSEService.GetLicensesAsync();
var licensesCloseTask = HSSEData_HSSEService.GetLicensesCloseAsync();
var generalHiddenRectificationOutputsTask = HSSEData_HSSEService.GetGeneralHiddenRectificationOutputsAsync();
var largerHiddenRectificationOutputsTask = HSSEData_HSSEService.GetLargerHiddenRectificationOutputsAsync();
var majorHiddenRectificationOutputsTask = HSSEData_HSSEService.GetMajorHiddenRectificationOutputsAsync();
// 等待所有异步方法执行完成
@ -767,6 +778,7 @@ namespace BLL
var licensesList = await licensesTask;
var licensesCloseList = await licensesCloseTask;
var generalHiddenRectificationOutputsList = await generalHiddenRectificationOutputsTask;
var largerHiddenRectificationOutputsList = await largerHiddenRectificationOutputsTask;
var majorHiddenRectificationOutputsList = await majorHiddenRectificationOutputsTask;
// 构造结果对象
@ -848,6 +860,8 @@ namespace BLL
LicensesCloseNum = licensesCloseList.Count(),
GeneralClosedNum = generalHiddenRectificationOutputsList.Sum(x => x.RecNum),
GeneralNotClosedNum = generalHiddenRectificationOutputsList.Sum(x => x.NoRecNum),
LargerClosedNum = largerHiddenRectificationOutputsList.Sum(x => x.RecNum),
LargerNotClosedNum = largerHiddenRectificationOutputsList.Sum(x => x.NoRecNum),
MajorClosedNum = majorHiddenRectificationOutputsList.Sum(x => x.RecNum),
MajorNotClosedNum = majorHiddenRectificationOutputsList.Sum(x => x.NoRecNum),
LowRiskNum = securityRiskOutputListTask.Result.Sum(x => x.LowRiskNum),
@ -878,6 +892,12 @@ namespace BLL
g => g.Key,
g => new { ClosedNum = g.Sum(x => x.RecNum), NotClosedNum = g.Sum(x => x.NoRecNum) }
);
var largerHiddenRectificationOutputsDict = largerHiddenRectificationOutputsList
.GroupBy(x => x.ProjectId)
.ToDictionary(
g => g.Key,
g => new { ClosedNum = g.Sum(x => x.RecNum), NotClosedNum = g.Sum(x => x.NoRecNum) }
);
var majorHiddenRectificationOutputsDict = majorHiddenRectificationOutputsList
.GroupBy(x => x.ProjectId)
.ToDictionary(
@ -921,6 +941,7 @@ namespace BLL
foreach (var projectid in BeUnderConstructionList)
{
generalHiddenRectificationOutputsDict.TryGetValue(projectid, out var generalHiddenRectificationOutputs);
largerHiddenRectificationOutputsDict.TryGetValue(projectid, out var largerHiddenRectificationOutputs);
majorHiddenRectificationOutputsDict.TryGetValue(projectid, out var majorHiddenRectificationOutputs);
securityRiskOutputDict.TryGetValue(projectid, out var securityRiskOutputs);
largeEngineeringOutputsDict.TryGetValue(projectid, out var largeEngineeringOutputs);
@ -1000,6 +1021,8 @@ namespace BLL
LicensesCloseNum = licensesCloseList.Count(x => x.ProjectId == projectid),
GeneralClosedNum = generalHiddenRectificationOutputs?.ClosedNum ?? 0,
GeneralNotClosedNum = generalHiddenRectificationOutputs?.NotClosedNum ?? 0,
LargerClosedNum = largerHiddenRectificationOutputs?.ClosedNum ?? 0,
LargerNotClosedNum = largerHiddenRectificationOutputs?.NotClosedNum ?? 0,
MajorClosedNum = majorHiddenRectificationOutputs?.ClosedNum ?? 0,
MajorNotClosedNum = majorHiddenRectificationOutputs?.NotClosedNum ?? 0,
LowRiskNum = securityRiskOutputs?.LowRiskNum ?? 0,
@ -1124,6 +1147,8 @@ namespace BLL
table.LicensesCloseNum = newtable.LicensesCloseNum;
table.GeneralClosedNum = newtable.GeneralClosedNum;
table.GeneralNotClosedNum = newtable.GeneralNotClosedNum;
table.LargerClosedNum = newtable.LargerClosedNum;
table.LargerNotClosedNum = newtable.LargerNotClosedNum;
table.MajorClosedNum = newtable.MajorClosedNum;
table.MajorNotClosedNum = newtable.MajorNotClosedNum;
table.GeneralRiskNum = newtable.GeneralRiskNum;
@ -3949,7 +3974,6 @@ namespace BLL
/// <returns></returns>
public static List<Model.HiddenRectificationOutput> GetGeneralHiddenRectificationOutputs()
{
var query = (from x in Funs.DB.Base_Project
join y in Funs.DB.HSSE_Hazard_HazardRegister on x.ProjectId equals y.ProjectId into yGroup
from y in yGroup.DefaultIfEmpty()
@ -3979,6 +4003,41 @@ namespace BLL
return await Task.Run(GetGeneralHiddenRectificationOutputs);
}
/// <summary>
/// 获取较大隐患数据
/// </summary>
/// <returns></returns>
public static List<Model.HiddenRectificationOutput> GetLargerHiddenRectificationOutputs()
{
var query = (from x in Funs.DB.Base_Project
join y in Funs.DB.HSSE_Hazard_HazardRegister on x.ProjectId equals y.ProjectId into yGroup
from y in yGroup.DefaultIfEmpty()
where BeUnderConstructionList.Contains(x.ProjectId) && y.ProblemTypes == "1" && y.Risk_Level == "较大事故隐患" && y.CheckTime > Const.DtmarkTime
group y by new { x.ProjectId, x.ProjectName, x.ProjectCode } into gg
select new HiddenRectificationOutput
{
ProjectId = gg.Key.ProjectId,
ProjectName = gg.Key.ProjectName,
ProjectCode = gg.Key.ProjectCode,
ProNum = gg.Count(y => y.States != "4" && y.States != "-1"),
RecNum = gg.Count(y => y.States == "3"),
NoRecNum = gg.Count(y => y.States != "3" && y.States != "4" && y.States != "-1"),
RecRate = gg.Count(y => y.States != "4" && y.States != "-1") == 0 ? "0" :
Math.Round(Convert.ToDecimal(gg.Count(y => y.States == "3") /
gg.Count(y => y.States != "4" && y.States != "-1") * 100), 2, MidpointRounding.AwayFromZero).ToString()
}).ToList();
foreach (var item in query)
{
item.RecRate = Math.Round(Convert.ToDecimal(item.RecRate), 2).ToString(); // 转换为字符串并格式化为两位小数
}
return query;
}
public static async Task<List<Model.HiddenRectificationOutput>> GetLargerHiddenRectificationOutputsAsync()
{
return await Task.Run(GetLargerHiddenRectificationOutputs);
}
/// <summary>
/// 获取重大隐患数据
/// </summary>
@ -3997,7 +4056,7 @@ namespace BLL
ProjectCode = gg.Key.ProjectCode,
ProNum = gg.Count(y => y.States != "4" && y.States != "-1"),
RecNum = gg.Count(y => y.States == "3"),
NoRecNum = gg.Count(y => y.States != "3" && y.States != "-1"),
NoRecNum = gg.Count(y => y.States != "3" && y.States != "4" && y.States != "-1"),
RecRate = gg.Count(y => y.States != "4" && y.States != "-1") == 0 ? "0" :
Math.Round((decimal)gg.Count(y => y.States == "3") /
gg.Count(y => y.States != "4" && y.States != "-1") * 100, 2, MidpointRounding.AwayFromZero).ToString()
@ -4298,6 +4357,8 @@ namespace BLL
x.LicensesCloseNum,
x.GeneralClosedNum,
x.GeneralNotClosedNum,
x.LargerClosedNum,
x.LargerNotClosedNum,
x.MajorClosedNum,
x.MajorNotClosedNum,
x.GeneralRiskNum,

View File

@ -189616,6 +189616,10 @@ namespace Model
private System.Nullable<int> _ProjectSubFullTimeNum;
private System.Nullable<int> _LargerClosedNum;
private System.Nullable<int> _LargerNotClosedNum;
#region
partial void OnLoaded();
partial void OnValidate(System.Data.Linq.ChangeAction action);
@ -189812,6 +189816,10 @@ namespace Model
partial void OnBranchDrillPersonNumChanged();
partial void OnProjectSubFullTimeNumChanging(System.Nullable<int> value);
partial void OnProjectSubFullTimeNumChanged();
partial void OnLargerClosedNumChanging(System.Nullable<int> value);
partial void OnLargerClosedNumChanged();
partial void OnLargerNotClosedNumChanging(System.Nullable<int> value);
partial void OnLargerNotClosedNumChanged();
#endregion
public HSSEData_HSSE()
@ -191739,6 +191747,46 @@ namespace Model
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_LargerClosedNum", DbType="Int")]
public System.Nullable<int> LargerClosedNum
{
get
{
return this._LargerClosedNum;
}
set
{
if ((this._LargerClosedNum != value))
{
this.OnLargerClosedNumChanging(value);
this.SendPropertyChanging();
this._LargerClosedNum = value;
this.SendPropertyChanged("LargerClosedNum");
this.OnLargerClosedNumChanged();
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_LargerNotClosedNum", DbType="Int")]
public System.Nullable<int> LargerNotClosedNum
{
get
{
return this._LargerNotClosedNum;
}
set
{
if ((this._LargerNotClosedNum != value))
{
this.OnLargerNotClosedNumChanging(value);
this.SendPropertyChanging();
this._LargerNotClosedNum = value;
this.SendPropertyChanged("LargerNotClosedNum");
this.OnLargerNotClosedNumChanged();
}
}
}
public event PropertyChangingEventHandler PropertyChanging;
public event PropertyChangedEventHandler PropertyChanged;
@ -315554,6 +315602,10 @@ namespace Model
private System.Nullable<int> _ProjectSubFullTimeNum;
private System.Nullable<int> _LargerClosedNum;
private System.Nullable<int> _LargerNotClosedNum;
#region
partial void OnLoaded();
partial void OnValidate(System.Data.Linq.ChangeAction action);
@ -315746,6 +315798,10 @@ namespace Model
partial void OnBranchDrillPersonNumChanged();
partial void OnProjectSubFullTimeNumChanging(System.Nullable<int> value);
partial void OnProjectSubFullTimeNumChanged();
partial void OnLargerClosedNumChanging(System.Nullable<int> value);
partial void OnLargerClosedNumChanged();
partial void OnLargerNotClosedNumChanging(System.Nullable<int> value);
partial void OnLargerNotClosedNumChanged();
#endregion
public Project_HSSEData_HSSE()
@ -317633,6 +317689,46 @@ namespace Model
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_LargerClosedNum", DbType="Int")]
public System.Nullable<int> LargerClosedNum
{
get
{
return this._LargerClosedNum;
}
set
{
if ((this._LargerClosedNum != value))
{
this.OnLargerClosedNumChanging(value);
this.SendPropertyChanging();
this._LargerClosedNum = value;
this.SendPropertyChanged("LargerClosedNum");
this.OnLargerClosedNumChanged();
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_LargerNotClosedNum", DbType="Int")]
public System.Nullable<int> LargerNotClosedNum
{
get
{
return this._LargerNotClosedNum;
}
set
{
if ((this._LargerNotClosedNum != value))
{
this.OnLargerNotClosedNumChanging(value);
this.SendPropertyChanging();
this._LargerNotClosedNum = value;
this.SendPropertyChanged("LargerNotClosedNum");
this.OnLargerNotClosedNumChanged();
}
}
}
public event PropertyChangingEventHandler PropertyChanging;
public event PropertyChangedEventHandler PropertyChanged;
@ -461379,7 +461475,7 @@ namespace Model
private System.Nullable<int> _ProjectSubFullTimeNum;
private System.Nullable<decimal> _TotalWorkNum;
private System.Nullable<int> _TotalWorkNum;
public View_Project_HSSEData_HSSE()
{
@ -462921,8 +463017,8 @@ namespace Model
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_TotalWorkNum", DbType="Decimal(38,4)")]
public System.Nullable<decimal> TotalWorkNum
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_TotalWorkNum", DbType="Int")]
public System.Nullable<int> TotalWorkNum
{
get
{

View File

@ -57,6 +57,9 @@ namespace Model
public int? GeneralNotClosedNum { get; set; }
public string GeneralRate { get; set; }
public int? GeneralRiskNum { get; set; }
public int? LargerClosedNum { get; set; }
public int? LargerNotClosedNum { get; set; }
public string LargerRate { get; set; }
public int? HeadOfficeFullTimeNum { get; set; }
public int? HeadOfficeInspectorGeneralNum { get; set; }
public int? HighRiskNum { get; set; }