【牛尾】培训计划新增Excel导出

master
xiaochanghai 2 weeks ago
parent 893df17b4a
commit 2237ece5fa
  1. BIN
      Lib/Tiobon.Core.Base.dll
  2. BIN
      Lib/Tiobon.Core.Model.Entity.dll
  3. 55
      Lib/Tiobon.Core.Model.Entity.xml
  4. BIN
      Tiobon.Core.Api/wwwroot/MVP_Logo_Horizontal_Preferred_Cyan300_CMYK_72ppi.png
  5. 1
      Tiobon.Core.Common/DB/Aop/SqlsugarAop.cs
  6. 6
      Tiobon.Core.Common/DB/RepositorySetting.cs
  7. 83
      Tiobon.Core.Common/Helper/NPOIHelper.cs
  8. 78
      Tiobon.Core.Model/Base/BasePoco.cs
  9. 4
      Tiobon.Core.Model/Models/RootTkey/BaseEntity.cs
  10. 13
      Tiobon.Core.Model/Models/RootTkey/Interface/IDeleteFilter.cs
  11. 103
      Tiobon.Core.Services/Ghre/Ghre_PlanServices.cs
  12. 1
      Tiobon.Core.Services/Ghre/Ghre_StudyRuleServices.cs
  13. 55
      Tiobon.Core/Tiobon.Core.Model.xml

Binary file not shown.

Binary file not shown.

@ -4,6 +4,61 @@
<name>Tiobon.Core.Model.Entity</name>
</assembly>
<members>
<member name="P:Tiobon.Core.Model.Entity.BasePoco.Id">
<summary>
表主键
</summary>
</member>
<member name="P:Tiobon.Core.Model.Entity.BasePoco1.IsEnable">
<summary>
1:有效,0:未生效
</summary>
</member>
<member name="P:Tiobon.Core.Model.Entity.BasePoco1.CreateBy">
<summary>
创建人
</summary>
</member>
<member name="P:Tiobon.Core.Model.Entity.BasePoco1.CreateTime">
<summary>
创建时间
</summary>
</member>
<member name="P:Tiobon.Core.Model.Entity.BasePoco1.CreateProg">
<summary>
创建程序
</summary>
</member>
<member name="P:Tiobon.Core.Model.Entity.BasePoco1.CreateIP">
<summary>
创建IP
</summary>
</member>
<member name="P:Tiobon.Core.Model.Entity.BasePoco1.UpdateBy">
<summary>
最后修改人
</summary>
</member>
<member name="P:Tiobon.Core.Model.Entity.BasePoco1.UpdateTime">
<summary>
最后修改时间
</summary>
</member>
<member name="P:Tiobon.Core.Model.Entity.BasePoco1.UpdateProg">
<summary>
最后修改程序
</summary>
</member>
<member name="P:Tiobon.Core.Model.Entity.BasePoco1.UpdateIP">
<summary>
最后修改IP
</summary>
</member>
<member name="T:Tiobon.Core.Model.Entity.IDeleteFilter">
<summary>
软删除 过滤器
</summary>
</member>
<member name="T:Tiobon.Core.Model.Entity.QueryBody">
<summary>
动态查询条件

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

@ -5,6 +5,7 @@ using StackExchange.Profiling;
using Tiobon.Core.Common.LogHelper;
using Tiobon.Core.Common.UserManager;
using Tiobon.Core.Model;
using Tiobon.Core.Model.Entity;
using Tiobon.Core.Model.Models.RootTkey;
using Tiobon.Core.Model.Tenants;

@ -1,7 +1,7 @@
using Tiobon.Core.Model.Models.RootTkey;
using Tiobon.Core.Model.Models.RootTkey.Interface;
using SqlSugar;
using Tiobon.Core.Model.Entity;
using Tiobon.Core.Model.Models.RootTkey;
using Tiobon.Core.Model.Tenants;
using SqlSugar;
namespace Tiobon.Core.Common.DB;

