三级安全教育在线考试

This commit is contained in:
wyw 2025-11-25 21:14:54 +08:00
parent 3bc9a80abd
commit 74fdf556ae
2 changed files with 85 additions and 81 deletions

View File

@ -221,85 +221,83 @@ namespace APT.PP.WebApi.Controllers.Api.PP
//金源培训 9 ~ 15 可以触发一次 //金源培训 9 ~ 15 可以触发一次
if (currTime.Hour == 8 || currTime.Hour == 9) if (currTime.Hour == 8 || currTime.Hour == 9)
{ {
return true; var orgId = filter.GetOrgId();
} var newUsers = GetEntities<T_SE_USER_TEMP>(t => t.IS_SEND == 0, new BaseFilter(orgId));
if (!newUsers.Any() || newUsers.Count() < 1)
{
return true;
}
//如果今天触发过三级安全教育 直接返回
var NewCheck = GetEntity<T_SE_NEW_USERS>(e => !e.IS_DELETED && e.TRAIN_STATUS == SEThreeLevelSafeTrainType. && e.CREATE_TIME.HasValue && e.CREATE_TIME.Value.Date == currTime.Date);
if (NewCheck != null)
{
return true;
}
var orgId = filter.GetOrgId(); T_SE_NEW_USERS eduCard = null;
var newUsers = GetEntities<T_SE_USER_TEMP>(t => t.IS_SEND == 0, new BaseFilter(orgId)); List<T_FM_NOTIFICATION_TASK> sendNotice = new List<T_FM_NOTIFICATION_TASK>();
if (!newUsers.Any() || newUsers.Count() < 1) List<T_SE_NEW_USER_DETAIL> userDetails = new List<T_SE_NEW_USER_DETAIL>();
{
return true;
}
//如果今天触发过三级安全教育 直接返回
var NewCheck = GetEntity<T_SE_NEW_USERS>(e => !e.IS_DELETED && e.TRAIN_STATUS == SEThreeLevelSafeTrainType. && e.CREATE_TIME.HasValue && e.CREATE_TIME.Value.Date == currTime.Date);
if (NewCheck != null)
{
return true;
}
T_SE_NEW_USERS eduCard = null; var newUsersId = newUsers.Select(t => t.USER_ID);
List<T_FM_NOTIFICATION_TASK> sendNotice = new List<T_FM_NOTIFICATION_TASK>(); var newAllUsers = GetEntities<T_FM_USER>(t => newUsersId.Contains(t.ID), new BaseFilter(orgId));
List<T_SE_NEW_USER_DETAIL> userDetails = new List<T_SE_NEW_USER_DETAIL>(); var sendUser = GetEntity<T_FM_USER>(t => t.Nav_ApproveRole != null && t.Nav_ApproveRole.NAME == "安环部安全员" && t.IS_DELETED == false && t.ENABLE_STATUS == 0);
var train_contents = GetEntity<T_SE_THREE_LEVEL_SAFE_CONTENT>(t => t.THREE_LEVEL_SAFE_TRAIN_TYPE == SEThreeLevelSafeTrainType.);
eduCard = new T_SE_NEW_USERS();
eduCard.ID = Guid.NewGuid();
eduCard.DEPARTMENT_ID = sendUser.DEPARTMENT_ID;
eduCard.USER_ID = sendUser.ID;
eduCard.ORG_ID = orgId;
eduCard.TRAIN_STATUS = SEThreeLevelSafeTrainType.;
eduCard.CREATE_TIME = currTime;
if (train_contents != null)
{
eduCard.CONTENT_ID = train_contents.ID;
}
foreach (var user in newAllUsers)
{
T_SE_NEW_USER_DETAIL userDetail = new T_SE_NEW_USER_DETAIL();
userDetail.ID = Guid.NewGuid();
userDetail.EDU_CARD_ID = eduCard.ID;
userDetail.USER_ID = user.ID;
userDetail.ID_CARD_NUMBER = user.ID_CARD;
userDetail.STATUS = 0;
userDetail.ORG_ID = eduCard.ORG_ID;
userDetail.IN_TIME = user.ENTRYTIME;
userDetails.Add(userDetail);
}
foreach (var item in newUsers)
{
item.IS_SEND = 1;
}
if (sendUser != null)
{
var endTime = DateTime.Now.AddDays(10);
var newEndTime = new DateTime(endTime.Year, endTime.Month, endTime.Day, 23, 59, 59);
sendNotice.Add(NotificationTaskService.InsertUserNoticeTaskModel(currTime.ToString("MMdd") + "-三级安全培训-" + eduCard.STATUS.GetDescription(), eduCard.ID, eduCard.ORG_ID, sendUser.ID, sendUser.NAME, DateTime.Now, newEndTime, 1, "SE062"));
}
T_FM_SYNC_TASK task = null;
if (!string.IsNullOrEmpty(filter.Parameter1) && eduCard != null)
{
task = GetEntity<T_FM_SYNC_TASK>(filter.Keyword);
task.CURR_TASK_START_TIME = currTime;//上次同步结束时间
task.UPDATE_SUCCES_TIME = DateTime.Now;//上次同步结束时间
task.SYNC_PARAM = "";//清空参数
}
var newUsersId = newUsers.Select(t => t.USER_ID); UnifiedCommit(() =>
var newAllUsers = GetEntities<T_FM_USER>(t => newUsersId.Contains(t.ID), new BaseFilter(orgId)); {
var sendUser = GetEntity<T_FM_USER>(t => t.Nav_ApproveRole != null && t.Nav_ApproveRole.NAME == "安环部安全员" && t.IS_DELETED == false && t.ENABLE_STATUS == 0); if (eduCard != null)
var train_contents = GetEntity<T_SE_THREE_LEVEL_SAFE_CONTENT>(t => t.THREE_LEVEL_SAFE_TRAIN_TYPE == SEThreeLevelSafeTrainType.); AddEntityNoCommit(eduCard);
eduCard = new T_SE_NEW_USERS(); if (sendNotice != null && sendNotice.Any())
eduCard.ID = Guid.NewGuid(); BantchAddEntityNoCommit(sendNotice);
eduCard.DEPARTMENT_ID = sendUser.DEPARTMENT_ID; if (userDetails != null && sendNotice.Any())
eduCard.USER_ID = sendUser.ID; BantchAddEntityNoCommit(userDetails);
eduCard.ORG_ID = orgId; if (newUsers != null && newUsers.Any())
eduCard.TRAIN_STATUS = SEThreeLevelSafeTrainType.; BantchUpdateEntityNoCommit(newUsers);
eduCard.CREATE_TIME = currTime; if (task != null)
if (train_contents != null) UpdateEntity(task);
{ });
eduCard.CONTENT_ID = train_contents.ID;
} }
foreach (var user in newAllUsers)
{
T_SE_NEW_USER_DETAIL userDetail = new T_SE_NEW_USER_DETAIL();
userDetail.ID = Guid.NewGuid();
userDetail.EDU_CARD_ID = eduCard.ID;
userDetail.USER_ID = user.ID;
userDetail.ID_CARD_NUMBER = user.ID_CARD;
userDetail.STATUS = 0;
userDetail.ORG_ID = eduCard.ORG_ID;
userDetail.IN_TIME = user.ENTRYTIME;
userDetails.Add(userDetail);
}
foreach (var item in newUsers)
{
item.IS_SEND = 1;
}
if (sendUser != null)
{
var endTime = DateTime.Now.AddDays(10);
var newEndTime = new DateTime(endTime.Year, endTime.Month, endTime.Day, 23, 59, 59);
sendNotice.Add(NotificationTaskService.InsertUserNoticeTaskModel(currTime.ToString("MMdd") + "-三级安全培训-" + eduCard.STATUS.GetDescription(), eduCard.ID, eduCard.ORG_ID, sendUser.ID, sendUser.NAME, DateTime.Now, newEndTime, 1, "SE062"));
}
T_FM_SYNC_TASK task = null;
if (!string.IsNullOrEmpty(filter.Parameter1) && eduCard != null)
{
task = GetEntity<T_FM_SYNC_TASK>(filter.Keyword);
task.CURR_TASK_START_TIME = currTime;//上次同步结束时间
task.UPDATE_SUCCES_TIME = DateTime.Now;//上次同步结束时间
task.SYNC_PARAM = "";//清空参数
}
UnifiedCommit(() =>
{
if (eduCard != null)
AddEntityNoCommit(eduCard);
if (sendNotice != null && sendNotice.Any())
BantchAddEntityNoCommit(sendNotice);
if (userDetails != null && sendNotice.Any())
BantchAddEntityNoCommit(userDetails);
if (newUsers != null && newUsers.Any())
BantchUpdateEntityNoCommit(newUsers);
if (task != null)
UpdateEntity(task);
});
return true; return true;
}); });
} }

