试卷停用后,停用课程;重新启用试卷时,校验试卷关联的课程是否 已停用。

master
xiaochanghai 12 months ago
parent 43f23473e6
commit 7c0e628fd1
  1. 12
      Tiobon.Core.Api/Controllers/Ghre/Ghre_CourseController.cs
  2. 7
      Tiobon.Core.Api/Controllers/Ghre/Ghre_ExamController.cs
  3. 7
      Tiobon.Core.Api/Controllers/Ghre/Ghre_ExamPaperController.cs
  4. 1
      Tiobon.Core.Common/Attribute/QueryFilter.cs
  5. 4
      Tiobon.Core.IServices/Ghre/IGhre_CourseServices.cs
  6. 4
      Tiobon.Core.IServices/Ghre/IGhre_ExamPaperServices.cs
  7. 2
      Tiobon.Core.IServices/Ghre/IGhre_ExamServices.cs
  8. 9
      Tiobon.Core.Services/BASE/BaseServices.cs
  9. 6
      Tiobon.Core.Services/CommonServices.cs
  10. 60
      Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs
  11. 63
      Tiobon.Core.Services/Ghre/Ghre_ExamPaperServices.cs
  12. 73
      Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs
  13. 2
      Tiobon.Core.Services/Ghre/Ghre_QuestionServices.cs

@ -1,4 +1,6 @@
namespace Tiobon.Core.Api.Controllers;
using StackExchange.Profiling.Data;
namespace Tiobon.Core.Api.Controllers;
/// <summary>
/// 课程(Controller)
@ -22,7 +24,7 @@ public class Ghre_CourseController : BaseController<IGhre_CourseServices, Ghre_C
[HttpPost, Route("QueryList/{status}")]
public async Task<ServicePageResult<Ghre_CourseDto>> QueryList(string status, [FromBody] QueryBody body)
{
return await _service.QueryList(body, status);
return await _service.QueryList(body, status, null);
}
[HttpPost, Route("QueryDeptID/{StaffID}")]
@ -60,4 +62,10 @@ public class Ghre_CourseController : BaseController<IGhre_CourseServices, Ghre_C
}
#endregion
[HttpPost, Route("ExportExcel/{status}")]
public async Task<ServiceResult<string>> ExportExcel([FromBody] QueryExport body, string status)
{
return await _service.ExportExcel(body, status);
}
}

@ -167,4 +167,11 @@ public class Ghre_ExamController : BaseController<IGhre_ExamServices, Ghre_Exam,
}
#endregion
[HttpPost, Route("ExportExcel/{status}")]
public async Task<ServiceResult<string>> ExportExcel([FromBody] QueryExport body, string status)
{
return await _service.ExportExcel(body, status);
}
}

@ -105,4 +105,11 @@ public class Ghre_ExamPaperController : BaseController<IGhre_ExamPaperServices,
return await _service.GetSelectAsync(linkId, KeyWords);
}
#endregion
[HttpPost, Route("ExportExcel/{status}")]
public async Task<ServiceResult<string>> ExportExcel([FromBody] QueryExport body, string status)
{
return await _service.ExportExcel(body, status);
}
}

@ -144,6 +144,7 @@ public class QueryExportField
public List<string> ExFields { get; set; }
public string IsTitle { get; set; }
public string TitleName { get; set; }
public List<long> SelectRowKeys { get; set; }
}

@ -11,12 +11,14 @@ namespace Tiobon.Core.IServices
public interface IGhre_CourseServices : IBaseServices<Ghre_Course, Ghre_CourseDto, InsertGhre_CourseInput, EditGhre_CourseInput>
{
Task<ServicePageResult<Ghre_CourseDto>> QueryList(QueryBody filter, string status);
Task<ServicePageResult<Ghre_CourseDto>> QueryList(QueryBody filter, string status, List<long> ids);
Task<ServiceResult<int>> QueryDeptID(int StaffID);
Task<ServiceResult<CommonSelect>> QueryTeacher(long? linkId);
Task<ServiceResult> UpdateStatus(long[] ids, string status);
Task<ServiceResult<CommonSelect>> GetSelectAsync(long? linkId, string keyWords);
Task<ServiceResult<string>> ExportExcel(QueryExport body, string status);
}
}

