问卷记录

master
Tiobon 2 months ago
parent 11c326b200
commit 021680359c
  1. 13
      Tiobon.Core.Api/Controllers/Ghre/Ghre_SurveyController.cs
  2. 7
      Tiobon.Core.Api/Tiobon.Core.xml
  3. 2
      Tiobon.Core.IServices/Ghre/IGhre_SurveyServices.cs
  4. 83
      Tiobon.Core.Services/Ghre/Ghre_SurveyServices.cs

@ -123,4 +123,17 @@ public class Ghre_SurveyController : BaseController<IGhre_SurveyServices, Ghre_S
public async Task<ServiceResult> Start(long id) => await _service.Start(id);
#endregion
#region 记录
/// <summary>
/// 记录
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpPost("QueryRecord/{id}")]
public async Task<dynamic> QueryRecord(long id) => await _service.QueryRecord(id);
#endregion
}

@ -1453,6 +1453,13 @@
<param name="id"></param>
<returns></returns>
</member>
<member name="M:Tiobon.Core.Api.Controllers.Ghre_SurveyController.QueryRecord(System.Int64)">
<summary>
开始
</summary>
<param name="id"></param>
<returns></returns>
</member>
<member name="T:Tiobon.Core.Api.Controllers.Ghre_SurveyOptionController">
<summary>
问卷调查选项(Controller)

@ -25,4 +25,6 @@ public interface IGhre_SurveyServices : IBaseServices<Ghre_Survey, Ghre_SurveyDt
Task<ServiceResult<Ghre_SurveyStatistic>> QueryStatistic(long id);
Task<ServiceResult> Start(long id);
Task<dynamic> QueryRecord(long id);
}

@ -1,4 +1,5 @@
using SqlSugar.Extensions;
using Tiobon.Core.IServices;
namespace Tiobon.Core.Services;
@ -614,6 +615,88 @@ public class Ghre_SurveyServices : BaseServices<Ghre_Survey, Ghre_SurveyDto, Ins
}
public async Task<dynamic> QueryRecord(long id)
{
dynamic obj = new ExpandoObject();
dynamic data = new ExpandoObject();
var entity = await base.QueryById(id);
var questions = await Db.Queryable<Ghre_SurveyQuestion>().OrderBy(x => x.SortNo).Where(x => x.SurveyId == id).ToListAsync();
var options = await Db.Queryable<Ghre_SurveyOption>().OrderBy(x => x.SortNo).Where(x => x.SurveyId == id).ToListAsync();
data.Count = await Db.Queryable<Ghre_SurveyRecord>().Where(x => x.SurveyId == id).CountAsync();
var records = await Db.Queryable<Ghre_SurveyRecord>().Where(x => x.SurveyId == id).ToListAsync();
var recordOptions = await Db.Queryable<Ghre_SurveyRecordOption>().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<Ghra_Staff>().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;
}
}

Loading…
Cancel
Save