View File

@ -302,17 +302,23 @@ namespace APT.SC.WebApi.Controllers.Api.SE
testFilter.Include = new string[] { "Nav_Points" }; testFilter.Include = new string[] { "Nav_Points" };
var currStatus = eduCard.TRAIN_STATUS; var currStatus = eduCard.TRAIN_STATUS;
IEnumerable<T_SE_TEST_ENUM_POINT> pointS = new List<T_SE_TEST_ENUM_POINT>(); IEnumerable<T_SE_TEST_ENUM_POINT> pointS = new List<T_SE_TEST_ENUM_POINT>();
string PointName = "";
if (eduCard.TRAIN_STATUS == SEThreeLevelSafeTrainType.) if (eduCard.TRAIN_STATUS == SEThreeLevelSafeTrainType.)
{ {
pointS = GetEntities<T_SE_TEST_ENUM_POINT>(t => t.NAME == "三级安全教育-公司级", new BaseFilter(orgId)); PointName = "三级安全教育-公司级";
} }
else if (eduCard.TRAIN_STATUS == SEThreeLevelSafeTrainType.) else if (eduCard.TRAIN_STATUS == SEThreeLevelSafeTrainType.)
{ {
pointS = GetEntities<T_SE_TEST_ENUM_POINT>(t => t.NAME == "三级安全教育-部门级", new BaseFilter(orgId)); PointName = "三级安全教育-部门级";
} }
else if (eduCard.TRAIN_STATUS == SEThreeLevelSafeTrainType.) else if (eduCard.TRAIN_STATUS == SEThreeLevelSafeTrainType.)
{ {
pointS = GetEntities<T_SE_TEST_ENUM_POINT>(t => t.NAME == "三级安全教育-班组级", new BaseFilter(orgId)); PointName = "三级安全教育-班组级";
}
pointS = GetEntities<T_SE_TEST_ENUM_POINT>(t => t.NAME == PointName, new BaseFilter(orgId));
if (pointS == null || pointS.Count() < 1)
{
throw new Exception("未找到试题知识点【" + PointName + "】的配置信息,请沟通管理员完善知识点和题库!");
} }
var pointIDS = pointS.Select(t => t.ID).ToList(); var pointIDS = pointS.Select(t => t.ID).ToList();
var allTests = GetEntities<T_SE_TEST>(st => st.Nav_Points.Any(pt => pointIDS.Contains((Guid)pt.POINT_ID)), testFilter).ToList(); var allTests = GetEntities<T_SE_TEST>(st => st.Nav_Points.Any(pt => pointIDS.Contains((Guid)pt.POINT_ID)), testFilter).ToList();
@ -324,12 +330,12 @@ namespace APT.SC.WebApi.Controllers.Api.SE
CreateTestList(allTests, testidlist, pointIDS, (int)SETestTypeEnum., CCount); CreateTestList(allTests, testidlist, pointIDS, (int)SETestTypeEnum., CCount);
CreateTestList(allTests, testidlist, pointIDS, (int)SETestTypeEnum., SCount); CreateTestList(allTests, testidlist, pointIDS, (int)SETestTypeEnum., SCount);
CreateTestList(allTests, testidlist, pointIDS, (int)SETestTypeEnum., MCount); CreateTestList(allTests, testidlist, pointIDS, (int)SETestTypeEnum., MCount);
if (testidlist.Count == 0)
if (testidlist.Count == 0 || testidlist.Count < (SCount + MCount + CCount))
{ {
throw new Exception("当前题库数据不足,未能正常生成试卷!"); throw new Exception("当前题库数据不足,未能正常生成试卷! 知识点:" + PointName + "是非题:" + CCount + "单选题:" + SCount + "多选题:" + MCount + "");
} }
Nav_Papers = new List<T_SE_NEW_USER_DETAIL_PAPER>(); Nav_Papers = new List<T_SE_NEW_USER_DETAIL_PAPER>();
testidlist.ForEach(testid => testidlist.ForEach(testid =>
{ {
var p = new T_SE_NEW_USER_DETAIL_PAPER var p = new T_SE_NEW_USER_DETAIL_PAPER