diff --git a/Tiobon.Core.Api/Controllers/Ghre/Ghre_OpenClassController.cs b/Tiobon.Core.Api/Controllers/Ghre/Ghre_OpenClassController.cs index 9015ecd3..9a23215a 100644 --- a/Tiobon.Core.Api/Controllers/Ghre/Ghre_OpenClassController.cs +++ b/Tiobon.Core.Api/Controllers/Ghre/Ghre_OpenClassController.cs @@ -200,4 +200,24 @@ public class Ghre_OpenClassController : BaseController> QuerySchedule(long Id) => await _service.QuerySchedule(Id); #endregion + + #region 签到 + /// + /// 签到 + /// + /// 开班ID + /// + [HttpPost, Route("AttendCheckIn/{Id}")] + public async Task AttendCheckIn(long Id) => await _service.Attend(Id, "CheckIn"); + #endregion + + #region 签退 + /// + /// 签退 + /// + /// 开班ID + /// + [HttpPost, Route("AttendCheckOut/{Id}")] + public async Task AttendCheckOut(long Id) => await _service.Attend(Id, "CheckOut"); + #endregion } \ No newline at end of file diff --git a/Tiobon.Core.Api/Tiobon.Core.Model.xml b/Tiobon.Core.Api/Tiobon.Core.Model.xml index dd73ad82..c9916e5d 100644 --- a/Tiobon.Core.Api/Tiobon.Core.Model.xml +++ b/Tiobon.Core.Api/Tiobon.Core.Model.xml @@ -5825,9 +5825,9 @@ 预留字段12 - + - 讲师上级ID + 员工ID @@ -6030,6 +6030,11 @@ 预留字段12 + + + 讲师上级ID + + 开班成绩 (Dto.Base) @@ -23012,9 +23017,9 @@ 预留字段12 - + - 讲师上级ID + 员工ID @@ -23217,6 +23222,11 @@ 预留字段12 + + + 讲师上级ID + + 开班成绩 (Model) @@ -38453,6 +38463,16 @@ 批改评语 + + + 是否可以签到 + + + + + 是否可以签退 + + 课程ID @@ -38478,6 +38498,16 @@ 结束时间 + + + 开始时间 + + + + + 结束时间 + + 备注 diff --git a/Tiobon.Core.Api/Tiobon.Core.xml b/Tiobon.Core.Api/Tiobon.Core.xml index 523d4cd9..b6e079a0 100644 --- a/Tiobon.Core.Api/Tiobon.Core.xml +++ b/Tiobon.Core.Api/Tiobon.Core.xml @@ -1191,6 +1191,20 @@ 开班ID + + + 签到 + + 开班ID + + + + + 签退 + + 开班ID + + 开班费用(Controller) diff --git a/Tiobon.Core.IServices/Ghre/IGhre_OpenClassServices.cs b/Tiobon.Core.IServices/Ghre/IGhre_OpenClassServices.cs index 671d0afb..8d6929c1 100644 --- a/Tiobon.Core.IServices/Ghre/IGhre_OpenClassServices.cs +++ b/Tiobon.Core.IServices/Ghre/IGhre_OpenClassServices.cs @@ -33,4 +33,6 @@ public interface IGhre_OpenClassServices : IBaseServices> ExportStaff(long Id); Task> QuerySchedule(long Id); + + Task Attend(long Id, string type); } \ No newline at end of file diff --git a/Tiobon.Core.Model/Base/Ghre/Ghre_OpenClassAttend.Dto.Base.cs b/Tiobon.Core.Model/Base/Ghre/Ghre_OpenClassAttend.Dto.Base.cs index e451f4b5..418b0a0a 100644 --- a/Tiobon.Core.Model/Base/Ghre/Ghre_OpenClassAttend.Dto.Base.cs +++ b/Tiobon.Core.Model/Base/Ghre/Ghre_OpenClassAttend.Dto.Base.cs @@ -6,7 +6,7 @@ * * Ver 变更日期 负责人 变更内容 * ─────────────────────────────────── -*V0.01 2025/4/15 9:41:36 SimonHsiao 初版 +*V0.01 2025/4/15 15:27:48 SimonHsiao 初版 * * Copyright(c) 2025 Tiobon Corporation. All Rights Reserved. *┌──────────────────────────────────┐ @@ -120,7 +120,7 @@ public class Ghre_OpenClassAttendBase public int? ReverseI2 { get; set; } /// - /// 讲师上级ID + /// 员工ID /// - public long? TeacherSuperiorId { get; set; } + public int? StaffId { get; set; } } diff --git a/Tiobon.Core.Model/Base/Ghre/Ghre_OpenClassSchedule.Dto.Base.cs b/Tiobon.Core.Model/Base/Ghre/Ghre_OpenClassSchedule.Dto.Base.cs index f2b49e5d..0e7b241f 100644 --- a/Tiobon.Core.Model/Base/Ghre/Ghre_OpenClassSchedule.Dto.Base.cs +++ b/Tiobon.Core.Model/Base/Ghre/Ghre_OpenClassSchedule.Dto.Base.cs @@ -6,7 +6,7 @@ * * Ver 变更日期 负责人 变更内容 * ─────────────────────────────────── -*V0.01 2025/2/8 14:57:01 SimonHsiao 初版 +*V0.01 2025/4/15 15:27:32 SimonHsiao 初版 * * Copyright(c) 2025 Tiobon Corporation. All Rights Reserved. *┌──────────────────────────────────┐ @@ -135,5 +135,10 @@ public class Ghre_OpenClassScheduleBase /// public int? ReverseI2 { get; set; } + /// + /// 讲师上级ID + /// public List StartEndTime { get; set; } = new List(); + + public long? TeacherSuperiorId { get; set; } } diff --git a/Tiobon.Core.Model/Models/Ghre/Ghre_OpenClassAttend.cs b/Tiobon.Core.Model/Models/Ghre/Ghre_OpenClassAttend.cs index a8b58c4e..8d36a6f5 100644 --- a/Tiobon.Core.Model/Models/Ghre/Ghre_OpenClassAttend.cs +++ b/Tiobon.Core.Model/Models/Ghre/Ghre_OpenClassAttend.cs @@ -6,7 +6,7 @@ * * Ver 变更日期 负责人 变更内容 * ─────────────────────────────────── -*V0.01 2025/4/15 9:41:36 SimonHsiao 初版 +*V0.01 2025/4/15 15:27:48 SimonHsiao 初版 * * Copyright(c) 2025 Tiobon Corporation. All Rights Reserved. *┌──────────────────────────────────┐ @@ -121,7 +121,7 @@ public class Ghre_OpenClassAttend : BasePoco public int? ReverseI2 { get; set; } /// - /// 讲师上级ID + /// 员工ID /// - public long? TeacherSuperiorId { get; set; } + public int? StaffId { get; set; } } diff --git a/Tiobon.Core.Model/Models/Ghre/Ghre_OpenClassSchedule.cs b/Tiobon.Core.Model/Models/Ghre/Ghre_OpenClassSchedule.cs index 7873df14..eee63c9e 100644 --- a/Tiobon.Core.Model/Models/Ghre/Ghre_OpenClassSchedule.cs +++ b/Tiobon.Core.Model/Models/Ghre/Ghre_OpenClassSchedule.cs @@ -6,7 +6,7 @@ * * Ver 变更日期 负责人 变更内容 * ─────────────────────────────────── -*V0.01 2025/2/8 14:57:01 SimonHsiao 初版 +*V0.01 2025/4/15 15:27:32 SimonHsiao 初版 * * Copyright(c) 2025 Tiobon Corporation. All Rights Reserved. *┌──────────────────────────────────┐ @@ -135,4 +135,9 @@ public class Ghre_OpenClassSchedule : BasePoco /// 预留字段12 /// public int? ReverseI2 { get; set; } + + /// + /// 讲师上级ID + /// + public long? TeacherSuperiorId { get; set; } } diff --git a/Tiobon.Core.Model/ViewModels/Extend/Ghre_OpenClassScore.cs b/Tiobon.Core.Model/ViewModels/Extend/Ghre_OpenClassScore.cs index f0c14d55..9a7b6eea 100644 --- a/Tiobon.Core.Model/ViewModels/Extend/Ghre_OpenClassScore.cs +++ b/Tiobon.Core.Model/ViewModels/Extend/Ghre_OpenClassScore.cs @@ -90,6 +90,18 @@ public class Ghre_OpenClassScore public class Ghre_OpenClassSchedule1 { public string SceneName { get; set; } + /// + /// 是否可以签到 + /// + public bool IsCheckIn { get; set; } = false; + /// + /// 是否可以签退 + /// + public bool IsCheckOut { get; set; } = false; + + public string Status { get; set; } + public string AttendType { get; set; } + public List Details { get; set; } } @@ -98,7 +110,7 @@ public class Ghre_OpenClassSchedule1 public class Ghre_OpenClassScheduleDeatil { - public string Id { get; set; } + public long? Id { get; set; } /// /// 课程ID @@ -125,6 +137,16 @@ public class Ghre_OpenClassScheduleDeatil /// public DateTime? EndTime { get; set; } + /// + /// 开始时间 + /// + public DateTime? StartTime1 { get; set; } + + /// + /// 结束时间 + /// + public DateTime? EndTime1 { get; set; } + /// /// 备注 /// @@ -139,6 +161,8 @@ public class Ghre_OpenClassScheduleDeatil /// 课程名称 /// public string CourseName { get; set; } + public DateTime? CheckInTime { get; set; } + public DateTime? CheckOutTime { get; set; } /// /// 状态,缺席:Absence,出席:Attend,当前课程:Current,待开课:WaitStart diff --git a/Tiobon.Core.Services/CommonServices.cs b/Tiobon.Core.Services/CommonServices.cs index e26f03f7..3655727f 100644 --- a/Tiobon.Core.Services/CommonServices.cs +++ b/Tiobon.Core.Services/CommonServices.cs @@ -3945,7 +3945,7 @@ public partial class CommonServices : BaseServices>, ICommon SET @OperateLogID = NULL; - EXEC @return_value = GHR30.dbo.[PS_OperateLog] + EXEC @return_value = dbo.[PS_OperateLog] @OpUserID = {param.userId}, @OpType = {param.doType}, @OpMenuNo = {param.menuName}, @@ -4054,7 +4054,7 @@ public partial class CommonServices : BaseServices>, ICommon SET @ErrorMsg = NULL; - EXEC @return_value = GHR30.dbo.[PT_GHR30_FlowApply] + EXEC @return_value = dbo.[PT_GHR30_FlowApply] @ID = {id}, @FlowID = {@FlowID}, @UserID = {param.userId}, diff --git a/Tiobon.Core.Services/Ghre/Ghre_CourseWareServices.cs b/Tiobon.Core.Services/Ghre/Ghre_CourseWareServices.cs index 4cfbe89e..8514bf32 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_CourseWareServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_CourseWareServices.cs @@ -39,8 +39,9 @@ public class Ghre_CourseWareServices : BaseServices new InsertGhre_CourseWareAttachmentInput() { diff --git a/Tiobon.Core.Services/Ghre/Ghre_OpenClassServices.cs b/Tiobon.Core.Services/Ghre/Ghre_OpenClassServices.cs index 054a00ea..f027c6e3 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_OpenClassServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_OpenClassServices.cs @@ -1,4 +1,6 @@ -namespace Tiobon.Core.Services; +using MongoDB.Driver.Linq; + +namespace Tiobon.Core.Services; /// /// 开班管理 (服务) @@ -488,8 +490,13 @@ WHERE B.OpenClassId = '{Id}'"; public async Task> QuerySchedule(long Id) { var data = new Ghre_OpenClassSchedule1(); + data.AttendType = await Db.Queryable().Where(x => x.ConfigCode == "Open_Class_Schedule_Attend_Type").Select(x => x.ConfigValue).FirstAsync() ?? "CheckIn"; + var min = await Db.Queryable().Where(x => x.ConfigCode == "Open_Class_Schedule_Valid_Attend_Min").Select(x => x.ConfigValue).FirstAsync() ?? "15"; var entity = await base.QueryById(Id); + + var attends = await Db.Queryable().Where(x => x.OpenClassId == Id && x.StaffId == App.User.StaffId).ToListAsync(); + if (entity.LinkType == "CourseScene") { @@ -505,7 +512,13 @@ WHERE B.OpenClassId = '{Id}'"; FROM Ghre_OpenClassSchedule A LEFT JOIN Ghre_Course B ON A.CourseId = B.Id WHERE A.OpenClassId = '{Id}' AND A.IsEnable = 1"; data.Details = await Db.Ado.SqlQueryAsync(sql); - + data.Details.ForEach(x => + { + x.StartTime = x.StartTime; + x.EndTime = x.EndTime; + x.StartTime1 = x.StartTime.Value.AddMinutes(-min.ObjToInt()); + x.EndTime1 = x.EndTime.Value.AddMinutes(min.ObjToInt()); + }); } else { @@ -514,26 +527,123 @@ WHERE A.OpenClassId = '{Id}' AND A.IsEnable = 1"; Address = entity.Address, StartTime = entity.StartTime, EndTime = entity.EndTime, + StartTime1 = entity.StartTime.Value.AddMinutes(-min.ObjToInt()), + EndTime1 = entity.EndTime.Value.AddMinutes(min.ObjToInt()), CourseId = entity.LinkId, }; detail.CourseName = await Db.Queryable().Where(x => x.Id == entity.LinkId).Select(x => x.CourseName).FirstAsync(); data.Details.Add(detail); } - + var dt = DateTime.Now; data.Details.ForEach(d => { d.Time = DateTimeHelper.ConvertToMiniuteString(d.StartTime) + " ~ " + DateTimeHelper.ConvertToMiniuteString(d.EndTime); + + if (d.StartTime1 <= dt && dt <= d.EndTime1) + d.Status = "Current"; + if (d.StartTime1 > dt) + d.Status = "WaitStart"; + + #region 处理签到签退时间 + + if (data.SceneName.IsNotEmptyOrNull()) + { + d.CheckInTime = attends.Where(x => x.ScheduleId == d.Id && x.Reverse1 == "CheckIn").Select(x => x.AttendTime).FirstOrDefault(); + d.CheckOutTime = attends.Where(x => x.ScheduleId == d.Id && x.Reverse1 == "CheckOut").Select(x => x.AttendTime).FirstOrDefault(); + + } + else + { + d.CheckInTime = attends.Where(x => x.Reverse1 == "CheckIn").Select(x => x.AttendTime).FirstOrDefault(); + d.CheckOutTime = attends.Where(x => x.Reverse1 == "CheckOut").Select(x => x.AttendTime).FirstOrDefault(); + } + #endregion + + if (d.Status != "Current") + { + if (d.CheckInTime != null) + d.Status = "Attend"; + } }); //entitys.ForEach(it => //{ // it.IsPassLabel = it.IsPass == true ? "合格" : "不合格"; // it.FinallyIsPassLabel = it.FinallyIsPass == true ? "合格" : "不合格"; //}); + var current = data.Details.Where(x => x.Status == "Current").FirstOrDefault(); + if (current != null) + { + + data.IsCheckIn = true; + data.IsCheckOut = false; + + if (current.CheckInTime != null) + { + data.IsCheckIn = false; + data.Status = "HasCheckIn"; + var start = current.EndTime.Value.AddMinutes(-min.ObjToInt() * 2); + if (dt >= start && dt <= current.EndTime) + data.IsCheckOut = true; + } + if (current.CheckOutTime != null) + { + data.IsCheckOut = false; + data.Status = "HasCheckOut"; + + } + + } return ServiceResult.OprateSuccess("查询成功!", data); } #endregion + #region 签到 + /// + /// 签到 + /// + /// 开班ID + /// + public async Task Attend(long Id, string type) + { + var entity = await base.QueryById(Id); + + if (entity is null) + return ServiceResult.OprateSuccess("无效的开班ID!"); + + long? scheduleId = null; + var dt = DateTime.Now; + var min = await Db.Queryable().Where(x => x.ConfigCode == "Open_Class_Schedule_Valid_Attend_Min").Select(x => x.ConfigValue).FirstAsync() ?? "15"; + + if (entity.LinkType == "CourseScene") + { + var schedules = await Db.Queryable().Where(x => x.OpenClassId == entity.Id).ToListAsync(); + schedules.ForEach(x => + { + x.StartTime = x.StartTime.Value.AddMinutes(-min.ObjToInt()); + x.EndTime = x.EndTime.Value.AddMinutes(min.ObjToInt()); + }); + scheduleId = schedules.Where(x => x.StartTime <= dt && x.EndTime >= dt).FirstOrDefault()?.Id; + } + + if (!await Db.Queryable() + .Where(x => x.OpenClassId == Id && x.StaffId == App.User.StaffId && x.ScheduleId == scheduleId && x.Reverse1 == type) + .AnyAsync()) + { + var staff = new Ghre_OpenClassAttend() + { + StaffId = App.User.StaffId, + OpenClassId = Id, + AttendTime = DateTime.Now, + ScheduleId = scheduleId, + Reverse1 = type + }; + await Db.Insertable(staff).ExecuteReturnSnowflakeIdAsync(); + } + + return ServiceResult.OprateSuccess("签到成功!"); + } + #endregion } \ No newline at end of file diff --git a/Tiobon.Core/Tiobon.Core.Model.xml b/Tiobon.Core/Tiobon.Core.Model.xml index dd73ad82..c9916e5d 100644 --- a/Tiobon.Core/Tiobon.Core.Model.xml +++ b/Tiobon.Core/Tiobon.Core.Model.xml @@ -5825,9 +5825,9 @@ 预留字段12 - + - 讲师上级ID + 员工ID @@ -6030,6 +6030,11 @@ 预留字段12 + + + 讲师上级ID + + 开班成绩 (Dto.Base) @@ -23012,9 +23017,9 @@ 预留字段12 - + - 讲师上级ID + 员工ID @@ -23217,6 +23222,11 @@ 预留字段12 + + + 讲师上级ID + + 开班成绩 (Model) @@ -38453,6 +38463,16 @@ 批改评语 + + + 是否可以签到 + + + + + 是否可以签退 + + 课程ID @@ -38478,6 +38498,16 @@ 结束时间 + + + 开始时间 + + + + + 结束时间 + + 备注 diff --git a/Tiobon.Core/Tiobon.Core.xml b/Tiobon.Core/Tiobon.Core.xml index 523d4cd9..b6e079a0 100644 --- a/Tiobon.Core/Tiobon.Core.xml +++ b/Tiobon.Core/Tiobon.Core.xml @@ -1191,6 +1191,20 @@ 开班ID + + + 签到 + + 开班ID + + + + + 签退 + + 开班ID + + 开班费用(Controller)