培训考试积分

This commit is contained in:
2026-11-20 15:32:57 +08:00
parent 02a1a827f1
commit 6baa4ed8b5
16 changed files with 552 additions and 535 deletions
+490
View File
@@ -178,5 +178,495 @@ namespace BLL
db.SubmitChanges();
}
}
#region 考试后记分
/// <summary>
/// 考试后记分
/// </summary>
/// <param name="testRecordId"></param>
public static void HseScoring(string testRecordId)
{
if (string.IsNullOrWhiteSpace(testRecordId))
{
return;
}
//考试大于等于及格分、已开考、且没有加过分的记录,加分
int passScore = SysConstSetService.getPassScore();
var testRecordList = (from x in Funs.DB.View_Training_TestRecord
where x.TestScores >= passScore && x.TestRecordId == testRecordId && x.TestStartTime != null
&& !Funs.DB.ScoreFlowLog.Any(log => log.DataSourceId == x.TestRecordId)
select x).ToList();
foreach (var item in testRecordList)
{
//无身份证(人员档案缺失)或教材/教材分类已删除时无法定位记分对象,跳过,避免按首档分重复加分
if (string.IsNullOrWhiteSpace(item.IdentityCard)
|| string.IsNullOrWhiteSpace(item.CompanyTrainingName)
|| string.IsNullOrWhiteSpace(item.CompanyTrainingItemName))
{
continue;
}
//查找最新一条积分记录
var flowLog = GetScoreFlowLogByIdentityCard(item.IdentityCard, item.TestStartTime.Value.Year, DateTime.Now);
//作业人员考试加分
if (item.WorkPostType == "一般作业岗位" || item.WorkPostType == "特种作业人员")
{
//必修-岗位基本操作技能:一门专业课20分,最高20分;超过1门课程,多出的学习课程每门2分
if (item.CompanyTrainingId == BLL.Const.CompanyTrainingId3)
{
var scoreFlowLog = (from x in Funs.DB.ScoreFlowLog where x.Type == 1 && x.IdentityCard == item.IdentityCard && x.Year == item.TestStartTime.Value.Year && x.Item.Contains("考试【岗位基本操作技能】") orderby x.CompileDate descending select x).ToList();
//一个课程加分一次
var isExist = scoreFlowLog.Where(x => x.LogContent.Contains("岗位基本操作技能【" + item.CompanyTrainingItemName + "】")).FirstOrDefault();
if (isExist == null)//第一次加分
{
//人员记分流水日志表
Model.ScoreFlowLog newlog = new Model.ScoreFlowLog();
newlog.Id = SQLHelper.GetNewID();
newlog.Year = item.TestStartTime.Value.Year;
newlog.IdentityCard = item.IdentityCard;
newlog.UserName = item.PersonName;
newlog.PersonId = item.TestManId;
newlog.UnitId = item.UnitId;
newlog.ProjectId = item.ProjectId;
newlog.UnitName = item.UnitName;
newlog.ProjectName = item.ProjectName;
newlog.Type = 1;
newlog.Item = "考试【岗位基本操作技能】";
newlog.LogContent = "岗位基本操作技能【" + item.CompanyTrainingItemName + "】考试得分" + item.TestScores + "分后,加分";
newlog.CompileDate = DateTime.Now;
newlog.CompileManId = "";
newlog.CompileMan = "";
newlog.DataSourceId = item.TestRecordId;
newlog.CheckDate = item.TestStartTime;
if (scoreFlowLog.Count == 0)
{
newlog.Score = 20;
if (flowLog != null)
{
newlog.CurrentScore = flowLog.CurrentScore + 20;
}
else
{
newlog.CurrentScore = 120;
}
}
else
{
newlog.Score = 2;
if (flowLog != null)
{
newlog.CurrentScore = flowLog.CurrentScore + 2;
}
else
{
newlog.CurrentScore = 102;
}
}
newlog.CurrentScore = newlog.CurrentScore < 0 ? 0 : newlog.CurrentScore;
BLL.ScoreFlowLogService.AddScoreFlowLog(newlog);
//人员记分情况
Model.ScoreUser newScoreUser = new ScoreUser();
newScoreUser.Id = SQLHelper.GetNewID();
newScoreUser.Year = newlog.Year;
newScoreUser.IdentityCard = item.IdentityCard;
newScoreUser.Score = newlog.CurrentScore;
newScoreUser.UserName = newlog.UserName;
newScoreUser.CompileDate = newlog.CompileDate;
newScoreUser.DataSourceId = newlog.DataSourceId;
newScoreUser.CheckDate = newlog.CheckDate;
BLL.ScoreUserService.AddScoreUser(newScoreUser);
}
}
//必修-通用安全知识:60分,每门10分,最高60分;超过6门课程,多出的学习课程每门2分
else if (item.CompanyTrainingId == BLL.Const.CompanyTrainingId1)
{
var scoreFlowLog = (from x in Funs.DB.ScoreFlowLog where x.Type == 1 && x.IdentityCard == item.IdentityCard && x.Year == item.TestStartTime.Value.Year && x.Item.Contains("考试【通用安全知识】") orderby x.CompileDate descending select x).ToList();
//一个课程加分一次
var isExist = scoreFlowLog.Where(x => x.LogContent.Contains("通用安全知识【" + item.CompanyTrainingItemName + "】")).FirstOrDefault();
if (isExist == null)//第一次加分
{
//人员记分流水日志表
Model.ScoreFlowLog newlog = new Model.ScoreFlowLog();
newlog.Id = SQLHelper.GetNewID();
newlog.Year = item.TestStartTime.Value.Year;
newlog.IdentityCard = item.IdentityCard;
newlog.UserName = item.PersonName;
newlog.PersonId = item.TestManId;
newlog.UnitId = item.UnitId;
newlog.ProjectId = item.ProjectId;
newlog.UnitName = item.UnitName;
newlog.ProjectName = item.ProjectName;
newlog.Type = 1;
newlog.Item = "考试【通用安全知识】";
newlog.LogContent = "通用安全知识【" + item.CompanyTrainingItemName + "】考试得分" + item.TestScores + "分后,加分";
newlog.CompileDate = DateTime.Now;
newlog.CompileManId = "";
newlog.CompileMan = "";
newlog.DataSourceId = item.TestRecordId;
newlog.CheckDate = item.TestStartTime;
if (scoreFlowLog.Count < 6)
{
newlog.Score = 10;
if (flowLog != null)
{
newlog.CurrentScore = flowLog.CurrentScore + 10;
}
else
{
newlog.CurrentScore = 110;
}
}
else
{
newlog.Score = 2;
if (flowLog != null)
{
newlog.CurrentScore = flowLog.CurrentScore + 2;
}
else
{
newlog.CurrentScore = 102;
}
}
newlog.CurrentScore = newlog.CurrentScore < 0 ? 0 : newlog.CurrentScore;
BLL.ScoreFlowLogService.AddScoreFlowLog(newlog);
//人员记分情况
Model.ScoreUser newScoreUser = new ScoreUser();
newScoreUser.Id = SQLHelper.GetNewID();
newScoreUser.Year = newlog.Year;
newScoreUser.IdentityCard = item.IdentityCard;
newScoreUser.Score = newlog.CurrentScore;
newScoreUser.UserName = newlog.UserName;
newScoreUser.CompileDate = newlog.CompileDate;
newScoreUser.DataSourceId = newlog.DataSourceId;
newScoreUser.CheckDate = newlog.CheckDate;
BLL.ScoreUserService.AddScoreUser(newScoreUser);
}
}
//选修加分 每节课2分,加分上线不限制,以年度为节点
else
{
var isExist = (from x in Funs.DB.ScoreFlowLog
where x.Type == 1 && x.IdentityCard == item.IdentityCard && x.Year == item.TestStartTime.Value.Year
&& x.Item.Contains(item.CompanyTrainingName)
&& x.LogContent.Contains(item.CompanyTrainingName + "【" + item.CompanyTrainingItemName + "】")
orderby x.CompileDate descending
select x).FirstOrDefault();
if (isExist == null)
{
//人员记分流水日志表
Model.ScoreFlowLog newlog = new Model.ScoreFlowLog();
newlog.Id = SQLHelper.GetNewID();
newlog.Year = item.TestStartTime.Value.Year;
newlog.IdentityCard = item.IdentityCard;
newlog.UserName = item.PersonName;
newlog.PersonId = item.TestManId;
newlog.UnitId = item.UnitId;
newlog.ProjectId = item.ProjectId;
newlog.UnitName = item.UnitName;
newlog.ProjectName = item.ProjectName;
newlog.Type = 1;
newlog.Item = "考试【" + item.CompanyTrainingName + "】";
newlog.LogContent = item.CompanyTrainingName + "【" + item.CompanyTrainingItemName + "】考试得分" + item.TestScores + "分后,加分";
newlog.CompileDate = DateTime.Now;
newlog.CompileManId = "";
newlog.CompileMan = "";
newlog.DataSourceId = item.TestRecordId;
newlog.CheckDate = item.TestStartTime;
newlog.Score = 2;
if (flowLog != null)
{
newlog.CurrentScore = flowLog.CurrentScore + 2;
}
else
{
newlog.CurrentScore = 102;
}
newlog.CurrentScore = newlog.CurrentScore < 0 ? 0 : newlog.CurrentScore;
BLL.ScoreFlowLogService.AddScoreFlowLog(newlog);
//人员记分情况
Model.ScoreUser newScoreUser = new ScoreUser();
newScoreUser.Id = SQLHelper.GetNewID();
newScoreUser.Year = newlog.Year;
newScoreUser.IdentityCard = item.IdentityCard;
newScoreUser.Score = newlog.CurrentScore;
newScoreUser.UserName = newlog.UserName;
newScoreUser.CompileDate = newlog.CompileDate;
newScoreUser.DataSourceId = newlog.DataSourceId;
newScoreUser.CheckDate = newlog.CheckDate;
BLL.ScoreUserService.AddScoreUser(newScoreUser);
}
}
}
//管理人员考试加分
else if (item.WorkPostType == "一般管理岗位" || item.WorkPostType == "特种管理人员")
{
//必修-知识方法工具,最少学习5门课程,一门5分;超过5门课程,多出的学习课程每门2分
if (item.CompanyTrainingId == BLL.Const.CompanyTrainingId2)
{
var scoreFlowLog = (from x in Funs.DB.ScoreFlowLog where x.Type == 1 && x.IdentityCard == item.IdentityCard && x.Year == item.TestStartTime.Value.Year && x.Item.Contains("考试【知识方法工具】") orderby x.CompileDate descending select x).ToList();
//一次考试加分一次
var isExist = scoreFlowLog.Where(x => x.LogContent.Contains("知识方法工具【" + item.CompanyTrainingItemName + "】")).FirstOrDefault();
if (isExist == null)//第一次加分
{
//人员记分流水日志表
Model.ScoreFlowLog newlog = new Model.ScoreFlowLog();
newlog.Id = SQLHelper.GetNewID();
newlog.Year = item.TestStartTime.Value.Year;
newlog.IdentityCard = item.IdentityCard;
newlog.UserName = item.PersonName;
newlog.PersonId = item.TestManId;
newlog.UnitId = item.UnitId;
newlog.ProjectId = item.ProjectId;
newlog.UnitName = item.UnitName;
newlog.ProjectName = item.ProjectName;
newlog.Type = 1;
newlog.Item = "考试【知识方法工具】";
newlog.LogContent = "知识方法工具【" + item.CompanyTrainingItemName + "】考试得分" + item.TestScores + "分后,加分";
newlog.CompileDate = DateTime.Now;
newlog.CompileManId = "";
newlog.CompileMan = "";
newlog.DataSourceId = item.TestRecordId;
newlog.CheckDate = item.TestStartTime;
if (scoreFlowLog.Count < 5)
{
newlog.Score = 5;
if (flowLog != null)
{
newlog.CurrentScore = flowLog.CurrentScore + 5;
}
else
{
newlog.CurrentScore = 105;
}
}
else
{
newlog.Score = 2;
if (flowLog != null)
{
newlog.CurrentScore = flowLog.CurrentScore + 2;
}
else
{
newlog.CurrentScore = 102;
}
}
newlog.CurrentScore = newlog.CurrentScore < 0 ? 0 : newlog.CurrentScore;
BLL.ScoreFlowLogService.AddScoreFlowLog(newlog);
//人员记分情况
Model.ScoreUser newScoreUser = new ScoreUser();
newScoreUser.Id = SQLHelper.GetNewID();
newScoreUser.Year = newlog.Year;
newScoreUser.IdentityCard = item.IdentityCard;
newScoreUser.Score = newlog.CurrentScore;
newScoreUser.UserName = newlog.UserName;
newScoreUser.CompileDate = newlog.CompileDate;
newScoreUser.DataSourceId = newlog.DataSourceId;
newScoreUser.CheckDate = newlog.CheckDate;
BLL.ScoreUserService.AddScoreUser(newScoreUser);
}
}
//必修-生产受控管理,最少学习5门课程,一门5分;超过5门课程,多出的学习课程每门2分
else if (item.CompanyTrainingId == BLL.Const.CompanyTrainingId4)
{
var scoreFlowLog = (from x in Funs.DB.ScoreFlowLog where x.Type == 1 && x.IdentityCard == item.IdentityCard && x.Year == item.TestStartTime.Value.Year && x.Item.Contains("考试【生产受控管理】") orderby x.CompileDate descending select x).ToList();
//一次考试加分一次
var isExist = scoreFlowLog.Where(x => x.LogContent.Contains("生产受控管理【" + item.CompanyTrainingItemName + "】")).FirstOrDefault();
if (isExist == null)//第一次加分
{
//人员记分流水日志表
Model.ScoreFlowLog newlog = new Model.ScoreFlowLog();
newlog.Id = SQLHelper.GetNewID();
newlog.Year = item.TestStartTime.Value.Year;
newlog.IdentityCard = item.IdentityCard;
newlog.UserName = item.PersonName;
newlog.PersonId = item.TestManId;
newlog.UnitId = item.UnitId;
newlog.ProjectId = item.ProjectId;
newlog.UnitName = item.UnitName;
newlog.ProjectName = item.ProjectName;
newlog.Type = 1;
newlog.Item = "考试【生产受控管理】";
newlog.LogContent = "生产受控管理【" + item.CompanyTrainingItemName + "】考试得分" + item.TestScores + "分后,加分";
newlog.CompileDate = DateTime.Now;
newlog.CompileManId = "";
newlog.CompileMan = "";
newlog.DataSourceId = item.TestRecordId;
newlog.CheckDate = item.TestStartTime;
if (scoreFlowLog.Count < 5)
{
newlog.Score = 5;
if (flowLog != null)
{
newlog.CurrentScore = flowLog.CurrentScore + 5;
}
else
{
newlog.CurrentScore = 105;
}
}
else
{
newlog.Score = 2;
if (flowLog != null)
{
newlog.CurrentScore = flowLog.CurrentScore + 2;
}
else
{
newlog.CurrentScore = 102;
}
}
newlog.CurrentScore = newlog.CurrentScore < 0 ? 0 : newlog.CurrentScore;
BLL.ScoreFlowLogService.AddScoreFlowLog(newlog);
//人员记分情况
Model.ScoreUser newScoreUser = new ScoreUser();
newScoreUser.Id = SQLHelper.GetNewID();
newScoreUser.Year = newlog.Year;
newScoreUser.IdentityCard = item.IdentityCard;
newScoreUser.Score = newlog.CurrentScore;
newScoreUser.UserName = newlog.UserName;
newScoreUser.CompileDate = newlog.CompileDate;
newScoreUser.DataSourceId = newlog.DataSourceId;
newScoreUser.CheckDate = newlog.CheckDate;
BLL.ScoreUserService.AddScoreUser(newScoreUser);
}
}
//必修-通用课程:通用安全知识:30分,每门10分,最高30分;超过3门课程,多出的学习课程每门2分
else if (item.CompanyTrainingId == BLL.Const.CompanyTrainingId1)
{
var scoreFlowLog = (from x in Funs.DB.ScoreFlowLog where x.Type == 1 && x.IdentityCard == item.IdentityCard && x.Year == item.TestStartTime.Value.Year && x.Item.Contains("考试【通用安全知识】") orderby x.CompileDate descending select x).ToList();
//一次考试加分一次
var isExist = scoreFlowLog.Where(x => x.LogContent.Contains("通用安全知识【" + item.CompanyTrainingItemName + "】")).FirstOrDefault();
if (isExist == null)//第一次加分
{
//人员记分流水日志表
Model.ScoreFlowLog newlog = new Model.ScoreFlowLog();
newlog.Id = SQLHelper.GetNewID();
newlog.Year = item.TestStartTime.Value.Year;
newlog.IdentityCard = item.IdentityCard;
newlog.UserName = item.PersonName;
newlog.PersonId = item.TestManId;
newlog.UnitId = item.UnitId;
newlog.ProjectId = item.ProjectId;
newlog.UnitName = item.UnitName;
newlog.ProjectName = item.ProjectName;
newlog.Type = 1;
newlog.Item = "考试【通用安全知识】";
newlog.LogContent = "通用安全知识【" + item.CompanyTrainingItemName + "】考试得分" + item.TestScores + "分后,加分";
newlog.CompileDate = DateTime.Now;
newlog.CompileManId = "";
newlog.CompileMan = "";
newlog.DataSourceId = item.TestRecordId;
newlog.CheckDate = item.TestStartTime;
if (scoreFlowLog.Count < 3)
{
newlog.Score = 10;
if (flowLog != null)
{
newlog.CurrentScore = flowLog.CurrentScore + 10;
}
else
{
newlog.CurrentScore = 110;
}
}
else
{
newlog.Score = 2;
if (flowLog != null)
{
newlog.CurrentScore = flowLog.CurrentScore + 2;
}
else
{
newlog.CurrentScore = 102;
}
}
newlog.CurrentScore = newlog.CurrentScore < 0 ? 0 : newlog.CurrentScore;
BLL.ScoreFlowLogService.AddScoreFlowLog(newlog);
//人员记分情况
Model.ScoreUser newScoreUser = new ScoreUser();
newScoreUser.Id = SQLHelper.GetNewID();
newScoreUser.Year = newlog.Year;
newScoreUser.IdentityCard = item.IdentityCard;
newScoreUser.Score = newlog.CurrentScore;
newScoreUser.UserName = newlog.UserName;
newScoreUser.CompileDate = newlog.CompileDate;
newScoreUser.DataSourceId = newlog.DataSourceId;
newScoreUser.CheckDate = newlog.CheckDate;
BLL.ScoreUserService.AddScoreUser(newScoreUser);
}
}
else //选修加分 每节课2分,加分上线不限制,以年度为节点
{
var isExist = (from x in Funs.DB.ScoreFlowLog
where x.Type == 1 && x.IdentityCard == item.IdentityCard && x.Year == item.TestStartTime.Value.Year
&& x.Item.Contains(item.CompanyTrainingName)
&& x.LogContent.Contains(item.CompanyTrainingName + "【" + item.CompanyTrainingItemName + "】")
orderby x.CompileDate descending
select x).FirstOrDefault();
if (isExist == null)
{
//人员记分流水日志表
Model.ScoreFlowLog newlog = new Model.ScoreFlowLog();
newlog.Id = SQLHelper.GetNewID();
newlog.Year = item.TestStartTime.Value.Year;
newlog.IdentityCard = item.IdentityCard;
newlog.UserName = item.PersonName;
newlog.PersonId = item.TestManId;
newlog.UnitId = item.UnitId;
newlog.ProjectId = item.ProjectId;
newlog.UnitName = item.UnitName;
newlog.ProjectName = item.ProjectName;
newlog.Type = 1;
newlog.Item = "考试【" + item.CompanyTrainingName + "】";
newlog.LogContent = item.CompanyTrainingName + "【" + item.CompanyTrainingItemName + "】考试得分" + item.TestScores + "分后,加分";
newlog.CompileDate = DateTime.Now;
newlog.CompileManId = "";
newlog.CompileMan = "";
newlog.DataSourceId = item.TestRecordId;
newlog.CheckDate = item.TestStartTime;
newlog.Score = 2;
if (flowLog != null)
{
newlog.CurrentScore = flowLog.CurrentScore + 2;
}
else
{
newlog.CurrentScore = 102;
}
newlog.CurrentScore = newlog.CurrentScore < 0 ? 0 : newlog.CurrentScore;
BLL.ScoreFlowLogService.AddScoreFlowLog(newlog);
//人员记分情况
Model.ScoreUser newScoreUser = new ScoreUser();
newScoreUser.Id = SQLHelper.GetNewID();
newScoreUser.Year = newlog.Year;
newScoreUser.IdentityCard = item.IdentityCard;
newScoreUser.Score = newlog.CurrentScore;
newScoreUser.UserName = newlog.UserName;
newScoreUser.CompileDate = newlog.CompileDate;
newScoreUser.DataSourceId = newlog.DataSourceId;
newScoreUser.CheckDate = newlog.CheckDate;
BLL.ScoreUserService.AddScoreUser(newScoreUser);
}
}
}
}
}
#endregion
}
}