1代码合并

This commit is contained in:
2025-02-05 17:57:14 +08:00
parent 4bbce72980
commit 5712066e0a
57 changed files with 334 additions and 3709 deletions
-297
View File
@@ -1660,302 +1660,5 @@ namespace BLL
}
}
}
#region
/// <summary>
/// 根据培训类型获取项目培训人员信息
/// </summary>
/// <param name="projectId">项目ID</param>
/// <param name="unitIds">培训单位ID</param>
/// <param name="workPostIds">培训岗位ID</param>
/// <param name="trainTypeId">培训类型ID</param>
/// <returns></returns>
public static List<Model.PersonItem> getTrainingPersonListByTrainTypeId(string projectId, string unitIds, string workPostIds, string departIds, string trainTypeId, string InTime, string strParam)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
DateTime inDateTime = DateTime.Now;
if (!string.IsNullOrEmpty(InTime) && !"null".Equals(InTime))
{
inDateTime = DateTime.Parse(InTime);
}
List<string> unitIdList = Funs.GetStrListByStr(unitIds, ',');
var getPersons = (from x in db.View_SitePerson_Person
where x.ProjectId == projectId && unitIdList.Contains(x.UnitId) && x.IsUsed == true && (string.IsNullOrEmpty(strParam) || x.PersonName.Contains(strParam)) && (string.IsNullOrEmpty(InTime) || x.InTime < inDateTime)
&& x.InTime <= DateTime.Now && (!x.OutTime.HasValue || x.OutTime >= DateTime.Now)
select new Model.PersonItem
{
PersonId = x.PersonId,
CardNo = x.CardNo,
PersonName = x.PersonName,
SexName = x.SexName,
IdentityCard = x.IdentityCard,
Address = x.Address,
ProjectId = x.ProjectId,
ProjectCode = x.ProjectCode,
ProjectName = x.ProjectName,
UnitId = x.UnitId,
UnitCode = x.UnitCode,
UnitName = x.UnitName,
TeamGroupId = x.TeamGroupId,
TeamGroupName = x.TeamGroupName,
WorkPostId = x.WorkPostId,
WorkPostName = x.WorkPostName,
InTime = string.Format("{0:yyyy-MM-dd}", x.InTime),
OutTime = string.Format("{0:yyyy-MM-dd}", x.OutTime),
OutResult = x.OutResult,
Telephone = x.Telephone,
PhotoUrl = x.PhotoUrl,
DepartName = x.DepartName,
}).ToList();
if (!string.IsNullOrEmpty(workPostIds))
{
List<string> workPostIdList = Funs.GetStrListByStr(workPostIds, ',');
getPersons = getPersons.Where(x => workPostIdList.Contains(x.WorkPostId)).ToList();
}
if (!string.IsNullOrEmpty(trainTypeId) && trainTypeId == Const.SpecialSafeTrainId)//专项安全培训
{
var ids = db.Base_WorkPost.Where(x => x.PostType == "2").Select(x => x.WorkPostId).ToList();
getPersons = getPersons.Where(x => ids.Contains(x.WorkPostId)).ToList();
}
List<Model.PersonItem> getTrainPersonList = new List<Model.PersonItem>();
var getTrainType = TrainTypeService.GetTrainTypeById(trainTypeId);
if (getTrainType != null && (!getTrainType.IsRepeat.HasValue || getTrainType.IsRepeat.Value == false))
{
int score = 80;
var sysTestRule = db.Sys_TestRule.FirstOrDefault();
if (sysTestRule != null)
{
if (sysTestRule.PassingScore > 0)
{
score = sysTestRule.PassingScore;
}
}
foreach (var item in getPersons)
{
var getTrainPersonIdList3 = (from x in db.Training_TestRecord
join y in db.Training_TestPlan on x.TestPlanId equals y.TestPlanId
where y.ProjectId == projectId && y.TrainTypeId == trainTypeId && y.States != "3" && x.TestManId == item.PersonId
where x.TestScores > score
select x).FirstOrDefault();
if (getTrainPersonIdList3 != null)
{
continue;
}
var getTrainPersonIdList1 = (from x in db.EduTrain_TrainRecordDetail
join y in db.EduTrain_TrainRecord on x.TrainingId equals y.TrainingId
where y.ProjectId == projectId && y.TrainTypeId == trainTypeId && x.CheckResult == true && x.PersonId == item.PersonId
select x).FirstOrDefault();
if (getTrainPersonIdList1 == null)
{
var getTrainPersonIdList2 = (from x in db.Training_Task
join y in db.Training_Plan on x.PlanId equals y.PlanId
where y.ProjectId == projectId && y.TrainTypeId == trainTypeId && y.States != "3" && x.UserId == item.PersonId
select x).FirstOrDefault();
if (getTrainPersonIdList2 == null)
{
getTrainPersonList.Add(item);
}
}
}
return getTrainPersonList;
}
else if (getTrainType != null && getTrainType.IsRepeat.HasValue && getTrainType.IsRepeat.Value == true)//重复的 过滤人员
{
foreach (var item in getPersons)
{
//int score = 80;
//var sysTestRule = db.Sys_TestRule.FirstOrDefault();
//if (sysTestRule != null)
//{
// if (sysTestRule.PassingScore > 0)
// {
// score = sysTestRule.PassingScore;
// }
//}
//var getTrainPersonIdList2 = (from x in db.Training_TestRecord
// join y in db.Training_TestPlan on x.TestPlanId equals y.TestPlanId
// where y.ProjectId == projectId && y.TrainTypeId == trainTypeId && y.States != "3" && x.TestManId == item.PersonId
// where x.TestScores > score
// select x).FirstOrDefault();
//if (getTrainPersonIdList2 != null)
//{
// continue;
//}
getTrainPersonList.Add(item);
}
return getTrainPersonList;
}
//else if (getTrainType != null && (!getTrainType.IsRepeat.HasValue || getTrainType.IsRepeat == false))//重复的 过滤人员
//{
// int score = 80;
// var sysTestRule = db.Sys_TestRule.FirstOrDefault();
// if (sysTestRule != null)
// {
// if (sysTestRule.PassingScore > 0)
// {
// score = sysTestRule.PassingScore;
// }
// }
// foreach (var item in getPersons)
// {
// var getTrainPersonIdList2 = (from x in db.Training_TestRecord
// join y in db.Training_TestPlan on x.TestPlanId equals y.TestPlanId
// where y.ProjectId == projectId && y.TrainTypeId == trainTypeId && y.States != "3" && x.TestManId == item.PersonId
// where x.TestScores > score
// select x).FirstOrDefault();
// if (getTrainPersonIdList2 != null)
// {
// continue;
// }
// getTrainPersonList.Add(item);
// }
// return getTrainPersonList;
//}
else
{
return getPersons.ToList();
}
}
}
#endregion
#region
/// <summary>
/// 根据培训类型获取项目培训人员信息
/// </summary>
/// <param name="projectId">项目ID</param>
/// <param name="unitIds">培训单位ID</param>
/// <param name="departIds">培训岗位ID</param>
/// <param name="trainTypeId">培训类型ID</param>
/// <returns></returns>
public static List<Model.PersonItem> getTrainingPersonListByDepartAndTrainTypeId(string unitIds, string departIds, string trainTypeId)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
List<string> unitIdList = Funs.GetStrListByStr(unitIds, ',');
var getPersons = from x in db.Sys_User
where unitIdList.Contains(x.UnitId)
select new Model.PersonItem
{
PersonId = x.UserId,
PersonName = x.UserName,
SexName = x.Sex,
IdentityCard = x.IdentityCard,
UnitId = x.UnitId,
WorkPostId = x.WorkPostId,
Telephone = x.Telephone,
PhotoUrl = x.PhotoUrl,
DepartId = x.DepartId
};
if (!string.IsNullOrEmpty(departIds))
{
List<string> departIdList = Funs.GetStrListByStr(departIds, ',');
getPersons = getPersons.Where(x => departIdList.Contains(x.DepartId));
}
foreach (var item in getPersons)
{
Model.Base_Unit unit = db.Base_Unit.FirstOrDefault(x => x.UnitId == item.UnitId);
if (!string.IsNullOrEmpty(item.UnitId))
{
if (unit != null)
{
item.UnitCode = unit.UnitCode;
item.UnitName = unit.UnitName;
}
}
if (!string.IsNullOrEmpty(item.DepartId))
{
Model.Base_Depart depart = db.Base_Depart.FirstOrDefault(x => x.DepartId == item.DepartId);
if (depart != null)
{
item.DepartName = depart.DepartName;
}
}
}
if (!string.IsNullOrEmpty(trainTypeId) && trainTypeId == Const.SpecialSafeTrainId)//专项安全培训
{
var ids = db.Base_WorkPost.Where(x => x.PostType == "2").Select(x => x.WorkPostId).ToList();
getPersons = getPersons.Where(x => ids.Contains(x.WorkPostId));
}
List<Model.PersonItem> getTrainPersonList = new List<Model.PersonItem>();
var getTrainType = db.Base_TrainType.FirstOrDefault(e => e.TrainTypeId == trainTypeId);
if (getTrainType != null && (!getTrainType.IsRepeat.HasValue || getTrainType.IsRepeat == false))
{
int score = 80;
var sysTestRule = db.Sys_TestRule.FirstOrDefault();
if (sysTestRule != null)
{
if (sysTestRule.PassingScore > 0)
{
score = sysTestRule.PassingScore;
}
}
foreach (var item in getPersons)
{
var getTrainPersonIdList3 = (from x in db.Training_TestRecord
join y in db.Training_TestPlan on x.TestPlanId equals y.TestPlanId
where y.TrainTypeId == trainTypeId && y.States != "3" && x.TestManId == item.PersonId
where x.TestScores > score
select x).FirstOrDefault();
if (getTrainPersonIdList3 != null)
{
continue;
}
var getTrainPersonIdList1 = (from x in db.EduTrain_TrainRecordDetail
join y in db.EduTrain_TrainRecord on x.TrainingId equals y.TrainingId
where y.ProjectId == null && y.TrainTypeId == trainTypeId && x.CheckResult == true && x.PersonId == item.PersonId
select x).FirstOrDefault();
if (getTrainPersonIdList1 == null)
{
var getTrainPersonIdList2 = (from x in db.Training_Task
join y in db.Training_Plan on x.PlanId equals y.PlanId
where y.ProjectId == null && y.TrainTypeId == trainTypeId && y.States != "3" && x.UserId == item.PersonId
select x).FirstOrDefault();
if (getTrainPersonIdList2 == null)
{
getTrainPersonList.Add(item);
}
}
}
return getTrainPersonList;
}
else
{
return getPersons.ToList();
}
}
}
#endregion
}
}