@ -186,6 +186,80 @@ public class NPOIHelper
}
#endregion
#region 培训计划【牛尾】
if (sheetName == "培训计划【牛尾】")
{
HeightInPoints = 15;
#region 标题单元格样式
ICellStyle titleStyle = workbook.CreateCellStyle();
titleStyle.Alignment = HorizontalAlignment.Center; //居中
titleStyle.VerticalAlignment = VerticalAlignment.Center;//垂直居中
titleStyle.WrapText = true;//自动换行
// 边框
titleStyle.BorderBottom = BorderStyle.Thin;
titleStyle.BorderLeft = BorderStyle.Thin;
titleStyle.BorderRight = BorderStyle.Thin;
titleStyle.BorderTop = BorderStyle.Thin;
IFont font = workbook.CreateFont();
font.FontHeightInPoints = (short)10;
font.FontName = "宋体";
font.IsBold = true;
titleStyle.SetFont(font);
#endregion
IRow headerRow = sheet.CreateRow(intTop);
headerRow.HeightInPoints = HeightInPoints;
for (int i = 0; i < 13; i++)
{
headerRow.CreateCell(i).SetCellValue(dtSource.Columns[i].ColumnName);
headerRow.GetCell(i).CellStyle = titleStyle;
sheet.AddMergedRegion(new NPOI.SS.Util.CellRangeAddress(0 + intTop, 1 + intTop, i, i));
}
for (int i = 13; i < 36; i = i + 2)
{
string month = dtSource.Columns[i].ColumnName.Replace("实际合计人天_M", "") + "月";
//month = month.Replace("进展率_M", "");
headerRow.CreateCell(i).SetCellValue(month);
headerRow.GetCell(i).CellStyle = titleStyle;
headerRow.CreateCell(i + 1).SetCellValue(month);
headerRow.GetCell(i + 1).CellStyle = titleStyle;
sheet.AddMergedRegion(new NPOI.SS.Util.CellRangeAddress(intTop, intTop, i, i + 1));
}
for (int i = 37; i < 42; i++)
{
headerRow.CreateCell(i).SetCellValue(dtSource.Columns[i].ColumnName);
headerRow.GetCell(i).CellStyle = titleStyle;
sheet.AddMergedRegion(new NPOI.SS.Util.CellRangeAddress(0 + intTop, 1 + intTop, i, i));
}
//for (int i = 5; i < 17; i++)
//{
// headerRow.CreateCell(i).SetCellValue("预算编制数");
// headerRow.GetCell(i).CellStyle = titleStyle;
//}
////headerRow.CreateCell(5).SetCellValue("预算编制数");
////headerRow.GetCell(5).CellStyle = titleStyle;
//headerRow.CreateCell(17).SetCellValue("备注");
//headerRow.GetCell(17).CellStyle = titleStyle;
//for (int i = 36; i < 41; i++)
//sheet.AddMergedRegion(new NPOI.SS.Util.CellRangeAddress(0 + intTop, 1 + intTop, 17, 17));
//sheet.AddMergedRegion(new NPOI.SS.Util.CellRangeAddress(0 + intTop, 0 + intTop, 5, 16));
intTop += 1;
}
#endregion
#region 列头及样式
{
IRow headerRow = sheet.CreateRow(intTop);
@ -218,7 +292,14 @@ public class NPOIHelper
//headStyle.SetFont(font);
foreach (DataColumn column in dtSource.Columns)
{
headerRow.CreateCell(column.Ordinal).SetCellValue(column.ColumnName);
var name = column.ColumnName;
if (name.IndexOf("实际合计人天") > -1)
name = "实际合计人天";
if (name.IndexOf("进展率") > -1)
name = "进展率";
headerRow.CreateCell(column.Ordinal).SetCellValue(name);
headerRow.GetCell(column.Ordinal).CellStyle = headStyle;
//设置列宽
//sheet.SetColumnWidth(column.Ordinal, (arrColWidth[column.Ordinal] + 1) * 256);

@ -1,78 +0,0 @@
using Tiobon.Core.Model.Models.RootTkey.Interface;
namespace Tiobon.Core.Model;
public class BasePoco : BasePoco1
{
/// <summary>
/// 表主键
/// </summary>
//public long Id { get; set; }
[SugarColumn(IsNullable = false, IsPrimaryKey = true, IsIdentity = false), Display(Name = "表主键")]
public long Id { get; set; }
}
public class BasePoco1 : IBaseDeleteFilter
{
/// <summary>
/// 1:有效,0:未生效
/// </summary>
[Display(Name = "1:有效,0:未生效")]
public int IsEnable { get; set; } = 1;
///// <summary>
///// 操作日志ID
///// </summary>
//[Display(Name = "操作日志ID")]
//public long? OperateLogID { get; set; }
/// <summary>
/// 创建人
/// </summary>
[Display(Name = "创建人"), SugarColumn(IsOnlyIgnoreUpdate = true)]
public int? CreateBy { get; set; }
/// <summary>
/// 创建时间
/// </summary>
[Display(Name = "创建时间"), SugarColumn(IsOnlyIgnoreUpdate = true)]
public DateTime? CreateTime { get; set; }
/// <summary>
/// 创建程序
/// </summary>
[Display(Name = "创建程序"), SugarColumn(IsOnlyIgnoreUpdate = true)]
public string CreateProg { get; set; }
/// <summary>
/// 创建IP
/// </summary>
[Display(Name = "创建IP"), SugarColumn(IsOnlyIgnoreUpdate = true)]
public string CreateIP { get; set; }
/// <summary>
/// 最后修改人
/// </summary>
[Display(Name = "最后修改人")]
public int? UpdateBy { get; set; }
/// <summary>
/// 最后修改时间
/// </summary>
[Display(Name = "最后修改时间")]
public DateTime? UpdateTime { get; set; }
/// <summary>
/// 最后修改程序
/// </summary>
[Display(Name = "最后修改程序")]
public string UpdateProg { get; set; }
/// <summary>
/// 最后修改IP
/// </summary>
[Display(Name = "最后修改IP")]
public string UpdateIP { get; set; }
}

@ -1,6 +1,4 @@
using Tiobon.Core.Model.Models.RootTkey.Interface;
namespace Tiobon.Core.Model.Models.RootTkey;
namespace Tiobon.Core.Model.Models.RootTkey;
[SugarIndex("index_{table}_Enabled", nameof(Enabled), OrderByType.Asc)]
[SugarIndex("index_{table}_IsDeleted", nameof(IsDeleted), OrderByType.Asc)]

@ -1,13 +0,0 @@
namespace Tiobon.Core.Model.Models.RootTkey.Interface;
/// <summary>
/// 软删除 过滤器
/// </summary>
public interface IDeleteFilter
{
public bool IsDeleted { get; set; }
}
public interface IBaseDeleteFilter
{
public int IsEnable { get; set; }
}

@ -394,11 +394,11 @@ public class Ghre_PlanServices : BaseServices<Ghre_Plan, Ghre_PlanDto, InsertGhr
filter.langId = body.langId;
filter.menuName = body.menuName;
var condition = "1=1";
if (body.exportSet.SelectRowKeys != null && body.exportSet.SelectRowKeys.Any())
condition += $" AND Id IN({string.Join(",", body.exportSet.SelectRowKeys)})";
//var condition = "1=1";
//if (body.exportSet.SelectRowKeys != null && body.exportSet.SelectRowKeys.Any())
// condition += $" AND Id IN({string.Join(",", body.exportSet.SelectRowKeys)})";
var data = await QueryFilterPage(filter, condition, true);
var data = await QueryUshioPlan(filter);
var columns = data.result.JM_TableColumnT1.TableColumn;
@ -411,7 +411,7 @@ public class Ghre_PlanServices : BaseServices<Ghre_Plan, Ghre_PlanDto, InsertGhr
});
else
fieldDescs = columns.ToDictionary(item => item.field, item => item.label);
var dt = ToDataTable(data.result.DT_TableDataT1, fieldDescs, null);
var dt = ToUshioDataTable(data.result.DT_TableDataT1, fieldDescs, null);
// 获取所有列名
var dtColumns = dt.Columns;
@ -422,13 +422,104 @@ public class Ghre_PlanServices : BaseServices<Ghre_Plan, Ghre_PlanDto, InsertGhr
Directory.CreateDirectory(physicsPath + path);
path = path + body.exportSet.TitleName + ".xlsx";
NPOIHelper.ExportExcel(dt, body.exportSet.TitleName, "年度人力配置", physicsPath + path);
NPOIHelper.ExportExcel(dt, body.exportSet.TitleName, "培训计划【牛尾】", physicsPath + path);
var result = new ExcelData();
result.filePath = "/Advanced" + path;
result.fileName = body.exportSet.TitleName + ".xlsx";
return ServiceResult<ExcelData>.OprateSuccess("导出成功", result);
}
public static DataTable ToUshioDataTable(List<UshioPlanReport> list, Dictionary<string, string> fieldDescs = null, params string[] propertyName)
{
var (fields, colunms) = Sort(fieldDescs, null);
List<string> propertyNameList = new List<string>();
if (propertyName != null)
{
propertyNameList.AddRange(propertyName);
}
DataTable result = new DataTable();
if (list.Count > 0)
{
PropertyInfo[] propertys = list[0].GetType().GetProperties();
for (int i = 0; i < fields.Count; i++)
{
foreach (PropertyInfo pi in propertys)
{
if (propertyNameList.Count == 0)
{
//if (DBNull.Value.Equals(pi.PropertyType))
//{
// // pi.PropertyType = DateTime;
//}
Type colType = pi.PropertyType;
if (colType.IsGenericType && colType.GetGenericTypeDefinition() == typeof(Nullable<>))
{
colType = colType.GetGenericArguments()[0];
}
if (fields[i] == pi.Name)
{
if (fields[i].IndexOf("_Count") > 0)
result.Columns.Add(colunms[i] + "_" + fields[i].Replace("_Count", ""), colType);
else if (fields[i].IndexOf("_CompletionRate") > 0)
result.Columns.Add(colunms[i] + "_" + fields[i].Replace("_CompletionRate", ""), colType);
else
result.Columns.Add(colunms[i], colType);
}
//result.Columns.Add(pi.Name, pi.PropertyType);
}
else
{
if (propertyNameList.Contains(pi.Name))
{
if (fields[i] == pi.Name)
result.Columns.Add(fields[i], pi.PropertyType);
}
}
}
}
for (int i = 0; i < list.Count; i++)
{
ArrayList tempList = new ArrayList();
for (int j = 0; j < fields.Count; j++)
{
foreach (PropertyInfo pi in propertys)
{
if (fields[j] == pi.Name)
{
if (propertyNameList.Count == 0)
{
object obj = pi.GetValue(list[i], null);
tempList.Add(obj);
}
else
{
if (propertyNameList.Contains(pi.Name))
{
object obj = pi.GetValue(list[i], null);
tempList.Add(obj);
}
}
}
}
}
object[] array = tempList.ToArray();
try
{
result.LoadDataRow(array, true);
}
catch (Exception E)
{
}
}
}
return result;
}
#endregion
public override async Task<ServiceResult<string>> DownloadExcel(string menuName)

