diff --git a/Tiobon.Core.Api/Controllers/Ghrh/Ghrh_ResumeController.cs b/Tiobon.Core.Api/Controllers/Ghrh/Ghrh_ResumeController.cs index 79834679..a578502a 100644 --- a/Tiobon.Core.Api/Controllers/Ghrh/Ghrh_ResumeController.cs +++ b/Tiobon.Core.Api/Controllers/Ghrh/Ghrh_ResumeController.cs @@ -496,4 +496,17 @@ public class Ghrh_ResumeController : BaseController>> Log(long id) => await _service.Log(id); #endregion + + #region 获取面试日志 + /// + /// 获取面试日志 + /// + /// 简历Id + /// 扩展栏位 + /// 扩展栏位 + /// + [HttpPost, Route("OfferDownLoad/{id}/{templateId}")] + public async Task> OfferDownLoad(long id, long templateId, [FromBody] Dictionary extFields) => await _service.OfferDownLoad(id, templateId, extFields); + + #endregion } \ No newline at end of file diff --git a/Tiobon.Core.Api/Tiobon.Core.xml b/Tiobon.Core.Api/Tiobon.Core.xml index 9969806f..9d1cfb84 100644 --- a/Tiobon.Core.Api/Tiobon.Core.xml +++ b/Tiobon.Core.Api/Tiobon.Core.xml @@ -1597,6 +1597,15 @@ 简历ID + + + 获取面试日志 + + 简历Id + 扩展栏位 + 扩展栏位 + + 教育背景(Controller) diff --git a/Tiobon.Core.IServices/Ghrh/IGhrh_ResumeServices.cs b/Tiobon.Core.IServices/Ghrh/IGhrh_ResumeServices.cs index 5003ca42..f1b04331 100644 --- a/Tiobon.Core.IServices/Ghrh/IGhrh_ResumeServices.cs +++ b/Tiobon.Core.IServices/Ghrh/IGhrh_ResumeServices.cs @@ -77,4 +77,6 @@ public interface IGhrh_ResumeServices : IBaseServices>> Log(long id); + + Task> OfferDownLoad(long id, long templateId, Dictionary extFields); } \ No newline at end of file diff --git a/Tiobon.Core.Services/CommonServices.cs b/Tiobon.Core.Services/CommonServices.cs index 0e98ed01..f6e42fb7 100644 --- a/Tiobon.Core.Services/CommonServices.cs +++ b/Tiobon.Core.Services/CommonServices.cs @@ -1472,15 +1472,16 @@ public partial class CommonServices : BaseServices>, ICommon position = "left" }); - result.JM_PageControlT1.Toolbar.Add(new Toolbar() - { - display = true, - fnKey = "TBD27YN", - fnTitle = "Offer下载", - fnType = "row", - icon = "ess-icon-reject", - position = "left" - }); + if (toolbarRoles.Where(x => x.RoleNo == "RecruitResumeOfferDownLoad").Any()) + result.JM_PageControlT1.Toolbar.Add(new Toolbar() + { + display = true, + fnKey = "TBD27YN", + fnTitle = "Offer下载", + fnType = "row", + icon = "ess-icon-reject", + position = "left" + }); if (toolbarRoles.Where(x => x.RoleNo == "RecruitResumeTag").Any()) result.JM_PageControlT1.Toolbar.Add(new Toolbar() { diff --git a/Tiobon.Core.Services/Ghrh/Ghrh_ResumeServices.cs b/Tiobon.Core.Services/Ghrh/Ghrh_ResumeServices.cs index 37f327c1..ae69ad4f 100644 --- a/Tiobon.Core.Services/Ghrh/Ghrh_ResumeServices.cs +++ b/Tiobon.Core.Services/Ghrh/Ghrh_ResumeServices.cs @@ -2,7 +2,6 @@ using DinkToPdf.Contracts; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Hosting; -using NPOI.OpenXmlFormats.Wordprocessing; using System.IO.Compression; using static Tiobon.Core.Model.Consts; @@ -3641,6 +3640,7 @@ WHERE A.IsEnable = 1 AND C.IsEnable = 1 AND C.Status = A.Status"; break; case "SendOffer": + case "OfferDownLoad": if (interviewLog.Reverse1.IsNotEmptyOrNull()) item.OfferFileUrl = interviewLog.Reverse1; break; @@ -3668,6 +3668,72 @@ WHERE A.IsEnable = 1 AND C.IsEnable = 1 AND C.Status = A.Status"; } #endregion + #region Offer下载 + public async Task> OfferDownLoad(long id, long templateId, Dictionary extFields) + { + var entity = await base.QueryById(id); + if (entity == null) + return ServiceResult.OprateFailed("无效的简历ID!"); + var order = await _ghrh_InterviewOrderServices.QuerySingle(x => x.ResumeId == id); + var content = (await _ghrh_TemplateServices.Preview(id, templateId, extFields)).Data; + + #region 生成Offer PDf + var globalSettings = new GlobalSettings + { + ColorMode = ColorMode.Color, + Orientation = Orientation.Portrait, + PaperSize = PaperKind.A4, + DocumentTitle = entity.StaffName, + }; + + var objectSettings = new ObjectSettings + { + PagesCount = true, + HtmlContent = content, + WebSettings = { DefaultEncoding = "utf-8" }, + }; + + var pdf = new HtmlToPdfDocument() + { + GlobalSettings = globalSettings, + Objects = { objectSettings } + }; + + var fileBytes = _converter.Convert(pdf); + string pathHeader = "wwwroot/files/pdf_files"; + if (!Directory.Exists(pathHeader)) + Directory.CreateDirectory(pathHeader); + var ms = new MemoryStream(fileBytes); + var file = new FormFile(ms, 0, ms.Length, Path.GetFileNameWithoutExtension(pathHeader), Path.GetFileName(pathHeader)); + + var fileName = entity.StaffName + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".pdf"; + await using (var fs = System.IO.File.Create(pathHeader + "/" + fileName)) + { + await file.CopyToAsync(fs); + fs.Flush(); + } + entity.OfferFileUrl = "/Advanced/files/pdf_files/" + fileName; + await Update(entity, ["OfferFileUrl"]); + + await _ghrh_InterviewLogServices.Add(new InsertGhrh_InterviewLogInput() + { + InterviewOrderId = order.Id, + ResumeId = id, + StaffId = App.User.StaffId, + StaffName = App.User.StaffName + "(" + App.User.StaffNo + ")", + Source = "OfferDownLoad", + Reverse1 = entity.OfferFileUrl, + UserId = App.User.ID, + UserName = App.User.Name, + RemarkSz = $"下载Offer!", + }); + + #endregion + + return ServiceResult.OprateSuccess("获取成功", entity.OfferFileUrl); + } + #endregion + #region 通用方法 /// /// 记录日志 diff --git a/Tiobon.Core/Tiobon.Core.xml b/Tiobon.Core/Tiobon.Core.xml index 9969806f..9d1cfb84 100644 --- a/Tiobon.Core/Tiobon.Core.xml +++ b/Tiobon.Core/Tiobon.Core.xml @@ -1597,6 +1597,15 @@ 简历ID + + + 获取面试日志 + + 简历Id + 扩展栏位 + 扩展栏位 + + 教育背景(Controller)