11
This commit is contained in:
@@ -542,13 +542,15 @@ namespace BLL
|
||||
|
||||
private static IEnumerable<ToDoItem> GetWarningItemsFromTable(string projectId)
|
||||
{
|
||||
var strSql = @"SELECT * FROM SGManPower_WarningResult
|
||||
var strSql = @"SELECT UnitId,WarningType,SUM(PlanQuantity) as SumPlanQuantity, SUM(ActualQuantity) as SumActualQuantity FROM SGManPower_WarningResult
|
||||
WHERE ProjectId = @ProjectId ";
|
||||
|
||||
var parameters = new List<System.Data.SqlClient.SqlParameter>
|
||||
{
|
||||
new System.Data.SqlClient.SqlParameter("@ProjectId", projectId)
|
||||
};
|
||||
|
||||
strSql += " GROUP BY UnitId,WarningType ";
|
||||
|
||||
var dt = SQLHelper.GetDataTableRunText(strSql, parameters.ToArray());
|
||||
var warningItems = new List<ToDoItem>();
|
||||
@@ -557,26 +559,209 @@ namespace BLL
|
||||
{
|
||||
var warningType = row["WarningType"].ToString();
|
||||
var unitId = row["UnitId"].ToString();
|
||||
var workPostId = row["WorkPostId"].ToString();
|
||||
var unitWorkId = row["UnitWorkId"].ToString();
|
||||
var startDate = Convert.ToDateTime(row["StartDate"]);
|
||||
var endDate = Convert.ToDateTime(row["EndDate"]);
|
||||
var planQuantity = Convert.ToInt32(row["PlanQuantity"]);
|
||||
var actualQuantity = Convert.ToInt32(row["ActualQuantity"]);
|
||||
// var workPostId = row["WorkPostId"].ToString();
|
||||
// var unitWorkId = row["UnitWorkId"].ToString();
|
||||
// var startDate = Convert.ToDateTime(row["StartDate"]);
|
||||
// var endDate = Convert.ToDateTime(row["EndDate"]);
|
||||
var planQuantity = Convert.ToInt32(row["SumPlanQuantity"]);
|
||||
var actualQuantity = Convert.ToInt32(row["SumActualQuantity"]);
|
||||
|
||||
if (warningType == "Shortage")
|
||||
{
|
||||
warningItems.AddRange(SendManagerWarning(unitId, projectId, workPostId, unitWorkId,
|
||||
startDate, endDate, planQuantity, actualQuantity));
|
||||
warningItems.AddRange(SendManagerWarning(unitId, projectId,warningType, planQuantity, actualQuantity));
|
||||
}
|
||||
else if (warningType == "Deviation")
|
||||
{
|
||||
warningItems.AddRange(SendWorkerDeviationWarning(unitId, projectId, workPostId, unitWorkId,
|
||||
startDate, endDate, planQuantity, actualQuantity));
|
||||
warningItems.AddRange(SendWorkerDeviationWarning(unitId, projectId,warningType, planQuantity, actualQuantity));
|
||||
}
|
||||
}
|
||||
|
||||
return warningItems;
|
||||
}
|
||||
|
||||
|
||||
private static List<ToDoItem> SendManagerWarning(string unitId, string projectId,string warningType, int? quantity, int num)
|
||||
{
|
||||
// 发送预警信息
|
||||
var toDoItems = new List<ToDoItem>();
|
||||
|
||||
var projectUnits = (from x in Funs.DB.Project_ProjectUnit
|
||||
join y in Funs.DB.Base_Unit on x.UnitId equals y.UnitId
|
||||
where x.UnitId == unitId
|
||||
select new { x.UnitId, y.UnitName, x.UnitType }).FirstOrDefault();
|
||||
if (projectUnits != null)
|
||||
{
|
||||
List<string> toUserIds = new List<string>();
|
||||
|
||||
// 施工单位人员推送至施工单位项目经理和总包单位施工经理
|
||||
if (projectUnits.UnitType == Const.ProjectUnitType_2) // 施工分包单位
|
||||
{
|
||||
// 获取施工单位项目经理
|
||||
var constructionManagers = (from x in Funs.DB.Project_ProjectUser
|
||||
where x.ProjectId == projectId && x.UnitId == unitId && x.IsPost == true &&
|
||||
x.RoleId.Contains(Const.ProjectManager)
|
||||
select x).ToList();
|
||||
|
||||
if (constructionManagers.Count > 0)
|
||||
{
|
||||
foreach (var projectUser in constructionManagers)
|
||||
{
|
||||
toUserIds.Add(projectUser.UserId);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取总包单位施工经理
|
||||
var generalContractorUnit = Funs.DB.Project_ProjectUnit.FirstOrDefault(pu =>
|
||||
pu.ProjectId == projectId && pu.UnitType == Const.ProjectUnitType_1); // 总包单位
|
||||
|
||||
if (generalContractorUnit != null)
|
||||
{
|
||||
var constructionManagerGCs = (from x in Funs.DB.Project_ProjectUser
|
||||
where x.ProjectId == projectId && x.UnitId == generalContractorUnit.UnitId &&
|
||||
x.IsPost == true && x.RoleId.Contains(Const.ConstructionManager)
|
||||
select x).ToList();
|
||||
if (constructionManagerGCs.Count > 0)
|
||||
{
|
||||
foreach (var projectUser in constructionManagerGCs)
|
||||
{
|
||||
toUserIds.Add(projectUser.UserId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 总包单位人员推送到总包单位施工经理和项目经理
|
||||
else if (projectUnits.UnitType == Const.ProjectUnitType_1) // 总包单位
|
||||
{
|
||||
// 获取总包单位施工经理
|
||||
var constructionManagers = (from x in Funs.DB.Project_ProjectUser
|
||||
where x.ProjectId == projectId && x.UnitId == unitId && x.IsPost == true &&
|
||||
x.RoleId.Contains(Const.ConstructionManager)
|
||||
select x).ToList();
|
||||
if (constructionManagers.Count() > 0)
|
||||
{
|
||||
foreach (var projectUser in constructionManagers)
|
||||
{
|
||||
toUserIds.Add(projectUser.UserId);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取总包单位项目经理
|
||||
var projectManagers = (from x in Funs.DB.Project_ProjectUser
|
||||
where x.ProjectId == projectId && x.UnitId == unitId && x.IsPost == true &&
|
||||
x.RoleId.Contains(Const.ProjectManager)
|
||||
select x).ToList();
|
||||
if (projectManagers.Count() > 0)
|
||||
{
|
||||
foreach (var projectUser in projectManagers)
|
||||
{
|
||||
toUserIds.Add(projectUser.UserId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string warningContent = $"{projectUnits.UnitName}单位计划投入人力{quantity}人,实际考勤为{num}人。";
|
||||
|
||||
string urlParams = "JDGL/SGManPower/SGWarningDetails.aspx?projectId=" + projectId;
|
||||
// 添加单位参数
|
||||
if (!string.IsNullOrEmpty(warningType))
|
||||
{
|
||||
urlParams += "&warningType=" + warningType;
|
||||
}
|
||||
|
||||
foreach (var userId in toUserIds)
|
||||
{
|
||||
Model.ToDoItem toDoItem = new Model.ToDoItem();
|
||||
toDoItem.DataId = SQLHelper.GetNewID(typeof(Model.ToDoItem));
|
||||
toDoItem.MenuId = "";
|
||||
toDoItem.MenuName = "管理人员到岗预警";
|
||||
toDoItem.ProjectCode = "";
|
||||
toDoItem.Content = warningContent;
|
||||
toDoItem.UserId = userId;
|
||||
toDoItem.UserName = UserService.GetUserNameByUserId(userId);
|
||||
toDoItem.DataTime = DateTime.Now;
|
||||
toDoItem.DataTimeStr = DateTime.Now.ToString("yyyy-MM-dd");
|
||||
toDoItem.PCUrl = urlParams;
|
||||
toDoItems.Add(toDoItem);
|
||||
}
|
||||
}
|
||||
|
||||
return toDoItems;
|
||||
}
|
||||
|
||||
|
||||
private static List<ToDoItem> SendWorkerDeviationWarning(string unitId, string projectId,string warningType, int? quantity, int num)
|
||||
{
|
||||
// 发送预警信息
|
||||
var toDoItems = new List<ToDoItem>();
|
||||
List<string> toUserIds = new List<string>();
|
||||
|
||||
|
||||
var projectUnits = (from x in Funs.DB.Project_ProjectUnit
|
||||
join y in Funs.DB.Base_Unit on x.UnitId equals y.UnitId
|
||||
where x.UnitId == unitId
|
||||
select new { x.UnitId, y.UnitName, x.UnitType }).FirstOrDefault();
|
||||
|
||||
// 获取施工单位项目经理
|
||||
var constructionManagers = (from x in Funs.DB.Project_ProjectUser
|
||||
where x.ProjectId == projectId && x.UnitId == unitId && x.IsPost == true &&
|
||||
x.RoleId.Contains(Const.ProjectManager)
|
||||
select x).ToList();
|
||||
|
||||
if (constructionManagers.Count > 0)
|
||||
{
|
||||
foreach (var projectUser in constructionManagers)
|
||||
{
|
||||
toUserIds.Add(projectUser.UserId);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取总包单位施工经理
|
||||
var generalContractorUnit = Funs.DB.Project_ProjectUnit.FirstOrDefault(pu =>
|
||||
pu.ProjectId == projectId && pu.UnitType == Const.ProjectUnitType_1); // 总包单位
|
||||
|
||||
if (generalContractorUnit != null)
|
||||
{
|
||||
var constructionManagerGCs = (from x in Funs.DB.Project_ProjectUser
|
||||
where x.ProjectId == projectId && x.UnitId == generalContractorUnit.UnitId &&
|
||||
x.IsPost == true && x.RoleId.Contains(Const.ConstructionManager)
|
||||
select x).ToList();
|
||||
if (constructionManagerGCs.Count > 0)
|
||||
{
|
||||
foreach (var projectUser in constructionManagerGCs)
|
||||
{
|
||||
toUserIds.Add(projectUser.UserId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 构建预警信息内容
|
||||
string warningContent = $"{projectUnits.UnitName}单位计划投入人力{quantity}人,实际考勤为{num}人。";
|
||||
|
||||
string urlParams = "JDGL/SGManPower/SGWarningDetails.aspx?projectId=" + projectId;
|
||||
// 添加单位参数
|
||||
if (!string.IsNullOrEmpty(warningType))
|
||||
{
|
||||
urlParams += "&warningType=" + warningType;
|
||||
}
|
||||
|
||||
// 发送预警信息
|
||||
foreach (var userId in toUserIds)
|
||||
{
|
||||
Model.ToDoItem toDoItem = new Model.ToDoItem();
|
||||
toDoItem.DataId = SQLHelper.GetNewID(typeof(Model.ToDoItem));
|
||||
toDoItem.MenuId = "";
|
||||
toDoItem.MenuName = "人力资源偏差预警";
|
||||
toDoItem.ProjectCode = "";
|
||||
toDoItem.Content = warningContent;
|
||||
toDoItem.UserId = userId;
|
||||
toDoItem.UserName = UserService.GetUserNameByUserId(userId);
|
||||
toDoItem.DataTime = DateTime.Now;
|
||||
toDoItem.DataTimeStr = DateTime.Now.ToString("yyyy-MM-dd");
|
||||
toDoItem.PCUrl = urlParams;
|
||||
toDoItems.Add(toDoItem);
|
||||
}
|
||||
|
||||
return toDoItems;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user