From 6f47f2df92fbbb273b5c2024ca41465358aac6d3 Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Wed, 17 Jul 2024 10:03:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E5=B7=A5=E5=8F=B7=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E5=AD=A6=E5=88=86=E6=98=8E=E7=BB=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Ghre/Ghre_CreditPointController.cs | 12 ++ Tiobon.Core.Api/Tiobon.Core.Model.xml | 15 ++ .../Ghre/IGhre_CreditPointServices.cs | 8 +- .../Extend/Ghre_CreditPointTotal.cs | 24 ++++ .../Ghre/Ghre_CreditPointServices.cs | 131 +++++++++++++++++- 5 files changed, 184 insertions(+), 6 deletions(-) diff --git a/Tiobon.Core.Api/Controllers/Ghre/Ghre_CreditPointController.cs b/Tiobon.Core.Api/Controllers/Ghre/Ghre_CreditPointController.cs index df57b64b..8b97d32a 100644 --- a/Tiobon.Core.Api/Controllers/Ghre/Ghre_CreditPointController.cs +++ b/Tiobon.Core.Api/Controllers/Ghre/Ghre_CreditPointController.cs @@ -24,5 +24,17 @@ public class Ghre_CreditPointController : BaseController + /// 根据工号查询学分明细 + /// + /// + /// 员工ID + /// + [HttpPost("QueryDetail/{staffId}")] + public async Task> QueryDetail([FromBody] QueryBody body, string staffId) + { + return await _service.QueryDetail(body, staffId); + } + #endregion } \ No newline at end of file diff --git a/Tiobon.Core.Api/Tiobon.Core.Model.xml b/Tiobon.Core.Api/Tiobon.Core.Model.xml index 554eff7b..a153619b 100644 --- a/Tiobon.Core.Api/Tiobon.Core.Model.xml +++ b/Tiobon.Core.Api/Tiobon.Core.Model.xml @@ -12125,5 +12125,20 @@ 学分 + + + Id + + + + + + + + + + 学分 + + diff --git a/Tiobon.Core.IServices/Ghre/IGhre_CreditPointServices.cs b/Tiobon.Core.IServices/Ghre/IGhre_CreditPointServices.cs index cf872942..6037357d 100644 --- a/Tiobon.Core.IServices/Ghre/IGhre_CreditPointServices.cs +++ b/Tiobon.Core.IServices/Ghre/IGhre_CreditPointServices.cs @@ -8,7 +8,9 @@ namespace Tiobon.Core.IServices; /// /// 学分记录(自定义服务接口) /// - public interface IGhre_CreditPointServices :IBaseServices +public interface IGhre_CreditPointServices : IBaseServices { - Task> QueryTotal(QueryBody filter); - } \ No newline at end of file + Task> QueryTotal(QueryBody filter); + + Task> QueryDetail(QueryBody filter, string staffId); +} \ No newline at end of file diff --git a/Tiobon.Core.Model/ViewModels/Extend/Ghre_CreditPointTotal.cs b/Tiobon.Core.Model/ViewModels/Extend/Ghre_CreditPointTotal.cs index 90eb9a5c..f3be3d2d 100644 --- a/Tiobon.Core.Model/ViewModels/Extend/Ghre_CreditPointTotal.cs +++ b/Tiobon.Core.Model/ViewModels/Extend/Ghre_CreditPointTotal.cs @@ -54,3 +54,27 @@ public class Ghre_CreditPointTotal public string CreditPoints { get; set; } } + + + +public class Ghre_CreditPointDetail +{ + /// + /// Id + /// + public long Id { get; set; } + /// + /// + /// + public string Date { get; set; } + public string CourseClass { get; set; } + public string CourseScene { get; set; } + public string CoverUrl { get; set; } + public string CourseNo { get; set; } + public string CourseName { get; set; } + /// + /// 学分 + /// + + public string CreditPoints { get; set; } +} diff --git a/Tiobon.Core.Services/Ghre/Ghre_CreditPointServices.cs b/Tiobon.Core.Services/Ghre/Ghre_CreditPointServices.cs index 526a2c3d..67386bf8 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_CreditPointServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_CreditPointServices.cs @@ -55,7 +55,7 @@ public class Ghre_CreditPointServices : BaseServices(value); + var jsonParam = JsonConvert.DeserializeObject(value); switch (jsonParam.operationKey) { @@ -118,7 +118,7 @@ public class Ghre_CreditPointServices : BaseServices(filter.pageNum, totalCount, filter.pageSize, data); } + + public async Task> QueryDetail(QueryBody filter, string staffId) + { + RefAsync totalCount = 0; + string sql = @$"SELECT A.Id, + CONVERT (VARCHAR (100), A.[Date], 23) Date, + A.[Date] Date1, + A.CreditPoints, + B.CoverUrl, + B.CourseClass, + B.CourseScene, + B.CourseNo, + B.CourseName + FROM Ghre_CreditPoint A LEFT JOIN Ghre_CourseSnap B ON A.CourseSnapId = B.Id + WHERE A.StaffId = '{staffId}'"; + + if (string.IsNullOrWhiteSpace(filter.orderBy)) + filter.orderBy = "Date1 DESC"; + + string conditions = "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 (name == "Indate") + //{ + // var jsonParam = JsonConvert.DeserializeObject(value); + // conditions += $" AND (Indate BETWEEN '{jsonParam.columnValue[0]}' AND '{jsonParam.columnValue[1]}')"; + + // continue; + //} + if (name == "Date") + { + var jsonParam = JsonConvert.DeserializeObject(value); + conditions += $" AND (Date BETWEEN '{jsonParam.columnValue[0]}' AND '{jsonParam.columnValue[1]}')"; + + continue; + } + if (name == "CreditPoints") + { + var jsonParam = JsonConvert.DeserializeObject(value); + + switch (jsonParam.operationKey) + { + case "Include": + sql += $" WHERE {name} LIKE '%{jsonParam.columnValue}%'"; + break; + case "NotInclude": + sql += $" WHERE {name} NOT LIKE '%{jsonParam.columnValue}%'"; + break; + case "IsNull": + sql += $" WHERE {name} IS NULL"; + break; + case "NotNull": + sql += $" WHERE {name} IS NOT NULL"; + break; + case "Equal": + sql += $" WHERE {name} ='{jsonParam.columnValue}'"; + break; + case "NotEqual": + sql += $" WHERE {name} !='{jsonParam.columnValue}'"; + break; + case "GreaterOrEqual"://大于等于 + sql += $" WHERE {name} >='{jsonParam.columnValue}'"; + break; + case "Greater"://大于 + sql += $" WHERE {name} >'{jsonParam.columnValue}'"; + break; + case "LessOrEqual"://小于等于 + sql += $" WHERE {name} <='{jsonParam.columnValue}'"; + break; + case "Less"://小于 + sql += $" WHERE {name} <'{jsonParam.columnValue}'"; + break; + default: + break; + } + + continue; + } + + if (!string.IsNullOrWhiteSpace(value)) + { + var jsonParam = JsonConvert.DeserializeObject(value); + + 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; + default: + break; + } + } + } + + sql = string.Format(sql, conditions); + if (filter.pageSize == 0) + filter.pageSize = 10000; + var data = await Db.SqlQueryable(sql) + .OrderBy(filter.orderBy) + .ToPageListAsync(filter.pageNum, filter.pageSize, totalCount); + + return new ServicePageResult(filter.pageNum, totalCount, filter.pageSize, data); + } + } \ No newline at end of file