From 3d63f80cc42370f192f9699dfbf33b482d44e526 Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Mon, 4 Nov 2024 09:22:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=9F=A5=E8=AF=A2=E7=AE=80?= =?UTF-8?q?=E5=8E=86=E6=8F=90=E4=BA=A4=E7=BB=93=E6=9E=9C=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Ghrh/Ghrh_ResumeController.cs | 10 + Tiobon.Core.Api/Tiobon.Core.xml | 6 + Tiobon.Core.Common/Helper/StringHelper.cs | 114 +++++- .../Ghrh/IGhrh_ResumeServices.cs | 2 + .../Extend/ResumeTemplateGroupColumn.cs | 6 + .../Ghre/Ghre_StudyRecordServices.cs | 4 +- .../Ghrh/Ghrh_ResumeServices.cs | 340 ++++++++++++++++-- Tiobon.Core/Tiobon.Core.xml | 6 + 8 files changed, 440 insertions(+), 48 deletions(-) diff --git a/Tiobon.Core.Api/Controllers/Ghrh/Ghrh_ResumeController.cs b/Tiobon.Core.Api/Controllers/Ghrh/Ghrh_ResumeController.cs index bad58963..d25b0b4f 100644 --- a/Tiobon.Core.Api/Controllers/Ghrh/Ghrh_ResumeController.cs +++ b/Tiobon.Core.Api/Controllers/Ghrh/Ghrh_ResumeController.cs @@ -176,4 +176,14 @@ public class Ghrh_ResumeController : BaseController Submit(long id, string status, [FromBody] ResumeFormColumnSubmit resume) => await _service.Submit(id, status, resume); #endregion + + #region 查询招聘表单信息提交结果接口 + /// + /// 查询招聘表单信息提交结果接口 + /// + /// + [HttpPost("QueryResult/{id}/{langId}"), AllowAnonymous] + public async Task> QueryResult(long id, int langId) => await _service.QueryResult(id, langId); + + #endregion } \ No newline at end of file diff --git a/Tiobon.Core.Api/Tiobon.Core.xml b/Tiobon.Core.Api/Tiobon.Core.xml index 57961b67..203dcb73 100644 --- a/Tiobon.Core.Api/Tiobon.Core.xml +++ b/Tiobon.Core.Api/Tiobon.Core.xml @@ -1237,6 +1237,12 @@ + + + 查询招聘表单信息提交结果接口 + + + 教育背景(Controller) diff --git a/Tiobon.Core.Common/Helper/StringHelper.cs b/Tiobon.Core.Common/Helper/StringHelper.cs index 3aed5e16..1b73a8b8 100644 --- a/Tiobon.Core.Common/Helper/StringHelper.cs +++ b/Tiobon.Core.Common/Helper/StringHelper.cs @@ -80,7 +80,8 @@ public class StringHelper /// /// 格式-默认为N /// - public static string GetGUID(string format="N") { + public static string GetGUID(string format = "N") + { return Guid.NewGuid().ToString(format); } /// @@ -98,9 +99,10 @@ public class StringHelper /// /// /// - public static string GetCusLine(string resourceStr, int length) { + public static string GetCusLine(string resourceStr, int length) + { string[] arrStr = resourceStr.Split("\r\n"); - return string.Join("", (from q in arrStr select q).Skip(arrStr.Length - length + 1).Take(length).ToArray()); + return string.Join("", (from q in arrStr select q).Skip(arrStr.Length - length + 1).Take(length).ToArray()); } #region 求系统唯一字符串 /// @@ -119,39 +121,115 @@ public class StringHelper + + #region 格式化数字字符 + /// + /// 格式化数字字符,如传入1.24500,返回1.245 + /// + /// + /// + public static string TrimDecimalString(string value) + { + try + { + string result = string.Empty; + if (!string.IsNullOrEmpty(value)) + { + Decimal tmp = Decimal.Parse(value); + result = string.Format("{0:#0.##########}", tmp); + } + return result; + } + catch (Exception) + { + throw; + } + } + + public static string TrimDecimalString(decimal value) + { + return TrimDecimalString(value.ToString()); + } + + /// + /// 格式化数字字符,并保留指定的小数位 + /// + /// 需要处理的值 + /// 保留小数点后位数 + /// + public static string TrimDecimalString(string value, int reservedDigit) + { + try + { + string result = string.Empty; + if (!string.IsNullOrEmpty(value)) + { + Decimal tmp = Decimal.Parse(value); + if (reservedDigit == -1) + result = string.Format("{0:#0.##########}", tmp); + else + { + result = String.Format("{0:N" + reservedDigit.ToString() + "}", tmp); + result = result.Replace(",", ""); + } + } + return result; + } + catch (Exception) { throw; } + } + /// /// 格式化数字字符,并保留指定的小数位 /// /// 需要处理的值 /// 保留小数点后位数,-1时只会去除小数点后最后几位的0 /// - public static string TrimNumber(decimal value, int reservedDigit) + public static string TrimDecimalString(object value, int reservedDigit) { try { string result = string.Empty; if (!string.IsNullOrEmpty(Convert.ToString(value))) { - //此处主要是为MVC页面中数字类型的字段作处理 - if (value != decimal.MinValue) + Decimal tmp = Decimal.Parse(Convert.ToString(value)); + if (reservedDigit == -1) + result = string.Format("{0:#0.##########}", tmp); + else { - Decimal tmp = Decimal.Parse(Convert.ToString(value)); - if (reservedDigit == -1) - { - result = string.Format("{0:#0.##########}", tmp); - } - else - { - result = String.Format("{0:N" + reservedDigit.ToString() + "}", tmp); - result = result.Replace(",", ""); - } + result = String.Format("{0:N" + reservedDigit.ToString() + "}", tmp); + result = result.Replace(",", ""); } } return result; } - catch (Exception E) + catch (Exception) { throw; } + } + + /// + /// 格式化数字字符,并保留指定的小数位 + /// + /// 需要处理的值 + /// 保留小数点后位数,-1时只会去除小数点后最后几位的0 + /// + public static decimal TrimDecimal(object value, int reservedDigit) + { + try { - throw E; + string result = string.Empty; + if (!string.IsNullOrEmpty(Convert.ToString(value))) + { + Decimal tmp = Decimal.Parse(Convert.ToString(value)); + if (reservedDigit == -1) + result = string.Format("{0:#0.##########}", tmp); + else + { + result = String.Format("{0:N" + reservedDigit.ToString() + "}", tmp); + result = result.Replace(",", ""); + } + } + return Convert.ToDecimal(result); } + catch (Exception) { throw; } } + #endregion } diff --git a/Tiobon.Core.IServices/Ghrh/IGhrh_ResumeServices.cs b/Tiobon.Core.IServices/Ghrh/IGhrh_ResumeServices.cs index ccccd24b..b67eed08 100644 --- a/Tiobon.Core.IServices/Ghrh/IGhrh_ResumeServices.cs +++ b/Tiobon.Core.IServices/Ghrh/IGhrh_ResumeServices.cs @@ -27,5 +27,7 @@ namespace Tiobon.Core.IServices Task> Query(long id, int langId); Task Submit(long id, string status, ResumeFormColumnSubmit resume); + + Task> QueryResult(long id, int langId); } } \ No newline at end of file diff --git a/Tiobon.Core.Model/ViewModels/Extend/ResumeTemplateGroupColumn.cs b/Tiobon.Core.Model/ViewModels/Extend/ResumeTemplateGroupColumn.cs index 8d71721d..d964ae3d 100644 --- a/Tiobon.Core.Model/ViewModels/Extend/ResumeTemplateGroupColumn.cs +++ b/Tiobon.Core.Model/ViewModels/Extend/ResumeTemplateGroupColumn.cs @@ -26,5 +26,11 @@ public class ResumeCondition public Dictionary Items { get; set; } } +public class ResumeFormColumn1 +{ + public string ColumnName { get; set; } + public string GroupType { get; set; } + +} diff --git a/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs b/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs index d8f4e4c9..0d51421a 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs @@ -114,7 +114,7 @@ public class Ghre_StudyRecordServices : BaseServices(sql); + var formColumns = await QueryResumeFormColumn(1); + + #region Base + + var columnNames = formColumns.Where(x => x.GroupType == "Base").Select(x => x.ColumnName).ToList(); columnNames = columnNames.Distinct().ToList(); var dicts = new Dictionary { @@ -606,11 +592,115 @@ END"; dicts.Add(x, value); }); Data.Base = dicts; - Data.Family = await _ghrh_ResumeHomeServices.QueryDto(x => x.ResumeId != null && x.ResumeId == id);//家庭关系 - Data.Education = await _ghrh_ResumeEduBGServices.QueryDto(x => x.ResumeId != null && x.ResumeId == id);//教育背景 - Data.WorkExp = await _ghrh_ResumeWorkExpServices.QueryDto(x => x.ResumeId != null && x.ResumeId == id);//工作经历 - Data.Licence = await _ghrh_ResumeLicenceServices.QueryDto(x => x.ResumeId != null && x.ResumeId == id);//简历培训记录 - Data.Training = await _ghrh_ResumeTrainingServices.QueryDto(x => x.ResumeId != null && x.ResumeId == id);//证件 + #endregion + + #region 家庭关系 + + columnNames = formColumns.Where(x => x.GroupType == "Family").Select(x => x.ColumnName).ToList(); + columnNames = columnNames.Distinct().ToList(); + var familys = await _ghrh_ResumeHomeServices.QueryDto(x => x.ResumeId != null && x.ResumeId == id); + var family = new List>(); + familys.ForEach(x => + { + var dicts = new Dictionary(); + columnNames.ForEach(x => + { + var value = entity.GetPropertyValue(x); + dicts.Add(x, value); + }); + if (columnNames.Any(x => x == "AttachmentIDs")) + dicts["AttachmentIDs"] = x.AttachmentIDs; + family.Add(dicts); + }); + + Data.Family = family; + #endregion + + #region 教育背景 + + columnNames = formColumns.Where(x => x.GroupType == "Education").Select(x => x.ColumnName).ToList(); + columnNames = columnNames.Distinct().ToList(); + var educations = await _ghrh_ResumeEduBGServices.QueryDto(x => x.ResumeId != null && x.ResumeId == id); + var education = new List>(); + educations.ForEach(x => + { + var dicts = new Dictionary(); + columnNames.ForEach(x => + { + var value = entity.GetPropertyValue(x); + dicts.Add(x, value); + }); + if (columnNames.Any(x => x == "AttachmentIDs")) + dicts["AttachmentIDs"] = x.AttachmentIDs; + education.Add(dicts); + }); + + Data.Education = education; + #endregion + + #region 工作经历 + columnNames = formColumns.Where(x => x.GroupType == "WorkExp").Select(x => x.ColumnName).ToList(); + columnNames = columnNames.Distinct().ToList(); + var workExps = await _ghrh_ResumeWorkExpServices.QueryDto(x => x.ResumeId != null && x.ResumeId == id); + var workExp = new List>(); + workExps.ForEach(x => + { + var dicts = new Dictionary(); + columnNames.ForEach(x => + { + var value = entity.GetPropertyValue(x); + dicts.Add(x, value); + }); + if (columnNames.Any(x => x == "AttachmentIDs")) + dicts["AttachmentIDs"] = x.AttachmentIDs; + workExp.Add(dicts); + }); + + Data.WorkExp = workExp; + #endregion + + #region 证件 + columnNames = formColumns.Where(x => x.GroupType == "Licence").Select(x => x.ColumnName).ToList(); + columnNames = columnNames.Distinct().ToList(); + var Licences = await _ghrh_ResumeLicenceServices.QueryDto(x => x.ResumeId != null && x.ResumeId == id); + var Licence = new List>(); + Licences.ForEach(x => + { + var dicts = new Dictionary(); + columnNames.ForEach(x => + { + var value = entity.GetPropertyValue(x); + dicts.Add(x, value); + }); + if (columnNames.Any(x => x == "AttachmentIDs")) + dicts["AttachmentIDs"] = x.AttachmentIDs; + Licence.Add(dicts); + }); + + Data.Licence = Licence; + #endregion + + #region 简历培训记录 + columnNames = formColumns.Where(x => x.GroupType == "Training").Select(x => x.ColumnName).ToList(); + columnNames = columnNames.Distinct().ToList(); + var Trainings = await _ghrh_ResumeTrainingServices.QueryDto(x => x.ResumeId != null && x.ResumeId == id); + var Training = new List>(); + Trainings.ForEach(x => + { + var dicts = new Dictionary(); + columnNames.ForEach(x => + { + var value = entity.GetPropertyValue(x); + dicts.Add(x, value); + }); + if (columnNames.Any(x => x == "AttachmentIDs")) + dicts["AttachmentIDs"] = x.AttachmentIDs; + Training.Add(dicts); + }); + + Data.Training = Training; + #endregion + Data.Attachment = await Db.Queryable().Where(x => x.TableName == id.ObjToString()).ToListAsync(); var statements = await _ghrh_ResumeStatementServices.QueryDto(x => x.ResumeId != null && x.ResumeId == id);//证件 @@ -633,10 +723,10 @@ END"; #region 承诺 var promiseList = new List - { + { "本人诚实告知未思有各类传染性疾病,若经体检后发现有不符合本公司要求的项目,本人愿意放弃此次应征机会!", "本人正式入职之前,已不与任何单位存在劳动关系,并承诺在工作中不使用曾经服务过的工作单位的技术和商业秘密,如有违背,由此引起的法律纠纷及经济责任由本人承担。" - }; + }; obj.Promise = promiseList; #endregion @@ -649,6 +739,29 @@ END"; return ServiceResult.OprateSuccess("查询成功", obj); } + + + public async Task> QueryResumeFormColumn(long resumeTemplateID) + { + var sql = @$"DECLARE @ResumeTemplateID BIGINT = {resumeTemplateID} + + SELECT A.ColumnName, D.GroupType + FROM Ghrh_ResumeInfoColumn A + LEFT JOIN Ghrh_ResumeTemplateInfoGroupColumn B + ON B.ResumeInfoColumnID = A.ID + AND B.IsDisplay = 1 + AND B.IsEnable = 1 + AND A.IsEnable = 1 + JOIN Ghrh_ResumeTemplateInfoGroup C + ON B.ResumeTemplateInfoGroupID = C.Id + JOIN Ghrh_ResumeInfoGroup D + ON C.ResumeInfoGroupId = D.ID AND D.IsEnable = 1 + WHERE C.ResumeTemplateID = @ResumeTemplateID + -- AND D.GroupType = 'Base' + ORDER BY D.GroupType, b.SortNo"; + + return await Db.Ado.SqlQueryAsync(sql); + } #endregion #region 简历提交接口 @@ -708,8 +821,179 @@ END"; await _ghrh_ResumeStatementServices.Add(inserts); } - return ServiceResult.OprateSuccess(); } #endregion + + #region 简历提交接口 + public async Task> QueryResult(long id, int langId) + { + dynamic Data = new ExpandoObject(); + var entity = await QueryById(id); + + if (entity is null) throw new Exception("无效的ID!"); + decimal completionDegree = 0; + + var groups = await Db.Ado.SqlQueryAsync("select GroupName tabName, GroupType type from Ghrh_ResumeInfoGroup where IsEnable=1 and GroupType !='Photo' and GroupType !='Attachment'"); + int count = groups.Count; + + #region 基础数据 + var notNUllCount = 0; + var formColumns = await QueryResumeFormColumn(1); + var columnNames = formColumns.Where(x => x.GroupType == "Base").Select(x => x.ColumnName).ToList(); + columnNames = columnNames.Distinct().ToList(); + columnNames.ForEach(x => + { + var value = entity.GetPropertyValue(x); + if (value != null) + notNUllCount++; + }); + var basePercent = (decimal)notNUllCount / columnNames.Count * 100; + completionDegree += basePercent; + #endregion + + #region 家庭关系 + decimal familyPercent = 0; + var familys = await _ghrh_ResumeHomeServices.QueryDto(x => x.ResumeId != null && x.ResumeId == id); + if (familys.Any()) + { + notNUllCount = 0; + columnNames = formColumns.Where(x => x.GroupType == "Family").Select(x => x.ColumnName).ToList(); + columnNames = columnNames.Distinct().ToList(); + columnNames.ForEach(x => + { + var value = entity.GetPropertyValue(x); + if (value != null) + notNUllCount++; + + }); + familyPercent = (decimal)notNUllCount / (columnNames.Count * familys.Count) * 100; + completionDegree += familyPercent; + } + #endregion + + #region 教育背景 + decimal educationPercent = 0; + var educations = await _ghrh_ResumeEduBGServices.QueryDto(x => x.ResumeId != null && x.ResumeId == id); + if (educations.Any()) + { + notNUllCount = 0; + columnNames = formColumns.Where(x => x.GroupType == "Education").Select(x => x.ColumnName).ToList(); + columnNames = columnNames.Distinct().ToList(); + columnNames.ForEach(x => + { + var value = entity.GetPropertyValue(x); + if (value != null) + notNUllCount++; + + }); + educationPercent = (decimal)notNUllCount / (columnNames.Count * educations.Count) * 100; + completionDegree += educationPercent; + } + #endregion + + #region 工作经历 + decimal workExpPercent = 0; + var workExps = await _ghrh_ResumeWorkExpServices.QueryDto(x => x.ResumeId != null && x.ResumeId == id); + if (workExps.Any()) + { + notNUllCount = 0; + columnNames = formColumns.Where(x => x.GroupType == "WorkExp").Select(x => x.ColumnName).ToList(); + columnNames = columnNames.Distinct().ToList(); + columnNames.ForEach(x => + { + var value = entity.GetPropertyValue(x); + if (value != null) + notNUllCount++; + + }); + workExpPercent = (decimal)notNUllCount / (columnNames.Count * workExps.Count) * 100; + completionDegree += workExpPercent; + } + #endregion + + #region 证件 + decimal licencePercent = 0; + var licences = await _ghrh_ResumeLicenceServices.QueryDto(x => x.ResumeId != null && x.ResumeId == id); + if (licences.Any()) + { + notNUllCount = 0; + columnNames = formColumns.Where(x => x.GroupType == "Licence").Select(x => x.ColumnName).ToList(); + columnNames = columnNames.Distinct().ToList(); + columnNames.ForEach(x => + { + var value = entity.GetPropertyValue(x); + if (value != null) + notNUllCount++; + + }); + licencePercent = (decimal)notNUllCount / (columnNames.Count * licences.Count) * 100; + completionDegree += licencePercent; + } + #endregion + + #region 培训 + decimal trainingPercent = 0; + var trainings = await _ghrh_ResumeTrainingServices.QueryDto(x => x.ResumeId != null && x.ResumeId == id); + if (trainings.Any()) + { + notNUllCount = 0; + columnNames = formColumns.Where(x => x.GroupType == "Training").Select(x => x.ColumnName).ToList(); + columnNames = columnNames.Distinct().ToList(); + columnNames.ForEach(x => + { + var value = entity.GetPropertyValue(x); + if (value != null) + notNUllCount++; + + }); + trainingPercent = (decimal)notNUllCount / (columnNames.Count * trainings.Count) * 100; + completionDegree += trainingPercent; + } + #endregion + + #region 声明 + decimal statementPercent = 0; + var statements = await _ghrh_ResumeStatementServices.QueryDto(x => x.ResumeId != null && x.ResumeId == id);//证件 + if (statements.Any()) + { + notNUllCount = statements.Count; + statementPercent = (decimal)notNUllCount / columnNames.Count * 100; + completionDegree += statementPercent; + } + #endregion + + completionDegree = completionDegree / count; + + Dictionary dics = new() + { + { "Base", Convert.ToInt32(StringHelper.TrimDecimalString(StringHelper.TrimDecimalString(basePercent, 0))) }, + { "Family", Convert.ToInt32(StringHelper.TrimDecimalString(StringHelper.TrimDecimalString(familyPercent, 0))) }, + { "Education", Convert.ToInt32(StringHelper.TrimDecimalString(StringHelper.TrimDecimalString(educationPercent, 0))) }, + { "WorkExp", Convert.ToInt32(StringHelper.TrimDecimalString(StringHelper.TrimDecimalString(workExpPercent, 0))) }, + { "Licence", Convert.ToInt32(StringHelper.TrimDecimalString(StringHelper.TrimDecimalString(licencePercent, 0))) }, + { "Training", Convert.ToInt32(StringHelper.TrimDecimalString(StringHelper.TrimDecimalString(trainingPercent, 0))) }, + { "Statement", Convert.ToInt32(StringHelper.TrimDecimalString(StringHelper.TrimDecimalString(statementPercent, 0))) } + }; + var seriesData = new List(); + var xAxisData = new List(); + + groups.ForEach(x => + { + if (dics.ContainsKey(x.type)) + { + seriesData.Add(dics[x.type]); + xAxisData.Add(x.tabName); + } + }); + + + Data.CompletionDegree = StringHelper.TrimDecimalString(StringHelper.TrimDecimalString(completionDegree, 2)); + Data.SeriesData = seriesData; + Data.XAxisData = xAxisData; + Data.StaffName = entity.StaffName; + Data.PhotoUrl = entity.PhotoUrl; + return ServiceResult.OprateSuccess("查询成功", Data); + } + #endregion } \ No newline at end of file diff --git a/Tiobon.Core/Tiobon.Core.xml b/Tiobon.Core/Tiobon.Core.xml index 57961b67..203dcb73 100644 --- a/Tiobon.Core/Tiobon.Core.xml +++ b/Tiobon.Core/Tiobon.Core.xml @@ -1237,6 +1237,12 @@ + + + 查询招聘表单信息提交结果接口 + + + 教育背景(Controller)