diff --git a/Tiobon.Core.Api/Controllers/Ghre/Ghre_SurveyController.cs b/Tiobon.Core.Api/Controllers/Ghre/Ghre_SurveyController.cs index 5d338f33..dc55acb6 100644 --- a/Tiobon.Core.Api/Controllers/Ghre/Ghre_SurveyController.cs +++ b/Tiobon.Core.Api/Controllers/Ghre/Ghre_SurveyController.cs @@ -95,11 +95,21 @@ public class Ghre_SurveyController : BaseController /// 发布 /// - /// - /// + /// /// [HttpPost("Publish/{id}")] public async Task Publish(long id) => await _service.Publish(id); #endregion + + #region 统计 + /// + /// 统计 + /// + /// + /// + [HttpPost("QueryStatistic/{id}")] + public async Task> QueryStatistic(long id) => await _service.QueryStatistic(id); + + #endregion } diff --git a/Tiobon.Core.Api/Tiobon.Core.Model.xml b/Tiobon.Core.Api/Tiobon.Core.Model.xml index e6e30d73..3484be5a 100644 --- a/Tiobon.Core.Api/Tiobon.Core.Model.xml +++ b/Tiobon.Core.Api/Tiobon.Core.Model.xml @@ -37008,6 +37008,31 @@ 问卷调查选项 + + + 今日新增 + + + + + 已填写 + + + + + 未填写 + + + + + 问卷调查题目 + + + + + 问卷调查题目 + + 人力需求维护ID diff --git a/Tiobon.Core.Api/Tiobon.Core.xml b/Tiobon.Core.Api/Tiobon.Core.xml index cc538f86..39f01c7d 100644 --- a/Tiobon.Core.Api/Tiobon.Core.xml +++ b/Tiobon.Core.Api/Tiobon.Core.xml @@ -1431,8 +1431,14 @@ 发布 - - + + + + + + 统计 + + diff --git a/Tiobon.Core.IServices/Ghre/IGhre_SurveyServices.cs b/Tiobon.Core.IServices/Ghre/IGhre_SurveyServices.cs index 77622954..c459936e 100644 --- a/Tiobon.Core.IServices/Ghre/IGhre_SurveyServices.cs +++ b/Tiobon.Core.IServices/Ghre/IGhre_SurveyServices.cs @@ -21,4 +21,6 @@ public interface IGhre_SurveyServices : IBaseServices SubmitESSData(long id, Ghre_SurveyExtend input); Task Publish(long id); + + Task> QueryStatistic(long id); } \ No newline at end of file diff --git a/Tiobon.Core.Model/ViewModels/Extend/InsertGhre_SurveyExtend.cs b/Tiobon.Core.Model/ViewModels/Extend/InsertGhre_SurveyExtend.cs index aae4b7cb..465c2967 100644 --- a/Tiobon.Core.Model/ViewModels/Extend/InsertGhre_SurveyExtend.cs +++ b/Tiobon.Core.Model/ViewModels/Extend/InsertGhre_SurveyExtend.cs @@ -302,4 +302,50 @@ public class Ghre_SurveyQuestionExtend : Ghre_SurveyQuestionExtendBase /// public class Ghre_SurveyOptionExtend : InsertGhre_SurveyOptionExtend { +} + +public class Ghre_SurveyStatistic +{ + /// + /// 今日新增 + /// + public int New { get; set; } + + /// + /// 已填写 + /// + public int Has { get; set; } + + /// + /// 未填写 + /// + public int All { get; set; } + + + /// + /// 问卷调查题目 + /// + public List Questions { get; set; } +} + +/// +/// 问卷调查题目 +/// +public class Ghre_SurveyStatisticQuestion : Ghre_SurveyQuestionExtendBase +{ + public List Table { get; set; } + + +} + +public class Ghre_SurveyStatisticQuestionTable +{ + public long Id { get; set; } + public string OptionNo { get; set; } + public string OptionContent { get; set; } + public decimal Count { get; set; } + + public string Percent { get; set; } + public decimal? Percent1 { get; set; } = 0; + } \ No newline at end of file diff --git a/Tiobon.Core.Services/Ghre/Ghre_SurveyServices.cs b/Tiobon.Core.Services/Ghre/Ghre_SurveyServices.cs index dabe424b..e68ad958 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_SurveyServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_SurveyServices.cs @@ -1,4 +1,7 @@ -namespace Tiobon.Core.Services; +using AgileObjects.AgileMapper.Extensions; +using Microsoft.IdentityModel.Tokens; + +namespace Tiobon.Core.Services; /// /// 问卷调查 (服务) @@ -398,8 +401,6 @@ public class Ghre_SurveyServices : BaseServices Publish(long id) { var entity = await base.QueryById(id); @@ -457,4 +458,55 @@ public class Ghre_SurveyServices : BaseServices> QueryStatistic(long id) + { + var data = new Ghre_SurveyStatistic(); + var entity = await base.QueryById(id); + var deptIds = new List(); + var staffIds = new List(); + + if (entity.DeptId.IsNotEmptyOrNull()) + deptIds = JsonHelper.JsonToObj>(entity.DeptId); + + if (entity.StaffId.IsNotEmptyOrNull()) + staffIds = JsonHelper.JsonToObj>(entity.StaffId); + + var staffIds1 = await Db.Queryable().Where(x => x.DeptID != null && deptIds.Contains(x.DeptID.Value)).Select(x => x.StaffID).ToListAsync(); + staffIds.AddRange(staffIds1); + staffIds = staffIds.Distinct().ToList(); + + data.All = staffIds.Count; + data.Has = await Db.Queryable().Where(x => x.SurveyId == id).CountAsync(); + data.New = await Db.Queryable().Where(x => x.SurveyId == id && x.SubmitDate.Value.Date == DateTime.Now.Date).CountAsync(); + + var recordOptions = await Db.Queryable().Where(x => x.SurveyId == id).ToListAsync(); + + var questions = await Db.Queryable().OrderBy(x => x.SortNo).Where(x => x.SurveyId == id).ToListAsync(); + var options = await Db.Queryable().OrderBy(x => x.SortNo).Where(x => x.SurveyId == id).ToListAsync(); + + + + data.Questions = Mapper.Map(questions).ToANew>(); + data.Questions.ForEach(x => + { + x.Table = Mapper.Map(options.Where(o => o.SurveyQuestionId == x.Id)).ToANew>(); + + decimal total = recordOptions.Where(a => a.SurveyQuestionId == x.Id).Count(); + x.Table.ForEach(o => + { + + o.Count = recordOptions.Where(a => a.SurveyQuestionOptionId == o.Id).Count(); + if (o.Count > 0 && total > 0) + { + o.Percent1 = o.Count / total; + o.Percent1 = o.Percent1 * 100; + o.Percent = $"{o.Percent1.RemoveZero()}%"; + }else + o.Percent = $"0%"; + }); + }); + + return ServiceResult.OprateSuccess("查询成功!", data); + } +} + diff --git a/Tiobon.Core/Tiobon.Core.Model.xml b/Tiobon.Core/Tiobon.Core.Model.xml index e6e30d73..3484be5a 100644 --- a/Tiobon.Core/Tiobon.Core.Model.xml +++ b/Tiobon.Core/Tiobon.Core.Model.xml @@ -37008,6 +37008,31 @@ 问卷调查选项 + + + 今日新增 + + + + + 已填写 + + + + + 未填写 + + + + + 问卷调查题目 + + + + + 问卷调查题目 + + 人力需求维护ID diff --git a/Tiobon.Core/Tiobon.Core.xml b/Tiobon.Core/Tiobon.Core.xml index cc538f86..39f01c7d 100644 --- a/Tiobon.Core/Tiobon.Core.xml +++ b/Tiobon.Core/Tiobon.Core.xml @@ -1431,8 +1431,14 @@ 发布 - - + + + + + + 统计 + +