考试优化

This commit is contained in:
2026-11-25 19:14:57 +08:00
parent 6baa4ed8b5
commit 93a48943a1
6 changed files with 62 additions and 8 deletions
@@ -506,10 +506,10 @@ namespace BLL
{
getTItem.SubjectScore = getTItem.Score ?? 0;
}
else
{
getTItem.SubjectScore = Convert.ToDecimal((getTItem.Score ?? 0) * 1.0 / 2);
}
//else
//{
// getTItem.SubjectScore = Convert.ToDecimal((getTItem.Score ?? 0) * 1.0 / 2);
//}
}
}
}
@@ -960,6 +960,7 @@ namespace BLL
{
using (Model.CNPCDB db = new Model.CNPCDB(Funs.ConnString))
{
//ErrLogInfo.WriteLog($"【考试交卷后记分2】testRecordId:{testPlanId};");
//// 获取考试计划
var getTestPlan = db.Training_TestPlan.FirstOrDefault(x => x.TestPlanId == testPlanId);
if (getTestPlan != null)
@@ -62,6 +62,45 @@ namespace BLL
#endregion
#region 根据testRecordId关闭【培训任务】和计划
/// <summary>
/// 关闭人员培训任务计划
/// </summary>
/// <param name="testRecordId"></param>
public static void UpdatePersonTask(string testRecordId, string companyTrainingItemId, string projectId, string testManId)
{
using (Model.CNPCDB db = new Model.CNPCDB(Funs.ConnString))
{
var taskIds = from tba in db.Training_Plan
join tbb in db.Training_Task on tba.PlanId equals tbb.PlanId
where tba.ProjectId == projectId && tba.CompanyTrainingItemId == companyTrainingItemId && tbb.States == "1" && tbb.UserId == testManId
select tbb.TaskId;
foreach (var tid in taskIds)
{
var taskItem = db.Training_TaskItem.Where(x => x.TaskId == tid && x.CompanyTrainingItemId == companyTrainingItemId && x.PersonId == testManId).FirstOrDefault();
if (taskItem != null)
{
taskItem.EndTime = DateTime.Now;//有结束时间代表已完成
db.SubmitChanges();
}
var taskItems = db.Training_TaskItem.Where(x => x.TaskId == tid && x.EndTime.HasValue == false);
//if (taskItems.Count() == 0)
if (!taskItems.Any())
{
var task = db.Training_Task.Where(x => x.TaskId == tid).FirstOrDefault();
if (task != null)
{
task.States = Const.State_2;//0-未响应;1-已响应;2-已完成
db.SubmitChanges();
}
}
}
}
}
#endregion
#region 根据TaskId获取培训任务教材列表
/// <summary>
/// 根据TaskId获取培训任务列表
@@ -298,7 +298,7 @@ namespace BLL
var workPostPersons = PersonService.GetPersonListByWorkPostIds(info.CurrProjectId, workPostIds);
//人员单位
var unitIds = workPostPersons.Any() ? String.Join(", ", workPostPersons.Select(x => x.UnitId).Distinct()) : string.Empty;
var unitIds = workPostPersons.Any() ? string.Join(", ", workPostPersons.Select(x => x.UnitId).Distinct()) : string.Empty;
//2、根据教材id查询今年是否有相关培训计划(排除重修培训计划),如果有先删除;
var plans = GetThisYearPlanByCompanyTrainingItemId(info.CurrProjectId, info.CompanyTrainingItemId, DateTime.Now.Year);
if (plans.Any())
@@ -350,7 +350,7 @@ namespace BLL
TrainLevelId = Const.OtherTrainLevelId,
UnitIds = unitIds,
WorkPostId = companyTrainingItem.WorkPostIds,
States = "1",
States = "1",//0-待提交;1-已提交;2-已推送;-1-已作废
Cycle = "",
//IsRetakeCourse = 0,
//CheckType = info.CheckType.ToString(),
@@ -371,8 +371,9 @@ namespace BLL
List<Training_Task> newTasks = new List<Training_Task>();
List<Training_TaskItem> newTaskItems = new List<Training_TaskItem>();
var proWorkPostPersons = workPostPersons.Where(x => x.ProjectId == pid);
//循环给人员添加任务
foreach (var person in workPostPersons)
foreach (var person in proWorkPostPersons)
{
string taskId = SQLHelper.GetNewID();
//新增培训任务
@@ -383,7 +384,7 @@ namespace BLL
PlanId = planId,
UserId = person.PersonId,
TaskDate = DateTime.Now,
States = Const.State_1,
States = Const.State_1,//0-未响应;1-已响应;2-已完成
};
newTasks.Add(newTask);
+2
View File
@@ -188,6 +188,8 @@ namespace BLL
/// <param name="testRecordId"></param>
public static void HseScoring(string testRecordId)
{
//ErrLogInfo.WriteLog($"【考试后记分】testRecordId:{testRecordId};");
if (string.IsNullOrWhiteSpace(testRecordId))
{
return;
@@ -354,6 +354,7 @@ namespace WebAPI.Controllers
}
else
{
//ErrLogInfo.WriteLog($"【考试交卷后记分】testRecordId:{testRecordId};");
//记分
ScoreFlowLogService.HseScoring(testRecordId);
APITestRecordService.updateAll(getTestRecord.TestPlanId);
@@ -383,6 +384,7 @@ namespace WebAPI.Controllers
string Signature = testRecordItem.Signature;
string Fingerprint = testRecordItem.Fingerprint;
var responeData = new Model.ResponeData();
//ErrLogInfo.WriteLog($"【交卷】testRecordId:{testRecordId};");
try
{
using (Model.CNPCDB db = new Model.CNPCDB(Funs.ConnString))
@@ -465,6 +467,7 @@ namespace WebAPI.Controllers
}
else
{
//ErrLogInfo.WriteLog($"【考试交卷后记分2】testRecordId:{testRecordId};");
//记分
ScoreFlowLogService.HseScoring(testRecordId);
APITestRecordService.updateAll(getTestRecord.TestPlanId);
@@ -474,6 +477,14 @@ namespace WebAPI.Controllers
}
else
{
if (getTestScores >= getPassScores)
{
//ErrLogInfo.WriteLog($"【考试交卷后记分2.2】testRecordId:{testRecordId};");
//记分
ScoreFlowLogService.HseScoring(testRecordId);
//关闭培训任务
APITrainingTaskService.UpdatePersonTask(getTestRecord.TestRecordId, getTestRecord.CompanyTrainingItemId, getTestRecord.ProjectId, getTestRecord.TestManId);
}
responeData.data = new { getTestScores, getPassScores };
}
}