diff --git a/Backend/Views/BuildMenu/Index.cshtml b/Backend/Views/BuildMenu/Index.cshtml index c8ff911..07d0521 100644 --- a/Backend/Views/BuildMenu/Index.cshtml +++ b/Backend/Views/BuildMenu/Index.cshtml @@ -509,7 +509,7 @@ { "data": null, "render": function (data, type, row, meta){ - return ' '; + return ' '; } } ], diff --git a/Backend/Views/UserInfo/_RoleAuth.cshtml b/Backend/Views/UserInfo/_RoleAuth.cshtml index 0416027..9c9b339 100644 --- a/Backend/Views/UserInfo/_RoleAuth.cshtml +++ b/Backend/Views/UserInfo/_RoleAuth.cshtml @@ -23,7 +23,7 @@ # 角色 功能類型 - 區域 + 棟別 功能名稱 功能細項名稱 建立時間 diff --git a/FrontendWebApi/ApiControllers/EmergencyContactController.cs b/FrontendWebApi/ApiControllers/EmergencyContactController.cs index b8b4fba..4417dc9 100644 --- a/FrontendWebApi/ApiControllers/EmergencyContactController.cs +++ b/FrontendWebApi/ApiControllers/EmergencyContactController.cs @@ -107,7 +107,7 @@ namespace FrontendWebApi.ApiControllers [HttpPost] [Route("api/EmergencyContact/PDF")] - public async Task>> ExportPDF(export post) + public async Task>> ExportPDF([FromBody] export post) { //var grouping = JsonConvert.DeserializeObject(post); ApiResult apiResult = new ApiResult(); @@ -182,7 +182,7 @@ namespace FrontendWebApi.ApiControllers [HttpPost] [Route("api/EmergencyContact/Excel")] - public async Task>> ExportExcel(export post) + public async Task>> ExportExcel([FromBody] export post) { //var guid = Guid.NewGuid().ToString(); ApiResult apiResult = new ApiResult(); diff --git a/FrontendWebApi/ApiControllers/HydroMeterController.cs b/FrontendWebApi/ApiControllers/HydroMeterController.cs index 7275e6c..5bfda67 100644 --- a/FrontendWebApi/ApiControllers/HydroMeterController.cs +++ b/FrontendWebApi/ApiControllers/HydroMeterController.cs @@ -766,7 +766,157 @@ namespace FrontendWebApi.ApiControllers Response.Headers.Add("Access-Control-Expose-Headers", "Content-Disposition"); return File(ms, "application/vnd.ms-excel", "電表報表.xlsx"); } + [HttpPost] + [Route("api/ExportWaterList")] + public FileResult OpeExportExcelWater([FromBody] HydroMeterInput input) + { + var result = this.WaterList(input).Result.Value.Data.ToList(); + + var workbook = new XSSFWorkbook(); + #region excel設定 + IFont font12 = workbook.CreateFont(); + font12.FontName = "新細明體"; + font12.FontHeightInPoints = 12; + ICellStyle style12 = workbook.CreateCellStyle(); + style12.SetFont(font12); + style12.Alignment = HorizontalAlignment.Center; + style12.VerticalAlignment = VerticalAlignment.Center; + IFont font12Times = workbook.CreateFont(); + font12Times.FontName = "Times New Roman"; + font12Times.FontHeightInPoints = 12; + IFont font18 = workbook.CreateFont(); + font18.FontName = "新細明體"; + font18.FontHeightInPoints = 18; + font18.IsBold = true; + ICellStyle styleTitle18 = workbook.CreateCellStyle(); + styleTitle18.SetFont(font18); + styleTitle18.Alignment = HorizontalAlignment.Center; + styleTitle18.VerticalAlignment = VerticalAlignment.Center; + ICellStyle styleLeft12 = workbook.CreateCellStyle(); + styleLeft12.SetFont(font12); + styleLeft12.Alignment = HorizontalAlignment.Left; + styleLeft12.VerticalAlignment = VerticalAlignment.Center; + ICellStyle styleLine12 = workbook.CreateCellStyle(); + styleLine12.SetFont(font12); + styleLine12.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center; + styleLine12.VerticalAlignment = VerticalAlignment.Center; + styleLine12.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin; + styleLine12.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin; + styleLine12.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin; + styleLine12.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin; + ICellStyle stylein12 = workbook.CreateCellStyle(); + stylein12.SetFont(font12Times); + stylein12.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Left; + stylein12.VerticalAlignment = VerticalAlignment.Center; + stylein12.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin; + stylein12.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin; + stylein12.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin; + stylein12.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin; + stylein12.WrapText = true; + #endregion + + var sheet = workbook.CreateSheet("電表報表"); + int RowPosition = 0; + if (result.Count > 0) + { + #region set cell + IRow row = sheet.CreateRow(RowPosition); + sheet.SetColumnWidth(0, 4 * 160 * 12); + sheet.SetColumnWidth(1, 4 * 160 * 12); + sheet.SetColumnWidth(2, 4 * 160 * 12); + + int i = 0; + ICell cell = row.CreateCell(i++); + cell.SetCellValue("東別"); + cell.CellStyle = styleLine12; + cell = row.CreateCell(i++); + cell.SetCellValue("樓層"); + cell.CellStyle = styleLine12; + cell = row.CreateCell(i++); + cell.SetCellValue("設備"); + cell.CellStyle = styleLine12; + + foreach (var rr in result.FirstOrDefault().rawData) + { + cell = row.CreateCell(i++); + cell.SetCellValue(rr.timeStamp); + cell.CellStyle = styleLine12; + } + + cell = row.CreateCell(i++); + cell.SetCellValue("小計"); + cell.CellStyle = styleLine12; + cell = row.CreateCell(i++); + cell.SetCellValue("單價"); + cell.CellStyle = styleLine12; + cell = row.CreateCell(i++); + cell.SetCellValue("金額總計"); + cell.CellStyle = styleLine12; + #endregion + + foreach (var r in result) + { + RowPosition += 1; + int k = 3; + row = sheet.CreateRow(RowPosition); + for (int j = 0; j <= i; j++) + { + cell = row.CreateCell(j); + if (j == 0) + { + cell.SetCellValue(r.building_name); + } + if (j == 1) + { + cell.SetCellValue(r.floor_tag); + } + if (j == 2) + { + cell.SetCellValue(r.device_serial_tag); + } + + if (j == 3) + { + foreach (var rr in r.rawData) + { + cell.SetCellValue(rr.avg_rawdata.ToString()); + j++; + k++; + cell = row.CreateCell(j); + } + } + + if (j == k) + { + cell.SetCellValue(r.total); + } + if (j == k + 1) + { + cell.SetCellValue(r.price); + } + if (j == k + 2) + { + cell.SetCellValue(r.total_price); + } + + cell.CellStyle = style12; + } + } + } + + var ms = new NpoiMemoryStream + { + AllowClose = false + }; + workbook.Write(ms); + ms.Flush(); + ms.Seek(0, SeekOrigin.Begin); + + Response.Headers.Add("Access-Control-Expose-Headers", "Content-Disposition"); + + return File(ms, "application/vnd.ms-excel", "水表報表.xlsx"); + } public static int GetDayInMonth(string yearMonth) { List datesList = new List(); diff --git a/FrontendWebApi/Views/EmergencyContact/Index.cshtml b/FrontendWebApi/Views/EmergencyContact/Index.cshtml index 0a05b26..bbd3c77 100644 --- a/FrontendWebApi/Views/EmergencyContact/Index.cshtml +++ b/FrontendWebApi/Views/EmergencyContact/Index.cshtml @@ -32,8 +32,6 @@
- -
@@ -201,8 +199,7 @@ } //選擇組別 - function SelectGrouping(grouping, e) - { + function SelectGrouping(grouping, e) { if ($(e).hasClass("btn-outline-success")) { $(e).removeClass("btn-outline-success").addClass("btn-success"); selectgroupidlist.push(grouping); @@ -218,8 +215,7 @@ } //全選所有組別 - function Allgroupingselect() - { + function Allgroupingselect() { if (Allgroupingbool) { $('#groupinglist').find(".btn-success").removeClass("btn-success").addClass("btn-outline-success"); selectgroupidlist = []; @@ -249,7 +245,27 @@ disaster: $('#Disasterlist').find('.btn-success').html(), groupidlist: selectgroupidlist } - window.location = "/EmergencyContact/ExportPDF?post=" + JSON.stringify(send_data); + + var url = "/api/EmergencyContact/PDF"; + $.ajax({ + method: "POST", + contentType:"application/json; chatset='utf-8'", + headers: { "Authorization": "Bearer " + localStorage.getItem('JWT-Authorization') }, + url: url, + data: JSON.stringify(send_data), + success: (res, text, xhr) => { + if (res.code == "9999") { + toast_error(res.msg); + return; + } + if(res.data && res.code == "0000"){ + window.open(location.origin + "/" + res.data) + } else { + toast_error("系統發生錯誤,請再重新嘗試"); + } + + } + }) } } @@ -269,7 +285,25 @@ disaster: $('#Disasterlist').find('.btn-success').html(), groupidlist: selectgroupidlist } - window.location = "/EmergencyContact/ExportExcel?post=" + JSON.stringify(send_data); + var url = "/api/EmergencyContact/Excel"; + $.ajax({ + method: "POST", + contentType: "application/json; chatset='utf-8'", + headers: { "Authorization": "Bearer " + localStorage.getItem('JWT-Authorization') }, + url: url, + data: JSON.stringify(send_data), + success: (res, text, xhr) => { + if (res.code == "9999") { + toast_error(res.msg); + return; + } + if(res.data && res.code == "0000"){ + window.open(location.origin + "/" + res.data) + } else { + toast_error("系統發生錯誤,請再重新嘗試"); + } + } + }) } } diff --git a/FrontendWebApi/wwwroot/excel/緊急應變_聯絡清單_20230725_131117.pdf b/FrontendWebApi/wwwroot/excel/緊急應變_聯絡清單_20230725_131117.pdf new file mode 100644 index 0000000..94e65be Binary files /dev/null and b/FrontendWebApi/wwwroot/excel/緊急應變_聯絡清單_20230725_131117.pdf differ diff --git a/FrontendWebApi/wwwroot/excel/緊急應變_聯絡清單_20230725_131124.pdf b/FrontendWebApi/wwwroot/excel/緊急應變_聯絡清單_20230725_131124.pdf new file mode 100644 index 0000000..1bf50b0 Binary files /dev/null and b/FrontendWebApi/wwwroot/excel/緊急應變_聯絡清單_20230725_131124.pdf differ diff --git a/FrontendWebApi/wwwroot/excel/緊急應變_聯絡清單_20230725_131732.pdf b/FrontendWebApi/wwwroot/excel/緊急應變_聯絡清單_20230725_131732.pdf new file mode 100644 index 0000000..a947c05 Binary files /dev/null and b/FrontendWebApi/wwwroot/excel/緊急應變_聯絡清單_20230725_131732.pdf differ diff --git a/FrontendWebApi/wwwroot/excel/緊急應變_聯絡清單_20230725_131814.pdf b/FrontendWebApi/wwwroot/excel/緊急應變_聯絡清單_20230725_131814.pdf new file mode 100644 index 0000000..58d656a Binary files /dev/null and b/FrontendWebApi/wwwroot/excel/緊急應變_聯絡清單_20230725_131814.pdf differ diff --git a/FrontendWebApi/wwwroot/excel/緊急應變_聯絡清單_20230725_131831.pdf b/FrontendWebApi/wwwroot/excel/緊急應變_聯絡清單_20230725_131831.pdf new file mode 100644 index 0000000..db01ce5 Binary files /dev/null and b/FrontendWebApi/wwwroot/excel/緊急應變_聯絡清單_20230725_131831.pdf differ diff --git a/FrontendWebApi/wwwroot/excel/緊急應變_聯絡清單_20230725_131933.pdf b/FrontendWebApi/wwwroot/excel/緊急應變_聯絡清單_20230725_131933.pdf new file mode 100644 index 0000000..5a67b87 Binary files /dev/null and b/FrontendWebApi/wwwroot/excel/緊急應變_聯絡清單_20230725_131933.pdf differ diff --git a/FrontendWebApi/wwwroot/excel/緊急應變_聯絡清單_20230725_131944.pdf b/FrontendWebApi/wwwroot/excel/緊急應變_聯絡清單_20230725_131944.pdf new file mode 100644 index 0000000..7d49111 Binary files /dev/null and b/FrontendWebApi/wwwroot/excel/緊急應變_聯絡清單_20230725_131944.pdf differ diff --git a/FrontendWebApi/wwwroot/excel/緊急應變_聯絡清單_20230725_131948.pdf b/FrontendWebApi/wwwroot/excel/緊急應變_聯絡清單_20230725_131948.pdf new file mode 100644 index 0000000..c576fce Binary files /dev/null and b/FrontendWebApi/wwwroot/excel/緊急應變_聯絡清單_20230725_131948.pdf differ diff --git a/FrontendWebApi/wwwroot/excel/緊急應變_聯絡清單_20230725_132239.xlsx b/FrontendWebApi/wwwroot/excel/緊急應變_聯絡清單_20230725_132239.xlsx new file mode 100644 index 0000000..06e73b4 Binary files /dev/null and b/FrontendWebApi/wwwroot/excel/緊急應變_聯絡清單_20230725_132239.xlsx differ diff --git a/FrontendWebApi/wwwroot/excel/緊急應變_聯絡清單_20230725_132246.xlsx b/FrontendWebApi/wwwroot/excel/緊急應變_聯絡清單_20230725_132246.xlsx new file mode 100644 index 0000000..bc12b3b Binary files /dev/null and b/FrontendWebApi/wwwroot/excel/緊急應變_聯絡清單_20230725_132246.xlsx differ diff --git a/FrontendWebApi/wwwroot/excel/緊急應變_聯絡清單_20230725_132319.xlsx b/FrontendWebApi/wwwroot/excel/緊急應變_聯絡清單_20230725_132319.xlsx new file mode 100644 index 0000000..989e864 Binary files /dev/null and b/FrontendWebApi/wwwroot/excel/緊急應變_聯絡清單_20230725_132319.xlsx differ diff --git a/FrontendWebApi/wwwroot/excel/緊急應變_聯絡清單_20230725_132328.pdf b/FrontendWebApi/wwwroot/excel/緊急應變_聯絡清單_20230725_132328.pdf new file mode 100644 index 0000000..af2c25b Binary files /dev/null and b/FrontendWebApi/wwwroot/excel/緊急應變_聯絡清單_20230725_132328.pdf differ