This commit is contained in:
Celeste 2023-03-06 11:38:44 +08:00
commit bd65e50f85
13 changed files with 833 additions and 687 deletions

File diff suppressed because it is too large Load Diff

View File

@ -95,7 +95,8 @@ namespace Backend.Controllers
{ "@created_by", myUserInfo.Userinfo_guid} { "@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"); backendRepository.InsertOperatorLog(operatorLog, "operation_back_log");
//operatorLogRepository.Add(operatorLog, properties); //operatorLogRepository.Add(operatorLog, properties);

View File

@ -11,6 +11,7 @@ using Repository.Models;
using System.Linq; using System.Linq;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using NPOI.SS.Formula.Functions; using NPOI.SS.Formula.Functions;
using Repository.Helper;
namespace Backend.Controllers namespace Backend.Controllers
{ {
@ -19,11 +20,13 @@ namespace Backend.Controllers
private readonly IBackendRepository backendRepository; private readonly IBackendRepository backendRepository;
//private readonly IDeviceImportRepository deviceImportRepository; //private readonly IDeviceImportRepository deviceImportRepository;
private readonly INiagaraDataSynchronizeRepository niagaraDataSynchronizeRepository; 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.backendRepository = backendRepository;
//this.deviceImportRepository = deviceImportRepository; //this.deviceImportRepository = deviceImportRepository;
this.niagaraDataSynchronizeRepository = niagaraDataSynchronizeRepository; this.niagaraDataSynchronizeRepository = niagaraDataSynchronizeRepository;
this.backEndConfig = backEndConfig;
} }
public IActionResult Index() public IActionResult Index()
@ -43,16 +46,14 @@ namespace Backend.Controllers
try try
{ {
List<Device_value> ds; List<Device_value> ds;
string url_slot = "slot:/TPE/B1|";//三菱 string url_slot = backEndConfig.GetUrlSlot();
//string url_slot = "slot:/NTPC/B1|";//wsp
string top100 = "";//" top 100 "; string top100 = "";//" top 100 ";
webRequestService svc = new webRequestService(); webRequestService svc = new webRequestService();
string bql = url_slot + "bql:select " + top100 + " * from baja:Folder "; 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://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://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(backEndConfig.GetobixQuery(), bql);//三菱
//ds = svc.obixQuery("http://192.168.0.136:8081/obix/config/Program/ObixQuery/query/", bql);//wsp
apiResult.Code = "0000"; apiResult.Code = "0000";
apiResult.Data = ds; apiResult.Data = ds;
@ -112,12 +113,10 @@ namespace Backend.Controllers
try try
{ {
List<ImpNiaItem> ds; List<ImpNiaItem> ds;
string url_slot = "slot:/TPE/B1|";//三菱 string url_slot = backEndConfig.GetUrlSlot();
//string url_slot = "slot:/NTPC/B1|";//wsp
webRequestService svc = new webRequestService(); 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(backEndConfig.GetobixHisBqlQuery(), backEndConfig.GetobixHisUrlQuery(), 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
apiResult.Code = "0000"; apiResult.Code = "0000";
apiResult.Data = ds; apiResult.Data = ds;

View File

@ -265,6 +265,19 @@ namespace Backend.Models
} }
public class ImportDevForCoo 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_number { get; set; }
public string device_coordinate_3d { get; set; } public string device_coordinate_3d { get; set; }

View File

@ -36,6 +36,10 @@ namespace Backend
MySqlDBConfig = new MySqlDBConfig() MySqlDBConfig = new MySqlDBConfig()
}; };
public BackEndConfig BackEndConfig = new BackEndConfig()
{
NiagaraDataSyncConfig=new NiagaraDataSyncConfig()
};
public Startup(IConfiguration configuration) public Startup(IConfiguration configuration)
{ {
Configuration = configuration; Configuration = configuration;
@ -56,6 +60,13 @@ namespace Backend
dBConfig.MySqlDBConfig.Database = Configuration.GetValue<string>("DBConfig:MySqlDBConfig:Database"); dBConfig.MySqlDBConfig.Database = Configuration.GetValue<string>("DBConfig:MySqlDBConfig:Database");
#endregion MySql DB Config #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; } public IConfiguration Configuration { get; }
@ -89,6 +100,13 @@ namespace Backend
services.AddTransient<IDatabaseHelper, DatabaseHelper>(); services.AddTransient<IDatabaseHelper, DatabaseHelper>();
#endregion DBHelper ª`¤J #endregion DBHelper ª`¤J
#region BackEndConfigHelper ª`¤J
services.Configure<BackEndConfig>(Configuration.GetSection("BackEndConfig"));
services.AddTransient<IBackEndConfigHelper, BackEndConfigHelper>();
#endregion DBHelper ª`¤J
#region Repository ª`¤J #region Repository ª`¤J
services.AddTransient<IBackendRepository, BackendRepository>(); services.AddTransient<IBackendRepository, BackendRepository>();
services.AddTransient<IFrontendRepository, FrontendRepository>(); services.AddTransient<IFrontendRepository, FrontendRepository>();

View File

@ -42,5 +42,17 @@
// "Root": "+plVKQ+enAqt7BYV2uMQng==", // "Root": "+plVKQ+enAqt7BYV2uMQng==",
// "Password": "0O24es2ZRF5uoJ4aU+YCdg==" // "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" //
}
} }
} }

