|
|
@ -3,14 +3,12 @@ using System.Data; |
|
|
|
using System.Net; |
|
|
|
using System.Net; |
|
|
|
using System.Text.RegularExpressions; |
|
|
|
using System.Text.RegularExpressions; |
|
|
|
using AgileObjects.AgileMapper; |
|
|
|
using AgileObjects.AgileMapper; |
|
|
|
using MathNet.Numerics.Distributions; |
|
|
|
|
|
|
|
using Microsoft.AspNetCore.Http; |
|
|
|
using Microsoft.AspNetCore.Http; |
|
|
|
using MongoDB.Driver.Linq; |
|
|
|
using MongoDB.Driver.Linq; |
|
|
|
using Newtonsoft.Json.Linq; |
|
|
|
using Newtonsoft.Json.Linq; |
|
|
|
using SqlSugar; |
|
|
|
using SqlSugar; |
|
|
|
using Tiobon.Core.Common; |
|
|
|
using Tiobon.Core.Common; |
|
|
|
using Tiobon.Core.Common.Caches; |
|
|
|
using Tiobon.Core.Common.Caches; |
|
|
|
using Tiobon.Core.Common.DB.Dapper.Extensions; |
|
|
|
|
|
|
|
using Tiobon.Core.Common.Helper; |
|
|
|
using Tiobon.Core.Common.Helper; |
|
|
|
using Tiobon.Core.Common.UserManager; |
|
|
|
using Tiobon.Core.Common.UserManager; |
|
|
|
using Tiobon.Core.IRepository.Base; |
|
|
|
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); |
|
|
|
// 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 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(); |
|
|
|
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); |
|
|
|
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) |
|
|
|
//public async Task<ServicePageResult<Ghre_ExamPaper>> QueryFilterPage1(QueryBody filter, string status = null) |
|
|
|
//{ |
|
|
|
//{ |
|
|
|
// if (string.IsNullOrWhiteSpace(filter.orderBy)) |
|
|
|
// if (string.IsNullOrWhiteSpace(filter.orderBy)) |
|
|
@ -774,6 +823,12 @@ delete from Ghre_ExamPaperQuestion WHERE ExamPaperId='{id}';"); |
|
|
|
|
|
|
|
|
|
|
|
if (status == "Released" && entity.Status != "Released") |
|
|
|
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)
|
|
|
|
string sql = @$"SELECT COUNT(0)
|
|
|
|
FROM Ghre_ExamPaperQuestion A |
|
|
|
FROM Ghre_ExamPaperQuestion A |
|
|
|
JOIN Ghre_Question B ON A.QuestionId = B.Id and B.IsEnable = 0 |
|
|
|
JOIN Ghre_Question B ON A.QuestionId = B.Id and B.IsEnable = 0 |
|
|
|