diff --git a/APT.BaseData.Services/Services/PF/PFApproveCallBackService.cs b/APT.BaseData.Services/Services/PF/PFApproveCallBackService.cs index 3e35c03..42a9983 100644 --- a/APT.BaseData.Services/Services/PF/PFApproveCallBackService.cs +++ b/APT.BaseData.Services/Services/PF/PFApproveCallBackService.cs @@ -11392,74 +11392,79 @@ namespace APT.BaseData.Services.DomainServices }); } else - { - var entity = this.GetEntity(modelApp != null ? modelApp.DATA_ID : entityInt.DATA_ID, "Nav_CheckType"); - entity.STATUS = PFStandardStatus.Sign; - var entityDetails = this.GetEntities(t => t.SECURITY_INSPECTION_NOTICE_ID == entity.ID, new BaseFilter(entity.ORG_ID), "Nav_CheckNoticeDetailUsers"); - List sendNotices = new List(); - List userIds = new List(); - List applyUserIds = new List(); + { + List sendNotices = new List(); + List userIds = new List(); + List applyUserIds = new List(); List detailUsers = new List(); - if (entityDetails != null && entityDetails.Any()) - { - foreach (var user in entityDetails) - { - if (user.Nav_CheckNoticeDetailUsers != null && user.Nav_CheckNoticeDetailUsers.Any()) - { - var tempIds = user.Nav_CheckNoticeDetailUsers.Where(t => t.USER_ID == entity.APPLY_USER_ID).Select(t => t.ID).ToList(); - if (tempIds != null && tempIds.Any()) - { - applyUserIds.AddRange(tempIds); - } - var ids = user.Nav_CheckNoticeDetailUsers.Where(m => m.USER_ID != null && m.USER_ID != entity.APPLY_USER_ID).Select(t => (Guid)t.USER_ID).Distinct().ToList(); - userIds.AddRange(ids); - } + var entity = this.GetEntity(modelApp != null ? modelApp.DATA_ID : entityInt.DATA_ID, "Nav_CheckType"); + entity.STATUS = PFStandardStatus.Approving; + if (DateTime.Now > entity.CHECK_TIME) + { } + else + { + var entityDetails = this.GetEntities(t => t.SECURITY_INSPECTION_NOTICE_ID == entity.ID, new BaseFilter(entity.ORG_ID), "Nav_CheckNoticeDetailUsers"); + if (entityDetails != null && entityDetails.Any()) + { + foreach (var user in entityDetails) + { + if (user.Nav_CheckNoticeDetailUsers != null && user.Nav_CheckNoticeDetailUsers.Any()) + { + var tempIds = user.Nav_CheckNoticeDetailUsers.Where(t => t.USER_ID == entity.APPLY_USER_ID).Select(t => t.ID).ToList(); + if (tempIds != null && tempIds.Any()) + { + applyUserIds.AddRange(tempIds); + } + var ids = user.Nav_CheckNoticeDetailUsers.Where(m => m.USER_ID != null && m.USER_ID != entity.APPLY_USER_ID).Select(t => (Guid)t.USER_ID).Distinct().ToList(); + userIds.AddRange(ids); + } + } + } + if (applyUserIds != null && applyUserIds.Any()) + { + detailUsers = this.GetEntities(t => applyUserIds.Contains(t.ID), new BaseFilter(entity.ORG_ID)).ToList(); + detailUsers.ForEach(t => + { + t.ISCHECK = true; + t.CHECKTIME = DateTime.Now; + }); + //存入一条已办 + T_FM_NOTIFICATION_TASK notice = new T_FM_NOTIFICATION_TASK(); + notice.CODE = DateTime.Now.ToString("yyyyMMddHHmmss"); + notice.NOTICE_TITLE = entity.DEPARTMENT_TYPE.GetDescription() + "安全检查通知" + DateTime.Now.Year + DateTime.Now.Month.PadLeft(2, '0') + DateTime.Now.Day.PadLeft(2, '0') + entity.Nav_CheckType?.NAME + "-确认"; + notice.SOURCE_DATA_ID = entity.ID; + notice.ORG_ID = entity.ORG_ID; + notice.ID = Guid.NewGuid(); + notice.TASK_STARTDT = DateTime.Now; + notice.TASK_ENDDT = DateTime.Now.AddHours(24); + notice.NOTICE_TYPE = (int)FMNoticeTypeEnum.消息; + notice.NOTICE_STATUS = (int)FMNoticeStatusEnum.正常已办; + notice.USER_ID = (Guid)entity.APPLY_USER_ID; + notice.USER_NAME = entity.Nav_ApplyUser?.NAME; + notice.SOURCE_FORMCODE = "SK006_SHOWPRINT"; + sendNotices.Add(notice); + } + userIds = userIds.Distinct().ToList(); + if (userIds != null && userIds.Any()) + { + entity.STATUS = PFStandardStatus.Sign; + var UserNames = new List(); + var users = this.GetEntities(t => t.ENABLE_STATUS == (int)FMEnableStatusEnum.启用 && userIds.Contains(t.ID), new BaseFilter(entity.ORG_ID)).ToList(); + foreach (var u in userIds) + { + var current = users.FirstOrDefault(t => t.ID == u); + UserNames.Add(current?.NAME); + } + var date = DateTime.Now.Year + DateTime.Now.Month.PadLeft(2, '0') + DateTime.Now.Day.PadLeft(2, '0'); + //发消息 + sendNotices.AddRange(NotificationTaskService.InsertUserNoticeTaskModels(entity.DEPARTMENT_TYPE.GetDescription() + "安全检查通知" + date + entity.Nav_CheckType?.NAME + "-确认", entity.ID, entity.ORG_ID, userIds, UserNames, DateTime.Now, + DateTime.Now.AddHours(24), (int)FMNoticeTypeEnum.消息, "SK006_SHOWPRINT")); + } + else + { + entity.STATUS = PFStandardStatus.Archived; } } - if (applyUserIds != null && applyUserIds.Any()) - { - detailUsers = this.GetEntities(t => applyUserIds.Contains(t.ID), new BaseFilter(entity.ORG_ID)).ToList(); - detailUsers.ForEach(t => - { - t.ISCHECK = true; - t.CHECKTIME = DateTime.Now; - }); - //存入一条已办 - T_FM_NOTIFICATION_TASK notice = new T_FM_NOTIFICATION_TASK(); - notice.CODE = DateTime.Now.ToString("yyyyMMddHHmmss"); - notice.NOTICE_TITLE = entity.DEPARTMENT_TYPE.GetDescription() + "安全检查通知" + DateTime.Now.Year + DateTime.Now.Month.PadLeft(2, '0') + DateTime.Now.Day.PadLeft(2, '0') + entity.Nav_CheckType?.NAME + "-确认"; - notice.SOURCE_DATA_ID = entity.ID; - notice.ORG_ID = entity.ORG_ID; - notice.ID = Guid.NewGuid(); - notice.TASK_STARTDT = DateTime.Now; - notice.TASK_ENDDT = DateTime.Now.AddHours(24); - notice.NOTICE_TYPE = (int)FMNoticeTypeEnum.消息; - notice.NOTICE_STATUS = (int)FMNoticeStatusEnum.正常已办; - notice.USER_ID = (Guid)entity.APPLY_USER_ID; - notice.USER_NAME = entity.Nav_ApplyUser?.NAME; - notice.SOURCE_FORMCODE = "SK006_SHOWPRINT"; - sendNotices.Add(notice); - } - userIds = userIds.Distinct().ToList(); - if (userIds != null && userIds.Any()) - { - entity.STATUS = PFStandardStatus.Sign; - var UserNames = new List(); - var users = this.GetEntities(t => t.ENABLE_STATUS == (int)FMEnableStatusEnum.启用 && userIds.Contains(t.ID), new BaseFilter(entity.ORG_ID)).ToList(); - foreach (var u in userIds) - { - var current = users.FirstOrDefault(t => t.ID == u); - UserNames.Add(current?.NAME); - } - var date = DateTime.Now.Year + DateTime.Now.Month.PadLeft(2, '0') + DateTime.Now.Day.PadLeft(2, '0'); - //发消息 - sendNotices.AddRange(NotificationTaskService.InsertUserNoticeTaskModels(entity.DEPARTMENT_TYPE.GetDescription() + "安全检查通知" + date + entity.Nav_CheckType?.NAME + "-确认", entity.ID, entity.ORG_ID, userIds, UserNames, DateTime.Now, - DateTime.Now.AddHours(24), (int)FMNoticeTypeEnum.消息, "SK006_SHOWPRINT")); - } - else - { - entity.STATUS = PFStandardStatus.Archived; - } UnifiedCommit(() => { if (modelApp != null) diff --git a/APT.MicroApi/APT.PP.WebApi/Controllers/Api/SKController.cs b/APT.MicroApi/APT.PP.WebApi/Controllers/Api/SKController.cs index 08cdaea..a619cb7 100644 --- a/APT.MicroApi/APT.PP.WebApi/Controllers/Api/SKController.cs +++ b/APT.MicroApi/APT.PP.WebApi/Controllers/Api/SKController.cs @@ -790,7 +790,7 @@ namespace APT.PP.WebApi.Controllers.Api var day = dtNow.Day; var week = dtNow.DayOfWeek; filter.IgnoreDataRule = true; - //查记录表,检查时间第二天12点自动转为已办 + //查记录表,检查时间第二天自动转为已办 List tasks = new List(); List noticeTasks = new List(); List summarys = new List(); @@ -810,11 +810,12 @@ namespace APT.PP.WebApi.Controllers.Api // "Nav_CheckRecordDetails.Nav_CheckRecordDetailUsers.ISMAINCHECK","Nav_CheckRecordDetails.Nav_CheckRecordDetailUsers.CHECKTIME","Nav_CheckRecordDetails.Nav_CheckRecordDetailUsers.ISCHECK", // "Nav_CheckRecordDetails.Nav_CheckRecordDetailUsers.SECURITY_INSPECTION_RECORD_DETAIL_ID","Nav_CheckRecordDetails.Nav_CheckRecordDetailBasics.SECURITY_INSPECTION_RECORD_DETAIL_ID", // "Nav_CheckRecordDetails.Nav_CheckRecordDetailBasics.LAW_ID" }; //指定字段,包括导航属性 - var notices = GetEntities(i => i.CHECK_TIME.Value.AddDays(1).Date == dtNow.Date && i.CHECK_TIME.Value.AddDays(1).Hour == dtNow.Hour && i.Nav_CheckType != null && !i.Nav_CheckType.NAME.Contains("岗位排查"), baseFilter); + var notices = GetEntities(i => i.CHECK_TIME.Value.AddDays(1).Date == dtNow.Date && i.CHECK_TIME.Value.AddDays(1).Hour == dtNow.Hour && i.Nav_CheckType != null && !i.Nav_CheckType.NAME.Contains("岗位排查") && (i.STATUS == PFStandardStatus.Archived || i.STATUS == PFStandardStatus.Sign), baseFilter); var noticeIds = notices.Select(t => t.ID).ToList(); var sumNoticeIds = GetEntities(t => t.SECURITY_INSPECTION_NOTICE_ID != null && noticeIds.Contains((Guid)t.SECURITY_INSPECTION_NOTICE_ID), baseFilter).Select(m => m.SECURITY_INSPECTION_NOTICE_ID).Distinct().ToList(); var needDealIds = noticeIds.Where(t => !sumNoticeIds.Contains(t)).ToList(); var records = GetEntities(i => i.SECURITY_INSPECTION_NOTICE_ID != null && needDealIds.Contains((Guid)i.SECURITY_INSPECTION_NOTICE_ID), baseFilter).ToList(); + var recordNoticeIds = records.Select(t => t.SECURITY_INSPECTION_NOTICE_ID).Distinct().ToList(); if (records != null && records.Any()) { var recordIds = records.Select(i => i.ID).ToList(); @@ -832,7 +833,7 @@ namespace APT.PP.WebApi.Controllers.Api var recordDetailFiles = this.GetEntities(t => recordDetailIds.Contains(t.SECURITY_INSPECTION_RECORD_DETAIL_ID), baseFilter); var recordDetailBasics = this.GetEntities(t => recordDetailIds.Contains(t.SECURITY_INSPECTION_RECORD_DETAIL_ID), baseFilter); //触发汇总表 - foreach (var id in needDealIds) + foreach (var id in recordNoticeIds) { var noticeFirst = notices.FirstOrDefault(t => t.ID == id); var user = users.FirstOrDefault(t => t.ID == noticeFirst?.APPLY_USER_ID);