diff --git a/Tiobon.Core.Api/wwwroot/files/ExcelTemplate/F_TrainPlan.xlsx b/Tiobon.Core.Api/wwwroot/files/ExcelTemplate/F_TrainPlan.xlsx new file mode 100644 index 00000000..194081b6 Binary files /dev/null and b/Tiobon.Core.Api/wwwroot/files/ExcelTemplate/F_TrainPlan.xlsx differ diff --git a/Tiobon.Core.Model/View/Ghre/Ghre_CourseScene.Dto.View.cs b/Tiobon.Core.Model/View/Ghre/Ghre_CourseScene.Dto.View.cs index 9bea9ad3..375bd000 100644 --- a/Tiobon.Core.Model/View/Ghre/Ghre_CourseScene.Dto.View.cs +++ b/Tiobon.Core.Model/View/Ghre/Ghre_CourseScene.Dto.View.cs @@ -37,6 +37,7 @@ public class Ghre_CourseSceneDto : Ghre_CourseScene public string UpdateDataInfo { get; set; } public List Courses { get; set; } + public string BuiltInLabel { get; set; } public string CreditRuleName { get; set; } diff --git a/Tiobon.Core.Services/Ghre/Ghre_CourseSceneServices.cs b/Tiobon.Core.Services/Ghre/Ghre_CourseSceneServices.cs index 75060738..87ac36eb 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_CourseSceneServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_CourseSceneServices.cs @@ -34,7 +34,9 @@ public class Ghre_CourseSceneServices : BaseServices(); }); - + var coures = await Db.Queryable().Where(x => x.CourseSceneIds != null && (x.CourseSceneIds.Contains(body.id.ObjToString()) || x.CourseSceneId == body.id) && x.Status == Consts.DIC_COURSE_STATUS.RELEASED).ToListAsync(); + if (DT_TableDataT1.Any()) + DT_TableDataT1[0].Courses = coures; result.result.DT_TableDataT1 = DT_TableDataT1; return result; } diff --git a/Tiobon.Core.Services/Ghre/Ghre_PlanServices.cs b/Tiobon.Core.Services/Ghre/Ghre_PlanServices.cs index 981c3cb1..2a8ba504 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_PlanServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_PlanServices.cs @@ -1,4 +1,5 @@ -using static Tiobon.Core.Model.Consts; +using NPOI.SS.UserModel; +using static Tiobon.Core.Model.Consts; namespace Tiobon.Core.Services; @@ -372,4 +373,74 @@ public class Ghre_PlanServices : BaseServices> DownloadExcel(string menuName) + { + var physicsPath = $"{Environment.CurrentDirectory}{Path.DirectorySeparatorChar}wwwroot"; + var path = $"{$"{Path.DirectorySeparatorChar}files{Path.DirectorySeparatorChar}ExcelTemplate{Path.DirectorySeparatorChar}"}"; + if (!Directory.Exists(physicsPath + path)) + Directory.CreateDirectory(physicsPath + path); + + Type entityType = typeof(Ghre_Course); + var fileName = "F_TrainPlan.xlsx"; + //physicsPath = physicsPath + path + fileName; + + IWorkbook hssfworkbook; + ISheet sheet; + using (FileStream file = new FileStream(physicsPath + path + fileName, FileMode.Open, FileAccess.Read)) + { + //hssfworkbook = new HSSFWorkbook(file); + //hssfworkbook = new XSSFWorkbook(file); + hssfworkbook = WorkbookFactory.Create(file); + } + ISheet sheet2 = hssfworkbook.CreateSheet("下拉数据"); + + var newFileName = Guid.NewGuid() + ".xlsx"; + int listColIndex = 0; + //string sql = @"select 'Course' field, Id id, CourseNo no, CourseName name from Ghre_Course where IsEnable=1 and Status='Released'"; + //var dataSourceLists = await Db.Ado.SqlQueryAsync(sql); + //if (dataSourceLists.Any()) + //{ + // var types = new List + // { + // "学习记录" + // }; + + // types.ForEach(sheetName => + // { + // int sheetIndex = hssfworkbook.GetSheetIndex(sheetName); + // if (sheetIndex >= 0) + // { + // sheet = hssfworkbook.GetSheetAt(sheetIndex); + + // SetCellDropdownList(sheet, 0, 0, dataSourceLists.Select(x => x.name).ToArray()); + // } + + // }); + // MemoryStream ms; + // using (ms = new MemoryStream()) + // { + // hssfworkbook.Write(ms); + // ms.Flush(); + // hssfworkbook.Dispose(); + // //ms.Position = 0; + // //return ms; + // } + // using (FileStream fs = new FileStream(physicsPath + path + newFileName, FileMode.Create, FileAccess.Write)) + // { + // byte[] data = ms.ToArray(); + // fs.Write(data, 0, data.Length); + // fs.Flush(); + // } + + //} + + var physicsPath1 = physicsPath + path + fileName; + if (menuName == "F_TrainPlan_Temporary") + return ServiceResult.OprateSuccess("计划暂存_" + DateTimeHelper.ConvertToSecondString1(DateTime.Now) + ".xlsx", physicsPath1); + else + return ServiceResult.OprateSuccess("计划维护_" + DateTimeHelper.ConvertToSecondString1(DateTime.Now) + ".xlsx", physicsPath1); + + } } \ No newline at end of file