开班Ess端查询接口开发

开班Ess页面开发
master
xiaochanghai 4 months ago
parent 1fc7d871ab
commit 508bb62898
  1. 2
      Tiobon.Core.Api/Controllers/Ghre/Ghre_OpenClassController.cs
  2. 3
      Tiobon.Core.Services/CommonServices.cs
  3. 3
      Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs
  4. 10
      Tiobon.Core.Services/Ghre/Ghre_OpenClassServices.cs
  5. 325
      Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs

@ -120,7 +120,7 @@ public class Ghre_OpenClassController : BaseController<IGhre_OpenClassServices,
public async Task<ServiceResult> TransferPublished(long Id) => await _service.UpdateStatus([Id], "Publish");
[HttpPost, Route("TransferPublished")]
public async Task<ServiceResult> TransferPublished([FromBody] List<long> Ids) => await _service.UpdateStatus(Ids, "Publish");
public async Task<ServiceResult> TransferPublished([FromBody] List<long> Ids) => await _service.UpdateStatus(Ids, "Publish", "TransferPublished");
#endregion
#region 取消发布

@ -1049,7 +1049,8 @@ public partial class CommonServices : BaseServices<RootEntityTkey<int>>, ICommon
case "F_CourseClassification":
case "F_CourseScene":
index = result.JM_PageControlT1.Toolbar.FindIndex(x => x.fnKey == "BatchUpdateYN");
result.JM_PageControlT1.Toolbar.RemoveAt(index);
if (index >= 0)
result.JM_PageControlT1.Toolbar.RemoveAt(index);
result.JM_PageControlT1.Toolbar.Insert(0, new Toolbar()
{

@ -285,7 +285,8 @@ public class Ghre_CourseServices : BaseServices<Ghre_Course, Ghre_CourseDto, Ins
var classs = await _ghre_CourseClassServices.Query(x => classsIds.Contains(x.Id));
var courseSceneIds = new List<long>();
courseSceneIds = courseSceneIds.Concat(JsonConvert.DeserializeObject<List<long>>(DT_TableDataT1.CourseSceneIds)).ToList();
if (DT_TableDataT1.CourseSceneIds.IsNotEmptyOrNull())
courseSceneIds = courseSceneIds.Concat(JsonConvert.DeserializeObject<List<long>>(DT_TableDataT1.CourseSceneIds)).ToList();
courseSceneIds = courseSceneIds.Distinct().ToList();
var courseScenes = await Db.Queryable<Ghre_CourseScene>().Where(x => courseSceneIds.Contains(x.Id)).ToListAsync();

@ -133,7 +133,7 @@ public class Ghre_OpenClassServices : BaseServices<Ghre_OpenClass, Ghre_OpenClas
if (entity.Attachments != null && entity.Attachments.Any())
{
var paths = entity.Attachments.Select(x => x.RelativePath).ToList();
var paths = entity.Attachments.Select(x => x.RelativePath.Replace("/Advanced", null)).ToList();
await Db.Updateable<Ghre_Attachment>()
.SetColumns(it => new Ghre_Attachment() { TableName = result.ObjToString(), AttachmentGroupID = 1 })
.Where(it => paths.Contains(it.RelativePath))
@ -176,7 +176,7 @@ public class Ghre_OpenClassServices : BaseServices<Ghre_OpenClass, Ghre_OpenClas
if (entity.Attachments != null && entity.Attachments.Any())
{
var paths = entity.Attachments.Select(x => x.RelativePath).ToList();
var paths = entity.Attachments.Select(x => x.RelativePath.Replace("/Advanced", null)).ToList();
await Db.Updateable<Ghre_Attachment>()
.SetColumns(it => new Ghre_Attachment() { TableName = Id.ObjToString(), AttachmentGroupID = 1 })
.Where(it => paths.Contains(it.RelativePath))
@ -222,7 +222,7 @@ public class Ghre_OpenClassServices : BaseServices<Ghre_OpenClass, Ghre_OpenClas
public async Task<ServiceResult> InsertStaff(long Id, List<int> staffIds)
{
var staffIds1 = await Db.Queryable<Ghre_OpenClassStaff>().Select(s => s.StaffId).ToListAsync();
var staffIds1 = await Db.Queryable<Ghre_OpenClassStaff>().Where(x => x.OpenClassId == Id).Select(s => s.StaffId).ToListAsync();
var inserts = staffIds.Where(x => !staffIds1.Contains(x))
.Select(x => new InsertGhre_OpenClassStaffInput()
{
@ -298,7 +298,7 @@ public class Ghre_OpenClassServices : BaseServices<Ghre_OpenClass, Ghre_OpenClas
if (entity.Attachments != null && entity.Attachments.Any())
{
var paths = entity.Attachments.Select(x => x.RelativePath).ToList();
var paths = entity.Attachments.Select(x => x.RelativePath.Replace("/Advanced", null)).ToList();
await Db.Updateable<Ghre_Attachment>()
.SetColumns(it => new Ghre_Attachment() { TableName = Id.ObjToString(), AttachmentGroupID = 2 })
.Where(it => paths.Contains(it.RelativePath))
@ -315,7 +315,7 @@ public class Ghre_OpenClassServices : BaseServices<Ghre_OpenClass, Ghre_OpenClas
switch (source)
{
case "TransferOpening":
case "TransferPublished":
#region 转入开课,开班自动产生考试数据
var list = await Query(x => ids.Contains(x.Id));

@ -855,19 +855,38 @@ public class Ghre_StudyRecordServices : BaseServices<Ghre_StudyRecord, Ghre_Stud
/// <returns></returns>
public async Task<ServicePageResult<Ghre_StudyRecordESS>> QueryESS(QueryBody filter, string condition, bool? IsEnable = true)
{
if (await QueryCompanyCode() == "Ushio" && string.IsNullOrWhiteSpace(filter.orderBy))
{
filter.orderBy = "CoursePublishTime DESC";
}
string courseType = "Required";
if (filter.jsonParam != null)
foreach (JProperty jProperty in filter.jsonParam.Properties())
{
var name = jProperty.Name;
var value = jProperty.Value.ToString();
if (name == "CourseType")
{
var jsonParam = JsonConvert.DeserializeObject<JsonParam>(value);
courseType = jsonParam.columnValue.ObjToString();
continue;
}
}
if (courseType == "OpenClass")
return await QueryOpenClass(filter, condition, IsEnable);
else
if (string.IsNullOrWhiteSpace(filter.orderBy))
filter.orderBy = "JoinTime DESC";
{
if (await QueryCompanyCode() == "Ushio" && string.IsNullOrWhiteSpace(filter.orderBy))
filter.orderBy = "CoursePublishTime DESC";
else if (string.IsNullOrWhiteSpace(filter.orderBy))
filter.orderBy = "JoinTime DESC";
if (filter.pageSize == 0)
filter.pageSize = 10000;
if (filter.pageSize == 0)
filter.pageSize = 10000;
var countSql = @$" SELECT COUNT(1) FROM Ghre_StudyRecord_V";
var sql = @$" SELECT A.Id,
var countSql = @$" SELECT COUNT(1) FROM Ghre_StudyRecord_V";
var sql = @$" SELECT A.Id,
A.StaffId,
A.CourseSnapId,
A.CourseId,
@ -892,12 +911,277 @@ public class Ghre_StudyRecordServices : BaseServices<Ghre_StudyRecord, Ghre_Stud
A.ExamId,A.ExamStatus,A.CoursePublishTime
FROM Ghre_StudyRecord_V A";
string conditions = $" WHERE UserId={App.User.ID} ";
string conditions = $" WHERE UserId={App.User.ID} ";
if (IsEnable == true)
conditions += " AND IsEnable = 1";
else if (IsEnable == false)
conditions += " AND IsEnable = 0";
if (IsEnable == true)
conditions += " AND IsEnable = 1";
else if (IsEnable == false)
conditions += " AND IsEnable = 0";
if (!string.IsNullOrWhiteSpace(condition))
conditions += " AND " + condition;
if (filter.jsonParam != null)
foreach (JProperty jProperty in filter.jsonParam.Properties())
{
var name = jProperty.Name;
var value = jProperty.Value.ToString();
if (name == "page" || name == "pageSize")
continue;
if (name == "CourseNoOrName")
{
var jsonParam = JsonConvert.DeserializeObject<JsonParam>(value);
conditions += $" AND CourseName LIKE '%{jsonParam.columnValue}%'";
continue;
}
if (name == "CourseClassId")
{
var jsonParam = JsonConvert.DeserializeObject<JsonParam>(value);
conditions += $" AND CourseClassId LIKE '%{jsonParam.columnValue}%' ";
continue;
}
if (name == "CourseType")
{
var jsonParam = JsonConvert.DeserializeObject<JsonParam>(value);
var value1 = jsonParam.columnValue;
conditions += $" AND {name} LIKE '%{jsonParam.columnValue}%'";
continue;
}
if (name == "CourseStatus")
{
var jsonParam = JsonConvert.DeserializeObject<JsonParam>(value);
var dtTime = DateTime.Now;
var value1 = jsonParam.columnValue;
switch (value1)
{
case "In":
conditions += $" AND '{DateTimeHelper.ConvertToSecondString(dtTime)}' BETWEEN CourseBeginTime AND CourseEndTime";
break;
case "Over":
conditions += $" AND CourseEndTime >'{DateTimeHelper.ConvertToSecondString(dtTime)}'";
break;
case "NOStart":
conditions += $" AND CourseBeginTime >'{DateTimeHelper.ConvertToSecondString(dtTime)}'";
break;
default:
break;
}
continue;
}
if (!string.IsNullOrWhiteSpace(value))
{
var jsonParam = JsonConvert.DeserializeObject<JsonParam>(value);
switch (jsonParam.operationKey)
{
case "Include":
conditions += $" AND {name} LIKE '%{jsonParam.columnValue}%'";
break;
case "NotInclude":
conditions += $" AND {name} NOT LIKE '%{jsonParam.columnValue}%'";
break;
case "IsNull":
conditions += $" AND {name} IS NULL";
break;
case "NotNull":
conditions += $" AND {name} IS NOT NULL";
break;
case "Equal":
conditions += $" AND {name} ='{jsonParam.columnValue}'";
break;
case "NotEqual":
conditions += $" AND {name} !='{jsonParam.columnValue}'";
break;
case "GreaterOrEqual"://大于等于
conditions += $" AND {name} >='{jsonParam.columnValue}'";
break;
case "Greater"://大于
conditions += $" AND {name} >'{jsonParam.columnValue}'";
break;
case "LessOrEqual"://小于等于
conditions += $" AND {name} <='{jsonParam.columnValue}'";
break;
case "Less"://小于
conditions += $" AND {name} <'{jsonParam.columnValue}'";
break;
default:
break;
}
}
}
sql += conditions;
countSql += conditions;
int total = await Db.Ado.GetIntAsync(countSql);
sql = "SELECT * FROM (SELECT *, ROW_NUMBER() OVER (ORDER BY " + filter.orderBy + ") NUM FROM (SELECT * FROM (" + sql + " ";
sql += ") A ) B ) C";
sql += " WHERE NUM <= " + filter.pageNum * filter.pageSize + " AND NUM >" + (filter.pageNum - 1) * filter.pageSize;
var entitys = await Db.Ado.SqlQueryAsync<Ghre_StudyRecordESS>(sql);
var dt = DateTime.Now.Date;
entitys.ForEach(x =>
{
if (x.CourseBeginDate != null && x.CourseEndDate != null)
x.CourseDateString = DateTimeHelper.ConvertToDayString(x.CourseBeginDate) + "~" + DateTimeHelper.ConvertToDayString(x.CourseEndDate);
if (!x.ExamId.IsNull())
{
if (x.ExamBeginDate != null && x.ExamEndDate != null)
x.ExamDateString = DateTimeHelper.ConvertToDayString(x.ExamBeginDate) + "~" + DateTimeHelper.ConvertToDayString(x.ExamEndDate);
else x.ExamDateString = $"学完{x.AfterHowLong}天";
}
//if (x.CourseBeginDate != null && x.CourseEndDate != null)
// if (x.StudyProgress >= 100 || !(x.CourseBeginDate.Value.Date <= DateTime.Now.Date && x.CourseEndDate.Value.Date >= DateTime.Now.Date))
// x.DisableStudyBtn = true;
if (x.StudyProgress < 100 || x.ExamId.IsNull())
x.DisableExamBtn = true;
if (x.FeedbackOrderId.IsNull())
x.ShowFeedbackBtn = false;
#region 处理学习进度
if (x.ExamId.IsNull())
x.ShowExamBtn = false;
if (!x.ExamId.IsNull() && x.FeedbackOrderId.IsNull())
{
if (x.ExamStatus == DIC_EXAM_RECORD_STATUS.WAIT || x.ExamStatus.IsNull())
x.StudyProgress = x.StudyProgress / 2;
else if (x.ExamStatus == DIC_EXAM_RECORD_STATUS.EXAMING)
x.StudyProgress = 75;
else if (x.ExamStatus == DIC_EXAM_RECORD_STATUS.EXAM_END)
x.StudyProgress = 100;
}
if (!x.ExamId.IsNull() && !x.FeedbackOrderId.IsNull())
{
if (x.ExamStatus == DIC_EXAM_RECORD_STATUS.WAIT)
x.StudyProgress = x.StudyProgress / 3;
else if (x.ExamStatus == DIC_EXAM_RECORD_STATUS.EXAMING)
x.StudyProgress = 45;
else if (x.ExamStatus == DIC_EXAM_RECORD_STATUS.EXAM_END)
x.StudyProgress = 60;
}
#endregion
});
return new ServicePageResult<Ghre_StudyRecordESS>(filter.pageNum, total, filter.pageSize, entitys);
}
}
public async Task<ServicePageResult<Ghre_StudyRecordESS>> QueryOpenClass(QueryBody filter, string condition, bool? IsEnable = true)
{
if (string.IsNullOrWhiteSpace(filter.orderBy))
filter.orderBy = "PublishTime DESC";
if (filter.pageSize == 0)
filter.pageSize = 10000;
var staffId = App.User.StaffId;
var sql = @$"SELECT A.Id,
A.StartTime CourseBeginDate,
A.EndTime CourseEndDate,
A.RegisterStartTime,
A.RegisterEndTime,
A.ExamStartTime ExamBeginDate,
A.ExamEndTime ExamEndDate,
isnull (C.CourseName, D.SceneName) CourseName,
isnull (C.StandardHour, D.StandardHour) StandardHour,
isnull
(
C.CoverUrl,
'/File/UploadPath/41_20240807204236365_Snipaste_2024-08-07_20-41-44.png') CoverUrl,
C.UseDefaultCoverImage,
C.DefaultCoverImageName,
isnull (C.CreditPoints, D.CreditPoints) CreditPoints,
'ExamDate' ExamDateType,
A.ExamId,
E.Status ExamStatus, A.CreateTime PublishTime
FROM Ghre_OpenClass A
JOIN Ghre_StaffGroup B ON A.StaffGroupId = B.Id
LEFT JOIN Ghre_Course C ON A.LinkId = C.Id
LEFT JOIN Ghre_CourseScene D ON A.LinkId = D.Id
LEFT JOIN Ghre_Exam E ON A.ExamId = E.Id
WHERE EXISTS (
SELECT 1
FROM Ghra_Staff A
WHERE A.StaffID = '{staffId}'
AND A.StaffID IN (
SELECT value
FROM OPENJSON(B.StaffId)
)
AND A.StaffID NOT IN (
SELECT value
FROM OPENJSON(B.ExclStaffId)
)
AND A.StaffType1 IN (
SELECT value
FROM OPENJSON(B.StaffType1)
)
AND A.StaffType2 IN (
SELECT value
FROM OPENJSON(B.StaffType2)
)
AND A.ZoneId IN (
SELECT value
FROM OPENJSON(B.ZoneId)
)
AND A.ZoneId NOT IN (
SELECT value
FROM OPENJSON(B.ExclZoneId)
)
AND A.DeptId IN (
SELECT value
FROM OPENJSON(B.DeptId)
)
AND A.DeptId NOT IN (
SELECT value
FROM OPENJSON(B.ExclDeptId)
)
AND A.TitleId IN (
SELECT value
FROM OPENJSON(B.TitleId)
)
AND A.TitleId NOT IN (
SELECT value
FROM OPENJSON(B.ExclTitleId)
)
AND A.GradeId IN (
SELECT value
FROM OPENJSON(B.GradeId)
)
AND A.GradeId NOT IN (
SELECT value
FROM OPENJSON(B.ExclGradeId)
)
AND A.JobId IN (
SELECT value
FROM OPENJSON(B.JobId)
)
AND A.JobId NOT IN (
SELECT value
FROM OPENJSON(B.ExclJobId)
)
)
OR EXISTS (
SELECT 1
FROM Ghre_OpenClassStaff C
WHERE C.OpenClassId = A.ID
AND c.StaffId = '{staffId}'
)";
string conditions = $"";
if (!string.IsNullOrWhiteSpace(condition))
conditions += " AND " + condition;
@ -925,14 +1209,7 @@ public class Ghre_StudyRecordServices : BaseServices<Ghre_StudyRecord, Ghre_Stud
continue;
}
if (name == "CourseType")
{
var jsonParam = JsonConvert.DeserializeObject<JsonParam>(value);
var value1 = jsonParam.columnValue;
conditions += $" AND {name} LIKE '%{jsonParam.columnValue}%'";
continue;
}
if (name == "CourseStatus")
{
@ -999,7 +1276,8 @@ public class Ghre_StudyRecordServices : BaseServices<Ghre_StudyRecord, Ghre_Stud
}
sql += conditions;
countSql += conditions;
var countSql = @$" SELECT COUNT(1) FROM ({sql}) A";
int total = await Db.Ado.GetIntAsync(countSql);
sql = "SELECT * FROM (SELECT *, ROW_NUMBER() OVER (ORDER BY " + filter.orderBy + ") NUM FROM (SELECT * FROM (" + sql + " ";
@ -1058,7 +1336,6 @@ public class Ghre_StudyRecordServices : BaseServices<Ghre_StudyRecord, Ghre_Stud
});
return new ServicePageResult<Ghre_StudyRecordESS>(filter.pageNum, total, filter.pageSize, entitys);
}
#endregion

Loading…
Cancel
Save