IEnumerable <DictBindItem> GetSalaryLevelTypesList(bool appendPreix = false) { var lst = CommonDictService.GetDictItems(RuleCodeConstants.HR_EMP_SalaryLevelType, GetCurrentCredential().LegalGuid()); if (appendPreix) { lst.Insert(0, new DictBindItem { ID = string.Empty, Name = "请选择" }); } return(lst); }
public BusinessResult GetPersonalInfoData(BusinessContext context) { using (var dc = new HRDbContext()) { var tenantId = this.GetCurrentCredential().TenantGuid(); var empId = this.GetCurrentCredential().UserGuid(); var item = dc.HR_EMP_Employee.FirstOrDefault(t => t.TenantID == tenantId && !t.IsDeleted && t.EmployeeID == empId); //如果item.EmployeeID为空下面自然没值 var addresses = from a in dc.HR_EMP_Address where a.EmployeeID == item.EmployeeID && a.IsDeleted == false && a.AddressType == "0" select a; var area = string.Empty; HR_EMP_Address address = addresses.FirstOrDefault(); if (addresses.Any()) { if (!string.IsNullOrEmpty(address.Province)) { area += address.Province + "/"; } if (!string.IsNullOrEmpty(address.City)) { area += address.City + "/"; } if (!string.IsNullOrEmpty(address.District)) { area += address.District; } } var hujiaddresses = from a in dc.HR_EMP_Address where a.EmployeeID == item.EmployeeID && a.IsDeleted == false && a.AddressType == "1" select a; var hujiarea = string.Empty; HR_EMP_Address hujiaddress = hujiaddresses.FirstOrDefault(); if (hujiaddresses.Any()) { if (!string.IsNullOrEmpty(hujiaddress.Province)) { hujiarea += hujiaddress.Province + "/"; } if (!string.IsNullOrEmpty(hujiaddress.City)) { hujiarea += hujiaddress.City + "/"; } if (!string.IsNullOrEmpty(hujiaddress.District)) { hujiarea += hujiaddress.District; } } var banks = from b in dc.HR_EMP_BankCard where b.EmployeeID == item.EmployeeID && b.IsDeleted == false select b; HR_EMP_BankCard bank = banks.FirstOrDefault(); var positions = from c in dc.HR_EMP_PostInformation join d in dc.HR_ORG_Position on c.PositionID equals d.PositionID where c.EmployeeID == item.EmployeeID && c.IsDeleted == false && c.IsMain == true select d; HR_ORG_Position position = positions.FirstOrDefault(); if (position == null) { position = new HR_ORG_Position(); } var organizations = from c in dc.HR_EMP_PostInformation join d in dc.HR_ORG_Organization on c.OrganizationID equals d.OrganizationID where c.EmployeeID == item.EmployeeID && c.IsDeleted == false && c.IsMain == true select d; HR_ORG_Organization organization = organizations.FirstOrDefault(); if (organization == null) { organization = new HR_ORG_Organization(); } //var areaService = GetBizService<IBizFMService>(); //var areaName = areaService.MJService.GetAreaName(item.OfficeAreaID.GetValueOrDefault(Guid.Empty)); //var empSalaryLevelTypes = GetSalaryLevelList(item.LegalEntityID, true); var data = new { form = new { ResId = item.EmployeeID, empId = item.EmployeeID, item.EmployeeNumber, item.EmployeeNameCN, item.EmployeeNameEN, item.Gender, GenderName = CommonDictService.GetDictItemName(item.Gender), item.IDType, IDTypeName = CommonDictService.GetDictItemName(item.IDType), item.IDNumber, Birthday = item.Birthday?.ToString("yyyy-MM-dd") ?? String.Empty, item.MaritalStatus, MaritalStatusName = CommonDictService.GetDictItemName(item.MaritalStatus), FirstWorkedDate = item.FirstWorkedDate?.ToString("yyyy-MM-dd") ?? String.Empty, item.Nationality, NationalityName = CommonDictService.GetDictItemName(item.Nationality), item.OfficeAreaID, OFDetailAddress = "", item.HukouAddress, OnboardDate = item.OnboardDate?.ToString("yyyy-MM-dd") ?? String.Empty, item.EmployeeEMail, item.EmpStatus, EmpStatusName = CommonDictService.GetDictItemName(item.EmpStatus), item.EmployeeStatus, EmployeeStatusName = CommonDictService.GetDictItemName(item.EmployeeStatus), item.OrganizationID, item.OrganizationCode, item.OrganizationName, item.MainJobPositionID, item.CurrentJobLevelName, CurrentJobLevelValue = item.CurrentJobLevelValue?.ToString("0.00") ?? string.Empty, JobLevelText = item.CurrentJobLevelValue.HasValue ? (item.CurrentJobLevelName + "[" + item.CurrentJobLevelValue.Value.ToString("0.00") + "]") : string.Empty, item.ExtCode, item.TeleCode, item.PersonalEmail, item.Education, item.PersonalCellPhone, item.CPFAccount, item.EmergencyCellPhone, FileTransferInDate = item.FileTransferInDate?.ToString("yyyy-MM-dd") ?? String.Empty, FileTransferOutDate = item.FileTransferOutDate?.ToString("yyyy-MM-dd") ?? String.Empty, item.PoliticalStatus, PoliticalStatusName = CommonDictService.GetDictItemName(item.PoliticalStatus), item.TAG, item.Description, item.UserName, item.MLAccount, TrialBeginDate = item.TrialBeginDate?.ToString("yyyy-MM-dd") ?? String.Empty, TrialEndDate = item.TrialEndDate?.ToString("yyyy-MM-dd") ?? String.Empty, item.CreateTime, item.CreateUserID, item.UpdateTime, item.UpdateUserID, item.IsDeleted, item.LegalEntityID, item.TenantID, item.Ethnic, EthnicName = CommonDictService.GetDictItemName(item.Ethnic), item.ProfessionalTitle, ProfessionalTitleName = CommonDictService.GetDictItemName(item.ProfessionalTitle), item.SupplHousingAccount, TerminationDate = item.TerminationDate?.ToString("yyyy-MM-dd") ?? string.Empty, item.TerminationTypeName, item.PhotoAttachmentID, Country = address?.Country ?? string.Empty, Area = area, Address = address?.Address ?? string.Empty, ZipCode = address?.ZipCode ?? string.Empty, AddressPhone = address?.AddressPhone ?? string.Empty, HujiCountry = hujiaddress?.Country ?? string.Empty, HujiArea = hujiarea, HujiAddress = hujiaddress?.Address ?? string.Empty, HujiZipCode = hujiaddress?.ZipCode ?? string.Empty, HujiAddressPhone = hujiaddress?.AddressPhone ?? string.Empty, BankNumber = bank?.BankNumber ?? string.Empty, BankName = bank?.BankName ?? string.Empty, BanksName = CommonDictService.GetDictItemName(bank?.BankName ?? string.Empty), BankAddress = bank?.Address ?? string.Empty, AccountName = bank?.AccountName ?? string.Empty, BankCity = bank?.BankCity ?? string.Empty, MainJobPositionName = string.IsNullOrWhiteSpace(position.PositionName) ? "无" : position.PositionName + "(" + organization.OrganizationName + ")", PartyJoinInDate = item.PartyJoinInDate?.ToString("yyyy-MM-dd") ?? String.Empty, ADAccount = item.ADAccount } }; return(this.Success(data)); } }
public BusinessResult GetEmployeeByOrg(BusinessContext context) { var legalId = context.Credential.LegalGuid(); var tenantId = context.Credential.TenantGuid(); var name = context.Request["name"]; var userno = context.Request["userno"]; var orgId = context.Request.Contains("orgId") && !string.IsNullOrWhiteSpace(context.Request["orgId"]) ? Guid.Parse(context.Request["orgId"]) : Guid.Empty; var options = context.Request["options"]; var notLimitLegal = "1".Equals(context.Request["notLimitLegal"]); var includeOnBoarding = "1".Equals(context.Request["includeOnBoarding"]); var showChild = "true".Equals(context.Request["showChild"], StringComparison.CurrentCultureIgnoreCase); var showSideline = "true".Equals(context.Request["showSideline"], StringComparison.CurrentCultureIgnoreCase); using (var dbContect = new HRDbContext()) { #region "Query" var lstEmpStatus = new List <string>() { "0|HR_EMP_EmpStatus", "2|HR_EMP_EmpStatus", }; if (includeOnBoarding) { lstEmpStatus.Add("1|HR_EMP_EmpStatus"); } var lstChildOrgId = new HR_OrganizationHelper().GetChildOrgId(notLimitLegal ? Guid.Empty : legalId, orgId, true); var query = from emp in dbContect.HR_EMP_Employee join emppos in dbContect.HR_EMP_PostInformation on emp.EmployeeID equals emppos.EmployeeID join pos in dbContect.HR_ORG_Position on emppos.PositionID equals pos.PositionID //join posl in dbContect.HR_ORG_PositionLevels on pos.PositionLevelID equals posl.PositionLevelID into tmpPOSL //from posl in tmpPOSL.DefaultIfEmpty() join sl in dbContect.HR_EMP_SalaryLevel.Where(p => !p.IsDeleted) on emp.SalaryLevelID equals sl.SalaryLevelID into tmpSL from sl in tmpSL.DefaultIfEmpty() join area in dbContect.HR_EMP_OfficeArea on emp.OfficeAreaID equals area.AreaID into tmpArea from area in tmpArea.DefaultIfEmpty() join org in dbContect.HR_ORG_Organization on emppos.OrganizationID equals org.OrganizationID join leg in dbContect.HR_ORG_LegalEntity on org.LegalEntityID equals leg.LegalEntityID where !emp.IsDeleted && !emppos.IsDeleted && lstEmpStatus.Contains(emp.EmpStatus) && emp.TenantID == tenantId select new EmployeeInfo { EmployeeID = emp.EmployeeID, EmployeeNameCN = emp.EmployeeNameCN, EmployeeNameEN = emp.EmployeeNameEN, EmployeeNumber = emp.EmployeeNumber, TeleCode = emp.TeleCode, ExtCode = emp.ExtCode, OfficeAreaID = emp.OfficeAreaID, OfficeAreaName = area == null ? string.Empty : area.AreaName, IDType = emp.IDType, IDNumber = emp.IDNumber, PersonalTelNumber = emp.PersonalCellPhone, MainJobPostionID = emp.MainJobPositionID, MainJobPostionName = emp.MainJobPostionName, CurrentJobLevelID = Guid.Empty, CurrentJobLevelName = string.Empty, CurrentJobLevelValue = decimal.Zero, SalaryLevelID = sl != null ? sl.SalaryLevelID : (Guid?)null, SalaryLevelName = sl != null ? sl.SalaryLevelName : string.Empty, SalaryLevelType = sl != null ? sl.SalaryLevelType : string.Empty, FirstWorkedDate = emp.FirstWorkedDate, OnboardDate = emp.OnboardDate, PositionID = pos.PositionID, PositionCode = pos.PositionCode, PositionName = pos.PositionName, OrganizationID = org.OrganizationID, OrganizationCode = org.OrganizationCode, OrganizationName = org.OrganizationName, LegalEntityID = org.LegalEntityID, LegalEntityCode = leg.LegalEntityCode, LegalEntityName = leg.LegalEntityName, LegalEntityTelNumber = leg.TelNumber, IsMain = emppos.IsMain, CreateTime = emp.CreateTime, EmployeeStatus = emp.EmployeeStatus, TrialBeginDate = emp.TrialBeginDate, TrialEndDate = emp.TrialEndDate, EmployeeEMail = emp.EmployeeEMail, Gender = emp.Gender, Birthday = emp.Birthday, MaritalStatus = emp.MaritalStatus }; if (!notLimitLegal) { query = query.Where(t => t.LegalEntityID == legalId); } if (!string.IsNullOrEmpty(name)) { query = query.Where(u => u.EmployeeNameCN.Contains(name)); } if (!string.IsNullOrEmpty(userno)) { query = query.Where(u => u.EmployeeNumber.Contains(userno)); } #region "Options" var mainPosOnly = false; var probationEmpOnly = false; if (!string.IsNullOrWhiteSpace(options)) { var opts = Newtonsoft.Json.JsonConvert.DeserializeObject(options) as dynamic; try { mainPosOnly = Convert.ToBoolean(opts.mainPosOnly); probationEmpOnly = Convert.ToBoolean(opts.probationEmpOnly); } catch { } } if (mainPosOnly) { query = query.Where(u => u.IsMain); } if (probationEmpOnly) { query = query.Where(u => u.EmployeeStatus == "6|" + DictConstants.HR_EMP_EmployeeStatus); } #endregion if (!showSideline) { query = query.Where(u => u.IsMain); } if (showChild) { query = query.Where(t => lstChildOrgId.Contains(t.OrganizationID.Value)); } else { query = query.Where(t => t.OrganizationID == orgId); } #endregion var total = 0; var results = new EmployeeInfo[0]; query = BizHelper.GetPageQuery(context, query.OrderBy(g => g.CreateTime), out total); if (total > 0) { results = query.ToArray(); foreach (var item in results) { item.Gender = CommonDictService.GetDictItemName(item.Gender); item.MaritalStatus = CommonDictService.GetDictItemName(item.MaritalStatus); item.IDType = CommonDictService.GetDictItemName(item.IDType); item.SalaryLevelName = string.Format("{0} ({1})", item.SalaryLevelName, CommonDictService.GetDictItemName(item.SalaryLevelType)); } #region "Options: Address" var empIDs = query.Select(p => p.EmployeeID).ToList(); var addrDatum = from c in dbContect.HR_EMP_Address.Where(p => !p.IsDeleted && empIDs.Contains(p.EmployeeID)) group c by c.EmployeeID into g select new { EmployeeID = g.Key, HomeAddress = g.Where(p => p.AddressType == "0").OrderByDescending(p => p.CreateTime).Select(p => new EmployeeAddress { Country = p.Country, Province = p.Province, City = p.City, District = p.District, Address = p.Address, AddressPhone = p.AddressPhone, ZipCode = p.ZipCode }).FirstOrDefault(), HukouAddress = g.Where(p => p.AddressType == "1").OrderByDescending(p => p.CreateTime).Select(p => new EmployeeAddress { Country = p.Country, Province = p.Province, City = p.City, District = p.District, Address = p.Address, AddressPhone = p.AddressPhone, ZipCode = p.ZipCode }).FirstOrDefault() }; foreach (var addr in addrDatum) { var item = results.FirstOrDefault(p => p.EmployeeID == addr.EmployeeID); if (item != null) { item.HomeAddress = addr.HomeAddress; item.HukouAddress = addr.HukouAddress; } } #endregion } return(this.OK(new { total = total, rows = results })); } }
public BusinessResult GetEmployeeByIDs(BusinessContext context) { var content = context.Content as JObject; var data = content["formdata"]; var jsonObj = JsonConvert.DeserializeAnonymousType( context.Content.ToJsonString(), new { ids = string.Empty, orgId = string.Empty, name = string.Empty, userno = string.Empty, options = string.Empty, notLimitLegal = string.Empty, includeOnBoarding = string.Empty, showChild = string.Empty, showSideline = string.Empty //formdata = new //{ // ids = string.Empty //} }); if (string.IsNullOrEmpty(jsonObj.ids)) { this.ThrowException("请选择员工!"); } var idPosList = jsonObj.ids.Split(';').ToList(); var selectedEmpList = idPosList.Select(a => new { EmployeeID = Guid.Parse(a.Split(',')[0].ToString()), PosID = Guid.Parse(a.Split(',')[1].ToString()) }).ToList(); //List<Guid> idList = new List<Guid>(); //if (!string.IsNullOrEmpty(jsonObj.ids)) //{ // idList = jsonObj.ids.Split(';').Select(a => Guid.Parse(a.Trim().ToString())).ToList(); //} List <Guid> idList = selectedEmpList.Select(a => a.EmployeeID).ToList(); var legalId = context.Credential.LegalGuid(); var tenantId = context.Credential.TenantGuid(); //var orgId = context.Request["orgId"]; //Guid orgGuid = Guid.Parse(orgId); //var name = context.Request["name"]; //var userno = context.Request["userno"]; //var options = context.Request["options"]; //var notLimitLegal = "1".Equals(context.Request["notLimitLegal"]); //var includeOnBoarding = "1".Equals(context.Request["includeOnBoarding"]); //var showChild = "true".Equals(context.Request["showChild"], StringComparison.CurrentCultureIgnoreCase); //var showSideline = "true".Equals(context.Request["showSideline"], StringComparison.CurrentCultureIgnoreCase); var orgId = jsonObj.orgId; Guid orgGuid = Guid.Parse(orgId); var name = jsonObj.name; var userno = jsonObj.userno; var options = jsonObj.options; var notLimitLegal = "1".Equals(jsonObj.notLimitLegal); var includeOnBoarding = "1".Equals(jsonObj.includeOnBoarding); var showChild = "true".Equals(jsonObj.showChild, StringComparison.CurrentCultureIgnoreCase); var showSideline = "true".Equals(jsonObj.showSideline, StringComparison.CurrentCultureIgnoreCase); using (var dbContect = new HRDbContext()) { var lstEmpStatus = new List <string>() { "0|HR_EMP_EmpStatus", "2|HR_EMP_EmpStatus", }; if (includeOnBoarding) { lstEmpStatus.Add("1|HR_EMP_EmpStatus"); } var lstChildOrgId = new HR_OrganizationHelper().GetChildOrgId(notLimitLegal ? Guid.Empty : legalId, orgGuid, true); ////HR_EMP_Employee,HR_ORG_Position,HR_ORG_Organization var query = (from emp in dbContect.HR_EMP_Employee join emppos in dbContect.HR_EMP_PostInformation on emp.EmployeeID equals emppos.EmployeeID join pos in dbContect.HR_ORG_Position on emppos.PositionID equals pos.PositionID join org in dbContect.HR_ORG_Organization on emppos.OrganizationID equals org.OrganizationID join leg in dbContect.HR_ORG_LegalEntity on org.LegalEntityID equals leg.LegalEntityID join salary in dbContect.HR_EMP_SalaryLevel.Where(s => !s.IsDeleted && !s.IsDisabled) on emp.SalaryLevelID equals salary.SalaryLevelID into salaryClosure from s in salaryClosure.DefaultIfEmpty() join area in dbContect.HR_EMP_OfficeArea on emp.OfficeAreaID equals area.AreaID into tmpArea from area in tmpArea.DefaultIfEmpty() where !emp.IsDeleted && !emppos.IsDeleted && !leg.IsDeleted && !pos.IsDeleted && !org.IsDeleted && emp.TenantID == tenantId && idList.Contains(emp.EmployeeID) select new EmployeeInfo { EmployeeID = emp.EmployeeID, EmployeeNameCN = emp.EmployeeNameCN, EmployeeNameEN = emp.EmployeeNameEN, EmployeeNumber = emp.EmployeeNumber, TeleCode = emp.TeleCode, ExtCode = emp.ExtCode, OfficeAreaID = emp.OfficeAreaID, OfficeAreaName = area == null ? string.Empty : area.AreaName, IDType = emp.IDType, IDNumber = emp.IDNumber, PersonalTelNumber = emp.PersonalCellPhone, MainJobPostionID = emp.MainJobPositionID, MainJobPostionName = emp.MainJobPostionName, CurrentJobLevelName = emp.CurrentJobLevelName, FirstWorkedDate = emp.FirstWorkedDate, OnboardDate = emp.OnboardDate, PositionID = pos.PositionID, PositionCode = pos.PositionCode, PositionName = pos.PositionName, OrganizationID = org.OrganizationID, OrganizationCode = org.OrganizationCode, OrganizationName = org.OrganizationName, LegalEntityID = org.LegalEntityID, LegalEntityCode = leg.LegalEntityCode, LegalEntityName = leg.LegalEntityName, LegalEntityTelNumber = leg.TelNumber, IsMain = emppos.IsMain, CreateTime = emp.CreateTime, EmployeeStatus = emp.EmployeeStatus, TrialBeginDate = emp.TrialBeginDate, TrialEndDate = emp.TrialEndDate, EmployeeEMail = emp.EmployeeEMail, Gender = emp.Gender, Birthday = emp.Birthday, MaritalStatus = emp.MaritalStatus, SalaryLevelID = emp.SalaryLevelID, SalaryLevelName = s == null ? String.Empty : s.SalaryLevelName, SalaryLevelType = s.SalaryLevelType }).Distinct().ToList(); if (!notLimitLegal) { query = query.Where(t => t.LegalEntityID == legalId).ToList(); } if (!string.IsNullOrEmpty(name)) { query = query.Where(u => u.EmployeeNameCN.Contains(name)).ToList(); } if (!string.IsNullOrEmpty(userno)) { query = query.Where(u => u.EmployeeNumber.Contains(userno)).ToList(); } #region "Options" var mainPosOnly = false; var probationEmpOnly = false; if (!string.IsNullOrWhiteSpace(options)) { var opts = Newtonsoft.Json.JsonConvert.DeserializeObject(options) as dynamic; try { mainPosOnly = Convert.ToBoolean(opts.mainPosOnly); probationEmpOnly = Convert.ToBoolean(opts.probationEmpOnly); } catch { } } if (mainPosOnly) { query = query.Where(u => u.IsMain).ToList(); } if (probationEmpOnly) { query = query.Where(u => u.EmployeeStatus == "6|" + DictConstants.HR_EMP_EmployeeStatus).ToList(); } #endregion if (!showSideline) { query = query.Where(u => u.IsMain).ToList(); } else { query = (from q in query join emp in selectedEmpList on new { empID = q.EmployeeID, posID = q.PositionID } equals new { empID = emp.EmployeeID, posID = (Guid?)emp.PosID } select q).ToList(); } if (showChild) { query = query.Where(t => lstChildOrgId.Contains(t.OrganizationID.Value)).ToList(); } else { query = query.Where(t => t.OrganizationID == orgGuid).ToList(); } var total = 0; var results = new EmployeeInfo[0]; query = BizHelper.GetPageQuery(context, query.OrderBy(g => g.CreateTime).AsQueryable(), out total).ToList(); if (total > 0) { results = query.ToArray(); foreach (var item in results) { item.Gender = CommonDictService.GetDictItemName(item.Gender); item.MaritalStatus = CommonDictService.GetDictItemName(item.MaritalStatus); item.IDType = CommonDictService.GetDictItemName(item.IDType); } #region "Options: Address" var empIDs = query.Select(p => p.EmployeeID).ToList(); var addrDatum = from c in dbContect.HR_EMP_Address.Where(p => !p.IsDeleted && empIDs.Contains(p.EmployeeID)) group c by c.EmployeeID into g select new { EmployeeID = g.Key, HomeAddress = g.Where(p => p.AddressType == "0").OrderByDescending(p => p.CreateTime).Select(p => new EmployeeAddress { Country = p.Country, Province = p.Province, City = p.City, District = p.District, Address = p.Address, AddressPhone = p.AddressPhone, ZipCode = p.ZipCode }).FirstOrDefault(), HukouAddress = g.Where(p => p.AddressType == "1").OrderByDescending(p => p.CreateTime).Select(p => new EmployeeAddress { Country = p.Country, Province = p.Province, City = p.City, District = p.District, Address = p.Address, AddressPhone = p.AddressPhone, ZipCode = p.ZipCode }).FirstOrDefault() }; foreach (var addr in addrDatum) { var item = results.FirstOrDefault(p => p.EmployeeID == addr.EmployeeID); if (item != null) { item.HomeAddress = addr.HomeAddress; item.HukouAddress = addr.HukouAddress; } } #endregion } return(this.Success(results)); //return this.OK(new { total = total, rows = new List<dynamic> { new { // EmployeeID = "B31E66F4-2E66-4C55-8957-1A50280F9696", // EmployeeNameCN = "赵六", // EmployeeNumber = "123", // IsMain = false //} } }); } }