diff --git a/Tiobon.Core.Api/Controllers/FileController.cs b/Tiobon.Core.Api/Controllers/FileController.cs index 09982839..d3f13feb 100644 --- a/Tiobon.Core.Api/Controllers/FileController.cs +++ b/Tiobon.Core.Api/Controllers/FileController.cs @@ -118,8 +118,6 @@ public class FileController : BaseApiController if (System.IO.File.Exists(webRootPath + filePath)) System.IO.File.Delete(webRootPath + filePath); - var file = await _ghre_AttachmentServices.Delete(x => x.AttachmentName == fileName); - #endregion using (var stream = global::System.IO.File.Create("wwwroot/" + filePath)) diff --git a/Tiobon.Core.Common/Helper/UtilHelper.cs b/Tiobon.Core.Common/Helper/UtilHelper.cs index a43235ce..ffd47b47 100644 --- a/Tiobon.Core.Common/Helper/UtilHelper.cs +++ b/Tiobon.Core.Common/Helper/UtilHelper.cs @@ -228,6 +228,27 @@ public static class UtilHelper } catch (Exception) { return null; } } + public static decimal? TrimDecimal(this decimal? value1, int reservedDigit) + { + try + { + var value = value1.TrimDecimalString(reservedDigit); + string result = string.Empty; + if (!string.IsNullOrEmpty(value)) + { + Decimal tmp = Decimal.Parse(value); + if (reservedDigit == -1) + result = string.Format("{0:#0.##########}", tmp); + else + { + result = String.Format("{0:N" + reservedDigit.ToString() + "}", tmp); + result = result.Replace(",", ""); + } + } + return Convert.ToDecimal(result); + } + catch (Exception) { return null; } + } #endregion /// diff --git a/Tiobon.Core.Services/CommonServices.cs b/Tiobon.Core.Services/CommonServices.cs index 85bfd202..a0a38fe0 100644 --- a/Tiobon.Core.Services/CommonServices.cs +++ b/Tiobon.Core.Services/CommonServices.cs @@ -1,5 +1,4 @@ using Microsoft.AspNetCore.Mvc; -using System.IO; using System.Text.RegularExpressions; namespace Tiobon.Core.Services; diff --git a/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs b/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs index c7c5da62..03df985a 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs @@ -1186,13 +1186,13 @@ public class Ghre_CourseServices : BaseServices 0) + data[i].AvgScore = data[i].AvgScore.TrimDecimal(2); + var examCount = await Db.Queryable() .Where(x => x.StudyRecordId != null && studyRecordIds.Contains(x.StudyRecordId.Value)) .CountAsync(); diff --git a/Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs b/Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs index 8a03c809..51cacefb 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs @@ -1401,11 +1401,20 @@ public class Ghre_ExamServices : BaseServices id != x).ToList(); if (entity.LinkType == DIC_EXAM_LINK_TYPE_COURSE) { + var ids1 = await Db.Queryable() + .Where(x => + x.Source == null && + x.Status == DIC_EXAM_STATUS.RELEASED && + x.CourseId == entity.CourseId && + x.Id != id) + .Select(x => x.Id).ToListAsync(); + #region 校验同一个课程下 考试时间不允许重叠 - var exams = await base.Query(x => (x.Source == null && x.Status == DIC_EXAM_STATUS.RELEASED && x.CourseId == entity.CourseId && x.Id != id) || ids1.Contains(x.Id)); + var exams = await base.Query(x => ( + x.Source == null && + x.Status == DIC_EXAM_STATUS.RELEASED && x.CourseId == entity.CourseId && x.Id != id) || ids1.Contains(x.Id)); if (exams.Any()) for (int i = 0; i < exams.Count; i++) { @@ -1428,6 +1437,13 @@ public class Ghre_ExamServices : BaseServices() + .Where(x => + x.Source == null && + x.Status == DIC_EXAM_STATUS.RELEASED && + x.CourseSceneId == entity.CourseSceneId && + x.Id != id) + .Select(x => x.Id).ToListAsync(); #region 校验同一个课程场景下 考试时间不允许重叠 var exams = await base.Query(x => (x.Source == null && x.Status == DIC_EXAM_STATUS.RELEASED && x.CourseSceneId == entity.CourseSceneId && x.Id != id) || ids1.Contains(x.Id)); if (exams.Any()) @@ -1468,11 +1484,11 @@ public class Ghre_ExamServices : BaseServices DeleteById1(object id) + { + return await DeleteByIds1([id.ObjToLong()]); + } + /// + /// 删除指定ID集合的数据(批量删除) + /// + /// 主键ID集合 + /// + public override async Task DeleteByIds1(long[] ids) + { + await Db.Updateable() + .SetColumns(it => new Ghre_Exam() { IsEnable = 0 }, true) + .Where(it => ids.Contains(it.Id)) + .ExecuteCommandAsync(); + + await Db.Updateable() + .SetColumns(it => new Ghre_StudyRecord() { ExamId = null }, true) + .Where(it => it.ExamId != null && ids.Contains(it.ExamId.Value)) + .ExecuteCommandAsync(); + + return true; + } + #endregion } \ No newline at end of file diff --git a/Tiobon.Core.Services/Ghre/Ghre_PlanServices.cs b/Tiobon.Core.Services/Ghre/Ghre_PlanServices.cs index 47616247..be6f67af 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_PlanServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_PlanServices.cs @@ -1,7 +1,5 @@ -using NPOI.SS.Formula.Functions; -using NPOI.SS.UserModel; +using NPOI.SS.UserModel; using NPOI.SS.Util; -using Tiobon.Core.Common; using static Tiobon.Core.Model.Consts; namespace Tiobon.Core.Services; diff --git a/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs b/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs index c09ce922..48810cb3 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs @@ -39,12 +39,12 @@ public class Ghre_StudyRecordServices : BaseServices().Where(x => x.DataPrivType == "Priv" && x.MenuNo == filter.menuName).AnyAsync()) { var staffIds = await GetUserStaffPrivIds((int)App.User.ID); if (staffIds.Any()) - conditions = $" WHERE ((BeginTime IS NOT NULL AND ( IsRequireStudy='true' OR IsRequireStudy IS NULL )) OR IsRequireStudy='false') AND StaffId IN ({string.Join(",", staffIds.Select(id => "'" + id + "'"))})"; + conditions = $" WHERE ((( IsRequireStudy='true' OR IsRequireStudy IS NULL )) OR IsRequireStudy='false') AND StaffId IN ({string.Join(",", staffIds.Select(id => "'" + id + "'"))})"; } if (IsEnable == true)