From 19bec64e17ca24c4b55b12242ebb248ae3c155e7 Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Tue, 13 May 2025 14:59:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=AF=BE=E7=A8=8B=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E5=9C=BA=E6=99=AF=E5=88=86=E6=9E=90=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Ghre/Ghre_CourseController.cs | 13 +++ Tiobon.Core.Api/Tiobon.Core.xml | 7 ++ .../Ghre/IGhre_CourseServices.cs | 3 + .../ViewModels/Extend/CourseAndScene.cs | 9 ++ Tiobon.Core.Services/CommonServices.cs | 1 + .../Ghre/Ghre_CourseServices.cs | 103 +++++++++++++++++- Tiobon.Core/Tiobon.Core.xml | 7 ++ 7 files changed, 142 insertions(+), 1 deletion(-) create mode 100644 Tiobon.Core.Model/ViewModels/Extend/CourseAndScene.cs diff --git a/Tiobon.Core.Api/Controllers/Ghre/Ghre_CourseController.cs b/Tiobon.Core.Api/Controllers/Ghre/Ghre_CourseController.cs index c0169e8c..538d9627 100644 --- a/Tiobon.Core.Api/Controllers/Ghre/Ghre_CourseController.cs +++ b/Tiobon.Core.Api/Controllers/Ghre/Ghre_CourseController.cs @@ -1,4 +1,5 @@ using StackExchange.Profiling.Data; +using Tiobon.Core.Model.ViewModels.Extend; namespace Tiobon.Core.Api.Controllers; @@ -103,4 +104,16 @@ public class Ghre_CourseController : BaseController + /// 统计 + /// + /// + /// + [HttpPost("QueryCourseAndScene")] + public async Task> QueryCourseAndScene([FromBody] QueryBody filter) + { + return await _service.QueryCourseAndScene(filter); + } } \ No newline at end of file diff --git a/Tiobon.Core.Api/Tiobon.Core.xml b/Tiobon.Core.Api/Tiobon.Core.xml index b08cf52d..6f86fb91 100644 --- a/Tiobon.Core.Api/Tiobon.Core.xml +++ b/Tiobon.Core.Api/Tiobon.Core.xml @@ -813,6 +813,13 @@ + + + 统计 + + + + 课程场景(Controller) diff --git a/Tiobon.Core.IServices/Ghre/IGhre_CourseServices.cs b/Tiobon.Core.IServices/Ghre/IGhre_CourseServices.cs index d76e140e..a0c75960 100644 --- a/Tiobon.Core.IServices/Ghre/IGhre_CourseServices.cs +++ b/Tiobon.Core.IServices/Ghre/IGhre_CourseServices.cs @@ -2,6 +2,7 @@ using Tiobon.Core.IServices.BASE; using Tiobon.Core.Model; using Tiobon.Core.Model.Models; +using Tiobon.Core.Model.ViewModels.Extend; namespace Tiobon.Core.IServices; @@ -28,4 +29,6 @@ public interface IGhre_CourseServices : IBaseServices ModifyCourseSortNo(List courses); Task QueryStatistic(long id); + + Task> QueryCourseAndScene(QueryBody filter); } \ No newline at end of file diff --git a/Tiobon.Core.Model/ViewModels/Extend/CourseAndScene.cs b/Tiobon.Core.Model/ViewModels/Extend/CourseAndScene.cs new file mode 100644 index 00000000..5d1b21e5 --- /dev/null +++ b/Tiobon.Core.Model/ViewModels/Extend/CourseAndScene.cs @@ -0,0 +1,9 @@ +namespace Tiobon.Core.Model.ViewModels.Extend; + +public class CourseAndScene +{ + public long Id { get; set; } + public string CourseNo { get; set; } + public string Type { get; set; } + public string CourseName { get; set; } +} diff --git a/Tiobon.Core.Services/CommonServices.cs b/Tiobon.Core.Services/CommonServices.cs index 2a055687..c77cc156 100644 --- a/Tiobon.Core.Services/CommonServices.cs +++ b/Tiobon.Core.Services/CommonServices.cs @@ -859,6 +859,7 @@ public partial class CommonServices : BaseServices>, ICommon switch (param.menuName) { case "F_SurveyQuestionPool": + case "F_Training_CourseAndScene_Report": case "F_QuestionBank": toolbar = result.JM_PageControlT1.Toolbar.Where(x => x.fnKey == "NewYN").FirstOrDefault(); if (toolbar != null) { toolbar.fnKey = "TBD1YN"; } diff --git a/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs b/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs index 62e79eb5..ebe123e4 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs @@ -1,5 +1,4 @@ using NPOI.SS.UserModel; -using Tiobon.Core.IServices; using static Tiobon.Core.Model.Consts; namespace Tiobon.Core.Services; @@ -1314,6 +1313,108 @@ public class Ghre_CourseServices : BaseServices> QueryCourseAndScene(QueryBody filter) + { + RefAsync totalCount = 0; + string sql = @"SELECT Id, + CourseNo, + CourseName, + Type from Ghre_CourseScene_V A"; + + if (string.IsNullOrWhiteSpace(filter.orderBy)) + filter.orderBy = "CourseNo ASC"; + + string conditions = " WHERE 1=1"; + + + + if (filter.jsonParam != null) + foreach (JProperty jProperty in filter.jsonParam.Properties()) + { + var name = jProperty.Name; + var value = jProperty.Value.ToString(); + if (name == "page" || name == "pageSize") + continue; + + if (!string.IsNullOrWhiteSpace(value)) + { + var jsonParam = JsonConvert.DeserializeObject(value); + + if (name == "CourseNoOrName") + { + conditions += $" AND ( CourseNo LIKE '%{jsonParam.columnValue}%' OR CourseName LIKE '%{jsonParam.columnValue}%')"; + continue; + } + + switch (jsonParam.operationKey) + { + case "Include": + conditions += $" AND {name} LIKE '%{jsonParam.columnValue}%'"; + break; + case "NotInclude": + conditions += $" AND {name} NOT LIKE '%{jsonParam.columnValue}%'"; + break; + case "IsNull": + conditions += $" AND {name} IS NULL"; + break; + case "NotNull": + conditions += $" AND {name} IS NOT NULL"; + break; + case "Equal": + conditions += $" AND {name} ='{jsonParam.columnValue}'"; + break; + case "NotEqual": + conditions += $" AND {name} !='{jsonParam.columnValue}'"; + break; + case "GreaterOrEqual"://大于等于 + conditions += $" AND {name} >='{jsonParam.columnValue}'"; + break; + case "Greater"://大于 + conditions += $" AND {name} >'{jsonParam.columnValue}'"; + break; + case "LessOrEqual"://小于等于 + conditions += $" AND {name} <='{jsonParam.columnValue}'"; + break; + case "Less"://小于 + conditions += $" AND {name} <'{jsonParam.columnValue}'"; + break; + case "EqualAny":// + if (jsonParam.columnValue != null) + { + var ids1 = JsonHelper.JsonToObj>(jsonParam.columnValue.ToString()); + + conditions += $" AND {name} IN ({string.Join(",", ids1.Select(id => "'" + id + "'"))})"; + } + break; + case "NotEqualAny":// + if (jsonParam.columnValue != null) + { + var ids1 = JsonHelper.JsonToObj>(jsonParam.columnValue.ToString()); + + conditions += $" AND ({name} NOT IN ({string.Join(",", ids1.Select(id => "'" + id + "'"))}) OR {name} IS NULL)"; + } + break; + default: + break; + } + } + } + if (filter.pageSize == 0) + filter.pageSize = 10000; + sql += conditions; + + var sql1 = GetQueryString(sql, filter.pageNum, filter.pageSize, filter.orderBy); + + var data = DbAccess.QueryList(sql1); + + totalCount = await Db.Ado.GetIntAsync("SELECT COUNT(0) from Ghre_CourseScene_V A WHERE 1=1"); + + + return new ServicePageResult(filter.pageNum, totalCount, filter.pageSize, data); + } + #endregion + #region 课程统计 /// /// 课程统计 diff --git a/Tiobon.Core/Tiobon.Core.xml b/Tiobon.Core/Tiobon.Core.xml index b08cf52d..6f86fb91 100644 --- a/Tiobon.Core/Tiobon.Core.xml +++ b/Tiobon.Core/Tiobon.Core.xml @@ -813,6 +813,13 @@ + + + 统计 + + + + 课程场景(Controller)