From d4abf3353127be8c744e7e4a3468b2398934bd1a Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Thu, 30 May 2024 17:23:03 +0800 Subject: [PATCH] =?UTF-8?q?2.=E6=96=B0=E5=A2=9E=E8=80=83=E8=AF=95=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E3=80=81=E7=BC=96=E8=BE=91=E6=95=B0=E6=8D=AE=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Ghre/Ghre_ExamController.cs | 20 ++- Tiobon.Core.Api/Tiobon.Core.xml | 25 ++- .../Ghre/IGhre_ExamServices.cs | 4 +- .../View/Ghre/Ghre_Exam.Dto.View.cs | 34 +++- .../Extend/DefaultGhre_ExamInput.cs | 3 +- .../Ghre/Ghre_ExamServices.cs | 167 +++++++++++++----- Tiobon.Core/Tiobon.Core.xml | 25 ++- 7 files changed, 220 insertions(+), 58 deletions(-) diff --git a/Tiobon.Core.Api/Controllers/Ghre/Ghre_ExamController.cs b/Tiobon.Core.Api/Controllers/Ghre/Ghre_ExamController.cs index a2656c0c..7f3eb938 100644 --- a/Tiobon.Core.Api/Controllers/Ghre/Ghre_ExamController.cs +++ b/Tiobon.Core.Api/Controllers/Ghre/Ghre_ExamController.cs @@ -33,7 +33,7 @@ public class Ghre_ExamController : BaseController条件 /// [HttpPost, Route("QueryList/{status}")] - public async Task> QueryList(string status, [FromBody] QueryBody body) + public async Task QueryList(string status, [FromBody] QueryBody body) { return await _service.QueryList(body, status); } @@ -44,7 +44,7 @@ public class Ghre_ExamController : BaseController /// 查询明细数据 /// - /// statusid /// [HttpPost, Route("QueryDefault/{id}")] public async Task> QueryDefault(long id) @@ -59,7 +59,8 @@ public class Ghre_ExamController : BaseController /// 根据员工ID查询员工数据 /// - /// statusIds + /// type /// [HttpPost, Route("QueryStaff/{type}")] public async Task>> QueryStaff([FromBody] List Ids, string type) @@ -70,5 +71,18 @@ public class Ghre_ExamController : BaseController + /// 新增 + /// + /// id + /// pageData + /// + [HttpPost("Insert1/{id}")] + public async Task> Insert1(long id, [FromBody] DefaultGhre_ExamPageData pageData) + { + return await _service.Insert1(id, pageData); + } + #endregion } \ No newline at end of file diff --git a/Tiobon.Core.Api/Tiobon.Core.xml b/Tiobon.Core.Api/Tiobon.Core.xml index ebaf4ec6..287de0fc 100644 --- a/Tiobon.Core.Api/Tiobon.Core.xml +++ b/Tiobon.Core.Api/Tiobon.Core.xml @@ -603,8 +603,29 @@ 条件 - - + + + 查询明细数据 + + id + + + + + 根据员工ID查询员工数据 + + Ids + type + + + + + 新增 + + id + pageData + + 试卷配置(Controller) diff --git a/Tiobon.Core.IServices/Ghre/IGhre_ExamServices.cs b/Tiobon.Core.IServices/Ghre/IGhre_ExamServices.cs index 333c5d1b..b66a44c8 100644 --- a/Tiobon.Core.IServices/Ghre/IGhre_ExamServices.cs +++ b/Tiobon.Core.IServices/Ghre/IGhre_ExamServices.cs @@ -11,10 +11,12 @@ namespace Tiobon.Core.IServices public interface IGhre_ExamServices : IBaseServices { Task GetModuleInfo(ModuleParam param); - Task> QueryList(QueryBody body, string status); + Task QueryList(QueryBody body, string status); Task> QueryDefault(long Id); Task>> QueryStaff(List Ids, string type); + + Task> Insert1(long id, DefaultGhre_ExamPageData pageData); } } \ No newline at end of file diff --git a/Tiobon.Core.Model/View/Ghre/Ghre_Exam.Dto.View.cs b/Tiobon.Core.Model/View/Ghre/Ghre_Exam.Dto.View.cs index c3523d97..8684dc9b 100644 --- a/Tiobon.Core.Model/View/Ghre/Ghre_Exam.Dto.View.cs +++ b/Tiobon.Core.Model/View/Ghre/Ghre_Exam.Dto.View.cs @@ -13,7 +13,7 @@ *│ 此技术信息为本公司机密信息,未经本公司书面同意禁止向第三方披露. │ *│ 作者:SimonHsiao │ *└──────────────────────────────────┘ -*/ +*/ namespace Tiobon.Core.Model.Models; @@ -22,13 +22,29 @@ namespace Tiobon.Core.Model.Models; /// public class Ghre_ExamDto : Ghre_Exam { -/// -/// 创建信息 -/// -public string CreateDataInfo { get; set; } + /// + /// 创建信息 + /// + public string CreateDataInfo { get; set; } -/// -/// 修改信息 -/// -public string UpdateDataInfo { get; set; } + /// + /// 修改信息 + /// + public string UpdateDataInfo { get; set; } + + public string AfterHowLongLabel { get; set; } + public string CourseName { get; set; } + public string ExamModeLabel { get; set; } + public string OpenClassName { get; set; } + + public int canCheckbox { get; set; } = 1; // checkbox是否可选 1 是 0否 + public int canDetail { get; set; } = 1; // 可查看明细 + public int canEdit { get; set; } = 1; // 可编辑 + public int canCopy { get; set; } = 1; // 可复制 + public int canDelete { get; set; } = 1; // 可作废 + public int canPreview { get; set; } = 1; // 可预览 + public int showLink { get; set; } = 1; // 显示考试链接按钮 + public int showResult { get; set; } = 1; // 显示成绩按钮 + public int canClose { get; set; } = 1; // 可归档 + public int canCancelRelease { get; set; } = 1;// 可取消发布 } diff --git a/Tiobon.Core.Model/ViewModels/Extend/DefaultGhre_ExamInput.cs b/Tiobon.Core.Model/ViewModels/Extend/DefaultGhre_ExamInput.cs index 80ef7020..e633d668 100644 --- a/Tiobon.Core.Model/ViewModels/Extend/DefaultGhre_ExamInput.cs +++ b/Tiobon.Core.Model/ViewModels/Extend/DefaultGhre_ExamInput.cs @@ -37,7 +37,8 @@ public class DefaultGhre_ExamColumn public class DefaultGhre_ExamPageData : Ghre_ExamBase { - public string AfterHowLong1 { get; set; } + public int? AfterHowLong1 { get; set; } + public List ExamDate { get; set; } = new List(); public List staffTableData { get; set; } = new List(); } diff --git a/Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs b/Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs index b4832c73..8868780e 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs @@ -11,7 +11,7 @@ using AgileObjects.AgileMapper; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using SqlSugar; -using NPOI.OpenXmlFormats.Wordprocessing; +using Tiobon.Core.Common.Helper; namespace Tiobon.Core.Services; @@ -24,10 +24,12 @@ public class Ghre_ExamServices : BaseServices dal) { this._dal = dal; @@ -36,6 +38,7 @@ public class Ghre_ExamServices : BaseServices GetModuleInfo(ModuleParam param) { @@ -186,46 +189,61 @@ public class Ghre_ExamServices : BaseServices> QueryList(QueryBody body, string status) + public async Task QueryList(QueryBody body, string status) { var data = await QueryFilterPage1(body, status); - var data1 = Mapper.Map(data.result.DT_TableDataT1).ToANew>(); - //var linkIds = data1.Where(x => x.LinkId != null).Select(x => x.LinkId.Value).Distinct().ToList(); - //var courses = await _ghre_CourseServices.Query(x => linkIds.Contains(x.Id)); - //var courseScenes = await _ghre_CourseSceneServices.Query(x => linkIds.Contains(x.Id)); - - //data1.ForEach(async x => - //{ - // try - // { - // x.ScoreMethodLabel = await GetParaLabel("ScoreMethod", x.ScoreMethod); - // x.TotalScore1 = Regex.Replace(x.PassScore.ToString(), @"\.(0+)$", "") + "/" + Regex.Replace(x.TotalScore.ToString(), @"\.(0+)$", ""); - // x.SetMethodLabel = await GetParaLabel("SetMethod", x.SetMethod); - - // if (x.LinkType == "CourseId") - // x.CourseName = courses.FirstOrDefault(o => o.Id == x.LinkId)?.CourseName; - // else if (x.LinkType == "CourseSceneId") - // x.CourseName = courseScenes.FirstOrDefault(o => o.Id == x.LinkId)?.SceneName; - // } - // catch (Exception) - // { - - // } - - //}); - - return new ServicePageResult(body.pageNum, data.result.DT_TablePageInfoT1.TotalCount, body.pageSize, data1); + dynamic return1 = new ExpandoObject(); + dynamic result = new ExpandoObject(); + dynamic DT_TablePageInfoT1 = new ExpandoObject(); + + result.DT_TableDataT1 = data.result.DT_TableDataT1; + DT_TablePageInfoT1.PageNum = body.pageNum; + DT_TablePageInfoT1.PageSize = body.pageSize; + DT_TablePageInfoT1.TotalCount = data.result.DT_TablePageInfoT1.TotalCount; + result.DT_TablePageInfoT1 = DT_TablePageInfoT1; + dynamic CardConfig = new ExpandoObject(); + CardConfig.cardTitle = "ExamName"; + CardConfig.cardImage = "CoverUrl"; + CardConfig.column1 = "AfterHowLongLabel"; + CardConfig.column1Icon = "ghr-form-designer-deteSelect"; + CardConfig.column2 = "CourseName"; + CardConfig.column2Icon = "ghr-exam-paper"; + CardConfig.column3 = "ExamModeLabel"; + CardConfig.column3Icon = "ghr-online-exam"; + CardConfig.column4 = "OpenClassName"; + CardConfig.column4Icon = "ghr-link-openClass"; + CardConfig.column5 = ""; + CardConfig.column5Icon = ""; + CardConfig.column6 = ""; + CardConfig.column6Icon = ""; + result.CardConfig = CardConfig; + + + return1.result = result; + return1.message = "查询成功!"; + return1.Success = true; + return1.code = 0; + return1.type = "success"; + return return1; } - public async Task> QueryFilterPage1(QueryBody filter, string status = null) + public async Task> QueryFilterPage1(QueryBody filter, string status = null) { + RefAsync totalCount = 0; + string sql = @"SELECT * + FROM (SELECT A.*, + B.CourseName, + C.Id CourseTypeId, + C.ClassName CourseType + FROM Ghre_Exam A + LEFT JOIN Ghre_Course B ON A.CourseId = B.Id + LEFT JOIN Ghre_CourseClass C ON B.CourseClassId = C.Id + WHERE A.IsEnable = 1) A"; + if (string.IsNullOrWhiteSpace(filter.orderBy)) filter.orderBy = "CreateTime DESC"; - RefAsync totalCount = 0; - var query = Db.Queryable(); - if (!string.IsNullOrWhiteSpace(status)) - query = query.Where(x => x.Status == status); + string conditions = "1=1"; if (filter.jsonParam != null) foreach (JProperty jProperty in filter.jsonParam.Properties()) @@ -234,6 +252,7 @@ public class Ghre_ExamServices : BaseServices(value); @@ -265,12 +284,17 @@ public class Ghre_ExamServices : BaseServices(sql) + .OrderBy(filter.orderBy) .ToPageListAsync(filter.pageNum, filter.pageSize, totalCount); - return new ServicePageResult(filter.pageNum, totalCount, filter.pageSize, list); + //data.ForEach(async x => + //{ + // x.DifficultyLevelLabel = await GetParaLabel("DifficultyLevel", x.DifficultyLevel); + // x.QuestionTypeLabel = await GetParaLabel("QuestionType", x.QuestionType); + //}); + + return new ServicePageResult(filter.pageNum, totalCount, filter.pageSize, data); } @@ -460,7 +484,22 @@ public class Ghre_ExamServices : BaseServices(); + var pageData = Mapper.Map(exam).ToANew(); + + if (pageData.AfterHowLong != 7 && pageData.AfterHowLong != 15 && pageData.AfterHowLong != 30) + { + pageData.AfterHowLong1 = pageData.AfterHowLong; + pageData.AfterHowLong = 0; + } + if (pageData.DateType == "ExamDate") pageData.ExamDate.Add(pageData.BeginTime.Value.ToString("yyyy/MM/dd")); + if (pageData.DateType == "ExamDate") pageData.ExamDate.Add(pageData.EndTime.Value.ToString("yyyy/MM/dd")); + input.pageData = pageData; + + var staffs = await _ghre_ExamStaffServices.Query(x => x.ExamId == Id); + + var ids = staffs.Select(x => Convert.ToInt32(x.StaffId)).ToList(); + var staffTableData = await QueryStaff(ids, null); + pageData.staffTableData = staffTableData.Data; } #endregion @@ -484,8 +523,10 @@ public class Ghre_ExamServices : BaseServices Ids.Contains(x.StaffID)); + if (Ids.Any()) + sql += $"AND StaffID IN({string.Join(",", Ids)}) "; + else sql += "AND 1!=1 "; + //var list = await _ghra_StaffSceneServices.Query(x => Ids.Contains(x.StaffID)); var data = Db.Ado.SqlQuery(sql); //var data = list.Select(x => new StaffTableData() @@ -498,4 +539,50 @@ public class Ghre_ExamServices : BaseServices>.OprateSuccess("查询成功!", data); } + public async Task> Insert1(long id, DefaultGhre_ExamPageData pageData) + { + if (pageData.DateType == "ExamDate") + { + pageData.BeginTime = Convert.ToDateTime(pageData.ExamDate[0]); + pageData.EndTime = Convert.ToDateTime(pageData.ExamDate[1]); + } + if (pageData.AfterHowLong == 0) + pageData.AfterHowLong = pageData.AfterHowLong1; + + if (id == 0) + { + + pageData.Status = "Draft"; + var insert = Mapper.Map(pageData).ToANew(); + id = await base.Add(insert); + + var insertStaffs = pageData.staffTableData.Select(x => new InsertGhre_ExamStaffInput() + { + ExamId = id, + StaffId = x.StaffID, + Source = x.DataSource + }).ToList(); + + await _ghre_ExamStaffServices.Add(insertStaffs); + + return ServiceResult.OprateSuccess("添加成功!", id); + } + else + { + var insert = Mapper.Map(pageData).ToANew(); + await base.Update(id, insert); + await _ghre_ExamStaffServices.Delete(x => x.ExamId == id); + var insertStaffs = pageData.staffTableData.Select(x => new InsertGhre_ExamStaffInput() + { + ExamId = id, + StaffId = x.StaffID, + Source = x.DataSource + }).ToList(); + + await _ghre_ExamStaffServices.Add(insertStaffs); + + return ServiceResult.OprateSuccess("修改成功!", id); + } + } + } \ No newline at end of file diff --git a/Tiobon.Core/Tiobon.Core.xml b/Tiobon.Core/Tiobon.Core.xml index ebaf4ec6..287de0fc 100644 --- a/Tiobon.Core/Tiobon.Core.xml +++ b/Tiobon.Core/Tiobon.Core.xml @@ -603,8 +603,29 @@ 条件 - - + + + 查询明细数据 + + id + + + + + 根据员工ID查询员工数据 + + Ids + type + + + + + 新增 + + id + pageData + + 试卷配置(Controller)