From 3350dbc6f05cb5523003b56f4fed079e512b8c10 Mon Sep 17 00:00:00 2001 From: dev02 Date: Thu, 18 May 2023 12:44:43 +0800 Subject: [PATCH 01/19] =?UTF-8?q?[=E5=BE=8C=E7=AB=AF]=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?get=20device=20api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FrontendWebApi/ApiControllers/BuildController.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/FrontendWebApi/ApiControllers/BuildController.cs b/FrontendWebApi/ApiControllers/BuildController.cs index e0e91ec..5fa1457 100644 --- a/FrontendWebApi/ApiControllers/BuildController.cs +++ b/FrontendWebApi/ApiControllers/BuildController.cs @@ -532,6 +532,7 @@ namespace FrontendWebApi.ApiControllers left join device_master dm ON d.device_building_tag = dm.device_building_tag AND d.device_name_tag = dm.device_name_tag left join device_item di ON d.device_name_tag = di.device_name_tag + AND di.device_building_tag = '{post.building_tag}' AND di.deleted = 0 AND di.is_show_riserDiagram = 1 left join floor f on d.device_floor_tag = f.full_name and f.deleted = 0 From faa2ddca2f1688ee456aa3faf5a6b8be46c668dc Mon Sep 17 00:00:00 2001 From: dev01 Date: Thu, 18 May 2023 12:45:35 +0800 Subject: [PATCH 02/19] =?UTF-8?q?=E5=BE=8C=E5=8F=B0=20[=E6=AD=B7=E5=8F=B2?= =?UTF-8?q?=E8=B3=87=E6=96=99]=20api=20=E7=A8=8B=E5=BA=8F=E8=AA=BF?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FrontendWebApi/ApiControllers/HistoryController.cs | 8 ++++---- FrontendWebApi/Models/HistoryClass.cs | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/FrontendWebApi/ApiControllers/HistoryController.cs b/FrontendWebApi/ApiControllers/HistoryController.cs index 289a63c..6d60f63 100644 --- a/FrontendWebApi/ApiControllers/HistoryController.cs +++ b/FrontendWebApi/ApiControllers/HistoryController.cs @@ -1137,7 +1137,7 @@ namespace FrontendWebApi.ApiControllers and di.device_system_tag COLLATE utf8mb4_unicode_ci = d.device_system_tag and di.device_name_tag COLLATE utf8mb4_unicode_ci = d.device_name_tag and d.deleted = 0 - where di.deleted = 0 and di.unit is not null and d.device_number IN @Device_number + where di.deleted = 0 and di.unit is not null and d.device_number = @Device_number ) temp inner join building b on temp.device_building_tag COLLATE utf8mb4_unicode_ci = b.building_tag and b.deleted = 0 inner join variable v1 on temp.device_system_tag COLLATE utf8mb4_unicode_ci = v1.system_value and v1.deleted = 0 and v1.system_type = 'device_system_category_layer2' @@ -1149,12 +1149,12 @@ namespace FrontendWebApi.ApiControllers var device_number = hi.Device_number_point.Split(":")[0]; var point = hi.Device_number_point.Split(":")[1]; //var tableName = await backgroundServiceMsSqlRepository.GetAllAsync($"select table_name from INFORMATION_SCHEMA.TABLES where table_name like '%{device_number}%'"); - var device_item_infos = await frontendRepository.GetAllAsync(sqlDeviceItemInfo, new { Device_number = hi.Device_number_point }); + var device_item_infos = await frontendRepository.GetAllAsync(sqlDeviceItemInfo, new { Device_number = device_number }); var device_item_info = device_item_infos.Where(x => x.Device_number == device_number && x.Points == point).FirstOrDefault(); var sql = $@"select '{device_item_info.Building_name}' as Building_name, '{device_item_info.Main_system_name}' as Main_system_name, - '{device_item_info.Sub_system_name}' as Sub_system_name', {device_item_info.Device_number}' as Device_number, + '{device_item_info.Sub_system_name}' as Sub_system_name, '{device_item_info.Device_number}' as Device_number, '{device_item_info.Device_name}' as Device_name, '{device_item_info.Item_name}' as Item_name, '{device_item_info.Points}' as Points, '{device_item_info.Unit}' as Unit, timestamp as Timestamp, round(value, 2) as Value from FIC_CENTER_{device_number}_{point} @@ -1167,7 +1167,7 @@ namespace FrontendWebApi.ApiControllers //{ //} } - + apiResult.Code = "0000"; apiResult.Data = apiResult.Data.OrderBy(x => x.Device_number).ThenBy(x => x.Timestamp).ToList(); } catch (Exception exception) diff --git a/FrontendWebApi/Models/HistoryClass.cs b/FrontendWebApi/Models/HistoryClass.cs index ebdf803..79bc3a1 100644 --- a/FrontendWebApi/Models/HistoryClass.cs +++ b/FrontendWebApi/Models/HistoryClass.cs @@ -264,6 +264,7 @@ namespace FrontendWebApi.Models public class HistoryItem { public string Device_number_point { get; set; } + public string Device_number { get; set; } public string Unit { get; set; } } From 47f29cdddf4f311c1375c917ce9e05293661e45f Mon Sep 17 00:00:00 2001 From: dev02 Date: Thu, 18 May 2023 16:05:59 +0800 Subject: [PATCH 03/19] =?UTF-8?q?[=E5=BE=8C=E7=AB=AF]=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=89=8D=E5=8F=B0=E7=99=BB=E5=85=A5=E6=99=82=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FrontendWebApi/ApiControllers/LoginController.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/FrontendWebApi/ApiControllers/LoginController.cs b/FrontendWebApi/ApiControllers/LoginController.cs index b93e427..8042d9a 100644 --- a/FrontendWebApi/ApiControllers/LoginController.cs +++ b/FrontendWebApi/ApiControllers/LoginController.cs @@ -58,8 +58,8 @@ namespace FrontendWebApi.ApiControllers ControllerContext.HttpContext.Response.Headers.Add("Access-Control-Allow-Origin", "*"); EDFunction eDFunction = new EDFunction(); - string SHA256Pwd = eDFunction.GetSHA256Encryption(login.password); - var User = await backendRepository.GetOneAsync("userinfo", @$"account = '{login.account}' and password = '{SHA256Pwd}' and deleted = 0"); + //string SHA256Pwd = eDFunction.GetSHA256Encryption(login.password); + var User = await backendRepository.GetOneAsync("userinfo", @$"account = '{login.account}' and deleted = 0"); if (User == null) { apiResult.Code = "9998"; From 7b55ec92af2af5df72a929415060653794ffa18f Mon Sep 17 00:00:00 2001 From: dev02 Date: Thu, 18 May 2023 17:25:15 +0800 Subject: [PATCH 04/19] =?UTF-8?q?[=E5=BE=8C=E7=AB=AF]=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=BE=8C=E7=AB=AFcontroller=20router,=20=E4=BF=AE=E6=94=B9logi?= =?UTF-8?q?n=20index=E6=A8=99=E9=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/EmergencyContactController.cs | 232 ++++++++++++++++++ .../EmergencyDeviceMenuController.cs | 24 ++ .../Controllers/EmergencyRecordController.cs | 142 +++++++++++ FrontendWebApi/Controllers/HomeController.cs | 25 ++ FrontendWebApi/Controllers/LoginController.cs | 144 +++++++++++ .../Controllers/MyBaseController.cs | 170 +++++++++++++ .../Controllers/RescueDeviceController.cs | 34 +++ FrontendWebApi/Views/Login/Index.cshtml | 4 +- 8 files changed, 773 insertions(+), 2 deletions(-) create mode 100644 FrontendWebApi/Controllers/EmergencyContactController.cs create mode 100644 FrontendWebApi/Controllers/EmergencyDeviceMenuController.cs create mode 100644 FrontendWebApi/Controllers/EmergencyRecordController.cs create mode 100644 FrontendWebApi/Controllers/HomeController.cs create mode 100644 FrontendWebApi/Controllers/LoginController.cs create mode 100644 FrontendWebApi/Controllers/MyBaseController.cs create mode 100644 FrontendWebApi/Controllers/RescueDeviceController.cs diff --git a/FrontendWebApi/Controllers/EmergencyContactController.cs b/FrontendWebApi/Controllers/EmergencyContactController.cs new file mode 100644 index 0000000..15b5625 --- /dev/null +++ b/FrontendWebApi/Controllers/EmergencyContactController.cs @@ -0,0 +1,232 @@ +using FrontendWebApi.Models; +using iTextSharp.text; +using iTextSharp.text.html.simpleparser; +using iTextSharp.text.pdf; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; +using NPOI.SS.UserModel; +using NPOI.XSSF.UserModel; +using Repository.BackendRepository.Interface; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; + +namespace FrontendWebApi.Controllers +{ + public class EmergencyContactController : MyBaseController + { + private readonly IBackendRepository backendRepository; + public EmergencyContactController(IBackendRepository backendRepository) + { + this.backendRepository = backendRepository; + } + public IActionResult Index() + { + return View(); + } + + [HttpPost] + public async Task EmergencyContactTable (List selectgroupidlist) + { + List Emergency_member_tables = new List(); + ApiResult> apiResult = new ApiResult>(); + try + { + Emergency_member_tables = await backendRepository.GetAllAsync($@" + select v.system_key groupingName,va.system_key departmentName,* from emergency_member em left join variable v on em.grouping = v.id + left join (select * from variable vs where vs.system_type = 'department' and vs.deleted = 0) va on va.system_value = em.department + where em.grouping in @groupinglist and em.deleted = 0",new { groupinglist = selectgroupidlist }); + apiResult.Code = "0000"; + apiResult.Data = Emergency_member_tables; + } + catch (Exception exception) + { + apiResult.Code = "9999"; + apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; + Logger.LogError("【" + controllerName + "/" + actionName + "】"); + Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + } + var result = Json(new + { + data = apiResult + }); + return result; + } + + + public FileResult ExportPDF(string post) + { + var grouping = JsonConvert.DeserializeObject(post); + var stream = new MemoryStream(); + try + { + var Emergency_member_tables = backendRepository.GetAllAsync($@" + select v.system_key groupingName,va.system_key departmentName,* from emergency_member em left join variable v on em.grouping = v.id + left join (select * from variable vs where vs.system_type = 'department' and vs.deleted = 0) va on va.system_value = em.department + where em.grouping in @groupinglist and em.deleted = 0", new { groupinglist = grouping.groupidlist }); + using (var doc = new Document()) + { + using (var writer = PdfWriter.GetInstance(doc, stream)) + { + writer.CloseStream = false; + BaseFont BaseF = BaseFont.CreateFont("C:\\Windows\\Fonts\\kaiu.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); + Font fontCh = new Font(BaseF, 14); + doc.Open(); + PdfPTable table = new PdfPTable(new float[] { 1, 1, 1, 1, 1 ,1 }); + table.TotalWidth = 480f; + table.LockedWidth = true; + PdfPCell header = new PdfPCell(new Phrase(grouping.disaster+"-聯絡清單", fontCh)); + header.Colspan = 6; + table.AddCell(header); + table.AddCell(new Phrase("組別", fontCh)); + table.AddCell(new Phrase("姓名", fontCh)); + table.AddCell(new Phrase("部門", fontCh)); + table.AddCell(new Phrase("電話", fontCh)); + table.AddCell(new Phrase("LINE ID", fontCh)); + table.AddCell(new Phrase("電子信箱", fontCh)); + + foreach(var group in Emergency_member_tables.Result) + { + table.AddCell(new Phrase(group.groupingName, fontCh)); + table.AddCell(new Phrase(group.full_name, fontCh)); + table.AddCell(new Phrase(group.departmentName, fontCh)); + table.AddCell(new Phrase(group.phone, fontCh)); + table.AddCell(new Phrase(group.lineid, fontCh)); + table.AddCell(new Phrase(group.email, fontCh)); + } + doc.Add(table); + doc.Close(); + } + } + var bytes = stream.ToArray(); + stream.Position = 0; + } + catch (Exception exception) + { + Logger.LogError("【" + controllerName + "/" + actionName + "】"); + Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + } + return File(stream, "application/pdf", grouping.disaster+"-聯絡清單.pdf"); + } + + public FileResult ExportExcel(string post) + { + var grouping = JsonConvert.DeserializeObject(post); + var workbook = new XSSFWorkbook(); + var ms = new NpoiMemoryStream + { + AllowClose = false + }; + #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 + try + { + var Emergency_member_tables = backendRepository.GetAllAsync($@" + select v.system_key groupingName,va.system_key departmentName,* from emergency_member em left join variable v on em.grouping = v.id + left join (select * from variable vs where vs.system_type = 'department' and vs.deleted = 0) va on va.system_value = em.department + where em.grouping in @groupinglist and em.deleted = 0", new { groupinglist = grouping.groupidlist }).Result; + var sheet = workbook.CreateSheet(grouping.disaster+"-聯絡清單"); + int RowPosition = 0; + IRow row = sheet.CreateRow(RowPosition); + sheet.SetColumnWidth(0, 4 * 160 * 6); + sheet.SetColumnWidth(1, 4 * 160 * 6); + sheet.SetColumnWidth(2, 4 * 160 * 6); + sheet.SetColumnWidth(3, 4 * 160 * 6); + sheet.SetColumnWidth(4, 4 * 160 * 6); + sheet.SetColumnWidth(5, 4 * 160 * 6); + ICell cell = row.CreateCell(0); + cell.SetCellValue("組別"); + cell.CellStyle = styleLine12; + cell = row.CreateCell(1); + cell.SetCellValue("姓名"); + cell.CellStyle = styleLine12; + cell = row.CreateCell(2); + cell.SetCellValue("部門"); + cell.CellStyle = styleLine12; + cell = row.CreateCell(3); + cell.SetCellValue("電話"); + cell.CellStyle = styleLine12; + cell = row.CreateCell(4); + cell.SetCellValue("LINE ID"); + cell.CellStyle = styleLine12; + cell = row.CreateCell(5); + cell.SetCellValue("電子信箱"); + cell.CellStyle = styleLine12; + foreach (var group in Emergency_member_tables) + { + RowPosition += 1; + row = sheet.CreateRow(RowPosition); + cell = row.CreateCell(0); + cell.SetCellValue(group.groupingName); + cell.CellStyle = style12; + cell = row.CreateCell(1); + cell.SetCellValue(group.full_name); + cell.CellStyle = style12; + cell = row.CreateCell(2); + cell.SetCellValue(group.departmentName); + cell.CellStyle = style12; + cell = row.CreateCell(3); + cell.SetCellValue(group.phone); + cell.CellStyle = style12; + cell = row.CreateCell(4); + cell.SetCellValue(group.lineid); + cell.CellStyle = style12; + cell = row.CreateCell(5); + cell.SetCellValue(group.email); + cell.CellStyle = style12; + } + workbook.Write(ms); + ms.Flush(); + ms.Seek(0, SeekOrigin.Begin); + } + catch(Exception exception) + { + Logger.LogError("【" + controllerName + "/" + actionName + "】"); + Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + } + return File(ms, "application/vnd.ms-excel", grouping.disaster + "-聯絡清單.xlsx"); + } + } +} diff --git a/FrontendWebApi/Controllers/EmergencyDeviceMenuController.cs b/FrontendWebApi/Controllers/EmergencyDeviceMenuController.cs new file mode 100644 index 0000000..eddf142 --- /dev/null +++ b/FrontendWebApi/Controllers/EmergencyDeviceMenuController.cs @@ -0,0 +1,24 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace FrontendWebApi.Controllers +{ + public class EmergencyDeviceMenuController : MyBaseController + { + private readonly ILogger _logger; + + public EmergencyDeviceMenuController(ILogger logger) + { + _logger = logger; + } + + public IActionResult Index() + { + return View(); + } + } +} diff --git a/FrontendWebApi/Controllers/EmergencyRecordController.cs b/FrontendWebApi/Controllers/EmergencyRecordController.cs new file mode 100644 index 0000000..5857d1d --- /dev/null +++ b/FrontendWebApi/Controllers/EmergencyRecordController.cs @@ -0,0 +1,142 @@ +using FrontendWebApi.Models; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using Repository.BackendRepository.Interface; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace FrontendWebApi.Controllers +{ + public class EmergencyRecordController : MyBaseController + { + private readonly IBackendRepository backendRepository; + public EmergencyRecordController(IBackendRepository backendRepository) + { + this.backendRepository = backendRepository; + } + public IActionResult Index() + { + return View(); + } + + [HttpPost] + public async Task>> DisasterList() + { + ApiResult> apiResult = new ApiResult>(); + List Variable = new List(); + + try + { + var sqlString = @$"select system_value as Value, system_key as Name from variable a where a.system_type = 'disaster' and a.deleted = 0"; + Variable = await backendRepository.GetAllAsync(sqlString); + + apiResult.Code = "0000"; + apiResult.Data = Variable; + } + catch (Exception exception) + { + apiResult.Code = "9999"; + apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; + Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + } + + return apiResult; + } + + [HttpPost] + public async Task>> BuildInfoList() + { + ApiResult> apiResult = new ApiResult>(); + List KeyValue = new List(); + + try + { + var sqlString = @$"select building_guid as Value, full_name as Name from building a where a.deleted = 0 and a.status = 0 ORDER BY A.priority ASC, A.created_at DESC"; + KeyValue = await backendRepository.GetAllAsync(sqlString); + + apiResult.Code = "0000"; + apiResult.Data = KeyValue; + } + catch (Exception exception) + { + apiResult.Code = "9999"; + apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; + Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + } + + return apiResult; + } + + [HttpPost] + public async Task EmergencyRecordTable(EmergencyRecordEventPost post) + { + List EmergencyRecordEvent = new List(); + ApiResult> apiResult = new ApiResult>(); + try + { + var sqlplus = ""; + if(post.selectaType != 2 ) + { + sqlplus = $"and ee.type = '{post.selectaType}'"; + } + if (post.dateranger != null) + { + var date = post.dateranger.Replace(" ", "").Split("-"); + sqlplus += $"and ee.created_at between '{date[0].Replace(" / ", " - ")} 00:00:00' and '{date[1].Replace(" / ", " - ")} 23:59:59'"; + } + + EmergencyRecordEvent = await backendRepository.GetAllAsync($@" + select d.device_number device_name,v.system_key disaster_name,ee.*,b.full_name building_name from emergency_event ee + left join (select * from variable v where v.system_type = 'disaster') v on v.system_value = ee.disaster + left join device d on d.device_guid = ee.device_guid + left join building b on b.building_guid = ee.building_guid + where ee.deleted = 0 and ee.building_guid = '{post.selectaBuild}' and ee.disaster = '{post.selectaDisaster}' {sqlplus} + "); + apiResult.Code = "0000"; + apiResult.Data = EmergencyRecordEvent; + } + catch (Exception exception) + { + apiResult.Code = "9999"; + apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; + Logger.LogError("【" + controllerName + "/" + actionName + "】"); + Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + } + var result = Json(new + { + data = apiResult + }); + return result; + } + + + [HttpPost] + public async Task EmergencyItemTable(string event_guid) + { + List EmergencyRecordEvent = new List(); + ApiResult> apiResult = new ApiResult>(); + try + { + EmergencyRecordEvent = await backendRepository.GetAllAsync($@" + select * from emergency_item where event_guid = '{event_guid}' order by created_at desc + "); + apiResult.Code = "0000"; + apiResult.Data = EmergencyRecordEvent; + } + catch (Exception exception) + { + apiResult.Code = "9999"; + apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; + Logger.LogError("【" + controllerName + "/" + actionName + "】"); + Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + } + var result = Json(new + { + data = apiResult + }); + return result; + } + } +} diff --git a/FrontendWebApi/Controllers/HomeController.cs b/FrontendWebApi/Controllers/HomeController.cs new file mode 100644 index 0000000..78e9710 --- /dev/null +++ b/FrontendWebApi/Controllers/HomeController.cs @@ -0,0 +1,25 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace FrontendWebApi.Controllers +{ + public class HomeController : MyBaseController + { + private readonly ILogger _logger; + + public HomeController(ILogger logger) + { + _logger = logger; + } + + public IActionResult Index() + { + return View(); + } + + } +} diff --git a/FrontendWebApi/Controllers/LoginController.cs b/FrontendWebApi/Controllers/LoginController.cs new file mode 100644 index 0000000..8e7dc50 --- /dev/null +++ b/FrontendWebApi/Controllers/LoginController.cs @@ -0,0 +1,144 @@ +using FrontendWebApi.Jwt; +using FrontendWebApi.Models; +using iTextSharp.text; +using iTextSharp.text.pdf; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; +using NPOI.SS.UserModel; +using NPOI.XSSF.UserModel; +using Repository.BackendRepository.Interface; +using Repository.FrontendRepository.Interface; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net; +using System.Threading.Tasks; + +namespace FrontendWebApi.Controllers +{ + public class LoginController : Controller + { + private readonly ILogger logger; + private readonly IBackendRepository backendRepository; + private readonly IFrontendRepository frontendRepository; + private readonly IJwtHelpers jwt; + //string jwt_str = "login"; + protected MyUserInfo myUserInfo = null; + protected JwtGet myUser; + protected string jwt_str = null; + protected bool jwtlife = true; + + public LoginController + ( + ILogger logger, + IBackendRepository backendRepository, + IFrontendRepository frontendRepository, + IJwtHelpers jwt + ) + { + this.logger = logger; + this.jwt = jwt; + this.backendRepository = backendRepository; + this.frontendRepository = frontendRepository; + } + + public IActionResult Index(string jwt) + { + ViewBag.jwt = jwt; + ViewBag.ProjectName = backendRepository.GetOneAsync("select system_key from variable where deleted = 0 and system_type = 'project_name';").Result; + return View(); + } + + [HttpPost] + [Route("api/Login")] + public async Task>> Login(Login login) + { + ApiResult apiResult = new ApiResult(null); + ErrorCode errorCode = new ErrorCode(); + try + { + ControllerContext.HttpContext.Response.Headers.Add("Access-Control-Allow-Origin", "*"); + EDFunction eDFunction = new EDFunction(); + + //string SHA256Pwd = eDFunction.GetSHA256Encryption(login.password); + var User = await backendRepository.GetOneAsync("userinfo", @$"account = '{login.account}' and deleted = 0"); + if (User == null) + { + apiResult.Code = "9998"; + return Ok(apiResult); + } + JwtLogin jwtLoing = new JwtLogin() + { + account = User.account, + email = User.email, + full_name = User.full_name, + userinfo_guid = User.userinfo_guid + }; + apiResult.Code = "0000"; + apiResult.Data = jwt.GenerateToken(jwtLoing); + } + catch + { + apiResult.Code = "9999"; + return BadRequest(apiResult); + } + return Ok(apiResult); + } + + + [HttpPost] + public async Task>> CheckJwt() + { + ApiResult apiResult = new ApiResult(null); + ErrorCode errorCode = new ErrorCode(); + try + { + var ctx = ControllerContext.HttpContext; + ctx.Response.Headers.Add("Access-Control-Allow-Origin", "*"); + ctx.Response.Headers.Add("Access-Control-Allow-Headers", "*"); + ctx.Response.Headers.Add("Access-Control-Allow-Credentials", "true"); + var a = User.Claims.Select(p => new { Type = p.Type, Value = p.Value }).ToList(); + myUser = new JwtGet() + { + account = User.Claims.Where(a => a.Type == "account").Select(e => e.Value).FirstOrDefault(), + email = User.Claims.Where(a => a.Type == "email").Select(e => e.Value).FirstOrDefault(), + full_name = User.Claims.Where(a => a.Type == "full_name").Select(e => e.Value).FirstOrDefault(), + exp = User.Claims.Where(a => a.Type == "exp").Select(e => Convert.ToInt32(e.Value)).FirstOrDefault(), + nbf = User.Claims.Where(a => a.Type == "nbf").Select(e => Convert.ToInt32(e.Value)).FirstOrDefault(), + userinfo_guid = User.Claims.Where(a => a.Type == "userinfo_guid").Select(e => e.Value).FirstOrDefault(), + }; + + if (myUser.exp == 0) + { + jwt_str = "Jwt Token不合法"; + jwtlife = false; + } + else + { + //if (myUser.exp <= DateTime.Now.AddHours(-8).AddMinutes(10).Subtract(new DateTime(1970, 1, 1)).TotalSeconds) + //{ + //取得當前登入使用者資訊 + EDFunction edFunction = new EDFunction(); + HttpContext.Session.SetString("MyApiAccount", edFunction.AESEncrypt(myUser.account)); //將帳號透過AES加密 + //} + } + + apiResult.Code = "0000"; + } + catch(Exception exception) + { + apiResult.Code = "9999"; + string json = System.Text.Json.JsonSerializer.Serialize(myUser.account); + logger.LogError("【Login/Index - 登入資訊】" + json); + logger.LogError("【Login/Index】" + exception.Message); + + return Ok(apiResult); + } + + return Ok(apiResult); + } + } +} diff --git a/FrontendWebApi/Controllers/MyBaseController.cs b/FrontendWebApi/Controllers/MyBaseController.cs new file mode 100644 index 0000000..c319e00 --- /dev/null +++ b/FrontendWebApi/Controllers/MyBaseController.cs @@ -0,0 +1,170 @@ +using FrontendWebApi.Jwt; +using FrontendWebApi.Models; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Filters; +using Microsoft.Extensions.Configuration; +using Repository.BackendRepository.Interface; +using Repository.BaseRepository.Interface; +using Repository.FrontendRepository.Interface; +using Repository.Helper; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Microsoft.AspNetCore.Routing; +using System.Diagnostics; +using Repository.BackendRepository.Implement; + +namespace FrontendWebApi.Controllers +{ + public class MyBaseController : Controller where T : MyBaseController + { + private ILogger _logger; + protected ILogger Logger => _logger ?? (_logger = HttpContext?.RequestServices.GetService>()); + + private IBackendRepository backendRepository => HttpContext?.RequestServices.GetService(); + private IJwtHelpers jwt => HttpContext?.RequestServices.GetService(); + + private IFrontendRepository frontendRepository => HttpContext?.RequestServices.GetService(); + + public BackgroundService backgroundService; + public MyBaseController() { } + protected MyUserInfo myUserInfo = null; + protected JwtGet myUser; + protected string jwt_str = null; + protected bool jwtlife = true; + public string controllerName; + public string actionName; + public ErrorCode errorCode = new ErrorCode(); + [Authorize] + public override void OnActionExecuting(ActionExecutingContext filterContext) + { + EDFunction edFunction = new EDFunction(); + var myAccount = edFunction.AESDecrypt(HttpContext.Session.GetString("MyApiAccount")); + controllerName = ControllerContext.RouteData.Values["controller"].ToString(); //controller名稱 + actionName = ControllerContext.RouteData.Values["action"].ToString(); //action名稱 + + //紀錄當前PID + Process currentProcess = Process.GetCurrentProcess(); + Dictionary updateProcess = new Dictionary(); + updateProcess.Add("@system_value", currentProcess.Id.ToString()); + + frontendRepository.UpdateProcessPID(updateProcess, "variable", "system_type = 'watchDogCongfig' AND system_key = 'AlarmPID'"); + + bool isAjaxCall = filterContext.HttpContext.Request.Headers["x-requested-with"] == "XMLHttpRequest"; + if (string.IsNullOrEmpty(myAccount)) + { + + if (isAjaxCall) + { + filterContext.HttpContext.Response.Clear(); + filterContext.HttpContext.Response.StatusCode = 499; + return; + } + else + { + filterContext.Result = new RedirectToRouteResult( + new RouteValueDictionary + { + {"controller", "Login"}, + {"action", "Index"} + }); + return; + } + } + else + { + //取得當前登入使用者資訊 + myUserInfo = frontendRepository.GetMyUserInfoByAccount(myAccount); + var showview = frontendRepository.GetAllAsync($@"select ap.ShowView from userinfo us + left join role_auth ra on ra.role_guid = us.role_guid + left join auth_page ap on ap.AuthCode = ra.AuthCode + where us.userinfo_guid = '{myUserInfo.Userinfo_guid}'"); + myUserInfo.ShowView = showview.Result; + ViewBag.myUserInfo = myUserInfo; + ViewBag.role = showview.Result; + + //var showviewt = new List() + // { + // "EmergencyDeviceMenuIndex", + // "EmergencyContactIndex", + // "EmergencyRecordIndex", + // "RescueDeviceFireExtinguisher", + // "RescueDeviceAED", + // }; + //ViewBag.role = showviewt; + } + + //var ctx = filterContext.HttpContext; + //ctx.Response.Headers.Add("Access-Control-Allow-Origin", "*"); + //ctx.Response.Headers.Add("Access-Control-Allow-Headers", "*"); + //ctx.Response.Headers.Add("Access-Control-Allow-Credentials", "true"); + //var a = User.Claims.Select(p => new { Type = p.Type, Value = p.Value }).ToList(); + //myUser = new JwtGet() + //{ + // account = User.Claims.Where(a => a.Type == "account").Select(e => e.Value).FirstOrDefault(), + // email = User.Claims.Where(a => a.Type == "email").Select(e => e.Value).FirstOrDefault(), + // full_name = User.Claims.Where(a => a.Type == "full_name").Select(e => e.Value).FirstOrDefault(), + // exp = User.Claims.Where(a => a.Type == "exp").Select(e => Convert.ToInt32(e.Value)).FirstOrDefault(), + // nbf = User.Claims.Where(a => a.Type == "nbf").Select(e => Convert.ToInt32(e.Value)).FirstOrDefault(), + // userinfo_guid = User.Claims.Where(a => a.Type == "userinfo_guid").Select(e => e.Value).FirstOrDefault(), + //}; + + //TODO 模擬JWT,記得刪除 + //myUser.account = "Bajascript"; + //myUser.email = "asd@com"; + //myUser.full_name = "野原廣志"; + //myUser.exp = 3600; + //myUser.userinfo_guid = "1EF9CEAC-4DBF-E2BE-8B1D-CB3014E0DA17"; + + //if (myUser.exp == 0) + //{ + // jwt_str = "Jwt Token不合法"; + // jwtlife = false; + + // ViewBag.myUserInfo = null; + // ViewBag.role = null; + //} + //else + //{ + // if (myUser.exp <= DateTime.Now.AddHours(-8).AddMinutes(10).Subtract(new DateTime(1970, 1, 1)).TotalSeconds) + // { + // //取得當前登入使用者資訊 + // myUserInfo = frontendRepository.GetMyUserInfoByAccount(myUser.account); + // //var showview = frontendRepository.GetAllAsync($@"select ap.ShowView from userinfo us + // // left join role_auth ra on ra.role_guid = us.role_guid + // // left join auth_page ap on ap.AuthCode = ra.AuthCode + // // where us.userinfo_guid = '{myUserInfo.Userinfo_guid}'"); + // //myUserInfo.ShowView = showview.Result; + // ViewBag.myUserInfo = myUserInfo; + + // var showviewt = new List() + // { + // "EmergencyDeviceMenuIndex", + // "EmergencyContactIndex", + // "EmergencyRecordIndex", + // "RescueDeviceFireExtinguisher", + // "RescueDeviceAED", + // }; + // //ViewBag.role = showview.Result; + // ViewBag.role = showviewt; + + // jwtlife = true; + // JwtLogin jwtLoing = new JwtLogin() + // { + // account = myUser.account, + // email = myUser.email, + // full_name = myUser.full_name, + // userinfo_guid = myUser.userinfo_guid + // }; + // jwt_str = jwt.GenerateToken(jwtLoing).token; + // } + //} + base.OnActionExecuting(filterContext); + } + } +} diff --git a/FrontendWebApi/Controllers/RescueDeviceController.cs b/FrontendWebApi/Controllers/RescueDeviceController.cs new file mode 100644 index 0000000..1d97a1b --- /dev/null +++ b/FrontendWebApi/Controllers/RescueDeviceController.cs @@ -0,0 +1,34 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; +using NPOI.HSSF.UserModel; +using NPOI.SS.UserModel; +using NPOI.XSSF.UserModel; +using Repository.BackendRepository.Interface; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; + +namespace FrontendWebApi.Controllers +{ + public class RescueDeviceController : MyBaseController + { + private readonly IBackendRepository backendRepository; + + public RescueDeviceController(IBackendRepository backendRepository) + { + this.backendRepository = backendRepository; + } + public IActionResult FireExtinguisher() + { + return View(); + } + public IActionResult AED() + { + return View(); + } + } +} diff --git a/FrontendWebApi/Views/Login/Index.cshtml b/FrontendWebApi/Views/Login/Index.cshtml index d10647a..5d90c0c 100644 --- a/FrontendWebApi/Views/Login/Index.cshtml +++ b/FrontendWebApi/Views/Login/Index.cshtml @@ -6,7 +6,7 @@ - 登入 | IBMS緊急應變系統 + 登入 | @ViewData["ProjectName"]緊急應變系統 @@ -30,7 +30,7 @@
From 9e33f4c368e506b4449649e90e26039966046f8d Mon Sep 17 00:00:00 2001 From: dev02 Date: Fri, 19 May 2023 10:06:18 +0800 Subject: [PATCH 05/19] =?UTF-8?q?[=E5=BE=8C=E7=AB=AF]=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?niagara=20=E5=90=8C=E6=AD=A5=E5=95=8F=E9=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Backend/Services/Implement/webRequestService.cs | 10 +++++++--- .../Implement/NiagaraDataSynchronizeRepository.cs | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Backend/Services/Implement/webRequestService.cs b/Backend/Services/Implement/webRequestService.cs index 2528ae5..96e0630 100644 --- a/Backend/Services/Implement/webRequestService.cs +++ b/Backend/Services/Implement/webRequestService.cs @@ -20,6 +20,7 @@ using NPOI.SS.Formula.Functions; using Microsoft.AspNetCore.Localization; using MySqlX.XDevAPI.Relational; using Backend.Models; +using NPOI.OpenXmlFormats.Dml; namespace Backend.Services.Implement { @@ -263,9 +264,12 @@ namespace Backend.Services.Implement row.parent_path = stationName; //full_name 其實是點位名稱 point_name - row.full_name = conPoint.Where(x => x.name.Contains(tagName.Replace('_', '/')) && !x.isHistory).Select(x => x.displayName).FirstOrDefault(); - if (conPoint.Where(x => x.name.Contains(tagName.Replace('_', '/')) && !x.isHistory).FirstOrDefault() != null) - conPoint.Where(x => x.name.Contains(tagName.Replace('_', '/')) && !x.isHistory).FirstOrDefault().isHistory = true; + var deviceNumber = tagName.Substring(0, tagName.LastIndexOf(tagName.Split("_")[5]) - 1); + var point = tagName.Split("_")[5]; + conPoint = conPoint.Where(x => x.name.Split("/").Length > 6).ToList(); + row.full_name = conPoint.Where(x => x.name.Split("/")[5] == deviceNumber && x.name.Split("/")[6] == point && !x.isHistory).Select(x => x.displayName).FirstOrDefault(); + if (conPoint.Where(x => x.name.Split("/")[5] == deviceNumber && x.name.Split("/")[6] == point && !x.isHistory).FirstOrDefault() != null) + conPoint.Where(x => x.name.Split("/")[5] == deviceNumber && x.name.Split("/")[6] == point && !x.isHistory).FirstOrDefault().isHistory = true; row.isHistory = true; result.Add(row); } diff --git a/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs b/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs index 1f2824e..ebf60a8 100644 --- a/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs +++ b/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs @@ -244,7 +244,7 @@ namespace Repository.BackendRepository.Implement var isDome = await GetOneAsync("select system_value from variable where deleted = 0 and system_type = 'project_name';"); if (sb.Length > 0) { - if (isDome == "ibms_dome_dome/D2") + if (isDome == "ibms_dome_dome/D2" || isDome == "ibms_dome_hotel/H") { sb.Append($@" update import_niagara_item a join dic_system b on a.device_name_tag COLLATE utf8mb4_general_ci = b.s2_code From 1ce1e8400b27b4626dc70176dd15147dfd309490 Mon Sep 17 00:00:00 2001 From: dev02 Date: Fri, 19 May 2023 11:18:38 +0800 Subject: [PATCH 06/19] =?UTF-8?q?[=E5=BE=8C=E7=AB=AF]=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=89=8D=E5=8F=B0=20=E7=B7=8A=E6=80=A5=E4=BD=BF=E7=94=A8api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EmergencyContactController.cs | 6 +- .../EmergencyDeviceController.cs | 57 ++--- .../EmergencyRecordController.cs | 6 +- .../ApiControllers/RescueDeviceController.cs | 8 +- .../Controllers/EmergencyContactController.cs | 201 ------------------ .../Controllers/EmergencyRecordController.cs | 94 -------- FrontendWebApi/Controllers/LoginController.cs | 89 -------- .../Controllers/MyBaseController.cs | 4 - 8 files changed, 40 insertions(+), 425 deletions(-) diff --git a/FrontendWebApi/ApiControllers/EmergencyContactController.cs b/FrontendWebApi/ApiControllers/EmergencyContactController.cs index c6b7a83..b8b4fba 100644 --- a/FrontendWebApi/ApiControllers/EmergencyContactController.cs +++ b/FrontendWebApi/ApiControllers/EmergencyContactController.cs @@ -90,7 +90,7 @@ namespace FrontendWebApi.ApiControllers try { Emergency_member_tables = await backendRepository.GetAllAsync($@" - select v.system_key groupingName,va.system_key departmentName,* from emergency_member em left join variable v on em.grouping = v.id + select v.system_key groupingName,va.system_key departmentName, em.* from emergency_member em left join variable v on em.grouping = v.id left join (select * from variable vs where vs.system_type = 'department' and vs.deleted = 0) va on va.system_value = em.department where em.grouping in @groupinglist and em.deleted = 0", new { groupinglist = selectgroupidlist }); apiResult.Code = "0000"; @@ -120,7 +120,7 @@ namespace FrontendWebApi.ApiControllers try { var Emergency_member_tables = await backendRepository.GetAllAsync($@" - select v.system_key groupingName,va.system_key departmentName,* from emergency_member em left join variable v on em.grouping = v.id + select v.system_key groupingName,va.system_key departmentName, em.* from emergency_member em left join variable v on em.grouping = v.id left join (select * from variable vs where vs.system_type = 'department' and vs.deleted = 0) va on va.system_value = em.department where em.grouping in @groupinglist and em.deleted = 0", new { groupinglist = post.groupidlist }); using (var doc = new Document()) @@ -236,7 +236,7 @@ namespace FrontendWebApi.ApiControllers try { var Emergency_member_tables = await backendRepository.GetAllAsync($@" - select v.system_key groupingName,va.system_key departmentName,* from emergency_member em left join variable v on em.grouping = v.id + select v.system_key groupingName,va.system_key departmentName, em.* from emergency_member em left join variable v on em.grouping = v.id left join (select * from variable vs where vs.system_type = 'department' and vs.deleted = 0) va on va.system_value = em.department where em.grouping in @groupinglist and em.deleted = 0", new { groupinglist = post.groupidlist }); var sheet = workbook.CreateSheet(post.disaster + "-聯絡清單"); diff --git a/FrontendWebApi/ApiControllers/EmergencyDeviceController.cs b/FrontendWebApi/ApiControllers/EmergencyDeviceController.cs index c74bccf..e2e78b4 100644 --- a/FrontendWebApi/ApiControllers/EmergencyDeviceController.cs +++ b/FrontendWebApi/ApiControllers/EmergencyDeviceController.cs @@ -125,7 +125,7 @@ namespace FrontendWebApi.ApiControllers d.device_guid, d.device_number, d.full_name AS device_name, - d.building_guid, + d.device_building_tag, b.full_name AS building_name, CONCAT(b.ip_address , ':', b.ip_port) AS ip_address, v.layer2, @@ -137,27 +137,27 @@ namespace FrontendWebApi.ApiControllers floor.full_name floorname, floor.floor_guid floorguid from - (SELECT * - FROM device d - WHERE d.deleted = 0 - AND d.building_guid = '{selectdevice.selectbuilding}' - AND d.floor_guid in @floor - AND d.device_system_category_layer3 IN @layer3) d - left join floor on floor.floor_guid = d.floor_guid + (SELECT * + FROM device d + WHERE d.deleted = 0 + AND d.device_building_tag = '{selectdevice.selectbuilding}' + AND d.device_floor_tag in @floor + AND d.device_name_tag IN @layer3) d + left join floor on floor.full_name = d.device_floor_tag and floor.building_tag = d.device_building_tag left join ( - SELECT - v.*, - v2.system_key AS layer2_name, - v2.system_value AS layer2 - FROM ( - select * - from variable v - where v.system_type = 'device_system_category_layer3') v - LEFT JOIN variable v2 ON v2.deleted = 0 AND v.system_parent_id = v2.id - ) v on v.system_value = d.device_system_category_layer3 + SELECT + v.*, + v2.system_key AS layer2_name, + v2.system_value AS layer2 + FROM ( + select * + from variable v + where v.system_type = 'device_system_category_layer3') v + LEFT JOIN variable v2 ON v2.deleted = 0 AND v.system_parent_id = v2.id + ) v on v.system_value = d.device_system_category_layer3 left join device_disaster dd on dd.device_guid = d.device_guid left join (select * from variable v where v.system_type = 'disaster') ddd on ddd.system_value = dd.device_system_value - LEFT JOIN building b ON b.deleted = 0 AND d.building_guid = b.building_guid + LEFT JOIN building b ON b.deleted = 0 AND d.device_building_tag = b.building_tag where dd.device_system_value IN @disasters ORDER BY d.device_number "; @@ -451,7 +451,7 @@ namespace FrontendWebApi.ApiControllers try { Emergency_member_tables = await backendRepository.GetAllAsync($@" - select v.system_key groupingName,va.system_key departmentName,* from emergency_member em left join variable v on em.grouping = v.id + select v.system_key groupingName,va.system_key departmentName, em.* from emergency_member em left join variable v on em.grouping = v.id left join (select * from variable vs where vs.system_type = 'department' and vs.deleted = 0) va on va.system_value = em.department where em.grouping in @groupinglist and em.deleted = 0", new { groupinglist = selectgroupidlist }); apiResult.Code = "0000"; @@ -486,13 +486,16 @@ namespace FrontendWebApi.ApiControllers try { getDeviceGroup = await backendRepository.GetAllAsync($@" - select dg.*,vd.system_key disater_name,b.full_name building_name,f.full_name floor_name,v2.system_key system_category_layer2,v3.system_key system_category_layer3 from (SELECT * FROM device_group dg WHERE dg.device_disaster != 0) dg - left join (select * from variable v where v.system_type = 'disaster' and v.deleted = 0) vd on vd.system_value = dg.device_disaster - left join building b on b.building_guid = dg.device_building_guid - left join floor f on f.floor_guid = dg.device_floor_guid - left join (select * from variable v where v.system_type = 'device_system_category_layer2' and v.deleted = 0) v2 on v2.system_value = dg.device_system_category_layer2 - left join (select * from variable v where v.system_type = 'device_system_category_layer3' and v.deleted = 0) v3 on v3.system_value = dg.device_system_category_layer3 - order by vd.system_priority,b.priority,f.priority,v2.system_priority,v3.system_priority"); + select dg.*,vd.system_key disater_name,b.full_name building_name,f.full_name floor_name,v2.system_key system_category_layer2,v3.system_key system_category_layer3 + from ( + SELECT * + FROM device_group dg WHERE dg.device_disaster != 0) dg + left join (select * from variable v where v.system_type = 'disaster' and v.deleted = 0) vd on vd.system_value = dg.device_disaster + left join building b on b.building_tag = dg.device_building_guid + left join floor f on f.floor_guid = dg.device_floor_guid + left join (select * from variable v where v.system_type = 'device_system_category_layer2' and v.deleted = 0) v2 on v2.system_value = dg.device_system_category_layer2 + left join (select * from variable v where v.system_type = 'device_system_category_layer3' and v.deleted = 0) v3 on v3.system_value = dg.device_system_category_layer3 + order by vd.system_priority,b.priority,f.priority,v2.system_priority,v3.system_priority"); var dis = getDeviceGroup.GroupBy(a => a.device_disaster); //finalDeviceGroup.disaster = new List(); diff --git a/FrontendWebApi/ApiControllers/EmergencyRecordController.cs b/FrontendWebApi/ApiControllers/EmergencyRecordController.cs index 70dd040..871cb49 100644 --- a/FrontendWebApi/ApiControllers/EmergencyRecordController.cs +++ b/FrontendWebApi/ApiControllers/EmergencyRecordController.cs @@ -35,7 +35,7 @@ namespace FrontendWebApi.ApiControllers try { - var sqlString = @$"select building_guid as Value, full_name as Name from building a where a.deleted = 0 and a.status = 0"; + var sqlString = @$"select building_tag as Value, full_name as Name from building a where a.deleted = 0 and a.status = 0"; KeyValue = await backendRepository.GetAllAsync(sqlString); apiResult.Code = "0000"; @@ -74,8 +74,8 @@ namespace FrontendWebApi.ApiControllers select d.device_number device_name,v.system_key disaster_name,ee.*,b.full_name building_name from emergency_event ee left join (select * from variable v where v.system_type = 'disaster') v on v.system_value = ee.disaster left join device d on d.device_guid = ee.device_guid - left join building b on b.building_guid = ee.building_guid - where ee.deleted = 0 and ee.building_guid = '{post.selectaBuild}' and ee.disaster = '{post.selectaDisaster}' {sqlplus} + left join building b on b.building_tag = ee.building_tag + where ee.deleted = 0 and ee.building_tag = '{post.selectaBuild}' and ee.disaster = '{post.selectaDisaster}' {sqlplus} "); apiResult.Code = "0000"; apiResult.Data = EmergencyRecordEvent; diff --git a/FrontendWebApi/ApiControllers/RescueDeviceController.cs b/FrontendWebApi/ApiControllers/RescueDeviceController.cs index 9182f91..ac58c9f 100644 --- a/FrontendWebApi/ApiControllers/RescueDeviceController.cs +++ b/FrontendWebApi/ApiControllers/RescueDeviceController.cs @@ -33,7 +33,7 @@ namespace FrontendWebApi.ApiControllers try { - var sqlString = @$"select floor_guid as Value, full_name as Name from floor a where a.deleted = 0 and a.building_guid = '{Building}' and a.status = 0 order by a.priority"; + var sqlString = @$"select floor_guid as Value, full_name as Name from floor a where a.deleted = 0 and a.building_tag = '{Building}' and a.status = 0 order by a.priority"; KeyValue = await backendRepository.GetAllAsync(sqlString); apiResult.Code = "0000"; @@ -61,7 +61,7 @@ namespace FrontendWebApi.ApiControllers ApiResult> apiResult = new ApiResult>(); try { - RescueDeviceTables = await backendRepository.GetAllAsync("rescue_device", $"building_guid = '{post.build}' and floor_guid in @floors and rescue_device_kind = {post.kind}", new { floors = post.floors }, "floor_name"); + RescueDeviceTables = await backendRepository.GetAllAsync("rescue_device", $"building_tag = '{post.build}' and floor_guid in @floors and rescue_device_kind = {post.kind}", new { floors = post.floors }, "floor_name"); apiResult.Code = "0000"; apiResult.Data = RescueDeviceTables; } @@ -88,7 +88,7 @@ namespace FrontendWebApi.ApiControllers try { - var sqlString = @$"select building_guid as Value, full_name as Name from building a where a.deleted = 0 and a.status = 0 ORDER BY A.priority ASC, A.created_at DESC"; + var sqlString = @$"select building_tag as Value, full_name as Name from building a where a.deleted = 0 and a.status = 0 ORDER BY A.priority ASC, A.created_at DESC"; KeyValue = await backendRepository.GetAllAsync(sqlString); apiResult.Code = "0000"; @@ -159,7 +159,7 @@ namespace FrontendWebApi.ApiControllers devicename = "AED"; } var sheet = workbook.CreateSheet(devicename); - var RescueDevices = backendRepository.GetAllAsync("rescue_device", $"building_guid = '{postObject.build}' and rescue_device_kind = {postObject.kind}",null, "floor_name"); + var RescueDevices = backendRepository.GetAllAsync("rescue_device", $"building_tag = '{postObject.build}' and rescue_device_kind = {postObject.kind}",null, "floor_name"); int RowPosition = 0; IRow row = sheet.CreateRow(RowPosition); ICell cell = row.CreateCell(1); diff --git a/FrontendWebApi/Controllers/EmergencyContactController.cs b/FrontendWebApi/Controllers/EmergencyContactController.cs index 15b5625..ae0d89d 100644 --- a/FrontendWebApi/Controllers/EmergencyContactController.cs +++ b/FrontendWebApi/Controllers/EmergencyContactController.cs @@ -27,206 +27,5 @@ namespace FrontendWebApi.Controllers { return View(); } - - [HttpPost] - public async Task EmergencyContactTable (List selectgroupidlist) - { - List Emergency_member_tables = new List(); - ApiResult> apiResult = new ApiResult>(); - try - { - Emergency_member_tables = await backendRepository.GetAllAsync($@" - select v.system_key groupingName,va.system_key departmentName,* from emergency_member em left join variable v on em.grouping = v.id - left join (select * from variable vs where vs.system_type = 'department' and vs.deleted = 0) va on va.system_value = em.department - where em.grouping in @groupinglist and em.deleted = 0",new { groupinglist = selectgroupidlist }); - apiResult.Code = "0000"; - apiResult.Data = Emergency_member_tables; - } - catch (Exception exception) - { - apiResult.Code = "9999"; - apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; - Logger.LogError("【" + controllerName + "/" + actionName + "】"); - Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); - } - var result = Json(new - { - data = apiResult - }); - return result; - } - - - public FileResult ExportPDF(string post) - { - var grouping = JsonConvert.DeserializeObject(post); - var stream = new MemoryStream(); - try - { - var Emergency_member_tables = backendRepository.GetAllAsync($@" - select v.system_key groupingName,va.system_key departmentName,* from emergency_member em left join variable v on em.grouping = v.id - left join (select * from variable vs where vs.system_type = 'department' and vs.deleted = 0) va on va.system_value = em.department - where em.grouping in @groupinglist and em.deleted = 0", new { groupinglist = grouping.groupidlist }); - using (var doc = new Document()) - { - using (var writer = PdfWriter.GetInstance(doc, stream)) - { - writer.CloseStream = false; - BaseFont BaseF = BaseFont.CreateFont("C:\\Windows\\Fonts\\kaiu.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); - Font fontCh = new Font(BaseF, 14); - doc.Open(); - PdfPTable table = new PdfPTable(new float[] { 1, 1, 1, 1, 1 ,1 }); - table.TotalWidth = 480f; - table.LockedWidth = true; - PdfPCell header = new PdfPCell(new Phrase(grouping.disaster+"-聯絡清單", fontCh)); - header.Colspan = 6; - table.AddCell(header); - table.AddCell(new Phrase("組別", fontCh)); - table.AddCell(new Phrase("姓名", fontCh)); - table.AddCell(new Phrase("部門", fontCh)); - table.AddCell(new Phrase("電話", fontCh)); - table.AddCell(new Phrase("LINE ID", fontCh)); - table.AddCell(new Phrase("電子信箱", fontCh)); - - foreach(var group in Emergency_member_tables.Result) - { - table.AddCell(new Phrase(group.groupingName, fontCh)); - table.AddCell(new Phrase(group.full_name, fontCh)); - table.AddCell(new Phrase(group.departmentName, fontCh)); - table.AddCell(new Phrase(group.phone, fontCh)); - table.AddCell(new Phrase(group.lineid, fontCh)); - table.AddCell(new Phrase(group.email, fontCh)); - } - doc.Add(table); - doc.Close(); - } - } - var bytes = stream.ToArray(); - stream.Position = 0; - } - catch (Exception exception) - { - Logger.LogError("【" + controllerName + "/" + actionName + "】"); - Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); - } - return File(stream, "application/pdf", grouping.disaster+"-聯絡清單.pdf"); - } - - public FileResult ExportExcel(string post) - { - var grouping = JsonConvert.DeserializeObject(post); - var workbook = new XSSFWorkbook(); - var ms = new NpoiMemoryStream - { - AllowClose = false - }; - #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 - try - { - var Emergency_member_tables = backendRepository.GetAllAsync($@" - select v.system_key groupingName,va.system_key departmentName,* from emergency_member em left join variable v on em.grouping = v.id - left join (select * from variable vs where vs.system_type = 'department' and vs.deleted = 0) va on va.system_value = em.department - where em.grouping in @groupinglist and em.deleted = 0", new { groupinglist = grouping.groupidlist }).Result; - var sheet = workbook.CreateSheet(grouping.disaster+"-聯絡清單"); - int RowPosition = 0; - IRow row = sheet.CreateRow(RowPosition); - sheet.SetColumnWidth(0, 4 * 160 * 6); - sheet.SetColumnWidth(1, 4 * 160 * 6); - sheet.SetColumnWidth(2, 4 * 160 * 6); - sheet.SetColumnWidth(3, 4 * 160 * 6); - sheet.SetColumnWidth(4, 4 * 160 * 6); - sheet.SetColumnWidth(5, 4 * 160 * 6); - ICell cell = row.CreateCell(0); - cell.SetCellValue("組別"); - cell.CellStyle = styleLine12; - cell = row.CreateCell(1); - cell.SetCellValue("姓名"); - cell.CellStyle = styleLine12; - cell = row.CreateCell(2); - cell.SetCellValue("部門"); - cell.CellStyle = styleLine12; - cell = row.CreateCell(3); - cell.SetCellValue("電話"); - cell.CellStyle = styleLine12; - cell = row.CreateCell(4); - cell.SetCellValue("LINE ID"); - cell.CellStyle = styleLine12; - cell = row.CreateCell(5); - cell.SetCellValue("電子信箱"); - cell.CellStyle = styleLine12; - foreach (var group in Emergency_member_tables) - { - RowPosition += 1; - row = sheet.CreateRow(RowPosition); - cell = row.CreateCell(0); - cell.SetCellValue(group.groupingName); - cell.CellStyle = style12; - cell = row.CreateCell(1); - cell.SetCellValue(group.full_name); - cell.CellStyle = style12; - cell = row.CreateCell(2); - cell.SetCellValue(group.departmentName); - cell.CellStyle = style12; - cell = row.CreateCell(3); - cell.SetCellValue(group.phone); - cell.CellStyle = style12; - cell = row.CreateCell(4); - cell.SetCellValue(group.lineid); - cell.CellStyle = style12; - cell = row.CreateCell(5); - cell.SetCellValue(group.email); - cell.CellStyle = style12; - } - workbook.Write(ms); - ms.Flush(); - ms.Seek(0, SeekOrigin.Begin); - } - catch(Exception exception) - { - Logger.LogError("【" + controllerName + "/" + actionName + "】"); - Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); - } - return File(ms, "application/vnd.ms-excel", grouping.disaster + "-聯絡清單.xlsx"); - } } } diff --git a/FrontendWebApi/Controllers/EmergencyRecordController.cs b/FrontendWebApi/Controllers/EmergencyRecordController.cs index 5857d1d..4f04f29 100644 --- a/FrontendWebApi/Controllers/EmergencyRecordController.cs +++ b/FrontendWebApi/Controllers/EmergencyRecordController.cs @@ -44,99 +44,5 @@ namespace FrontendWebApi.Controllers return apiResult; } - - [HttpPost] - public async Task>> BuildInfoList() - { - ApiResult> apiResult = new ApiResult>(); - List KeyValue = new List(); - - try - { - var sqlString = @$"select building_guid as Value, full_name as Name from building a where a.deleted = 0 and a.status = 0 ORDER BY A.priority ASC, A.created_at DESC"; - KeyValue = await backendRepository.GetAllAsync(sqlString); - - apiResult.Code = "0000"; - apiResult.Data = KeyValue; - } - catch (Exception exception) - { - apiResult.Code = "9999"; - apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; - Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); - } - - return apiResult; - } - - [HttpPost] - public async Task EmergencyRecordTable(EmergencyRecordEventPost post) - { - List EmergencyRecordEvent = new List(); - ApiResult> apiResult = new ApiResult>(); - try - { - var sqlplus = ""; - if(post.selectaType != 2 ) - { - sqlplus = $"and ee.type = '{post.selectaType}'"; - } - if (post.dateranger != null) - { - var date = post.dateranger.Replace(" ", "").Split("-"); - sqlplus += $"and ee.created_at between '{date[0].Replace(" / ", " - ")} 00:00:00' and '{date[1].Replace(" / ", " - ")} 23:59:59'"; - } - - EmergencyRecordEvent = await backendRepository.GetAllAsync($@" - select d.device_number device_name,v.system_key disaster_name,ee.*,b.full_name building_name from emergency_event ee - left join (select * from variable v where v.system_type = 'disaster') v on v.system_value = ee.disaster - left join device d on d.device_guid = ee.device_guid - left join building b on b.building_guid = ee.building_guid - where ee.deleted = 0 and ee.building_guid = '{post.selectaBuild}' and ee.disaster = '{post.selectaDisaster}' {sqlplus} - "); - apiResult.Code = "0000"; - apiResult.Data = EmergencyRecordEvent; - } - catch (Exception exception) - { - apiResult.Code = "9999"; - apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; - Logger.LogError("【" + controllerName + "/" + actionName + "】"); - Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); - } - var result = Json(new - { - data = apiResult - }); - return result; - } - - - [HttpPost] - public async Task EmergencyItemTable(string event_guid) - { - List EmergencyRecordEvent = new List(); - ApiResult> apiResult = new ApiResult>(); - try - { - EmergencyRecordEvent = await backendRepository.GetAllAsync($@" - select * from emergency_item where event_guid = '{event_guid}' order by created_at desc - "); - apiResult.Code = "0000"; - apiResult.Data = EmergencyRecordEvent; - } - catch (Exception exception) - { - apiResult.Code = "9999"; - apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; - Logger.LogError("【" + controllerName + "/" + actionName + "】"); - Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); - } - var result = Json(new - { - data = apiResult - }); - return result; - } } } diff --git a/FrontendWebApi/Controllers/LoginController.cs b/FrontendWebApi/Controllers/LoginController.cs index 8e7dc50..464ada6 100644 --- a/FrontendWebApi/Controllers/LoginController.cs +++ b/FrontendWebApi/Controllers/LoginController.cs @@ -51,94 +51,5 @@ namespace FrontendWebApi.Controllers ViewBag.ProjectName = backendRepository.GetOneAsync("select system_key from variable where deleted = 0 and system_type = 'project_name';").Result; return View(); } - - [HttpPost] - [Route("api/Login")] - public async Task>> Login(Login login) - { - ApiResult apiResult = new ApiResult(null); - ErrorCode errorCode = new ErrorCode(); - try - { - ControllerContext.HttpContext.Response.Headers.Add("Access-Control-Allow-Origin", "*"); - EDFunction eDFunction = new EDFunction(); - - //string SHA256Pwd = eDFunction.GetSHA256Encryption(login.password); - var User = await backendRepository.GetOneAsync("userinfo", @$"account = '{login.account}' and deleted = 0"); - if (User == null) - { - apiResult.Code = "9998"; - return Ok(apiResult); - } - JwtLogin jwtLoing = new JwtLogin() - { - account = User.account, - email = User.email, - full_name = User.full_name, - userinfo_guid = User.userinfo_guid - }; - apiResult.Code = "0000"; - apiResult.Data = jwt.GenerateToken(jwtLoing); - } - catch - { - apiResult.Code = "9999"; - return BadRequest(apiResult); - } - return Ok(apiResult); - } - - - [HttpPost] - public async Task>> CheckJwt() - { - ApiResult apiResult = new ApiResult(null); - ErrorCode errorCode = new ErrorCode(); - try - { - var ctx = ControllerContext.HttpContext; - ctx.Response.Headers.Add("Access-Control-Allow-Origin", "*"); - ctx.Response.Headers.Add("Access-Control-Allow-Headers", "*"); - ctx.Response.Headers.Add("Access-Control-Allow-Credentials", "true"); - var a = User.Claims.Select(p => new { Type = p.Type, Value = p.Value }).ToList(); - myUser = new JwtGet() - { - account = User.Claims.Where(a => a.Type == "account").Select(e => e.Value).FirstOrDefault(), - email = User.Claims.Where(a => a.Type == "email").Select(e => e.Value).FirstOrDefault(), - full_name = User.Claims.Where(a => a.Type == "full_name").Select(e => e.Value).FirstOrDefault(), - exp = User.Claims.Where(a => a.Type == "exp").Select(e => Convert.ToInt32(e.Value)).FirstOrDefault(), - nbf = User.Claims.Where(a => a.Type == "nbf").Select(e => Convert.ToInt32(e.Value)).FirstOrDefault(), - userinfo_guid = User.Claims.Where(a => a.Type == "userinfo_guid").Select(e => e.Value).FirstOrDefault(), - }; - - if (myUser.exp == 0) - { - jwt_str = "Jwt Token不合法"; - jwtlife = false; - } - else - { - //if (myUser.exp <= DateTime.Now.AddHours(-8).AddMinutes(10).Subtract(new DateTime(1970, 1, 1)).TotalSeconds) - //{ - //取得當前登入使用者資訊 - EDFunction edFunction = new EDFunction(); - HttpContext.Session.SetString("MyApiAccount", edFunction.AESEncrypt(myUser.account)); //將帳號透過AES加密 - //} - } - - apiResult.Code = "0000"; - } - catch(Exception exception) - { - apiResult.Code = "9999"; - string json = System.Text.Json.JsonSerializer.Serialize(myUser.account); - logger.LogError("【Login/Index - 登入資訊】" + json); - logger.LogError("【Login/Index】" + exception.Message); - - return Ok(apiResult); - } - - return Ok(apiResult); - } } } diff --git a/FrontendWebApi/Controllers/MyBaseController.cs b/FrontendWebApi/Controllers/MyBaseController.cs index c319e00..70408ab 100644 --- a/FrontendWebApi/Controllers/MyBaseController.cs +++ b/FrontendWebApi/Controllers/MyBaseController.cs @@ -25,13 +25,9 @@ namespace FrontendWebApi.Controllers { private ILogger _logger; protected ILogger Logger => _logger ?? (_logger = HttpContext?.RequestServices.GetService>()); - - private IBackendRepository backendRepository => HttpContext?.RequestServices.GetService(); private IJwtHelpers jwt => HttpContext?.RequestServices.GetService(); - private IFrontendRepository frontendRepository => HttpContext?.RequestServices.GetService(); - public BackgroundService backgroundService; public MyBaseController() { } protected MyUserInfo myUserInfo = null; protected JwtGet myUser; From 606826eb66e82b72e6f96c794389b575f8182ac2 Mon Sep 17 00:00:00 2001 From: dev02 Date: Fri, 19 May 2023 14:06:25 +0800 Subject: [PATCH 07/19] =?UTF-8?q?[=E5=BE=8C=E7=AB=AF]=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E7=B7=8A=E6=80=A5api=E5=95=8F=E9=A1=8C,=20=E6=96=B0=E5=A2=9Eof?= =?UTF-8?q?fice=20=E7=9A=84mysqldatabase?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Backend/appsettings.Development.json | 1 + Backend/appsettings.json | 1 + FrontendWebApi/ApiControllers/EmergencyDeviceController.cs | 4 ++-- FrontendWebApi/appsettings.Development.json | 1 + FrontendWebApi/appsettings.json | 1 + 5 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Backend/appsettings.Development.json b/Backend/appsettings.Development.json index d9b4695..fa903a2 100644 --- a/Backend/appsettings.Development.json +++ b/Backend/appsettings.Development.json @@ -20,6 +20,7 @@ //"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp "Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome //"Database": "siTUcDaC/g2yGTMFWD72Kg==", //tpe_dome_hotel + //"Database": "iuaY0h0+TWkir44/eZLDqw==", //tpe_dome_office "Root": "SzdxEgaJJ7tcTCrUl2zKsA==", "Password": "FVAPxztxpY4gJJKQ/se4bQ==" } diff --git a/Backend/appsettings.json b/Backend/appsettings.json index c0ce7a5..4a53716 100644 --- a/Backend/appsettings.json +++ b/Backend/appsettings.json @@ -19,6 +19,7 @@ //"Database": "VJB2XC+lAtzuHObDGMVOAA==", //三菱 //"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp "Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome + //"Database": "iuaY0h0+TWkir44/eZLDqw==", //tpe_dome_office "Root": "SzdxEgaJJ7tcTCrUl2zKsA==", "Password": "FVAPxztxpY4gJJKQ/se4bQ==" } diff --git a/FrontendWebApi/ApiControllers/EmergencyDeviceController.cs b/FrontendWebApi/ApiControllers/EmergencyDeviceController.cs index e2e78b4..4dba11c 100644 --- a/FrontendWebApi/ApiControllers/EmergencyDeviceController.cs +++ b/FrontendWebApi/ApiControllers/EmergencyDeviceController.cs @@ -70,7 +70,7 @@ namespace FrontendWebApi.ApiControllers List buildingToF = new List(); try { - var sqlString = @$"select f.floor_guid ,f.full_name floorname,b.building_guid,b.full_name buildingname from floor f left join building b on b.building_guid = f.building_guid order by f.building_guid , f.priority"; + var sqlString = @$"select f.floor_guid ,f.full_name floorname,b.building_tag,b.full_name buildingname from floor f left join building b on b.building_tag = f.building_tag order by f.building_tag , f.priority"; Building_floor = await backendRepository.GetAllAsync(sqlString); var builds = Building_floor.GroupBy(a => a.building_guid).ToList(); @@ -491,7 +491,7 @@ namespace FrontendWebApi.ApiControllers SELECT * FROM device_group dg WHERE dg.device_disaster != 0) dg left join (select * from variable v where v.system_type = 'disaster' and v.deleted = 0) vd on vd.system_value = dg.device_disaster - left join building b on b.building_tag = dg.device_building_guid + left join building b on b.building_tag = dg.device_building_tag left join floor f on f.floor_guid = dg.device_floor_guid left join (select * from variable v where v.system_type = 'device_system_category_layer2' and v.deleted = 0) v2 on v2.system_value = dg.device_system_category_layer2 left join (select * from variable v where v.system_type = 'device_system_category_layer3' and v.deleted = 0) v3 on v3.system_value = dg.device_system_category_layer3 diff --git a/FrontendWebApi/appsettings.Development.json b/FrontendWebApi/appsettings.Development.json index 8253f21..b530df5 100644 --- a/FrontendWebApi/appsettings.Development.json +++ b/FrontendWebApi/appsettings.Development.json @@ -20,6 +20,7 @@ //"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp "Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome //"Database": "siTUcDaC/g2yGTMFWD72Kg==", //tpe_dome_hotel + //"Database": "iuaY0h0+TWkir44/eZLDqw==", //tpe_dome_office "Root": "SzdxEgaJJ7tcTCrUl2zKsA==", "Password": "FVAPxztxpY4gJJKQ/se4bQ==" } diff --git a/FrontendWebApi/appsettings.json b/FrontendWebApi/appsettings.json index eef838c..1052fc0 100644 --- a/FrontendWebApi/appsettings.json +++ b/FrontendWebApi/appsettings.json @@ -26,6 +26,7 @@ //"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp "Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome //"Database": "siTUcDaC/g2yGTMFWD72Kg==", //tpe_dome_hotel + //"Database": "iuaY0h0+TWkir44/eZLDqw==", //tpe_dome_office "Root": "SzdxEgaJJ7tcTCrUl2zKsA==", "Password": "FVAPxztxpY4gJJKQ/se4bQ==" }, From c1a05f2207e90e24cc7025b169482979495c7dc4 Mon Sep 17 00:00:00 2001 From: dev02 Date: Fri, 19 May 2023 14:22:05 +0800 Subject: [PATCH 08/19] =?UTF-8?q?[=E5=BE=8C=E7=AB=AF]=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=89=8D=E5=8F=B0=20class=20building=5Ftag=E5=95=8F=E9=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApiControllers/EmergencyDeviceController.cs | 10 +++++----- FrontendWebApi/Models/EmergencyDevice.cs | 10 +++++----- FrontendWebApi/Models/RescueDevice.cs | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/FrontendWebApi/ApiControllers/EmergencyDeviceController.cs b/FrontendWebApi/ApiControllers/EmergencyDeviceController.cs index 4dba11c..839648c 100644 --- a/FrontendWebApi/ApiControllers/EmergencyDeviceController.cs +++ b/FrontendWebApi/ApiControllers/EmergencyDeviceController.cs @@ -73,12 +73,12 @@ namespace FrontendWebApi.ApiControllers var sqlString = @$"select f.floor_guid ,f.full_name floorname,b.building_tag,b.full_name buildingname from floor f left join building b on b.building_tag = f.building_tag order by f.building_tag , f.priority"; Building_floor = await backendRepository.GetAllAsync(sqlString); - var builds = Building_floor.GroupBy(a => a.building_guid).ToList(); + var builds = Building_floor.GroupBy(a => a.building_tag).ToList(); foreach (var floor in builds) { BuildingToF buildingToF1 = new BuildingToF() { - building_guid = floor.Select(a => a.building_guid).FirstOrDefault(), + building_tag = floor.Select(a => a.building_tag).FirstOrDefault(), building_name = floor.Select(a => a.buildingname).FirstOrDefault(), floors = new List() }; @@ -194,7 +194,7 @@ namespace FrontendWebApi.ApiControllers { {"@emergency_event_guid",newguid}, {"@disaster",eventpost.disaster}, - {"@building_guid", eventpost.build}, + {"@building_tag", eventpost.build}, {"@device_guid",eventpost.device }, {"@type",eventpost.type} }; @@ -507,13 +507,13 @@ namespace FrontendWebApi.ApiControllers Name = diss.Select(a => a.disater_name).FirstOrDefault().ToString(), groupBuildings = new List() }; - var buds = diss.GroupBy(a => a.device_building_guid); + var buds = diss.GroupBy(a => a.device_building_tag); getDeviceGroup1.groupBuildings = new List(); foreach (var bud in buds) { GroupBuildings groupBuildings = new GroupBuildings() { - guid = bud.Key, + tag = bud.Key, name = bud.Select(a => a.building_name).FirstOrDefault().ToString(), device_amount = 0, groupFloors = new List() diff --git a/FrontendWebApi/Models/EmergencyDevice.cs b/FrontendWebApi/Models/EmergencyDevice.cs index 4e55131..4f8eaec 100644 --- a/FrontendWebApi/Models/EmergencyDevice.cs +++ b/FrontendWebApi/Models/EmergencyDevice.cs @@ -8,7 +8,7 @@ namespace FrontendWebApi.Models public class EmergencyDeviceGroup { public string device_disaster { get; set; } - public string device_building_guid { get; set; } + public string device_building_tag { get; set; } public string device_floor_guid { get; set; } public string device_system_category_layer2 { get; set; } public string device_system_category_layer3 { get; set; } @@ -35,7 +35,7 @@ namespace FrontendWebApi.Models public class GroupBuildings { - public string guid { get; set; } + public string tag { get; set; } public string name { get; set; } public int device_amount { get; set; } public List groupFloors { get; set; } @@ -68,13 +68,13 @@ namespace FrontendWebApi.Models { public string floor_guid { get; set; } public string floorname { get; set; } - public string building_guid { get; set; } + public string building_tag { get; set; } public string buildingname { get; set; } } public class BuildingToF { - public string building_guid { get; set; } + public string building_tag { get; set; } public string building_name { get; set; } public List floors { get; set; } } @@ -89,7 +89,7 @@ namespace FrontendWebApi.Models public string device_guid { get; set; } public string device_number { get; set; } public string device_name { get; set; } - public string building_guid { get; set; } + public string building_tag { get; set; } public string building_name { get; set; } public string ip_address { get; set; } public string layer2 { get; set; } diff --git a/FrontendWebApi/Models/RescueDevice.cs b/FrontendWebApi/Models/RescueDevice.cs index 708273c..f29939a 100644 --- a/FrontendWebApi/Models/RescueDevice.cs +++ b/FrontendWebApi/Models/RescueDevice.cs @@ -37,7 +37,7 @@ namespace FrontendWebApi.Models { public string rescue_device_guid { get; set; } public string rescue_device_id { get; set; } - public string building_guid { get; set; } + public string building_tag { get; set; } public string floor_guid { get; set; } public string floor_name { get; set; } public string location { get; set; } From e77715fb0e552c2c63fba47b21303ba57aafff22 Mon Sep 17 00:00:00 2001 From: dev01 Date: Fri, 19 May 2023 14:26:54 +0800 Subject: [PATCH 09/19] =?UTF-8?q?[=E5=89=8D=E5=8F=B0][=E7=B7=8A=E6=80=A5?= =?UTF-8?q?=E6=87=89=E8=AE=8A]=20=E5=89=8D=E7=AB=AF=E4=BA=94=E6=AE=B5?= =?UTF-8?q?=E6=94=B9=E5=85=AB=E6=AE=B5=E8=AA=BF=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Views/EmergencyDeviceMenu/Index.cshtml | 84 +++++++++---------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/FrontendWebApi/Views/EmergencyDeviceMenu/Index.cshtml b/FrontendWebApi/Views/EmergencyDeviceMenu/Index.cshtml index 9d69c45..19ef091 100644 --- a/FrontendWebApi/Views/EmergencyDeviceMenu/Index.cshtml +++ b/FrontendWebApi/Views/EmergencyDeviceMenu/Index.cshtml @@ -337,7 +337,7 @@ var SelectedFilter = { disasters: [], - building_guid: '', + building_tag: '', floor_guids: [], layer2: [], layer3: [] @@ -393,7 +393,7 @@ $("#building").find(".building_device_amount").html(0); rel.data.buildingAlarmDeviceAmount.forEach(function (item) { - $(`#${item.building_guid}_device_amount`).html(item.device_amount); + $(`#${item.building_tag}_device_amount`).html(item.device_amount); }); ResetDeviceTable(); } @@ -562,13 +562,13 @@ "data": "device_number", "render": function (data, type, row, meta) { @*var html = ` - + ${data} `;*@ var html = ` - + ${data} `; @@ -620,7 +620,7 @@ "type": "POST", "data": function (d) { d.select_disasters = SelectedFilter.disasters; - d.selectbuilding = SelectedFilter.building_guid; + d.selectbuilding = SelectedFilter.building_tag; d.select_Floors = SelectedFilter.floor_guids; d.select_Layer3 = SelectedFilter.layer3; }, @@ -656,7 +656,7 @@ device_number: temp_device.device_number, device_name: temp_device.device_name, building_name: temp_device.building_name, - building_guid: temp_device.building_guid, + building_tag: temp_device.building_tag, ip_address: temp_device.ip_address, disaster: temp_device.disaster, disaster_name: temp_device.disaster_name, @@ -669,10 +669,10 @@ alarm_timestamp: alarm_device.alarm_timestamp, } - var temp_building_index = backfill_building_alarm_device_amount.findIndex(x => x.building_guid == temp_device.building_guid); + var temp_building_index = backfill_building_alarm_device_amount.findIndex(x => x.building_tag == temp_device.building_tag); if (temp_building_index < 0) { var building_obj = { - building_guid: temp_device.building_guid, + building_tag: temp_device.building_tag, device_amount: 1 } @@ -681,10 +681,10 @@ backfill_building_alarm_device_amount[temp_building_index].device_amount += 1; } - var temp_layer2_index = backfill_layer2_alarm_device_amount.findIndex(x => x.value == temp_device.layer2 && x.building_guid == temp_device.building_guid) + var temp_layer2_index = backfill_layer2_alarm_device_amount.findIndex(x => x.value == temp_device.layer2 && x.building_tag == temp_device.building_tag) if (temp_layer2_index < 0) { var layer2_obj = { - building_guid: temp_device.building_guid, + building_tag: temp_device.building_tag, value: temp_device.layer2, device_amount: 1 } @@ -694,10 +694,10 @@ backfill_layer2_alarm_device_amount[temp_layer2_index].device_amount += 1; } - var temp_layer3_index = backfill_layer3_alarm_device_amount.findIndex(x => x.layer3 == temp_device.layer3 && x.layer2 == temp_device.layer2 && x.building_guid == temp_device.building_guid) + var temp_layer3_index = backfill_layer3_alarm_device_amount.findIndex(x => x.layer3 == temp_device.layer3 && x.layer2 == temp_device.layer2 && x.building_tag == temp_device.building_tag) if (temp_layer3_index < 0) { var layer3_obj = { - building_guid: temp_device.building_guid, + building_tag: temp_device.building_tag, layer2: temp_device.layer2, layer3: temp_device.layer3, device_amount: 1 @@ -764,10 +764,10 @@ device_amount: layer3.device_amount } - var temp_building_index = backfill_building_device_amount.findIndex(x => x.building_guid == building.guid); + var temp_building_index = backfill_building_device_amount.findIndex(x => x.building_tag == building.guid); if (temp_building_index < 0) { var building_obj = { - building_guid: building.guid, + building_tag: building.guid, device_amount: new_layer3.device_amount } @@ -776,10 +776,10 @@ backfill_building_device_amount[temp_building_index].device_amount += new_layer3.device_amount; } - var temp_layer2_index = backfill_layer2_device_amount.findIndex(x => x.value == layer2.value && x.building_guid == building.guid) + var temp_layer2_index = backfill_layer2_device_amount.findIndex(x => x.value == layer2.value && x.building_tag == building.guid) if (temp_layer2_index < 0) { var layer2_obj = { - building_guid: building.guid, + building_tag: building.guid, value: layer2.value, device_amount: new_layer3.device_amount } @@ -789,10 +789,10 @@ backfill_layer2_device_amount[temp_layer2_index].device_amount += new_layer3.device_amount; } - var temp_layer3_index = backfill_layer3_device_amount.findIndex(x => x.layer3 == layer3.value && x.layer2 == layer2.value && x.building_guid == building.guid) + var temp_layer3_index = backfill_layer3_device_amount.findIndex(x => x.layer3 == layer3.value && x.layer2 == layer2.value && x.building_tag == building.guid) if (temp_layer3_index < 0) { var layer3_obj = { - building_guid: building.guid, + building_tag: building.guid, layer2: layer2.value, layer3: layer3.value, device_amount: new_layer3.device_amount @@ -909,7 +909,7 @@ var html = ""; temp_all_building.forEach(function (building, building_index) { - var building_device_amount = backfill_building_device_amount.filter(x => x.building_guid == building.guid)[0]; + var building_device_amount = backfill_building_device_amount.filter(x => x.building_tag == building.guid)[0]; @*html += `
@@ -941,10 +941,10 @@ //#endregion //#region 選擇棟別 - function SelectBuilding(building_guid, e) { + function SelectBuilding(building_tag, e) { $('#building').find('button').removeClass('btn-success').addClass('btn-secondary') - SelectedFilter.building_guid = building_guid; + SelectedFilter.building_tag = building_tag; if (show_mode == 'alarm') { $(e).find('button').addClass('btn-success'); } else { @@ -963,7 +963,7 @@ all_device_group.forEach(function (disaster, disaster_index) { if (SelectedFilter.disasters.findIndex(x => x == disaster.value) > -1) { //抓取已選擇的防災類型的棟別內容 disaster.groupBuildings.forEach(function (building, building_index) { - if (building.guid == SelectedFilter.building_guid) { //抓取選擇棟別的底下樓層 + if (building.guid == SelectedFilter.building_tag) { //抓取選擇棟別的底下樓層 building.groupFloors.forEach(function (floor, floor_index) { if (temp_all_floor.findIndex(x => x.guid == floor.guid) < 0) { //表示未加入,需加入 temp_all_floor.push(floor); @@ -1034,7 +1034,7 @@ all_device_group.forEach(function (disaster, disaster_index) { if (SelectedFilter.disasters.findIndex(x => x == disaster.value) > -1) { //抓取選擇防災類型的底下棟別 disaster.groupBuildings.forEach(function (building, building_index) { - if (building.guid == SelectedFilter.building_guid) { //抓取選擇棟別的底下樓層 + if (building.guid == SelectedFilter.building_tag) { //抓取選擇棟別的底下樓層 building.groupFloors.forEach(function (floor, floor_index) { if (SelectedFilter.floor_guids.findIndex(x => x == floor.guid) > -1) { //抓取選擇樓層的底下大類 floor.groupLayer2s.forEach(function (layer2, layer2_index) { @@ -1056,18 +1056,18 @@ var html = ""; temp_all_layer2.forEach(function (layer2, layer2_index) { - var layer2_device_amount = backfill_layer2_device_amount.filter(x => x.value == layer2.value && x.building_guid == SelectedFilter.building_guid)[0]; + var layer2_device_amount = backfill_layer2_device_amount.filter(x => x.value == layer2.value && x.building_tag == SelectedFilter.building_tag)[0]; @*html += `
- +
`;*@ html += `
- +
`; }); @@ -1125,7 +1125,7 @@ all_device_group.forEach(function (disaster, disaster_index) { if (SelectedFilter.disasters.findIndex(x => x == disaster.value) > -1) { //抓取選擇防災類型的底下棟別 disaster.groupBuildings.forEach(function (building, building_index) { - if (building.guid == SelectedFilter.building_guid) { //抓取選擇棟別的底下樓層 + if (building.guid == SelectedFilter.building_tag) { //抓取選擇棟別的底下樓層 building.groupFloors.forEach(function (floor, floor_index) { if (SelectedFilter.floor_guids.findIndex(x => x == floor.guid) > -1) { //抓取選擇樓層的底下大類 floor.groupLayer2s.forEach(function (layer2, layer2_index) { @@ -1161,18 +1161,18 @@ var html = ""; temp_all_layer3.forEach(function (layer3, layer3_index) { - var layer3_device_amount = backfill_layer3_device_amount.filter(x => x.layer3 == layer3.value && x.building_guid == SelectedFilter.building_guid)[0]; + var layer3_device_amount = backfill_layer3_device_amount.filter(x => x.layer3 == layer3.value && x.building_tag == SelectedFilter.building_tag)[0]; @*html += `
- +
`;*@ html += `
- +
`; }); @@ -1226,20 +1226,20 @@ function ResetDeviceTable() { if ((SelectedFilter.disasters == null || SelectedFilter.disasters.length <= 0) - || (SelectedFilter.building_guid == null || SelectedFilter.building_guid == "") + || (SelectedFilter.building_tag == null || SelectedFilter.building_tag == "") || (SelectedFilter.floor_guids == null || SelectedFilter.floor_guids.length <= 0) || (SelectedFilter.layer3 == null || SelectedFilter.layer3.length <= 0) ) { return; } - if (changeBuilding != "" && changeBuilding != SelectedFilter.building_guid) { + if (changeBuilding != "" && changeBuilding != SelectedFilter.building_tag) { alarmDeviceTable.clear().draw(); } else { alarmDeviceTable.ajax.reload(null, false); } - changeBuilding = SelectedFilter.building_guid; + changeBuilding = SelectedFilter.building_tag; } //#endregion @@ -1250,39 +1250,39 @@ if (show_mode == 'alarm') { backfill_building_alarm_device_amount.forEach(function (building, index) { - $(`#${building.building_guid}_device_amount`).html(building.device_amount); + $(`#${building.building_tag}_device_amount`).html(building.device_amount); }); backfill_layer2_alarm_device_amount.forEach(function (layer2, index) { - $(`#${layer2.building_guid}_${layer2.value}_device_amount`).html(layer2.device_amount); + $(`#${layer2.building_tag}_${layer2.value}_device_amount`).html(layer2.device_amount); }); backfill_layer3_alarm_device_amount.forEach(function (layer3, index) { - $(`#${layer3.building_guid}_${layer3.layer3}_device_amount`).html(layer3.device_amount); + $(`#${layer3.building_tag}_${layer3.layer3}_device_amount`).html(layer3.device_amount); }); } else { backfill_building_device_amount.forEach(function (building, index) { - $(`#${building.building_guid}_device_amount`).html(building.device_amount); + $(`#${building.building_tag}_device_amount`).html(building.device_amount); }); backfill_layer2_device_amount.forEach(function (layer2, index) { - $(`#${layer2.building_guid}_${layer2.value}_device_amount`).html(layer2.device_amount); + $(`#${layer2.building_tag}_${layer2.value}_device_amount`).html(layer2.device_amount); }); backfill_layer3_device_amount.forEach(function (layer3, index) { - $(`#${layer3.building_guid}_${layer3.layer3}_device_amount`).html(layer3.device_amount); + $(`#${layer3.building_tag}_${layer3.layer3}_device_amount`).html(layer3.device_amount); }); } } //#endregion //#region 變更右方地圖(改為跳新分頁) - function ChangeFloormap(building_guid, floor_guid, device_number, layer3) { + function ChangeFloormap(building_tag, floor_guid, device_number, layer3) { @* $("#iframe-floormap").empty(); $("#iframe-floormap").append( - `` + `` ) *@ } @@ -1312,7 +1312,7 @@ // de_number = $(e).parent().parent().attr('de-number'); var url = "/api/EmergencyDevice/SaveAndOpenSimulationExercise"; var send_data = { - build: SelectedFilter.building_guid, + build: SelectedFilter.building_tag, disaster: disaster, type: type, device: guid From 8a2ac8e3931f00c0684f9c09fb48e0ae3ef38cec Mon Sep 17 00:00:00 2001 From: dev01 Date: Fri, 19 May 2023 18:47:45 +0800 Subject: [PATCH 10/19] =?UTF-8?q?[=E7=B7=8A=E6=80=A5=E6=87=89=E8=AE=8A]=20?= =?UTF-8?q?=E7=B0=A1=E8=A8=8A=E7=99=BC=E9=80=81=E7=A8=8B=E5=BA=8F=E5=BB=BA?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApiControllers/BuildController.cs | 20 +-- .../ApiControllers/HiNetController.cs | 2 +- FrontendWebApi/Models/Build.cs | 8 +- .../Views/EmergencyDeviceMenu/Index.cshtml | 118 +++++++++++++++++- 4 files changed, 128 insertions(+), 20 deletions(-) diff --git a/FrontendWebApi/ApiControllers/BuildController.cs b/FrontendWebApi/ApiControllers/BuildController.cs index 5fa1457..0e73864 100644 --- a/FrontendWebApi/ApiControllers/BuildController.cs +++ b/FrontendWebApi/ApiControllers/BuildController.cs @@ -582,41 +582,41 @@ namespace FrontendWebApi.ApiControllers { var device_url = string.Empty; - if (((de.icon_click & 1) > 0) && !string.IsNullOrEmpty(de.icon_click_url)) + if (((de.left_icon_click & 1) > 0) && !string.IsNullOrEmpty(de.left_icon_click_url)) { - device_url = de.icon_click_url; + device_url = de.left_icon_click_url; //點擊顯示系統圖 - if (de.icon_click_url.Contains("[device_building_tag]")) + if (de.left_icon_click_url.Contains("[device_building_tag]")) { device_url = device_url.Replace("[device_building_tag]", de.device_building_tag); } - if (de.icon_click_url.Contains("[device_system_tag]")) + if (de.left_icon_click_url.Contains("[device_system_tag]")) { device_url = device_url.Replace("[device_system_tag]", de.device_system_tag); } - if (de.icon_click_url.Contains("[device_floor_tag]")) + if (de.left_icon_click_url.Contains("[device_floor_tag]")) { device_url = device_url.Replace("[device_floor_tag]", de.device_floor_tag); } - if (de.icon_click_url.Contains("[device_name_tag]")) + if (de.left_icon_click_url.Contains("[device_name_tag]")) { device_url = device_url.Replace("[device_name_tag]", de.device_name_tag); } - if (de.icon_click_url.Contains("[device_serial_tag]")) + if (de.left_icon_click_url.Contains("[device_serial_tag]")) { device_url = device_url.Replace("[device_serial_tag]", de.device_serial_tag); } - if (de.icon_click_url.Contains("[tag_name]")) + if (de.left_icon_click_url.Contains("[tag_name]")) { device_url = device_url.Replace("[tag_name]", de.device_number); } - de.icon_click_url = null; + de.left_icon_click_url = null; de.DeviceURL = device_url; } @@ -642,7 +642,7 @@ namespace FrontendWebApi.ApiControllers // priority = de.priority, // status = de.status, // DeviceURL = device_url, - // icon_click = de.icon_click + // left_icon_click = de.left_icon_click //}; //afloor.device.Add(device); } diff --git a/FrontendWebApi/ApiControllers/HiNetController.cs b/FrontendWebApi/ApiControllers/HiNetController.cs index a5cc095..1285703 100644 --- a/FrontendWebApi/ApiControllers/HiNetController.cs +++ b/FrontendWebApi/ApiControllers/HiNetController.cs @@ -825,7 +825,7 @@ namespace FrontendWebApi.ApiControllers Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); return Ok(apiResult); } - + apiResult.Code = "0000"; return Ok(apiResult); } } diff --git a/FrontendWebApi/Models/Build.cs b/FrontendWebApi/Models/Build.cs index d072fd8..a5b5174 100644 --- a/FrontendWebApi/Models/Build.cs +++ b/FrontendWebApi/Models/Build.cs @@ -186,10 +186,10 @@ namespace FrontendWebApi.Models public byte device_error_flashing { get; set; } public byte device_error_independent { get; set; } public int priority { get; set; } - public byte icon_click { get; set; } - public string icon_click_url { get; set; } - public int icon_click_url_width { get; set; } - public int icon_click_url_height { get; set; } + public byte left_icon_click { get; set; } + public string left_icon_click_url { get; set; } + public int left_icon_click_url_width { get; set; } + public int left_icon_click_url_height { get; set; } public string DeviceURL { get; set; } public string point_name { get; set; } public string points { get; set; } diff --git a/FrontendWebApi/Views/EmergencyDeviceMenu/Index.cshtml b/FrontendWebApi/Views/EmergencyDeviceMenu/Index.cshtml index 19ef091..677339f 100644 --- a/FrontendWebApi/Views/EmergencyDeviceMenu/Index.cshtml +++ b/FrontendWebApi/Views/EmergencyDeviceMenu/Index.cshtml @@ -282,20 +282,23 @@
- + 發訊人:
- +
- +
- + +
@@ -1418,6 +1421,7 @@ //#region 模擬演練 / SOP modal 開啟發送簡訊Modal function OpenSendSMSModal() { + ToVerifyType = 2; $('#send-sms-modal').modal(); SmsMemberTable.ajax.reload(); } @@ -1731,7 +1735,7 @@ { EmerLastsetting = $('#bigsetting').find('.active').attr('mas'); ToVerifyType = 0; - $('.modal-title').html("指揮官驗證"); + //$('.modal-title').html("指揮官驗證"); $('#small_setting').hide(); $('#emergency_verify_input').val(''); $('#emergency-verify-modal').modal(); @@ -1747,6 +1751,7 @@ } function PassVerify(Vbool) { + console.log(SmsMemberTable.data().toArray()) if (ToVerifyType == 0) { if (Vbool) { var url = "api/EmergencyDevice/CheckVerifybool"; @@ -1815,6 +1820,109 @@ $('#emergency-verify-modal').modal('hide'); } } + + if(ToVerifyType == 2) { + if (Vbool) { + if(!$("#sms_messagebox").val()){ + toast_warning('請輸入簡訊內容'); + return; + } + controlSmsSaveBtnLoading(true); + var url = "api/EmergencyDevice/CheckVerifybool"; + var send_data = { + pass: $('#sendSms_verify_input').val() + }; + + $.post(url, send_data, function (rel) { + if (rel.code != "0000") { + if (rel.code == "9999") { + toast_error(rel.msg); + } + return; + } else { + if (rel.data) { + Verifybool = true; + sendSmsMessage(); + } else { + toast_warning('密碼驗證失敗,請重新驗證'); + } + } + controlSmsSaveBtnLoading(false); + }) + } else {//取消驗證 + if (EmerLastsetting == 0) { + + } else { + $('#small_setting').show(); + $('#bigsetting').find('.active').removeClass('active'); + $(`#t${EmerLastsetting}_tab`).addClass('active'); + + $('#small_setting').find('.show').removeClass('active show') + $(`#t${EmerLastsetting}_modal`).addClass('active show'); + + $('#list_' + EmerLastsetting).find('.active').children().trigger('click'); + $('#emergency-verify-modal').modal('hide'); + } + + + + } + } + } + + function controlSmsSaveBtnLoading(isShow = true) { + if(isShow){ + $("#smsSaveBtnLoading").parent("button").prop("disabled",true); + $("#smsSaveBtnLoading").fadeIn(200); + } else { + $("#smsSaveBtnLoading").fadeOut(200); + $("#smsSaveBtnLoading").parent("button").prop("disabled",false); + } + + } + + function sendSmsMessage() { + if(Verifybool){ + const members = SmsMemberTable.data().toArray(); + const url = "api/HiNetMsg"; + controlSmsSaveBtnLoading(true); + members.forEach(m => { + const send_data = { + Number:m.phone, + Msg:$("#sms_messagebox").val(), + }; + $.ajax({ + method:"POST", + url:url, + data:JSON.stringify(send_data), + contentType:"application/json;charset=utf-8", + success:(rel) => { + if (rel.code != "0000") { + if (rel.code == "9999") { + toast_error(rel.msg); + } + return; + } else { + if (rel.data) { + toast_ok("簡訊發送成功"); + $("#send-sms-modal").modal("hide"); + } else { + toast_warning('簡訊發送失敗,請重新操作'); + } + } + }, + complete:() => { + controlSmsSaveBtnLoading(false); + } + }) + //$.post(url, JSON.stringify(send_data),{contentType:"applicaiton/json;charset=utf-8"}, function (rel) { + + //}) + }) + } else { + toast_warning('密碼驗證失敗,請重新驗證'); + } + } function Closemodal() { From ba6fc268f07157f5f477c6ee308c711d08900c77 Mon Sep 17 00:00:00 2001 From: dev02 Date: Mon, 22 May 2023 10:09:01 +0800 Subject: [PATCH 11/19] =?UTF-8?q?[=E5=BE=8C=E7=AB=AF]=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?table=E5=95=8F=E9=A1=8C,=20db=E6=96=B0=E5=A2=9Etable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FrontendWebApi/ApiControllers/DeviceManageController.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/FrontendWebApi/ApiControllers/DeviceManageController.cs b/FrontendWebApi/ApiControllers/DeviceManageController.cs index d84690f..0dc7b34 100644 --- a/FrontendWebApi/ApiControllers/DeviceManageController.cs +++ b/FrontendWebApi/ApiControllers/DeviceManageController.cs @@ -581,8 +581,8 @@ namespace FrontendWebApi.ApiControllers LENGTH(SUBSTRING_INDEX(errmsg, '_', -1) -1) -- 最後一段的長度 -1 -- 減掉最後的 _ ex:D3_B_B1F_CO_ ) device_tag - FROM alarmorion_orionalarmrecord a - JOIN alarmorion_orionalarmfacetvalue b on a.id = b.alarm + FROM alarmOrion_OrionAlarmRecord a + JOIN alarmOrion_OrionAlarmFacetValue b on a.id = b.alarm WHERE a.sourceState = 1 and b.facetName = 9 ) a left join device b on a.device_tag = b.device_number AND b.deleted = 0 From aa61f213544e3a8f2e0a4da1510b2f1d39c70866 Mon Sep 17 00:00:00 2001 From: dev02 Date: Mon, 22 May 2023 10:19:15 +0800 Subject: [PATCH 12/19] =?UTF-8?q?[=E5=BE=8C=E7=AB=AF]=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?table=20=E5=8F=A6=E5=90=8D=E9=8C=AF=E8=AA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FrontendWebApi/ApiControllers/RescueDeviceController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FrontendWebApi/ApiControllers/RescueDeviceController.cs b/FrontendWebApi/ApiControllers/RescueDeviceController.cs index ac58c9f..2e9b04c 100644 --- a/FrontendWebApi/ApiControllers/RescueDeviceController.cs +++ b/FrontendWebApi/ApiControllers/RescueDeviceController.cs @@ -88,7 +88,7 @@ namespace FrontendWebApi.ApiControllers try { - var sqlString = @$"select building_tag as Value, full_name as Name from building a where a.deleted = 0 and a.status = 0 ORDER BY A.priority ASC, A.created_at DESC"; + var sqlString = @$"select building_tag as Value, full_name as Name from building a where a.deleted = 0 and a.status = 0 ORDER BY a.priority ASC, a.created_at DESC"; KeyValue = await backendRepository.GetAllAsync(sqlString); apiResult.Code = "0000"; From c5ee9299aba6c85b6c27aea7e2214410e0f4468c Mon Sep 17 00:00:00 2001 From: dev01 Date: Mon, 22 May 2023 11:57:41 +0800 Subject: [PATCH 13/19] =?UTF-8?q?[=E5=89=8D=E5=8F=B0][=E7=B7=8A=E6=80=A5?= =?UTF-8?q?=E6=87=89=E8=AE=8A]=20GetEmergencySetting,=20GetContentAndMakeI?= =?UTF-8?q?tem,=20BuildInfoList=20API=20=E7=A8=8B=E5=BA=8F=E8=AA=BF?= =?UTF-8?q?=E6=95=B4=20|=20[=E7=B7=8A=E6=80=A5=E6=87=89=E8=AE=8A][?= =?UTF-8?q?=E8=81=AF=E7=B5=A1=E6=B8=85=E5=96=AE]=20=E5=89=8D=E7=AB=AF?= =?UTF-8?q?=E7=A8=8B=E5=BA=8Fapi=E4=B8=B2=E6=8E=A5=E8=AA=BF=E6=95=B4=20=20?= =?UTF-8?q?|=20[=E7=B7=8A=E6=80=A5=E6=87=89=E8=AE=8A][=E8=A8=AD=E5=82=99?= =?UTF-8?q?=E7=B8=BD=E8=A6=BD]=20=E5=89=8D=E7=AB=AF=E7=A8=8B=E5=BA=8Fapi?= =?UTF-8?q?=E4=B8=B2=E6=8E=A5=E8=AA=BF=E6=95=B4=20|=20[=E7=B7=8A=E6=80=A5?= =?UTF-8?q?=E6=87=89=E8=AE=8A][=E7=B4=80=E9=8C=84=E6=9F=A5=E8=A9=A2]=20?= =?UTF-8?q?=E5=89=8D=E7=AB=AF=E7=A8=8B=E5=BA=8Fapi=E4=B8=B2=E6=8E=A5?= =?UTF-8?q?=E8=AA=BF=E6=95=B4=20|=20=20[=E7=B7=8A=E6=80=A5=E6=87=89?= =?UTF-8?q?=E8=AE=8A][AED=E8=A3=9D=E7=BD=AE=E8=A8=AD=E5=AE=9A]=20=E5=89=8D?= =?UTF-8?q?=E7=AB=AF=E7=A8=8B=E5=BA=8Fapi=E4=B8=B2=E6=8E=A5=E8=AA=BF?= =?UTF-8?q?=E6=95=B4=E3=80=81=E4=B8=8B=E8=BC=89=E7=A8=8B=E5=BA=8F=E8=AA=BF?= =?UTF-8?q?=E6=95=B4=20|=20=20[=E7=B7=8A=E6=80=A5=E6=87=89=E8=AE=8A][?= =?UTF-8?q?=E6=BB=85=E7=81=AB=E5=99=A8=E8=A3=9D=E7=BD=AE=E8=A8=AD=E5=AE=9A?= =?UTF-8?q?]=20=E5=89=8D=E7=AB=AF=E7=A8=8B=E5=BA=8Fapi=E4=B8=B2=E6=8E=A5?= =?UTF-8?q?=E8=AA=BF=E6=95=B4=E3=80=81=E4=B8=8B=E8=BC=89=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E8=AA=BF=E6=95=B4=20|?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EmergencyDeviceController.cs | 4 +-- .../ApiControllers/RescueDeviceController.cs | 2 +- .../Views/EmergencyContact/Index.cshtml | 4 +-- .../Views/EmergencyDeviceMenu/Index.cshtml | 32 ++++++++--------- .../Views/EmergencyRecord/Index.cshtml | 10 +++--- FrontendWebApi/Views/RescueDevice/AED.cshtml | 12 ++++++- .../RescueDevice/FireExtinguisher.cshtml | 14 +++++++- FrontendWebApi/wwwroot/js/site.js | 34 +++++++++++++++++-- 8 files changed, 82 insertions(+), 30 deletions(-) diff --git a/FrontendWebApi/ApiControllers/EmergencyDeviceController.cs b/FrontendWebApi/ApiControllers/EmergencyDeviceController.cs index 839648c..c294721 100644 --- a/FrontendWebApi/ApiControllers/EmergencyDeviceController.cs +++ b/FrontendWebApi/ApiControllers/EmergencyDeviceController.cs @@ -267,7 +267,7 @@ namespace FrontendWebApi.ApiControllers try { Emergency_Setting_tables = await backendRepository.GetAllAsync($@" - select v.system_key big_setting_name,* from emergency_setting es left join variable v on es.big_setting = v.id + select v.system_key big_setting_name,es.* from emergency_setting es left join variable v on es.big_setting = v.id where es.big_setting = {selectsetting} and es.deleted = 0 order by es.priority"); apiResult.Code = "0000"; apiResult.Data = Emergency_Setting_tables; @@ -296,7 +296,7 @@ namespace FrontendWebApi.ApiControllers try { var Emergency_Setting_tables = await backendRepository.GetOneAsync($@" - select v.system_key big_setting_name,* from emergency_setting es left join variable v on es.big_setting = v.id + select v.system_key big_setting_name,es.* from emergency_setting es left join variable v on es.big_setting = v.id where es.emergency_guid = '{post.emergency_guid}'"); if (post.make_item == 1) diff --git a/FrontendWebApi/ApiControllers/RescueDeviceController.cs b/FrontendWebApi/ApiControllers/RescueDeviceController.cs index ac58c9f..2e9b04c 100644 --- a/FrontendWebApi/ApiControllers/RescueDeviceController.cs +++ b/FrontendWebApi/ApiControllers/RescueDeviceController.cs @@ -88,7 +88,7 @@ namespace FrontendWebApi.ApiControllers try { - var sqlString = @$"select building_tag as Value, full_name as Name from building a where a.deleted = 0 and a.status = 0 ORDER BY A.priority ASC, A.created_at DESC"; + var sqlString = @$"select building_tag as Value, full_name as Name from building a where a.deleted = 0 and a.status = 0 ORDER BY a.priority ASC, a.created_at DESC"; KeyValue = await backendRepository.GetAllAsync(sqlString); apiResult.Code = "0000"; diff --git a/FrontendWebApi/Views/EmergencyContact/Index.cshtml b/FrontendWebApi/Views/EmergencyContact/Index.cshtml index ccef77e..c7e06aa 100644 --- a/FrontendWebApi/Views/EmergencyContact/Index.cshtml +++ b/FrontendWebApi/Views/EmergencyContact/Index.cshtml @@ -106,7 +106,7 @@ $(row).attr('guid', data.emergency_guid); }, "ajax": { - "url": "/EmergencyContact/EmergencyContactTable", + "url": "/api/EmergencyContact/EmergencyContactTable", "type": "POST", "data": function (d) { d.selectgroupidlist = selectgroupidlist @@ -116,7 +116,7 @@ toast_error(rel.msg); return; } - data = rel.data.data; + data = rel.data; if (data == null || data.length == 0) { this.data = []; diff --git a/FrontendWebApi/Views/EmergencyDeviceMenu/Index.cshtml b/FrontendWebApi/Views/EmergencyDeviceMenu/Index.cshtml index 677339f..ac07ab6 100644 --- a/FrontendWebApi/Views/EmergencyDeviceMenu/Index.cshtml +++ b/FrontendWebApi/Views/EmergencyDeviceMenu/Index.cshtml @@ -767,10 +767,10 @@ device_amount: layer3.device_amount } - var temp_building_index = backfill_building_device_amount.findIndex(x => x.building_tag == building.guid); + var temp_building_index = backfill_building_device_amount.findIndex(x => x.building_tag == building.tag); if (temp_building_index < 0) { var building_obj = { - building_tag: building.guid, + building_tag: building.tag, device_amount: new_layer3.device_amount } @@ -779,10 +779,10 @@ backfill_building_device_amount[temp_building_index].device_amount += new_layer3.device_amount; } - var temp_layer2_index = backfill_layer2_device_amount.findIndex(x => x.value == layer2.value && x.building_tag == building.guid) + var temp_layer2_index = backfill_layer2_device_amount.findIndex(x => x.value == layer2.value && x.building_tag == building.tag) if (temp_layer2_index < 0) { var layer2_obj = { - building_tag: building.guid, + building_tag: building.tag, value: layer2.value, device_amount: new_layer3.device_amount } @@ -792,10 +792,10 @@ backfill_layer2_device_amount[temp_layer2_index].device_amount += new_layer3.device_amount; } - var temp_layer3_index = backfill_layer3_device_amount.findIndex(x => x.layer3 == layer3.value && x.layer2 == layer2.value && x.building_tag == building.guid) + var temp_layer3_index = backfill_layer3_device_amount.findIndex(x => x.layer3 == layer3.value && x.layer2 == layer2.value && x.building_tag == building.tag) if (temp_layer3_index < 0) { var layer3_obj = { - building_tag: building.guid, + building_tag: building.tag, layer2: layer2.value, layer3: layer3.value, device_amount: new_layer3.device_amount @@ -900,7 +900,7 @@ all_device_group.forEach(function (disaster, disaster_index) { if (SelectedFilter.disasters.findIndex(x => x == disaster.value) > -1) { //表示已選擇該防災類型 disaster.groupBuildings.forEach(function (building, building_index) { - if (temp_all_building.findIndex(x => x.guid == building.guid) < 0) { //表示未加入,需加入 + if (temp_all_building.findIndex(x => x.tag == building.tag) < 0) { //表示未加入,需加入 temp_all_building.push(building); } }); @@ -912,16 +912,16 @@ var html = ""; temp_all_building.forEach(function (building, building_index) { - var building_device_amount = backfill_building_device_amount.filter(x => x.building_tag == building.guid)[0]; + var building_device_amount = backfill_building_device_amount.filter(x => x.building_tag == building.tag)[0]; - @*html += `
+ @*html += `
- +
`;*@ - html += `
+ html += `
- +
`; }); @@ -932,7 +932,7 @@ else { var html = ""; temp_all_building.forEach(function (building, building_index) { - html += ''; + html += ''; }); $('#building').append(html); @@ -966,7 +966,7 @@ all_device_group.forEach(function (disaster, disaster_index) { if (SelectedFilter.disasters.findIndex(x => x == disaster.value) > -1) { //抓取已選擇的防災類型的棟別內容 disaster.groupBuildings.forEach(function (building, building_index) { - if (building.guid == SelectedFilter.building_tag) { //抓取選擇棟別的底下樓層 + if (building.tag == SelectedFilter.building_tag) { //抓取選擇棟別的底下樓層 building.groupFloors.forEach(function (floor, floor_index) { if (temp_all_floor.findIndex(x => x.guid == floor.guid) < 0) { //表示未加入,需加入 temp_all_floor.push(floor); @@ -1037,7 +1037,7 @@ all_device_group.forEach(function (disaster, disaster_index) { if (SelectedFilter.disasters.findIndex(x => x == disaster.value) > -1) { //抓取選擇防災類型的底下棟別 disaster.groupBuildings.forEach(function (building, building_index) { - if (building.guid == SelectedFilter.building_tag) { //抓取選擇棟別的底下樓層 + if (building.tag == SelectedFilter.building_tag) { //抓取選擇棟別的底下樓層 building.groupFloors.forEach(function (floor, floor_index) { if (SelectedFilter.floor_guids.findIndex(x => x == floor.guid) > -1) { //抓取選擇樓層的底下大類 floor.groupLayer2s.forEach(function (layer2, layer2_index) { @@ -1128,7 +1128,7 @@ all_device_group.forEach(function (disaster, disaster_index) { if (SelectedFilter.disasters.findIndex(x => x == disaster.value) > -1) { //抓取選擇防災類型的底下棟別 disaster.groupBuildings.forEach(function (building, building_index) { - if (building.guid == SelectedFilter.building_tag) { //抓取選擇棟別的底下樓層 + if (building.tag == SelectedFilter.building_tag) { //抓取選擇棟別的底下樓層 building.groupFloors.forEach(function (floor, floor_index) { if (SelectedFilter.floor_guids.findIndex(x => x == floor.guid) > -1) { //抓取選擇樓層的底下大類 floor.groupLayer2s.forEach(function (layer2, layer2_index) { diff --git a/FrontendWebApi/Views/EmergencyRecord/Index.cshtml b/FrontendWebApi/Views/EmergencyRecord/Index.cshtml index c22edb2..da8cc75 100644 --- a/FrontendWebApi/Views/EmergencyRecord/Index.cshtml +++ b/FrontendWebApi/Views/EmergencyRecord/Index.cshtml @@ -192,7 +192,7 @@ $(row).attr('device', data.device_name); }, "ajax": { - "url": "/EmergencyRecord/EmergencyRecordTable", + "url": "/api/EmergencyRecord/EmergencyRecordTable", "type": "POST", "data": function (d) { d.selectaDisaster = SelectaDisaster, @@ -205,7 +205,7 @@ toast_error(rel.msg); return; } - data = rel.data.data; + data = rel.data; if (data == null || data.length == 0) { this.data = []; @@ -252,7 +252,7 @@ $(row).attr('guid', data.emergency_item_guid); }, "ajax": { - "url": "/EmergencyRecord/EmergencyItemTable", + "url": "/api/EmergencyRecord/EmergencyItemTable", "type": "POST", "data": function (d) { d.event_guid = SelectEvent @@ -262,7 +262,7 @@ toast_error(rel.msg); return; } - data = rel.data.data; + data = rel.data; if (data == null || data.length == 0) { this.data = []; @@ -320,7 +320,7 @@ //取得所有棟別 function GetBuild() { - var url = "/EmergencyRecord/BuildInfoList"; + var url = "/api/EmergencyRecord/BuildInfoList"; var send_data = {}; $.post(url, send_data, function (rel) { if (rel.code != "0000") { diff --git a/FrontendWebApi/Views/RescueDevice/AED.cshtml b/FrontendWebApi/Views/RescueDevice/AED.cshtml index 38b5643..7b5da75 100644 --- a/FrontendWebApi/Views/RescueDevice/AED.cshtml +++ b/FrontendWebApi/Views/RescueDevice/AED.cshtml @@ -253,7 +253,17 @@ kind: 1 }; var url = "/RescueDevice/ExportExcel"; - window.location = "/RescueDevice/ExportExcel?post=" + JSON.stringify(send_data); + $.ajax({ + method: "POST", + xhrFields: { responseType: "blob" }, + headers: { "Authorization": "Bearer " + localStorage.getItem('JWT-Authorization') }, + url: "/RescueDevice/ExportExcel", + data: { "post": JSON.stringify(send_data) }, + success: (res, text, xhr) => { + download(xhr, res); + } + }) + //window.location = "/RescueDevice/ExportExcel?post=" + JSON.stringify(send_data); return; } diff --git a/FrontendWebApi/Views/RescueDevice/FireExtinguisher.cshtml b/FrontendWebApi/Views/RescueDevice/FireExtinguisher.cshtml index 90220eb..0522ce3 100644 --- a/FrontendWebApi/Views/RescueDevice/FireExtinguisher.cshtml +++ b/FrontendWebApi/Views/RescueDevice/FireExtinguisher.cshtml @@ -253,8 +253,20 @@ kind: 0 }; var url = "/RescueDevice/ExportExcel"; - window.location = "/RescueDevice/ExportExcel?post=" + JSON.stringify(send_data); + $.ajax({ + method:"POST", + xhrFields:{responseType:"blob"}, + headers:{"Authorization":"Bearer " + localStorage.getItem('JWT-Authorization')}, + url: "/RescueDevice/ExportExcel", + data:{"post":JSON.stringify(send_data)}, + success:(res,text,xhr) => { + download(xhr,res); + } + }) return; } + + + } \ No newline at end of file diff --git a/FrontendWebApi/wwwroot/js/site.js b/FrontendWebApi/wwwroot/js/site.js index 5d6e6b5..180bcd2 100644 --- a/FrontendWebApi/wwwroot/js/site.js +++ b/FrontendWebApi/wwwroot/js/site.js @@ -54,7 +54,7 @@ $(function () { "Please check your input." ); - + }) //#region 個人資訊表單驗證 @@ -228,6 +228,36 @@ function SaveSpinner(status) { //1:Spinner 0:還原儲存 } } +/** + * 下載檔案 + */ +function download(res, blob, filename, fetchOption, callback = null) { + // 擷取回傳 header > content-disposition (後端定義檔案名稱) + let disposition = res.getResponseHeader("Content-Disposition"); + let sDowName = ""; + if (disposition) { + // 解析出名稱 + sDowName = disposition.split(/filename\*=(?:utf-8'')?(.*)/gi)[1]; + if (sDowName.toLowerCase().startsWith("utf-8''")) + sDowName = decodeURIComponent(sDowName.replace(/utf-8''/i, "")); + else sDowName = sDowName.replace(/['"]/g, ""); + sDowName = decodeURIComponent(sDowName); + } + // 隱形a標籤 + const a = document.createElement("a"); + let href = URL.createObjectURL(blob); + if (href) { + a.href = href; + a.download = filename || sDowName || ""; + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + callback ? callback() : ""; + return true; + } else { + return false; + } +} $(document).ready(function () { - + }); From 9b639ae44dcc331859b5c24a888725534a4a1590 Mon Sep 17 00:00:00 2001 From: dev02 Date: Mon, 22 May 2023 12:22:34 +0800 Subject: [PATCH 14/19] =?UTF-8?q?[=E5=BE=8C=E7=AB=AF]=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E7=B7=8A=E6=80=A5=E6=87=89=E8=AE=8Aapi=20alarmRecord?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApiControllers/AlarmRecordController.cs | 78 +++++++++---------- FrontendWebApi/Models/AlarmRecord.cs | 16 ++-- 2 files changed, 47 insertions(+), 47 deletions(-) diff --git a/FrontendWebApi/ApiControllers/AlarmRecordController.cs b/FrontendWebApi/ApiControllers/AlarmRecordController.cs index 5ef95d6..033a8ca 100644 --- a/FrontendWebApi/ApiControllers/AlarmRecordController.cs +++ b/FrontendWebApi/ApiControllers/AlarmRecordController.cs @@ -20,7 +20,7 @@ namespace FrontendWebApi.ApiControllers public class AlarmRecordController : MyBaseApiController { private readonly IFrontendRepository frontendRepository; - + public AlarmRecordController ( IFrontendRepository frontendRepository @@ -47,41 +47,41 @@ namespace FrontendWebApi.ApiControllers try { var sqlBuildingMain = $@"SELECT - b.building_guid, + b.building_tag, b.full_name AS building_name, - ms.main_system_guid, - ms.full_name AS main_system_name + v1.system_value, + v1.system_key AS main_system_name FROM building_menu bm INNER JOIN ( SELECT - ap.building_guid, ap.ShowView + ap.building_tag, ap.ShowView FROM role_auth ra JOIN auth_page ap ON ra.AuthCode = ap.AuthCode - JOIN userinfo u ON u.role_guid = ra.role_guid WHERE u.account = @Account - AND ap.building_guid IS NOT NULL - ) ap ON bm.building_guid = ap.building_guid AND bm.sub_system_guid = ap.ShowView - LEFT JOIN building b ON bm.building_guid = b.building_guid - LEFT JOIN main_system ms ON bm.main_system_guid = ms.main_system_guid - GROUP BY bm.building_guid, bm.main_system_guid - ORDER BY b.priority, ms.priority"; + JOIN userinfo u ON u.role_guid = ra.role_guid WHERE u.account = 'Bajascript' + AND ap.building_tag IS NOT NULL + ) ap ON bm.building_tag = ap.building_tag + LEFT JOIN building b ON bm.building_tag = b.building_tag + left join variable v2 on ap.ShowView = v2.id and v2.deleted = 0 + left join variable v1 on v2.system_parent_id = v1.id + GROUP BY b.building_tag, b.full_name, v1.system_value, v1.system_key"; var alarmRecordPanelRawDatas = await frontendRepository.GetAllAsync(sqlBuildingMain, new { Account = account }); List alarmRecordPanels = new List(); - var alarmRecordPanelRawDatas_GroupBy = alarmRecordPanelRawDatas.GroupBy(x => x.building_guid); + var alarmRecordPanelRawDatas_GroupBy = alarmRecordPanelRawDatas.GroupBy(x => x.building_tag); foreach (var building in alarmRecordPanelRawDatas_GroupBy) { AlarmRecordPanel alarmRecordPanel = new AlarmRecordPanel(); - alarmRecordPanel.building_guid = building.Key; + alarmRecordPanel.building_tag = building.Key; alarmRecordPanel.building_name = building.First().building_name; alarmRecordPanel.mainSystemPanels = new List(); foreach (var tempData in building) { MainSystemPanel mainSystemPanel = new MainSystemPanel(); - mainSystemPanel.main_system_guid = tempData.main_system_guid; - mainSystemPanel.main_system_name = tempData.main_system_name; + mainSystemPanel.system_value = tempData.system_value; + mainSystemPanel.system_key = tempData.system_key; alarmRecordPanel.mainSystemPanels.Add(mainSystemPanel); } @@ -115,31 +115,31 @@ namespace FrontendWebApi.ApiControllers try { var sql = $@"SELECT - temp_path.source AS alarm_path, - temp_msg.source_msg AS msgText, - from_unixtime(record.timestamp/1000,'%Y-%m-%d %H:%i:%s') alarm_timestamp, - record.priority, - CASE WHEN record.normalTime > 0 THEN from_unixtime(record.normalTime/1000,'%Y-%m-%d %H:%i:%s') - ELSE NULL - END AS normal_timestamp, - record.sourceState AS ackState, - class.alarmclass AS alarm_className, - record.userAccount - - FROM alarmorion_orionalarmrecord record + temp_path.source AS alarm_path, + temp_msg.source_msg AS msgText, + from_unixtime(record.timestamp/1000,'%Y-%m-%d %H:%i:%s') alarm_timestamp, + record.priority, + CASE WHEN record.normalTime > 0 THEN from_unixtime(record.normalTime/1000,'%Y-%m-%d %H:%i:%s') + ELSE NULL + END AS normal_timestamp, + record.sourceState AS ackState, + class.alarmclass AS alarm_className, + record.userAccount + + FROM alarmOrion_OrionAlarmRecord record JOIN ( - SELECT sourceorder.* ,temp_source.source - FROM alarmorion_orionalarmsourceorder sourceorder - JOIN alarmorion_orionalarmsource temp_source ON sourceorder.alarmSource = temp_source.id + SELECT sourceorder.* ,temp_source.source + FROM alarmOrion_OrionAlarmSourceOrder sourceorder + JOIN alarmOrion_OrionAlarmSource temp_source ON sourceorder.alarmSource = temp_source.id ) temp_path ON record.id = temp_path.alarm JOIN( - SELECT - val.alarm, - val.value AS source_msg - FROM alarmorion_orionalarmfacetvalue val - JOIN alarmorion_orionalarmfacetname nam ON val.facetName = nam.id AND nam.facetName = 'msgText' + SELECT + val.alarm, + val.value AS source_msg + FROM alarmOrion_OrionAlarmFacetValue val + JOIN alarmOrion_OrionAlarmFacetName nam ON val.facetName = nam.id AND nam.facetName = 'msgText' ) temp_msg ON record.id = temp_msg.alarm - JOIN alarmorion_orionalarmclass class ON record.alarmClass = class.id + JOIN alarmOrion_OrionAlarmClass class ON record.alarmClass = class.id WHERE from_unixtime(record.timestamp/1000,'%Y-%m-%d %H:%i:%s') BETWEEN @StartTimestamp AND @EndTimeStamp"; if (post.IsSolve != 0) @@ -183,8 +183,8 @@ namespace FrontendWebApi.ApiControllers var sql_device = $@"SELECT * FROM device d WHERE d.deleted = 0 - AND d.building_guid = @building_guid - AND d.main_system_guid IN @main_system_guids"; + AND d.device_building_tag = @building_tag + AND d.device_system_tag IN @main_system_tag"; var devices = await frontendRepository.GetAllAsync(sql_device, post); diff --git a/FrontendWebApi/Models/AlarmRecord.cs b/FrontendWebApi/Models/AlarmRecord.cs index b00e0f5..49dd2e1 100644 --- a/FrontendWebApi/Models/AlarmRecord.cs +++ b/FrontendWebApi/Models/AlarmRecord.cs @@ -8,23 +8,23 @@ namespace FrontendWebApi.Models { public class AlarmRecordPanelRawData { - public string building_guid { get; set; } + public string building_tag { get; set; } public string building_name { get; set; } - public string main_system_guid { get; set; } - public string main_system_name { get; set; } + public string system_key { get; set; } + public string system_value { get; set; } } public class AlarmRecordPanel { - public string building_guid { get; set; } + public string building_tag { get; set; } public string building_name { get; set; } public List mainSystemPanels { get; set; } } public class MainSystemPanel { - public string main_system_guid { get; set; } - public string main_system_name { get; set; } + public string system_key { get; set; } + public string system_value { get; set; } } public class AlarmRecord @@ -52,8 +52,8 @@ namespace FrontendWebApi.Models { public string StartTimestamp { get; set; } public string EndTimestamp { get; set; } - public string Building_guid { get; set; } - public List Main_system_guids { get; set; } + public string Building_tag { get; set; } + public List Main_system_tag { get; set; } public byte IsSolve { get;set;} public byte IsAck { get;set;} } From 902616600471687eb233adb683b0fc1e36bfe04f Mon Sep 17 00:00:00 2001 From: dev02 Date: Mon, 22 May 2023 15:24:16 +0800 Subject: [PATCH 15/19] =?UTF-8?q?[=E5=BE=8C=E7=AB=AF]=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?getAlarmRecordFilterPanel=20api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FrontendWebApi/ApiControllers/AlarmRecordController.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/FrontendWebApi/ApiControllers/AlarmRecordController.cs b/FrontendWebApi/ApiControllers/AlarmRecordController.cs index 033a8ca..5daf8be 100644 --- a/FrontendWebApi/ApiControllers/AlarmRecordController.cs +++ b/FrontendWebApi/ApiControllers/AlarmRecordController.cs @@ -50,14 +50,14 @@ namespace FrontendWebApi.ApiControllers b.building_tag, b.full_name AS building_name, v1.system_value, - v1.system_key AS main_system_name + v1.system_key FROM building_menu bm INNER JOIN ( SELECT ap.building_tag, ap.ShowView FROM role_auth ra JOIN auth_page ap ON ra.AuthCode = ap.AuthCode - JOIN userinfo u ON u.role_guid = ra.role_guid WHERE u.account = 'Bajascript' + JOIN userinfo u ON u.role_guid = ra.role_guid WHERE u.account = @Account AND ap.building_tag IS NOT NULL ) ap ON bm.building_tag = ap.building_tag LEFT JOIN building b ON bm.building_tag = b.building_tag From 86548b7fb6e7a23e20491cb5934c407c47836d79 Mon Sep 17 00:00:00 2001 From: dev02 Date: Mon, 22 May 2023 15:37:36 +0800 Subject: [PATCH 16/19] =?UTF-8?q?[=E5=BE=8C=E7=AB=AF]=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?device=20getAlarm?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FrontendWebApi/ApiControllers/DeviceManageController.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/FrontendWebApi/ApiControllers/DeviceManageController.cs b/FrontendWebApi/ApiControllers/DeviceManageController.cs index 0dc7b34..8134147 100644 --- a/FrontendWebApi/ApiControllers/DeviceManageController.cs +++ b/FrontendWebApi/ApiControllers/DeviceManageController.cs @@ -618,12 +618,12 @@ namespace FrontendWebApi.ApiControllers var device_amount_sql = $@"SELECT - d.building_guid, + d.device_building_tag, COUNT(*) AS device_amount FROM device d WHERE d.deleted = 0 AND d.device_number IN @devices - GROUP BY d.building_guid"; + GROUP BY d.device_building_tag"; alarmObj.buildingAlarmDeviceAmount = await frontendRepository.GetAllAsync(device_amount_sql, new { devices = alarmObj.alarmorion.Select(x => x.device_number).ToList() }); apiResult.Data = alarmObj; From a5bcf2e8fbaf16e1d64196851e1c553a6621a89e Mon Sep 17 00:00:00 2001 From: dev01 Date: Mon, 22 May 2023 16:29:07 +0800 Subject: [PATCH 17/19] =?UTF-8?q?[=E7=B7=8A=E6=80=A5=E6=87=89=E8=AE=8A]=20?= =?UTF-8?q?=E8=A8=AD=E5=82=99=E7=B8=BD=E6=94=AC=20Filter=20Panel=20?= =?UTF-8?q?=E5=89=8D=E7=AB=AF=E7=A8=8B=E5=BA=8F=E5=84=AA=E5=8C=96=E5=8F=8A?= =?UTF-8?q?=E8=AA=BF=E6=95=B4=20|=20=E7=B7=8A=E6=80=A5=E6=87=89=E8=AE=8A?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E9=A0=81=E9=9D=A2=E7=9B=B4=E6=8E=A5=E5=B0=8E?= =?UTF-8?q?=E9=80=B2=E8=A8=AD=E5=82=99=E7=B8=BD=E8=A6=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Views/EmergencyDeviceMenu/Index.cshtml | 46 +++++++++++-------- FrontendWebApi/Views/Login/Index.cshtml | 2 +- 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/FrontendWebApi/Views/EmergencyDeviceMenu/Index.cshtml b/FrontendWebApi/Views/EmergencyDeviceMenu/Index.cshtml index ac07ab6..3a79bc3 100644 --- a/FrontendWebApi/Views/EmergencyDeviceMenu/Index.cshtml +++ b/FrontendWebApi/Views/EmergencyDeviceMenu/Index.cshtml @@ -224,7 +224,7 @@ *@