Merge branch 'master' of https://gitea.mjm-staging.developers-homelab.net/BIMS/BIMS
This commit is contained in:
commit
ce792c2a5c
@ -53,6 +53,8 @@ namespace Backend.Controllers
|
||||
obixApiConfig.ApiBase = variableObix.Where(x => x.Name == "ApiBase").Select(x => x.Value).FirstOrDefault() + "obix/config/Program/ObixQuery/query/";
|
||||
obixApiConfig.UrlSlot =variableObix.Where(x => x.Name == "url_slot").Select(x => x.Value).FirstOrDefault();
|
||||
obixApiConfig.TagQuantity = variableObix.Where(x => x.Name == "tag_quantity").Select(x => x.Value).FirstOrDefault();
|
||||
obixApiConfig.UserName = variableObix.Where(x => x.Name == "UserName").Select(x => x.Value).FirstOrDefault();
|
||||
obixApiConfig.Password = variableObix.Where(x => x.Name == "Password").Select(x => x.Value).FirstOrDefault();
|
||||
|
||||
List<Device_value> ds;
|
||||
|
||||
@ -61,7 +63,7 @@ namespace Backend.Controllers
|
||||
string bql = obixApiConfig.UrlSlot + "bql:select " + top100 + " * from baja:Folder ";
|
||||
//ds = svc.obixQuery("http://192.168.0.136:8080/obix/config/Arena/Program/ObixQuery/query/", bql);
|
||||
//ds = svc.obixQuery("http://localhost:8080/obix/config/Program/ObixQuery/query/", bql);
|
||||
ds = svc.obixQuery(obixApiConfig.ApiBase, bql, obixApiConfig.TagQuantity);//三菱
|
||||
ds = svc.obixQuery(obixApiConfig.ApiBase, bql, obixApiConfig.TagQuantity, obixApiConfig.UserName, obixApiConfig.Password);//三菱
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Data = ds;
|
||||
|
@ -17,18 +17,23 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Repository.Models.CodeBeautify;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using Microsoft.AspNetCore.Localization;
|
||||
using MySqlX.XDevAPI.Relational;
|
||||
using Backend.Models;
|
||||
|
||||
namespace Backend.Services.Implement
|
||||
{
|
||||
public class webRequestService
|
||||
{
|
||||
public List<Device_value> obixQuery(string urlString, string bql, string tag_quantity)
|
||||
public List<Device_value> obixQuery(string urlString, string bql, string tag_quantity, string acc, string pass)
|
||||
{
|
||||
List<Device_value> result = new List<Device_value>();
|
||||
String username = "obixUser";
|
||||
String password = "Admin123456";
|
||||
//String username = "obixUser";
|
||||
//String password = "Admin123456";
|
||||
//String username = "stanGG";
|
||||
//String password = "St12345678";
|
||||
String username = acc;
|
||||
String password = pass;
|
||||
String encoded = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(username + ":" + password));
|
||||
String API_Url = urlString;
|
||||
|
||||
@ -141,7 +146,7 @@ namespace Backend.Services.Implement
|
||||
String username = acc;
|
||||
String password = pass;
|
||||
String encoded = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(username + ":" + password));
|
||||
|
||||
String oneStationName = null;
|
||||
#region get control point data
|
||||
List<control_point> conPoint = new List<control_point>();
|
||||
String cp_API_Url = bqlUrlString;
|
||||
@ -176,6 +181,7 @@ namespace Backend.Services.Implement
|
||||
|
||||
row.name = s1[0].Replace('/', '_').Remove(s1[0].Length - 1, 1).Remove(0, 1);
|
||||
row.displayName = displayName;
|
||||
row.isHistory = false;
|
||||
|
||||
conPoint.Add(row);
|
||||
}
|
||||
@ -199,7 +205,8 @@ namespace Backend.Services.Implement
|
||||
//ref https://stackoverflow.com/questions/642293/how-do-i-read-and-parse-an-xml-file-in-c
|
||||
foreach (XmlNode node in xmlDoc.DocumentElement.ChildNodes)
|
||||
{
|
||||
string stationName = node.Attributes["name"].InnerText; // WSP_Supervisor
|
||||
var stationName = node.Attributes["name"].InnerText; // WSP_Supervisor
|
||||
oneStationName = oneStationName ?? stationName;
|
||||
String API_Url2 = urlString + "/" + stationName; // http://192.168.0.136:8081/obix/histories/WSP_Supervisor
|
||||
|
||||
HttpWebRequest Postrequest2 = (HttpWebRequest)WebRequest.Create(API_Url2);
|
||||
@ -228,6 +235,9 @@ namespace Backend.Services.Implement
|
||||
|
||||
//full_name 其實是點位名稱 point_name
|
||||
row.full_name = conPoint.Where(x => x.name == tagName).Select(x => x.displayName).FirstOrDefault();
|
||||
if (conPoint.Where(x => x.name == tagName).FirstOrDefault() != null)
|
||||
conPoint.Where(x => x.name == tagName).FirstOrDefault().isHistory = true;
|
||||
row.isHistory = true;
|
||||
|
||||
result.Add(row);
|
||||
|
||||
@ -239,7 +249,7 @@ namespace Backend.Services.Implement
|
||||
row.device_building_tag = tagName.Split('_')[0];
|
||||
row.device_system_tag = tagName.Split('_')[1];
|
||||
row.device_floor_tag = tagName.Split('_')[2];
|
||||
row.device_name_tag = tagName.Split('_')[3].Substring(1);
|
||||
row.device_name_tag = tagName.Split('_')[3];
|
||||
row.device_point_name = tagName.Split('_')[5];
|
||||
}
|
||||
else //for normal
|
||||
@ -253,13 +263,63 @@ namespace Backend.Services.Implement
|
||||
|
||||
row.parent_path = stationName;
|
||||
//full_name 其實是點位名稱 point_name
|
||||
row.full_name = conPoint.Where(x => x.name == tagName).Select(x => x.displayName).FirstOrDefault();
|
||||
row.full_name = conPoint.Where(x => x.name.Contains(tagName) && !x.isHistory).Select(x => x.displayName).FirstOrDefault();
|
||||
if (conPoint.Where(x => x.name.Contains(tagName) && !x.isHistory).FirstOrDefault() != null)
|
||||
conPoint.Where(x => x.name.Contains(tagName) && !x.isHistory).FirstOrDefault().isHistory = true;
|
||||
row.isHistory = true;
|
||||
result.Add(row);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
var newConPoint = conPoint.Where(x => !x.isHistory).ToArray();
|
||||
foreach(var n in newConPoint)
|
||||
{
|
||||
if (n.name.Split('_').Length == 9)
|
||||
{
|
||||
result.Add(new ImpNiaItem
|
||||
{
|
||||
device_area_tag = n.name.Split('_')[0],
|
||||
device_building_tag = n.name.Split('_')[1],
|
||||
device_system_tag = n.name.Split('_')[2],
|
||||
device_name_tag = n.name.Split('_')[3],
|
||||
device_point_name = n.name.Split('_')[8],
|
||||
full_name = n.displayName,
|
||||
parent_path = oneStationName,
|
||||
isHistory = n.isHistory
|
||||
});
|
||||
}
|
||||
else if (n.name.Split('_').Length == 11) //Arena_D2_CWB_L110_CAP_D2_CWB_L110_CAP_MET1_ER
|
||||
{
|
||||
if (n.name.Split('_')[6] == "S" || n.name.Split('_')[6] == "CWB") //for security system and CWB system
|
||||
{
|
||||
result.Add(new ImpNiaItem {
|
||||
device_building_tag = n.name.Split('_')[5],
|
||||
device_system_tag = n.name.Split('_')[6],
|
||||
device_floor_tag = n.name.Split('_')[7],
|
||||
device_name_tag = n.name.Split('_')[8],
|
||||
device_point_name = n.name.Split('_')[10],
|
||||
full_name = n.displayName,
|
||||
parent_path = oneStationName,
|
||||
isHistory = n.isHistory
|
||||
});
|
||||
}
|
||||
else //for normal
|
||||
{
|
||||
result.Add(new ImpNiaItem
|
||||
{
|
||||
device_building_tag = n.name.Split('_')[5],
|
||||
//device_system_tag = n.name.Split('_')[1],
|
||||
device_floor_tag = n.name.Split('_')[7],
|
||||
device_name_tag = n.name.Split('_')[6],
|
||||
device_point_name = n.name.Split('_')[10],
|
||||
full_name = n.displayName,
|
||||
parent_path = oneStationName,
|
||||
isHistory = n.isHistory
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -631,29 +631,6 @@
|
||||
if ($("#device-item-sub-form").valid()) {
|
||||
$("#save-device-item-btn").html('<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>').attr("disabled", true);
|
||||
|
||||
var uurl = "/SystemCategory/HaveSamePoints";
|
||||
var ssend_data = {
|
||||
subId: selected_system_sub_guid,
|
||||
id: selected_system_device_item_guid,
|
||||
points: $('#device_sub_points_modal').val(),
|
||||
}
|
||||
$.post(uurl, ssend_data, function (rel) {
|
||||
if (rel.code != "0000") {
|
||||
$("#save-device-item-btn").html('確定').attr("disabled", false);
|
||||
if (rel.code == "9999") {
|
||||
toast_error(rel.msg);
|
||||
}
|
||||
else {
|
||||
toast_warning(rel.msg);
|
||||
}
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if (rel.data) {
|
||||
toast_warning("點位名稱已存在");
|
||||
$("#save-device-item-btn").html('確定').attr("disabled", false);
|
||||
}
|
||||
else {
|
||||
var url = "/SystemCategory/Savedevice_item";
|
||||
var send_data = {
|
||||
id: selected_system_device_item_guid,
|
||||
@ -690,12 +667,36 @@
|
||||
.fail(function (xhr, status, error) {
|
||||
$("#save-device-item-btn").html('確定').attr("disabled", false);
|
||||
});
|
||||
}
|
||||
}
|
||||
}, 'json')
|
||||
.fail(function (xhr, status, error) {
|
||||
$("#save-device-item-btn").html('確定').attr("disabled", false);
|
||||
});
|
||||
//var uurl = "/SystemCategory/HaveSamePoints";
|
||||
//var ssend_data = {
|
||||
// subId: selected_system_sub_guid,
|
||||
// id: selected_system_device_item_guid,
|
||||
// points: $('#device_sub_points_modal').val(),
|
||||
//}
|
||||
//$.post(uurl, ssend_data, function (rel) {
|
||||
// if (rel.code != "0000") {
|
||||
// $("#save-device-item-btn").html('確定').attr("disabled", false);
|
||||
// if (rel.code == "9999") {
|
||||
// toast_error(rel.msg);
|
||||
// }
|
||||
// else {
|
||||
// toast_warning(rel.msg);
|
||||
// }
|
||||
// return;
|
||||
// }
|
||||
// else {
|
||||
// if (rel.data) {
|
||||
// toast_warning("點位名稱已存在");
|
||||
// $("#save-device-item-btn").html('確定').attr("disabled", false);
|
||||
// }
|
||||
// else {
|
||||
|
||||
// }
|
||||
// }
|
||||
//}, 'json')
|
||||
//.fail(function (xhr, status, error) {
|
||||
// $("#save-device-item-btn").html('確定').attr("disabled", false);
|
||||
//});
|
||||
}
|
||||
}
|
||||
//#endregion
|
||||
|
@ -196,12 +196,33 @@ namespace Repository.BackendRepository.Implement
|
||||
sql = "delete from import_niagara_item where device_building_tag = '" + building + "'";
|
||||
await conn.ExecuteAsync(sql);
|
||||
#endregion
|
||||
ds = ds.GroupBy(x => new {
|
||||
device_area_tag = x.device_area_tag,
|
||||
device_building_tag = x.device_building_tag,
|
||||
device_system_tag = x.device_system_tag,
|
||||
device_name_tag = x.device_name_tag,
|
||||
device_point_name = x.device_point_name,
|
||||
full_name = x.full_name,
|
||||
parent_path = x.parent_path,
|
||||
isHistory = x.isHistory
|
||||
})
|
||||
.Select(x => new ImpNiaItem
|
||||
{
|
||||
device_area_tag = x.Key.device_area_tag,
|
||||
device_building_tag = x.Key.device_building_tag,
|
||||
device_system_tag = x.Key.device_system_tag,
|
||||
device_name_tag = x.Key.device_name_tag,
|
||||
device_point_name = x.Key.device_point_name,
|
||||
full_name = x.Key.full_name,
|
||||
parent_path = x.Key.parent_path,
|
||||
isHistory = x.Key.isHistory
|
||||
}).ToList();
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
#region 放入import_niagara_item資料表
|
||||
foreach (var row in ds)
|
||||
{
|
||||
sb.Append($@" insert import_niagara_item(device_area_tag, device_building_tag, device_system_tag, device_name_tag, device_point_name, parent_path, full_name)
|
||||
sb.Append($@" insert import_niagara_item(device_area_tag, device_building_tag, device_system_tag, device_name_tag, device_point_name, parent_path, full_name, is_history)
|
||||
values('"+
|
||||
row.device_area_tag + "', '" +
|
||||
row.device_building_tag + "', '" +
|
||||
@ -209,7 +230,8 @@ namespace Repository.BackendRepository.Implement
|
||||
row.device_name_tag + "', '" +
|
||||
row.device_point_name + "', '" +
|
||||
row.parent_path + "', '" +
|
||||
row.full_name + "'" +
|
||||
row.full_name + "'," +
|
||||
row.isHistory +
|
||||
");");
|
||||
}
|
||||
|
||||
@ -440,12 +462,14 @@ namespace Repository.BackendRepository.Implement
|
||||
{
|
||||
isBool = 1;
|
||||
}
|
||||
sb.Append($@"insert device_item(deleted, points, is_show, is_show_riserDiagram, is_controll, is_bool, is_link, is_show_history,
|
||||
sb.Append($@"insert device_item(deleted, points, is_show, is_show_riserDiagram, is_controll, is_bool, is_show_history, is_link,
|
||||
device_system_tag, device_name_tag, full_name, parent_path, created_at, updated_at)
|
||||
VALUES (0, '" +
|
||||
data.device_point_name + "', 1, 0, " +
|
||||
isControll + "," +
|
||||
isBool + ", 1, 1, '" +
|
||||
isBool + "," +
|
||||
data.is_history +
|
||||
", 1, '" +
|
||||
data.device_system_tag + "', '" +
|
||||
data.device_name_tag + "', '" +
|
||||
data.full_name + "', '" +
|
||||
@ -472,9 +496,11 @@ namespace Repository.BackendRepository.Implement
|
||||
//本次有匯入的 isLink 改為 1, 沒有的 isLink = 0
|
||||
sb.Append($@" SET SQL_SAFE_UPDATES = 0;
|
||||
UPDATE device_item d LEFT JOIN import_niagara_item m
|
||||
ON d.device_system_tag = m.device_system_tag and d.device_name_tag = m.device_name_tag and d.points = m.device_point_name
|
||||
ON d.device_system_tag = m.device_system_tag and d.device_name_tag = m.device_name_tag and d.points = m.device_point_name and d.full_name = m.full_name and d.is_show_history = m.is_history
|
||||
SET d.is_link = case when device_point_name is null then 0 else 1 end ,
|
||||
d.is_show_history = case when device_point_name is null then 0 else 1 end");
|
||||
d.is_show_history = case when device_point_name is null then 0 else 1 end
|
||||
where m.is_history = 1
|
||||
");
|
||||
|
||||
await conn.ExecuteAsync(sb.ToString());
|
||||
}
|
||||
@ -790,10 +816,10 @@ namespace Repository.BackendRepository.Implement
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
//先全部關閉
|
||||
sb.Append("update device_item set is_show_history=0;");
|
||||
sb.Append("update device_item set is_show_history = 1 " +
|
||||
"WHERE(device_system_tag, device_name_tag, points) IN " +
|
||||
"(select distinct device_system_tag, device_name_tag, device_point_name From import_niagara_item);");
|
||||
//sb.Append("update device_item set is_show_history=0;");
|
||||
sb.Append("update device_item set is_show_history = 0 " +
|
||||
"WHERE(device_system_tag, device_name_tag, points, full_name, is_show_history) NOT IN " +
|
||||
"(select distinct device_system_tag, device_name_tag, device_point_name, full_name, is_history From import_niagara_item where is_history = 1);");
|
||||
await conn.ExecuteAsync(sb.ToString());
|
||||
}
|
||||
catch (Exception exception)
|
||||
|
@ -95,6 +95,7 @@ namespace Repository.Models
|
||||
public string device_point_name { get; set; }
|
||||
public string full_name { get; set; }
|
||||
public string parent_path { get; set; }
|
||||
public bool is_history { get; set; }
|
||||
}
|
||||
|
||||
public class building_menu
|
||||
@ -121,11 +122,13 @@ namespace Repository.Models
|
||||
public string parent_path { get; set; }
|
||||
public string check_status { get; set; }
|
||||
public string full_name { get; set; }
|
||||
public bool isHistory { get; set; }
|
||||
}
|
||||
|
||||
public class control_point
|
||||
{
|
||||
public string name { get; set; }
|
||||
public string displayName { get; set; }
|
||||
public bool isHistory { get; set; }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user