@ -19,8 +19,10 @@ namespace Tiobon.Core.IServices
Task<ServiceResult> UpdateStatus(long[] ids, string status);
Task<ServicePageResult<Ghre_ExamPaperDto>> QueryList(QueryBody body, string status);
Task<ServicePageResult<Ghre_ExamPaperDto>> QueryList(QueryBody body, string status, List<long> ids = null);
Task<ServiceResult<CommonSelect>> GetSelectAsync(long? linkId, string KeyWords);
Task<ServiceResult<string>> ExportExcel(QueryExport body, string status);
}
}

@ -30,5 +30,7 @@ namespace Tiobon.Core.IServices
Task<ServiceResult<Ghre_ExamMessageLogDto>> QueryMessageLog(long id);
Task<ServiceResult> InsertMessageLog(Ghre_ExamMessageLogDto insert);
Task<ServiceResult<string>> ExportExcel(QueryExport body, string status);
}
}

@ -819,14 +819,19 @@ public class BaseServices<TEntity, TEntityDto, TInsertDto, TEditDto> : IBaseServ
filter.pageNum = 1;
filter.pageSize = 1000000;
filter.langId = body.langId;
var data = await QueryFilterPage(filter);
var condition = "1=1";
if (body.exportSet.SelectRowKeys != null && body.exportSet.SelectRowKeys.Any())
condition += $" AND Id IN({string.Join(",", body.exportSet.SelectRowKeys)})";
var data = await QueryFilterPage(filter, condition);
string sql = $@"SELECT *
FROM Ghrs_PageSettingQuery
WHERE IsEnable = 1
AND PageNo = '{body.menuName}'
AND defaultHidden = 'false'
AND (defaultHidden = 'false' OR defaultHidden is null)
ORDER BY SortNo ASC";
var columns = await Db.Ado.SqlQueryAsync<QueryExportColumn>(sql);

@ -901,6 +901,7 @@ public partial class CommonServices : BaseServices<RootEntityTkey<int>>, ICommon
icon = "ghr-preview",
position = "left"
});
result.DT_Procedure.ExportExcel = "/api/Ghre_ExamPaper/ExportExcel/Draft";
break;
case "F_ExamPaperReleased":
@ -935,6 +936,7 @@ public partial class CommonServices : BaseServices<RootEntityTkey<int>>, ICommon
position = "left"
});
result.DT_Procedure.ExportExcel = "/api/Ghre_ExamPaper/ExportExcel/Released";
break;
case "F_ExamPaperDisabled":
toolbar = result.JM_PageControlT1.Toolbar.Where(x => x.fnKey == "DetailYN").FirstOrDefault();
@ -958,6 +960,7 @@ public partial class CommonServices : BaseServices<RootEntityTkey<int>>, ICommon
icon = "ghr-preview",
position = "left"
});
result.DT_Procedure.ExportExcel = "/api/Ghre_ExamPaper/ExportExcel/Disabled";
break;
case "F_Training_CoursewWare":
toolbar = result.JM_PageControlT1.Toolbar.Where(x => x.fnKey == "NewYN").FirstOrDefault();
@ -1001,6 +1004,7 @@ public partial class CommonServices : BaseServices<RootEntityTkey<int>>, ICommon
if (toolbar != null) { toolbar.fnKey = "TBD3YN"; }
toolbar = result.JM_PageControlT1.Toolbar.Where(x => x.fnKey == "DetailYN").FirstOrDefault();
if (toolbar != null) { toolbar.fnKey = "TBD5YN"; }
result.DT_Procedure.ExportExcel = "/api/Ghre_Course/ExportExcel/Draft";
break;
case "F_Training_Course_Released":
@ -1022,6 +1026,7 @@ public partial class CommonServices : BaseServices<RootEntityTkey<int>>, ICommon
icon = "ghr-icon-stop",
position = "left"
});
result.DT_Procedure.ExportExcel = "/api/Ghre_Course/ExportExcel/Released";
break;
case "F_Training_Course_Disabled":
@ -1035,6 +1040,7 @@ public partial class CommonServices : BaseServices<RootEntityTkey<int>>, ICommon
icon = "ghr-icon-stop",
position = "left"
});
result.DT_Procedure.ExportExcel = "/api/Ghre_Course/ExportExcel/Disabled";
break;

