/// <summary> /// 获取员工档案信息 /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task <PagedResultDto <EmployeeDocmentListDto> > GetList(EmployeeSearchInput input) { var query = _employeeRepository.GetAll(); if (string.IsNullOrWhiteSpace(input.SearchKey) == false) { query = query.Where(ite => ite.Name.Contains(input.SearchKey) || ite.Phone.Contains(input.SearchKey) || ite.Code.Contains(input.SearchKey)); } if (input.OrgId.HasValue) { var orgu = _userOrganizationUnitRepository.GetAll().Where(ite => ite.OrganizationUnitId == input.OrgId.Value).Select(ite => ite.UserId).ToList(); query = query.Where(ite => orgu.Contains(ite.UserId.Value)); } if (input.IsTemp.HasValue && input.IsTemp.Value) { query = query.Where(ite => ite.IsTemp == true); } var totalCount = query.Count(); var ret = (await query.OrderByDescending(r => r.CreationTime).PageBy(input).ToListAsync()).MapTo <List <EmployeeDocmentListDto> >(); foreach (var r in ret) { if (r.UserId.HasValue) { var org = await(from a in _userOrganizationUnitRepository.GetAll() join b in _organizationUnitRepository.GetAll() on a.OrganizationUnitId equals b.Id where a.UserId == r.UserId.Value select new SimpleOrganizationDto() { Code = b.Code, Id = a.OrganizationUnitId, IsMain = a.IsMain, Title = b.DisplayName }).ToListAsync(); var post = from a in _postsRepository.GetAll() join b in _userPostsRepository.GetAll() on a.Id equals b.PostId join c in _organizationUnitPostsRepository.GetAll() on b.OrgPostId equals c.Id join d in _organizationUnitRepository.GetAll() on c.OrganizationUnitId equals d.Id where b.UserId == r.UserId.Value select new UserPostDto { Id = b.Id, OrgPostId = c.Id, PostId = a.Id, PostName = a.Name, OrgName = d.DisplayName }; r.Organization = org.ToList(); r.Posts = post.ToList(); } //r.AuditFileList = _abpFileRelationAppService.GetList(new GetAbpFilesInput() { BusinessId = r.Id.ToString(), BusinessType = (int)AbpFileBusinessType.面试评审表 }); //r.ContactFileList = _abpFileRelationAppService.GetList(new GetAbpFilesInput() { BusinessId = r.Id.ToString(), BusinessType = (int)AbpFileBusinessType.员工合同 }); //r.EduFileList = _abpFileRelationAppService.GetList(new GetAbpFilesInput() { BusinessId = r.Id.ToString(), BusinessType = (int)AbpFileBusinessType.员工毕业证书 }); //r.FaceFileList = _abpFileRelationAppService.GetList(new GetAbpFilesInput() { BusinessId = r.Id.ToString(), BusinessType = (int)AbpFileBusinessType.员工面试题 }); //r.InfoFileList = _abpFileRelationAppService.GetList(new GetAbpFilesInput() { BusinessId = r.Id.ToString(), BusinessType = (int)AbpFileBusinessType.员工信息登记表 }); //r.SalaryFileList = _abpFileRelationAppService.GetList(new GetAbpFilesInput() { BusinessId = r.Id.ToString(), BusinessType = (int)AbpFileBusinessType.员工薪水核定表 }); } return(new PagedResultDto <EmployeeDocmentListDto>(totalCount, ret)); }
public async Task <IActionResult> GetEmployeeSearch(EmployeeSearchInput input) { if (TempData.Peek("userName") == null) { return(UserNotAllowedAccess(isUserLoggedIn: false)); } if (TempData.Peek("userRole").ToString() == "Employee") { return(UserNotAllowedAccess(isUserLoggedIn: true)); } //return the model state if the request is invalid if (!ModelState.IsValid) { List <string> errors = ModelState.Values.SelectMany(p => p.Errors.Select(x => x.ErrorMessage)).ToList(); TempData.Add("EmployeeSearchInvalid", errors); return(RedirectTo("ProjectManager", "EmployeeSearch")); } var databaseInput = new EmployeeSearchDatabaseInput() { SearchedEmployeeUserName = input.SearchedEmployee }; //define the output outside of the try catch block EmployeeSearchOutput employeeSearchResult; try { //this is just a stub for now employeeSearchResult = await _IProjectManagerDomain.GetEmployeeSearch(databaseInput); employeeSearchResult.ChartData = employeeSearchResult.getCapacityForChart(); if (employeeSearchResult.IsOverCapacity) { TempData.Add("IsOverCapacity", "Warning: Thie employee is over capacity."); } } catch (Exception) { TempData.Add("NoEmployeeFound", $"The User Name you entered, {input.SearchedEmployee}, was either incorrect, does not exist in the system, or has no associated data in the system. Please verify the User Name is correct and and try again."); return(RedirectTo("ProjectManager", "EmployeeSearch")); } //return the View and pass in the Model return(View(employeeSearchResult)); }
public ActionResult EmployeeSearch(EmployeeSearchInput employeeSearchInput) { try { EmployeeService employeeService = new EmployeeService(); List <EmployeeSearchOutput> employees = employeeService.searchEmployees(employeeSearchInput); TempData["employees"] = employees; TempData["employeeSearchInput"] = employeeSearchInput; return(RedirectToAction("Index")); }catch (Exception e) { TempData["ViewData"] = ViewData; TempData["employeeSearchInput"] = employeeSearchInput; return(RedirectToAction("Index")); } }
/// <summary> /// 人事填报工资条-获取人员列表 /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task <EmployeeSalaryDto> GetAllEmployee(EmployeeSearchInput input) { var model = new EmployeeSalaryDto(); if (input.Year.HasValue == false) { input.Year = DateTime.Now.Year; } if (input.Month.HasValue == false) { input.Month = DateTime.Now.Month - 1; var set = _setting.FirstOrDefault(ite => ite.Name == "HR.Salary.Setting"); if (set == null) { throw new UserFriendlyException((int)ErrorCode.CodeValErr, "请先设置工资发放日期。"); } var setting = Newtonsoft.Json.JsonConvert.DeserializeObject <SalarySettingInput>(set.Value); var date = new DateTime(DateTime.Now.Year, DateTime.Now.Month, setting.Day); if (DateTime.Now.Day <= date.Day) { input.Month = input.Month - 2; } } var query = _employeeRepository.GetAll(); if (string.IsNullOrWhiteSpace(input.SearchKey) == false) { query = query.Where(ite => ite.Name.Contains(input.SearchKey) || ite.Phone.Contains(input.SearchKey) || ite.Code.Contains(input.SearchKey)); } if (input.OrgId.HasValue) { var orgu = _userOrganizationUnitRepository.GetAll().Where(ite => ite.OrganizationUnitId == input.OrgId.Value).Select(ite => ite.UserId).ToList(); query = query.Where(ite => orgu.Contains(ite.UserId.Value)); } if (input.IsTemp.HasValue && input.IsTemp.Value) { query = query.Where(ite => ite.IsTemp == true); } var totalCount = query.Count(); var ret = query.OrderByDescending(r => r.LastModificationTime).PageBy(input).Select(ite => new EmployeeSalaryBillDto() { Name = ite.Name, EmployeeId = ite.Id, Month = input.Month.Value, Year = input.Year.Value, UserId = ite.UserId }).ToList(); foreach (var r in ret) { var s = _employeeSalaryBillRepository.FirstOrDefault(ite => ite.Year == DateTime.Now.Year && ite.Month == input.Month.Value && ite.EmployeeId == r.EmployeeId); if (s != null) { r.AccumulationFund = s.AccumulationFund; r.BaseSalary = s.BaseSalary; r.Deduction = s.Deduction; r.DeductionReason = s.DeductionReason; r.Id = s.Id; r.EndowmentInsurance = s.EndowmentInsurance; r.InjuryInsurance = s.InjuryInsurance; r.MaternityInsurance = s.MaternityInsurance; r.MedicalInsurance = s.MedicalInsurance; r.Month = s.Month; r.MonthBonus = s.MonthBonus; r.PreSalary = s.PreSalary; r.QuarterBonus = s.QuarterBonus; r.Salary = s.Salary; r.Tax = s.Tax; r.UnworkInsurance = s.UnworkInsurance; r.WorkBonus = s.WorkBonus; r.WorkSalary = s.WorkSalary; r.Year = s.Year; r.YearBonus = s.YearBonus; } if (r.UserId.HasValue) { var org = await(from a in _userOrganizationUnitRepository.GetAll() join b in _organizationUnitRepository.GetAll() on a.OrganizationUnitId equals b.Id where a.UserId == r.UserId.Value select new SimpleOrganizationDto() { Code = b.Code, Id = a.OrganizationUnitId, IsMain = a.IsMain, Title = b.DisplayName }).ToListAsync(); var post = from a in _postsRepository.GetAll() join b in _userPostsRepository.GetAll() on a.Id equals b.PostId join c in _organizationUnitPostsRepository.GetAll() on b.OrgPostId equals c.Id join d in _organizationUnitRepository.GetAll() on c.OrganizationUnitId equals d.Id where b.UserId == r.UserId.Value select new UserPostDto { Id = b.Id, OrgPostId = c.Id, PostId = a.Id, PostName = a.Name, OrgName = d.DisplayName }; r.Organization = org.ToList(); r.Posts = post.ToList(); } } model.Items = new PagedResultDto <EmployeeSalaryBillDto>(totalCount, ret); model.Year = input.Year.Value; model.Month = input.Month.Value; return(model); }
/// <summary> /// 人事部获取员工信息列表 /// </summary> public async Task <PagedResultDto <EmployeeListDto> > GetList(EmployeeSearchInput input) { var query = from a in _employeeRepository.GetAll() join b in _userRepository.GetAll() on a.UserId equals b.Id orderby a.CreationTime descending select new EmployeeListDto() { Alipay = a.Alipay, BankName = a.BankName, BankNo = a.BankNo, Birthday = a.Birthday, Code = a.Code, Email = b.EmailAddress, EnterTime = a.EnterTime, Id = a.Id, IsTemp = a.IsTemp, IsResign = !b.IsActive, Name = a.Name, Phone = b.PhoneNumber, Sex = a.Sex, UserId = a.UserId, WXchat = a.WXchat }; if (string.IsNullOrWhiteSpace(input.SearchKey) == false) { query = query.Where(ite => ite.Name.Contains(input.SearchKey) || ite.Phone.Contains(input.SearchKey) || ite.Code.Contains(input.SearchKey)); } if (input.OrgId.HasValue) { var orgu = _userOrganizationUnitRepository.GetAll().Where(ite => ite.OrganizationUnitId == input.OrgId.Value).Select(ite => ite.UserId).ToList(); query = query.Where(ite => orgu.Contains(ite.UserId.Value)); } if (input.IsTemp.HasValue && input.IsTemp.Value) { query = query.Where(ite => ite.IsTemp == true); } var totalCount = query.Count(); var ret = (await query.PageBy(input).ToListAsync()).MapTo <List <EmployeeListDto> >(); foreach (var r in ret) { if (r.UserId.HasValue) { var org = await(from a in _userOrganizationUnitRepository.GetAll() join b in _organizationUnitRepository.GetAll() on a.OrganizationUnitId equals b.Id where a.UserId == r.UserId.Value select new SimpleOrganizationDto() { Code = b.Code, Id = a.OrganizationUnitId, IsMain = a.IsMain, Title = b.DisplayName }).ToListAsync(); var post = from a in _postsRepository.GetAll() join b in _userPostsRepository.GetAll() on a.Id equals b.PostId join c in _organizationUnitPostsRepository.GetAll() on b.OrgPostId equals c.Id join d in _organizationUnitRepository.GetAll() on c.OrganizationUnitId equals d.Id where b.UserId == r.UserId.Value select new UserPostDto { Id = b.Id, OrgPostId = c.Id, PostId = a.Id, PostName = a.Name, OrgName = d.DisplayName }; r.Organization = org.ToList(); r.Posts = post.ToList(); } } return(new PagedResultDto <EmployeeListDto>(totalCount, ret)); }
// 名前またIDで社員検索 public List <EmployeeSearchOutput> searchEmployees(EmployeeSearchInput employeeSearchInput) { List <EmployeeSearchOutput> employees = new List <EmployeeSearchOutput>(); using (sys_employeeEntities db = new sys_employeeEntities()) { var query = (from e in db.employee join c in db.customer on e.customerId equals c.customerId into ecGroup from ec in ecGroup.DefaultIfEmpty() join a in db.authority on e.authorityId equals a.authorityId into ecaGroup from eca in ecaGroup.DefaultIfEmpty() select new { e.employeeId, e.name, e.kataName, e.telephoneNumber, e.mailAddress, customerName = ec.name, entryDate = e.entryDate, authority = eca.authorityName, eca.authorityId, e.leavingDate, e.customerId, e.description }); if (!string.IsNullOrWhiteSpace(employeeSearchInput.Id)) { query = query.Where(p => p.employeeId.Equals(employeeSearchInput.Id)); } if (!string.IsNullOrWhiteSpace(employeeSearchInput.Name)) { query = query.Where(p => p.name.Contains(employeeSearchInput.Name)); } switch (employeeSearchInput.WorkSituation) { case ConstantCommon.ZAISHA: query = query.Where(p => p.leavingDate == null); break; case ConstantCommon.TAISHA: query = query.Where(p => p.leavingDate != null); break; default: break; } if (!string.IsNullOrWhiteSpace(employeeSearchInput.CustomerId)) { query = query.Where(p => p.customerId.Equals(employeeSearchInput.CustomerId)); } if (!string.IsNullOrWhiteSpace(employeeSearchInput.AuthorityId)) { query = query.Where(p => p.authorityId.Equals(employeeSearchInput.AuthorityId)); } query.ToList(); foreach (var item in query) { EmployeeSearchOutput employee = new EmployeeSearchOutput(); employee.Id = item.employeeId; employee.Name = item.name; employee.KataName = item.kataName; employee.TelephoneNumber = item.telephoneNumber; employee.MailAddress = item.mailAddress; employee.CustomerName = item.customerName; employee.EntryDate = item.entryDate; employee.Authority = item.authority; employee.Description = item.description; employees.Add(employee); } } return(employees); }