[WebApi]緊急應變功能修整

This commit is contained in:
張家睿 2024-05-31 10:55:48 +08:00
parent 687b78984e
commit 877055440c
8 changed files with 259 additions and 146 deletions

View File

@ -1,13 +1,17 @@
using FrontendWebApi.Models; using FrontendWebApi.Models;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Newtonsoft.Json; using Newtonsoft.Json;
using Repository.BackendRepository.Interface; using Repository.BackendRepository.Interface;
using Repository.FrontendRepository.Interface; using Repository.FrontendRepository.Interface;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data.SqlTypes;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace FrontendWebApi.ApiControllers namespace FrontendWebApi.ApiControllers
@ -27,6 +31,51 @@ namespace FrontendWebApi.ApiControllers
this.frontendRepository = frontendRepository; this.frontendRepository = frontendRepository;
} }
[HttpPost("api/Send")]
public async Task<ApiResult<List<Variable>>> SendMessageAsync(string message)
{
ApiResult<List<Variable>> apiResult = new ApiResult<List<Variable>>();
var sqlString = "SELECT * from variable WHERE system_type = 'TcpClient'";
var variables = await frontendRepository.GetAllAsync<Variable>(sqlString);
var serverAddress = variables.Where(x => x.System_key == "Address").First().system_value;
var serverPort = int.Parse(variables.Where(x => x.System_key == "Port").First().system_value);
try
{
using (var client = new TcpClient())
{
await client.ConnectAsync(serverAddress, serverPort);
using (var stream = client.GetStream())
{
var data = Encoding.UTF8.GetBytes(message);
await stream.WriteAsync(data, 0, data.Length);
//data = new byte[256];
//var bytes = await stream.ReadAsync(data, 0, data.Length);
apiResult.Code = "0000";
apiResult.Msg = "傳送指令, " + message;
return apiResult;
}
}
}
catch (SocketException ex)
{
apiResult.Code = "9999";
apiResult.Msg = ex.Message;
Logger.LogError("【" + controllerName + "/" + actionName + "】" + ex.Message);
return apiResult;
}
catch (Exception ex)
{
apiResult.Code = "9999";
apiResult.Msg = ex.Message;
Logger.LogError("【" + controllerName + "/" + actionName + "】" + ex.Message);
return apiResult;
}
}
[HttpPost] [HttpPost]
[Route("api/DisasterList")] [Route("api/DisasterList")]
public async Task<ActionResult<ApiResult<List<KeyValue>>>> DisasterList() public async Task<ActionResult<ApiResult<List<KeyValue>>>> DisasterList()
@ -155,7 +204,7 @@ namespace FrontendWebApi.ApiControllers
WHERE d.deleted = 0 WHERE d.deleted = 0
{deviceQue} {deviceQue}
) d ) d
left join floor on floor.full_name = d.device_floor_tag and floor.building_tag = d.device_building_tag left join floor on floor.full_name = d.device_floor_tag and floor.building_tag = d.device_building_tag and floor.deleted = 0
left join ( left join (
SELECT SELECT
v.*, v.*,

View File

@ -93,7 +93,7 @@ namespace FrontendWebApi.ApiControllers
XDocument xmlDoc = XDocument.Parse(resString); XDocument xmlDoc = XDocument.Parse(resString);
if (xmlDoc?.Root?.Name?.LocalName == "str") if (xmlDoc?.Root?.Name?.LocalName == "str" || xmlDoc?.Root?.Name?.LocalName == "bool")
{ {
result.targetValue = xmlDoc.Root.Attribute("val").Value; result.targetValue = xmlDoc.Root.Attribute("val").Value;
@ -118,7 +118,7 @@ namespace FrontendWebApi.ApiControllers
} }
/// <summary> /// <summary>
/// 取得警戒值 /// 設定警戒值
/// </summary> /// </summary>
/// <param name="post"></param> /// <param name="post"></param>
/// <returns></returns> /// <returns></returns>

View File

@ -8,7 +8,8 @@ namespace FrontendWebApi.Models
{ {
public enum WarningValueType { public enum WarningValueType {
Rain, //降雨 Rain, //降雨
Earthquake //地震 Earthquake , //地震
Infrared //紅外線
} }
public class WarningValueInput { public class WarningValueInput {

View File

@ -616,6 +616,14 @@
} }
} }
], ],
'columnDefs': [
// 隐藏第 7 列("alarm_timestamp" 列)和第 8 列SOP 按钮列)
{
'targets': [7, 8],
'visible': false,
'searchable': false
}
],
'drawCallback': function () { 'drawCallback': function () {
$('#alarm-device-table tbody tr td').css('padding', '5px 8px 5px 8px'); $('#alarm-device-table tbody tr td').css('padding', '5px 8px 5px 8px');
}, },

