Merge branch 'master' of https://gitea.mjm-staging.developers-homelab.net/BIMS/BIMS
This commit is contained in:
commit
bd65e50f85
@ -766,6 +766,7 @@ namespace Backend.Controllers
|
||||
await backendRepository.TruncateTable("device_node");
|
||||
|
||||
int node_priority = 1;
|
||||
|
||||
foreach (var idfc in post)
|
||||
{
|
||||
if (idfc.device_number.IndexOf("_LT_L1") > -1)
|
||||
@ -773,6 +774,12 @@ namespace Backend.Controllers
|
||||
//取得device_guid
|
||||
var sWhere = $@" deleted = 0 and device_number = '" + idfc.device_number + "'";
|
||||
var device_guid = await backendRepository.GetOneColAsync("device", sWhere, "device_guid");
|
||||
if (device_guid == null)
|
||||
{
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + "【ERROR:forge匯入不存在device設備】" + idfc.device_number);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (device_guid.ToString() != device_guid_record)
|
||||
{
|
||||
device_guid_record = device_guid.ToString();
|
||||
@ -785,13 +792,13 @@ namespace Backend.Controllers
|
||||
await backendRepository.UpdateOneByCustomTable(deviceForLight, "device", $@" device_guid = '{device_guid}'");
|
||||
}
|
||||
|
||||
//燈具
|
||||
Dictionary<string, object> device = new Dictionary<string, object>();
|
||||
device.Add("@device_node_guid", Guid.NewGuid());
|
||||
device.Add("@deleted", 0);
|
||||
device.Add("@device_guid", device_guid);
|
||||
device.Add("@device_node_coordinate_3d", idfc.device_coordinate_3d);
|
||||
device.Add("@forge_dbid", idfc.forge_dbid);
|
||||
device.Add("@device_node_coordinate_3d", (idfc.node == null) ? idfc.device_coordinate_3d: idfc.node.device_coordinate_3d);
|
||||
device.Add("@forge_dbid", (idfc.node == null) ? idfc.forge_dbid: idfc.node.forge_dbid);
|
||||
device.Add("@device_number", (idfc.node == null) ? idfc.device_number : idfc.node.device_number);
|
||||
device.Add("@priority", node_priority);
|
||||
device.Add("@created_by", myUserInfo.Userinfo_guid);
|
||||
device.Add("@created_at", DateTime.Now);
|
||||
@ -801,6 +808,7 @@ namespace Backend.Controllers
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.LogError("測試設備匯入:" + idfc.device_number);
|
||||
Dictionary<string, object> device = new Dictionary<string, object>();
|
||||
device.Add("@device_coordinate_3d", idfc.device_coordinate_3d);
|
||||
device.Add("@forge_dbid", idfc.forge_dbid);
|
||||
@ -808,6 +816,7 @@ namespace Backend.Controllers
|
||||
device.Add("@updated_at", DateTime.Now);
|
||||
await backendRepository.UpdateOneByCustomTable(device, "device", $@" device_number = '{idfc.device_number}'");
|
||||
}
|
||||
}
|
||||
//更新device資料表 room_dbid 欄位
|
||||
string sql = @"
|
||||
SET SQL_SAFE_UPDATES = 0;
|
||||
@ -821,7 +830,6 @@ namespace Backend.Controllers
|
||||
WHERE de.room_name = re.room_name;";
|
||||
await backendRepository.ExecuteSql(sql);
|
||||
}
|
||||
}
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Msg = "編輯成功";
|
||||
}
|
||||
|
@ -95,7 +95,8 @@ namespace Backend.Controllers
|
||||
{ "@created_by", myUserInfo.Userinfo_guid}
|
||||
};
|
||||
|
||||
if (actionName != "CompareData" && controllerName != "NiagaraDataSynchronize") //skip the log
|
||||
if ((actionName != "CompareData" && controllerName != "NiagaraDataSynchronize") &&
|
||||
(actionName != "ImportDevForCor" && controllerName != "DeviceImport")) //skip the log
|
||||
backendRepository.InsertOperatorLog(operatorLog, "operation_back_log");
|
||||
|
||||
//operatorLogRepository.Add(operatorLog, properties);
|
||||
|
@ -11,6 +11,7 @@ using Repository.Models;
|
||||
using System.Linq;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using Repository.Helper;
|
||||
|
||||
namespace Backend.Controllers
|
||||
{
|
||||
@ -19,11 +20,13 @@ namespace Backend.Controllers
|
||||
private readonly IBackendRepository backendRepository;
|
||||
//private readonly IDeviceImportRepository deviceImportRepository;
|
||||
private readonly INiagaraDataSynchronizeRepository niagaraDataSynchronizeRepository;
|
||||
public NiagaraDataSynchronizeController(IBackendRepository backendRepository, INiagaraDataSynchronizeRepository niagaraDataSynchronizeRepository)
|
||||
private readonly IBackEndConfigHelper backEndConfig;
|
||||
public NiagaraDataSynchronizeController(IBackendRepository backendRepository, INiagaraDataSynchronizeRepository niagaraDataSynchronizeRepository,IBackEndConfigHelper backEndConfig)
|
||||
{
|
||||
this.backendRepository = backendRepository;
|
||||
//this.deviceImportRepository = deviceImportRepository;
|
||||
this.niagaraDataSynchronizeRepository = niagaraDataSynchronizeRepository;
|
||||
this.backEndConfig = backEndConfig;
|
||||
}
|
||||
|
||||
public IActionResult Index()
|
||||
@ -43,16 +46,14 @@ namespace Backend.Controllers
|
||||
try
|
||||
{
|
||||
List<Device_value> ds;
|
||||
string url_slot = "slot:/TPE/B1|";//三菱
|
||||
//string url_slot = "slot:/NTPC/B1|";//wsp
|
||||
string url_slot = backEndConfig.GetUrlSlot();
|
||||
|
||||
string top100 = "";//" top 100 ";
|
||||
webRequestService svc = new webRequestService();
|
||||
string bql = url_slot + "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("http://192.168.0.136:8080/obix/config/Program/ObixQuery/query/", bql);//三菱
|
||||
//ds = svc.obixQuery("http://192.168.0.136:8081/obix/config/Program/ObixQuery/query/", bql);//wsp
|
||||
ds = svc.obixQuery(backEndConfig.GetobixQuery(), bql);//三菱
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Data = ds;
|
||||
@ -112,12 +113,10 @@ namespace Backend.Controllers
|
||||
try
|
||||
{
|
||||
List<ImpNiaItem> ds;
|
||||
string url_slot = "slot:/TPE/B1|";//三菱
|
||||
//string url_slot = "slot:/NTPC/B1|";//wsp
|
||||
string url_slot = backEndConfig.GetUrlSlot();
|
||||
|
||||
webRequestService svc = new webRequestService();
|
||||
ds = svc.obixHisQuery("http://192.168.0.136:8080/obix/config/Program/ObixQuery/query/", "http://192.168.0.136:8080/obix/histories", url_slot);//三菱
|
||||
//ds = svc.obixHisQuery("http://192.168.0.136:8081/obix/config/Program/ObixQuery/query/", "http://192.168.0.136:8081/obix/histories", url_slot);//wsp
|
||||
ds = svc.obixHisQuery(backEndConfig.GetobixHisBqlQuery(), backEndConfig.GetobixHisUrlQuery(), url_slot);//三菱
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Data = ds;
|
||||
|
@ -265,6 +265,19 @@ namespace Backend.Models
|
||||
}
|
||||
|
||||
public class ImportDevForCoo
|
||||
{
|
||||
public string device_number { get; set; }
|
||||
public string? device_coordinate_3d { get; set; }
|
||||
public int forge_dbid { get; set; }
|
||||
public string room_name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 燈具放在子類別 node 中
|
||||
/// </summary>
|
||||
public device_node? node { get; set; }
|
||||
}
|
||||
|
||||
public class device_node
|
||||
{
|
||||
public string device_number { get; set; }
|
||||
public string device_coordinate_3d { get; set; }
|
||||
|
@ -36,6 +36,10 @@ namespace Backend
|
||||
MySqlDBConfig = new MySqlDBConfig()
|
||||
};
|
||||
|
||||
public BackEndConfig BackEndConfig = new BackEndConfig()
|
||||
{
|
||||
NiagaraDataSyncConfig=new NiagaraDataSyncConfig()
|
||||
};
|
||||
public Startup(IConfiguration configuration)
|
||||
{
|
||||
Configuration = configuration;
|
||||
@ -56,6 +60,13 @@ namespace Backend
|
||||
dBConfig.MySqlDBConfig.Database = Configuration.GetValue<string>("DBConfig:MySqlDBConfig:Database");
|
||||
#endregion MySql DB Config
|
||||
|
||||
#region NiagaraDataSync Config
|
||||
BackEndConfig.NiagaraDataSyncConfig.UrlSlot = Configuration.GetValue<string>("BackEndConfig:NiagaraDataSyncConfig:UrlSlot");
|
||||
BackEndConfig.NiagaraDataSyncConfig.ObixQuery= Configuration.GetValue<string>("BackEndConfig:NiagaraDataSyncConfig:ObixQuery");
|
||||
BackEndConfig.NiagaraDataSyncConfig.ObixHisBqlQuery = Configuration.GetValue<string>("BackEndConfig:NiagaraDataSyncConfig:ObixHisBqlQuery");
|
||||
BackEndConfig.NiagaraDataSyncConfig.ObixHisUrlQuery = Configuration.GetValue<string>("BackEndConfig:NiagaraDataSyncConfig:ObixHisUrlQuery");
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
public IConfiguration Configuration { get; }
|
||||
@ -89,6 +100,13 @@ namespace Backend
|
||||
services.AddTransient<IDatabaseHelper, DatabaseHelper>();
|
||||
#endregion DBHelper ª`¤J
|
||||
|
||||
#region BackEndConfigHelper ª`¤J
|
||||
services.Configure<BackEndConfig>(Configuration.GetSection("BackEndConfig"));
|
||||
services.AddTransient<IBackEndConfigHelper, BackEndConfigHelper>();
|
||||
#endregion DBHelper ª`¤J
|
||||
|
||||
|
||||
|
||||
#region Repository ª`¤J
|
||||
services.AddTransient<IBackendRepository, BackendRepository>();
|
||||
services.AddTransient<IFrontendRepository, FrontendRepository>();
|
||||
|
@ -42,5 +42,17 @@
|
||||
// "Root": "+plVKQ+enAqt7BYV2uMQng==",
|
||||
// "Password": "0O24es2ZRF5uoJ4aU+YCdg=="
|
||||
//}
|
||||
},
|
||||
"BackEndConfig": {
|
||||
"NiagaraDataSyncConfig": {
|
||||
"UrlSlot": "GbZ+gly0WQOx1PO+Y4T1/A==", //WSP
|
||||
"ObixQuery": "7C/j7U8PmDqMxpb7f6gMpHNoRwKZ9K5QF8eWPaSWVNYQpjygWdccOOkHLWCOLi/+zCwsX2CcMhlAJ5082oeSiQ==", //WSP
|
||||
"ObixHisBqlQuery": "7C/j7U8PmDqMxpb7f6gMpHNoRwKZ9K5QF8eWPaSWVNYQpjygWdccOOkHLWCOLi/+zCwsX2CcMhlAJ5082oeSiQ==", //WSP
|
||||
"ObixHisUrlQuery": "7C/j7U8PmDqMxpb7f6gMpObRPTGh1jI6LBqMJk0hrp7UqBfP1mt4ADLSdmf4ubca" //WSP
|
||||
//"UrlSlot": "+I/QBiWGAk/BQZOwiz16gw==", //三菱
|
||||
//"ObixQuery": "7C/j7U8PmDqMxpb7f6gMpHFicuOA83OZeuWHBFdi/xpfEIklxyQ/wP75bEKwrdh+fXXgjmpc9cLX9GqbBC7eGw==", //三菱
|
||||
//"ObixHisBqlQuery": "7C/j7U8PmDqMxpb7f6gMpHFicuOA83OZeuWHBFdi/xpfEIklxyQ/wP75bEKwrdh+fXXgjmpc9cLX9GqbBC7eGw==", //三菱
|
||||
//"ObixHisUrlQuery": "7C/j7U8PmDqMxpb7f6gMpD06cJcRzpVx0+IAssROlE4MlzSDPojSI17+XkQIL9Eu" //三菱
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,8 +16,8 @@
|
||||
"MySqlDBConfig": {
|
||||
"Server": "FYlY+w0XDIz+jmF2rlZWJw==", //0.201
|
||||
"Port": "js2LutKe+rdjzdxMPQUrvQ==",
|
||||
"Database": "VJB2XC+lAtzuHObDGMVOAA==", //三菱
|
||||
//"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp
|
||||
//"Database": "VJB2XC+lAtzuHObDGMVOAA==", //三菱
|
||||
"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp
|
||||
"Root": "SzdxEgaJJ7tcTCrUl2zKsA==",
|
||||
"Password": "FVAPxztxpY4gJJKQ/se4bQ=="
|
||||
}
|
||||
@ -28,5 +28,17 @@
|
||||
// "Root": "+plVKQ+enAqt7BYV2uMQng==",
|
||||
// "Password": "0O24es2ZRF5uoJ4aU+YCdg=="
|
||||
//}
|
||||
},
|
||||
"BackEndConfig": {
|
||||
"NiagaraDataSyncConfig": {
|
||||
"UrlSlot": "GbZ+gly0WQOx1PO+Y4T1/A==", //WSP
|
||||
"ObixQuery": "7C/j7U8PmDqMxpb7f6gMpHNoRwKZ9K5QF8eWPaSWVNYQpjygWdccOOkHLWCOLi/+zCwsX2CcMhlAJ5082oeSiQ==", //WSP
|
||||
"ObixHisBqlQuery": "7C/j7U8PmDqMxpb7f6gMpHNoRwKZ9K5QF8eWPaSWVNYQpjygWdccOOkHLWCOLi/+zCwsX2CcMhlAJ5082oeSiQ==", //WSP
|
||||
"ObixHisUrlQuery": "7C/j7U8PmDqMxpb7f6gMpObRPTGh1jI6LBqMJk0hrp7UqBfP1mt4ADLSdmf4ubca" //WSP
|
||||
//"UrlSlot": "+I/QBiWGAk/BQZOwiz16gw==", //三菱
|
||||
//"ObixQuery": "7C/j7U8PmDqMxpb7f6gMpHFicuOA83OZeuWHBFdi/xpfEIklxyQ/wP75bEKwrdh+fXXgjmpc9cLX9GqbBC7eGw==", //三菱
|
||||
//"ObixHisBqlQuery": "7C/j7U8PmDqMxpb7f6gMpHFicuOA83OZeuWHBFdi/xpfEIklxyQ/wP75bEKwrdh+fXXgjmpc9cLX9GqbBC7eGw==", //三菱
|
||||
//"ObixHisUrlQuery": "7C/j7U8PmDqMxpb7f6gMpD06cJcRzpVx0+IAssROlE4MlzSDPojSI17+XkQIL9Eu" //三菱
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -416,6 +416,7 @@
|
||||
}
|
||||
|
||||
function ImportDevForCor() {//callback = null
|
||||
console.log(tagIdDevList)
|
||||
var url = "/DeviceImport/ImportDevForCor";
|
||||
|
||||
$.ajax({
|
||||
|
@ -354,7 +354,8 @@ function onDocumentLoadSuccess(doc) {
|
||||
device_number: item.displayValue,
|
||||
device_coordinate_3d: '{ "x": ' + (position.x).toFixed(2) + ', "y": ' + (position.y).toFixed(2) + ', "z": ' + (position.z).toFixed(2) + ' }',
|
||||
forge_dbid: e.dbId,
|
||||
room_name: ""
|
||||
room_name: "",
|
||||
node: null
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -73,6 +73,13 @@ namespace BackendWorkerService
|
||||
services.AddTransient<IDatabaseHelper, DatabaseHelper>();
|
||||
#endregion DBHelper ª`¤J
|
||||
|
||||
|
||||
#region BackEndConfigHelper ª`¤J
|
||||
services.Configure<BackEndConfig>(configuration.GetSection("BackEndConfig"));
|
||||
services.AddTransient<IBackEndConfigHelper, BackEndConfigHelper>();
|
||||
#endregion BackEndConfigHelper ª`¤J
|
||||
|
||||
|
||||
#region Repository ª`¤J
|
||||
services.AddTransient<IBackendRepository, BackendRepository>();
|
||||
services.AddTransient<IBackgroundServiceRepository, BackgroundServiceRepository>();
|
||||
|
@ -75,7 +75,7 @@ namespace FrontendWebApi.ApiControllers
|
||||
left join device_kind dk on v1.system_value = dk.device_system_tag and v2.system_value = dk.device_name_tag and dk.device_building_tag = @building_tag
|
||||
-- left join device_item di on v2.system_value = di.device_name_tag and v1.system_value = di.device_system_tag and di.deleted = 0
|
||||
join (
|
||||
select distinct main_system_tag, sub_system_tag from building_menu where building_tag = @building_tag
|
||||
select distinct main_system_tag, sub_system_tag from building_menu where building_tag = @building_tag and is_link = 1
|
||||
) as bm on v2.system_value = bm.sub_system_tag and v1.system_value = bm.main_system_tag
|
||||
where c.account = @account
|
||||
order by v2.system_priority", new { @account = myUser.account, @sub_system_type = sub_system_type, @main_system_type = main_system_type, @building_tag = fd.building_tag });
|
||||
|
57
Repository/Helper/BackEndConfigHelper.cs
Normal file
57
Repository/Helper/BackEndConfigHelper.cs
Normal file
@ -0,0 +1,57 @@
|
||||
using Microsoft.Extensions.Options;
|
||||
using Repository.Models;
|
||||
|
||||
namespace Repository.Helper
|
||||
{
|
||||
public interface IBackEndConfigHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 取得url_slot
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
string GetUrlSlot();
|
||||
|
||||
/// <summary>
|
||||
/// 取得obixQuery
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
string GetobixQuery();
|
||||
|
||||
string GetobixHisBqlQuery();
|
||||
|
||||
string GetobixHisUrlQuery();
|
||||
}
|
||||
|
||||
|
||||
public class BackEndConfigHelper : IBackEndConfigHelper
|
||||
{
|
||||
private NiagaraDataSyncConfig _NiagaraDataSyncConfig;
|
||||
private EDFunction ed;
|
||||
public BackEndConfigHelper(IOptions<BackEndConfig> BackEndConfig)
|
||||
{
|
||||
_NiagaraDataSyncConfig = BackEndConfig.Value.NiagaraDataSyncConfig;
|
||||
|
||||
ed = new EDFunction();
|
||||
}
|
||||
public string GetUrlSlot()
|
||||
{
|
||||
return ed.AESDecrypt(_NiagaraDataSyncConfig.UrlSlot);
|
||||
}
|
||||
public string GetobixQuery()
|
||||
{
|
||||
return ed.AESDecrypt(_NiagaraDataSyncConfig.ObixQuery);
|
||||
}
|
||||
|
||||
public string GetobixHisBqlQuery()
|
||||
{
|
||||
return ed.AESDecrypt(_NiagaraDataSyncConfig.ObixHisBqlQuery);
|
||||
}
|
||||
public string GetobixHisUrlQuery()
|
||||
{
|
||||
return ed.AESDecrypt(_NiagaraDataSyncConfig.ObixHisUrlQuery);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
17
Repository/Models/BackEndConfig.cs
Normal file
17
Repository/Models/BackEndConfig.cs
Normal file
@ -0,0 +1,17 @@
|
||||
namespace Repository.Models
|
||||
{
|
||||
public class BackEndConfig
|
||||
{
|
||||
public NiagaraDataSyncConfig NiagaraDataSyncConfig { get; set; }
|
||||
}
|
||||
|
||||
public class NiagaraDataSyncConfig
|
||||
{
|
||||
public string UrlSlot { get; set; }
|
||||
public string ObixQuery { get; set; }
|
||||
public string ObixHisBqlQuery { get; set; }
|
||||
public string ObixHisUrlQuery { get; set; }
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user