培训记录添加是否 触发培训记录待办

跑批修改 (如果提前签到 先生成培训记录单 等培训开始时间触发)
对于没触发培训记录编辑的待办 添加培训记录 未处理的待办
This commit is contained in:
wyw 2026-07-17 09:50:32 +08:00
parent 495843846d
commit d11dae692e
6 changed files with 140053 additions and 19 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,24 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace APT.Data.Migrations.Migrations
{
public partial class wyw2026071601 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "IS_SENDNOTICE",
table: "T_SE_TRAIN_RECORD",
type: "bit",
nullable: false,
defaultValue: false);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "IS_SENDNOTICE",
table: "T_SE_TRAIN_RECORD");
}
}
}

View File

@ -76378,6 +76378,9 @@ namespace APT.Data.Migrations.Migrations
b.Property<bool>("IS_DELETED") b.Property<bool>("IS_DELETED")
.HasColumnType("bit"); .HasColumnType("bit");
b.Property<bool>("IS_SENDNOTICE")
.HasColumnType("bit");
b.Property<Guid?>("MODIFIER_ID") b.Property<Guid?>("MODIFIER_ID")
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");

View File

@ -105,5 +105,10 @@ namespace APT.MS.Domain.Entities.SE
[Description("审阅时间")] [Description("审阅时间")]
public DateTime? DT_APPROVE { get; set; } public DateTime? DT_APPROVE { get; set; }
/// <summary>
/// 是否触发记录通知
/// </summary>
[Description("是否触发记录通知")]
public bool IS_SENDNOTICE { get; set; }
} }
} }

View File

