[後端] 修改niagara程序

This commit is contained in:
dev02 2023-04-21 17:40:18 +08:00
parent 46447193b7
commit 917696275b
9 changed files with 114 additions and 24 deletions

View File

@ -85,8 +85,9 @@ namespace Backend.Controllers
{
string ss = ds.Where(x => x.tag_name != "").FirstOrDefault().tag_name;
var building = ss.Split("_")[0];
var newDs = ds.Where(x => x.building == building).ToList();
string LightSwitchLevel = await niagaraDataSynchronizeRepository.getLightSwitchLevel(); //獲取照明開關 是否在 device or device_node
await niagaraDataSynchronizeRepository.InsertNiagaraTagList(ds, building, tag_quantity); // 匯入 MySQL table: import_niagara_tag
await niagaraDataSynchronizeRepository.InsertNiagaraTagList(newDs, building, tag_quantity); // 匯入 MySQL table: import_niagara_tag
await niagaraDataSynchronizeRepository.DeviceComparison(LightSwitchLevel);
await niagaraDataSynchronizeRepository.CheckDiffFullNameAndCover();
await niagaraDataSynchronizeRepository.CheckFullNameEmptyReplaceByDeviceName();
@ -111,7 +112,7 @@ namespace Backend.Controllers
/// </summary>
/// <returns></returns>
[HttpPost]
public Task<ApiResult<List<ImpNiaItem>>> RawDataDevItemList()
public Task<ApiResult<List<ImpNiaItem>>> RawDataDevItemList([FromBody] Device_value building)
{
ApiResult<List<ImpNiaItem>> apiResult = new ApiResult<List<ImpNiaItem>>();
@ -121,10 +122,10 @@ namespace Backend.Controllers
string url_slot = backEndConfig.GetUrlSlot();
webRequestService svc = new webRequestService();
ds = svc.obixHisQuery(backEndConfig.GetobixHisBqlQuery(), backEndConfig.GetobixHisUrlQuery(), url_slot);//三菱
ds = svc.obixHisQuery(backEndConfig.GetobixHisBqlQuery(), backEndConfig.GetobixHisUrlQuery(), url_slot, backEndConfig.Getobixtag_acc(), backEndConfig.Getobixtag_pass());//三菱
apiResult.Code = "0000";
apiResult.Data = ds;
apiResult.Data = ds.Where(x => x.device_building_tag == building.building).ToList(); ;
}
catch (Exception exception)
{

View File

@ -241,5 +241,28 @@ namespace Backend.Controllers
return apiResult;
}
[HttpPost]
public async Task<ApiResult<Variable>> ProjectName()
{
ApiResult<Variable> apiResult = new ApiResult<Variable>();
try
{
var variable = await backendRepository.GetOneAsync<Variable>("select * from variable where deleted = 0 and system_type = 'project_name';");
apiResult.Data = variable;
apiResult.Code = "0000";
apiResult.Msg = "成功";
}
catch (Exception exception)
{
apiResult.Code = "9999";
apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
}
return apiResult;
}
}
}

View File

