Compare commits

..

10 Commits

19 changed files with 317 additions and 141 deletions

View File

@ -167,7 +167,11 @@ namespace Backend.Controllers
buildMenu.left_system_url = string.Format("http://{0}:{1}{2}", building.Ip_address, building.Ip_port, buildMenu.left_system_url);
}
if (buildMenu.left_planimetric_click == 1)
{
dictionary.Add("@left_icon_click_url_width", buildMenu.left_icon_click_url_width);
dictionary.Add("@left_icon_click_url_height", buildMenu.left_icon_click_url_height);
}
dictionary.Add("@left_system_url", buildMenu.left_system_url);
}
else if (buildMenu.left_drawing == 4)
@ -184,8 +188,11 @@ namespace Backend.Controllers
dictionary.Add("@left_riser_diagram_url", buildMenu.left_riser_diagram_url);
dictionary.Add("@left_icon_click", buildMenu.left_icon_click);
dictionary.Add("@left_icon_click_url", buildMenu.left_icon_click_url);
dictionary.Add("@left_icon_click_url_width", buildMenu.left_icon_click_url_width);
dictionary.Add("@left_icon_click_url_height", buildMenu.left_icon_click_url_height);
if (buildMenu.left_icon_click == 1 || buildMenu.left_planimetric_click == 1)
{
dictionary.Add("@left_icon_click_url_width", buildMenu.left_icon_click_url_width);
dictionary.Add("@left_icon_click_url_height", buildMenu.left_icon_click_url_height);
}
}
else if (buildMenu.left_drawing == 1)
{
@ -293,7 +300,11 @@ namespace Backend.Controllers
buildMenu.left_system_url = string.Format("http://{0}:{1}{2}", building.Ip_address, building.Ip_port, buildMenu.left_system_url);
}
if (buildMenu.left_planimetric_click == 1)
{
dictionary.Add("@left_icon_click_url_width", buildMenu.left_icon_click_url_width);
dictionary.Add("@left_icon_click_url_height", buildMenu.left_icon_click_url_height);
}
dictionary.Add("@left_system_url", buildMenu.left_system_url);
}
else if (buildMenu.left_drawing == 4)
@ -310,8 +321,11 @@ namespace Backend.Controllers
dictionary.Add("@left_riser_diagram_url", buildMenu.left_riser_diagram_url);
dictionary.Add("@left_icon_click", buildMenu.left_icon_click);
dictionary.Add("@left_icon_click_url", buildMenu.left_icon_click_url);
dictionary.Add("@left_icon_click_url_width", buildMenu.left_icon_click_url_width);
dictionary.Add("@left_icon_click_url_height", buildMenu.left_icon_click_url_height);
if (buildMenu.left_icon_click == 1 || buildMenu.left_planimetric_click == 1)
{
dictionary.Add("@left_icon_click_url_width", buildMenu.left_icon_click_url_width);
dictionary.Add("@left_icon_click_url_height", buildMenu.left_icon_click_url_height);
}
}
else if (buildMenu.left_drawing == 1)
{

View File

@ -137,7 +137,7 @@ namespace Backend.Controllers
string random_password = new string(Enumerable.Repeat(chars, 8).Select(s => s[random.Next(chars.Length)]).ToArray());
//var newPassword = edFunction.GetSHA256Encryption(random_password);
var newPassword = edFunction.GetSHA256Encryption("123456");
var newPassword = edFunction.GetSHA256Encryption(post.Password);
//產生一組GUID
var guid = Guid.NewGuid(); //使用者GUID

View File

@ -60,6 +60,7 @@ namespace Backend.Models
{
public string Id { get; set; }
public string Name { get; set; } //姓名
public string Password { get; set; } //密碼
public string Email { get; set; } //信箱
public string Account { get; set; } //帳號
public string Phone { get; set; } //手機號碼

View File

@ -869,15 +869,16 @@
changebuild_menu_drawing_modal(this);
});
//#endregion
$('#build_menu_icon_click_onoff_modal_div').on("click", "input[type=checkbox]", function () {
if ($(this).prop("checked") && $(this).val() == 1) {
//$('#build_menu_icon_click_url_modal_div').show();
$('#build_menu_icon_click_url_width_height_modal_div').show();
} else {
//$('#build_menu_icon_click_url_modal_div').hide();
$('#build_menu_icon_click_url_width_height_modal_div').hide();
}
});
// $('#build_menu_icon_click_onoff_modal_div').on("click", "input[type=checkbox]", function () {
// if ($(this).prop("checked") && $(this).val() == 1) {
// $('#build_menu_icon_click_url_modal_div').show();
// $('#build_menu_icon_click_url_width_height_modal_div').show();
// } else {
// $('#build_menu_icon_click_url_modal_div').hide();
// $('#build_menu_icon_click_url_width_height_modal_div').hide();
// }
// });
$('#build_menu_icon_click_onoff_modal_div_r').on("click", "input[type=checkbox]", function () {
if ($(this).prop("checked") && $(this).val() == 1) {
@ -1057,43 +1058,131 @@
}, 'json');
});
//#endregion
function changebuild_menu_drawing_modal(selector = "input[name^='drawing']:checked") {
function changebuild_menu_drawing_modal(selector = "input[name^='drawing']:checked") {
$(selector).each(function (index, value) {
let drawingParent = $(value).parents("[id^=build_menu_position]")
let drawingParent = $(value).parents("[id^=build_menu_position]");
// 重置所有相關的 modal
$(drawingParent).find('[id^=build_menu_icon_click_onoff_modal_div]').hide();
$(drawingParent).find('[id^=build_menu_blankurl_modal_div]').hide();
//$(drawingParent).find('[id^=build_menu_icon_click_url_modal_div]').hide();
$(drawingParent).find('[id^=build_menu_icon_click_url_width_height_modal_div]').hide();
$(drawingParent).find('[id^=build_menu_planimetric_floor_modal_div]').hide();
$(drawingParent).find('[id^=build_menu_systemurl_modal_div]').hide();
$(drawingParent).find('[id^=build_menu_planimetric_modal_div]').show();
if ($(value).val() == 2) {
$(drawingParent).find('[id^=planimetric_click]').attr("disabled", false);
$(drawingParent).find('[id^=build_menu_systemurl_modal_div]').show();
} else if ($(value).val() == 4) {
$(drawingParent).find('[id^="planimetric_click"]').attr("disabled", false);
$(drawingParent).find('[id^=build_menu_icon_click_onoff_modal_div]').show();
if ($(drawingParent).find("[id^=icon_click_url]").prop('checked')) {
//$(drawingParent).find('[id^=build_menu_icon_click_url_modal_div]').show();
$(drawingParent).find('[id^=build_menu_icon_click_url_width_height_modal_div]').show();
}
} else if ($(value).val() == 1) {
$(drawingParent).find('[id^=planimetric_click]').prop("checked", true).attr("disabled", true);
$(drawingParent).find('[id^=build_menu_planimetric_floor_modal_div]').show();
} else if ($(value).val() == 5) {
$(drawingParent).find('[id^=planimetric_click]').prop("checked", false);
$(drawingParent).find('[id^=build_menu_blankurl_modal_div]').show();
} else if ($(value).val() == 3) {
$(drawingParent).find('[id^=planimetric_click]').prop("checked", false).attr("disabled", true);
} else {
$(drawingParent).find('[id^=build_menu_planimetric_modal_div]').hide();
// 根據 input 的值設定顯示/隱藏邏輯
switch ($(value).val()) {
case '2':
$(drawingParent).find('[id^=planimetric_click]').attr("disabled", false);
$(drawingParent).find('[id^=build_menu_systemurl_modal_div]').show();
function toggleModalVisibilityCase2() {
const planimetricChecked = $(drawingParent).find('#build_menu_planimetric_modal_div input[type=checkbox]').is(":checked");
if (planimetricChecked) {
$(drawingParent).find('#build_menu_icon_click_url_width_height_modal_div').show();
} else {
$(drawingParent).find('#build_menu_icon_click_url_width_height_modal_div').hide();
}
}
$(drawingParent).find('#build_menu_planimetric_modal_div').on("click", "input[type=checkbox]", function () {
toggleModalVisibilityCase2();
});
toggleModalVisibilityCase2(); // 初始化時也要檢查一次
break;
case '4':
$(drawingParent).find('[id^=planimetric_click]').attr("disabled", false);
$(drawingParent).find('[id^=build_menu_icon_click_onoff_modal_div]').show();
function toggleModalVisibilityCase4() {
const planimetricChecked = $(drawingParent).find('#build_menu_planimetric_modal_div input[type=checkbox]').is(":checked");
const onoffChecked = $(drawingParent).find('#build_menu_icon_click_onoff_modal_div input[type=checkbox]').is(":checked");
if (planimetricChecked || onoffChecked) {
$(drawingParent).find('#build_menu_icon_click_url_width_height_modal_div').show();
} else {
$(drawingParent).find('#build_menu_icon_click_url_width_height_modal_div').hide();
}
}
$(drawingParent).find('#build_menu_planimetric_modal_div').on("click", "input[type=checkbox]", function () {
toggleModalVisibilityCase4();
});
$(drawingParent).find('#build_menu_icon_click_onoff_modal_div').on("click", "input[type=checkbox]", function () {
toggleModalVisibilityCase4();
});
toggleModalVisibilityCase4(); // 初始化時也要檢查一次
break;
case '1':
$(drawingParent).find('[id^=planimetric_click]').prop("checked", true).attr("disabled", true);
$(drawingParent).find('[id^=build_menu_planimetric_floor_modal_div]').show();
break;
case '5':
$(drawingParent).find('[id^=planimetric_click]').prop("checked", false);
$(drawingParent).find('[id^=build_menu_blankurl_modal_div]').show();
break;
case '3':
$(drawingParent).find('[id^=planimetric_click]').prop("checked", false).attr("disabled", true);
break;
default:
$(drawingParent).find('[id^=build_menu_planimetric_modal_div]').hide();
break;
}
})
});
}
// function changebuild_menu_drawing_modal(selector = "input[name^='drawing']:checked") {
// $(selector).each(function (index, value) {
// let drawingParent = $(value).parents("[id^=build_menu_position]")
// $(drawingParent).find('[id^=build_menu_icon_click_onoff_modal_div]').hide();
// $(drawingParent).find('[id^=build_menu_blankurl_modal_div]').hide();
// $(drawingParent).find('[id^=build_menu_icon_click_url_modal_div]').hide();
// $(drawingParent).find('[id^=build_menu_icon_click_url_width_height_modal_div]').hide();
// $(drawingParent).find('[id^=build_menu_planimetric_floor_modal_div]').hide();
// $(drawingParent).find('[id^=build_menu_systemurl_modal_div]').hide();
// $(drawingParent).find('[id^=build_menu_planimetric_modal_div]').show();
// if ($(value).val() == 2) {
// $(drawingParent).find('[id^=planimetric_click]').attr("disabled", false);
// $(drawingParent).find('[id^=build_menu_systemurl_modal_div]').show();
// if ($(drawingParent).find("[id^=planimetric_click]").prop('checked')) {
// $(drawingParent).find('[id^=build_menu_icon_click_url_width_height_modal_div]').show();
// }
// } else if ($(value).val() == 4) {
// $(drawingParent).find('[id^="planimetric_click"]').attr("disabled", false);
// $(drawingParent).find('[id^=build_menu_icon_click_onoff_modal_div]').show();
// if ($(drawingParent).find("[id^=icon_click_url]").prop('checked')) {
// $(drawingParent).find('[id^=build_menu_icon_click_url_modal_div]').show();
// $(drawingParent).find('[id^=build_menu_icon_click_url_width_height_modal_div]').show();
// }
// } else if ($(value).val() == 1) {
// $(drawingParent).find('[id^=planimetric_click]').prop("checked", true).attr("disabled", true);
// $(drawingParent).find('[id^=build_menu_planimetric_floor_modal_div]').show();
// } else if ($(value).val() == 5) {
// $(drawingParent).find('[id^=planimetric_click]').prop("checked", false);
// $(drawingParent).find('[id^=build_menu_blankurl_modal_div]').show();
// } else if ($(value).val() == 3) {
// $(drawingParent).find('[id^=planimetric_click]').prop("checked", false).attr("disabled", true);
// } else {
// $(drawingParent).find('[id^=build_menu_planimetric_modal_div]').hide();
// }
// })
// }
$('#buildMenu_table').on("click", "button.del-btn", function () {
var send_data = {

View File

@ -2951,9 +2951,14 @@
return;
}
if ($("#device_normal_point_value_modal").val() == $("#device_close_point_value_modal").val()) {
toast_warning("點位值設定重複,請修改");
return;
var normalValue = $("#device_normal_point_value_modal").val();
var closeValue = $("#device_close_point_value_modal").val();
if (normalValue != "" && closeValue != "" && normalValue != null && closeValue != null) {
if (normalValue == closeValue) {
toast_warning("點位值設定重複,請修改");
return;
}
}
if ($("#device-kind-form").valid()) {

View File

@ -329,6 +329,7 @@
var send_data = {
Id: selected_id,
Name: $("#user_name_modal").val(),
Password: $("#user_password_modal").val(),
Email: $("#user_email_modal").val(),
Account: $("#user_account_modal").val(),
Phone: $("#user_phone_modal").val(),

View File

@ -63,7 +63,7 @@
<div class="form-group col-lg-6 user-password-div">
<label class="form-label" for="user_password_modal">密碼</label>
<input type="password" id="user_password_modal" name="user_password_modal" class="form-control" placeholder="由系統產生" disabled>
<input type="password" id="user_password_modal" name="user_password_modal" class="form-control">
</div>
<div class="form-group col-lg-6">

View File

@ -1127,9 +1127,9 @@ namespace BackendWorkerService.Quartz.Jobs
var endDay = System.DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd");
foreach (DateTime day in EachMonth(startDay, endDay))
foreach (DateTime month in EachMonth(startDay, endDay))
{
if (day.ToString("yyyy-MM") == System.DateTime.Now.AddDays(-1).ToString("yyyy-MM"))
if (month.ToString("yyyy-MM") == System.DateTime.Now.AddDays(-1).ToString("yyyy-MM"))
{
var preDay = now.AddDays(-1); //取得前一天
@ -1154,9 +1154,9 @@ namespace BackendWorkerService.Quartz.Jobs
}
else
{
var dayInMonth = DateTime.DaysInMonth(day.Year, day.Month);
var FirstDay = new DateTime(day.Year, day.Month, 1);
var LastDay = new DateTime(day.Year, day.Month, dayInMonth);
var dayInMonth = DateTime.DaysInMonth(month.Year, month.Month);
var FirstDay = new DateTime(month.Year, month.Month, 1);
var LastDay = new DateTime(month.Year, month.Month, dayInMonth);
startTimestamp = string.Format("{0}T00:00:00.000+08:00", FirstDay.ToString("yyyy-MM-dd"));
@ -1270,7 +1270,7 @@ namespace BackendWorkerService.Quartz.Jobs
{
var dayInMonth = DateTime.DaysInMonth(day.Year, day.Month);
var FirstDay = new DateTime(day.Year, day.Month, 1);
var LastDay = new DateTime(day.Year, day.Month, dayInMonth);
var LastDay = new DateTime(day.Year, day.Month, dayInMonth).AddDays(1);
startTimestamp = string.Format("{0}T00:00:00.000+08:00", FirstDay.ToString("yyyy-MM-dd"));
@ -1746,9 +1746,11 @@ namespace BackendWorkerService.Quartz.Jobs
{
var strtday = DateTime.Parse(from);
var endday = DateTime.Parse(thru);
for (var _month = strtday.Date; _month.Month <= endday.Month; _month = _month.AddMonths(1))
yield return _month;
for (var _month = strtday.Date; _month <= endday; _month = _month.AddMonths(1))
{
yield return _month;
}
}
private List<Dictionary<string, object>> ArrangeRawData(DeviceNumberPoint deviceNumberPoint, JObject jsonResult)
{

View File

@ -1,6 +1,7 @@
using FrontendWebApi.Models;
using Microsoft.Extensions.Logging;
using Quartz;
using Repository.BackendRepository.Implement;
using Repository.BackendRepository.Interface;
using System;
using System.Collections.Generic;
@ -52,8 +53,10 @@ namespace BackendWorkerService.Quartz.Jobs
using (HttpClient client = new HttpClient())
{
string username = "stanGG";
string password = "St12345678";
var sqlObix = $@"SELECT system_value as Value, system_key as Name FROM variable WHERE deleted = 0 AND system_type = 'obixConfig'";
var variableObix = backendRepository.GetAllAsync<KeyValue>(sqlObix).Result;
string username = variableObix.Where(x => x.Name == "UserName").Select(x => x.Value).FirstOrDefault();
string password = variableObix.Where(x => x.Name == "Password").Select(x => x.Value).FirstOrDefault();
string encoded = Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(username + ":" + password));
client.DefaultRequestHeaders.Add("Authorization", "Basic " + encoded);
@ -88,7 +91,8 @@ namespace BackendWorkerService.Quartz.Jobs
foreach (var obj in filteredObjs)
{
var newguid = Guid.NewGuid();
var guid = obj.Descendants().Where(d => d.Name.LocalName == "str" && d.Attribute("name").Value == "niagara-uuid").
Select(x => x.Attribute("val").Value).FirstOrDefault();
var alarm_timestamp = obj.Descendants().Where(d => d.Name.LocalName == "abstime" && d.Attribute("name").Value == "timestamp")
.Select(d =>
{
@ -110,7 +114,7 @@ namespace BackendWorkerService.Quartz.Jobs
var dictionary = new Dictionary<string, object>()
{
{"@emergency_event_guid",newguid},
{"@emergency_event_guid",guid},
{"@disaster",filterDevice.device_system_value},
{"@building_tag", filterDevice.device_building_tag},
{"@device_guid",filterDevice.device_guid },
@ -120,7 +124,7 @@ namespace BackendWorkerService.Quartz.Jobs
dictionaryList.Add(dictionary);
}
// 之前以為沒有唯一識別碼(uuid)故該table有設置一個以device_guid跟alarm_time的unique替代
var mergeSql = @"
INSERT INTO emergency_event
(emergency_event_guid, disaster, device_guid, building_tag, type, alarm_time)

View File

@ -42,8 +42,11 @@ namespace BackendWorkerService.Quartz.Jobs
{
try
{
string username = "stanGG";
string password = "St12345678";
var sqlObix = $@"SELECT system_value as Value, system_key as Name FROM variable WHERE deleted = 0 AND system_type = 'obixConfig'";
var variableObix = backgroundServiceRepository.GetAllAsync<KeyValue>(sqlObix).Result;
string username = variableObix.Where(x => x.Name == "UserName").Select(x => x.Value).FirstOrDefault();
string password = variableObix.Where(x => x.Name == "Password").Select(x => x.Value).FirstOrDefault();
string encoded = Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(username + ":" + password));
HttpWebRequest Postrequest = (HttpWebRequest)WebRequest.Create(url);
Postrequest.Method = "POST";

View File

@ -61,8 +61,10 @@ namespace FrontendWebApi.ApiControllers
using (HttpClient client = new HttpClient())
{
string username = "stanGG";
string password = "St12345678";
var sqlObix = $@"SELECT system_value as Value, system_key as Name FROM variable WHERE deleted = 0 AND system_type = 'obixConfig'";
var variableObix = frontendRepository.GetAllAsync<KeyValue>(sqlObix).Result;
string username = variableObix.Where(x => x.Name == "UserName").Select(x => x.Value).FirstOrDefault();
string password = variableObix.Where(x => x.Name == "Password").Select(x => x.Value).FirstOrDefault();
string encoded = Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(username + ":" + password));
client.DefaultRequestHeaders.Add("Authorization", "Basic " + encoded);

View File

@ -359,12 +359,22 @@ namespace FrontendWebApi.ApiControllers
var sub_system = await backendRepository.GetOneAsync<BuildMenuSql>(@$"select v.system_key subfull_name,me.* from building_menu me
left join variable v on v.system_value = me.sub_system_tag and v.system_type = 'device_system_category_layer3' and v.deleted = 0
where me.building_tag = '{get.building_tag}' and me.main_system_tag = '{get.main_system_tag}' and me.sub_system_tag = '{get.sub_system_tag}' order by me.priority");
List<Floor> Floors = new List<Floor>();
get.sub_system_tag = get.sub_system_tag == "P" ? $"'{get.sub_system_tag}','B'" : $"'{get.sub_system_tag}'"; // 巨蛋緊急壓扣(P)跟閃光喇吧被視為同一類
List <Floor> Floors = new List<Floor>();
var floorsql = await backendRepository.GetAllAsync<Floorsql>($@"
select * from (select * from sub_system_floor ssf where ssf.deleted = 0 and ssf.status = 0 and ssf.building_tag = '{get.building_tag}' and ssf.main_system_tag = '{get.main_system_tag}' and ssf.sub_system_tag = '{get.sub_system_tag}' and ssf.is_link = 1) a
select * from (select *,
CASE
WHEN ssf.sub_system_tag IN ({get.sub_system_tag}) THEN 'P_B' -- 'P' 'B'
ELSE ssf.sub_system_tag --
END AS merged_sub_system_tag
from sub_system_floor ssf where ssf.deleted = 0 and ssf.status = 0
and ssf.building_tag = '{get.building_tag}'
and ssf.main_system_tag = '{get.main_system_tag}'
and ssf.sub_system_tag in ({get.sub_system_tag})
and ssf.is_link = 1) a
left join floor on floor.full_name = a.floor_tag and a.building_tag = floor.building_tag
where floor.deleted = 0
GROUP BY a.floor_tag, a.building_tag, a.merged_sub_system_tag
order by floor.priority");
Sub_system sub_System = new Sub_system()
{
@ -402,6 +412,7 @@ namespace FrontendWebApi.ApiControllers
catch (Exception exception)
{
apiResult.Code = "9999";
apiResult.Msg = "9999";
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
return Ok(apiResult);
}

View File

@ -319,6 +319,7 @@ namespace FrontendWebApi.ApiControllers
try
{
input.EnableLimit = false; // CSV關閉5W筆限制
var apiData = await GetHistoryRealTime(input);
if (apiData.Value == null)
{
@ -1394,6 +1395,7 @@ namespace FrontendWebApi.ApiControllers
ApiResult<List<HistoryRawData>> apiResult = new ApiResult<List<HistoryRawData>>(jwt_str);
apiResult.Data = new List<HistoryRawData>();
List<string> noDataDevice = new List<string>();
if (!jwtlife)
{
apiResult.Code = "5000";
@ -1439,41 +1441,40 @@ namespace FrontendWebApi.ApiControllers
int totalRecordCount = 0;
// 先計算總記錄數
foreach (var hi in input.HistoryItems)
if (input.EnableLimit)
{
var device_number = hi.Device_number_point.Split(":")[0];
var point = hi.Device_number_point.Split(":")[1];
var stationName = await backendRepository.GetOneAsync<string>($"select distinct parent_path from import_niagara_item_history where device_building_tag = '{device_number.Split('_')[0]}' limit 1");
var tableName = await backgroundServiceMsSqlRepository.GetOneAsync<string>($"select table_name from INFORMATION_SCHEMA.TABLES where table_name like '%{stationName}_{device_number}_{point}%'");
if (!string.IsNullOrEmpty(tableName))
foreach (var hi in input.HistoryItems)
{
var sqlCount = $@"select count(*) from {tableName}
var device_number = hi.Device_number_point.Split(":")[0];
var point = hi.Device_number_point.Split(":")[1];
var stationName = await backendRepository.GetOneAsync<string>($"select distinct parent_path from import_niagara_item_history where device_building_tag = '{device_number.Split('_')[0]}' limit 1");
var tableName = await backgroundServiceMsSqlRepository.GetOneAsync<string>($"select table_name from INFORMATION_SCHEMA.TABLES where table_name like '%{stationName}_{device_number}_{point}%'");
if (!string.IsNullOrEmpty(tableName))
{
var sqlCount = $@"select count(*) from {tableName}
where replace(convert(varchar, [timestamp], 111), '/', '-') >= @startTime
and replace(convert(varchar, [timestamp], 111), '/', '-') <= @endTime";
var recordCount = await backgroundServiceMsSqlRepository.GetOneAsync<int>(sqlCount, new { startTime = input.Start_timestamp, endTime = input.End_timestamp });
totalRecordCount += recordCount;
var recordCount = await backgroundServiceMsSqlRepository.GetOneAsync<int>(sqlCount, new { startTime = input.Start_timestamp, endTime = input.End_timestamp });
totalRecordCount += recordCount;
if (totalRecordCount > 50000)
{
// 如果總記錄數超過5萬筆返回提示信息
apiResult.Code = "5000";
apiResult.Msg = "資料量超過5萬筆請減少選擇區間或設備";
return apiResult;
if (totalRecordCount > 50000)
{
// 如果總記錄數超過5萬筆返回提示信息
apiResult.Code = "5000";
apiResult.Msg = "資料量超過5萬筆請減少選擇區間或設備";
return apiResult;
}
}
}
else
{
noDataDevice.Add(hi.Device_number_point);
}
}
// 正式撈取資料
foreach (var hi in input.HistoryItems)
{
var device_number = hi.Device_number_point.Split(":")[0];
var point = hi.Device_number_point.Split(":")[1];
var stationName = await backendRepository.GetOneAsync<string>($"select distinct parent_path from import_niagara_item_history where device_building_tag = '{device_number.Split('_')[0]}' limit 1");
var stationName = await backendRepository.GetOneAsync<string>($"select distinct parent_path from import_niagara_item_history where device_number = '{device_number}' limit 1");
var tableName = await backgroundServiceMsSqlRepository.GetOneAsync<string>($"select table_name from INFORMATION_SCHEMA.TABLES where table_name like '%{stationName}_{device_number}_{point}%'");
if (!string.IsNullOrEmpty(tableName))
{
@ -1485,56 +1486,92 @@ namespace FrontendWebApi.ApiControllers
//valueFacets = "range=E:{$u5176$u4ed6$u72c0$u614b=1,$u6b63$u5e38=2,$u4f4e$u96fb$u4f4d=3,$u8017$u76e1=4,$u672a$u9023$u63a5=5,$u7570$u5e38=6}";
// 檢查 valueFacets 是否包含 "range=E"
string valueDisplaySql;
if (valueFacets != null && valueFacets.Contains("range=E"))
string valueDisplaySql = string.Empty;
// 直接給千分位數值會讓前台套件顯示有問題故頁面千分位顯示由前端處理CSV千分位後端處理
string DisplaySql = input.EnableLimit ? "ROUND(value, 2) AS Value" : " FORMAT(ROUND(value, 2), 'N2') AS Value";
if (valueFacets != null)
{
// 提取 "range=E:" 之後的部分
string rangePart = valueFacets.Substring(valueFacets.IndexOf("range=E:") + "range=E:".Length);
// 去除開頭和結尾的大括號
rangePart = rangePart.Trim('{', '}');
// 分割各個條目
var entries = rangePart.Split(',');
// 存儲匹配條目的列表
var caseWhenStatements = new List<string>();
foreach (var entry in entries)
// 轉換 Unicode 序列為中文字符的函數
string ConvertUnicodeToChinese(string unicodeSequence)
{
// 分割 Unicode 序列和數字
var parts = entry.Split('=');
if (parts.Length == 2)
var chineseCharacters = new StringBuilder();
var unicodeParts = unicodeSequence.Split("$u");
foreach (var unicodePart in unicodeParts)
{
string unicodeSequence = parts[0];
int correspondingValue = int.Parse(parts[1]);
// 轉換 Unicode 序列為中文字符
var chineseCharacters = new StringBuilder();
var unicodeParts = unicodeSequence.Split("$u");
foreach (var unicodePart in unicodeParts)
if (unicodePart.Length == 4)
{
if (unicodePart.Length == 4)
{
var unicodeValue = Convert.ToInt32(unicodePart, 16);
chineseCharacters.Append(char.ConvertFromUtf32(unicodeValue));
}
var unicodeValue = Convert.ToInt32(unicodePart, 16);
chineseCharacters.Append(char.ConvertFromUtf32(unicodeValue));
}
// 添加 Case When 語句
caseWhenStatements.Add($"when value = {correspondingValue} then '{chineseCharacters}'");
}
return chineseCharacters.ToString();
}
// 處理 range=E 的部分
if (valueFacets.Contains("range=E"))
{
// 提取 "range=E:" 之後的部分
string rangePart = valueFacets.Substring(valueFacets.IndexOf("range=E:") + "range=E:".Length);
rangePart = rangePart.Trim('{', '}'); // 去除大括號
var entries = rangePart.Split(',');
foreach (var entry in entries)
{
var parts = entry.Split('=');
if (parts.Length == 2)
{
string unicodeSequence = parts[0];
int correspondingValue = int.Parse(parts[1]);
// 轉換 Unicode 為中文
string chineseCharacters = ConvertUnicodeToChinese(unicodeSequence);
// 添加 Case When 語句
caseWhenStatements.Add($"when value = {correspondingValue} then '{chineseCharacters}'");
}
}
valueDisplaySql = $"Case {string.Join(" ", caseWhenStatements)} else 'Unknow' End as Value";
}
// 處理 trueText 和 falseText 的部分
else if (valueFacets.Contains("trueText=s:") && valueFacets.Contains("falseText=s:"))
{
// 提取 trueText 和 falseText 的部分
string trueTextPart = valueFacets.Substring(valueFacets.IndexOf("trueText=s:") + "trueText=s:".Length);
trueTextPart = trueTextPart.Split('|')[0]; // 只保留 trueText 的部分
string falseTextPart = valueFacets.Substring(valueFacets.IndexOf("falseText=s:") + "falseText=s:".Length);
falseTextPart = falseTextPart.Split('|')[0]; // 只保留 falseText 的部分
// 如果不包含 $u就直接使用這些字串
if (trueTextPart.Contains("$u"))
{
trueTextPart = ConvertUnicodeToChinese(trueTextPart);
}
if (falseTextPart.Contains("$u"))
{
falseTextPart = ConvertUnicodeToChinese(falseTextPart);
}
// 添加 Case When 語句
caseWhenStatements.Add($"when value = 1 then '{trueTextPart}'");
caseWhenStatements.Add($"when value = 0 then '{falseTextPart}'");
valueDisplaySql = $"Case {string.Join(" ", caseWhenStatements)} else 'Unknow' End as Value";
}
else
{
// 使用原始的顯示方式
valueDisplaySql = valueType.Equals("bit")
? "Case when value = 1 then 'true' when value = 0 then 'false' else 'Unknow' End as Value"
: DisplaySql;
}
// 最後的 SQL 語句
valueDisplaySql = $"Case {string.Join(" ", caseWhenStatements)} else 'Unknow' End as Value";
}
else
{
// 如果不包含 range=E使用原始的顯示方式
valueDisplaySql = valueType.Equals("bit")
? "Case when value = 1 then 'true' when value = 0 then 'false' else 'Unknow' End as Value"
: "round(value, 2) as Value";
}
@ -1560,7 +1597,7 @@ namespace FrontendWebApi.ApiControllers
apiResult.Code = "0000";
apiResult.Msg = @$"DB無資料的設備{string.Join(".", noDataDevice)}";
apiResult.Data = apiResult.Data.OrderBy(x => x.Device_number).ThenByDescending(x => x.Timestamp).ToList();
apiResult.Data = apiResult.Data.OrderBy(x => x.Device_number).ThenBy(x => x.Points).ThenByDescending(x => x.Timestamp).ToList();
}
catch (Exception exception)
{

View File

@ -170,7 +170,7 @@ namespace FrontendWebApi.ApiControllers
stylein12.WrapText = true;
#endregion
var sheet = workbook.CreateSheet("電表報表");
var sheet = workbook.CreateSheet(input.exportOpeTypeName);
int RowPosition = 0;
if (result.Count > 0)
{
@ -202,7 +202,7 @@ namespace FrontendWebApi.ApiControllers
cell = row.CreateCell(i++);
cell.SetCellValue("內容");
cell.CellStyle = stylein12;
cell.CellStyle = styleLine12;
cell = row.CreateCell(i++);
cell.SetCellValue("紀錄時間");
cell.CellStyle = styleLine12;

View File

@ -6,6 +6,7 @@ using Newtonsoft.Json;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using Repository.BackendRepository.Implement;
using Repository.BackendRepository.Interface;
using Repository.FrontendRepository.Interface;
using System;
using System.Collections.Generic;
@ -82,8 +83,10 @@ namespace FrontendWebApi.ApiControllers
using (HttpClient client = new HttpClient())
{
apiUrl = Path.Combine(baseApiUrl, "obix/config/", apiUrl);
string username = "stanGG";
string password = "St12345678";
var sqlObix = $@"SELECT system_value as Value, system_key as Name FROM variable WHERE deleted = 0 AND system_type = 'obixConfig'";
var variableObix = frontendRepository.GetAllAsync<KeyValue>(sqlObix).Result;
string username = variableObix.Where(x => x.Name == "UserName").Select(x => x.Value).FirstOrDefault();
string password = variableObix.Where(x => x.Name == "Password").Select(x => x.Value).FirstOrDefault();
string encoded = Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(username + ":" + password));
client.DefaultRequestHeaders.Add("Authorization", "Basic " + encoded);
@ -165,8 +168,10 @@ namespace FrontendWebApi.ApiControllers
using (HttpClient client = new HttpClient())
{
apiUrl = Path.Combine(baseApiUrl, "obix/config/", apiUrl);
string username = "stanGG";
string password = "St12345678";
var sqlObix = $@"SELECT system_value as Value, system_key as Name FROM variable WHERE deleted = 0 AND system_type = 'obixConfig'";
var variableObix = frontendRepository.GetAllAsync<KeyValue>(sqlObix).Result;
string username = variableObix.Where(x => x.Name == "UserName").Select(x => x.Value).FirstOrDefault();
string password = variableObix.Where(x => x.Name == "Password").Select(x => x.Value).FirstOrDefault();
string encoded = Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(username + ":" + password));
client.DefaultRequestHeaders.Add("Authorization", "Basic " + encoded);

View File

@ -197,6 +197,7 @@ namespace FrontendWebApi.Models
public string point_name { get; set; }
public string points { get; set; }
public byte points_is_bool { get; set; }
public int is_RTSP { get; set; } // 巨蛋監視器控制項
public List<DeviceNode> Device_nodes { get; set; }
public List<DeviceItem> deviceItems { get; set; }
}

View File

@ -259,6 +259,7 @@ namespace FrontendWebApi.Models
{
public string Start_timestamp { get; set; }
public string End_timestamp { get; set; }
public bool EnableLimit { get; set; } = true; // 控制是否需要限制查詢筆數
public List<HistoryItem> HistoryItems { get; set; }
}

View File

@ -95,7 +95,7 @@
<span aria-hidden="true"><i class="fal fa-times"></i></span>
</button>*@
<div class="position-absolute pos-right mr-sm-3 mt-sm-3 z-index-space">
@*<button type="button" class="btn btn-danger waves-effect waves-themed mr-2" id="Tcp" onclick="SendMessageAsync('D002')">取消上牆</button>*@
<button type="button" class="btn btn-danger waves-effect waves-themed mr-2" id="Tcp" onclick="SendMessageAsync('D002')">取消上牆</button>
<button type="button" class="btn btn-danger waves-effect waves-themed" id="closemodal" onclick="Closemodal()">關閉流程</button>
</div>
<div class="modal-body bg-white">
@ -755,7 +755,7 @@
selected_device_time = $(this).parents('tr').attr('data-time');
OnSimulationExercise(selected_device_guid, selected_device_disaster, 0, selected_device_time);
// SendMessageAsync("D001");
SendMessageAsync("D001");
});
//#endregion
@ -1952,7 +1952,7 @@
CloseVerify = true;
$('#emergency-verify-modal').modal('hide');
$('#SimulationExercisemodal').modal('hide');
// SendMessageAsync("D002");
SendMessageAsync("D002");
UpdateRecordFinishTime()
CloseVerify = false; // 每次關閉流程都要驗證一次
} else {

View File

@ -122,7 +122,7 @@
<span aria-hidden="true"><i class="fal fa-times"></i></span>
</button>*@
<div class="position-absolute pos-right mr-sm-3 mt-sm-3 z-index-space">
@*<button type="button" class="btn btn-danger waves-effect waves-themed mr-2" id="Tcp" onclick="SendMessageAsync('D002')">取消上牆</button>*@
<button type="button" class="btn btn-danger waves-effect waves-themed mr-2" id="Tcp" onclick="SendMessageAsync('D002')">取消上牆</button>
<button type="button" class="btn btn-danger waves-effect waves-themed" id="closemodal" onclick="Closemodal()">關閉流程</button>
</div>
<div class="modal-body bg-white">
@ -860,7 +860,7 @@
SimulationExerciseGuid = selected_event_guid;
OnSimulationExercise(selected_event_guid, selected_device_disaster, 0);
// SendMessageAsync("D001");
SendMessageAsync("D001");
});
//#endregion
//#region 模擬演練 / SOP 開啟畫面
@ -1385,7 +1385,7 @@
CloseVerify = true;
$('#emergency-verify-modal').modal('hide');
$('#SimulationExercisemodal').modal('hide');
// SendMessageAsync("D002");
SendMessageAsync("D002");
UpdateRecordFinishTime(function () {
EmergencyEventTable.ajax.reload();
});