@ -1908,6 +1908,7 @@ namespace APT.PP.WebApi.Controllers.Api.PP
{ {
try try
{ {
bool isClear = false;
var dt = DateTime.Now; var dt = DateTime.Now;
var Parameter1 = filter.Parameter1; var Parameter1 = filter.Parameter1;
if (!string.IsNullOrEmpty(filter.Parameter1)) if (!string.IsNullOrEmpty(filter.Parameter1))
@ -1929,7 +1930,7 @@ namespace APT.PP.WebApi.Controllers.Api.PP
var notifys = GetEntities<T_SE_TRAIN_NOTIFY>(t => (t.STATUS == SETrainNotifyStatus. || t.STATUS == SETrainNotifyStatus.) && t.TRAIN_START_TIME.Value < maxTime && t.CREATE_NOTIFY_RECORD == true, baseFilter).ToList(); var notifys = GetEntities<T_SE_TRAIN_NOTIFY>(t => (t.STATUS == SETrainNotifyStatus. || t.STATUS == SETrainNotifyStatus.) && t.TRAIN_START_TIME.Value < maxTime && t.CREATE_NOTIFY_RECORD == true, baseFilter).ToList();
#region #region
if (notifys != null || notifys.Any()) if (notifys != null && notifys.Any())
{ {
List<T_FM_NOTIFICATION_TASK> SendNotices = null; List<T_FM_NOTIFICATION_TASK> SendNotices = null;
List<T_SE_TRAIN_RECORD> TrainRecords = new List<T_SE_TRAIN_RECORD>(); List<T_SE_TRAIN_RECORD> TrainRecords = new List<T_SE_TRAIN_RECORD>();
@ -1954,6 +1955,7 @@ namespace APT.PP.WebApi.Controllers.Api.PP
ORG_ID = orgId, ORG_ID = orgId,
NOTIFY_ID = notify.ID, NOTIFY_ID = notify.ID,
STATUS = SETrainRecordStatus.稿, STATUS = SETrainRecordStatus.稿,
CREATER_ID = notify.RECORD_USER_ID,
}; };
foreach (var user in notify.Nav_TrainUserList) foreach (var user in notify.Nav_TrainUserList)
{ {
@ -1997,6 +1999,7 @@ namespace APT.PP.WebApi.Controllers.Api.PP
{ {
notify.STATUS = STATUS; notify.STATUS = STATUS;
} }
notify.ISSENDNOTICE = true;
notify.Nav_LaunchUser = null; notify.Nav_LaunchUser = null;
notify.Nav_RecordUser = null; notify.Nav_RecordUser = null;
}; };
@ -2008,17 +2011,7 @@ namespace APT.PP.WebApi.Controllers.Api.PP
notify1.NOTICE_STATUS = 4;//待办 处理 notify1.NOTICE_STATUS = 4;//待办 处理
} }
SendNotices = NotificationTaskService.InsertUserNoticeTaskModels(allSendTitles, allSendDataIds, orgId, allSendUserIds, allSendUserNames, DateTime.Now, DateTime.Now.AddDays(10), (int)FMNoticeTypeEnum., "SE018"); SendNotices = NotificationTaskService.InsertUserNoticeTaskModels(allSendTitles, allSendDataIds, orgId, allSendUserIds, allSendUserNames, DateTime.Now, DateTime.Now.AddDays(10), (int)FMNoticeTypeEnum., "SE018");
isClear = true;
T_FM_SYNC_TASK task = null;
if (!string.IsNullOrEmpty(filter.Parameter1))
{
task = GetEntity<T_FM_SYNC_TASK>(filter.Keyword);
if (task != null)
{
task.UPDATE_SUCCES_TIME = DateTime.Now;//上次同步结束时间
task.SYNC_PARAM = "";//清空参数
}
}
UnifiedCommit(() => UnifiedCommit(() =>
{ {
@ -2032,13 +2025,50 @@ namespace APT.PP.WebApi.Controllers.Api.PP
BantchAddEntityNoCommit(joinUsers); BantchAddEntityNoCommit(joinUsers);
if (files.Any()) if (files.Any())
BantchAddEntityNoCommit(files); BantchAddEntityNoCommit(files);
if (task != null)
UpdateEntityNoCommit(task);
if (finishNotifys1 != null && finishNotifys1.Any()) if (finishNotifys1 != null && finishNotifys1.Any())
BantchUpdateEntityNoCommit(finishNotifys1); BantchUpdateEntityNoCommit(finishNotifys1);
}); });
} }
#region
var listSend = GetEntities<T_SE_TRAIN_RECORD>(e => !e.IS_SENDNOTICE && e.Nav_Notify != null && e.Nav_Notify.TRAIN_START_TIME.HasValue && e.Nav_Notify.TRAIN_START_TIME.Value < maxTime, null, "Nav_Notify.Nav_RecordUser");
if (listSend != null && listSend.Count() > 0)
{
List<T_FM_NOTIFICATION_TASK> SendNotices = null;
var allSendUserIds = new List<Guid>();
var allSendUserNames = new List<string>();
var allSendTitles = new List<string>();
var allSendDataIds = new List<Guid>();
foreach (var item in listSend)
{
if (item.Nav_Notify.RECORD_USER_ID.HasValue)
{
item.IS_SENDNOTICE = true;
allSendTitles.Add("培训记录-" + item.Nav_Notify.NAME);
allSendDataIds.Add(item.ID);
allSendUserIds.Add(item.Nav_Notify.RECORD_USER_ID.Value);
allSendUserNames.Add(item.Nav_Notify.Nav_RecordUser.NAME);
}
}
SendNotices = NotificationTaskService.InsertUserNoticeTaskModels(allSendTitles, allSendDataIds, orgId, allSendUserIds, allSendUserNames, DateTime.Now, DateTime.Now.AddDays(10), (int)FMNoticeTypeEnum., "SE018");
if (SendNotices != null && SendNotices.Count > 0)
{
isClear = true;
UnifiedCommit(() =>
{
if (SendNotices.Any())
BantchAddEntityNoCommit(SendNotices);
if (listSend.Any())
BantchSaveEntityNoCommit(listSend);
});
}
}
#endregion
#endregion #endregion
#region #region
@ -2048,8 +2078,109 @@ namespace APT.PP.WebApi.Controllers.Api.PP
if (notifys != null && notifys.Count() > 0) if (notifys != null && notifys.Count() > 0)
{ {
var listNotifyID = notifys.Select(e => e.ID).Distinct(); var listNotifyID = notifys.Select(e => e.ID).Distinct();
var iListR = GetEntities<T_SE_TRAIN_RECORD>(e => listNotifyID.Contains(e.NOTIFY_ID), null, null); var iListR = GetEntities<T_SE_TRAIN_RECORD>(e => listNotifyID.Contains(e.NOTIFY_ID), null, null).ToList();
var listRecordID = iListR.Select(e => e.ID); #region
if (notifys.Count > iListR.Count())
{
List<T_SE_TRAIN_RECORD> TrainRecords = new List<T_SE_TRAIN_RECORD>();
List<T_SE_TRAIN_RECORD_USER> joinUsers = new List<T_SE_TRAIN_RECORD_USER>();
List<T_SE_TRAIN_RECORD_FILE> files = new List<T_SE_TRAIN_RECORD_FILE>();
T_SE_TRAIN_RECORD? modelCheck = null;
List<Guid> listNoticeID = new List<Guid>();
List<T_SE_TRAIN_NOTIFY> listAdd = new List<T_SE_TRAIN_NOTIFY>();
foreach (var item in notifys)
{
modelCheck = iListR.FirstOrDefault(e => e.NOTIFY_ID == item.ID);
if (modelCheck == null)
{
listNoticeID.Add(item.ID);
}
}
var notifysSign = GetEntities<T_SE_TRAIN_NOTIFY>(e => listNoticeID.Contains(e.ID), baseFilter).ToList();
SETrainNotifyStatus STATUS = SETrainNotifyStatus.稿;
foreach (var notify in notifysSign)
{
STATUS = notify.STATUS;
try
{
notify.STATUS = SETrainNotifyStatus.;
var record = new T_SE_TRAIN_RECORD
{
ID = Guid.NewGuid(),
ORG_ID = orgId,
NOTIFY_ID = notify.ID,
STATUS = SETrainRecordStatus.稿,
CREATER_ID = notify.RECORD_USER_ID,
};
foreach (var user in notify.Nav_TrainUserList)
{
var joinUser = new T_SE_TRAIN_RECORD_USER
{
ID = Guid.NewGuid(),
ORG_ID = orgId,
RECORD_ID = record.ID,
USER_ID = user.USER_ID,
DEPARTMENT_NAME = user.Nav_User.Nav_Department.NAME,
POST_NAME = user.Nav_User.Nav_Person.Nav_Post.NAME
};
if (user.IS_LEAVE == SETrainYesNoEnum.)
{
joinUser.STATUS = SETrainRecordUserStatusEnum.;
}
else
{
joinUser.STATUS = SETrainRecordUserStatusEnum.;
}
joinUsers.Add(joinUser);
}
foreach (var file in notify.Nav_Files)
{
var recordFile = new T_SE_TRAIN_RECORD_FILE
{
ID = Guid.NewGuid(),
ORG_ID = orgId,
RECORD_ID = record.ID,
IMG_FILE_ID = file.IMG_FILE_ID
};
files.Add(recordFile);
}
TrainRecords.Add(record);
}
catch
{
notify.STATUS = STATUS;
}
notify.ISSENDNOTICE = false;
notify.Nav_LaunchUser = null;
notify.Nav_RecordUser = null;
};
UnifiedCommit(() =>
{
if (notifysSign.Any())
BantchUpdateEntityNoCommit(notifysSign, "STATUS");
if (TrainRecords.Any())
BantchAddEntityNoCommit(TrainRecords);
if (joinUsers.Any())
BantchAddEntityNoCommit(joinUsers);
if (files.Any())
BantchAddEntityNoCommit(files);
});
iListR.AddRange(TrainRecords);
notifys.AddRange(notifysSign);
isClear = true;
}
#endregion
List<Guid> listRecordID = iListR.Select(e => e.ID).ToList();
#region
var listUsers = GetEntities<T_SE_TRAIN_RECORD_USER>(e => listRecordID.Contains(e.RECORD_ID) && e.STATUS == SETrainRecordUserStatusEnum. && e.Nav_User.ENABLE_STATUS == 0 && !e.Nav_User.IS_DELETED, null, "Nav_User"); var listUsers = GetEntities<T_SE_TRAIN_RECORD_USER>(e => listRecordID.Contains(e.RECORD_ID) && e.STATUS == SETrainRecordUserStatusEnum. && e.Nav_User.ENABLE_STATUS == 0 && !e.Nav_User.IS_DELETED, null, "Nav_User");
IEnumerable<T_SE_TRAIN_RECORD_USER> iListTemp = null; IEnumerable<T_SE_TRAIN_RECORD_USER> iListTemp = null;
T_SE_TRAIN_NOTIFY modelTr = null; T_SE_TRAIN_NOTIFY modelTr = null;
@ -2123,7 +2254,7 @@ namespace APT.PP.WebApi.Controllers.Api.PP
} }
item.DT_SSEND_SIGN = DateTime.Now; item.DT_SSEND_SIGN = DateTime.Now;
item.STATUS = SETrainRecordStatus.; item.STATUS = SETrainRecordStatus.;
isClear = true;
UnifiedCommit(() => UnifiedCommit(() =>
{ {
UpdateEntityNoCommit(modelTr); UpdateEntityNoCommit(modelTr);
@ -2136,10 +2267,26 @@ namespace APT.PP.WebApi.Controllers.Api.PP
} }
catch { } catch { }
} }
#endregion
} }
#endregion #endregion
if (!string.IsNullOrEmpty(filter.Parameter1) && isClear)
{
T_FM_SYNC_TASK task = GetEntity<T_FM_SYNC_TASK>(filter.Keyword);
if (task != null)
{
task.UPDATE_SUCCES_TIME = DateTime.Now;//上次同步结束时间
task.SYNC_PARAM = "";//清空参数
}
UnifiedCommit(() =>
{
UpdateEntityNoCommit(task);
});
}
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -2148,6 +2295,8 @@ namespace APT.PP.WebApi.Controllers.Api.PP
else else
throw new Exception("【" + HttpContext.Request.Path + "】错误日志:[Message]" + ex.Message); throw new Exception("【" + HttpContext.Request.Path + "】错误日志:[Message]" + ex.Message);
} }
return true; return true;
}); });
} }

