[後端] 修改同步device item is_history, 修改燈控排程api, 修改區域選單的left join 問題

This commit is contained in:
dev02 2023-09-26 15:54:02 +08:00
parent 9a3b098ee0
commit c324a37fe9
5 changed files with 30 additions and 26 deletions

View File

@ -383,9 +383,9 @@ namespace Backend.Controllers
from building_menu bm
join variable mv on bm.main_system_tag = mv.system_value and mv.system_type = @main_system_type and mv.deleted = 0
join variable sv on bm.sub_system_tag = sv.system_value and sv.system_type = @sub_system_type and sv.deleted = 0
join floor lf on lf.floor_guid = bm.left_planimetric_floor_guid
join floor rf on rf.floor_guid = bm.right_planimetric_floor_guid
where bm.building_tag = @building_tag and bm.main_system_tag in @MainList
left join floor lf on lf.floor_guid = bm.left_planimetric_floor_guid
left join floor rf on rf.floor_guid = bm.right_planimetric_floor_guid
where bm.building_tag = @building_tag and bm.main_system_tag in @MainList and bm.is_link > 0
ORDER BY bm.priority, mv.system_priority ASC, sv.system_priority ASC, sv.created_at DESC ",
new { building_tag = post.building_tag, MainList = post.MainList, main_system_type = main_system_type, sub_system_type = sub_system_type });

View File

@ -235,23 +235,23 @@ namespace Backend.Services.Implement
result.Add(row);
}
else if (tagName.Split('_').Length == 7)
else if (tagName.Split('_').Length == 6)
{ //巨蛋 tag 5 段版本
ImpNiaItem row = new ImpNiaItem();
if (tagName.Split('_')[2] == "S" || tagName.Split('_')[2] == "B" || tagName.Split('_')[2] == "CWB") //for security system and parking system
if (tagName.Split('_')[1] == "S" || tagName.Split('_')[1] == "B" || tagName.Split('_')[1] == "CWB") //for security system and parking system
{
row.device_building_tag = tagName.Split('_')[1];
row.device_system_tag = tagName.Split('_')[2];
row.device_floor_tag = tagName.Split('_')[3];
row.device_name_tag = tagName.Split('_')[4];
row.device_point_name = tagName.Split('_')[6];
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];
row.device_point_name = tagName.Split('_')[5];
}
else //for normal
{
row.device_building_tag = tagName.Split('_')[1];
row.device_floor_tag = tagName.Split('_')[3];
row.device_name_tag = tagName.Split('_')[2];
row.device_point_name = tagName.Split('_')[6];
row.device_building_tag = tagName.Split('_')[0];
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;

View File

@ -22,8 +22,8 @@
//"Database": "siTUcDaC/g2yGTMFWD72Kg==", //tpe_dome_hotel
//"Database": "iuaY0h0+TWkir44/eZLDqw==", //tpe_dome_office
//"Database": "Rq7Gn4x6LwBvVtl7GY8LbA==", //mcut
"Database": "+5RAiFLJVU+LRyDxF1K/pcLZaoZa4k/thZqF6xKoCag=", //dome_online_0821
//"Database": "2U+9jYGy0dCbMzLaguBXow==", //tpe_dome_mall
//"Database": "+5RAiFLJVU+LRyDxF1K/pcLZaoZa4k/thZqF6xKoCag=", //dome_online_0821
"Database": "2U+9jYGy0dCbMzLaguBXow==", //tpe_dome_mall
//"Database": "FbHCCU4CapG9UryANXC1W+iMe403Bd82RnA7bCNVbL0=", //ibms_dome_cinema,
"Root": "SzdxEgaJJ7tcTCrUl2zKsA==",
"Password": "FVAPxztxpY4gJJKQ/se4bQ=="

View File

@ -1,7 +1,9 @@
using FrontendWebApi.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Repository.BackendRepository.Implement;
using Repository.BackendRepository.Interface;
using Repository.FrontendRepository.Interface;
using System;
@ -46,7 +48,7 @@ namespace FrontendWebApi.ApiControllers
",new { floor_guid = post.floor_guid});
lightDevices = await backendRepository.GetAllAsync<lightDevice>($@"
select * from device where device_building_tag = '{post.building_tag}' and device_name_tag = '{post.sub_system_tag}' and device_floor_tag = '{floor_tag}' and deleted = 0 and status = 0 order by priority
select * from device where device_building_tag = '{post.building_tag}' and device_name_tag = '{post.sub_system_tag}' and device_floor_tag = '{floor_tag}' and deleted = 0 order by priority
");
if(!String.IsNullOrEmpty(post.schedule_guid))
@ -326,13 +328,18 @@ namespace FrontendWebApi.ApiControllers
}
var deviceNumList = await backendRepository.GetAllAsync<string>(@$"select d.device_number from schedule_device sd left join device d on sd.device_guid = d.device_guid
where light_schedule_guid = '{guid}'");
where light_schedule_guid = '
{guid}'");
foreach(var deviceNum in deviceNumList)
var variableObix = await backendRepository.GetAllAsync<KeyValue>("SELECT system_value as Value, system_key as Name FROM variable WHERE deleted = 0 AND system_type = 'obixConfig'");
string url = variableObix.Where(x => x.Name == "ApiBase").Select(x => x.Value).FirstOrDefault();
string account = variableObix.Where(x => x.Name == "UserName").Select(x => x.Value).FirstOrDefault();
string pass = variableObix.Where(x => x.Name == "Password").Select(x => x.Value).FirstOrDefault();
foreach (var deviceNum in deviceNumList)
{
var d = deviceNum.Split("_");
var html = "http://greencloud.fic.com.tw:8080/obix/config/Arena/"+$"{d[0]}/{d[1]}/{d[2]}/{d[3]}/{deviceNum}/SSC/set";
string authInfo = "AR_Light" + ":" + "Light12345";
var html = $"{url}/obix/config/Arena/" + $"{d[0]}/{d[1]}/{d[2]}/{d[3]}/{deviceNum}/SSC/set";
string authInfo = account + ":" + pass;
authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo));
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(html);
request.Method = "POST";

View File

@ -630,9 +630,7 @@ namespace Repository.BackendRepository.Implement
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
SET d.is_link = CASE WHEN m.device_point_name IS NULL THEN 0 ELSE 1 END;
");
SET d.is_link = CASE WHEN m.device_point_name IS NULL THEN 0 ELSE 1 END;");
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
{
@ -651,8 +649,7 @@ namespace Repository.BackendRepository.Implement
ON d.device_system_tag = subquery.device_system_tag
AND d.device_name_tag = subquery.device_name_tag
AND d.points = subquery.device_point_name
SET d.is_show_history = CASE WHEN subquery.device_point_name IS NULL THEN 0 ELSE 1 END
WHERE (d.is_show_history);");
SET d.is_show_history = CASE WHEN subquery.device_point_name IS NULL THEN 0 ELSE 1 END");
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
{