2022-09-05 16:36:31 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
|
|
namespace BLL
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 安全问题分析
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static class ProblemAnalysisService
|
|
|
|
|
|
{
|
|
|
|
|
|
#region AnalysisColumn
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 统计列
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public class AnalysisColumn
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// ID
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public string ID { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 名称
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 编号
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public string Code { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 问题数量
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public int AllCount { get; set; } = 0;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 已整改
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public int OkCount { get; set; } = 0;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 未整改
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public int UnCount { get; set; } = 0;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 次数
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public int NumberV { get; set; } = 0;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 整改率
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public string Rate { get; set; }
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 安全巡检
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 安全巡检
|
|
|
|
|
|
/// </summary>
|
2025-01-07 19:00:48 +08:00
|
|
|
|
public static IQueryable<Model.HSSE_Hazard_HazardRegister> getHazardRegisterLists = from x in Funs.DB.HSSE_Hazard_HazardRegister
|
2022-09-05 16:36:31 +08:00
|
|
|
|
where x.States != Const.State_4 && x.ProjectId != Const.Project_TestProjectId && x.ProjectId != null
|
|
|
|
|
|
select x;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// HSE日常检查问题分析
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="type"></param>
|
|
|
|
|
|
/// <param name="projectId"></param>
|
|
|
|
|
|
/// <param name="startTime"></param>
|
|
|
|
|
|
/// <param name="endTime"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static List<AnalysisColumn> getDailyProblemData(string type, string projectId, DateTime? startTime, DateTime? endTime)
|
|
|
|
|
|
{
|
|
|
|
|
|
var getDatas = getHazardRegisterLists;
|
|
|
|
|
|
List<AnalysisColumn> returnLists = new List<AnalysisColumn>();
|
|
|
|
|
|
if (getDatas.Count() > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!string.IsNullOrEmpty(projectId) && projectId != Const._Null)
|
|
|
|
|
|
{
|
|
|
|
|
|
getDatas = getDatas.Where(x => x.ProjectId == projectId);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (startTime.HasValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
getDatas = getDatas.Where(x => x.CheckTime >= startTime);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (endTime.HasValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
getDatas = getDatas.Where(x => x.CheckTime <= endTime);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int AllPCout, okPCount = 0;
|
|
|
|
|
|
string rate = string.Empty;
|
|
|
|
|
|
if (type == "0") ///按项目
|
|
|
|
|
|
{
|
|
|
|
|
|
var getProjects = getDatas.Select(x => x.ProjectId).Distinct();
|
|
|
|
|
|
if (!string.IsNullOrEmpty(projectId) && projectId != Const._Null)
|
|
|
|
|
|
{
|
|
|
|
|
|
getProjects = getProjects.Where(x => x == projectId);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var item in getProjects)
|
|
|
|
|
|
{
|
|
|
|
|
|
var getPRegisters = getDatas.Where(x => x.ProjectId == item);
|
|
|
|
|
|
AllPCout = getPRegisters.Count();
|
|
|
|
|
|
if (AllPCout > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
okPCount = getPRegisters.Where(x => x.States == Const.State_3).Count();
|
|
|
|
|
|
rate = Math.Round(okPCount * 1.0 / AllPCout * 100, 1).ToString() + "%";
|
|
|
|
|
|
AnalysisColumn newItem = new AnalysisColumn
|
|
|
|
|
|
{
|
|
|
|
|
|
ID = SQLHelper.GetNewID(),
|
|
|
|
|
|
AllCount = AllPCout,
|
|
|
|
|
|
OkCount = okPCount,
|
|
|
|
|
|
UnCount = AllPCout - okPCount,
|
|
|
|
|
|
Rate = rate
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var getProject = ProjectService.GetProjectByProjectId(item);
|
|
|
|
|
|
if (getProject != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
newItem.Code = getProject.ProjectCode;
|
|
|
|
|
|
newItem.Name = getProject.ProjectName;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
newItem.Name = "其他";
|
|
|
|
|
|
}
|
|
|
|
|
|
returnLists.Add(newItem);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (type == "5") ///按项目
|
|
|
|
|
|
{
|
|
|
|
|
|
var getUnits = getDatas.Select(x => x.ResponsibleUnit).Distinct();
|
|
|
|
|
|
foreach (var item in getUnits)
|
|
|
|
|
|
{
|
|
|
|
|
|
var getURegisters = getDatas.Where(x => x.ResponsibleUnit == item);
|
|
|
|
|
|
AllPCout = getURegisters.Count();
|
|
|
|
|
|
if (AllPCout > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
okPCount = getURegisters.Where(x => x.States == Const.State_3).Count();
|
|
|
|
|
|
rate = Math.Round(okPCount * 1.0 / AllPCout * 100, 1).ToString() + "%";
|
|
|
|
|
|
AnalysisColumn newItem = new AnalysisColumn
|
|
|
|
|
|
{
|
|
|
|
|
|
ID = SQLHelper.GetNewID(),
|
|
|
|
|
|
AllCount = AllPCout,
|
|
|
|
|
|
OkCount = okPCount,
|
|
|
|
|
|
UnCount = AllPCout - okPCount,
|
|
|
|
|
|
Rate = rate
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var getUnit = UnitService.GetUnitByUnitId(item);
|
|
|
|
|
|
if (getUnit != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
newItem.Code = getUnit.UnitCode;
|
|
|
|
|
|
newItem.Name = getUnit.UnitName;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
newItem.Name = "其他";
|
|
|
|
|
|
}
|
|
|
|
|
|
returnLists.Add(newItem);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2025-01-07 19:00:48 +08:00
|
|
|
|
var getTypes = from x in Funs.DB.HSSE_Hazard_HazardRegisterTypes
|
2022-09-05 16:36:31 +08:00
|
|
|
|
where x.HazardRegisterType == type
|
|
|
|
|
|
orderby x.TypeCode
|
|
|
|
|
|
select x;
|
|
|
|
|
|
foreach (var item in getTypes)
|
|
|
|
|
|
{
|
|
|
|
|
|
AnalysisColumn newItem = new AnalysisColumn
|
|
|
|
|
|
{
|
|
|
|
|
|
ID = SQLHelper.GetNewID(),
|
|
|
|
|
|
Name = item.RegisterTypesName,
|
|
|
|
|
|
Code = item.TypeCode,
|
|
|
|
|
|
};
|
|
|
|
|
|
IQueryable<Model.HSSE_Hazard_HazardRegister> getTRegisters = null;
|
|
|
|
|
|
if (type == "1")
|
|
|
|
|
|
{
|
|
|
|
|
|
getTRegisters = getDatas.Where(x => x.RegisterTypesId == item.RegisterTypesId);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (type == "2")
|
|
|
|
|
|
{
|
|
|
|
|
|
getTRegisters = getDatas.Where(x => x.RegisterTypes2Id == item.RegisterTypesId);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (type == "3")
|
|
|
|
|
|
{
|
|
|
|
|
|
getTRegisters = getDatas.Where(x => x.RegisterTypes3Id == item.RegisterTypesId);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (type == "4")
|
|
|
|
|
|
{
|
|
|
|
|
|
getTRegisters = getDatas.Where(x => x.RegisterTypes4Id == item.RegisterTypesId);
|
|
|
|
|
|
}
|
|
|
|
|
|
AllPCout = getTRegisters.Count();
|
|
|
|
|
|
if (AllPCout > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
okPCount = getTRegisters.Where(x => x.States == Const.State_3).Count();
|
|
|
|
|
|
rate = Math.Round(okPCount * 1.0 / AllPCout * 100, 1).ToString() + "%";
|
|
|
|
|
|
newItem.AllCount = AllPCout;
|
|
|
|
|
|
newItem.OkCount = okPCount;
|
|
|
|
|
|
newItem.UnCount = AllPCout - okPCount;
|
|
|
|
|
|
newItem.Rate = rate;
|
|
|
|
|
|
}
|
|
|
|
|
|
returnLists.Add(newItem);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
IQueryable<Model.HSSE_Hazard_HazardRegister> getTRegistersOther = null;
|
|
|
|
|
|
if (type == "1")
|
|
|
|
|
|
{
|
|
|
|
|
|
getTRegistersOther = getDatas.Where(x => x.RegisterTypesId == null || x.RegisterTypesId == "");
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (type == "2")
|
|
|
|
|
|
{
|
|
|
|
|
|
getTRegistersOther = getDatas.Where(x => x.RegisterTypes2Id == null || x.RegisterTypes2Id == "");
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (type == "3")
|
|
|
|
|
|
{
|
|
|
|
|
|
getTRegistersOther = getDatas.Where(x => x.RegisterTypes3Id == null || x.RegisterTypes3Id == "");
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (type == "4")
|
|
|
|
|
|
{
|
|
|
|
|
|
getTRegistersOther = getDatas.Where(x => x.RegisterTypes4Id == null || x.RegisterTypes4Id == "");
|
|
|
|
|
|
}
|
|
|
|
|
|
if (getTRegistersOther != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
int oAllPCout = getTRegistersOther.Count();
|
|
|
|
|
|
if (oAllPCout > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
int ookPCount = getTRegistersOther.Where(x => x.States == Const.State_3).Count();
|
|
|
|
|
|
string orate = Math.Round(ookPCount * 1.0 / oAllPCout * 100, 1).ToString() + "%";
|
|
|
|
|
|
AnalysisColumn newOherItem = new AnalysisColumn
|
|
|
|
|
|
{
|
|
|
|
|
|
ID = SQLHelper.GetNewID(),
|
|
|
|
|
|
Code = "99",
|
|
|
|
|
|
Name = "其他",
|
|
|
|
|
|
AllCount = oAllPCout,
|
|
|
|
|
|
OkCount = ookPCount,
|
|
|
|
|
|
UnCount = oAllPCout - ookPCount,
|
|
|
|
|
|
Rate = orate
|
|
|
|
|
|
};
|
|
|
|
|
|
returnLists.Add(newOherItem);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return returnLists;
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 隐患整改单
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 隐患整改单
|
|
|
|
|
|
/// </summary>
|
2025-01-07 19:00:48 +08:00
|
|
|
|
public static IQueryable<Model.Check_RectifyNotices> getRectifyNoticesLists = from x in Funs.DB.Check_RectifyNotices
|
2022-09-05 16:36:31 +08:00
|
|
|
|
where x.States != Const.State_0 && x.States != null && x.ProjectId != Const.Project_TestProjectId && x.ProjectId != null
|
|
|
|
|
|
select x;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 隐患整改检查问题分析
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="type"></param>
|
|
|
|
|
|
/// <param name="projectId"></param>
|
|
|
|
|
|
/// <param name="startTime"></param>
|
|
|
|
|
|
/// <param name="endTime"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static List<AnalysisColumn> getRectifyProblemData(string type, string projectId, DateTime? startTime, DateTime? endTime)
|
|
|
|
|
|
{
|
|
|
|
|
|
var getDatas = getRectifyNoticesLists;
|
|
|
|
|
|
List<AnalysisColumn> returnLists = new List<AnalysisColumn>();
|
|
|
|
|
|
if (getDatas.Count() > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!string.IsNullOrEmpty(projectId) && projectId != Const._Null)
|
|
|
|
|
|
{
|
|
|
|
|
|
getDatas = getDatas.Where(x => x.ProjectId == projectId);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (startTime.HasValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
getDatas = getDatas.Where(x => x.CheckedDate >= startTime);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (endTime.HasValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
getDatas = getDatas.Where(x => x.CheckedDate <= endTime);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int AllPCout, okPCount = 0;
|
|
|
|
|
|
string rate = string.Empty;
|
|
|
|
|
|
if (type == "0") ///按项目
|
|
|
|
|
|
{
|
|
|
|
|
|
var getProjects = getDatas.Select(x => x.ProjectId).Distinct();
|
|
|
|
|
|
if (!string.IsNullOrEmpty(projectId) && projectId != Const._Null)
|
|
|
|
|
|
{
|
|
|
|
|
|
getProjects = getProjects.Where(x => x == projectId);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var item in getProjects)
|
|
|
|
|
|
{
|
|
|
|
|
|
var getPRectifys = getDatas.Where(x => x.ProjectId == item);
|
|
|
|
|
|
AllPCout = getPRectifys.Count();
|
|
|
|
|
|
if (AllPCout > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
okPCount = getPRectifys.Where(x => x.States == Const.State_5).Count();
|
|
|
|
|
|
rate = Math.Round(okPCount * 1.0 / AllPCout * 100, 1).ToString() + "%";
|
|
|
|
|
|
AnalysisColumn newItem = new AnalysisColumn
|
|
|
|
|
|
{
|
|
|
|
|
|
ID = SQLHelper.GetNewID(),
|
|
|
|
|
|
AllCount = AllPCout,
|
|
|
|
|
|
OkCount = okPCount,
|
|
|
|
|
|
UnCount = AllPCout - okPCount,
|
|
|
|
|
|
Rate = rate
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var getProject = ProjectService.GetProjectByProjectId(item);
|
|
|
|
|
|
if (getProject != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
newItem.Code = getProject.ProjectCode;
|
|
|
|
|
|
newItem.Name = getProject.ProjectName;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
newItem.Name = "其他";
|
|
|
|
|
|
}
|
|
|
|
|
|
returnLists.Add(newItem);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (type == "2") ///按单位
|
|
|
|
|
|
{
|
|
|
|
|
|
var getUnits = getDatas.Select(x => x.UnitId).Distinct();
|
|
|
|
|
|
foreach (var item in getUnits)
|
|
|
|
|
|
{
|
|
|
|
|
|
var getURectifys = getDatas.Where(x => x.UnitId == item);
|
|
|
|
|
|
AllPCout = getURectifys.Count();
|
|
|
|
|
|
if (AllPCout > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
okPCount = getURectifys.Where(x => x.States == Const.State_5).Count();
|
|
|
|
|
|
rate = Math.Round(okPCount * 1.0 / AllPCout * 100, 1).ToString() + "%";
|
|
|
|
|
|
AnalysisColumn newItem = new AnalysisColumn
|
|
|
|
|
|
{
|
|
|
|
|
|
ID = SQLHelper.GetNewID(),
|
|
|
|
|
|
AllCount = AllPCout,
|
|
|
|
|
|
OkCount = okPCount,
|
|
|
|
|
|
UnCount = AllPCout - okPCount,
|
|
|
|
|
|
Rate = rate
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var getUnit = UnitService.GetUnitByUnitId(item);
|
|
|
|
|
|
if (getUnit != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
newItem.Code = getUnit.UnitCode;
|
|
|
|
|
|
newItem.Name = getUnit.UnitName;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
newItem.Name = "其他";
|
|
|
|
|
|
}
|
|
|
|
|
|
returnLists.Add(newItem);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
var getTypes = DropListService.GetHiddenHazardType();
|
|
|
|
|
|
foreach (var item in getTypes)
|
|
|
|
|
|
{
|
|
|
|
|
|
AnalysisColumn newItem = new AnalysisColumn
|
|
|
|
|
|
{
|
|
|
|
|
|
ID = SQLHelper.GetNewID(),
|
|
|
|
|
|
Name = item.Text,
|
|
|
|
|
|
Code = item.Value,
|
|
|
|
|
|
};
|
|
|
|
|
|
var getTRegisters = getDatas.Where(x => x.HiddenHazardType == item.Value);
|
|
|
|
|
|
AllPCout = getTRegisters.Count();
|
|
|
|
|
|
if (AllPCout > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
okPCount = getTRegisters.Where(x => x.States == Const.State_5).Count();
|
|
|
|
|
|
rate = Math.Round(okPCount * 1.0 / AllPCout * 100, 1).ToString() + "%";
|
|
|
|
|
|
newItem.AllCount = AllPCout;
|
|
|
|
|
|
newItem.OkCount = okPCount;
|
|
|
|
|
|
newItem.UnCount = AllPCout - okPCount;
|
|
|
|
|
|
newItem.Rate = rate;
|
|
|
|
|
|
}
|
|
|
|
|
|
returnLists.Add(newItem);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var getTRegistersOther = getDatas.Where(x => x.HiddenHazardType == null || x.HiddenHazardType == "");
|
|
|
|
|
|
int oAllPCout = getTRegistersOther.Count();
|
|
|
|
|
|
if (oAllPCout > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
int ookPCount = getTRegistersOther.Where(x => x.States == Const.State_3).Count();
|
|
|
|
|
|
string orate = Math.Round(ookPCount * 1.0 / oAllPCout * 100, 1).ToString() + "%";
|
|
|
|
|
|
AnalysisColumn newOherItem = new AnalysisColumn
|
|
|
|
|
|
{
|
|
|
|
|
|
ID = SQLHelper.GetNewID(),
|
|
|
|
|
|
Name = "其他",
|
|
|
|
|
|
AllCount = oAllPCout,
|
|
|
|
|
|
OkCount = ookPCount,
|
|
|
|
|
|
UnCount = oAllPCout - ookPCount,
|
|
|
|
|
|
Rate = orate
|
|
|
|
|
|
};
|
|
|
|
|
|
returnLists.Add(newOherItem);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return returnLists;
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 教育培训统计
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 教育培训
|
|
|
|
|
|
/// </summary>
|
2025-01-07 19:00:48 +08:00
|
|
|
|
public static IQueryable<Model.EduTrain_TrainRecord> getTrainRecordLists = from x in Funs.DB.EduTrain_TrainRecord
|
2022-09-05 16:36:31 +08:00
|
|
|
|
where x.ProjectId != Const.Project_TestProjectId && x.ProjectId != null
|
|
|
|
|
|
select x;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 教育培训明细
|
|
|
|
|
|
/// </summary>
|
2025-01-07 19:00:48 +08:00
|
|
|
|
public static IQueryable<Model.EduTrain_TrainRecordDetail> getTrainRecordDetailLists = from x in Funs.DB.EduTrain_TrainRecordDetail
|
2022-09-05 16:36:31 +08:00
|
|
|
|
select x;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 教育培训统计
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="HSEDataCollectId"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static List<AnalysisColumn> getTrainRecordData(string type, string projectId, string trainTypeId, DateTime? startTime, DateTime? endTime)
|
|
|
|
|
|
{
|
|
|
|
|
|
var getTrainRecordDatas = getTrainRecordLists;
|
|
|
|
|
|
List<AnalysisColumn> returnLists = new List<AnalysisColumn>();
|
|
|
|
|
|
if (getTrainRecordDatas.Count() > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!string.IsNullOrEmpty(projectId) && projectId != Const._Null)
|
|
|
|
|
|
{
|
|
|
|
|
|
getTrainRecordDatas = getTrainRecordDatas.Where(x => x.ProjectId == projectId);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!string.IsNullOrEmpty(trainTypeId) && trainTypeId != Const._Null)
|
|
|
|
|
|
{
|
|
|
|
|
|
getTrainRecordDatas = getTrainRecordDatas.Where(x => x.TrainTypeId == trainTypeId);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (startTime.HasValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
getTrainRecordDatas = getTrainRecordDatas.Where(x => x.TrainStartDate >= startTime);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (endTime.HasValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
getTrainRecordDatas = getTrainRecordDatas.Where(x => x.TrainStartDate <= endTime);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int AllPCout, okPCount, NumberV = 0;
|
|
|
|
|
|
string rate = string.Empty;
|
|
|
|
|
|
if (type == "0") ///按项目
|
|
|
|
|
|
{
|
|
|
|
|
|
var getProjects = getTrainRecordDatas.Select(x => x.ProjectId).Distinct();
|
|
|
|
|
|
if (!string.IsNullOrEmpty(projectId) && projectId != Const._Null)
|
|
|
|
|
|
{
|
|
|
|
|
|
getProjects = getProjects.Where(x => x == projectId);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var item in getProjects)
|
|
|
|
|
|
{
|
|
|
|
|
|
var getPTrainRecords = getTrainRecordDatas.Where(x => x.ProjectId == item);
|
|
|
|
|
|
NumberV = getPTrainRecords.Count();
|
|
|
|
|
|
if (NumberV > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
AnalysisColumn newItem = new AnalysisColumn
|
|
|
|
|
|
{
|
|
|
|
|
|
ID = SQLHelper.GetNewID(),
|
|
|
|
|
|
NumberV = NumberV,
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var getDetailDatas = from x in getTrainRecordDetailLists
|
|
|
|
|
|
join y in getPTrainRecords on x.TrainingId equals y.TrainingId
|
|
|
|
|
|
select x;
|
|
|
|
|
|
AllPCout = getDetailDatas.Count();
|
|
|
|
|
|
if (AllPCout > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
okPCount = getDetailDatas.Where(x => x.CheckResult == true).Count();
|
|
|
|
|
|
rate = Math.Round(okPCount * 1.0 / AllPCout * 100, 1).ToString() + "%";
|
|
|
|
|
|
newItem.AllCount = AllPCout;
|
|
|
|
|
|
newItem.OkCount = okPCount;
|
|
|
|
|
|
newItem.UnCount = AllPCout - okPCount;
|
|
|
|
|
|
newItem.Rate = rate;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var getProject = ProjectService.GetProjectByProjectId(item);
|
|
|
|
|
|
if (getProject != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
newItem.Code = getProject.ProjectCode;
|
|
|
|
|
|
newItem.Name = getProject.ProjectName;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
newItem.Name = "其他";
|
|
|
|
|
|
}
|
|
|
|
|
|
returnLists.Add(newItem);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
//else if (type == "2") ///按单位
|
|
|
|
|
|
//{
|
|
|
|
|
|
// var getUnits = getTrainRecordDatas.Select(x => x.UnitIds).Distinct();
|
|
|
|
|
|
// if (getUnits.Count() > 0)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// var getUnitIds = Funs.GetStrListByList(getUnits.ToList());
|
|
|
|
|
|
// var getIdList = Funs.GetStrListByStr(getUnitIds, ',').Distinct();
|
|
|
|
|
|
// foreach (var item in getIdList)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// var getUTrainRecords = getTrainRecordDatas.Where(x => x.UnitIds.Contains(item));
|
|
|
|
|
|
// NumberV = getUTrainRecords.Count();
|
|
|
|
|
|
// if (NumberV > 0)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// AnalysisColumn newItem = new AnalysisColumn
|
|
|
|
|
|
// {
|
|
|
|
|
|
// ID = SQLHelper.GetNewID(),
|
|
|
|
|
|
// NumberV = NumberV,
|
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
|
|
// var getDetailDatas = from x in getTrainRecordDetailLists
|
|
|
|
|
|
// join y in getUTrainRecords on x.TrainingId equals y.TrainingId
|
|
|
|
|
|
// join z in db.SitePerson_Person on x.PersonId equals z.PersonId
|
|
|
|
|
|
// where z.UnitId == item
|
|
|
|
|
|
// select x;
|
|
|
|
|
|
// AllPCout = getDetailDatas.Count();
|
|
|
|
|
|
// if (AllPCout > 0)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// okPCount = getDetailDatas.Where(x => x.CheckResult == true).Count();
|
|
|
|
|
|
// rate = Math.Round(okPCount * 1.0 / AllPCout * 100, 1).ToString() + "%";
|
|
|
|
|
|
// newItem.AllCount = AllPCout;
|
|
|
|
|
|
// newItem.OkCount = okPCount;
|
|
|
|
|
|
// newItem.UnCount = AllPCout - okPCount;
|
|
|
|
|
|
// newItem.Rate = rate;
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// var getUnit = UnitService.GetUnitByUnitId(item);
|
|
|
|
|
|
// if (getUnit != null)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// newItem.Code = getUnit.UnitCode;
|
|
|
|
|
|
// newItem.Name = getUnit.UnitName;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// else
|
|
|
|
|
|
// {
|
|
|
|
|
|
// newItem.Name = "其他";
|
|
|
|
|
|
// }
|
|
|
|
|
|
// returnLists.Add(newItem);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
//}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
var getTypes = TrainTypeService.GetTrainTypeList();
|
|
|
|
|
|
foreach (var item in getTypes)
|
|
|
|
|
|
{
|
|
|
|
|
|
AnalysisColumn newItem = new AnalysisColumn
|
|
|
|
|
|
{
|
|
|
|
|
|
ID = SQLHelper.GetNewID(),
|
|
|
|
|
|
Name = item.TrainTypeName,
|
|
|
|
|
|
Code = item.TrainTypeCode,
|
|
|
|
|
|
};
|
|
|
|
|
|
var getTTrainRecord = getTrainRecordDatas.Where(x => x.TrainTypeId == item.TrainTypeId);
|
|
|
|
|
|
NumberV = getTTrainRecord.Count();
|
|
|
|
|
|
if (NumberV > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
newItem.NumberV = NumberV;
|
|
|
|
|
|
var getDetailDatas = from x in getTrainRecordDetailLists
|
|
|
|
|
|
join y in getTTrainRecord on x.TrainingId equals y.TrainingId
|
|
|
|
|
|
select x;
|
|
|
|
|
|
AllPCout = getDetailDatas.Count();
|
|
|
|
|
|
if (AllPCout > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
okPCount = getDetailDatas.Where(x => x.CheckResult == true).Count();
|
|
|
|
|
|
rate = Math.Round(okPCount * 1.0 / AllPCout * 100, 1).ToString() + "%";
|
|
|
|
|
|
newItem.AllCount = AllPCout;
|
|
|
|
|
|
newItem.OkCount = okPCount;
|
|
|
|
|
|
newItem.UnCount = AllPCout - okPCount;
|
|
|
|
|
|
newItem.Rate = rate;
|
|
|
|
|
|
}
|
|
|
|
|
|
returnLists.Add(newItem);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var getTTrainRecordOther = getTrainRecordDatas.Where(x => x.TrainTypeId == null || x.TrainTypeId == "");
|
|
|
|
|
|
int oNumberV = getTTrainRecordOther.Count();
|
|
|
|
|
|
if (oNumberV > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
var getDetailDatas = from x in getTrainRecordDetailLists
|
|
|
|
|
|
join y in getTTrainRecordOther on x.TrainingId equals y.TrainingId
|
|
|
|
|
|
select x;
|
|
|
|
|
|
int oAllPCout = getDetailDatas.Count();
|
|
|
|
|
|
if (oAllPCout > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
int ookPCount = getDetailDatas.Where(x => x.CheckResult == true).Count();
|
|
|
|
|
|
string orate = Math.Round(ookPCount * 1.0 / oAllPCout * 100, 1).ToString() + "%";
|
|
|
|
|
|
AnalysisColumn newOherItem = new AnalysisColumn
|
|
|
|
|
|
{
|
|
|
|
|
|
ID = SQLHelper.GetNewID(),
|
|
|
|
|
|
Name = "/",
|
|
|
|
|
|
NumberV = oNumberV,
|
|
|
|
|
|
AllCount = oAllPCout,
|
|
|
|
|
|
OkCount = oAllPCout,
|
|
|
|
|
|
UnCount = oAllPCout - ookPCount,
|
|
|
|
|
|
Rate = orate
|
|
|
|
|
|
};
|
|
|
|
|
|
returnLists.Add(newOherItem);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return returnLists;
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|