View File

@ -66,9 +66,13 @@ namespace APT.SC.WebApi.Controllers.Api.SE
{ {
throw new Exception("培训开始时间不能大于培训结束时间!"); throw new Exception("培训开始时间不能大于培训结束时间!");
} }
if (entity.DT_START_SIGN.HasValue && entity.TRAIN_END_TIME.HasValue && entity.DT_START_SIGN.Value >= entity.TRAIN_END_TIME.Value) //if (entity.DT_START_SIGN.HasValue && entity.TRAIN_END_TIME.HasValue && entity.DT_START_SIGN.Value >= entity.TRAIN_END_TIME.Value)
//{
// throw new Exception("签到开始时间不能大于培训结束时间!");
//}
if (entity.DT_START_SIGN.HasValue && entity.TRAIN_START_TIME.HasValue && entity.DT_START_SIGN.Value >= entity.TRAIN_START_TIME.Value)
{ {
throw new Exception("签到开始时间不能大于培训结束时间!"); throw new Exception("签到开始时间不能大于培训开始时间!");
} }
var Nav_TrainUserList = entity.Nav_TrainUserList.Where(t => t.USER_ID != Guid.Empty); var Nav_TrainUserList = entity.Nav_TrainUserList.Where(t => t.USER_ID != Guid.Empty);
var Nav_Files = entity.Nav_Files; var Nav_Files = entity.Nav_Files;