View File

@ -1,12 +1,12 @@
@{ @{
ViewData["MainNum"] = "4"; ViewData["MainNum"] = "4";
ViewData["SubNum"] = "4"; ViewData["SubNum"] = "4";
ViewData["Title"] = "紀錄查詢"; ViewData["Title"] = "事件查詢";
} }
<ol class="breadcrumb page-breadcrumb"> <ol class="breadcrumb page-breadcrumb">
<li class="breadcrumb-item"><a href="javascript:void(0);">首頁</a></li> <li class="breadcrumb-item"><a href="javascript:void(0);">首頁</a></li>
<li class="breadcrumb-item active">紀錄查詢</li> <li class="breadcrumb-item active">事件查詢</li>
<li class="position-absolute pos-top pos-right d-none d-sm-block"><span class="js-get-date"></span></li> <li class="position-absolute pos-top pos-right d-none d-sm-block"><span class="js-get-date"></span></li>
</ol> </ol>
@ -17,7 +17,7 @@
<div class="panel-content"> <div class="panel-content">
<div class="subheader"> <div class="subheader">
<h1 class="subheader-title"> <h1 class="subheader-title">
<span>紀錄查詢</span> <span>事件查詢</span>
</h1> </h1>
</div> </div>
<div class="row mb-3 d-flex align-items-center px-3 justify-content-between"> <div class="row mb-3 d-flex align-items-center px-3 justify-content-between">
@ -273,11 +273,11 @@
} }
else if (val.finished == 1) else if (val.finished == 1)
{ {
val.type = "完成"; val.finished = "完成";
} }
else else
{ {
val.type = "不執行"; val.finished = "不執行";
} }
}) })
return data; return data;
@ -406,7 +406,10 @@
$(this).parents().find('tr').css('background-color', '#fff'); $(this).parents().find('tr').css('background-color', '#fff');
$(this).css('background-color', '#67B4AC'); $(this).css('background-color', '#67B4AC');
SelectEvent = $(this).attr('guid'); SelectEvent = $(this).attr('guid');
$('#emergencyitem').find('.card-title').html("事件明細" + "-" + $(this).attr('type') + "-" + $(this).attr('device')); var title = "事件明細" + "-" + $(this).attr('type')
if ($(this).attr('device') != undefined) { title += "-" + $(this).attr('device') }
$('#emergencyitem').find('.card-title').html(title);
// $('#emergencyitem').find('.card-title').html("事件明細" + "-" + $(this).attr('type') + "-" + $(this).attr('device'));
EmergencyItemTable.ajax.reload(); EmergencyItemTable.ajax.reload();
$('#emergencyitem').show(); $('#emergencyitem').show();
}) })

View File

