[後端] 修改niagara程序
This commit is contained in:
parent
46447193b7
commit
917696275b
@ -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)
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
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('_')[4];
|
||||
row.device_name_tag = tagName.Split('_')[3];
|
||||
row.device_floor_tag = tagName.Split('_')[2];
|
||||
row.device_name_tag = tagName.Split('_')[3].Substring(1);
|
||||
row.device_point_name = tagName.Split('_')[5];
|
||||
row.parent_path = stationName;
|
||||
}
|
||||
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);
|
||||
|
@ -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>
|
||||
}
|
@ -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==" //巨蛋
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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==" //巨蛋
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -213,8 +213,16 @@ namespace Repository.BackendRepository.Implement
|
||||
");");
|
||||
}
|
||||
|
||||
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());");
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,6 +16,8 @@
|
||||
/// tag 段數
|
||||
/// </summary>
|
||||
public string tag_quantity { get; set; }
|
||||
public string Account { get; set; }
|
||||
public string Password { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user