[後台] 修改區域選單管理
This commit is contained in:
parent
9e583a5b9c
commit
6fbc9b41fb
@ -19,8 +19,6 @@ namespace Backend.Controllers
|
|||||||
{
|
{
|
||||||
private readonly IBackendRepository backendRepository;
|
private readonly IBackendRepository backendRepository;
|
||||||
private string mapFileSaveAsPath = "";
|
private string mapFileSaveAsPath = "";
|
||||||
private string main_system_name = "device_system_category_layer2";
|
|
||||||
private string sub_system_name = "device_system_category_layer1";
|
|
||||||
|
|
||||||
public BuildInfoController(IBackendRepository backendRepository)
|
public BuildInfoController(IBackendRepository backendRepository)
|
||||||
{
|
{
|
||||||
@ -546,7 +544,7 @@ namespace Backend.Controllers
|
|||||||
|
|
||||||
//判斷區域選單是否還有使用該樓層
|
//判斷區域選單是否還有使用該樓層
|
||||||
var sub_system_where = $@"SELECT
|
var sub_system_where = $@"SELECT
|
||||||
CONCAT(b.full_name, ' - ', v1.system_key, ' - ', v2.system_key)
|
CONCAT(b.full_name, ' - ', mv.system_key, ' - ', sv.system_key)
|
||||||
FROM (
|
FROM (
|
||||||
SELECT
|
SELECT
|
||||||
ssf.building_tag,
|
ssf.building_tag,
|
||||||
@ -556,10 +554,10 @@ namespace Backend.Controllers
|
|||||||
WHERE ssf.deleted = 0 AND ssf.floor_tag = @floor_tag
|
WHERE ssf.deleted = 0 AND ssf.floor_tag = @floor_tag
|
||||||
) ssf
|
) ssf
|
||||||
LEFT JOIN building b ON ssf.building_tag = b.building_tag AND b.deleted = 0
|
LEFT JOIN building b ON ssf.building_tag = b.building_tag AND b.deleted = 0
|
||||||
LEFT JOIN variable v1 ON ssf.main_system_tag = v1.system_value AND v1.system_type = @main_system_type AND v1.deleted = 0
|
LEFT JOIN variable mv ON ssf.main_system_tag = mv.system_value AND mv.system_type = @main_system_type AND mv.deleted = 0
|
||||||
LEFT JOIN variable v2 ON ssf.sub_system_tag = v2.system_value AND v2.system_type = @sub_system_type AND v2.deleted = 0";
|
LEFT JOIN variable sv ON ssf.sub_system_tag = sv.system_value AND sv.system_type = @sub_system_type AND sv.deleted = 0";
|
||||||
|
|
||||||
var sub_system_floors = await backendRepository.GetAllAsync<string>(sub_system_where, new { floor_tag = buildFloor.Full_name, main_system_type = main_system_name, sub_system_type = sub_system_name });
|
var sub_system_floors = await backendRepository.GetAllAsync<string>(sub_system_where, new { floor_tag = buildFloor.Full_name, main_system_type = main_system_type, sub_system_type = sub_system_type });
|
||||||
if (sub_system_floors.Count > 0)
|
if (sub_system_floors.Count > 0)
|
||||||
{
|
{
|
||||||
apiResult.Code = "9997";
|
apiResult.Code = "9997";
|
||||||
|
@ -29,7 +29,7 @@ namespace Backend.Controllers
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var sqlString = @$"select building_guid as Value, full_name as Name from building a where a.deleted = 0 and a.status = 0 ORDER BY a.priority ASC, a.created_at DESC";
|
var sqlString = @$"select building_tag as Value, full_name as Name from building a where a.deleted = 0 and a.status = 0 ORDER BY a.priority ASC, a.created_at DESC";
|
||||||
KeyValue = await backendRepository.GetAllAsync<KeyValue>(sqlString);
|
KeyValue = await backendRepository.GetAllAsync<KeyValue>(sqlString);
|
||||||
|
|
||||||
apiResult.Code = "0000";
|
apiResult.Code = "0000";
|
||||||
@ -45,15 +45,22 @@ namespace Backend.Controllers
|
|||||||
return apiResult;
|
return apiResult;
|
||||||
}
|
}
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<ApiResult<List<KeyValue>>> MainListBybuild(string build)
|
public async Task<ApiResult<List<KeyValue>>> MainListBybuild(string building_tag)
|
||||||
{
|
{
|
||||||
ApiResult<List<KeyValue>> apiResult = new ApiResult<List<KeyValue>>();
|
ApiResult<List<KeyValue>> apiResult = new ApiResult<List<KeyValue>>();
|
||||||
List<KeyValue> KeyValue = new List<KeyValue>();
|
List<KeyValue> KeyValue = new List<KeyValue>();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var sqlString = @$"select ms.main_system_guid value, ms.full_name name from (select main_system_guid from building_menu bm where bm.building_guid = '{build}' group by bm.main_system_guid ) bm left join main_system ms on ms.main_system_guid = bm.main_system_guid ORDER BY ms.priority ASC";
|
var sqlString = @$"select v.system_value value, v.system_key name
|
||||||
KeyValue = await backendRepository.GetAllAsync<KeyValue>(sqlString);
|
from (
|
||||||
|
select main_system_tag from building_menu bm where bm.building_tag = @building_tag group by bm.main_system_tag
|
||||||
|
) bm
|
||||||
|
left join variable v on v.system_value = bm.main_system_tag AND v.system_type = @main_system_type and v.deleted = 0
|
||||||
|
ORDER BY v.system_priority ASC";
|
||||||
|
|
||||||
|
var param = new { building_tag = building_tag, main_system_type = main_system_type };
|
||||||
|
KeyValue = await backendRepository.GetAllAsync<KeyValue>(sqlString, param);
|
||||||
|
|
||||||
apiResult.Code = "0000";
|
apiResult.Code = "0000";
|
||||||
apiResult.Data = KeyValue;
|
apiResult.Data = KeyValue;
|
||||||
@ -74,8 +81,13 @@ namespace Backend.Controllers
|
|||||||
List<KeyValue> KeyValue = new List<KeyValue>();
|
List<KeyValue> KeyValue = new List<KeyValue>();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var sqlString = @$"select ms.full_name Name,ms.main_system_guid Value from main_system ms where ms.deleted = 0 and ms.status = 0 ORDER BY ms.priority ASC";
|
var sqlString = @$"select system_key Name, system_value Value
|
||||||
KeyValue = await backendRepository.GetAllAsync<KeyValue>(sqlString);
|
from variable
|
||||||
|
where deleted = 0 and system_type = @main_system_type
|
||||||
|
ORDER BY system_priority ASC";
|
||||||
|
|
||||||
|
var param = new { main_system_type = main_system_type };
|
||||||
|
KeyValue = await backendRepository.GetAllAsync<KeyValue>(sqlString, param);
|
||||||
|
|
||||||
apiResult.Code = "0000";
|
apiResult.Code = "0000";
|
||||||
apiResult.Data = KeyValue;
|
apiResult.Data = KeyValue;
|
||||||
@ -96,14 +108,16 @@ namespace Backend.Controllers
|
|||||||
List<KeyValue> KeyValue = new List<KeyValue>();
|
List<KeyValue> KeyValue = new List<KeyValue>();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
var mainList = await backendRepository.GetAllAsync<int>("select id from variable where system_value = @main_system_tag and system_type = @main_system_type", new { main_system_tag = post.main_system_tag, main_system_type = main_system_type});
|
||||||
var sqlString = @$"select
|
var sqlString = @$"select
|
||||||
ss.sub_system_guid value,ss.full_name name
|
sv.system_value value, sv.system_key name
|
||||||
from sub_system ss
|
from variable sv
|
||||||
left join (
|
left join (
|
||||||
select * from building_menu bm where bm.building_guid = '{post.build}') bm
|
select * from building_menu bm where bm.building_tag = @building_tag
|
||||||
on ss.sub_system_guid = bm.sub_system_guid
|
) bm
|
||||||
where bm.sub_system_guid is null and ss.deleted = 0 and ss.status = 0 and ss.main_system_guid = @guid ORDER BY ss.priority ASC, ss.created_at DESC";
|
on sv.system_value = bm.sub_system_tag
|
||||||
KeyValue = await backendRepository.GetAllAsync<KeyValue>(sqlString, new { guid = post.main });
|
where bm.sub_system_tag is null and sv.deleted = 0 and sv.system_parent_id in @mainList ORDER BY sv.system_priority ASC, sv.created_at DESC";
|
||||||
|
KeyValue = await backendRepository.GetAllAsync<KeyValue>(sqlString, new { building_tag = post.building_tag, mainList = mainList});
|
||||||
|
|
||||||
apiResult.Code = "0000";
|
apiResult.Code = "0000";
|
||||||
apiResult.Data = KeyValue;
|
apiResult.Data = KeyValue;
|
||||||
@ -125,14 +139,16 @@ namespace Backend.Controllers
|
|||||||
ApiResult<string> apiResult = new ApiResult<string>();
|
ApiResult<string> apiResult = new ApiResult<string>();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var get = await backendRepository.GetOneAsync<BuildMenu>("building_menu", $"building_guid = '{buildMenu.building_guid}' and main_system_guid = '{buildMenu.main_system_guid}' and sub_system_guid = '{buildMenu.sub_system_guid}'");
|
var get = await backendRepository.GetOneAsync<BuildMenu>("building_menu", $"building_tag = '{buildMenu.building_tag}' and main_system_tag = '{buildMenu.main_system_tag}' and sub_system_tag = '{buildMenu.sub_system_tag}'");
|
||||||
if (get == null)
|
if (get == null)
|
||||||
{
|
{
|
||||||
|
var subV = await backendRepository.GetOneAsync<VariableInfo>("variable", "system_value = @sub_tag and system_type = @sub_system_type", new { sub_tag = buildMenu.sub_system_tag, sub_system_type = sub_system_type });
|
||||||
|
|
||||||
var dictionary = new Dictionary<string, object>()
|
var dictionary = new Dictionary<string, object>()
|
||||||
{
|
{
|
||||||
{"@building_guid", buildMenu.building_guid},
|
{"@building_tag", buildMenu.building_tag},
|
||||||
{"@main_system_guid",buildMenu.main_system_guid },
|
{"@main_system_tag",buildMenu.main_system_tag },
|
||||||
{"@sub_system_guid", buildMenu.sub_system_guid},
|
{"@sub_system_tag", buildMenu.sub_system_tag},
|
||||||
{"@drawing",buildMenu.drawing },
|
{"@drawing",buildMenu.drawing },
|
||||||
{"@created_by",myUserInfo.Userinfo_guid },
|
{"@created_by",myUserInfo.Userinfo_guid },
|
||||||
{"@planimetric_click",buildMenu.planimetric_click}
|
{"@planimetric_click",buildMenu.planimetric_click}
|
||||||
@ -143,8 +159,8 @@ namespace Backend.Controllers
|
|||||||
if (buildMenu.system_url != null && buildMenu.system_url.CompareTo("http://") < 0 && buildMenu.system_url.CompareTo("https://") < 0)
|
if (buildMenu.system_url != null && buildMenu.system_url.CompareTo("http://") < 0 && buildMenu.system_url.CompareTo("https://") < 0)
|
||||||
{
|
{
|
||||||
//未包含http || https 抓該棟ip + port
|
//未包含http || https 抓該棟ip + port
|
||||||
var building_where = @"deleted = 0 AND building_guid = @Building_guid";
|
var building_where = @"deleted = 0 AND building_tag = @Building_tag";
|
||||||
var building = await backendRepository.GetOneAsync<BuildInfo>("building", building_where, new { Building_guid = buildMenu.building_guid });
|
var building = await backendRepository.GetOneAsync<BuildInfo>("building", building_where, new { Building_tag = buildMenu.building_tag });
|
||||||
|
|
||||||
buildMenu.system_url = string.Format("http://{0}:{1}{2}", building.Ip_address, building.Ip_port, buildMenu.system_url);
|
buildMenu.system_url = string.Format("http://{0}:{1}{2}", building.Ip_address, building.Ip_port, buildMenu.system_url);
|
||||||
}
|
}
|
||||||
@ -156,8 +172,8 @@ namespace Backend.Controllers
|
|||||||
if (buildMenu.system_url != null && buildMenu.system_url.CompareTo("http://") < 0 && buildMenu.system_url.CompareTo("https://") < 0)
|
if (buildMenu.system_url != null && buildMenu.system_url.CompareTo("http://") < 0 && buildMenu.system_url.CompareTo("https://") < 0)
|
||||||
{
|
{
|
||||||
//未包含http || https 抓該棟ip + port
|
//未包含http || https 抓該棟ip + port
|
||||||
var building_where = @"deleted = 0 AND building_guid = @Building_guid";
|
var building_where = @"deleted = 0 AND building_tag = @Building_tag";
|
||||||
var building = await backendRepository.GetOneAsync<BuildInfo>("building", building_where, new { Building_guid = buildMenu.building_guid });
|
var building = await backendRepository.GetOneAsync<BuildInfo>("building", building_where, new { Building_tag = buildMenu.building_tag });
|
||||||
|
|
||||||
buildMenu.system_url = string.Format("http://{0}:{1}{2}", building.Ip_address, building.Ip_port, buildMenu.system_url);
|
buildMenu.system_url = string.Format("http://{0}:{1}{2}", building.Ip_address, building.Ip_port, buildMenu.system_url);
|
||||||
}
|
}
|
||||||
@ -175,8 +191,14 @@ namespace Backend.Controllers
|
|||||||
|
|
||||||
await backendRepository.AddOneByCustomTable(dictionary, "building_menu");
|
await backendRepository.AddOneByCustomTable(dictionary, "building_menu");
|
||||||
|
|
||||||
var max = await backendRepository.GetOneAsync<int>("select Max(CONVERT(int,SUBSTRING(AuthCode,2,5))) AuthCode from auth_page ap where ap.AuthCode like 'F%'");
|
var max = await backendRepository.GetOneAsync<int>("select Max(CONVERT(SUBSTRING(AuthCode,2,5), SIGNED)) AuthCode from auth_page ap where ap.AuthCode like 'F%'");
|
||||||
var page = await backendRepository.GetOneAsync<Auth_page>($"select ss.full_name SubName,ms.full_name MainName from sub_system ss left join main_system ms on ms.main_system_guid = ss.main_system_guid where ss.sub_system_guid = '{buildMenu.sub_system_guid}' and ms.main_system_guid = '{buildMenu.main_system_guid}'");
|
|
||||||
|
var pageSql = $@"select sv.system_key SubName, mv.system_key MainName
|
||||||
|
from variable sv
|
||||||
|
left join variable mv on sv.system_parent_id = mv.id
|
||||||
|
where (sv.system_value = @sub_system_tag and sv.system_type = @sub_system_type) and (mv.system_value = @main_system_tag and mv.system_type = @main_system_type)";
|
||||||
|
var pageParam = new { sub_system_tag = buildMenu.sub_system_tag, main_system_tag = buildMenu.main_system_tag, sub_system_type = sub_system_type, main_system_type = main_system_type};
|
||||||
|
var page = await backendRepository.GetOneAsync<Auth_page>(pageSql, pageParam);
|
||||||
|
|
||||||
var pagedictionary = new Dictionary<string, object>()
|
var pagedictionary = new Dictionary<string, object>()
|
||||||
{
|
{
|
||||||
@ -184,42 +206,26 @@ namespace Backend.Controllers
|
|||||||
{"@AuthType", 1 },
|
{"@AuthType", 1 },
|
||||||
{"@MainName", page.MainName},
|
{"@MainName", page.MainName},
|
||||||
{"@SubName",page.SubName},
|
{"@SubName",page.SubName},
|
||||||
{"@building_guid",buildMenu.building_guid},
|
{"@building_tag",buildMenu.building_tag},
|
||||||
{"@ShowView",buildMenu.sub_system_guid}
|
{"@ShowView",subV.id}
|
||||||
};
|
};
|
||||||
await backendRepository.AddOneByCustomTable(pagedictionary, "auth_page");
|
await backendRepository.AddOneByCustomTable(pagedictionary, "auth_page");
|
||||||
|
|
||||||
|
var param = new { main_system_type = main_system_type, sub_system_type = sub_system_type };
|
||||||
await backendRepository.ExecuteSql(@"DELETE FROM auth_page
|
await backendRepository.ExecuteSql(@"DELETE FROM auth_page
|
||||||
WHERE auth_page.AuthCode like 'F%';
|
WHERE auth_page.AuthCode like 'F%';
|
||||||
INSERT INTO auth_page (AuthCode,AuthType,MainName,SubName,building_guid,ShowView)
|
INSERT INTO auth_page (AuthCode,AuthType,MainName,SubName,building_tag,ShowView)
|
||||||
SELECT 'F' + CONVERT(varchar,ROW_NUMBER() OVER(ORDER BY bm.building_guid ASC)) AuthCode,'1' AuthType,ms.full_name MainName,ss.full_name SubName,bm.building_guid,bm.sub_system_guid ShowView FROM building_menu bm
|
SELECT concat('F', CONVERT(ROW_NUMBER() OVER(ORDER BY bm.building_tag ASC), nchar)) AuthCode, '1' as AuthType,
|
||||||
left join main_system ms on ms.main_system_guid = bm.main_system_guid
|
mv.system_key MainName, sv.system_key SubName, bm.building_tag, sv.id ShowView
|
||||||
left join sub_system ss on ss.sub_system_guid = bm.sub_system_guid");
|
FROM building_menu bm
|
||||||
|
LEFT JOIN variable mv ON bm.main_system_tag = mv.system_value AND mv.system_type = @main_system_type
|
||||||
|
LEFT JOIN variable sv ON bm.sub_system_tag = sv.system_value AND sv.system_type = @sub_system_type", param);
|
||||||
|
|
||||||
await backendRepository.ExecuteSql(@"delete a from role_auth a join role b on a.role_guid = b.role_guid where b.layer = 0;
|
await backendRepository.ExecuteSql(@"delete a from role_auth a join role b on a.role_guid = b.role_guid where b.layer = 0;
|
||||||
INSERT INTO role_auth (role_guid,AuthCode,created_by)
|
INSERT INTO role_auth (role_guid,AuthCode,created_by)
|
||||||
SELECT r.role_guid,ap.AuthCode,'0' created_by FROM auth_page ap,role r
|
SELECT r.role_guid,ap.AuthCode,'0' created_by FROM auth_page ap,role r
|
||||||
WHERE r.layer = 0;");
|
WHERE r.layer = 0;");
|
||||||
|
|
||||||
#region 新增至派送資料表
|
|
||||||
var sql = $@"SELECT ra.* FROM role_auth ra join role r on ra.role_guid = r.role_guid where r.layer = 0";
|
|
||||||
var role_auths = await backendRepository.GetAllAsync<RoleAuthList>(sql);
|
|
||||||
|
|
||||||
List<Dictionary<string, object>> role_auth_dicts = new List<Dictionary<string, object>>();
|
|
||||||
foreach (var role_auth in role_auths)
|
|
||||||
{
|
|
||||||
Dictionary<string, object> role_auth_dict = new Dictionary<string, object>()
|
|
||||||
{
|
|
||||||
{ "role_guid", role_auth.Role_guid},
|
|
||||||
{ "@AuthCode", role_auth.AuthCode},
|
|
||||||
};
|
|
||||||
|
|
||||||
role_auth_dicts.Add(role_auth_dict);
|
|
||||||
}
|
|
||||||
|
|
||||||
await backendRepository.ManualInsertBackgroundServiceTask("", "", "role_auth", "purge_specify_insert", role_auth_dicts);
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
apiResult.Code = "0000";
|
apiResult.Code = "0000";
|
||||||
apiResult.Msg = "儲存成功";
|
apiResult.Msg = "儲存成功";
|
||||||
}
|
}
|
||||||
@ -237,8 +243,8 @@ namespace Backend.Controllers
|
|||||||
if (buildMenu.system_url != null && buildMenu.system_url.CompareTo("http://") < 0 && buildMenu.system_url.CompareTo("https://") < 0)
|
if (buildMenu.system_url != null && buildMenu.system_url.CompareTo("http://") < 0 && buildMenu.system_url.CompareTo("https://") < 0)
|
||||||
{
|
{
|
||||||
//未包含http || https 抓該棟ip + port
|
//未包含http || https 抓該棟ip + port
|
||||||
var building_where = @"deleted = 0 AND building_guid = @Building_guid";
|
var building_where = @"deleted = 0 AND building_tag = @Building_tag";
|
||||||
var building = await backendRepository.GetOneAsync<BuildInfo>("building", building_where, new { Building_guid = buildMenu.building_guid });
|
var building = await backendRepository.GetOneAsync<BuildInfo>("building", building_where, new { Building_tag = buildMenu.building_tag });
|
||||||
|
|
||||||
buildMenu.system_url = string.Format("http://{0}:{1}{2}", building.Ip_address, building.Ip_port, buildMenu.system_url);
|
buildMenu.system_url = string.Format("http://{0}:{1}{2}", building.Ip_address, building.Ip_port, buildMenu.system_url);
|
||||||
}
|
}
|
||||||
@ -250,8 +256,8 @@ namespace Backend.Controllers
|
|||||||
if (buildMenu.system_url != null && buildMenu.system_url.CompareTo("http://") < 0 && buildMenu.system_url.CompareTo("https://") < 0)
|
if (buildMenu.system_url != null && buildMenu.system_url.CompareTo("http://") < 0 && buildMenu.system_url.CompareTo("https://") < 0)
|
||||||
{
|
{
|
||||||
//未包含http || https 抓該棟ip + port
|
//未包含http || https 抓該棟ip + port
|
||||||
var building_where = @"deleted = 0 AND building_guid = @Building_guid";
|
var building_where = @"deleted = 0 AND building_tag = @Building_tag";
|
||||||
var building = await backendRepository.GetOneAsync<BuildInfo>("building", building_where, new { Building_guid = buildMenu.building_guid });
|
var building = await backendRepository.GetOneAsync<BuildInfo>("building", building_where, new { Building_tag = buildMenu.building_tag });
|
||||||
|
|
||||||
buildMenu.system_url = string.Format("http://{0}:{1}{2}", building.Ip_address, building.Ip_port, buildMenu.system_url);
|
buildMenu.system_url = string.Format("http://{0}:{1}{2}", building.Ip_address, building.Ip_port, buildMenu.system_url);
|
||||||
}
|
}
|
||||||
@ -267,7 +273,7 @@ namespace Backend.Controllers
|
|||||||
dictionary.Add("@planimetric_floor_guid", buildMenu.planimetric_floor_guid);
|
dictionary.Add("@planimetric_floor_guid", buildMenu.planimetric_floor_guid);
|
||||||
}
|
}
|
||||||
|
|
||||||
await backendRepository.UpdateOneByCustomTable(dictionary, "building_menu", $"building_guid = '{buildMenu.building_guid}' and main_system_guid = '{buildMenu.main_system_guid}' and sub_system_guid = '{buildMenu.sub_system_guid}'");
|
await backendRepository.UpdateOneByCustomTable(dictionary, "building_menu", $"building_tag = '{buildMenu.building_tag}' and main_system_tag = '{buildMenu.main_system_tag}' and sub_system_tag = '{buildMenu.sub_system_tag}'");
|
||||||
|
|
||||||
apiResult.Code = "0000";
|
apiResult.Code = "0000";
|
||||||
apiResult.Msg = "儲存成功";
|
apiResult.Msg = "儲存成功";
|
||||||
@ -294,12 +300,13 @@ namespace Backend.Controllers
|
|||||||
case drawing when 1 then '樓層平面圖' when 2 then '系統圖' when 4 then '昇位圖' end drawing_name,
|
case drawing when 1 then '樓層平面圖' when 2 then '系統圖' when 4 then '昇位圖' end drawing_name,
|
||||||
case icon_click when 1 then '開' when 0 then '關' end icon_click_name,
|
case icon_click when 1 then '開' when 0 then '關' end icon_click_name,
|
||||||
case planimetric_click when 1 then '開' when 0 then '關' end planimetric_click_name,
|
case planimetric_click when 1 then '開' when 0 then '關' end planimetric_click_name,
|
||||||
ms.full_name main_system_guid_name, ss.full_name sub_system_guid_name,ff.full_name floor_guid_name
|
mv.system_key main_system_guid_name, sv.system_key sub_system_guid_name,ff.full_name floor_guid_name
|
||||||
from building_menu bm
|
from building_menu bm
|
||||||
left join main_system ms on ms.main_system_guid = bm.main_system_guid
|
left join variable mv on bm.main_system_tag = mv.system_value and mv.system_type = @main_system_type and mv.deleted = 0
|
||||||
left join sub_system ss on ss.sub_system_guid = bm.sub_system_guid
|
left join variable sv on bm.sub_system_tag = sv.system_value and sv.system_type = @sub_system_type and sv.deleted = 0
|
||||||
left join floor ff on ff.floor_guid = bm.planimetric_floor_guid
|
left join floor ff on ff.floor_guid = bm.planimetric_floor_guid
|
||||||
where bm.building_guid = '{post.build}' and bm.main_system_guid in @MainList ORDER BY ms.priority ASC, ss.priority ASC, ss.created_at DESC ", new { MainList = post.MainList });
|
where bm.building_tag = @building_tag and bm.main_system_tag in @MainList ORDER BY 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 });
|
||||||
|
|
||||||
apiResult.Code = "0000";
|
apiResult.Code = "0000";
|
||||||
apiResult.Data = buildMenuTables;
|
apiResult.Data = buildMenuTables;
|
||||||
@ -324,9 +331,11 @@ namespace Backend.Controllers
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var BuildMenu = await backendRepository.GetOneAsync<BuildMenuAddSub>(
|
var BuildMenu = await backendRepository.GetOneAsync<BuildMenuAddSub>(
|
||||||
$@"select *,ss.full_name sub_system_guid_name from building_menu bm
|
$@"select *, sv.system_key sub_system_guid_name
|
||||||
left join sub_system ss on bm.sub_system_guid = ss.sub_system_guid
|
from building_menu bm
|
||||||
where bm.building_guid = @bg and bm.main_system_guid = @msg and bm.sub_system_guid = @ssg", new { bg = post.build, msg = post.main, ssg = post.sub });
|
left join variable sv on bm.sub_system_tag = sv.system_value and sv.system_type = @sub_system_type
|
||||||
|
where bm.building_tag = @building_tag and bm.main_system_tag = @main_system_tag and bm.sub_system_tag = @sub_system_tag"
|
||||||
|
, new { building_tag = post.building_tag, main_system_tag = post.main_system_tag, sub_system_tag = post.sub_system_tag, sub_system_type = sub_system_type });
|
||||||
apiResult.Code = "0000";
|
apiResult.Code = "0000";
|
||||||
apiResult.Data = BuildMenu;
|
apiResult.Data = BuildMenu;
|
||||||
}
|
}
|
||||||
@ -346,8 +355,9 @@ namespace Backend.Controllers
|
|||||||
ApiResult<string> apiResult = new ApiResult<string>();
|
ApiResult<string> apiResult = new ApiResult<string>();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await backendRepository.PurgeOneByGuidWithCustomDBNameAndTable("building_menu", $"building_guid = '{post.build}' and main_system_guid = '{post.main}' and sub_system_guid = '{post.sub}'");
|
await backendRepository.PurgeOneByGuidWithCustomDBNameAndTable("building_menu", $"building_tag = '{post.building_tag}' and main_system_tag = '{post.main_system_tag}' and sub_system_tag = '{post.sub_system_tag}'");
|
||||||
var authcode = await backendRepository.GetOneAsync<string>(@$"select AuthCode from auth_page where building_guid = '{post.build}' and ShowView = '{post.sub}'");
|
var subV = await backendRepository.GetOneAsync<VariableInfo>(@$"select * from variable where system_value = @sub_system_tag and system_type = sub_system_type and deleted = 0", new { sub_system_tag = post.sub_system_tag, sub_system_type = sub_system_type });
|
||||||
|
var authcode = await backendRepository.GetOneAsync<string>(@$"select AuthCode from auth_page where building_tag = @building_tag and ShowView = @sub_id", new {post.building_tag, subV.id});
|
||||||
if (authcode != null)
|
if (authcode != null)
|
||||||
{
|
{
|
||||||
await backendRepository.PurgeOneByGuidWithCustomDBNameAndTable("role_auth", $" AuthCode = '{authcode}'");
|
await backendRepository.PurgeOneByGuidWithCustomDBNameAndTable("role_auth", $" AuthCode = '{authcode}'");
|
||||||
@ -356,25 +366,6 @@ namespace Backend.Controllers
|
|||||||
INSERT INTO role_auth (role_guid,AuthCode,created_by)
|
INSERT INTO role_auth (role_guid,AuthCode,created_by)
|
||||||
SELECT r.role_guid,ap.AuthCode,'0' created_by FROM auth_page ap,role r
|
SELECT r.role_guid,ap.AuthCode,'0' created_by FROM auth_page ap,role r
|
||||||
WHERE r.layer = 0;");
|
WHERE r.layer = 0;");
|
||||||
|
|
||||||
#region 新增至派送資料表
|
|
||||||
var sql = $@"SELECT ra.* FROM role_auth ra join role r on ra.role_guid = r.role_guid where r.layer = 0";
|
|
||||||
var role_auths = await backendRepository.GetAllAsync<RoleAuthList>(sql);
|
|
||||||
|
|
||||||
List<Dictionary<string, object>> role_auth_dicts = new List<Dictionary<string, object>>();
|
|
||||||
foreach (var role_auth in role_auths)
|
|
||||||
{
|
|
||||||
Dictionary<string, object> role_auth_dict = new Dictionary<string, object>()
|
|
||||||
{
|
|
||||||
{ "role_guid", role_auth.Role_guid},
|
|
||||||
{ "@AuthCode", role_auth.AuthCode},
|
|
||||||
};
|
|
||||||
|
|
||||||
role_auth_dicts.Add(role_auth_dict);
|
|
||||||
}
|
|
||||||
|
|
||||||
await backendRepository.ManualInsertBackgroundServiceTask("", "", "role_auth", "purge_specify_insert", role_auth_dicts);
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
apiResult.Code = "0000";
|
apiResult.Code = "0000";
|
||||||
apiResult.Msg = "刪除成功";
|
apiResult.Msg = "刪除成功";
|
||||||
@ -396,13 +387,18 @@ namespace Backend.Controllers
|
|||||||
ApiResult<List<BuildMenuFloorTable>> apiResult = new ApiResult<List<BuildMenuFloorTable>>();
|
ApiResult<List<BuildMenuFloorTable>> apiResult = new ApiResult<List<BuildMenuFloorTable>>();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
var param = new { building_tag = post.building_tag, main_system_tag = post.main_system_tag, sub_system_tag = post.sub_system_tag, main_system_type = main_system_type, sub_system_type = sub_system_type };
|
||||||
buildMenuFloorTables = await backendRepository.GetAllAsync<BuildMenuFloorTable>($@"
|
buildMenuFloorTables = await backendRepository.GetAllAsync<BuildMenuFloorTable>($@"
|
||||||
select f.full_name floor_guid_name,sf.*,ms.full_name main_system_guid_name,ss.full_name sub_system_guid_name
|
select sf.id sub_system_floor_id, f.full_name floor_guid_name, sf.*, mv.system_key main_system_guid_name, sv.system_key sub_system_guid_name
|
||||||
from (select * from sub_system_floor ssf where ssf.building_guid = '{post.build}' and ssf.main_system_guid = '{post.main}' and ssf.sub_system_guid = '{post.sub}' and deleted = 0 and status = 0) sf
|
from (
|
||||||
left join floor f on sf.floor_guid = f.floor_guid
|
select *
|
||||||
left join main_system ms on ms.main_system_guid = sf.main_system_guid
|
from sub_system_floor ssf
|
||||||
left join sub_system ss on ss.sub_system_guid = sf.sub_system_guid
|
where ssf.building_tag = @building_tag and ssf.main_system_tag = @main_system_tag and ssf.sub_system_tag = @sub_system_tag and deleted = 0 and status = 0
|
||||||
ORDER BY ms.priority, ss.priority, f.priority");
|
) sf
|
||||||
|
left join floor f on sf.floor_tag = f.full_name
|
||||||
|
left join variable mv on sf.main_system_tag = mv.system_value and mv.system_type = @main_system_type and mv.deleted = 0
|
||||||
|
left join variable sv on sf.sub_system_tag = sv.system_value and sv.system_type = @sub_system_type and sv.deleted = 0
|
||||||
|
ORDER BY mv.system_priority, sv.system_priority, f.priority", param);
|
||||||
apiResult.Code = "0000";
|
apiResult.Code = "0000";
|
||||||
apiResult.Data = buildMenuFloorTables;
|
apiResult.Data = buildMenuFloorTables;
|
||||||
}
|
}
|
||||||
@ -426,12 +422,17 @@ namespace Backend.Controllers
|
|||||||
List<KeyValue> KeyValue = new List<KeyValue>();
|
List<KeyValue> KeyValue = new List<KeyValue>();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var sqlString = @$"select fg.floor_guid value, fg.full_name name from
|
var param = new { building_tag = post.building_tag, main_system_tag = post.main_system_tag, sub_system_tag = post.sub_system_tag };
|
||||||
(select * from floor fg where fg.building_guid = '{post.build}' and fg.deleted = 0 and fg.status = 0 ) fg
|
var sqlString = @$"select f.floor_guid value, f.full_name name
|
||||||
left join (select * from sub_system_floor where building_guid = '{post.build}' and main_system_guid = '{post.main}' and sub_system_guid = '{post.sub}' and deleted = 0 and status = 0) ssf
|
from (
|
||||||
on ssf.floor_guid = fg.floor_guid
|
select * from floor f where f.building_tag = @building_tag and f.deleted = 0 and f.status = 0
|
||||||
where ssf.floor_guid is null ORDER BY fg.priority";
|
) f
|
||||||
KeyValue = await backendRepository.GetAllAsync<KeyValue>(sqlString);
|
left join (
|
||||||
|
select * from sub_system_floor where building_tag = @building_tag and main_system_tag = @main_system_tag and sub_system_tag = @sub_system_tag and deleted = 0 and status = 0
|
||||||
|
) ssf
|
||||||
|
on ssf.floor_tag = f.full_name
|
||||||
|
where ssf.floor_tag is null ORDER BY f.priority";
|
||||||
|
KeyValue = await backendRepository.GetAllAsync<KeyValue>(sqlString, param);
|
||||||
|
|
||||||
apiResult.Code = "0000";
|
apiResult.Code = "0000";
|
||||||
apiResult.Data = KeyValue;
|
apiResult.Data = KeyValue;
|
||||||
@ -457,11 +458,11 @@ namespace Backend.Controllers
|
|||||||
{
|
{
|
||||||
var dictionary = new Dictionary<string, object>()
|
var dictionary = new Dictionary<string, object>()
|
||||||
{
|
{
|
||||||
{"@sub_system_floor_guid", Guid.NewGuid()},
|
{"@building_tag", menuInfloor.building_tag},
|
||||||
{"@building_guid",menuInfloor.build},
|
{"@main_system_tag", menuInfloor.main_system_tag},
|
||||||
{"@main_system_guid", menuInfloor.main},
|
{"@sub_system_tag",menuInfloor.sub_system_tag},
|
||||||
{"@sub_system_guid",menuInfloor.sub},
|
{"@floor_tag", a},
|
||||||
{"@floor_guid",a},
|
{"@is_link", 1},
|
||||||
{"@created_by", myUserInfo.Userinfo_guid}
|
{"@created_by", myUserInfo.Userinfo_guid}
|
||||||
};
|
};
|
||||||
listdictionary.Add(dictionary);
|
listdictionary.Add(dictionary);
|
||||||
@ -481,32 +482,32 @@ namespace Backend.Controllers
|
|||||||
return apiResult;
|
return apiResult;
|
||||||
}
|
}
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<ApiResult<string>> DeleteBuildFloorMenu(string subfloorguid)
|
public async Task<ApiResult<string>> DeleteBuildFloorMenu(string sub_system_floor_id)
|
||||||
{
|
{
|
||||||
ApiResult<string> apiResult = new ApiResult<string>();
|
ApiResult<string> apiResult = new ApiResult<string>();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//檢查該樓層底下是否有設備
|
//檢查該樓層底下是否有設備
|
||||||
var sql = $@"
|
var sql = $@"SELECT
|
||||||
SELECT
|
CONCAT(b.full_name, ' - ', mv.system_key, ' - ', sv.system_key, ' - ', f.full_name)
|
||||||
CONCAT(b.full_name, ' - ', ms.full_name, ' - ', ss.full_name , ' - ', f.full_name)
|
|
||||||
FROM device d
|
FROM device d
|
||||||
LEFT JOIN (
|
LEFT JOIN (
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM sub_system_floor ssf
|
FROM sub_system_floor ssf
|
||||||
WHERE ssf.deleted = 0 AND ssf.sub_system_floor_guid = @Guid) ssf
|
WHERE ssf.deleted = 0 AND ssf.id = @sub_system_floor_id
|
||||||
|
) ssf
|
||||||
ON d.deleted = 0
|
ON d.deleted = 0
|
||||||
AND d.building_guid = ssf.building_guid
|
AND d.device_building_tag = ssf.building_tag
|
||||||
AND d.main_system_guid = ssf.main_system_guid
|
AND d.device_system_tag = ssf.main_system_tag
|
||||||
AND d.sub_system_guid = ssf.sub_system_guid
|
AND d.device_name_tag = ssf.sub_system_tag
|
||||||
AND d.floor_guid = ssf.floor_guid
|
AND d.device_floor_tag = ssf.floor_tag
|
||||||
LEFT JOIN building b ON b.deleted = 0 AND d.building_guid = b.building_guid
|
LEFT JOIN building b ON b.deleted = 0 AND d.device_building_tag = b.building_tag
|
||||||
LEFT JOIN main_system ms ON ms.deleted = 0 AND d.main_system_guid = ms.main_system_guid
|
LEFT JOIN variable mv on mv.deleted = 0 AND d.device_system_tag = mv.system_value AND mv.system_type = @main_system_type and mv.deleted = 0
|
||||||
LEFT JOIN sub_system ss ON ss.deleted = 0 AND d.sub_system_guid = ss.sub_system_guid
|
LEFT JOIN variable sv on sv.deleted = 0 AND d.device_name_tag = sv.system_value AND sv.system_type = @sub_system_type and sv.deleted = 0
|
||||||
LEFT JOIN floor f ON f.deleted = 0 AND d.floor_guid = f.floor_guid
|
LEFT JOIN floor f ON f.deleted = 0 AND d.full_name = f.full_name
|
||||||
WHERE ssf.sub_system_floor_guid = @Guid";
|
WHERE ssf.id = @sub_system_floor_id";
|
||||||
|
|
||||||
var sub_system_floors = await backendRepository.GetAllAsync<string>(sql, new { Guid = subfloorguid });
|
var sub_system_floors = await backendRepository.GetAllAsync<string>(sql, new { sub_system_floor_id = sub_system_floor_id, main_system_type = main_system_type, sub_system_type = sub_system_type });
|
||||||
if (sub_system_floors.Count > 0)
|
if (sub_system_floors.Count > 0)
|
||||||
{
|
{
|
||||||
apiResult.Code = "9997";
|
apiResult.Code = "9997";
|
||||||
@ -514,7 +515,7 @@ namespace Backend.Controllers
|
|||||||
return apiResult;
|
return apiResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
await backendRepository.DeleteOne(subfloorguid, "sub_system_floor", "sub_system_floor_guid");
|
await backendRepository.DeleteOne(sub_system_floor_id, "sub_system_floor", "id");
|
||||||
apiResult.Code = "0000";
|
apiResult.Code = "0000";
|
||||||
apiResult.Msg = "刪除成功";
|
apiResult.Msg = "刪除成功";
|
||||||
}
|
}
|
||||||
@ -522,7 +523,7 @@ namespace Backend.Controllers
|
|||||||
{
|
{
|
||||||
apiResult.Code = "9999";
|
apiResult.Code = "9999";
|
||||||
apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
|
apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
|
||||||
string json = System.Text.Json.JsonSerializer.Serialize(subfloorguid);
|
string json = System.Text.Json.JsonSerializer.Serialize(sub_system_floor_id);
|
||||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + json);
|
Logger.LogError("【" + controllerName + "/" + actionName + "】" + json);
|
||||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||||
}
|
}
|
||||||
@ -536,10 +537,12 @@ namespace Backend.Controllers
|
|||||||
List<KeyValue> KeyValue = new List<KeyValue>();
|
List<KeyValue> KeyValue = new List<KeyValue>();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var sqlString = @$"select floor.floor_guid Value,floor.full_name Name from sub_system_floor sf left join floor on sf.floor_guid = floor.floor_guid
|
var sqlString = @$"select f.floor_guid Value, f.full_name Name
|
||||||
where sf.deleted = 0 and sf.status = 0 and sf.building_guid = '{post.build}' and sf.main_system_guid = '{post.main}' and sf.sub_system_guid = '{post.sub}'
|
from sub_system_floor sf
|
||||||
ORDER BY floor.priority, floor.created_at";
|
left join floor f on sf.floor_tag = f.full_name
|
||||||
KeyValue = await backendRepository.GetAllAsync<KeyValue>(sqlString);
|
where sf.deleted = 0 and sf.status = 0 and sf.building_tag = @building_tag and sf.main_system_tag = @main_system_tag and sf.sub_system_tag = @sub_system_tag
|
||||||
|
ORDER BY f.priority, f.created_at";
|
||||||
|
KeyValue = await backendRepository.GetAllAsync<KeyValue>(sqlString, new { building_tag = post.building_tag, main_system_tag = post.main_system_tag, sub_system_type = post.sub_system_tag });
|
||||||
|
|
||||||
apiResult.Code = "0000";
|
apiResult.Code = "0000";
|
||||||
apiResult.Data = KeyValue;
|
apiResult.Data = KeyValue;
|
||||||
|
@ -31,6 +31,9 @@ namespace Backend.Controllers
|
|||||||
protected MyUserInfo myUserInfo = null;
|
protected MyUserInfo myUserInfo = null;
|
||||||
public string controllerName;
|
public string controllerName;
|
||||||
public string actionName;
|
public string actionName;
|
||||||
|
public string main_system_type = "device_system_category_layer2";
|
||||||
|
public string sub_system_type = "device_system_category_layer3";
|
||||||
|
|
||||||
public MybaseController() { }
|
public MybaseController() { }
|
||||||
public override void OnActionExecuting(ActionExecutingContext filterContext)
|
public override void OnActionExecuting(ActionExecutingContext filterContext)
|
||||||
{
|
{
|
||||||
|
@ -13,8 +13,6 @@ namespace Backend.Controllers
|
|||||||
{
|
{
|
||||||
|
|
||||||
private readonly IBackendRepository backendRepository;
|
private readonly IBackendRepository backendRepository;
|
||||||
private string main_system_name = "device_system_category_layer2";
|
|
||||||
private string sub_system_name = "device_system_category_layer1";
|
|
||||||
|
|
||||||
public SystemCategoryController(IBackendRepository backendRepository)
|
public SystemCategoryController(IBackendRepository backendRepository)
|
||||||
{
|
{
|
||||||
@ -39,7 +37,7 @@ namespace Backend.Controllers
|
|||||||
{
|
{
|
||||||
var sWhere = "deleted = 0 AND system_type = @System_type";
|
var sWhere = "deleted = 0 AND system_type = @System_type";
|
||||||
|
|
||||||
var param = new { System_type = main_system_name };
|
var param = new { System_type = main_system_type };
|
||||||
|
|
||||||
var systemMainList = await backendRepository.GetAllAsync<VariableInfo>("variable", sWhere, param, "system_priority ASC, created_at DESC");
|
var systemMainList = await backendRepository.GetAllAsync<VariableInfo>("variable", sWhere, param, "system_priority ASC, created_at DESC");
|
||||||
|
|
||||||
@ -108,13 +106,13 @@ namespace Backend.Controllers
|
|||||||
//新增
|
//新增
|
||||||
//獲取最新的大類
|
//獲取最新的大類
|
||||||
sWhere = @$"deleted = @Deleted AND system_type = @System_type";
|
sWhere = @$"deleted = @Deleted AND system_type = @System_type";
|
||||||
param = new { Deleted = 0, System_type = main_system_name };
|
param = new { Deleted = 0, System_type = main_system_type };
|
||||||
var sOrder = @"id DESC LIMIT 1";
|
var sOrder = @"id DESC LIMIT 1";
|
||||||
var latestVariable = await backendRepository.GetOneAsync<VariableInfo>("variable", sWhere, param, sOrder);
|
var latestVariable = await backendRepository.GetOneAsync<VariableInfo>("variable", sWhere, param, sOrder);
|
||||||
|
|
||||||
Dictionary<string, object> variableMainDic = new Dictionary<string, object>()
|
Dictionary<string, object> variableMainDic = new Dictionary<string, object>()
|
||||||
{
|
{
|
||||||
{ "@system_type", main_system_name},
|
{ "@system_type", main_system_type},
|
||||||
{ "@system_key", post.System_key},
|
{ "@system_key", post.System_key},
|
||||||
{ "@system_value", post.system_value},
|
{ "@system_value", post.system_value},
|
||||||
{ "@system_remark", "系統類別(第2層)"},
|
{ "@system_remark", "系統類別(第2層)"},
|
||||||
@ -142,8 +140,8 @@ namespace Backend.Controllers
|
|||||||
var AuthCodes = await backendRepository.GetAllAsync<string>(
|
var AuthCodes = await backendRepository.GetAllAsync<string>(
|
||||||
@$"select AuthCode
|
@$"select AuthCode
|
||||||
from auth_page ap
|
from auth_page ap
|
||||||
join variable sv on ap.ShowView = sv.system_value and sv.system_type = 'device_system_category_layer1'
|
join variable sv on ap.ShowView = sv.id and sv.system_type = 'device_system_category_layer1'
|
||||||
where sv.id = '{systemMain.id}'");
|
where sv.system_parent_id = '{systemMain.id}'");
|
||||||
|
|
||||||
if(AuthCodes.Count > 0)
|
if(AuthCodes.Count > 0)
|
||||||
{
|
{
|
||||||
@ -324,17 +322,17 @@ namespace Backend.Controllers
|
|||||||
//產生一組GUID
|
//產生一組GUID
|
||||||
//獲取最新的大類
|
//獲取最新的大類
|
||||||
sWhere = @$"deleted = @Deleted AND system_type = @System_type";
|
sWhere = @$"deleted = @Deleted AND system_type = @System_type";
|
||||||
param = new { Deleted = 0, System_type = sub_system_name };
|
param = new { Deleted = 0, System_type = sub_system_type };
|
||||||
var sOrder = @"id DESC LIMIT 1";
|
var sOrder = @"id DESC LIMIT 1";
|
||||||
var latestVariable = await backendRepository.GetOneAsync<VariableInfo>("variable", sWhere, param, sOrder);
|
var latestVariable = await backendRepository.GetOneAsync<VariableInfo>("variable", sWhere, param, sOrder);
|
||||||
|
|
||||||
Dictionary<string, object> systemSubDic = new Dictionary<string, object>()
|
Dictionary<string, object> systemSubDic = new Dictionary<string, object>()
|
||||||
{
|
{
|
||||||
{ "@system_type", sub_system_name},
|
{ "@system_type", sub_system_type},
|
||||||
{ "@system_key", post.System_key},
|
{ "@system_key", post.System_key},
|
||||||
{ "@system_value", post.system_value},
|
{ "@system_value", post.system_value},
|
||||||
{ "@system_parent_id", post.system_parent_id},
|
{ "@system_parent_id", post.system_parent_id},
|
||||||
{ "@system_remark", "系統類別(第1層)"},
|
{ "@system_remark", "系統類別(第3層)"},
|
||||||
{ "@system_priority", latestVariable.system_priority + 1},
|
{ "@system_priority", latestVariable.system_priority + 1},
|
||||||
{ "@created_by", myUserInfo.Userinfo_guid},
|
{ "@created_by", myUserInfo.Userinfo_guid},
|
||||||
{ "@created_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}
|
{ "@created_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}
|
||||||
@ -411,12 +409,12 @@ namespace Backend.Controllers
|
|||||||
|
|
||||||
//檢查是否有未刪除的區域選單
|
//檢查是否有未刪除的區域選單
|
||||||
var sbuildMenu = $@"SELECT
|
var sbuildMenu = $@"SELECT
|
||||||
CONCAT(b.full_name, ' - ', v2.system_key)
|
CONCAT(b.full_name, ' - ', sv.system_key)
|
||||||
FROM building_menu bm
|
FROM building_menu bm
|
||||||
LEFT JOIN building b ON bm.building_tag = b.building_tag AND b.deleted = 0
|
LEFT JOIN building b ON bm.building_tag = b.building_tag AND b.deleted = 0
|
||||||
LEFT JOIN variable v1 ON bm.sub_system_tag = v1.system_value AND v1.deleted = 0
|
LEFT JOIN variable sv ON bm.sub_system_tag = sv.system_value AND sv.deleted = 0
|
||||||
LEFT JOIN variable v2 ON v1.system_parent_id = v2.id AND v1.deleted = 0
|
LEFT JOIN variable mv ON sv.system_parent_id = mv.id AND mv.deleted = 0
|
||||||
WHERE v1.id = @id";
|
WHERE sv.id = @id";
|
||||||
|
|
||||||
var buildMenus = await backendRepository.GetAllAsync<string>(sbuildMenu, new { id = id });
|
var buildMenus = await backendRepository.GetAllAsync<string>(sbuildMenu, new { id = id });
|
||||||
if (buildMenus.Count > 0)
|
if (buildMenus.Count > 0)
|
||||||
@ -429,13 +427,13 @@ namespace Backend.Controllers
|
|||||||
|
|
||||||
//檢查是否有未刪除的系統小類樓層
|
//檢查是否有未刪除的系統小類樓層
|
||||||
var ssubSystemFloor = $@"SELECT
|
var ssubSystemFloor = $@"SELECT
|
||||||
CONCAT(b.full_name, ' - ', v1.full_name, ' - ', v2.full_name, ' - ', f.full_name)
|
CONCAT(b.full_name, ' - ', mv.full_name, ' - ', sv.full_name, ' - ', f.full_name)
|
||||||
FROM sub_system_floor ssf
|
FROM sub_system_floor ssf
|
||||||
LEFT JOIN building b ON ssf.building_tag = b.building_tag AND b.deleted = 0
|
LEFT JOIN building b ON ssf.building_tag = b.building_tag AND b.deleted = 0
|
||||||
LEFT JOIN variable v2 ON v2.system_value = ssf.sub_system_tag AND v2.deleted = 0
|
LEFT JOIN variable sv ON sv.system_value = ssf.sub_system_tag AND sv.deleted = 0
|
||||||
LEFT JOIN variable v1 ON v1.system_parent_id = v1.id AND v1.deleted = 0
|
LEFT JOIN variable mv ON sv.system_parent_id = mv.id AND mv.deleted = 0
|
||||||
LEFT JOIN floor f ON ssf.floor_guid = f.floor_guid AND f.deleted = 0
|
LEFT JOIN floor f ON ssf.floor_guid = f.floor_guid AND f.deleted = 0
|
||||||
WHERE v2.id = @id AND ssf.deleted = 0";
|
WHERE sv.id = @id AND ssf.deleted = 0";
|
||||||
|
|
||||||
var subSystemFloor = await backendRepository.GetAllAsync<string>(sbuildMenu, new { id = id });
|
var subSystemFloor = await backendRepository.GetAllAsync<string>(sbuildMenu, new { id = id });
|
||||||
if (subSystemFloor.Count > 0)
|
if (subSystemFloor.Count > 0)
|
||||||
@ -450,8 +448,8 @@ namespace Backend.Controllers
|
|||||||
var sdeviceItem = $@"SELECT
|
var sdeviceItem = $@"SELECT
|
||||||
di.full_name
|
di.full_name
|
||||||
FROM device_item di
|
FROM device_item di
|
||||||
INNER JOIN variable v on di.device_name_tag = v.system_value
|
INNER JOIN variable sv on di.device_name_tag = sv.system_value
|
||||||
WHERE v.deleted = 0 AND v.id = @id AND di.deleted = 0";
|
WHERE v.deleted = 0 AND sv.id = @id AND di.deleted = 0";
|
||||||
|
|
||||||
var deviceItems = await backendRepository.GetAllAsync<string>(sdeviceItem, new { id = id });
|
var deviceItems = await backendRepository.GetAllAsync<string>(sdeviceItem, new { id = id });
|
||||||
if (deviceItems.Count > 0)
|
if (deviceItems.Count > 0)
|
||||||
@ -568,9 +566,9 @@ namespace Backend.Controllers
|
|||||||
|
|
||||||
var sql = @"SELECT di.*
|
var sql = @"SELECT di.*
|
||||||
FROM device_item di
|
FROM device_item di
|
||||||
JOIN variable v1 ON di.device_name_tag = v1.system_value
|
JOIN variable sv ON di.device_name_tag = sv.system_value
|
||||||
JOIN variable v2 ON v1.system_parent_id = v2.id AND di.device_system_tag = v2.system_value
|
JOIN variable mv ON sv.system_parent_id = mv.id AND di.device_system_tag = mv.system_value
|
||||||
WHERE v1.id = @id AND di.deleted = @Deleted";
|
WHERE sv.id = @id AND di.deleted = @Deleted";
|
||||||
|
|
||||||
object param = new { Deleted = 0, id = id };
|
object param = new { Deleted = 0, id = id };
|
||||||
|
|
||||||
@ -720,13 +718,13 @@ namespace Backend.Controllers
|
|||||||
unionsql += " union ";
|
unionsql += " union ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var sql = @$"select v1.system_key msname, b.full_name bname, v2.system_key subname,de.device_last_name as device_name_tag from
|
var sql = @$"select mv.system_key msname, b.full_name bname, sv.system_key subname,de.device_last_name as device_name_tag from
|
||||||
({unionsql}) de
|
({unionsql}) de
|
||||||
left join variable v1 on v1.system_value = de.device_system_tag and v1.system_type = @main_system_type
|
left join variable mv on mv.system_value = de.device_system_tag and mv.system_type = @main_system_type
|
||||||
left join building b on b.building_tag = de.building_tag
|
left join building b on b.building_tag = de.building_tag
|
||||||
left join variable v2 on v2.system_value = de.device_name_tag and v1.system_type = @sub_system_type";
|
left join variable sv on sv.system_value = de.device_name_tag and sv.system_type = @sub_system_type";
|
||||||
|
|
||||||
var param = new { main_system_type = main_system_name, sub_system_type = sub_system_name};
|
var param = new { main_system_type = main_system_type, sub_system_type = sub_system_type};
|
||||||
var names = await backendRepository.GetAllAsync<GetCheckName>(sql, param);
|
var names = await backendRepository.GetAllAsync<GetCheckName>(sql, param);
|
||||||
var count = 0;
|
var count = 0;
|
||||||
foreach (var name in names)
|
foreach (var name in names)
|
||||||
|
@ -7,9 +7,9 @@ namespace Backend.Models
|
|||||||
{
|
{
|
||||||
public class BuildMenu : Actor
|
public class BuildMenu : Actor
|
||||||
{
|
{
|
||||||
public string building_guid { get; set; }
|
public string building_tag { get; set; }
|
||||||
public string main_system_guid { get; set; }
|
public string main_system_tag { get; set; }
|
||||||
public string sub_system_guid { get; set; }
|
public string sub_system_tag { get; set; }
|
||||||
public byte drawing { get; set; }
|
public byte drawing { get; set; }
|
||||||
public byte icon_click { get; set; }
|
public byte icon_click { get; set; }
|
||||||
public string icon_click_url { get; set; }
|
public string icon_click_url { get; set; }
|
||||||
@ -27,11 +27,13 @@ namespace Backend.Models
|
|||||||
public class SubListIn
|
public class SubListIn
|
||||||
{
|
{
|
||||||
public string main { get; set; }
|
public string main { get; set; }
|
||||||
|
public string main_system_tag { get; set; }
|
||||||
public string build { get; set; }
|
public string build { get; set; }
|
||||||
|
public string building_tag { get; set; }
|
||||||
}
|
}
|
||||||
public class BuildMenuTablePost
|
public class BuildMenuTablePost
|
||||||
{
|
{
|
||||||
public string build { get; set; }
|
public string building_tag { get; set; }
|
||||||
public List<string> MainList { get; set; }
|
public List<string> MainList { get; set; }
|
||||||
}
|
}
|
||||||
public class BuildMenuTable: BuildMenu
|
public class BuildMenuTable: BuildMenu
|
||||||
@ -46,6 +48,7 @@ namespace Backend.Models
|
|||||||
public class MenuIn : SubListIn
|
public class MenuIn : SubListIn
|
||||||
{
|
{
|
||||||
public string sub { get; set; }
|
public string sub { get; set; }
|
||||||
|
public string sub_system_tag { get; set; }
|
||||||
}
|
}
|
||||||
public class BuildMenuFloor : Actor
|
public class BuildMenuFloor : Actor
|
||||||
{
|
{
|
||||||
@ -60,6 +63,7 @@ namespace Backend.Models
|
|||||||
|
|
||||||
public class BuildMenuFloorTable : BuildMenuFloor
|
public class BuildMenuFloorTable : BuildMenuFloor
|
||||||
{
|
{
|
||||||
|
public string sub_system_floor_id { get; set; }
|
||||||
public string main_system_guid_name { get; set; }
|
public string main_system_guid_name { get; set; }
|
||||||
public string sub_system_guid_name { get; set; }
|
public string sub_system_guid_name { get; set; }
|
||||||
public string floor_guid_name { get; set; }
|
public string floor_guid_name { get; set; }
|
||||||
|
@ -443,7 +443,7 @@
|
|||||||
buildMenuTable = $("#buildMenu_table").DataTable({
|
buildMenuTable = $("#buildMenu_table").DataTable({
|
||||||
"columns": [
|
"columns": [
|
||||||
{
|
{
|
||||||
"data": "building_guid",
|
"data": "building_tag",
|
||||||
"render": function (data, type, row, meta) {
|
"render": function (data, type, row, meta) {
|
||||||
return meta.row + 1;
|
return meta.row + 1;
|
||||||
}
|
}
|
||||||
@ -482,9 +482,9 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
'createdRow': function (row, data, dataIndex) {
|
'createdRow': function (row, data, dataIndex) {
|
||||||
$(row).attr('bg-guid', data.building_guid);
|
$(row).attr('bg-guid', data.building_tag);
|
||||||
$(row).attr('ms-guid', data.main_system_guid);
|
$(row).attr('ms-guid', data.main_system_tag);
|
||||||
$(row).attr('ss-guid', data.sub_system_guid);
|
$(row).attr('ss-guid', data.sub_system_tag);
|
||||||
$(row).attr('ms-name', data.main_system_guid_name);
|
$(row).attr('ms-name', data.main_system_guid_name);
|
||||||
$(row).attr('ss-name', data.sub_system_guid_name);
|
$(row).attr('ss-name', data.sub_system_guid_name);
|
||||||
},
|
},
|
||||||
@ -492,7 +492,7 @@
|
|||||||
"url": "/BuildMenu/BuildMenuTable",
|
"url": "/BuildMenu/BuildMenuTable",
|
||||||
"type": "POST",
|
"type": "POST",
|
||||||
"data": function (d) {
|
"data": function (d) {
|
||||||
d.build = SelectBuild,
|
d.building_tag = SelectBuild,
|
||||||
d.MainList = SelectMainList
|
d.MainList = SelectMainList
|
||||||
},
|
},
|
||||||
"dataSrc": function (rel) {
|
"dataSrc": function (rel) {
|
||||||
@ -523,7 +523,7 @@
|
|||||||
buildMenuFloorTable = $("#buildMenu_floor_table").DataTable({
|
buildMenuFloorTable = $("#buildMenu_floor_table").DataTable({
|
||||||
"columns": [
|
"columns": [
|
||||||
{
|
{
|
||||||
"data": "sub_system_floor_guid",
|
"data": "sub_system_floor_id",
|
||||||
"render": function (data, type, row, meta) {
|
"render": function (data, type, row, meta) {
|
||||||
return meta.row + 1;
|
return meta.row + 1;
|
||||||
}
|
}
|
||||||
@ -543,15 +543,15 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
'createdRow': function (row, data, dataIndex) {
|
'createdRow': function (row, data, dataIndex) {
|
||||||
$(row).attr('ssf-guid', data.sub_system_floor_guid);
|
$(row).attr('ssf-guid', data.sub_system_floor_id);
|
||||||
},
|
},
|
||||||
"ajax": {
|
"ajax": {
|
||||||
"url": "/BuildMenu/BuildMenuFloorTable",
|
"url": "/BuildMenu/BuildMenuFloorTable",
|
||||||
"type": "POST",
|
"type": "POST",
|
||||||
"data": function (d) {
|
"data": function (d) {
|
||||||
d.build = SelectBuild,
|
d.building_tag = SelectBuild,
|
||||||
d.main = SelectMainSys,
|
d.main_system_tag = SelectMainSys,
|
||||||
d.sub = SelectSubSys
|
d.sub_system_tag = SelectSubSys
|
||||||
},
|
},
|
||||||
"dataSrc": function (rel) {
|
"dataSrc": function (rel) {
|
||||||
if (rel.code == "9999") {
|
if (rel.code == "9999") {
|
||||||
@ -617,10 +617,10 @@
|
|||||||
//#endregion
|
//#endregion
|
||||||
var submain = new Array(0);
|
var submain = new Array(0);
|
||||||
//#region 以棟別找系統大類
|
//#region 以棟別找系統大類
|
||||||
function GetMainlistByBuild(build) {
|
function GetMainlistByBuild(building_tag) {
|
||||||
var url = "/BuildMenu/MainListBybuild";
|
var url = "/BuildMenu/MainListBybuild";
|
||||||
var send_data = {
|
var send_data = {
|
||||||
build: build
|
building_tag: building_tag
|
||||||
};
|
};
|
||||||
$.post(url, send_data, function (rel) {
|
$.post(url, send_data, function (rel) {
|
||||||
if (rel.code != "0000") {
|
if (rel.code != "0000") {
|
||||||
@ -683,8 +683,8 @@
|
|||||||
function GetSubList(main) {
|
function GetSubList(main) {
|
||||||
var url = "/BuildMenu/SubListNotAdd";
|
var url = "/BuildMenu/SubListNotAdd";
|
||||||
var send_data = {
|
var send_data = {
|
||||||
main: main,
|
main_system_tag: main,
|
||||||
build: SelectBuild
|
building_tag: SelectBuild
|
||||||
};
|
};
|
||||||
$.post(url, send_data, function (rel) {
|
$.post(url, send_data, function (rel) {
|
||||||
if (rel.code != "0000") {
|
if (rel.code != "0000") {
|
||||||
@ -791,9 +791,9 @@
|
|||||||
|
|
||||||
var url = "/BuildMenu/SavebuildMenuModal";
|
var url = "/BuildMenu/SavebuildMenuModal";
|
||||||
var send_data = {
|
var send_data = {
|
||||||
building_guid: $('#build_menu_building_modal').val(),
|
building_tag: $('#build_menu_building_modal').val(),
|
||||||
main_system_guid: $('#build_menu_main_modal').val(),
|
main_system_tag: $('#build_menu_main_modal').val(),
|
||||||
sub_system_guid: $('#build_menu_sub_modal').val(),
|
sub_system_tag: $('#build_menu_sub_modal').val(),
|
||||||
drawing: $('input[name="drawing"]:checked').val(),
|
drawing: $('input[name="drawing"]:checked').val(),
|
||||||
system_url: $('#build_menu_systemurl_modal').val(),
|
system_url: $('#build_menu_systemurl_modal').val(),
|
||||||
icon_click: icon_click,
|
icon_click: icon_click,
|
||||||
@ -822,22 +822,22 @@
|
|||||||
$('#buildMenu_table').on("click", "button.edit-btn", function () {
|
$('#buildMenu_table').on("click", "button.edit-btn", function () {
|
||||||
var url = "/BuildMenu/GetBuildMenu";
|
var url = "/BuildMenu/GetBuildMenu";
|
||||||
var send_data = {
|
var send_data = {
|
||||||
build: $(this).parents('tr').attr('bg-guid'),
|
building_tag: $(this).parents('tr').attr('bg-guid'),
|
||||||
main: $(this).parents('tr').attr('ms-guid'),
|
main_system_tag: $(this).parents('tr').attr('ms-guid'),
|
||||||
sub: $(this).parents('tr').attr('ss-guid')
|
sub_system_tag: $(this).parents('tr').attr('ss-guid')
|
||||||
};
|
};
|
||||||
$.post(url, send_data, function (rel) {
|
$.post(url, send_data, function (rel) {
|
||||||
if (rel.code != "0000") {
|
if (rel.code != "0000") {
|
||||||
toast_error(rel.msg);
|
toast_error(rel.msg);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$('#build_menu_building_modal').val(rel.data.building_guid);
|
$('#build_menu_building_modal').val(rel.data.building_tag);
|
||||||
$('#build_menu_main_modal').val(rel.data.main_system_guid);
|
$('#build_menu_main_modal').val(rel.data.main_system_tag);
|
||||||
$('#build_menu_building_modal').attr('disabled', true);
|
$('#build_menu_building_modal').attr('disabled', true);
|
||||||
$('#build_menu_main_modal').attr('disabled', true);
|
$('#build_menu_main_modal').attr('disabled', true);
|
||||||
$('#build_menu_sub_modal').attr('disabled', true);
|
$('#build_menu_sub_modal').attr('disabled', true);
|
||||||
$('#build_menu_sub_modal').append($("<option />").val(rel.data.sub_system_guid).text(rel.data.sub_system_guid_name));
|
$('#build_menu_sub_modal').append($("<option />").val(rel.data.sub_system_tag).text(rel.data.sub_system_guid_name));
|
||||||
$('#build_menu_sub_modal').val(rel.data.sub_system_guid);
|
$('#build_menu_sub_modal').val(rel.data.sub_system_tag);
|
||||||
$("input[name*='drawing'][value='" + rel.data.drawing + "']").prop("checked", true);
|
$("input[name*='drawing'][value='" + rel.data.drawing + "']").prop("checked", true);
|
||||||
if (rel.data.planimetric_click == 1) {
|
if (rel.data.planimetric_click == 1) {
|
||||||
$('input[name="planimetric_click"]').prop("checked", true)
|
$('input[name="planimetric_click"]').prop("checked", true)
|
||||||
@ -911,9 +911,9 @@
|
|||||||
}
|
}
|
||||||
$('#buildMenu_table').on("click", "button.del-btn", function () {
|
$('#buildMenu_table').on("click", "button.del-btn", function () {
|
||||||
var send_data = {
|
var send_data = {
|
||||||
build: $(this).parents('tr').attr('bg-guid'),
|
building_tag: $(this).parents('tr').attr('bg-guid'),
|
||||||
main: $(this).parents('tr').attr('ms-guid'),
|
main_system_tag: $(this).parents('tr').attr('ms-guid'),
|
||||||
sub: $(this).parents('tr').attr('ss-guid')
|
sub_system_tag: $(this).parents('tr').attr('ss-guid')
|
||||||
};
|
};
|
||||||
Swal.fire(
|
Swal.fire(
|
||||||
{
|
{
|
||||||
@ -966,9 +966,9 @@
|
|||||||
});
|
});
|
||||||
function AddFloor() {
|
function AddFloor() {
|
||||||
var send_data = {
|
var send_data = {
|
||||||
build: SelectBuild,
|
building_tag: SelectBuild,
|
||||||
main: SelectMainSys,
|
main_system_tag: SelectMainSys,
|
||||||
sub: SelectSubSys
|
sub_system_tag: SelectSubSys
|
||||||
};
|
};
|
||||||
var url = "/BuildMenu/GetNotUsefloor/";
|
var url = "/BuildMenu/GetNotUsefloor/";
|
||||||
$.post(url, send_data, function (rel) {
|
$.post(url, send_data, function (rel) {
|
||||||
@ -980,7 +980,7 @@
|
|||||||
$('#floor_check').empty();
|
$('#floor_check').empty();
|
||||||
$.each(rel.data, function (index, val) {
|
$.each(rel.data, function (index, val) {
|
||||||
checkbox += '<div class="col-3 mb-2 custom-control custom-checkbox align-content-center">';
|
checkbox += '<div class="col-3 mb-2 custom-control custom-checkbox align-content-center">';
|
||||||
checkbox += '<input type="checkbox" class="custom-control-input" name="selectfloor[]" id="' + val.value + '" value="' + val.value + ' " />';
|
checkbox += '<input type="checkbox" class="custom-control-input" name="selectfloor[]" id="' + val.value + '" value="' + val.name + ' " />';
|
||||||
checkbox += '<label class="custom-control-label" for="' + val.value + '">' + val.name + '</label>';
|
checkbox += '<label class="custom-control-label" for="' + val.value + '">' + val.name + '</label>';
|
||||||
checkbox += '</div>';
|
checkbox += '</div>';
|
||||||
});
|
});
|
||||||
@ -1003,9 +1003,9 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var send_data = {
|
var send_data = {
|
||||||
build: SelectBuild,
|
building_tag: SelectBuild,
|
||||||
main: SelectMainSys,
|
main_system_tag: SelectMainSys,
|
||||||
sub: SelectSubSys,
|
sub_system_tag: SelectSubSys,
|
||||||
floorlist: SelectAddFloor
|
floorlist: SelectAddFloor
|
||||||
};
|
};
|
||||||
var url = "/BuildMenu/SaveAddsubfloor/";
|
var url = "/BuildMenu/SaveAddsubfloor/";
|
||||||
@ -1023,7 +1023,7 @@
|
|||||||
}
|
}
|
||||||
$('#buildMenu_floor_table').on("click", "button.del-btn", function () {
|
$('#buildMenu_floor_table').on("click", "button.del-btn", function () {
|
||||||
var send_data = {
|
var send_data = {
|
||||||
subfloorguid: $(this).parents('tr').attr('ssf-guid')
|
sub_system_floor_id: $(this).parents('tr').attr('ssf-guid')
|
||||||
};
|
};
|
||||||
Swal.fire(
|
Swal.fire(
|
||||||
{
|
{
|
||||||
@ -1104,9 +1104,9 @@
|
|||||||
function GetFloorInSubSystem(floor = null) {
|
function GetFloorInSubSystem(floor = null) {
|
||||||
var url = "/BuildMenu/GetFloorInSubSystem";
|
var url = "/BuildMenu/GetFloorInSubSystem";
|
||||||
var send_data = {
|
var send_data = {
|
||||||
build: $('#build_menu_building_modal').val(),
|
building_tag: $('#build_menu_building_modal').val(),
|
||||||
main: $('#build_menu_main_modal').val(),
|
main_system_tag: $('#build_menu_main_modal').val(),
|
||||||
sub: $('#build_menu_sub_modal').val(),
|
sub_system_tag: $('#build_menu_sub_modal').val(),
|
||||||
};
|
};
|
||||||
$.post(url, send_data, function (rel) {
|
$.post(url, send_data, function (rel) {
|
||||||
if (rel.code != "0000") {
|
if (rel.code != "0000") {
|
||||||
|
Loading…
Reference in New Issue
Block a user