@ -132,12 +132,14 @@ namespace Backend.Services.Implement
/// <param name="urlString"></param>
/// <param name="slot"></param>
/// <returns></returns>
public List<ImpNiaItem> obixHisQuery(string bqlUrlString, string urlString, string slot)
public List<ImpNiaItem> obixHisQuery(string bqlUrlString, string urlString, string slot, string acc, string pass)
{
//String username = "obixUser";
//String password = "Admin123456";
String username = "stanGG";
String password = "St12345678";
//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));
#region get control point data
@ -232,13 +234,24 @@ namespace Backend.Services.Implement
} else if (tagName.Split('_').Length == 6)
{ //巨蛋 tag 5 段版本
ImpNiaItem row = new ImpNiaItem();
row.device_building_tag = tagName.Split('_')[0];
row.device_system_tag = tagName.Split('_')[1];
row.device_floor_tag = tagName.Split('_')[4];
row.device_name_tag = tagName.Split('_')[3];
row.device_point_name = tagName.Split('_')[5];
row.parent_path = stationName;
if (tagName.Split('_')[1] == "S") //for security system
{
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_point_name = tagName.Split('_')[5];
}
else //for normal
{
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('_')[1];
row.device_point_name = tagName.Split('_')[5];
}
row.parent_path = stationName;
//full_name 其實是點位名稱 point_name
row.full_name = conPoint.Where(x => x.name == tagName).Select(x => x.displayName).FirstOrDefault();
result.Add(row);

View File

@ -21,7 +21,7 @@
<div class="col-12 mb-3">
<div class="custom-control custom-radio custom-control-inline">
<input type="radio" id="Building_B" name="Building" value="B" class="custom-control-input">
<label class="custom-control-label" for="Building_B">三菱B1</label>
<label class="custom-control-label" for="Building_B"></label>
</div>
@*<div class="custom-control custom-radio custom-control-inline">
<input type="radio" id="Building_O" name="Building" value="O" class="custom-control-input">
@ -85,9 +85,9 @@
$(function () {
ds = null;
building = "B1";
document.getElementById("Building_B").checked = true;
projectName();
rawDataImportTable = $("#niagara_data_table").DataTable({
"columns": [
{
@ -133,7 +133,7 @@
document.getElementById('loadDataText').innerText = "Loading...";
buildingId = document.querySelector('input[name="Building"]:checked').value;
if (buildingId == "B") {
building = "B1";
//building = "B1";
rawDataImportTable.ajax.reload();
}
}
@ -180,10 +180,16 @@
//比對資料有差異的話再同步到device等資料表
var url_synchronize_data = "/NiagaraDataSynchronize/RawDataDevItemList/";
var url_synchronize_data_device_item = "/NiagaraDataSynchronize/DevIteComData/";
let object = {};
object.building = building;
$.ajax({
method: "POST",
url: url_synchronize_data,
cache: false,
async: false,
contentType: "application/json; charset=UTF-8",
data: JSON.stringify(object),
dataType: 'json',
success: function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
@ -218,5 +224,25 @@
},
});
}
function projectName()
{
$.post("/Variable/ProjectName", null, function (rel) {
building = "B1";
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
if (rel.data != null) {
building = rel.data.system_value.split('/')[1];
$(`label[for='Building_B']`).html(rel.data.system_key + building);
}
else
{
$(`label[for='Building_B']`).html('三菱B1');
}
}, 'json');
}
</script>
}

View File

@ -56,13 +56,17 @@
//"ObixQuery": "7C/j7U8PmDqMxpb7f6gMpHFicuOA83OZeuWHBFdi/xpfEIklxyQ/wP75bEKwrdh+fXXgjmpc9cLX9GqbBC7eGw==", //
//"ObixHisBqlQuery": "7C/j7U8PmDqMxpb7f6gMpHFicuOA83OZeuWHBFdi/xpfEIklxyQ/wP75bEKwrdh+fXXgjmpc9cLX9GqbBC7eGw==", //
//"ObixHisUrlQuery": "7C/j7U8PmDqMxpb7f6gMpD06cJcRzpVx0+IAssROlE4MlzSDPojSI17+XkQIL9Eu" //
//"Account": "UnUq+XFB1pEDdz8OId/kaA==", //
//"Password": "CQC+JFF11YW+axvka4WOKQ==", //
"UrlSlot": "e1dUH6340WkFoHPJYq7IYQ==", // D2
//"UrlSlot": "f9cDBTw5PCfbDTOt4Kwbew==", // slot:/Arena/H|
"ObixQuery": "7C/j7U8PmDqMxpb7f6gMpIDkLYyNwmXoqhx+N1G+fqQxEETrRbFLZfC7Sud5yX24CphfLlSUbfjft7gcP6v+gw==", // http://192.168.0.136:8082/obix/config/Program/ObixQuery/query/
"ObixHisBqlQuery": "7C/j7U8PmDqMxpb7f6gMpIDkLYyNwmXoqhx+N1G+fqQxEETrRbFLZfC7Sud5yX24CphfLlSUbfjft7gcP6v+gw==", // http://192.168.0.136:8082/obix/config/Program/ObixQuery/query/
"ObixHisUrlQuery": "7C/j7U8PmDqMxpb7f6gMpEVUZrrjJT0WiTUBn0FzipXfBFsxYAX3plIWBcJ+oZzW", // http://192.168.0.136:8081/obix/histories
"tag_quantity": "AeqCvTnIRIpvQcjBfwi+qg=="
"tag_quantity": "AeqCvTnIRIpvQcjBfwi+qg==",
"Account": "FMiVG4sIeDFmAUc/8Hn/kw==", //
"Password": "4+ussQ8rHohjPWpNvoujJQ==" //
}
}
}

