master
xiaochanghai 4 weeks ago
parent 0a146328e2
commit ac7d737947
  1. 2
      Tiobon.Core.Api/Controllers/FileController.cs
  2. 21
      Tiobon.Core.Common/Helper/UtilHelper.cs
  3. 1
      Tiobon.Core.Services/CommonServices.cs
  4. 15
      Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs
  5. 51
      Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs
  6. 4
      Tiobon.Core.Services/Ghre/Ghre_PlanServices.cs
  7. 4
      Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.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))

@ -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
/// <summary>

@ -1,5 +1,4 @@
using Microsoft.AspNetCore.Mvc;
using System.IO;
using System.Text.RegularExpressions;
namespace Tiobon.Core.Services;

@ -1186,13 +1186,13 @@ public class Ghre_CourseServices : BaseServices<Ghre_Course, Ghre_CourseDto, Ins
WHERE A.IsOpen = 1
AND A.IsEnable = 1
AND A.Status = '{DIC_COURSE_STATUS.RELEASED}') A";
if (await QueryCompanyCode() == "Ushio" && string.IsNullOrWhiteSpace(filter.orderBy))
{
filter.orderBy = "PublishTime DESC";
}
else
//if (await QueryCompanyCode() == "Ushio" && string.IsNullOrWhiteSpace(filter.orderBy))
//{
// filter.orderBy = "PublishTime DESC";
//}
//else
if (string.IsNullOrWhiteSpace(filter.orderBy))
filter.orderBy = "CourseName ASC";
filter.orderBy = "PublishTime DESC";
string conditions = " WHERE 1=1";
if (filter.jsonParam != null)
@ -1451,6 +1451,9 @@ public class Ghre_CourseServices : BaseServices<Ghre_Course, Ghre_CourseDto, Ins
data[i].AvgScore = data[i].AvgScore ?? 0;
if (data[i].AvgScore > 0)
data[i].AvgScore = data[i].AvgScore.TrimDecimal(2);
var examCount = await Db.Queryable<Ghre_ExamRecord>()
.Where(x => x.StudyRecordId != null && studyRecordIds.Contains(x.StudyRecordId.Value))
.CountAsync();

@ -1401,11 +1401,20 @@ public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhr
}
#endregion
var ids1 = ids.Where(x => id != x).ToList();
if (entity.LinkType == DIC_EXAM_LINK_TYPE_COURSE)
{
var ids1 = await Db.Queryable<Ghre_Exam>()
.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<Ghre_Exam, Ghre_ExamDto, InsertGhr
}
else
{
var ids1 = await Db.Queryable<Ghre_Exam>()
.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<Ghre_Exam, Ghre_ExamDto, InsertGhr
if (status == DIC_EXAM_STATUS.RELEASED || status == DIC_EXAM_STATUS.DISABLED || status == DIC_EXAM_STATUS.DRAFT)
{
entity.Status = status;
entities.Add(entity);
await BaseDal.Update(entity);
}
}
var result = await BaseDal.Update(entities);
//var result = await BaseDal.Update(entities);
if (status == DIC_EXAM_STATUS.RELEASED)
return ServiceResult.OprateSuccess("发布成功!");
else if (status == DIC_EXAM_STATUS.DRAFT)
@ -1924,4 +1940,31 @@ public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhr
//}
return ServiceResult.OprateSuccess("执行成功!");
}
#region 批量删除
public override async Task<bool> DeleteById1(object id)
{
return await DeleteByIds1([id.ObjToLong()]);
}
/// <summary>
/// 删除指定ID集合的数据(批量删除)
/// </summary>
/// <param name="ids">主键ID集合</param>
/// <returns></returns>
public override async Task<bool> DeleteByIds1(long[] ids)
{
await Db.Updateable<Ghre_Exam>()
.SetColumns(it => new Ghre_Exam() { IsEnable = 0 }, true)
.Where(it => ids.Contains(it.Id))
.ExecuteCommandAsync();
await Db.Updateable<Ghre_StudyRecord>()
.SetColumns(it => new Ghre_StudyRecord() { ExamId = null }, true)
.Where(it => it.ExamId != null && ids.Contains(it.ExamId.Value))
.ExecuteCommandAsync();
return true;
}
#endregion
}

@ -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;

@ -39,12 +39,12 @@ public class Ghre_StudyRecordServices : BaseServices<Ghre_StudyRecord, Ghre_Stud
var sql = @$" SELECT *
FROM Ghre_StudyRecord_V A";
string conditions = " WHERE ((BeginTime IS NOT NULL AND ( IsRequireStudy='true' OR IsRequireStudy IS NULL )) OR IsRequireStudy='false') ";
string conditions = " WHERE ((( IsRequireStudy='true' OR IsRequireStudy IS NULL )) OR IsRequireStudy='false') ";
if (await Db.Queryable<Ghrs_Menu>().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)

Loading…
Cancel
Save