From c969c24469689a763f36f7bcabbc4fcb891a5411 Mon Sep 17 00:00:00 2001 From: dev02 Date: Wed, 7 Jun 2023 16:45:00 +0800 Subject: [PATCH 1/2] =?UTF-8?q?[=E5=90=8E=E5=8F=B0]=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=8E=92=E7=A8=8B,=20=E8=B3=87=E6=96=99=E5=B0=8D=E6=AF=94?= =?UTF-8?q?=E9=8C=AF=E8=AA=A4,=20json=E5=A2=9E=E5=8A=A0mcut=E8=B3=87?= =?UTF-8?q?=E6=96=99=E5=BA=AB=E9=80=A3=E7=B6=AB=20[=E5=89=8D=E5=8F=B0]=20?= =?UTF-8?q?=E5=BE=8C=E7=AB=AF=E4=BF=AE=E6=94=B9emergencydevice=20api,=20em?= =?UTF-8?q?ergencydevice=20model,=20json=E5=A2=9E=E5=8A=A0mcut=E8=B3=87?= =?UTF-8?q?=E6=96=99=E5=BA=AB=E9=80=A3=E7=B6=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Quartz/Jobs/ArchiveElectricMeterDayJob.cs | 43 ++++++++++--------- .../appsettings.Development.json | 3 +- BackendWorkerService/appsettings.json | 3 +- .../EmergencyDeviceController.cs | 22 +++++++--- FrontendWebApi/Models/EmergencyDevice.cs | 2 +- FrontendWebApi/appsettings.Development.json | 4 +- 6 files changed, 46 insertions(+), 31 deletions(-) diff --git a/BackendWorkerService/Quartz/Jobs/ArchiveElectricMeterDayJob.cs b/BackendWorkerService/Quartz/Jobs/ArchiveElectricMeterDayJob.cs index cdfeb09..7874268 100644 --- a/BackendWorkerService/Quartz/Jobs/ArchiveElectricMeterDayJob.cs +++ b/BackendWorkerService/Quartz/Jobs/ArchiveElectricMeterDayJob.cs @@ -87,12 +87,15 @@ namespace BackendWorkerService.Quartz.Jobs { foreach (var point in electricPoints) { - DeviceNumberPoint deviceNumberPoint = new DeviceNumberPoint(); - deviceNumberPoint.DeviceNumber = electricMeter.Device_number; - deviceNumberPoint.Point = point.points; - deviceNumberPoint.FullDeviceNumberPoint = string.Format("{0}_{1}", electricMeter.Device_number, point.points); + if (electricMeter.device_building_tag == point.device_building_tag) + { + DeviceNumberPoint deviceNumberPoint = new DeviceNumberPoint(); + deviceNumberPoint.DeviceNumber = electricMeter.Device_number; + deviceNumberPoint.Point = point.points; + deviceNumberPoint.FullDeviceNumberPoint = string.Format("{0}_{1}", electricMeter.Device_number, point.points); - electricDeviceNumberPoints.Add(deviceNumberPoint); + electricDeviceNumberPoints.Add(deviceNumberPoint); + } } } #endregion 組合出所有電錶設備點位 @@ -102,12 +105,15 @@ namespace BackendWorkerService.Quartz.Jobs { foreach (var point in waterPoints) { - DeviceNumberPoint deviceNumberPoint = new DeviceNumberPoint(); - deviceNumberPoint.DeviceNumber = waterMeter.Device_number; - deviceNumberPoint.Point = point.points; - deviceNumberPoint.FullDeviceNumberPoint = string.Format("{0}_{1}", waterMeter.Device_number, point.points); + if (waterMeter.device_building_tag == point.device_building_tag) + { + DeviceNumberPoint deviceNumberPoint = new DeviceNumberPoint(); + deviceNumberPoint.DeviceNumber = waterMeter.Device_number; + deviceNumberPoint.Point = point.points; + deviceNumberPoint.FullDeviceNumberPoint = string.Format("{0}_{1}", waterMeter.Device_number, point.points); - waterDeviceNumberPoints.Add(deviceNumberPoint); + waterDeviceNumberPoints.Add(deviceNumberPoint); + } } } #endregion 組合出所有電錶設備點位 @@ -159,7 +165,6 @@ namespace BackendWorkerService.Quartz.Jobs archiveRequest.Method = "POST"; archiveRequest.Headers.Add("Authorization", "Basic " + encoded); archiveRequest.PreAuthenticate = true; - archiveRequest.Timeout = 3000; byte[] byteArray = Encoding.UTF8.GetBytes(historyQueryFilter); using (Stream reqStream = archiveRequest.GetRequestStream()) @@ -171,7 +176,7 @@ namespace BackendWorkerService.Quartz.Jobs archiveResponseContent = new StreamReader(archiveResponse.GetResponseStream()).ReadToEnd(); archiveResponse.Dispose(); archiveResponse.Close(); - + xmlDocument.LoadXml(archiveResponseContent); archiveJson = JsonConvert.SerializeXmlNode(xmlDocument); archiveJsonResult = (JObject)JsonConvert.DeserializeObject(archiveJson); @@ -217,7 +222,7 @@ namespace BackendWorkerService.Quartz.Jobs archiveRequest.Method = "POST"; archiveRequest.Headers.Add("Authorization", "Basic " + encoded); archiveRequest.PreAuthenticate = true; - archiveRequest.Timeout = 3000; + byte[] byteArray = Encoding.UTF8.GetBytes(historyQueryFilter); using (Stream reqStream = archiveRequest.GetRequestStream()) @@ -628,7 +633,7 @@ namespace BackendWorkerService.Quartz.Jobs archiveRequest.Method = "POST"; archiveRequest.Headers.Add("Authorization", "Basic " + encoded); archiveRequest.PreAuthenticate = true; - archiveRequest.Timeout = 3000; + byte[] byteArray = Encoding.UTF8.GetBytes(historyQueryFilter); using (Stream reqStream = archiveRequest.GetRequestStream()) @@ -685,8 +690,7 @@ namespace BackendWorkerService.Quartz.Jobs archiveRequest.Method = "POST"; archiveRequest.Headers.Add("Authorization", "Basic " + encoded); archiveRequest.PreAuthenticate = true; - archiveRequest.Timeout = 3000; - + byte[] byteArray = Encoding.UTF8.GetBytes(historyQueryFilter); using (Stream reqStream = archiveRequest.GetRequestStream()) { @@ -994,14 +998,13 @@ namespace BackendWorkerService.Quartz.Jobs archiveRequest.Method = "POST"; archiveRequest.Headers.Add("Authorization", "Basic " + encoded); archiveRequest.PreAuthenticate = true; - archiveRequest.Timeout = 3000; - + byte[] byteArray = Encoding.UTF8.GetBytes(historyQueryFilter); using (Stream reqStream = archiveRequest.GetRequestStream()) { reqStream.Write(byteArray, 0, byteArray.Length); } - + archiveResponse = (HttpWebResponse)archiveRequest.GetResponse(); archiveResponseContent = new StreamReader(archiveResponse.GetResponseStream()).ReadToEnd(); archiveResponse.Dispose(); @@ -1051,7 +1054,7 @@ namespace BackendWorkerService.Quartz.Jobs archiveRequest.Method = "POST"; archiveRequest.Headers.Add("Authorization", "Basic " + encoded); archiveRequest.PreAuthenticate = true; - archiveRequest.Timeout = 3000; + byte[] byteArray = Encoding.UTF8.GetBytes(historyQueryFilter); using (Stream reqStream = archiveRequest.GetRequestStream()) diff --git a/BackendWorkerService/appsettings.Development.json b/BackendWorkerService/appsettings.Development.json index 8620376..b4569f6 100644 --- a/BackendWorkerService/appsettings.Development.json +++ b/BackendWorkerService/appsettings.Development.json @@ -23,8 +23,9 @@ "Port": "js2LutKe+rdjzdxMPQUrvQ==", //"Database": "VJB2XC+lAtzuHObDGMVOAA==", //30 //"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp - "Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome + //"Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome //"Database": "siTUcDaC/g2yGTMFWD72Kg==", //tpe_dome_hotel + "Database": "Rq7Gn4x6LwBvVtl7GY8LbA==", //mcut "Root": "SzdxEgaJJ7tcTCrUl2zKsA==", "Password": "FVAPxztxpY4gJJKQ/se4bQ==" }, diff --git a/BackendWorkerService/appsettings.json b/BackendWorkerService/appsettings.json index 8620376..b4569f6 100644 --- a/BackendWorkerService/appsettings.json +++ b/BackendWorkerService/appsettings.json @@ -23,8 +23,9 @@ "Port": "js2LutKe+rdjzdxMPQUrvQ==", //"Database": "VJB2XC+lAtzuHObDGMVOAA==", //30 //"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp - "Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome + //"Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome //"Database": "siTUcDaC/g2yGTMFWD72Kg==", //tpe_dome_hotel + "Database": "Rq7Gn4x6LwBvVtl7GY8LbA==", //mcut "Root": "SzdxEgaJJ7tcTCrUl2zKsA==", "Password": "FVAPxztxpY4gJJKQ/se4bQ==" }, diff --git a/FrontendWebApi/ApiControllers/EmergencyDeviceController.cs b/FrontendWebApi/ApiControllers/EmergencyDeviceController.cs index c294721..0ba06f1 100644 --- a/FrontendWebApi/ApiControllers/EmergencyDeviceController.cs +++ b/FrontendWebApi/ApiControllers/EmergencyDeviceController.cs @@ -108,7 +108,7 @@ namespace FrontendWebApi.ApiControllers [HttpPost] [Route("api/EmergencyDevice")] - public async Task>>> EmergencyDevice(selectdevice selectdevice) + public async Task>>> EmergencyDevice([FromBody] selectdevice selectdevice) { ApiResult> apiResult = new ApiResult>(); if (!jwtlife) @@ -120,6 +120,16 @@ namespace FrontendWebApi.ApiControllers try { + string deviceQue = ""; + string disasQue = ""; + if (selectdevice.selectbuilding != null && selectdevice.selectbuilding.Count > 0) + deviceQue += $" AND d.device_building_tag in @building_tag "; + if (selectdevice.select_Floors != null && selectdevice.select_Floors.Count > 0) + deviceQue += $" AND d.device_floor_tag in @floor "; + if (selectdevice.select_Layer3 != null && selectdevice.select_Layer3.Count > 0) + deviceQue += $" AND d.device_name_tag IN @layer3 "; + if (selectdevice.select_disasters != null && selectdevice.select_disasters.Count > 0) + disasQue = " where dd.device_system_value IN @disasters "; var sqlString = @$"select d.device_guid, @@ -140,9 +150,8 @@ namespace FrontendWebApi.ApiControllers (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 + {deviceQue} + ) d left join floor on floor.full_name = d.device_floor_tag and floor.building_tag = d.device_building_tag left join ( SELECT @@ -158,10 +167,11 @@ namespace FrontendWebApi.ApiControllers 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.device_building_tag = b.building_tag - where dd.device_system_value IN @disasters + {disasQue} ORDER BY d.device_number "; - Variable = await backendRepository.GetAllAsync(sqlString, new { disasters= selectdevice.select_disasters, floor = selectdevice.select_Floors, layer3 = selectdevice.select_Layer3 }); + Variable = await backendRepository.GetAllAsync(sqlString, new { disasters= selectdevice.select_disasters, building_tag = selectdevice.selectbuilding, + floor = selectdevice.select_Floors, layer3 = selectdevice.select_Layer3 }); apiResult.Code = "0000"; apiResult.Data = Variable; diff --git a/FrontendWebApi/Models/EmergencyDevice.cs b/FrontendWebApi/Models/EmergencyDevice.cs index 9d72d50..fe5c076 100644 --- a/FrontendWebApi/Models/EmergencyDevice.cs +++ b/FrontendWebApi/Models/EmergencyDevice.cs @@ -106,7 +106,7 @@ namespace FrontendWebApi.Models public class selectdevice { public List select_disasters { get; set; } - public string selectbuilding { get; set; } + public List selectbuilding { get; set; } public List select_Floors { get; set; } public List select_Layer3 { get; set; } } diff --git a/FrontendWebApi/appsettings.Development.json b/FrontendWebApi/appsettings.Development.json index b87a385..f976969 100644 --- a/FrontendWebApi/appsettings.Development.json +++ b/FrontendWebApi/appsettings.Development.json @@ -18,10 +18,10 @@ "Port": "js2LutKe+rdjzdxMPQUrvQ==", //"Database": "VJB2XC+lAtzuHObDGMVOAA==", //30 //"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp - //"Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome + "Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome //"Database": "siTUcDaC/g2yGTMFWD72Kg==", //tpe_dome_hotel //"Database": "iuaY0h0+TWkir44/eZLDqw==", //tpe_dome_office - "Database": "Rq7Gn4x6LwBvVtl7GY8LbA==", //MCUT + //"Database": "Rq7Gn4x6LwBvVtl7GY8LbA==", //MCUT "Root": "SzdxEgaJJ7tcTCrUl2zKsA==", "Password": "FVAPxztxpY4gJJKQ/se4bQ==" } From b110151c8e6a2311ccb083a260898daa65f72628 Mon Sep 17 00:00:00 2001 From: dev02 Date: Wed, 7 Jun 2023 16:54:16 +0800 Subject: [PATCH 2/2] =?UTF-8?q?[=E5=BE=8C=E5=8F=B0]=20=E4=BF=AE=E6=94=B9bu?= =?UTF-8?q?ildinfo=20api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Backend/Controllers/BuildInfoController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Backend/Controllers/BuildInfoController.cs b/Backend/Controllers/BuildInfoController.cs index 24faf5b..c03565a 100644 --- a/Backend/Controllers/BuildInfoController.cs +++ b/Backend/Controllers/BuildInfoController.cs @@ -429,7 +429,7 @@ namespace Backend.Controllers try { - var sqlString = @$"SELECT A.floor_guid, A.full_name, InitMapName + '.svg' AS 'initMapName', A.priority, A.created_at + var sqlString = @$"SELECT A.floor_guid, A.full_name, CONCAT(InitMapName, '.svg') AS 'initMapName', A.priority, A.created_at FROM floor A WHERE deleted = @deleted AND A.building_tag = @building_tag