From 021680359cd94e65c6c571620eaeb0ea123750c9 Mon Sep 17 00:00:00 2001 From: Tiobon Date: Mon, 14 Apr 2025 16:13:47 +0800 Subject: [PATCH] =?UTF-8?q?=E9=97=AE=E5=8D=B7=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Ghre/Ghre_SurveyController.cs | 13 +++ Tiobon.Core.Api/Tiobon.Core.xml | 7 ++ .../Ghre/IGhre_SurveyServices.cs | 2 + .../Ghre/Ghre_SurveyServices.cs | 83 +++++++++++++++++++ 4 files changed, 105 insertions(+) diff --git a/Tiobon.Core.Api/Controllers/Ghre/Ghre_SurveyController.cs b/Tiobon.Core.Api/Controllers/Ghre/Ghre_SurveyController.cs index ec21df0d..107c4d24 100644 --- a/Tiobon.Core.Api/Controllers/Ghre/Ghre_SurveyController.cs +++ b/Tiobon.Core.Api/Controllers/Ghre/Ghre_SurveyController.cs @@ -123,4 +123,17 @@ public class Ghre_SurveyController : BaseController Start(long id) => await _service.Start(id); #endregion + + + + #region 记录 + /// + /// 记录 + /// + /// + /// + [HttpPost("QueryRecord/{id}")] + public async Task QueryRecord(long id) => await _service.QueryRecord(id); + + #endregion } diff --git a/Tiobon.Core.Api/Tiobon.Core.xml b/Tiobon.Core.Api/Tiobon.Core.xml index ccc09d81..5b607143 100644 --- a/Tiobon.Core.Api/Tiobon.Core.xml +++ b/Tiobon.Core.Api/Tiobon.Core.xml @@ -1453,6 +1453,13 @@ + + + 开始 + + + + 问卷调查选项(Controller) diff --git a/Tiobon.Core.IServices/Ghre/IGhre_SurveyServices.cs b/Tiobon.Core.IServices/Ghre/IGhre_SurveyServices.cs index 1f7824ee..ecaed2ef 100644 --- a/Tiobon.Core.IServices/Ghre/IGhre_SurveyServices.cs +++ b/Tiobon.Core.IServices/Ghre/IGhre_SurveyServices.cs @@ -25,4 +25,6 @@ public interface IGhre_SurveyServices : IBaseServices> QueryStatistic(long id); Task Start(long id); + + Task QueryRecord(long id); } \ 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 181bb3bc..26291f7c 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_SurveyServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_SurveyServices.cs @@ -1,4 +1,5 @@ using SqlSugar.Extensions; +using Tiobon.Core.IServices; namespace Tiobon.Core.Services; @@ -614,6 +615,88 @@ public class Ghre_SurveyServices : BaseServices QueryRecord(long id) + { + dynamic obj = new ExpandoObject(); + dynamic data = new ExpandoObject(); + + var entity = await base.QueryById(id); + 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.Count = await Db.Queryable().Where(x => x.SurveyId == id).CountAsync(); + + var records = await Db.Queryable().Where(x => x.SurveyId == id).ToListAsync(); + var recordOptions = await Db.Queryable().Where(x => x.SurveyId == id).ToListAsync(); + #region columns + var columns = new JArray(); + var item = new JObject + { + new JProperty("Filed", "No"), + new JProperty("Name", "序号"), + }; + columns.Add(item); + item = new JObject + { + new JProperty("Filed", "StaffName"), + new JProperty("Name", "填写人"), + }; + columns.Add(item); + item = new JObject + { + new JProperty("Filed", "BeginTime"), + new JProperty("Name", "开始时间"), + }; + columns.Add(item); + item = new JObject + { + new JProperty("Filed", "SubmitTime"), + new JProperty("Name", "提交时间"), + }; + columns.Add(item); + item = new JObject + { + new JProperty("Filed", "Duration"), + new JProperty("Name", "提交时长"), + }; + columns.Add(item); + int i = 1; + questions.ForEach(x => + { + item = new JObject + { + new JProperty("Filed", "Question"+i), + new JProperty("Name", "题目"+i) + }; + columns.Add(item); + i++; + }); + data.Columns = columns; + #endregion + + #region 记录 + var Records = new JArray(); + for (int j = 1; j <= records.Count; j++) + { + var record = records[i]; + var StaffName = await Db.Queryable().Where(x => x.StaffID == record.StaffId).Select(x => x.StaffID).FirstAsync(); + item = new JObject + { + new JProperty("No", i), + new JProperty("StaffName", StaffName), + }; + columns.Add(item); + } + #endregion + + obj.Data = data; + obj.Success = true; + obj.code = "0"; + obj.type = "success"; + obj.message = "查询成功!"; + obj.Status = 200; + return obj; + } }