diff --git a/Tiobon.Core.Api/Controllers/Ghre/Ghre_OpenClassController.cs b/Tiobon.Core.Api/Controllers/Ghre/Ghre_OpenClassController.cs index e5c566de..e02271d3 100644 --- a/Tiobon.Core.Api/Controllers/Ghre/Ghre_OpenClassController.cs +++ b/Tiobon.Core.Api/Controllers/Ghre/Ghre_OpenClassController.cs @@ -54,6 +54,14 @@ public class Ghre_OpenClassController : BaseController [HttpPost, Route("DeleteStaff/{Id}")] public async Task DeleteStaff(long Id, [FromBody] List staffIds) => await _service.DeleteStaff(Id, staffIds); + + /// + /// 学员导出 + /// + /// 开班ID + /// + [HttpPost, Route("ExportStaff/{Id}")] + public async Task> ExportStaff(long Id) => await _service.ExportStaff(Id); #endregion #region 费用 @@ -163,8 +171,6 @@ public class Ghre_OpenClassController : BaseController CancelClose([FromBody] List Ids) => await _service.UpdateStatus(Ids, "Opening"); #endregion - - #region 成绩 /// /// 查询成绩 @@ -174,4 +180,14 @@ public class Ghre_OpenClassController : BaseController>> QueryScore(long Id) => await _service.QueryScore(Id); #endregion + + #region 报名 + /// + /// 报名 + /// + /// 开班ID + /// + [HttpPost, Route("CheckIn/{Id}")] + public async Task CheckIn(long Id) => await _service.CheckIn(Id); + #endregion } \ No newline at end of file diff --git a/Tiobon.Core.Api/Tiobon.Core.xml b/Tiobon.Core.Api/Tiobon.Core.xml index 20ae34fc..29e9fa79 100644 --- a/Tiobon.Core.Api/Tiobon.Core.xml +++ b/Tiobon.Core.Api/Tiobon.Core.xml @@ -1104,6 +1104,13 @@ 员工ID列表 + + + 学员导出 + + 开班ID + + 查询团体费用 @@ -1155,6 +1162,13 @@ 开班ID + + + 报名 + + 开班ID + + 开班费用(Controller) diff --git a/Tiobon.Core.IServices/Ghre/IGhre_OpenClassServices.cs b/Tiobon.Core.IServices/Ghre/IGhre_OpenClassServices.cs index f8978d7b..48c4d9c8 100644 --- a/Tiobon.Core.IServices/Ghre/IGhre_OpenClassServices.cs +++ b/Tiobon.Core.IServices/Ghre/IGhre_OpenClassServices.cs @@ -27,4 +27,8 @@ public interface IGhre_OpenClassServices : IBaseServices UpdateStatus(List ids, string status, string source = null); Task>> QueryScore(long Id); + + Task CheckIn(long Id); + + Task> ExportStaff(long Id); } \ No newline at end of file diff --git a/Tiobon.Core.IServices/Ghre/IGhre_OpenClassStaffServices.cs b/Tiobon.Core.IServices/Ghre/IGhre_OpenClassStaffServices.cs index db7e2234..b0991bad 100644 --- a/Tiobon.Core.IServices/Ghre/IGhre_OpenClassStaffServices.cs +++ b/Tiobon.Core.IServices/Ghre/IGhre_OpenClassStaffServices.cs @@ -1,8 +1,11 @@ -namespace Tiobon.Core.IServices; +using System.Data; + +namespace Tiobon.Core.IServices; /// /// 开班学员(自定义服务接口) /// public interface IGhre_OpenClassStaffServices : IBaseServices { + DataTable ToDataTable1(List list, Dictionary fieldDescs = null, params string[] propertyName); } \ No newline at end of file diff --git a/Tiobon.Core.Model/View/Ghre/Ghre_OpenClassStaff.Dto.View.cs b/Tiobon.Core.Model/View/Ghre/Ghre_OpenClassStaff.Dto.View.cs index 6f685e7e..d02a9a04 100644 --- a/Tiobon.Core.Model/View/Ghre/Ghre_OpenClassStaff.Dto.View.cs +++ b/Tiobon.Core.Model/View/Ghre/Ghre_OpenClassStaff.Dto.View.cs @@ -40,7 +40,7 @@ public class Ghre_OpenClassStaffDto : Ghre_OpenClassStaff /// 姓名 /// public string StaffName { get; set; } - public DateTime? Indate { get; set; } + public string Indate { get; set; } public string TitleName { get; set; } public string DeptName { get; set; } public string Email { get; set; } diff --git a/Tiobon.Core.Services/Ghre/Ghre_OpenClassServices.cs b/Tiobon.Core.Services/Ghre/Ghre_OpenClassServices.cs index 5cf7648a..8b6717cb 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 NPOI.XWPF.UserModel; + +namespace Tiobon.Core.Services; /// /// 开班管理 (服务) @@ -241,6 +243,37 @@ public class Ghre_OpenClassServices : BaseServices> ExportStaff(long Id) + { + var result1 = await _ghre_OpenClassStaffServices.QueryFilterPage(new QueryBody(), $"OpenClassId='{Id}'"); + var result = new ExcelData(); + result.fileName = $"开班学员{DateTimeHelper.ConvertToSecondString1(DateTime.Now)}.xlsx"; + var fieldDescs = new Dictionary + { + { "StaffNo", "工号" }, + { "StaffName", "姓名" }, + { "DeptName", "部门" }, + { "TitleName", "岗位" }, + { "Indate", "入职日期" }, + { "Email", "邮箱" }, + { "Source", "数据来源" } + }; + var dt = _ghre_OpenClassStaffServices.ToDataTable1(result1.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 + result.fileName; + NPOIHelper.ExportExcel(dt, "开班学员", "sheet1", physicsPath + path); + + result.filePath = "/Advanced" + path; + return ServiceResult.OprateSuccess("导出成功", result); + } #endregion #region 费用 @@ -389,8 +422,6 @@ public class Ghre_OpenClassServices : BaseServices>> QueryScore(long Id) @@ -421,4 +452,28 @@ WHERE B.OpenClassId = '{Id}'"; return ServiceResult>.OprateSuccess("查询成功!", entitys); } #endregion + + #region 报名 + /// + /// 报名 + /// + /// 开班ID + /// + public async Task CheckIn(long Id) + { + if (!await base.AnyAsync(x => x.Id == Id)) + return ServiceResult.OprateSuccess("无效的开班ID!"); + if (await Db.Queryable().Where(x => x.StaffId == App.User.StaffId && x.OpenClassId == Id).AnyAsync()) + return ServiceResult.OprateSuccess("已报名,请勿重复提交!"); + + var staff = new Ghre_OpenClassStaff() + { + StaffId = App.User.StaffId, + OpenClassId = Id, + Source = "CheckIn" + }; + await Db.Insertable(staff).ExecuteReturnSnowflakeIdAsync(); + return ServiceResult.OprateSuccess("报名成功!"); + } + #endregion } \ No newline at end of file diff --git a/Tiobon.Core.Services/Ghre/Ghre_OpenClassStaffServices.cs b/Tiobon.Core.Services/Ghre/Ghre_OpenClassStaffServices.cs index 470f3f4f..4fdcd1ac 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_OpenClassStaffServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_OpenClassStaffServices.cs @@ -48,10 +48,10 @@ public class Ghre_OpenClassStaffServices : BaseServices x.StaffID == DT_TableDataT1.StaffId).FirstOrDefault(); DT_TableDataT1.StaffNo = staff?.StaffNo; DT_TableDataT1.StaffName = staff?.StaffName; - DT_TableDataT1.Indate = staff?.Indate; + DT_TableDataT1.Indate = DateTimeHelper.ConvertToDayString(staff?.Indate); DT_TableDataT1.TitleName = staff?.TitleName; DT_TableDataT1.DeptName = staff?.DeptName; - DT_TableDataT1.DeptName = staff?.Email; + DT_TableDataT1.Email = staff?.Email; result.result.DT_TableDataT1[i] = DT_TableDataT1; } } @@ -66,4 +66,9 @@ public class Ghre_OpenClassStaffServices : BaseServices list, Dictionary fieldDescs = null, params string[] propertyName) + { + return ToDataTable(list, fieldDescs, propertyName); + } } \ No newline at end of file