|
|
|
@ -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) |
|
|
|
|