@ -74,7 +74,6 @@
</a> </a>
</li> </li>
<li class="nav-title">Navigation Title</li>--> <li class="nav-title">Navigation Title</li>-->
@if (ViewBag.role.Contains("EmergencyDeviceMenuIndex") @if (ViewBag.role.Contains("EmergencyDeviceMenuIndex")
|| ViewBag.role.Contains("EmergencyContactIndex") || ViewBag.role.Contains("EmergencyContactIndex")
|| ViewBag.role.Contains("EmergencyRecordIndex") || ViewBag.role.Contains("EmergencyRecordIndex")
@ -114,41 +113,41 @@
@if (ViewBag.role.Contains("EmergencyRecordIndex")) @if (ViewBag.role.Contains("EmergencyRecordIndex"))
{ {
<li class="@(ViewData["MainNum"] == "4" && ViewData["SubNum"] == "4" ? "active" : "")"> <li class="@(ViewData["MainNum"] == "4" && ViewData["SubNum"] == "4" ? "active" : "")">
<a asp-controller="EmergencyRecord" asp-action="Index" title="紀錄查詢" data-filter-tags="utilities disabled item"> <a asp-controller="EmergencyRecord" asp-action="Index" title="事件查詢" data-filter-tags="utilities disabled item">
<span class="nav-link-text" data-i18n="nav.utilities_disabled_item">紀錄查詢</span> <span class="nav-link-text" data-i18n="nav.utilities_disabled_item">事件查詢</span>
</a> </a>
</li> </li>
} }
@if (ViewBag.role.Contains("RescueDeviceFireExtinguisher")) @*@if (ViewBag.role.Contains("RescueDeviceFireExtinguisher"))
{ {
<li class="@(ViewData["MainNum"] == "4" && ViewData["SubNum"] == "5" ? "active" : "")"> <li class="@(ViewData["MainNum"] == "4" && ViewData["SubNum"] == "5" ? "active" : "")">
<a asp-controller="RescueDevice" asp-action="FireExtinguisher" title="滅火器設定" data-filter-tags="utilities disabled item"> <a asp-controller="RescueDevice" asp-action="FireExtinguisher" title="滅火器設定" data-filter-tags="utilities disabled item">
<span class="nav-link-text" data-i18n="nav.utilities_disabled_item">滅火器設定</span> <span class="nav-link-text" data-i18n="nav.utilities_disabled_item">滅火器設定</span>
</a> </a>
</li> </li>
} }
@if (ViewBag.role.Contains("RescueDeviceAED")) @if (ViewBag.role.Contains("RescueDeviceAED"))
{ {
<li class="@(ViewData["MainNum"] == "4" && ViewData["SubNum"] == "6" ? "active" : "")"> <li class="@(ViewData["MainNum"] == "4" && ViewData["SubNum"] == "6" ? "active" : "")">
<a asp-controller="RescueDevice" asp-action="AED" title="AED裝置設定" data-filter-tags="utilities disabled item"> <a asp-controller="RescueDevice" asp-action="AED" title="AED裝置設定" data-filter-tags="utilities disabled item">
<span class="nav-link-text" data-i18n="nav.utilities_disabled_item">AED裝置設定</span> <span class="nav-link-text" data-i18n="nav.utilities_disabled_item">AED裝置設定</span>
</a> </a>
</li> </li>
} }*@
</ul> </ul>
</li> </li>
} }
@if (ViewBag.role.Contains("WarningValueIndex")) @if (ViewBag.role.Contains("WarningValueIndex"))
{ {
<li class=""> <li class="">
<a href="#" title="警戒值設定" data-filter-tags="category" id="warningValueBtn"> <a href="#" title="警戒值設定" data-filter-tags="category" id="warningValueBtn">
<i class="fal fa-ballot-check"></i> <i class="fal fa-ballot-check"></i>
<span class="nav-link-text" data-i18n="nav.category">警戒值設定</span> <span class="nav-link-text" data-i18n="nav.category">警戒值設定</span>
</a> </a>
</li> </li>
} }
</ul> </ul>
@ -609,33 +608,33 @@
<div> <div>
<a href="@(ViewBag.BackendUrl ?? "#")" target="_blank" id="go-to-setting"><i class="fal fa-cog fs-xxl"></i></a> <a href="@(ViewBag.BackendUrl ?? "#")" target="_blank" id="go-to-setting"><i class="fal fa-cog fs-xxl"></i></a>
@* @*
<a href="#" data-toggle="dropdown" title="drlantern@gotbootstrap.com" class="header-icon d-flex align-items-center justify-content-center ml-2"> <a href="#" data-toggle="dropdown" title="drlantern@gotbootstrap.com" class="header-icon d-flex align-items-center justify-content-center ml-2">
<img src="~/img/demo/avatars/avatar-admin.png" class="profile-image rounded-circle" alt="Dr. Codex Lantern"> <img src="~/img/demo/avatars/avatar-admin.png" class="profile-image rounded-circle" alt="Dr. Codex Lantern">
<!-- you can also add username next to the avatar with the codes below: <!-- you can also add username next to the avatar with the codes below:
<span class="ml-1 mr-1 text-truncate text-truncate-header hidden-xs-down">Me</span> <span class="ml-1 mr-1 text-truncate text-truncate-header hidden-xs-down">Me</span>
<i class="ni ni-chevron-down hidden-xs-down"></i> --> <i class="ni ni-chevron-down hidden-xs-down"></i> -->
</a>*@ </a>*@
@*<div class="dropdown-menu dropdown-menu-animated dropdown-lg"> @*<div class="dropdown-menu dropdown-menu-animated dropdown-lg">
<div class="dropdown-header bg-trans-gradient d-flex flex-row py-4 rounded-top"> <div class="dropdown-header bg-trans-gradient d-flex flex-row py-4 rounded-top">
<div class="d-flex flex-row align-items-center mt-1 mb-1 color-white"> <div class="d-flex flex-row align-items-center mt-1 mb-1 color-white">
<span class="mr-2"> <img src="~/img/demo/avatars/avatar-admin.png" class="rounded-circle profile-image" alt="Dr. Codex Lantern"> </span> <span class="mr-2"> <img src="~/img/demo/avatars/avatar-admin.png" class="rounded-circle profile-image" alt="Dr. Codex Lantern"> </span>
<div class="info-card-text"> <div class="info-card-text">
<div class="fs-lg text-truncate text-truncate-lg">@ViewBag.myUserInfo.Full_name</div> <div class="fs-lg text-truncate text-truncate-lg">@ViewBag.myUserInfo.Full_name</div>
<span class="text-truncate text-truncate-md opacity-80">@ViewBag.myUserInfo.Email</span> <span class="text-truncate text-truncate-md opacity-80">@ViewBag.myUserInfo.Email</span>
</div> </div>
</div> </div>
</div> </div>
<div class="dropdown-divider m-0"></div> <div class="dropdown-divider m-0"></div>
<a href="javascript:void(0);" id="btn-personal-info" class="dropdown-item"> <span data-i18n="drpdwn.settings">個人資料</span> </a> <a href="javascript:void(0);" id="btn-personal-info" class="dropdown-item"> <span data-i18n="drpdwn.settings">個人資料</span> </a>
<a href="javascript:void(0);" id="btn-change-password" class="dropdown-item"> <span data-i18n="drpdwn.settings">密碼修改</span> </a> <a href="javascript:void(0);" id="btn-change-password" class="dropdown-item"> <span data-i18n="drpdwn.settings">密碼修改</span> </a>
<div class="dropdown-divider m-0"></div> <div class="dropdown-divider m-0"></div>
<a href="#" class="dropdown-item" data-action="app-fullscreen"> <span data-i18n="drpdwn.fullscreen">Fullscreen</span> <i class="float-right text-muted fw-n">F11</i> </a> <a href="#" class="dropdown-item" data-action="app-print"> <span data-i18n="drpdwn.print">Print</span> <i class="float-right text-muted fw-n">Ctrl + P</i> </a> <a href="#" class="dropdown-item" data-action="app-fullscreen"> <span data-i18n="drpdwn.fullscreen">Fullscreen</span> <i class="float-right text-muted fw-n">F11</i> </a> <a href="#" class="dropdown-item" data-action="app-print"> <span data-i18n="drpdwn.print">Print</span> <i class="float-right text-muted fw-n">Ctrl + P</i> </a>
<div class="dropdown-divider m-0"></div> <div class="dropdown-divider m-0"></div>
<a class="dropdown-item fw-500 pt-3 pb-3" asp-controller="Login" asp-action="SignOut"> <span data-i18n="drpdwn.page-logout">登出</span> <span class="float-right fw-n">&commat;fic</span> </a> <a class="dropdown-item fw-500 pt-3 pb-3" asp-controller="Login" asp-action="SignOut"> <span data-i18n="drpdwn.page-logout">登出</span> <span class="float-right fw-n">&commat;fic</span> </a>
</div>*@ </div>*@
</div> </div>
</div> </div>
</header> </header>
@ -648,16 +647,16 @@
<!-- BEGIN Page Footer --> <!-- BEGIN Page Footer -->
<footer class="page-footer" role="contentinfo"> <footer class="page-footer" role="contentinfo">
@*<div class="d-flex align-items-center flex-1 text-muted"> @*<div class="d-flex align-items-center flex-1 text-muted">
<span class="hidden-md-down fw-700">2020 © Rage by&nbsp;<a href='https://www.rage.com.tw' class='text-primary fw-500' title='rage.com.tw' target='_blank'>rage.com.tw</a></span> <span class="hidden-md-down fw-700">2020 © Rage by&nbsp;<a href='https://www.rage.com.tw' class='text-primary fw-500' title='rage.com.tw' target='_blank'>rage.com.tw</a></span>
</div> </div>
<div> <div>
<ul class="list-table m-0"> <ul class="list-table m-0">
<li><a href="intel_introduction.html" class="text-secondary fw-700">About</a></li> <li><a href="intel_introduction.html" class="text-secondary fw-700">About</a></li>
<li class="pl-3"><a href="info_app_licensing.html" class="text-secondary fw-700">License</a></li> <li class="pl-3"><a href="info_app_licensing.html" class="text-secondary fw-700">License</a></li>
<li class="pl-3"><a href="info_app_docs.html" class="text-secondary fw-700">Documentation</a></li> <li class="pl-3"><a href="info_app_docs.html" class="text-secondary fw-700">Documentation</a></li>
</ul> </ul>
</div>*@ </div>*@
</footer> </footer>
<!-- END Page Footer --> <!-- END Page Footer -->
<!-- BEGIN Color profile --> <!-- BEGIN Color profile -->
@ -842,10 +841,10 @@
</div> </div>
</div> </div>
<!-- 警戒值設定 --> <!-- 警戒值設定 -->
<div class="modal" tabindex="-1" id="warning-value-modal" role="dialog" data-backdrop="static" data-keyboard="false"> <div class="modal" tabindex="-1" id="warning-value-modal" role="dialog" data-backdrop="static" data-keyboard="false">
<div class="modal-dialog modal-dialog-centered" style="max-width:45%;"> <div class="modal-dialog modal-dialog-centered" style="max-width:45%;">
<div class="modal-content" style="height:600px;"> <div class="modal-content" style="height:700px;">
<div class="modal-header"> <div class="modal-header">
<h5 class="modal-title">警戒值設定</h5> <h5 class="modal-title">警戒值設定</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> <button type="button" class="close" data-dismiss="modal" aria-label="Close">
@ -853,16 +852,16 @@
</button> </button>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<table class="table warning-value-table"> <table class="table warning-value-table">
<tbody> <tbody>
<tr class="disaster-title-bar"> <tr class="disaster-title-bar">
<td rowspan="3" class="disaster-icon"><i class="fa-solid fa-cloud-showers-heavy"></i></td> <td rowspan="3" class="disaster-icon"><i class="fa-solid fa-cloud-showers-heavy"></i></td>
<td class="disaster-title">降雨警戒設定值</td> <td class="disaster-title">降雨警戒設定值</td>
<td class="disaster-value" id="rainCurName">大雨</td> <td class="disaster-value" id="rainCurName">大雨</td>
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td colspan="2">
<div class="form-check form-check-inline"> <div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="rainRadio" id="rain1" value="1"> <input class="form-check-input" type="radio" name="rainRadio" id="rain1" value="1">
<label class="form-check-label" for="rain1">大雨</label> <label class="form-check-label" for="rain1">大雨</label>
@ -872,26 +871,26 @@
<label class="form-check-label" for="rain2">豪雨</label> <label class="form-check-label" for="rain2">豪雨</label>
</div> </div>
<div class="form-check form-check-inline"> <div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="rainRadio" id="rain3" value="3"> <input class="form-check-input" type="radio" name="rainRadio" id="rain3" value="3">
<label class="form-check-label" for="rain3">大豪雨</label> <label class="form-check-label" for="rain3">大豪雨</label>
</div> </div>
<div class="form-check form-check-inline"> <div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="rainRadio" id="rain4" value="4"> <input class="form-check-input" type="radio" name="rainRadio" id="rain4" value="4">
<label class="form-check-label" for="rain4">超大豪雨</label> <label class="form-check-label" for="rain4">超大豪雨</label>
</div> </div>
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2" id="rainDesc">24小時累積雨量達80毫米以上或時雨量達40毫米以上之降雨現象</td> <td colspan="2" id="rainDesc">24小時累積雨量達80毫米以上或時雨量達40毫米以上之降雨現象</td>
</tr> </tr>
<tr class="disaster-title-bar"> <tr class="disaster-title-bar">
<td rowspan="3" class="disaster-icon"><i class="fa-solid fa-house-chimney-crack"></i></td> <td rowspan="3" class="disaster-icon"><i class="fa-solid fa-house-chimney-crack"></i></td>
<td class="disaster-title">地震警戒設定值</td> <td class="disaster-title">地震警戒設定值</td>
<td class="disaster-value" id="eqCurName">7級</td> <td class="disaster-value" id="eqCurName"></td>
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td colspan="2">
<div class="form-check form-check-inline"> <div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="eqRadio" id="eq1" value="3"> <input class="form-check-input" type="radio" name="eqRadio" id="eq1" value="3">
<label class="form-check-label" for="inlineRadio1">3級</label> <label class="form-check-label" for="inlineRadio1">3級</label>
@ -901,27 +900,40 @@
<label class="form-check-label" for="eq2">4級</label> <label class="form-check-label" for="eq2">4級</label>
</div> </div>
<div class="form-check form-check-inline"> <div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="eqRadio" id="eq3" value="5"> <input class="form-check-input" type="radio" name="eqRadio" id="eq3" value="5">
<label class="form-check-label" for="eq3">5級</label> <label class="form-check-label" for="eq3">5級</label>
</div> </div>
<div class="form-check form-check-inline"> <div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="eqRadio" id="eq4" value="6"> <input class="form-check-input" type="radio" name="eqRadio" id="eq4" value="6">
<label class="form-check-label" for="eq4">6級</label> <label class="form-check-label" for="eq4">6級</label>
</div> </div>
<div class="form-check form-check-inline"> <div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="eqRadio" id="eq5" value="7"> <input class="form-check-input" type="radio" name="eqRadio" id="eq5" value="7">
<label class="form-check-label" for="eq5">7級</label> <label class="form-check-label" for="eq5">7級</label>
</div> </div>
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2" id="eqDesc">幾乎所有家俱都大幅移動或翻倒,部分耐震較強建築物可能損壞或倒塌。</td> <td colspan="2" id="eqDesc">幾乎所有家俱都大幅移動或翻倒,部分耐震較強建築物可能損壞或倒塌。</td>
</tr> </tr>
</tbody> <tr class="disaster-title-bar">
</table> <td rowspan="2" class="disaster-icon"><i class="fa-solid fa-bolt"></i></td>
<td class="disaster-title">紅外線抑制</td>
<td class="disaster-value"></td>
</tr>
<tr>
<td colspan="2">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="irCheckbox" name="irCheckbox" value="open">
<label class="form-check-label" for="irCheckbox">開啟</label>
</div>
</td>
</tr>
</tbody>
</table>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button> <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
<button type="button" class="btn btn-primary btn-save" onclick="setWarningValue()">儲存</button> <button type="button" class="btn btn-primary btn-save" onclick="setWarningValue()">儲存</button>
</div> </div>
@ -966,52 +978,52 @@
@RenderSection("Scripts", required: false) @RenderSection("Scripts", required: false)
<script> <script>
function showWarningValueModal(e){ function showWarningValueModal(e) {
$("#warning-value-modal").modal("show"); $("#warning-value-modal").modal("show");
} }
$("body").on("click","#warningValueBtn",showWarningValueModal); $("body").on("click", "#warningValueBtn", showWarningValueModal);
$("body").on("hidden.bs.modal","#warning-value-modal",function() { $("body").on("hidden.bs.modal", "#warning-value-modal", function () {
$("#warningValueIframe").attr("src","#"); $("#warningValueIframe").attr("src", "#");
}); });
$("body").on("shown.bs.modal","#warning-value-modal",function() { $("body").on("shown.bs.modal", "#warning-value-modal", function () {
$("#warningValueIframe").attr("src","@ViewBag.WarningValuePxPath"); $("#warningValueIframe").attr("src", "@ViewBag.WarningValuePxPath");
}); });
$("body").on("show.bs.modal","#warning-value-modal",getWarningValue); $("body").on("show.bs.modal", "#warning-value-modal", getWarningValue);
$("body").on("change","input[name=rainRadio]",onRainRadioChange); $("body").on("change", "input[name=rainRadio]", onRainRadioChange);
$("body").on("change","input[name=eqRadio]",onEqRadioChange); $("body").on("change", "input[name=eqRadio]", onEqRadioChange);
function onRainRadioChange(e) { function onRainRadioChange(e) {
let rainDecDict = { let rainDecDict = {
1:"24小時累積雨量達80毫米以上或時雨量達40毫米以上之降雨現象。", 1: "24小時累積雨量達80毫米以上或時雨量達40毫米以上之降雨現象。",
2:"24小時累積雨量達200毫米以上或3小時累積雨量達100毫米以上之降雨現象。", 2: "24小時累積雨量達200毫米以上或3小時累積雨量達100毫米以上之降雨現象。",
3:"24小時累積雨量達350毫米以上之降雨現象。", 3: "24小時累積雨量達350毫米以上之降雨現象。",
4:"24小時累積雨量達500毫米以上之降雨現象。", 4: "24小時累積雨量達500毫米以上之降雨現象。",
}; };
$("#rainDesc").text(rainDecDict[e.target.value] || ""); $("#rainDesc").text(rainDecDict[e.target.value] || "");
} }
function onEqRadioChange(e){ function onEqRadioChange(e) {
let eqDecDict = { let eqDecDict = {
3:"房屋震動,碗盤門窗發出聲音,懸掛物搖擺。", 3: "房屋震動,碗盤門窗發出聲音,懸掛物搖擺。",
4:"房屋搖動甚烈,少數未固定物品可能傾倒掉落,少數傢俱移動,可能有輕微災害。", 4: "房屋搖動甚烈,少數未固定物品可能傾倒掉落,少數傢俱移動,可能有輕微災害。",
5:"部分未固定物品傾倒掉落,少數傢俱可能移動或翻倒,少數門窗可能變形,部分牆壁產生裂痕。", 5: "部分未固定物品傾倒掉落,少數傢俱可能移動或翻倒,少數門窗可能變形,部分牆壁產生裂痕。",
6:"大量傢俱大幅移動或翻倒,門窗扭曲變形,部分耐震能力較差房屋可能損壞或倒塌。", 6: "大量傢俱大幅移動或翻倒,門窗扭曲變形,部分耐震能力較差房屋可能損壞或倒塌。",
7:"幾乎所有傢俱都大幅移動或翻倒,部分耐震較強建築物可能損壞或倒塌。", 7: "幾乎所有傢俱都大幅移動或翻倒,部分耐震較強建築物可能損壞或倒塌。",
} }
$("#eqDesc").text(eqDecDict[e.target.value] || ""); $("#eqDesc").text(eqDecDict[e.target.value] || "");
} }
function getWarningValue(){ function getWarningValue() {
let url = "/api/WarningValue/GetWarningValue"; let url = "/api/WarningValue/GetWarningValue";
$.post(url, {}, function (rel) { $.post(url, {}, function (rel) {
if (rel.code != "0000") { if (rel.code != "0000") {
if (rel.code == "9999") { if (rel.code == "9999") {
toast_error(rel.msg); toast_error(rel.msg);
@ -1019,34 +1031,56 @@
return; return;
} }
else { else {
if(rel.data){ if (rel.data) {
let irValue = rel.data.filter(d => d.type == 2).map(d => d.targetValue)[0];
let eqValue = rel.data.filter(d => d.type == 1).map(d => d.targetValue)[0]; let eqValue = rel.data.filter(d => d.type == 1).map(d => d.targetValue)[0];
let rainValue = rel.data.filter(d => d.type == 0).map(d => d.targetValue)[0]; let rainValue = rel.data.filter(d => d.type == 0).map(d => d.targetValue)[0];
if (irValue == "true") {
$(`input[name=irCheckbox][value=open]`).prop("checked", true);
} else { $(`input[name=irCheckbox][value=open]`).prop("checked", false); }
$(`input[name=rainRadio][value=${rainValue}]`).prop("checked",true); $(`input[name=rainRadio][value=${rainValue}]`).prop("checked", true);
$(`input[name=eqRadio][value=${eqValue}]`).prop("checked",true); $(`input[name=eqRadio][value=${eqValue}]`).prop("checked", true);
$("#rainCurName").text($(`input[name=rainRadio][value=${rainValue}]`).next("label").text()); $("#rainCurName").text($(`input[name=rainRadio][value=${rainValue}]`).next("label").text());
$("#eqCurName").text($(`input[name=eqRadio][value=${eqValue}]`).next("label").text()); $("#eqCurName").text($(`input[name=eqRadio][value=${eqValue}]`).next("label").text());
let rainDecDict = {
1: "24小時累積雨量達80毫米以上或時雨量達40毫米以上之降雨現象。",
2: "24小時累積雨量達200毫米以上或3小時累積雨量達100毫米以上之降雨現象。",
3: "24小時累積雨量達350毫米以上之降雨現象。",
4: "24小時累積雨量達500毫米以上之降雨現象。",
};
$("#rainDesc").text(rainDecDict[rainValue] || "");
let eqDecDict = {
3: "房屋震動,碗盤門窗發出聲音,懸掛物搖擺。",
4: "房屋搖動甚烈,少數未固定物品可能傾倒掉落,少數傢俱移動,可能有輕微災害。",
5: "部分未固定物品傾倒掉落,少數傢俱可能移動或翻倒,少數門窗可能變形,部分牆壁產生裂痕。",
6: "大量傢俱大幅移動或翻倒,門窗扭曲變形,部分耐震能力較差房屋可能損壞或倒塌。",
7: "幾乎所有傢俱都大幅移動或翻倒,部分耐震較強建築物可能損壞或倒塌。",
}
$("#eqDesc").text(eqDecDict[eqValue] || "");
} }
} }
}, 'json'); }, 'json');
} }
function setWarningValue(){ function setWarningValue() {
let irValue = $("input[name=irCheckbox]").is(":checked");
let eqValue = $("input[name=eqRadio]:checked").val(); let eqValue = $("input[name=eqRadio]:checked").val();
let rainValue = $("input[name=rainRadio]:checked").val(); let rainValue = $("input[name=rainRadio]:checked").val();
if (!eqValue || !rainValue) {
if(!eqValue || !rainValue){
toast_error("請輸入警戒值"); toast_error("請輸入警戒值");
return; return;
} }
let sendData = {
let sendData = {wvs: wvs:
[ [
{type:0,targetValue:rainValue}, { type: 0, targetValue: rainValue },
{type:1,targetValue:eqValue} { type: 1, targetValue: eqValue },
] { type: 2, targetValue: irValue }
]
}; };
let url = "/api/WarningValue/SetWarningValue"; let url = "/api/WarningValue/SetWarningValue";

View File

@ -10,7 +10,7 @@
"JwtSettings": { "JwtSettings": {
"Issuer": "Admin", //<EFBFBD>o<EFBFBD>e<EFBFBD><EFBFBD> "Issuer": "Admin", //<EFBFBD>o<EFBFBD>e<EFBFBD><EFBFBD>
"SignKey": "TaipeiDome123456", //ñ<EFBFBD><EFBFBD>//<EFBFBD>̤<EFBFBD>16<EFBFBD>r<EFBFBD><EFBFBD> "SignKey": "TaipeiDome123456", //ñ<EFBFBD><EFBFBD>//<EFBFBD>̤<EFBFBD>16<EFBFBD>r<EFBFBD><EFBFBD>
"JwtLifeSeconds": 3600 "JwtLifeSeconds": 86400
}, },
"FilePath": { "FilePath": {
"OutputForm": "C:\\jay.chang\\ibms\\FrontendWebApi\\wwwroot\\upload\\OutputForm\\", // "OutputForm": "C:\\jay.chang\\ibms\\FrontendWebApi\\wwwroot\\upload\\OutputForm\\", //

View File

@ -1567,6 +1567,7 @@ namespace Repository.BackendRepository.Implement
{ {
try try
{ {
await conn.ExecuteAsync("TRUNCATE TABLE device_disaster");
stopwatchSection = new Stopwatch(); stopwatchSection = new Stopwatch();
stopwatchSection.Start(); stopwatchSection.Start();
sb.Append("select * from device_disaster;"); sb.Append("select * from device_disaster;");
@ -1594,7 +1595,24 @@ namespace Repository.BackendRepository.Implement
stopwatchSection = new Stopwatch(); stopwatchSection = new Stopwatch();
stopwatchSection.Start(); stopwatchSection.Start();
dv = dv.Where(x => device.Any(d => d.device_number == x.value.Split('/')[6])).ToList(); // 過濾 dv 集合,只保留設備編號有效的項目
dv = dv.Where(x =>
{
string[] parts = x.value.Split('/');
// 確認陣列長度是否足夠長並且設備編號索引為6存在於 device 集合中
if (parts.Length > 6)
{
string deviceNumber = parts[6];
return device.Any(d => d.device_number == deviceNumber);
}
else
{
// 如果陣列長度不足,或者設備編號無效,則返回 false表示不保留此項目
return false;
}
}).ToList();
//dv = dv.Where(x => device.Any(d => d.device_number == x.value.Split('/')[6])).ToList();
sb.Clear(); sb.Clear();
var updateList = dv.Where(x => deviceDisaster.Any(dd => dd.device_number == x.value.Split('/')[6] && dd.device_system_value != x.disasterValue)).ToList(); var updateList = dv.Where(x => deviceDisaster.Any(dd => dd.device_number == x.value.Split('/')[6] && dd.device_system_value != x.disasterValue)).ToList();
foreach (var d in updateList) foreach (var d in updateList)