You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
217 lines
8.7 KiB
217 lines
8.7 KiB
using AgileObjects.AgileMapper.Extensions;
|
|
|
|
namespace Tiobon.Core.Services;
|
|
|
|
/// <summary>
|
|
/// 招聘模板 (服务)
|
|
/// </summary>
|
|
public class Ghrh_TemplateServices : BaseServices<Ghrh_Template, Ghrh_TemplateDto, InsertGhrh_TemplateInput, EditGhrh_TemplateInput>, IGhrh_TemplateServices
|
|
{
|
|
private readonly IBaseRepository<Ghrh_Template> _dal;
|
|
public Ghrh_TemplateServices(ICaching caching, IBaseRepository<Ghrh_Template> dal)
|
|
{
|
|
this._dal = dal;
|
|
base.BaseDal = dal;
|
|
base._caching = caching;
|
|
}
|
|
|
|
#region 是否开启
|
|
public async Task<ServiceResult> SwitchPublish(long id, int? isPublish)
|
|
{
|
|
|
|
if (isPublish == 0)
|
|
return ServiceResult.OprateFailed("当前已开启状态 不可以取消!");
|
|
|
|
await Db.Updateable<Ghrh_Template>()
|
|
.SetColumns(it => new Ghrh_Template()
|
|
{
|
|
IsPublish = 0,
|
|
UpdateBy = App.User.ID,
|
|
UpdateTime = DateTime.Now
|
|
})
|
|
.Where(it => it.IsPublish == 1)
|
|
.ExecuteCommandAsync();
|
|
await Db.Updateable<Ghrh_Template>()
|
|
.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<ServiceResult<List<CustomFieldView>>> QueryOfferTags()
|
|
{
|
|
int? extColumCount = 5;
|
|
var config = await Db.Queryable<Ghrh_Config>().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<ModelTagView2Item>();
|
|
var extColumnFields1 = new List<ModelTagView2Item>();
|
|
|
|
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<CustomFieldView>()
|
|
{
|
|
new CustomFieldView {
|
|
GroupName = "中文",
|
|
Fields = StringHelper.GetFieldDesc<OfferTemplate>().Select(o => new ModelTagView2Item { Name=o.Key,Code=o.Key}).ToList(),
|
|
ExtFields = extColumnFields
|
|
},
|
|
new CustomFieldView {
|
|
GroupName = "英文",
|
|
Fields = StringHelper.GetFieldDesc<OfferTemplate>().Select(o => new ModelTagView2Item { Name=o.Value+"_EN",Code=o.Value+"_EN"}).ToList(),
|
|
ExtFields = extColumnFields1
|
|
},
|
|
};
|
|
return await Task.FromResult(ServiceResult<List<CustomFieldView>>.OprateSuccess("查询成功!", list));
|
|
}
|
|
#endregion
|
|
|
|
#region 预览Offer简历
|
|
public async Task<ServiceResult<string>> Preview(long resumeId, Dictionary<string, string> extFields)
|
|
{
|
|
var resume = await Db.Queryable<Ghrh_Resume>().Where(x => x.Id == resumeId).SingleAsync();
|
|
var result = string.Empty;
|
|
var template = await base.QuerySingle(x => x.IsPublish == 1);
|
|
if (template != null)
|
|
{
|
|
result = template.TemplateContent;
|
|
if (result.IsNullOrEmpty())
|
|
return await Task.FromResult(ServiceResult<string>.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<Ghrh_OfferApplyOrder>().Where(x => x.ResumeId == resumeId).OrderByDescending(x => x.ApplyTime).SingleAsync();
|
|
|
|
if (offerApplyOrder != null)
|
|
{
|
|
#region 岗位
|
|
if (offerApplyOrder.TitleId.IsNotEmptyOrNull())
|
|
{
|
|
var title = await Db.Queryable<Ghra_Title>().Where(x => x.TitleID == offerApplyOrder.TitleId).SingleAsync();
|
|
if (title.MKey.IsNotEmptyOrNull())
|
|
{
|
|
var lang = await Db.Queryable<Ghrs_LangKey>().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<Ghra_Staff>().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.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<Ghra_LegalCompany>().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<Ghrh_Config>().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<OfferTemplate>().Select(o => new ModelTagView2Item { Name = o.Key, Code = o.Key }).ToList()
|
|
.ForEach(x =>
|
|
{
|
|
result = result.Replace("[" + x.Code + "]", null);
|
|
result = result.Replace("[" + x.Code + "_EN]", null);
|
|
});
|
|
}
|
|
return await Task.FromResult(ServiceResult<string>.OprateSuccess("查询成功!", result));
|
|
}
|
|
#endregion
|
|
} |