diff --git a/Tiobon.Core.Api/Controllers/Ghre/Ghre_RequestController.cs b/Tiobon.Core.Api/Controllers/Ghre/Ghre_RequestController.cs index c7e89da3..f12f53d1 100644 --- a/Tiobon.Core.Api/Controllers/Ghre/Ghre_RequestController.cs +++ b/Tiobon.Core.Api/Controllers/Ghre/Ghre_RequestController.cs @@ -1,4 +1,6 @@ -namespace Tiobon.Core.Api.Controllers; +using Consul.Filtering; + +namespace Tiobon.Core.Api.Controllers; /// /// 培训需求(Controller) @@ -57,9 +59,29 @@ public class Ghre_RequestController : BaseController> ExportExcel([FromBody] QueryExport filter, string type) + { + return await _service.ExportGroupExcel(filter, type); + } + #endregion + + #region 新增 + [HttpPost("ExportGroupExcel/{type}")] public async Task> ExportGroupExcel([FromBody] QueryExport filter, string type) { return await _service.ExportGroupExcel(filter, type); } #endregion + + /// + /// 查询菜单表单信息 + /// + /// body + /// + [HttpPost("QueryForm/{status}")] + public async Task> QueryFormByStatus([FromBody] QueryForm body) + { + return await _service.QueryForm(body); + + } } \ No newline at end of file diff --git a/Tiobon.Core.Services/CommonServices.cs b/Tiobon.Core.Services/CommonServices.cs index 35207ab8..d30e9a1d 100644 --- a/Tiobon.Core.Services/CommonServices.cs +++ b/Tiobon.Core.Services/CommonServices.cs @@ -2393,6 +2393,13 @@ public partial class CommonServices : BaseServices>, ICommon index++; }); break; + + case "F_TrainingDemandStatistics_Year": + case "F_TrainingDemandStatistics_Month": + if (!string.IsNullOrWhiteSpace(result.DT_Procedure.EditProcedure)) + result.DT_Procedure.ExportExcel = result.DT_Procedure.EditProcedure.Replace("QueryGroupForm", "ExportGroupExcel"); + + break; } #endregion diff --git a/Tiobon.Core.Services/Ghre/Ghre_RequestServices.cs b/Tiobon.Core.Services/Ghre/Ghre_RequestServices.cs index 90926f3b..b49adbd9 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_RequestServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_RequestServices.cs @@ -826,6 +826,68 @@ WHERE B.IsEnable ! = A.IsEnable result.fileName = body.exportSet.TitleName + ".xlsx"; return ServiceResult.OprateSuccess("导出成功", result); } + + public async Task> ExportExcel(QueryExport body, string status) + { + QueryBody filter = new QueryBody(); + filter.pageNum = 1; + filter.jsonParam = body.jsonParam; + filter.pageSize = 1000000; + filter.langId = body.langId; + + var condition = "1=1"; + if (body.exportSet.SelectRowKeys != null && body.exportSet.SelectRowKeys.Any()) + condition += $" AND Id IN({string.Join(",", body.exportSet.SelectRowKeys)})"; + + var data = new ServicePageResult(0, 0, filter.pageSize, null); + + if (status == "Active") + data = await QueryFilterPage(filter, $"(Status ='Active' OR Status ='Wait' OR (WorkID IS NOT NULL AND WorkState IN (0,1)))"); + else if (status == "Disable") + data = await QueryFilterPage(filter, null, false); + else + data = await QueryFilterPage(filter, $"Status ='{status}' AND WorkID IS NULL"); + + string sql = $@"SELECT * + FROM Ghrs_PageSettingQuery + WHERE IsEnable = 1 + AND PageNo = '{body.menuName}' + AND (defaultHidden = 'false' OR defaultHidden is null) + ORDER BY SortNo ASC"; + + var columns = DbAccess.QueryList(sql); + + var fieldDescs = new Dictionary(); + if (body.exportSet.ExFields.Any()) + body.exportSet.ExFields.ForEach(x => + { + if (columns.Any(o => o.field == x)) + { + var label = columns.FirstOrDefault(o => o.field == x)?.label; + if (!fieldDescs.ContainsKey(x)) + fieldDescs.Add(x, label); + } + }); + else + fieldDescs = columns.ToDictionary(item => item.field, item => item.label); + var dt = ToDataTable(data.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 + body.exportSet.TitleName + ".xlsx"; + NPOIHelper.ExportExcel(dt, body.exportSet.TitleName, "sheet1", physicsPath + path); + + var result = new ExcelData(); + result.filePath = "/Advanced" + path; + result.fileName = body.exportSet.TitleName + ".xlsx"; + return ServiceResult.OprateSuccess("导出成功", result); + } #endregion } \ No newline at end of file