public async Task CreateProjectBaseWorkSpaceNotice(NoticePublishInputForWorkSpaceInput input) { var projectModel = await _projectBaseRepository.GetAsync(input.ProjectId); string userIdStr = ""; switch (input.UserType) { case 0: var projectMembers = _projectAuditMemberRepository.GetAll().Where(r => r.ProjectBaseId == projectModel.Id); var userIds = await projectMembers.Select(r => r.UserId).Distinct().ToListAsync(); if (projectModel.CreatorUserId.HasValue) { if (!userIds.Contains(projectModel.CreatorUserId.Value)) { userIds.Add(projectModel.CreatorUserId.Value); } } Debug.Assert(AbpSession.UserId != null, ""); var currentUserId = AbpSession.UserId.Value; if (!userIds.Contains(currentUserId)) { userIds.Add(currentUserId); } userIdStr = string.Join(",", userIds); break; case 1: var task = _workFlowTaskRepository.GetAll().Where(x => x.InstanceID == projectModel.Id.ToString()).OrderByDescending(x => x.Sort).FirstOrDefault(); if (task != null) { var taskUserIds = await _workFlowTaskRepository.GetAll().Where(x => x.InstanceID == projectModel.Id.ToString() && x.Sort < task.Sort).Select(r => r.ReceiveID).Distinct().ToListAsync(); userIdStr = string.Join(",", taskUserIds); } break; case 3: var taskAllUserIds = await _workFlowTaskRepository.GetAll().Where(x => x.InstanceID == projectModel.Id.ToString()).Select(r => r.ReceiveID).Distinct().ToListAsync(); userIdStr = string.Join(",", taskAllUserIds); break; case 2: userIdStr = input.NoticeUserIds; break; } if (!string.IsNullOrEmpty(userIdStr)) { await _noticeManager.CreateOrUpdateNoticeAsync(new ZCYX.FRMSCore.Application.NoticePublishInput() { Title = input.Title, Content = input.Content, NoticeUserIds = userIdStr, NoticeType = 1 }); } }
public async Task Send(SupplySendDto input) { var user = _userRepository.GetAll().FirstOrDefault(ite => ite.Id == input.UserId); if (user == null) { throw new UserFriendlyException((int)ErrorCode.DataAccessErr, "未找到要发放的对象。"); } var menuInit = await _userMenuInitRepository.FirstOrDefaultAsync(r => r.MenuId == 28 && r.UserId == input.UserId); if (menuInit == null || menuInit.Status != -1) { throw new UserFriendlyException((int)ErrorCode.DataAccessErr, "当前用户还未完成用品初始化,不能发放用品。"); } var supplys = _supplyRepository.GetAll().Where(ite => input.SupplyId.Contains(ite.Id)); foreach (var s in supplys) { s.Status = (int)SupplyStatus.被领用; var has = _userSupplyRepository.FirstOrDefault(ite => ite.SupplyId == s.Id && ite.Status != (int)UserSupplyStatus.已退还 && ite.Status == (int)UserSupplyStatus.已报废); if (has != null) { throw new UserFriendlyException((int)ErrorCode.DataAccessErr, "当前用品正在被别人使用,发放失败。"); } var us = new UserSupply() { Status = (int)UserSupplyStatus.使用中, StartTime = DateTime.Now, SupplyId = s.Id, UserId = input.UserId, EndTime = s.ExpiryDate }; s.UserId = "u_" + input.UserId; await _userSupplyRepository.InsertAsync(us); await _supplyRepository.UpdateAsync(s); } await _noticeManager.CreateOrUpdateNoticeAsync(new ZCYX.FRMSCore.Application.NoticePublishInput() { Title = "用品发放", Content = "行政人员为你发放了新的个人用品,请注意查收", NoticeUserIds = input.UserId.ToString(), NoticeType = 1 }); }