View File

@ -44,12 +44,16 @@
//"ObixHisBqlQuery": "7C/j7U8PmDqMxpb7f6gMpHFicuOA83OZeuWHBFdi/xpfEIklxyQ/wP75bEKwrdh+fXXgjmpc9cLX9GqbBC7eGw==", //
//"ObixHisUrlQuery": "7C/j7U8PmDqMxpb7f6gMpD06cJcRzpVx0+IAssROlE4MlzSDPojSI17+XkQIL9Eu" //
//"tag_quantity": "fFA0lNwg5d/4ZNzWrPbVzw==" 8
//"Account": "UnUq+XFB1pEDdz8OId/kaA==", //
//"Password": "CQC+JFF11YW+axvka4WOKQ==", //
"UrlSlot": "e1dUH6340WkFoHPJYq7IYQ==", // D2
"ObixQuery": "7C/j7U8PmDqMxpb7f6gMpIDkLYyNwmXoqhx+N1G+fqQxEETrRbFLZfC7Sud5yX24CphfLlSUbfjft7gcP6v+gw==", // http://192.168.0.136:8082/obix/config/Program/ObixQuery/query/
"ObixHisBqlQuery": "7C/j7U8PmDqMxpb7f6gMpIDkLYyNwmXoqhx+N1G+fqQxEETrRbFLZfC7Sud5yX24CphfLlSUbfjft7gcP6v+gw==", // http://192.168.0.136:8082/obix/config/Program/ObixQuery/query/
"ObixHisUrlQuery": "7C/j7U8PmDqMxpb7f6gMpEVUZrrjJT0WiTUBn0FzipXfBFsxYAX3plIWBcJ+oZzW", // http://192.168.0.136:8081/obix/histories
"tag_quantity": "AeqCvTnIRIpvQcjBfwi+qg==" // 5
"tag_quantity": "AeqCvTnIRIpvQcjBfwi+qg==", // 5
"Account": "FMiVG4sIeDFmAUc/8Hn/kw==", //
"Password": "4+ussQ8rHohjPWpNvoujJQ==" //
}
}
}

View File

@ -212,9 +212,17 @@ namespace Repository.BackendRepository.Implement
row.full_name + "'" +
");");
}
var isDome = await GetOneAsync<string>("select system_value from variable where deleted = 0 and system_type = 'project_name';");
if (sb.Length > 0)
{
if (isDome == "ibms_dome_dome/D2")
{
sb.Append($@" update import_niagara_item a join dic_system b
on a.device_name_tag COLLATE utf8mb4_general_ci = b.s2_code
set device_system_tag = b.s1_code
where device_system_tag <> 'S'");
}
await conn.ExecuteAsync(sb.ToString());
sb.Clear();
}
@ -439,8 +447,8 @@ namespace Repository.BackendRepository.Implement
isControll + "," +
isBool + ", 1, 1, '" +
data.device_system_tag + "', '" +
data.device_name_tag + "', " +
data.full_name + "', " +
data.device_name_tag + "', '" +
data.full_name + "', '" +
data.parent_path + "', " +
"now(), now());");
}

View File

@ -26,6 +26,8 @@ namespace Repository.Helper
/// </summary>
/// <returns></returns>
string Getobixtag_quantity();
string Getobixtag_acc();
string Getobixtag_pass();
}
@ -60,7 +62,14 @@ namespace Repository.Helper
{
return ed.AESDecrypt(_NiagaraDataSyncConfig.tag_quantity);
}
public string Getobixtag_acc()
{
return ed.AESDecrypt(_NiagaraDataSyncConfig.Account);
}
public string Getobixtag_pass()
{
return ed.AESDecrypt(_NiagaraDataSyncConfig.Password);
}
}
}

View File

@ -16,6 +16,8 @@
/// tag 段數
/// </summary>
public string tag_quantity { get; set; }
public string Account { get; set; }
public string Password { get; set; }
}