@ -1,5 +1,4 @@
using MongoDB.Driver.Linq;
using Tiobon.Core.Model.Models.RootTkey.Interface;
using static Tiobon.Core.Model.Consts;
namespace Tiobon.Core.Services;

@ -4,56 +4,6 @@
<name>Tiobon.Core.Model</name>
</assembly>
<members>
<member name="P:Tiobon.Core.Model.BasePoco.Id">
<summary>
表主键
</summary>
</member>
<member name="P:Tiobon.Core.Model.BasePoco1.IsEnable">
<summary>
1:有效,0:未生效
</summary>
</member>
<member name="P:Tiobon.Core.Model.BasePoco1.CreateBy">
<summary>
创建人
</summary>
</member>
<member name="P:Tiobon.Core.Model.BasePoco1.CreateTime">
<summary>
创建时间
</summary>
</member>
<member name="P:Tiobon.Core.Model.BasePoco1.CreateProg">
<summary>
创建程序
</summary>
</member>
<member name="P:Tiobon.Core.Model.BasePoco1.CreateIP">
<summary>
创建IP
</summary>
</member>
<member name="P:Tiobon.Core.Model.BasePoco1.UpdateBy">
<summary>
最后修改人
</summary>
</member>
<member name="P:Tiobon.Core.Model.BasePoco1.UpdateTime">
<summary>
最后修改时间
</summary>
</member>
<member name="P:Tiobon.Core.Model.BasePoco1.UpdateProg">
<summary>
最后修改程序
</summary>
</member>
<member name="P:Tiobon.Core.Model.BasePoco1.UpdateIP">
<summary>
最后修改IP
</summary>
</member>
<member name="T:Tiobon.Core.Model.Models.Ghra_GradeBase">
<summary>
年级 (Dto.Base)
@ -38794,11 +38744,6 @@
数据版本
</summary>
</member>
<member name="T:Tiobon.Core.Model.Models.RootTkey.Interface.IDeleteFilter">
<summary>
软删除 过滤器
</summary>
</member>
<member name="T:Tiobon.Core.Model.Models.SysTenant">
<summary>
系统租户表 <br/>

Loading…
Cancel
Save