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

@@ -28,6 +28,14 @@ namespace TempTask.WebEntry.ApiController.Dto
/// </summary> /// </summary>
public class NumZjExcel 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> /// <summary>
/// sheet编号 从1开始 /// sheet编号 从1开始
/// </summary> /// </summary>
@@ -82,7 +90,7 @@ namespace TempTask.WebEntry.ApiController.Dto
/// 跳过行 集合 行留空 /// 跳过行 集合 行留空
/// </summary> /// </summary>
public List<string> skip_columns { get; set; } public List<string> skip_columns { get; set; }
} }
/// <summary> /// <summary>
/// ///

View File

@@ -30,8 +30,7 @@ namespace TempTask.WebEntry.ApiController
{ {
var configs = App.GetConfig<NumZjConfig>("NumZjConfig"); var configs = App.GetConfig<NumZjConfig>("NumZjConfig");
var current = configs.numZjExcels.Find(a => (int)a.excel_no == numZjDownloadInput.type); 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);
var filepath = NumZjHelper.WriteTemplate(numZjDownloadInput.year, numZjDownloadInput.month, numZjDownloadInput.week, current.excel_no, current.sheets);
return new FileStreamResult(new FileStream(filepath, FileMode.Open), "application/octet-stream") { FileDownloadName = current.excel_name }; return new FileStreamResult(new FileStream(filepath, FileMode.Open), "application/octet-stream") { FileDownloadName = current.excel_name };
}); });
} }

View File

@@ -8,6 +8,16 @@
<DocumentationFile>D:\temp_task\20220313\gitcode\number_zj\20220313_Excel\TempTask.WebEntry\TempTask.WebEntry.xml</DocumentationFile> <DocumentationFile>D:\temp_task\20220313\gitcode\number_zj\20220313_Excel\TempTask.WebEntry\TempTask.WebEntry.xml</DocumentationFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<None Remove="new_excel_config\1.xlsx" />
</ItemGroup>
<ItemGroup>
<Content Include="new_excel_config\1.xlsx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Furion" Version="2.20.7" /> <PackageReference Include="Furion" Version="2.20.7" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="5.0.0" /> <PackageReference Include="System.Configuration.ConfigurationManager" Version="5.0.0" />
@@ -32,4 +42,6 @@
</Reference> </Reference>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@@ -24,6 +24,11 @@
</summary> </summary>
</member> </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"> <member name="P:TempTask.WebEntry.ApiController.Dto.NumZjExcel.excel_no">
<summary> <summary>
sheet编号 从1开始 sheet编号 从1开始
@@ -84,6 +89,11 @@
跳过行 集合 行留空 跳过行 集合 行留空
</summary> </summary>
</member> </member>
<member name="P:TempTask.WebEntry.ApiController.Dto.NumZjConfigSheet.skip_columns">
<summary>
跳过行 集合 行留空
</summary>
</member>
<member name="T:TempTask.WebEntry.ApiController.Dto.NumZjDownloadInput"> <member name="T:TempTask.WebEntry.ApiController.Dto.NumZjDownloadInput">
<summary> <summary>
@@ -207,11 +217,12 @@
<param name="param">参数</param> <param name="param">参数</param>
<returns></returns> <returns></returns>
</member> </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>
</summary> </summary>
<param name="url"></param> <param name="url"></param>
<param name="param"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="T:TempTask.WebEntry.Tools.NumZjHelper"> <member name="T:TempTask.WebEntry.Tools.NumZjHelper">
@@ -239,15 +250,19 @@
房地产业 房地产业
</summary> </summary>
</member> </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>
</summary> </summary>
<param name="year"></param> <param name="year"></param>
<param name="month"></param> <param name="month"></param>
<param name="week"></param> <param name="week"></param>
<param name="excelType"></param> <param name="numZjExcel"></param>
<param name="sheets"></param>
<returns></returns> <returns></returns>
</member> </member>
</members> </members>

View File

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

View File

@@ -33,6 +33,7 @@
<el-dropdown-item command="1">总表</el-dropdown-item> <el-dropdown-item command="1">总表</el-dropdown-item>
<el-dropdown-item command="2">城市更新</el-dropdown-item> <el-dropdown-item command="2">城市更新</el-dropdown-item>
<el-dropdown-item command="3">房地产业</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-menu>
</el-dropdown> </el-dropdown>
</div> </div>
@@ -69,6 +70,9 @@
case "3": case "3":
excel_name = "住建系统抓投资情况通报(房地产业+GDP支撑性指标.xlsx"; excel_name = "住建系统抓投资情况通报(房地产业+GDP支撑性指标.xlsx";
break; break;
case "4":
excel_name = "通报表格城市更新2022-3-18.xls";
break;
} }
this.loading = true; this.loading = true;
this.download('/api/num-zj/download', a, excel_name, this.loading_false); this.download('/api/num-zj/download', a, excel_name, this.loading_false);

View File

@@ -18,8 +18,8 @@
"start_cell": "B", "start_cell": "B",
"null_cell_count": 27, "null_cell_count": 27,
"url": "http://10.19.94.196:81/data-system/api/bigScreen/house/totalKeyRate?months={year}{_month}&week={week2}", "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 ]
}, },
{ {
"sheet_no": 2, "sheet_no": 2,
@@ -52,7 +52,7 @@
"null_row_count": 14, "null_row_count": 14,
"start_cell": "B", "start_cell": "B",
"null_cell_count": 27, "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" ] //"skip_columns": [ "J", "S" ]
}, },
{ {
@@ -95,7 +95,7 @@
"null_row_count": 13, "null_row_count": 13,
"start_cell": "B", "start_cell": "B",
"null_cell_count": 24, "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" ] //"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}" "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"
}
]
} }
] ]
} }