diff --git a/APT.MS.Domain/Entities/SC/SE/51T_SE_TRAIN_NOTIFY.cs b/APT.MS.Domain/Entities/SC/SE/51T_SE_TRAIN_NOTIFY.cs index cac2e19..c80b0f2 100644 --- a/APT.MS.Domain/Entities/SC/SE/51T_SE_TRAIN_NOTIFY.cs +++ b/APT.MS.Domain/Entities/SC/SE/51T_SE_TRAIN_NOTIFY.cs @@ -299,7 +299,7 @@ namespace APT.MS.Domain.Entities.SE public DateTime? DT_START_SIGN { get; set; } /// - /// 是否触发培训通知 + /// 是否触发培训通知反馈 /// [Description("是否触发培训通知")] public bool ISSENDNOTICE { get; set; } diff --git a/APT.MicroApi/APT.PP.WebApi/Controllers/Api/SEController.cs b/APT.MicroApi/APT.PP.WebApi/Controllers/Api/SEController.cs index 6aa3d04..25d4419 100644 --- a/APT.MicroApi/APT.PP.WebApi/Controllers/Api/SEController.cs +++ b/APT.MicroApi/APT.PP.WebApi/Controllers/Api/SEController.cs @@ -1930,8 +1930,11 @@ namespace APT.PP.WebApi.Controllers.Api.PP var notifys = GetEntities(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() && notifys.Count() > 0) { + var listNoticeID = notifys.Select(e => e.ID); + var listRecordCheck = GetEntities(e => listNoticeID.Contains(e.ID), null, null); + List SendNotices = null; List TrainRecords = new List(); List joinUsers = new List(); @@ -1949,45 +1952,53 @@ namespace APT.PP.WebApi.Controllers.Api.PP try { notify.STATUS = SETrainNotifyStatus.归档; - var record = new T_SE_TRAIN_RECORD + T_SE_TRAIN_RECORD record = null; + if (listRecordCheck != null && listRecordCheck.Count() > 0) { - 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); + record = listRecordCheck.FirstOrDefault(e => e.NOTIFY_ID == notify.ID); } - foreach (var file in notify.Nav_Files) + if (record == null) { - var recordFile = new T_SE_TRAIN_RECORD_FILE + record = new T_SE_TRAIN_RECORD { ID = Guid.NewGuid(), ORG_ID = orgId, - RECORD_ID = record.ID, - IMG_FILE_ID = file.IMG_FILE_ID + NOTIFY_ID = notify.ID, + STATUS = SETrainRecordStatus.草稿, + CREATER_ID = notify.RECORD_USER_ID, }; - files.Add(recordFile); + 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); allSendTitles.Add("培训记录-" + notify.NAME); @@ -2004,7 +2015,7 @@ namespace APT.PP.WebApi.Controllers.Api.PP notify.Nav_RecordUser = null; }; var notifyids = notifys.Select(t => t.ID).ToList(); - var finishNotifys1 = GetEntities(t => notifyids.Contains((Guid)t.SOURCE_DATA_ID) && t.NOTICE_STATUS == 0, new BaseFilter(orgId)); + var finishNotifys1 = GetEntities(t => notifyids.Contains((Guid)t.SOURCE_DATA_ID) && t.NOTICE_STATUS == 0 && t.NOTICE_TITLE.EndsWith("-确认"), new BaseFilter(orgId)); foreach (var notify1 in finishNotifys1) { @@ -2018,7 +2029,7 @@ namespace APT.PP.WebApi.Controllers.Api.PP if (notifys.Any()) BantchUpdateEntityNoCommit(notifys, "STATUS"); if (TrainRecords.Any()) - BantchAddEntityNoCommit(TrainRecords); + BantchSaveEntityNoCommit(TrainRecords); if (SendNotices.Any()) BantchAddEntityNoCommit(SendNotices); if (joinUsers.Any()) @@ -2030,44 +2041,42 @@ namespace APT.PP.WebApi.Controllers.Api.PP }); } - #region 先签到 再触发培训通知给记录人 + //#region 先签到 再触发培训通知给记录人 + //var listSend = GetEntities(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 SendNotices = null; + // var allSendUserIds = new List(); + // var allSendUserNames = new List(); + // var allSendTitles = new List(); + // var allSendDataIds = new List(); + // foreach (var item in listSend) + // { + // if (item.Nav_Notify.RECORD_USER_ID.HasValue) + // { + // item.IS_SENDNOTICE = true; - var listSend = GetEntities(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 SendNotices = null; - var allSendUserIds = new List(); - var allSendUserNames = new List(); - var allSendTitles = new List(); - var allSendDataIds = new List(); - 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); + // } + // } - 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 + // 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 @@ -2191,6 +2200,8 @@ namespace APT.PP.WebApi.Controllers.Api.PP List allSendUserNames = null; List sendNotice = null; List listUserDoAuto = null; + + List listNoticeIDEnd = new List(); foreach (var item in iListR) { try @@ -2255,6 +2266,7 @@ namespace APT.PP.WebApi.Controllers.Api.PP item.DT_SSEND_SIGN = DateTime.Now; item.STATUS = SETrainRecordStatus.签到中; isClear = true; + listNoticeIDEnd.Add(item.NOTIFY_ID); UnifiedCommit(() => { UpdateEntityNoCommit(modelTr); @@ -2270,6 +2282,20 @@ namespace APT.PP.WebApi.Controllers.Api.PP #endregion + if (listNoticeIDEnd != null && listNoticeIDEnd.Count() > 0) + { + //发送签到 待办去除 + var finishNotifysSignEnd = GetEntities(t => listNoticeIDEnd.Contains((Guid)t.SOURCE_DATA_ID) && t.NOTICE_STATUS == 0 && t.NOTICE_TITLE.EndsWith("-确认"), new BaseFilter(orgId)); + foreach (var notify1 in finishNotifysSignEnd) + { + notify1.NOTICE_STATUS = 4;//待办 处理 + } + UnifiedCommit(() => + { + if (finishNotifysSignEnd != null && finishNotifysSignEnd.Any()) + BantchSaveEntityNoCommit(finishNotifysSignEnd); + }); + } } #endregion diff --git a/APT.MicroApi/APT.SC.WebApi/Controllers/Api/SEController/6SETrainRecordController.cs b/APT.MicroApi/APT.SC.WebApi/Controllers/Api/SEController/6SETrainRecordController.cs index 55d62ff..322b42d 100644 --- a/APT.MicroApi/APT.SC.WebApi/Controllers/Api/SEController/6SETrainRecordController.cs +++ b/APT.MicroApi/APT.SC.WebApi/Controllers/Api/SEController/6SETrainRecordController.cs @@ -72,7 +72,28 @@ namespace APT.SC.WebApi.Controllers.Api.SE var taskCheck = GetEntity(e => e.SOURCE_DATA_ID.HasValue && e.SOURCE_DATA_ID.Value == ru.RECORD_ID && e.USER_ID == ru.USER_ID && e.SOURCE_FORMCODE == "SE017_SHOWPRINT"); if (taskCheck != null) { - throw new Exception("该用户已有此签到单,请勿重复触发签到通知!"); + if (taskCheck.NOTICE_STATUS == 1) + { + throw new Exception("该用户已操签到过,请勿重复触发签到通知!"); + } + else if (taskCheck.NOTICE_STATUS == 0) + { + return true; + } + else if (taskCheck.NOTICE_STATUS == 4) + { + taskCheck.NOTICE_STATUS = 0; + ru.IS_RESEND = true; + UnifiedCommit(() => + { + UpdateEntityNoCommit(taskCheck); + UpdateEntityNoCommit(ru); + }); + } + else + { + throw new Exception("该用户已有此签到单,请勿重复触发签到通知!"); + } } DateTime dtEnd = ru.Nav_Record.Nav_Notify.TRAIN_END_TIME.HasValue ? ru.Nav_Record.Nav_Notify.TRAIN_END_TIME.Value : DateTime.Now.AddHours(12); T_FM_NOTIFICATION_TASK notice = NotificationTaskService.InsertUserNoticeTaskModel("培训记录签到-" + ru.Nav_Record.Nav_Notify.NAME, ru.RECORD_ID, ru.ORG_ID, ru.USER_ID, ru.Nav_User.NAME, DateTime.Now, dtEnd, 1, "SE017_SHOWPRINT");