@ -9,15 +9,11 @@ using Tiobon.Core.Model;
using Newtonsoft.Json.Linq;
using SqlSugar;
using Newtonsoft.Json;
using MySqlX.XDevAPI.Common;
using System.Data;
using System.Dynamic;
using Tiobon.Core.Common.DB.Dapper.Extensions;
using AgileObjects.AgileMapper;
using Microsoft.AspNetCore.Http;
using Tiobon.Core.Common.UserManager;
using Tiobon.Core.Common.Helper;
using static Microsoft.Extensions.Logging.EventSource.LoggingEventSource;
using Org.BouncyCastle.Crypto;
namespace Tiobon.Core.Services;
@ -125,7 +121,7 @@ public class Ghre_CourseServices : BaseServices<Ghre_Course, Ghre_CourseDto, Ins
}
public async Task<ServicePageResult<Ghre_CourseDto>> QueryList(QueryBody filter, string status)
public async Task<ServicePageResult<Ghre_CourseDto>> QueryList(QueryBody filter, string status, List<long> ids)
{
RefAsync<int> totalCount = 0;
string sql = @"SELECT *
@ -161,6 +157,9 @@ public class Ghre_CourseServices : BaseServices<Ghre_Course, Ghre_CourseDto, Ins
if (!string.IsNullOrWhiteSpace(status))
conditions += $" AND Status ='{status}'";
if (ids != null && ids.Any())
conditions += $" AND Id IN({string.Join(",", ids)})";
if (filter.jsonParam != null)
foreach (JProperty jProperty in filter.jsonParam.Properties())
@ -430,4 +429,53 @@ public class Ghre_CourseServices : BaseServices<Ghre_Course, Ghre_CourseDto, Ins
return new ServiceResult<CommonSelect>() { Success = true, Message = "查询成功", Data = result, };
}
#endregion
public async Task<ServiceResult<string>> ExportExcel(QueryExport body, string status)
{
QueryBody filter = new QueryBody();
filter.pageNum = 1;
filter.pageSize = 1000000;
filter.langId = body.langId;
var condition = "1=1";
var ids = new List<long>();
if (body.exportSet.SelectRowKeys != null && body.exportSet.SelectRowKeys.Any())
ids = body.exportSet.SelectRowKeys;
var data = await QueryList(filter, status, ids);
string sql = $@"SELECT *
FROM Ghrs_PageSettingQuery
WHERE IsEnable = 1
AND PageNo = '{body.menuName}'
AND (defaultHidden = 'false' or defaultHidden is null)
ORDER BY SortNo ASC";
var columns = await Db.Ado.SqlQueryAsync<QueryExportColumn>(sql);
var fieldDescs = new Dictionary<string, string>();
if (body.exportSet.ExFields.Any())
body.exportSet.ExFields.ForEach(x =>
{
if (columns.Any(o => o.field == x))
fieldDescs.Add(x, columns.FirstOrDefault(o => o.field == x)?.label);
});
else
fieldDescs = columns.ToDictionary(item => item.field, item => item.label);
var dt = ToDataTable(data.result.DT_TableDataT1, fieldDescs, null);
// 获取所有列名
var dtColumns = dt.Columns;
var id = SnowFlakeSingle.instance.getID();
var physicsPath = $"{Environment.CurrentDirectory}{Path.DirectorySeparatorChar}wwwroot";
var path = $"{$"{Path.DirectorySeparatorChar}files{Path.DirectorySeparatorChar}export{Path.DirectorySeparatorChar}{id}{Path.DirectorySeparatorChar}"}";
if (!Directory.Exists(physicsPath + path))
Directory.CreateDirectory(physicsPath + path);
path = path + body.exportSet.TitleName + ".xlsx";
NPOIHelper.ExportExcel(dt, null, "sheet1", physicsPath + path);
return ServiceResult<string>.OprateSuccess("导出成功", path);
}
}

