培训记录添加是否 触发培训记录待办
跑批修改 (如果提前签到 先生成培训记录单 等培训开始时间触发) 对于没触发培训记录编辑的待办 添加培训记录 未处理的待办
This commit is contained in:
parent
495843846d
commit
d11dae692e
139849
APT.Data.Migrations/Migrations/20260716065048_wyw2026071601.Designer.cs
generated
Normal file
139849
APT.Data.Migrations/Migrations/20260716065048_wyw2026071601.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -76378,6 +76378,9 @@ namespace APT.Data.Migrations.Migrations
|
||||
b.Property<bool>("IS_DELETED")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<bool>("IS_SENDNOTICE")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<Guid?>("MODIFIER_ID")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
|
||||
@ -105,5 +105,10 @@ namespace APT.MS.Domain.Entities.SE
|
||||
[Description("审阅时间")]
|
||||
public DateTime? DT_APPROVE { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否触发记录通知
|
||||
/// </summary>
|
||||
[Description("是否触发记录通知")]
|
||||
public bool IS_SENDNOTICE { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -1908,6 +1908,7 @@ namespace APT.PP.WebApi.Controllers.Api.PP
|
||||
{
|
||||
try
|
||||
{
|
||||
bool isClear = false;
|
||||
var dt = DateTime.Now;
|
||||
var Parameter1 = 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();
|
||||
#region 培训记录
|
||||
|
||||
if (notifys != null || notifys.Any())
|
||||
if (notifys != null && notifys.Any())
|
||||
{
|
||||
List<T_FM_NOTIFICATION_TASK> SendNotices = null;
|
||||
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,
|
||||
NOTIFY_ID = notify.ID,
|
||||
STATUS = SETrainRecordStatus.草稿,
|
||||
CREATER_ID = notify.RECORD_USER_ID,
|
||||
};
|
||||
foreach (var user in notify.Nav_TrainUserList)
|
||||
{
|
||||
@ -1997,6 +1999,7 @@ namespace APT.PP.WebApi.Controllers.Api.PP
|
||||
{
|
||||
notify.STATUS = STATUS;
|
||||
}
|
||||
notify.ISSENDNOTICE = true;
|
||||
notify.Nav_LaunchUser = null;
|
||||
notify.Nav_RecordUser = null;
|
||||
};
|
||||
@ -2008,17 +2011,7 @@ namespace APT.PP.WebApi.Controllers.Api.PP
|
||||
notify1.NOTICE_STATUS = 4;//待办 处理
|
||||
}
|
||||
SendNotices = NotificationTaskService.InsertUserNoticeTaskModels(allSendTitles, allSendDataIds, orgId, allSendUserIds, allSendUserNames, DateTime.Now, DateTime.Now.AddDays(10), (int)FMNoticeTypeEnum.消息, "SE018");
|
||||
|
||||
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 = "";//清空参数
|
||||
}
|
||||
}
|
||||
isClear = true;
|
||||
|
||||
UnifiedCommit(() =>
|
||||
{
|
||||
@ -2032,13 +2025,50 @@ namespace APT.PP.WebApi.Controllers.Api.PP
|
||||
BantchAddEntityNoCommit(joinUsers);
|
||||
if (files.Any())
|
||||
BantchAddEntityNoCommit(files);
|
||||
if (task != null)
|
||||
UpdateEntityNoCommit(task);
|
||||
if (finishNotifys1 != null && finishNotifys1.Any())
|
||||
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
|
||||
|
||||
#region 培训记录签到
|
||||
@ -2048,8 +2078,109 @@ namespace APT.PP.WebApi.Controllers.Api.PP
|
||||
if (notifys != null && notifys.Count() > 0)
|
||||
{
|
||||
var listNotifyID = notifys.Select(e => e.ID).Distinct();
|
||||
var iListR = GetEntities<T_SE_TRAIN_RECORD>(e => listNotifyID.Contains(e.NOTIFY_ID), null, null);
|
||||
var listRecordID = iListR.Select(e => e.ID);
|
||||
var iListR = GetEntities<T_SE_TRAIN_RECORD>(e => listNotifyID.Contains(e.NOTIFY_ID), null, null).ToList();
|
||||
#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");
|
||||
IEnumerable<T_SE_TRAIN_RECORD_USER> iListTemp = 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.STATUS = SETrainRecordStatus.签到中;
|
||||
|
||||
isClear = true;
|
||||
UnifiedCommit(() =>
|
||||
{
|
||||
UpdateEntityNoCommit(modelTr);
|
||||
@ -2136,10 +2267,26 @@ namespace APT.PP.WebApi.Controllers.Api.PP
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
#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)
|
||||
{
|
||||
@ -2148,6 +2295,8 @@ namespace APT.PP.WebApi.Controllers.Api.PP
|
||||
else
|
||||
throw new Exception("【" + HttpContext.Request.Path + "】错误日志:[Message]" + ex.Message);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
@ -66,9 +66,13 @@ namespace APT.SC.WebApi.Controllers.Api.SE
|
||||
{
|
||||
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_Files = entity.Nav_Files;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user