using AgileObjects.AgileMapper.Extensions; namespace Tiobon.Core.Services; /// /// 招聘模板 (服务) /// public class Ghrh_TemplateServices : BaseServices, IGhrh_TemplateServices { private readonly IBaseRepository _dal; public Ghrh_TemplateServices(ICaching caching, IBaseRepository dal) { this._dal = dal; base.BaseDal = dal; base._caching = caching; } #region 是否开启 public async Task SwitchPublish(long id, int? isPublish) { //await Db.Updateable() // .SetColumns(it => new Ghrh_Template() // { // IsPublish = 0, // UpdateBy = App.User.ID, // UpdateTime = DateTime.Now // }) // .Where(it => it.IsPublish == 1) // .ExecuteCommandAsync(); await Db.Updateable() .SetColumns(it => new Ghrh_Template() { IsPublish = isPublish, UpdateBy = App.User.ID, UpdateTime = DateTime.Now }) .Where(it => it.Id == id) .ExecuteCommandAsync(); return ServiceResult.OprateSuccess(); } #endregion #region 获取Offer模板字段 public async Task>> QueryOfferTags() { int? extColumCount = 5; var config = await Db.Queryable().Where(x => x.ConfigCode == "ESS_Recruit_Custom_Offer_Ext_Column_Count").FirstAsync(); if (config != null) { try { extColumCount = config?.ConfigValue.ObjToInt(); } catch (Exception) { } } var extColumnFields = new List(); var extColumnFields1 = new List(); for (int i = 1; i <= extColumCount; i++) { extColumnFields.Add(new ModelTagView2Item() { Name = "扩展栏位" + i, Code = "扩展栏位" + i, }); extColumnFields1.Add(new ModelTagView2Item() { Name = "ExtField" + i, Code = "ExtField" + i }); } var list = new List() { new CustomFieldView { GroupName = "中文", Fields = StringHelper.GetFieldDesc().Select(o => new ModelTagView2Item { Name=o.Key,Code=o.Key}).ToList(), ExtFields = extColumnFields }, new CustomFieldView { GroupName = "英文", Fields = StringHelper.GetFieldDesc().Select(o => new ModelTagView2Item { Name=o.Value+"_EN",Code=o.Value+"_EN"}).ToList(), ExtFields = extColumnFields1 }, }; return await Task.FromResult(ServiceResult>.OprateSuccess("查询成功!", list)); } #endregion #region 预览Offer简历 public async Task> Preview(long resumeId, long templateId, Dictionary extFields) { var resume = await Db.Queryable().Where(x => x.Id == resumeId).SingleAsync(); var result = string.Empty; var template = await base.QuerySingle(x => x.Id == templateId); if (template != null) { result = template.TemplateContent; if (result.IsNullOrEmpty()) return await Task.FromResult(ServiceResult.OprateSuccess("查询成功!", result)); result = result.Replace("[姓名]", resume.StaffName); result = result.Replace("[电话]", resume.Mobile); result = result.Replace("[邮箱]", resume.Email); result = result.Replace("[身份证号码]", resume.IdCardNo); result = result.Replace("[StaffName_EN]", resume.StaffEname); result = result.Replace("[Mobile_EN]", resume.Mobile); result = result.Replace("[Email_EN]", resume.Email); result = result.Replace("[IdCardNo_EN]", resume.IdCardNo); var offerApplyOrder = await Db.Queryable().Where(x => x.ResumeId == resumeId).OrderByDescending(x => x.ApplyTime).SingleAsync(); if (offerApplyOrder != null) { #region 岗位 if (offerApplyOrder.TitleId.IsNotEmptyOrNull()) { var title = await Db.Queryable().Where(x => x.TitleID == offerApplyOrder.TitleId).SingleAsync(); if (title.MKey.IsNotEmptyOrNull()) { var lang = await Db.Queryable().Where(x => x.LangKey == title.MKey).SingleAsync(); if (lang != null) { result = result.Replace("[TitleName_EN]", lang.Value03); result = result.Replace("[岗位]", lang.LangValue); } } } #endregion #region 汇报对象 if (offerApplyOrder.ReportId.IsNotEmptyOrNull()) { var staff = await Db.Queryable().Where(x => x.StaffID == offerApplyOrder.ReportId).SingleAsync(); if (staff != null) { result = result.Replace("[ReportName_EN]", staff.StaffEname ?? staff.StaffName); result = result.Replace("[汇报对象]", staff.StaffName); } } #endregion #region 试用期薪资 if (offerApplyOrder.ProbationSalary.IsNotEmptyOrNull()) { result = result.Replace("[Salary_EN]", offerApplyOrder.ProbationSalary.ObjToString()); result = result.Replace("[试用期薪资]", offerApplyOrder.ProbationSalary.ObjToString()); } #endregion #region 薪资 if (offerApplyOrder.ProbationSalary.IsNotEmptyOrNull()) { result = result.Replace("[AfterSalary_EN]", offerApplyOrder.ProbationAfterSalary.ObjToString()); result = result.Replace("[薪资]", offerApplyOrder.ProbationAfterSalary.ObjToString()); } #endregion #region 入职日期 if (offerApplyOrder.InDate.IsNotEmptyOrNull()) { result = result.Replace("[InDate_EN]", DateTimeHelper.ConvertToDayString(offerApplyOrder.InDate)); result = result.Replace("[入职日期]", $" {offerApplyOrder.InDate.Value.Year}年 {offerApplyOrder.InDate.Value.Month} 月 {offerApplyOrder.InDate.Value.Day} 日"); } #endregion #region 公司类别 if (offerApplyOrder.CompanyId.IsNotEmptyOrNull()) { var company = await Db.Queryable().Where(x => x.LegalCompanyID == offerApplyOrder.CompanyId).SingleAsync(); //var sql = $"Select * from Ghra_LegalCompany where LegalCompanyID='{offerApplyOrder.CompanyId}'"; result = result.Replace("[CompanyName_EN]", company?.LegalCompanyEname); result = result.Replace("[公司类别]", company?.LegalCompanyName); } else { result = result.Replace("[CompanyName_EN]", null); result = result.Replace("[公司类别]", null); } #endregion } int? extColumCount = 5; var config = await Db.Queryable().Where(x => x.ConfigCode == "ESS_Recruit_Custom_Offer_Ext_Column_Count").FirstAsync(); if (config != null) { try { extColumCount = config?.ConfigValue.ObjToInt(); } catch (Exception) { } } extFields.ForEach(x => { result = result.Replace("[" + x.Key + "]", x.Value); }); for (int i = 1; i <= extColumCount; i++) { result = result.Replace("[ExtField" + i + "]", null); result = result.Replace("[扩展栏位" + i + "]", null); } StringHelper.GetFieldDesc().Select(o => new ModelTagView2Item { Name = o.Value, Code = o.Key }).ToList() .ForEach(x => { result = result.Replace("[" + x.Code + "]", null); result = result.Replace("[" + x.Name + "_EN]", null); }); } return await Task.FromResult(ServiceResult.OprateSuccess("查询成功!", result)); } #endregion }