@ -3,14 +3,12 @@ using System.Data;
using System.Net;
using System.Text.RegularExpressions;
using AgileObjects.AgileMapper;
using MathNet.Numerics.Distributions;
using Microsoft.AspNetCore.Http;
using MongoDB.Driver.Linq;
using Newtonsoft.Json.Linq;
using SqlSugar;
using Tiobon.Core.Common;
using Tiobon.Core.Common.Caches;
using Tiobon.Core.Common.DB.Dapper.Extensions;
using Tiobon.Core.Common.Helper;
using Tiobon.Core.Common.UserManager;
using Tiobon.Core.IRepository.Base;
@ -104,9 +102,13 @@ public class Ghre_ExamPaperServices : BaseServices<Ghre_ExamPaper, Ghre_ExamPape
// return new ServicePageResult<Ghre_ExamPaperDto>(body.pageNum, data.result.DT_TablePageInfoT1.TotalCount, body.pageSize, data1);
//}
public async Task<ServicePageResult<Ghre_ExamPaperDto>> QueryList(QueryBody body, string status)
public async Task<ServicePageResult<Ghre_ExamPaperDto>> QueryList(QueryBody body, string status, List<long> ids = null)
{
var data = await base.QueryFilterPage(body, $"Status='{status}'");
var condition = $"Status='{status}'";
if (ids != null && ids.Any())
condition += $" AND Id IN({string.Join(",", ids)})";
var data = await base.QueryFilterPage(body, condition);
var data1 = Mapper.Map(data.result.DT_TableDataT1).ToANew<List<Ghre_ExamPaperDto>>();
var linkIds = data1.Where(x => x.LinkId != null).Select(x => x.LinkId.Value).Distinct().ToList();
@ -136,6 +138,53 @@ public class Ghre_ExamPaperServices : BaseServices<Ghre_ExamPaper, Ghre_ExamPape
return new ServicePageResult<Ghre_ExamPaperDto>(body.pageNum, data.result.DT_TablePageInfoT1.TotalCount, body.pageSize, data1);
}
public async Task<ServiceResult<string>> ExportExcel(QueryExport body, string status)
{
QueryBody filter = new QueryBody();
filter.pageNum = 1;
filter.pageSize = 1000000;
filter.langId = body.langId;
var ids = new List<long>();
if (body.exportSet.SelectRowKeys != null && body.exportSet.SelectRowKeys.Any())
ids = body.exportSet.SelectRowKeys;
var data = await QueryList(filter, status, ids);
string sql = $@"SELECT *
FROM Ghrs_PageSettingQuery
WHERE IsEnable = 1
AND PageNo = '{body.menuName}'
AND (defaultHidden = 'false' or defaultHidden is null)
ORDER BY SortNo ASC";
var columns = await Db.Ado.SqlQueryAsync<QueryExportColumn>(sql);
var fieldDescs = new Dictionary<string, string>();
if (body.exportSet.ExFields.Any())
body.exportSet.ExFields.ForEach(x =>
{
if (columns.Any(o => o.field == x))
fieldDescs.Add(x, columns.FirstOrDefault(o => o.field == x)?.label);
});
else
fieldDescs = columns.ToDictionary(item => item.field, item => item.label);
var dt = ToDataTable(data.result.DT_TableDataT1, fieldDescs, null);
// 获取所有列名
var dtColumns = dt.Columns;
var id = SnowFlakeSingle.instance.getID();
var physicsPath = $"{Environment.CurrentDirectory}{Path.DirectorySeparatorChar}wwwroot";
var path = $"{$"{Path.DirectorySeparatorChar}files{Path.DirectorySeparatorChar}export{Path.DirectorySeparatorChar}{id}{Path.DirectorySeparatorChar}"}";
if (!Directory.Exists(physicsPath + path))
Directory.CreateDirectory(physicsPath + path);
path = path + body.exportSet.TitleName + ".xlsx";
NPOIHelper.ExportExcel(dt, null, "sheet1", physicsPath + path);
return ServiceResult<string>.OprateSuccess("导出成功", path);
}
//public async Task<ServicePageResult<Ghre_ExamPaper>> QueryFilterPage1(QueryBody filter, string status = null)
//{
// if (string.IsNullOrWhiteSpace(filter.orderBy))
@ -774,6 +823,12 @@ delete from Ghre_ExamPaperQuestion WHERE ExamPaperId='{id}';");
if (status == "Released" && entity.Status != "Released")
{
if (entity.LinkType == "CourseId" && !await _ghre_CourseServices.AnyAsync(entity.LinkId))
return ServiceResult.OprateFailed($"试卷【{entity.PaperName}({entity.PaperNo})】,关联的课程,已被删除,请重新维护数据!");
if (entity.LinkType == "CourseSceneId" && !await _ghre_CourseSceneServices.AnyAsync(entity.LinkId))
return ServiceResult.OprateFailed($"试卷【{entity.PaperName}({entity.PaperNo})】,关联的课程场景,已被删除,请重新维护数据!");
string sql = @$"SELECT COUNT(0)
FROM Ghre_ExamPaperQuestion A
JOIN Ghre_Question B ON A.QuestionId = B.Id and B.IsEnable = 0

@ -15,6 +15,7 @@ using Microsoft.AspNetCore.Http;
using Tiobon.Core.Common.UserManager;
using MongoDB.Driver.Linq;
using Tiobon.Core.Common.DB.Dapper;
using Tiobon.Core.Common.Helper;
namespace Tiobon.Core.Services;
@ -393,6 +394,25 @@ public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhr
}
#endregion
switch (param.menuName)
{
case "F_ExamManageDraft":
DT_Procedure.ExportExcel = "/api/Ghre_Exam/ExportExcel/Draft";
break;
case "F_ExamManageReleased":
DT_Procedure.ExportExcel = "/api/Ghre_Exam/ExportExcel/Released";
break;
case "F_ExamManageDisabled":
DT_Procedure.ExportExcel = "/api/Ghre_Exam/ExportExcel/Disabled";
break;
}
data.Toolbar = Toolbar;
data.DT_Procedure = DT_Procedure;
data.SearchFormFields = SearchFormFields;
@ -449,7 +469,7 @@ public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhr
return return1;
}
public async Task<ServicePageResult<Ghre_ExamDto>> QueryFilterPage1(QueryBody filter, string status = null)
public async Task<ServicePageResult<Ghre_ExamDto>> QueryFilterPage1(QueryBody filter, string status = null, List<long> ids = null)
{
RefAsync<int> totalCount = 0;
string sql = @"SELECT *
@ -520,6 +540,9 @@ public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhr
if (!string.IsNullOrWhiteSpace(status))
conditions += $" AND Status ='{status}'";
if (ids != null && ids.Any())
conditions += $" AND Id IN({string.Join(",", ids)})";
sql += " WHERE " + conditions;
if (filter.pageSize == 0)
filter.pageSize = 10000;
@ -744,6 +767,54 @@ public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhr
}
public async Task<ServiceResult<string>> ExportExcel(QueryExport body, string status)
{
QueryBody filter = new QueryBody();
filter.pageNum = 1;
filter.pageSize = 1000000;
filter.langId = body.langId;
var ids = new List<long>();
if (body.exportSet.SelectRowKeys != null && body.exportSet.SelectRowKeys.Any())
ids = body.exportSet.SelectRowKeys;
var data = await QueryFilterPage1(filter, status, ids);
string sql = $@"SELECT *
FROM Ghrs_PageSettingQuery
WHERE IsEnable = 1
AND PageNo = '{body.menuName}'
AND (defaultHidden = 'false' or defaultHidden is null)
ORDER BY SortNo ASC";
var columns = await Db.Ado.SqlQueryAsync<QueryExportColumn>(sql);
var fieldDescs = new Dictionary<string, string>();
if (body.exportSet.ExFields.Any())
body.exportSet.ExFields.ForEach(x =>
{
if (columns.Any(o => o.field == x))
fieldDescs.Add(x, columns.FirstOrDefault(o => o.field == x)?.label);
});
else
fieldDescs = columns.ToDictionary(item => item.field, item => item.label);
var dt = ToDataTable(data.result.DT_TableDataT1, fieldDescs, null);
// 获取所有列名
var dtColumns = dt.Columns;
var id = SnowFlakeSingle.instance.getID();
var physicsPath = $"{Environment.CurrentDirectory}{Path.DirectorySeparatorChar}wwwroot";
var path = $"{$"{Path.DirectorySeparatorChar}files{Path.DirectorySeparatorChar}export{Path.DirectorySeparatorChar}{id}{Path.DirectorySeparatorChar}"}";
if (!Directory.Exists(physicsPath + path))
Directory.CreateDirectory(physicsPath + path);
path = path + body.exportSet.TitleName + ".xlsx";
NPOIHelper.ExportExcel(dt, null, "sheet1", physicsPath + path);
return ServiceResult<string>.OprateSuccess("导出成功", path);
}
public async Task<ServiceResult<DefaultGhre_ExamInput>> QueryDefault(long Id)
{
var input = new DefaultGhre_ExamInput();

@ -158,7 +158,7 @@ public class Ghre_QuestionServices : BaseServices<Ghre_Question, Ghre_QuestionDt
return new ServicePageResult<Ghre_QuestionDto>(filter.pageNum, data1.result.DT_TablePageInfoT1.TotalCount, filter.pageSize, data);
}
public override async Task<ServicePageResult<Ghre_QuestionDto>> QueryFilterPage(QueryBody filter)
public override async Task<ServicePageResult<Ghre_QuestionDto>> QueryFilterPage(QueryBody filter, string condition, bool? IsEnable = true)
{
RefAsync<int> totalCount = 0;

Loading…
Cancel
Save