add 增加新表格 城市更新0318
This commit is contained in:
@@ -28,6 +28,14 @@ namespace TempTask.WebEntry.ApiController.Dto
|
||||
/// </summary>
|
||||
public class NumZjExcel
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否采用Excel的新配置方式
|
||||
/// </summary>
|
||||
public bool is_excel_config { get; set; } = false;
|
||||
///// <summary>
|
||||
///// Excel新配置方式文件路径
|
||||
///// </summary>
|
||||
//public string excel_config_path { get; set; }
|
||||
/// <summary>
|
||||
/// sheet编号 从1开始
|
||||
/// </summary>
|
||||
|
||||
@@ -30,8 +30,7 @@ namespace TempTask.WebEntry.ApiController
|
||||
{
|
||||
var configs = App.GetConfig<NumZjConfig>("NumZjConfig");
|
||||
var current = configs.numZjExcels.Find(a => (int)a.excel_no == numZjDownloadInput.type);
|
||||
//var sheet_names = new Dictionary<int, string> { { 4, "房地产业分行业(项目信息)" }, { 5, "分地区(项目信息)" } };
|
||||
var filepath = NumZjHelper.WriteTemplate(numZjDownloadInput.year, numZjDownloadInput.month, numZjDownloadInput.week, current.excel_no, current.sheets);
|
||||
var filepath = NumZjHelper.WriteTemplate(numZjDownloadInput.year, numZjDownloadInput.month, numZjDownloadInput.week, current);
|
||||
return new FileStreamResult(new FileStream(filepath, FileMode.Open), "application/octet-stream") { FileDownloadName = current.excel_name };
|
||||
});
|
||||
}
|
||||
|
||||
@@ -8,6 +8,16 @@
|
||||
<DocumentationFile>D:\temp_task\20220313\gitcode\number_zj\20220313_Excel\TempTask.WebEntry\TempTask.WebEntry.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="new_excel_config\1.xlsx" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="new_excel_config\1.xlsx">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Furion" Version="2.20.7" />
|
||||
<PackageReference Include="System.Configuration.ConfigurationManager" Version="5.0.0" />
|
||||
@@ -32,4 +42,6 @@
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -24,6 +24,11 @@
|
||||
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:TempTask.WebEntry.ApiController.Dto.NumZjExcel.is_excel_config">
|
||||
<summary>
|
||||
是否采用Excel的新配置方式
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:TempTask.WebEntry.ApiController.Dto.NumZjExcel.excel_no">
|
||||
<summary>
|
||||
sheet编号 从1开始
|
||||
@@ -84,6 +89,11 @@
|
||||
跳过行 集合 行留空
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:TempTask.WebEntry.ApiController.Dto.NumZjConfigSheet.skip_columns">
|
||||
<summary>
|
||||
跳过行 集合 行留空
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:TempTask.WebEntry.ApiController.Dto.NumZjDownloadInput">
|
||||
<summary>
|
||||
|
||||
@@ -207,11 +217,12 @@
|
||||
<param name="param">参数</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:TempTask.WebEntry.Tools.HttpHelper.CallUrl(System.String)">
|
||||
<member name="M:TempTask.WebEntry.Tools.HttpHelper.CallUrl(System.String,System.String)">
|
||||
<summary>
|
||||
|
||||
</summary>
|
||||
<param name="url"></param>
|
||||
<param name="param"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:TempTask.WebEntry.Tools.NumZjHelper">
|
||||
@@ -239,15 +250,19 @@
|
||||
房地产业
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:TempTask.WebEntry.Tools.NumZjHelper.WriteTemplate(System.Int32,System.Int32,System.Int32,TempTask.WebEntry.Tools.NumZjHelper.ExcelType,System.Collections.Generic.List{TempTask.WebEntry.ApiController.Dto.NumZjConfigSheet})">
|
||||
<member name="F:TempTask.WebEntry.Tools.NumZjHelper.ExcelType.城市更新0318">
|
||||
<summary>
|
||||
城市更新0318
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:TempTask.WebEntry.Tools.NumZjHelper.WriteTemplate(System.Int32,System.Int32,System.Int32,TempTask.WebEntry.ApiController.Dto.NumZjExcel)">
|
||||
<summary>
|
||||
|
||||
</summary>
|
||||
<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>
|
||||
</member>
|
||||
</members>
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
<el-dropdown-item command="1">总表</el-dropdown-item>
|
||||
<el-dropdown-item command="2">城市更新</el-dropdown-item>
|
||||
<el-dropdown-item command="3">房地产业</el-dropdown-item>
|
||||
<el-dropdown-item command="4">通报表格-城市更新0318</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
</div>
|
||||
@@ -69,6 +70,9 @@
|
||||
case "3":
|
||||
excel_name = "住建系统抓投资情况通报(房地产业+GDP支撑性指标).xlsx";
|
||||
break;
|
||||
case "4":
|
||||
excel_name = "通报表格(城市更新)2022-3-18.xls";
|
||||
break;
|
||||
}
|
||||
this.loading = true;
|
||||
this.download('/api/num-zj/download', a, excel_name, this.loading_false);
|
||||
|
||||
BIN
20220313_Excel/TempTask.WebEntry/new_excel_config/1.xlsx
Normal file
BIN
20220313_Excel/TempTask.WebEntry/new_excel_config/1.xlsx
Normal file
Binary file not shown.
@@ -18,7 +18,7 @@
|
||||
"start_cell": "B",
|
||||
"null_cell_count": 27,
|
||||
"url": "http://10.19.94.196:81/data-system/api/bigScreen/house/totalKeyRate?months={year}{_month}&week={week2}",
|
||||
"skip_rows": [ 10, 12 ],
|
||||
"skip_rows": [ 10, 12 ]
|
||||
|
||||
},
|
||||
{
|
||||
@@ -52,7 +52,7 @@
|
||||
"null_row_count": 14,
|
||||
"start_cell": "B",
|
||||
"null_cell_count": 27,
|
||||
"url": "http://10.19.94.196:81/data-system/api/bigScreen/house/areaKeyRate1?type=104,105,106,107,108,109&months={year}{_month}&week={week2}",
|
||||
"url": "http://10.19.94.196:81/data-system/api/bigScreen/house/areaKeyRate1?type=104,105,106,107,108,109&months={year}{_month}&week={week2}"
|
||||
//"skip_columns": [ "J", "S" ]
|
||||
},
|
||||
{
|
||||
@@ -95,7 +95,7 @@
|
||||
"null_row_count": 13,
|
||||
"start_cell": "B",
|
||||
"null_cell_count": 24,
|
||||
"url": "http://10.19.94.196:81/data-system/api/bigScreen/house/areaKeyRate1?type=101,102,103&months={year}{_month}&week={week2}",
|
||||
"url": "http://10.19.94.196:81/data-system/api/bigScreen/house/areaKeyRate1?type=101,102,103&months={year}{_month}&week={week2}"
|
||||
//"skip_columns": [ "P", "S" ]
|
||||
},
|
||||
{
|
||||
@@ -162,6 +162,89 @@
|
||||
"url": "http://10.19.94.196:81/data-system/api/bigScreen/house/houseProjectByArea?months={year}{_month}&w={week}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"excel_no": 4,
|
||||
"excel_name": "通报表格(城市更新)2022-3-18.xls",
|
||||
"is_excel_config": true,
|
||||
"sheets": [
|
||||
{
|
||||
"sheet_no": 1,
|
||||
"sheet_name": "城市更新"
|
||||
},
|
||||
{
|
||||
"sheet_no": 2,
|
||||
"sheet_name": "分行业",
|
||||
"start_row": 4,
|
||||
"null_row_count": 7,
|
||||
"start_cell": "L",
|
||||
"null_cell_count": 5,
|
||||
"url": "http://10.19.94.196:81/data-system/api/bigScreen/house/projectByInd "
|
||||
},
|
||||
{
|
||||
"sheet_no": 3,
|
||||
"sheet_name": "分地区",
|
||||
"start_row": 4,
|
||||
"null_row_count": 14,
|
||||
"start_cell": "L",
|
||||
"null_cell_count": 5,
|
||||
"url": "http://10.19.94.196:81/data-system/api/bigScreen/house/projectByArea?industry=104,105,106,107,108,109"
|
||||
},
|
||||
{
|
||||
"sheet_no": 4,
|
||||
"sheet_name": "未来社区",
|
||||
"start_row": 4,
|
||||
"null_row_count": 14,
|
||||
"start_cell": "L",
|
||||
"null_cell_count": 5,
|
||||
"url": "http://10.19.94.196:81/data-system/api/bigScreen/house/projectByArea?industry=105"
|
||||
},
|
||||
{
|
||||
"sheet_no": 5,
|
||||
"sheet_name": "老旧小区",
|
||||
"start_row": 4,
|
||||
"null_row_count": 14,
|
||||
"start_cell": "L",
|
||||
"null_cell_count": 5,
|
||||
"url": "http://10.19.94.196:81/data-system/api/bigScreen/house/projectByArea?industry=109"
|
||||
},
|
||||
{
|
||||
"sheet_no": 6,
|
||||
"sheet_name": "村镇建设",
|
||||
"start_row": 4,
|
||||
"null_row_count": 14,
|
||||
"start_cell": "L",
|
||||
"null_cell_count": 5,
|
||||
"url": "http://10.19.94.196:81/data-system/api/bigScreen/house/projectByArea?industry=108"
|
||||
},
|
||||
{
|
||||
"sheet_no": 7,
|
||||
"sheet_name": "综合管廊",
|
||||
"start_row": 4,
|
||||
"null_row_count": 14,
|
||||
"start_cell": "L",
|
||||
"null_cell_count": 5,
|
||||
"url": "http://10.19.94.196:81/data-system/api/bigScreen/house/projectByArea?industry=107"
|
||||
},
|
||||
{
|
||||
"sheet_no": 8,
|
||||
"sheet_name": "其他市政设施",
|
||||
"start_row": 4,
|
||||
"null_row_count": 14,
|
||||
"start_cell": "L",
|
||||
"null_cell_count": 5,
|
||||
"url": "http://10.19.94.196:81/data-system/api/bigScreen/house/projectByArea?industry=104"
|
||||
},
|
||||
{
|
||||
"sheet_no": 9,
|
||||
"sheet_name": "城市公园",
|
||||
"start_row": 4,
|
||||
"null_row_count": 14,
|
||||
"start_cell": "L",
|
||||
"null_cell_count": 5,
|
||||
"url": "http://10.19.94.196:81/data-system/api/bigScreen/house/projectByArea?industry=106"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user