diff --git a/Tiobon.Core.Api/Tiobon.Core.Model.xml b/Tiobon.Core.Api/Tiobon.Core.Model.xml index 44f2a98d..5f7b6557 100644 --- a/Tiobon.Core.Api/Tiobon.Core.Model.xml +++ b/Tiobon.Core.Api/Tiobon.Core.Model.xml @@ -36088,19 +36088,19 @@ 问卷调查选项 - + - 问卷调查选项 + 选项 - + - 选项 + 选项列表 - + - 选项列表 + 问卷调查选项 diff --git a/Tiobon.Core.Model/ViewModels/Extend/InsertGhre_SurveyExtend.cs b/Tiobon.Core.Model/ViewModels/Extend/InsertGhre_SurveyExtend.cs index f5e99b03..aae4b7cb 100644 --- a/Tiobon.Core.Model/ViewModels/Extend/InsertGhre_SurveyExtend.cs +++ b/Tiobon.Core.Model/ViewModels/Extend/InsertGhre_SurveyExtend.cs @@ -285,13 +285,7 @@ public class Ghre_SurveyQuestionExtend : Ghre_SurveyQuestionExtendBase /// 问卷调查选项 /// public List Options { get; set; } -} -/// -/// 问卷调查选项 -/// -public class Ghre_SurveyOptionExtend : InsertGhre_SurveyOptionExtend -{ /// /// 选项 /// @@ -301,4 +295,11 @@ public class Ghre_SurveyOptionExtend : InsertGhre_SurveyOptionExtend /// 选项列表 /// public List Value1 { get; set; } +} + +/// +/// 问卷调查选项 +/// +public class Ghre_SurveyOptionExtend : InsertGhre_SurveyOptionExtend +{ } \ 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 0d931b24..b0025c34 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 MathNet.Numerics.Distributions; +using Tiobon.Core.Common; + +namespace Tiobon.Core.Services; /// /// 问卷调查 (服务) @@ -220,23 +223,97 @@ public class Ghre_SurveyServices : BaseServices SubmitESSData(long id, Ghre_SurveyExtend input) { var entity = await base.QueryById(id); - var data = Mapper.Map(entity).ToANew(); - data.BeginEndTime.Add(data.BeginTime); - data.BeginEndTime.Add(data.EndTime); - if (entity.StaffId.IsNotEmptyOrNull()) - data.StaffIds = JsonHelper.JsonToObj>(entity.StaffId); - if (entity.DeptId.IsNotEmptyOrNull()) - data.DeptIds = JsonHelper.JsonToObj>(entity.DeptId); + await Db.Updateable() + .SetColumns(it => new Ghre_SurveyRecord() { IsEnable = 0 }) + .Where(x => x.StaffId == App.User.StaffId && x.SurveyId == id && x.IsEnable == 1) + .ExecuteCommandAsync(); 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 => + //var recordId = SnowFlakeSingle.Instance.NextId(); + var record = new Ghre_SurveyRecord() { - x.Options = Mapper.Map(options.Where(o => o.SurveyQuestionId == x.Id)).ToANew>(); - }); + //Id = recordId, + SurveyId = id, + StaffId = App.User.StaffId, + Score = 0, + AdjustScore = 0, + SubmitDate = DateTime.Now, + IsView = false + }; + + var recordDetails = new List(); + + var recordId = await Db.Insertable(record).ExecuteReturnSnowflakeIdAsync(); + + for (int i = 0; i < input.Questions.Count; i++) + { + var question = input.Questions[i]; + + var recordDetailId = await Db.Insertable(new Ghre_SurveyRecordDetail() + { + + SurveyId = id, + SurveyRecordId = recordId, + SurveyQuestionId = question.Id, + StaffId = App.User.StaffId, + Score = 0 + + }).ExecuteReturnSnowflakeIdAsync(); + var recordOptions = new List(); + + switch (question.QuestionType) + { + case "Multiple": + case "MultipleScore": + for (int j = 0; j < question.Value1.Count; j++) + { + var option1 = new Ghre_SurveyRecordOption() + { + SurveyId = id, + SurveyRecordId = recordId, + SurveyRecordDetailId = recordDetailId, + SurveyQuestionId = question.Id, + //SurveyQuestionOptionId = x.Id, + StaffId = App.User.StaffId, + Score = 0 + }; + option1.SurveyQuestionOptionId = question.Options.Where(x => x.OptionNo == question.Value1[j]).FirstOrDefault()?.Id; + option1.OptionContent = question.Value1[j]; + await Db.Insertable(option1).ExecuteReturnSnowflakeIdAsync(); + } + + break; + + case "Single": + case "ShortAnswer": + case "SingleScore": + case "Rate": + case "Scale": + var option = new Ghre_SurveyRecordOption() + { + SurveyId = id, + SurveyRecordId = recordId, + SurveyRecordDetailId = recordDetailId, + SurveyQuestionId = question.Id, + //SurveyQuestionOptionId = x.Id, + StaffId = App.User.StaffId, + Score = 0 + }; + option.SurveyQuestionOptionId = question.Options.Where(x => x.OptionNo == question.Value).FirstOrDefault()?.Id; + option.OptionContent = question.Value; + await Db.Insertable(option).ExecuteReturnSnowflakeIdAsync(); + + break; + + default: + break; + } + + } + return ServiceResult.OprateSuccess("提交成功!"); }