|
|
@ -1,4 +1,5 @@ |
|
|
|
using MongoDB.Driver.Linq; |
|
|
|
using MathNet.Numerics.Distributions; |
|
|
|
|
|
|
|
using MongoDB.Driver.Linq; |
|
|
|
using NPOI.HSSF.UserModel; |
|
|
|
using NPOI.HSSF.UserModel; |
|
|
|
using NPOI.SS.UserModel; |
|
|
|
using NPOI.SS.UserModel; |
|
|
|
using NPOI.SS.Util; |
|
|
|
using NPOI.SS.Util; |
|
|
@ -1301,9 +1302,10 @@ WHERE A.Status !='Temporary' AND EXISTS ( |
|
|
|
x.ShowRegisterBtn = false; |
|
|
|
x.ShowRegisterBtn = false; |
|
|
|
|
|
|
|
|
|
|
|
if (dt >= x.RegisterStartTime && dt <= x.RegisterEndTime && x.OpenClassStatus == "Publish" && !openClassStaffs.Any(o => o.OpenClassId == x.Id)) |
|
|
|
if (dt >= x.RegisterStartTime && dt <= x.RegisterEndTime && x.OpenClassStatus == "Publish" && !openClassStaffs.Any(o => o.OpenClassId == x.Id)) |
|
|
|
x.ShowStudyBtn = true; |
|
|
|
x.ShowRegisterBtn = true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (dt >= x.CourseBeginDate && dt <= x.CourseEndDate && (x.OpenClassStatus == "Publish" || x.OpenClassStatus == "Opening") && openClassStaffs.Any(o => o.OpenClassId == x.Id)) |
|
|
|
|
|
|
|
x.ShowStudyBtn = true; |
|
|
|
|
|
|
|
|
|
|
|
if (x.CourseBeginDate != null && x.CourseEndDate != null) |
|
|
|
if (x.CourseBeginDate != null && x.CourseEndDate != null) |
|
|
|
x.CourseDateString = DateTimeHelper.ConvertToDayString(x.CourseBeginDate) + "~" + DateTimeHelper.ConvertToDayString(x.CourseEndDate); |
|
|
|
x.CourseDateString = DateTimeHelper.ConvertToDayString(x.CourseBeginDate) + "~" + DateTimeHelper.ConvertToDayString(x.CourseEndDate); |
|
|
@ -1366,6 +1368,34 @@ WHERE A.Status !='Temporary' AND EXISTS ( |
|
|
|
{ |
|
|
|
{ |
|
|
|
var course = new Ghre_StudyRecordCourse(); |
|
|
|
var course = new Ghre_StudyRecordCourse(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 处理开班自动绑定学习记录 |
|
|
|
|
|
|
|
if (await Db.Queryable<Ghre_OpenClass>().Where(x => x.Id == id).AnyAsync() && |
|
|
|
|
|
|
|
await Db.Queryable<Ghre_OpenClassStaff>().Where(x => x.OpenClassId == id && x.StaffId == App.User.StaffId).AnyAsync() && |
|
|
|
|
|
|
|
!await Db.Queryable<Ghre_StudyRecord>().Where(x => x.OpenClassId == id).AnyAsync()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var openClass = await Db.Queryable<Ghre_OpenClass>().Where(x => x.Id == id).FirstAsync(); |
|
|
|
|
|
|
|
var snap = await Db.Queryable<Ghre_CourseSnap>().FirstAsync(x => x.CourseId == openClass.LinkId); |
|
|
|
|
|
|
|
var studyRecord = new InsertGhre_StudyRecordInput() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
StaffId = App.User.StaffId, |
|
|
|
|
|
|
|
ExamId = openClass.ExamId, |
|
|
|
|
|
|
|
CourseSnapId = snap?.Id, |
|
|
|
|
|
|
|
CourseId = openClass.LinkType == "Course" ? openClass.LinkId : null, |
|
|
|
|
|
|
|
CourseSceneId = openClass.LinkType == "CourseScene" ? openClass.LinkId : null, |
|
|
|
|
|
|
|
JoinTime = DateTime.Now, |
|
|
|
|
|
|
|
CourseBeginTime = openClass.StartTime, |
|
|
|
|
|
|
|
CourseEndTime = openClass.EndTime, |
|
|
|
|
|
|
|
//CourseType = rule.RuleType, |
|
|
|
|
|
|
|
CourseStatus = DIC_STUDY_RECORD_COURSE_STATUS_IN, |
|
|
|
|
|
|
|
StudyStatus = DIC_STUDY_RECORD_STUDY_STATUS.NO_JOIN, |
|
|
|
|
|
|
|
OpenClassId = openClass.Id |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
id = await base.Add(studyRecord); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
id = await Db.Queryable<Ghre_StudyRecord>().Where(x => x.OpenClassId == id || x.Id == id).Select(x => x.Id).FirstAsync(); |
|
|
|
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
string sql = @$"SELECT A.Id,
|
|
|
|
string sql = @$"SELECT A.Id,
|
|
|
|
A.CourseId, |
|
|
|
A.CourseId, |
|
|
|
A.CourseSceneId, |
|
|
|
A.CourseSceneId, |
|
|
@ -1469,7 +1499,7 @@ WHERE A.Id = '{id}'"; |
|
|
|
{ |
|
|
|
{ |
|
|
|
course.CourseWareList = new List<Ghre_StudyRecordCourseWare>(); |
|
|
|
course.CourseWareList = new List<Ghre_StudyRecordCourseWare>(); |
|
|
|
course.CourseTeacherList = new List<Ghre_StudyRecordCourseTeacher>(); |
|
|
|
course.CourseTeacherList = new List<Ghre_StudyRecordCourseTeacher>(); |
|
|
|
var courses = await Db.Queryable<Ghre_Course>().Where(x => x.CourseSceneId == course.CourseSceneId && x.Status == Consts.DIC_COURSE_STATUS.RELEASED).OrderBy(x => x.SortNo).ToListAsync(); |
|
|
|
var courses = await Db.Queryable<Ghre_Course>().Where(x => (x.CourseSceneId == course.CourseSceneId || x.CourseSceneIds.Contains(course.CourseSceneId.ToString())) && x.Status == Consts.DIC_COURSE_STATUS.RELEASED).OrderBy(x => x.SortNo).ToListAsync(); |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < courses.Count; i++) |
|
|
|
for (int i = 0; i < courses.Count; i++) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1524,7 +1554,7 @@ WHERE A.Id = '{id}'"; |
|
|
|
CourseName = x.CourseName, |
|
|
|
CourseName = x.CourseName, |
|
|
|
Outline = x.Outline |
|
|
|
Outline = x.Outline |
|
|
|
}).ToList(); |
|
|
|
}).ToList(); |
|
|
|
course.TeacherName = string.Join("、", course.CourseTeacherList.Select(x => x.TeacherName)); |
|
|
|
course.TeacherName = string.Join("、", course.CourseTeacherList.Where(x => x.TeacherName != null).Select(x => x.TeacherName)); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -1557,8 +1587,7 @@ WHERE A.Id = '{id}'"; |
|
|
|
WHERE A.Id IN |
|
|
|
WHERE A.Id IN |
|
|
|
(SELECT CourseWareId |
|
|
|
(SELECT CourseWareId |
|
|
|
FROM Ghre_Course |
|
|
|
FROM Ghre_Course |
|
|
|
WHERE Id = '{course.CourseId}' |
|
|
|
WHERE (Id = '{course.CourseId}' OR CourseSceneId = '{course.CourseSceneId}' OR CourseSceneIds like '%{course.CourseSceneId}%') AND IsEnable = 1)";
|
|
|
|
OR CourseSceneId = '{course.CourseSceneId}' AND IsEnable = 1)";
|
|
|
|
|
|
|
|
var mins = await Db.Ado.GetDecimalAsync(sql); |
|
|
|
var mins = await Db.Ado.GetDecimalAsync(sql); |
|
|
|
|
|
|
|
|
|
|
|
course.CourseStandardDuration1 = mins; |
|
|
|
course.CourseStandardDuration1 = mins; |
|
|
@ -1628,9 +1657,13 @@ WHERE A.Id = '{id}'"; |
|
|
|
#region 记录学习时长 |
|
|
|
#region 记录学习时长 |
|
|
|
public async Task<ServiceResult> RecordDuration(long studyRecordId, decimal? duration, long attachmentId) |
|
|
|
public async Task<ServiceResult> RecordDuration(long studyRecordId, decimal? duration, long attachmentId) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var staffId = GetStaffId(); |
|
|
|
//var sql = $"UPDATE Ghre_StudyRecord SET StudyDuration = ISNULL(StudyDuration, 0)+{duration} WHERE Id='{studyRecordId}' AND StaffId='{staffId}'"; |
|
|
|
var sql = $"UPDATE Ghre_StudyRecord SET StudyDuration = ISNULL(StudyDuration, 0)+{duration} WHERE Id='{studyRecordId}' AND StaffId='{staffId}'"; |
|
|
|
//await Db.Ado.ExecuteCommandAsync(sql); |
|
|
|
await Db.Ado.ExecuteCommandAsync(sql); |
|
|
|
|
|
|
|
|
|
|
|
await Db.Updateable<Ghre_StudyRecord>() |
|
|
|
|
|
|
|
.SetColumns(it => new Ghre_StudyRecord() { StudyDuration = (it.StudyDuration ?? 0) + duration }, true) |
|
|
|
|
|
|
|
.Where(it => it.Id == studyRecordId && it.StaffId == App.User.StaffId) |
|
|
|
|
|
|
|
.ExecuteCommandAsync(); |
|
|
|
|
|
|
|
|
|
|
|
await Task.Factory.StartNew(async () => await GenerateStaffStudyRecord(Db, studyRecordId, duration.Value, attachmentId)); |
|
|
|
await Task.Factory.StartNew(async () => await GenerateStaffStudyRecord(Db, studyRecordId, duration.Value, attachmentId)); |
|
|
|
|
|
|
|
|
|
|
@ -1647,13 +1680,10 @@ WHERE A.Id = '{id}'"; |
|
|
|
var courseWareIds = new List<long?>(); |
|
|
|
var courseWareIds = new List<long?>(); |
|
|
|
|
|
|
|
|
|
|
|
if (record.CourseId.IsNullOrEmpty()) |
|
|
|
if (record.CourseId.IsNullOrEmpty()) |
|
|
|
courseWareIds = await Db.Queryable<Ghre_Course>().Where(x => x.CourseSceneId == record.CourseSceneId).Select(x => x.CourseWareId).ToListAsync(); |
|
|
|
courseWareIds = await Db.Queryable<Ghre_Course>().Where(x => x.CourseSceneId == record.CourseSceneId || x.CourseSceneIds.Contains(record.CourseSceneId.ObjToString())).Select(x => x.CourseWareId).ToListAsync(); |
|
|
|
else |
|
|
|
else |
|
|
|
courseWareIds = await Db.Queryable<Ghre_Course>().Where(x => x.Id == record.CourseId).Select(x => x.CourseWareId).ToListAsync(); |
|
|
|
courseWareIds = await Db.Queryable<Ghre_Course>().Where(x => x.Id == record.CourseId).Select(x => x.CourseWareId).ToListAsync(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 记录学习明细 |
|
|
|
#region 记录学习明细 |
|
|
|
var detail = new Ghre_StudyRecordDetail() |
|
|
|
var detail = new Ghre_StudyRecordDetail() |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1667,13 +1697,14 @@ WHERE A.Id = '{id}'"; |
|
|
|
#endregion |
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
decimal studyProgress = 0; |
|
|
|
decimal studyProgress = 0; |
|
|
|
var sql = $@"SELECT ISNULL (A.Hours, 0) * 60 + A.Minutes Minutes
|
|
|
|
var sql = $@"SELECT SUM(ISNULL (A.Hours, 0) * 60 + A.Minutes) Minutes
|
|
|
|
FROM Ghre_CourseWare A |
|
|
|
FROM Ghre_CourseWare A |
|
|
|
WHERE A.Id IN |
|
|
|
WHERE A.Id IN |
|
|
|
(SELECT CourseWareId |
|
|
|
(SELECT CourseWareId |
|
|
|
FROM Ghre_Course |
|
|
|
FROM Ghre_Course |
|
|
|
WHERE Id = '{record.CourseId}' |
|
|
|
WHERE (Id = '{record.CourseId}' |
|
|
|
OR CourseSceneId = '{record.CourseSceneId}' AND IsEnable = 1)";
|
|
|
|
OR CourseSceneId = '{record.CourseSceneId}' |
|
|
|
|
|
|
|
OR CourseSceneIds like '%{record.CourseSceneId}%') AND IsEnable = 1)";
|
|
|
|
var mins = await Db.Ado.GetDecimalAsync(sql); |
|
|
|
var mins = await Db.Ado.GetDecimalAsync(sql); |
|
|
|
|
|
|
|
|
|
|
|
if (mins > 0) |
|
|
|
if (mins > 0) |
|
|
|