View File

@ -16,8 +16,8 @@
"MySqlDBConfig": { "MySqlDBConfig": {
"Server": "FYlY+w0XDIz+jmF2rlZWJw==", //0.201 "Server": "FYlY+w0XDIz+jmF2rlZWJw==", //0.201
"Port": "js2LutKe+rdjzdxMPQUrvQ==", "Port": "js2LutKe+rdjzdxMPQUrvQ==",
"Database": "VJB2XC+lAtzuHObDGMVOAA==", // //"Database": "VJB2XC+lAtzuHObDGMVOAA==", //
//"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp "Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp
"Root": "SzdxEgaJJ7tcTCrUl2zKsA==", "Root": "SzdxEgaJJ7tcTCrUl2zKsA==",
"Password": "FVAPxztxpY4gJJKQ/se4bQ==" "Password": "FVAPxztxpY4gJJKQ/se4bQ=="
} }
@ -28,5 +28,17 @@
// "Root": "+plVKQ+enAqt7BYV2uMQng==", // "Root": "+plVKQ+enAqt7BYV2uMQng==",
// "Password": "0O24es2ZRF5uoJ4aU+YCdg==" // "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" //
}
} }
} }

View File

@ -416,6 +416,7 @@
} }
function ImportDevForCor() {//callback = null function ImportDevForCor() {//callback = null
console.log(tagIdDevList)
var url = "/DeviceImport/ImportDevForCor"; var url = "/DeviceImport/ImportDevForCor";
$.ajax({ $.ajax({

View File

@ -354,7 +354,8 @@ function onDocumentLoadSuccess(doc) {
device_number: item.displayValue, device_number: item.displayValue,
device_coordinate_3d: '{ "x": ' + (position.x).toFixed(2) + ', "y": ' + (position.y).toFixed(2) + ', "z": ' + (position.z).toFixed(2) + ' }', device_coordinate_3d: '{ "x": ' + (position.x).toFixed(2) + ', "y": ' + (position.y).toFixed(2) + ', "z": ' + (position.z).toFixed(2) + ' }',
forge_dbid: e.dbId, forge_dbid: e.dbId,
room_name: "" room_name: "",
node: null
}) })
} }
} }

View File

@ -73,6 +73,13 @@ namespace BackendWorkerService
services.AddTransient<IDatabaseHelper, DatabaseHelper>(); services.AddTransient<IDatabaseHelper, DatabaseHelper>();
#endregion DBHelper ª`¤J #endregion DBHelper ª`¤J
#region BackEndConfigHelper ª`¤J
services.Configure<BackEndConfig>(configuration.GetSection("BackEndConfig"));
services.AddTransient<IBackEndConfigHelper, BackEndConfigHelper>();
#endregion BackEndConfigHelper ª`¤J
#region Repository ª`¤J #region Repository ª`¤J
services.AddTransient<IBackendRepository, BackendRepository>(); services.AddTransient<IBackendRepository, BackendRepository>();
services.AddTransient<IBackgroundServiceRepository, BackgroundServiceRepository>(); services.AddTransient<IBackgroundServiceRepository, BackgroundServiceRepository>();

View File

@ -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_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 -- 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 ( 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 ) as bm on v2.system_value = bm.sub_system_tag and v1.system_value = bm.main_system_tag
where c.account = @account 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 }); 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 });

View 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);
}
}
}

View 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; }
}
}