add 增加新表格 城市更新0318

This commit is contained in:
路 范
2022-03-18 21:47:56 +08:00
parent 65f0634157
commit 9c04581fbb
11 changed files with 153 additions and 19 deletions

View File

@@ -36,7 +36,12 @@ namespace TempTask.WebEntry.Tools
/// 房地产业
/// </summary>
[Description("住建系统抓投资情况通报(房地产业+GDP支撑性指标样表.xlsx")]
= 3
= 3,
/// <summary>
/// 城市更新0318
/// </summary>
[Description("通报表格城市更新2022-3-18.xls")]
0318 = 4
}
/// <summary>
///
@@ -44,17 +49,16 @@ namespace TempTask.WebEntry.Tools
/// <param name="year"></param>
/// <param name="month"></param>
/// <param name="week"></param>
/// <param name="excelType"></param>
/// <param name="sheets"></param>
/// <param name="numZjExcel"></param>
/// <returns></returns>
public static string WriteTemplate(int year, int month, int week, ExcelType excelType, List<NumZjConfigSheet> sheets)
public static string WriteTemplate(int year, int month, int week, NumZjExcel numZjExcel)
{
try
{
var _month = month.ToString().Length == 1 ? ("0" + month) : month.ToString();
var week2 = week < 10 ? ("0" + week) : week.ToString();
int excelTypeInt = (int)excelType;
string template_name = EnumHelper.GetEnumDescription<ExcelType>(excelType);
int excelTypeInt = (int)numZjExcel.excel_no;
string template_name = EnumHelper.GetEnumDescription<ExcelType>(numZjExcel.excel_no);
string excelFilePath = $"{App.WebHostEnvironment.WebRootPath}\\ExcelTemplate\\{template_name}";
string outputPath = string.Empty;
if (!string.IsNullOrEmpty(excelFilePath))
@@ -63,7 +67,7 @@ namespace TempTask.WebEntry.Tools
{
bool isCompatible = ExcelHelper.GetIsCompatible(excelFilePath);
IWorkbook workbook = ExcelHelper.CreateWorkbook(isCompatible, excelFileStream);
foreach (var sheet_item in sheets)
foreach (var sheet_item in numZjExcel.sheets)
{
if (sheet_item.url.IsNullOrEmpty())
continue;
@@ -76,6 +80,7 @@ namespace TempTask.WebEntry.Tools
//{
// sheet = workbook.GetSheet(sheet_name.Value);
//}
Dictionary<string, string> dic_sheet_config = new Dictionary<string, string>();
var api_result = HttpHelper.CallUrl(sheet_item.url.Replace("{year}", year.ToString()).Replace("{_month}", _month).Replace("{week}", week.ToString()).Replace("{week2}", week2), "");
var obj = JObject.Parse(api_result);
var datas = obj["data"] as JArray;
@@ -103,7 +108,15 @@ namespace TempTask.WebEntry.Tools
var column_letter = x.ToExcelColumnName();
if (sheet_item.skip_columns != null && sheet_item.skip_columns.Contains(column_letter))
continue;
var api_column_name = App.Configuration[$"column_name_match_{excelTypeInt}_{sheet_item.sheet_no}:{ x.ToExcelColumnName()}"];
string api_column_name = string.Empty;
if (numZjExcel.is_excel_config)
{
if (!dic_sheet_config.ContainsKey(column_letter))
dic_sheet_config.Add(column_letter, sheet.GetRow(startRowIndex).GetCell(x).StringCellValue);
api_column_name = dic_sheet_config[column_letter];
}
else
api_column_name = App.Configuration[$"column_name_match_{excelTypeInt}_{sheet_item.sheet_no}:{ x.ToExcelColumnName()}"];
if (string.IsNullOrWhiteSpace(api_column_name))
continue;
var jtoken = datas[i - current_skip_count][api_column_name];