From 11ba8ff8ce35a9de0ef90be930d8c83d2424d805 Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Tue, 13 Aug 2024 15:32:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9F=B9=E8=AE=AD=E8=AE=B0=E5=BD=95=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=AD=A6=E4=B9=A0=E6=97=B6=E9=95=BF=E3=80=81?= =?UTF-8?q?=E8=80=83=E8=AF=95=E6=97=B6=E9=95=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Tiobon.Core.Api/Tiobon.Core.Model.xml | 5 +++ Tiobon.Core.Common/Helper/StringHelper.cs | 38 +++++++++++++++++++ .../View/Ghre/Ghre_StudyRecord.Dto.View.cs | 8 ++++ .../Ghre/Ghre_StudyRecordServices.cs | 7 ++++ Tiobon.Core/Tiobon.Core.Model.xml | 5 +++ 5 files changed, 63 insertions(+) diff --git a/Tiobon.Core.Api/Tiobon.Core.Model.xml b/Tiobon.Core.Api/Tiobon.Core.Model.xml index 2ab8fd93..cec28356 100644 --- a/Tiobon.Core.Api/Tiobon.Core.Model.xml +++ b/Tiobon.Core.Api/Tiobon.Core.Model.xml @@ -13272,6 +13272,11 @@ 必/选修人员 + + + 考试时长 + + 必选修规则(Dto.View) diff --git a/Tiobon.Core.Common/Helper/StringHelper.cs b/Tiobon.Core.Common/Helper/StringHelper.cs index 7c4feb22..3aed5e16 100644 --- a/Tiobon.Core.Common/Helper/StringHelper.cs +++ b/Tiobon.Core.Common/Helper/StringHelper.cs @@ -116,4 +116,42 @@ public class StringHelper return sid; } #endregion + + + + /// + /// 格式化数字字符,并保留指定的小数位 + /// + /// 需要处理的值 + /// 保留小数点后位数,-1时只会去除小数点后最后几位的0 + /// + public static string TrimNumber(decimal value, int reservedDigit) + { + try + { + string result = string.Empty; + if (!string.IsNullOrEmpty(Convert.ToString(value))) + { + //此处主要是为MVC页面中数字类型的字段作处理 + if (value != decimal.MinValue) + { + Decimal tmp = Decimal.Parse(Convert.ToString(value)); + if (reservedDigit == -1) + { + result = string.Format("{0:#0.##########}", tmp); + } + else + { + result = String.Format("{0:N" + reservedDigit.ToString() + "}", tmp); + result = result.Replace(",", ""); + } + } + } + return result; + } + catch (Exception E) + { + throw E; + } + } } diff --git a/Tiobon.Core.Model/View/Ghre/Ghre_StudyRecord.Dto.View.cs b/Tiobon.Core.Model/View/Ghre/Ghre_StudyRecord.Dto.View.cs index b6575358..24ea63e6 100644 --- a/Tiobon.Core.Model/View/Ghre/Ghre_StudyRecord.Dto.View.cs +++ b/Tiobon.Core.Model/View/Ghre/Ghre_StudyRecord.Dto.View.cs @@ -129,4 +129,12 @@ public class Ghre_StudyRecordDto : Ghre_StudyRecord /// 必/选修人员 /// public string StaffTypeLabel { get; set; } + + /// + /// 考试时长 + /// + public string ExamDuration { get; set; } + public DateTime? ActualEndTime { get; set; } + public DateTime? ActualBeginTime { get; set; } + } diff --git a/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs b/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs index a2b9ed9f..fe99006f 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs @@ -11,6 +11,7 @@ using Newtonsoft.Json; using Tiobon.Core.Common.Helper; using SqlSugar; using static Tiobon.Core.Model.Consts; +using Microsoft.IdentityModel.Tokens; namespace Tiobon.Core.Services { @@ -83,6 +84,12 @@ namespace Tiobon.Core.Services if (!string.IsNullOrWhiteSpace(entity.Indate)) entity.Indate = DateTimeHelper.ConvertToDayString(entity.Indate); entity.ExamDate = DateTimeHelper.ConvertToDayString(entity.ExamDate); + + if (entity.ActualBeginTime != null && entity.ActualEndTime != null) + { + TimeSpan timeDifference = entity.ActualEndTime.Value - entity.ActualBeginTime.Value; + entity.ExamDuration = StringHelper.TrimNumber(Convert.ToDecimal(timeDifference.TotalMinutes), 2); + } }); return new ServicePageResult(filter.pageNum, total, filter.pageSize, entitys); diff --git a/Tiobon.Core/Tiobon.Core.Model.xml b/Tiobon.Core/Tiobon.Core.Model.xml index 2ab8fd93..cec28356 100644 --- a/Tiobon.Core/Tiobon.Core.Model.xml +++ b/Tiobon.Core/Tiobon.Core.Model.xml @@ -13272,6 +13272,11 @@ 必/选修人员 + + + 考试时长 + + 必选修规则(Dto.View)