This commit is contained in:
cesar liu 2022-10-24 09:54:40 +08:00
commit 9f39811294
28 changed files with 20244 additions and 1260 deletions

File diff suppressed because it is too large Load Diff

View File

@ -44,7 +44,7 @@ namespace Backend.Controllers
try try
{ {
var sqlString = @$"SELECT A.priority, A.building_guid, A.full_name, A.ip_address, A.ip_port, (SELECT COUNT(*) FROM floor f WHERE f.deleted = 0 AND f.building_guid = A.building_guid) AS 'floorNum', A.created_at var sqlString = @$"SELECT A.priority, A.building_tag, A.full_name, A.ip_address, A.ip_port, (SELECT COUNT(*) FROM floor f WHERE f.deleted = 0 AND f.building_tag = A.building_tag) AS 'floorNum', A.created_at
FROM building A FROM building A
WHERE A.deleted = 0 WHERE A.deleted = 0
ORDER BY A.priority ASC, A.created_at DESC"; ORDER BY A.priority ASC, A.created_at DESC";
@ -78,8 +78,8 @@ namespace Backend.Controllers
//判斷監控主機IP是否重複 //判斷監控主機IP是否重複
var judgeIPAddressRepeat = true; var judgeIPAddressRepeat = true;
var sWhere = $@"deleted = 0 AND ip_address = @ip_address AND ip_port = @ip_port AND building_guid != @building_guid"; var sWhere = $@"deleted = 0 AND ip_address = @ip_address AND ip_port = @ip_port AND building_tag != @building_tag";
var buildInfos = await backendRepository.GetAllAsync<BuildInfo>("building", sWhere, new { ip_address = post.Ip_address, ip_port = post.Ip_port, building_guid = post.Building_guid }); var buildInfos = await backendRepository.GetAllAsync<BuildInfo>("building", sWhere, new { ip_address = post.Ip_address, ip_port = post.Ip_port, building_tag = post.building_tag });
if (buildInfos.Count == 0) if (buildInfos.Count == 0)
{ {
judgeIPAddressRepeat = false; judgeIPAddressRepeat = false;
@ -87,19 +87,25 @@ namespace Backend.Controllers
if (!judgeIPAddressRepeat) if (!judgeIPAddressRepeat)
{ {
//新增 //Check for duplicate building tag
if (post.Building_guid == "0") sWhere = $@"deleted = 0 AND building_tag = @Building_tag";
{ buildInfos = await backendRepository.GetAllAsync<BuildInfo>("building", sWhere, new { building_tag = post.building_tag });
//產生一組GUID
var guid = Guid.NewGuid(); //大樓GUID
if (buildInfos.Count > 0)
{
apiResult.Code = "0002";
apiResult.Msg = "區域代號不可重複";
return apiResult;
}
//新增
//抓取當前的Priority //抓取當前的Priority
var current_priority = await backendRepository.GetCurrentPriority("building"); var current_priority = await backendRepository.GetCurrentPriority("building");
Dictionary<string, object> building = new Dictionary<string, object>(); Dictionary<string, object> building = new Dictionary<string, object>();
building = new Dictionary<string, object>() building = new Dictionary<string, object>()
{ {
{ "@building_guid", guid}, { "@building_tag", post.building_tag},
{ "@full_name", post.Full_name}, { "@full_name", post.Full_name},
{ "@ip_address", post.Ip_address}, { "@ip_address", post.Ip_address},
{ "@ip_port", post.Ip_port}, { "@ip_port", post.Ip_port},
@ -111,7 +117,48 @@ namespace Backend.Controllers
apiResult.Code = "0000"; apiResult.Code = "0000";
apiResult.Msg = "新增成功"; apiResult.Msg = "新增成功";
} }
else //修改 else
{
apiResult.Code = "0001";
apiResult.Msg = "監控主機IP不可重複";
}
}
catch (Exception exception)
{
apiResult.Code = "9999";
apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
string json = System.Text.Json.JsonSerializer.Serialize(post);
Logger.LogError("【" + controllerName + "/" + actionName + "】" + json);
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
}
return apiResult;
}
/// <summary>
/// 新增 / 修改 區域基本資料
/// </summary>
/// <param name="post"></param>
/// <returns></returns>
[HttpPost]
public async Task<ApiResult<string>> EditBuildInfo(BuildInfo post)
{
ApiResult<string> apiResult = new ApiResult<string>();
try
{
//判斷監控主機IP是否重複
var judgeIPAddressRepeat = true;
var sWhere = $@"deleted = 0 AND ip_address = @ip_address AND ip_port = @ip_port AND building_tag != @building_tag";
var buildInfos = await backendRepository.GetAllAsync<BuildInfo>("building", sWhere, new { ip_address = post.Ip_address, ip_port = post.Ip_port, building_tag = post.building_tag });
if (buildInfos.Count == 0)
{
judgeIPAddressRepeat = false;
}
if (!judgeIPAddressRepeat)
{ {
Dictionary<string, object> building = new Dictionary<string, object>(); Dictionary<string, object> building = new Dictionary<string, object>();
building = new Dictionary<string, object>() building = new Dictionary<string, object>()
@ -122,12 +169,11 @@ namespace Backend.Controllers
{ "@updated_by", myUserInfo.Userinfo_guid}, { "@updated_by", myUserInfo.Userinfo_guid},
{ "@updated_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} { "@updated_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}
}; };
await backendRepository.UpdateOneByCustomTable(building, "building", "building_guid='" + post.Building_guid + "'"); await backendRepository.UpdateOneByCustomTable(building, "building", "building_tag='" + post.building_tag + "'");
apiResult.Code = "0000"; apiResult.Code = "0000";
apiResult.Msg = "修改成功"; apiResult.Msg = "修改成功";
} }
}
else else
{ {
apiResult.Code = "0001"; apiResult.Code = "0001";
@ -148,14 +194,14 @@ namespace Backend.Controllers
} }
[HttpPost] [HttpPost]
public async Task<ApiResult<string>> DeleteOneBuild(string guid) public async Task<ApiResult<string>> DeleteOneBuild(string tag)
{ {
var apiResult = new ApiResult<string>(); var apiResult = new ApiResult<string>();
try try
{ {
string sWhere = @$"deleted = @Deleted AND building_guid = @Guid"; string sWhere = @$"deleted = @Deleted AND building_tag = @Tag";
object param = new { Deleted = 0, Guid = guid }; object param = new { Deleted = 0, Tag = tag };
var buildInfo = await backendRepository.GetOneAsync<BuildInfo>("building", sWhere, param); var buildInfo = await backendRepository.GetOneAsync<BuildInfo>("building", sWhere, param);
@ -167,8 +213,8 @@ namespace Backend.Controllers
} }
//檢查是否有未刪除的區域選單 //檢查是否有未刪除的區域選單
var sbuildMenuWhere = $@"building_guid = @Guid"; var sbuildMenuWhere = $@"building_tag = @Tag";
var buildMenus = await backendRepository.GetAllAsync<BuildMenu>("building_menu", sbuildMenuWhere, new { Guid = guid }); var buildMenus = await backendRepository.GetAllAsync<BuildMenu>("building_menu", sbuildMenuWhere, new { Tag = tag });
if (buildMenus.Count > 0) if (buildMenus.Count > 0)
{ {
@ -178,8 +224,8 @@ namespace Backend.Controllers
} }
//檢查底下是否有未刪除的樓層 //檢查底下是否有未刪除的樓層
var sfloorWhere = $@"deleted = 0 AND building_guid = @Guid"; var sfloorWhere = $@"deleted = 0 AND building_tag = @tag";
var floors = await backendRepository.GetAllAsync<BuildFloor>("floor", sfloorWhere, new { Guid = guid }); var floors = await backendRepository.GetAllAsync<BuildFloor>("floor", sfloorWhere, new { Tag = tag });
if (floors.Count > 0) if (floors.Count > 0)
{ {
@ -189,7 +235,7 @@ namespace Backend.Controllers
return apiResult; return apiResult;
} }
await backendRepository.DeleteOne(guid, "building", "building_guid"); await backendRepository.DeleteOne(tag, "building", "building_tag");
apiResult.Code = "0000"; apiResult.Code = "0000";
apiResult.Msg = "刪除成功"; apiResult.Msg = "刪除成功";
@ -199,7 +245,7 @@ namespace Backend.Controllers
{ {
apiResult.Code = "9999"; apiResult.Code = "9999";
apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
Logger.LogError("【" + controllerName + "/" + actionName + "】" + "building_guid=" + guid); Logger.LogError("【" + controllerName + "/" + actionName + "】" + "building_tag=" + tag);
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
} }
return apiResult; return apiResult;
@ -223,7 +269,7 @@ namespace Backend.Controllers
Dictionary<string, object> building_priority_dic = new Dictionary<string, object>(); Dictionary<string, object> building_priority_dic = new Dictionary<string, object>();
building_priority_dic = new Dictionary<string, object>() building_priority_dic = new Dictionary<string, object>()
{ {
{ "building_guid", building_priority.Building_guid}, { "building_tag", building_priority.Building_tag},
{ "@priority", building_priority.Priority}, { "@priority", building_priority.Priority},
{ "@updated_by", myUserInfo.Userinfo_guid}, { "@updated_by", myUserInfo.Userinfo_guid},
{ "@updated_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} { "@updated_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}
@ -232,14 +278,9 @@ namespace Backend.Controllers
building_priorities.Add(building_priority_dic); building_priorities.Add(building_priority_dic);
} }
var sql = $@"UPDATE building SET priority = @priority, updated_by = @updated_by, updated_at=@updated_at WHERE building_guid = @building_guid"; var sql = $@"UPDATE building SET priority = @priority, updated_by = @updated_by, updated_at=@updated_at WHERE building_tag = @building_tag";
await backendRepository.ExecuteSql(sql, building_priorities); await backendRepository.ExecuteSql(sql, building_priorities);
#region
await backendRepository.ManualInsertBackgroundServiceTask("", "", "building", "update_list", building_priorities);
#endregion
} }
apiResult.Code = "0000"; apiResult.Code = "0000";
@ -261,7 +302,7 @@ namespace Backend.Controllers
/// <param name="post"></param> /// <param name="post"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
public async Task<ApiResult<List<BuildFloor>>> BuildFloorList(string BuildGuid) public async Task<ApiResult<List<BuildFloor>>> BuildFloorList(string build_tag)
{ {
ApiResult<List<BuildFloor>> apiResult = new ApiResult<List<BuildFloor>>(); ApiResult<List<BuildFloor>> apiResult = new ApiResult<List<BuildFloor>>();
List<BuildFloor> buildInfo = new List<BuildFloor>(); List<BuildFloor> buildInfo = new List<BuildFloor>();
@ -271,9 +312,9 @@ namespace Backend.Controllers
var sqlString = @$"SELECT A.floor_guid, A.full_name, InitMapName + '.svg' AS 'initMapName', A.priority, A.created_at var sqlString = @$"SELECT A.floor_guid, A.full_name, InitMapName + '.svg' AS 'initMapName', A.priority, A.created_at
FROM floor A FROM floor A
WHERE deleted = @deleted WHERE deleted = @deleted
AND A.building_guid = @building_guid AND A.building_tag = @building_tag
ORDER BY A.priority ASC"; ORDER BY A.priority ASC";
buildInfo = await backendRepository.GetAllAsync<BuildFloor>(sqlString, new { deleted = 0, building_guid = BuildGuid }); buildInfo = await backendRepository.GetAllAsync<BuildFloor>(sqlString, new { deleted = 0, building_tag = build_tag });
apiResult.Code = "0000"; apiResult.Code = "0000";
apiResult.Data = buildInfo; apiResult.Data = buildInfo;
@ -348,13 +389,13 @@ namespace Backend.Controllers
var floor_map_guid = Guid.NewGuid(); var floor_map_guid = Guid.NewGuid();
//抓取當前的Priority //抓取當前的Priority
var current_priority = await backendRepository.GetCurrentPriority("floor", "deleted = 0 AND building_guid = '" + post.Building_guid + "'"); var current_priority = await backendRepository.GetCurrentPriority("floor", "deleted = 0 AND building_tag = '" + post.Building_tag + "'");
Dictionary<string, object> floor = new Dictionary<string, object>(); Dictionary<string, object> floor = new Dictionary<string, object>();
floor = new Dictionary<string, object>() floor = new Dictionary<string, object>()
{ {
{ "@floor_guid", guid}, { "@floor_guid", guid},
{ "@building_guid", post.Building_guid}, { "@building_tag", post.Building_tag},
{ "@full_name", post.Full_name}, { "@full_name", post.Full_name},
{ "@InitMapName", post.InitMapName}, { "@InitMapName", post.InitMapName},
{ "@floor_map_name", floor_map_guid}, { "@floor_map_name", floor_map_guid},
@ -376,26 +417,6 @@ namespace Backend.Controllers
} }
} }
#region
List<Repository.Models.FileInfo> fileInfos = new List<Repository.Models.FileInfo>();
if (post.MapFile != null)
{
var split = post.MapFile.FileName.Split(".");
var fileName = floor_map_guid + "." + split[split.Length - 1];
var fullPath = Path.Combine(mapFileSaveAsPath, fileName);
Repository.Models.FileInfo fileInfo = new Repository.Models.FileInfo();
fileInfo.Folder = "floor_map";
fileInfo.OriginalFileName = null;
fileInfo.FileName = fileName;
fileInfo.File = fullPath;
fileInfos.Add(fileInfo);
await backendRepository.ManualInsertFileBackgroundServiceTask("", post.Building_guid, "floor", fileInfos);
}
#endregion
apiResult.Code = "0000"; apiResult.Code = "0000";
apiResult.Msg = "新增成功"; apiResult.Msg = "新增成功";
} }
@ -436,26 +457,6 @@ namespace Backend.Controllers
} }
} }
#region
List<Repository.Models.FileInfo> fileInfos = new List<Repository.Models.FileInfo>();
if (post.MapFile != null)
{
var split = post.MapFile.FileName.Split(".");
var fileName = floor_map_guid + "." + split[split.Length - 1];
var fullPath = Path.Combine(mapFileSaveAsPath, fileName);
Repository.Models.FileInfo fileInfo = new Repository.Models.FileInfo();
fileInfo.Folder = "floor_map";
fileInfo.OriginalFileName = buildFloor.Floor_map_name + ".svg";
fileInfo.FileName = fileName;
fileInfo.File = fullPath;
fileInfos.Add(fileInfo);
}
await backendRepository.ManualInsertFileBackgroundServiceTask("", post.Building_guid, "floor", fileInfos);
#endregion
apiResult.Code = "0000"; apiResult.Code = "0000";
apiResult.Msg = "修改成功"; apiResult.Msg = "修改成功";
} }
@ -502,10 +503,6 @@ namespace Backend.Controllers
var sql = $@"UPDATE floor SET priority = @priority, updated_by = @updated_by, updated_at=@updated_at WHERE floor_guid = @floor_guid"; var sql = $@"UPDATE floor SET priority = @priority, updated_by = @updated_by, updated_at=@updated_at WHERE floor_guid = @floor_guid";
await backendRepository.ExecuteSql(sql, floor_priorities); await backendRepository.ExecuteSql(sql, floor_priorities);
#region
await backendRepository.ManualInsertBackgroundServiceTask("", "", "floor", "update_list", floor_priorities);
#endregion
} }
apiResult.Code = "0000"; apiResult.Code = "0000";
@ -547,20 +544,20 @@ namespace Backend.Controllers
//判斷區域選單是否還有使用該樓層 //判斷區域選單是否還有使用該樓層
var sub_system_where = $@"SELECT var sub_system_where = $@"SELECT
CONCAT(b.full_name, ' - ', ms.full_name, ' - ', ss.full_name) CONCAT(b.full_name, ' - ', mv.system_key, ' - ', sv.system_key)
FROM ( FROM (
SELECT SELECT
ssf.building_guid, ssf.building_tag,
ssf.main_system_guid, ssf.main_system_tag,
ssf.sub_system_guid ssf.sub_system_tag
FROM sub_system_floor ssf FROM sub_system_floor ssf
WHERE ssf.deleted = 0 AND floor_guid = @Guid WHERE ssf.deleted = 0 AND ssf.floor_tag = @floor_tag
) ssf ) ssf
LEFT JOIN building b ON ssf.building_guid = b.building_guid AND b.deleted = 0 LEFT JOIN building b ON ssf.building_tag = b.building_tag AND b.deleted = 0
LEFT JOIN main_system ms ON ssf.main_system_guid = ms.main_system_guid AND ms.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 sub_system ss ON ssf.sub_system_guid = ss.sub_system_guid AND ss.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 { Guid = guid }); 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";

View File

@ -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,58 +139,103 @@ 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 }, {"@left_drawing",buildMenu.left_drawing },
{"@right_drawing",buildMenu.right_drawing },
{"@created_by",myUserInfo.Userinfo_guid }, {"@created_by",myUserInfo.Userinfo_guid },
{"@planimetric_click",buildMenu.planimetric_click} {"@left_planimetric_click",buildMenu.left_planimetric_click},
{"@right_planimetric_click",buildMenu.right_planimetric_click}
}; };
if (buildMenu.drawing == 2) if (buildMenu.left_drawing == 2)
{ {
if (buildMenu.system_url != null && buildMenu.system_url.CompareTo("http://") < 0 && buildMenu.system_url.CompareTo("https://") < 0) if (buildMenu.left_system_url != null && buildMenu.left_system_url.CompareTo("http://") < 0 && buildMenu.left_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.left_system_url = string.Format("http://{0}:{1}{2}", building.Ip_address, building.Ip_port, buildMenu.left_system_url);
} }
dictionary.Add("@system_url", buildMenu.system_url); dictionary.Add("@left_system_url", buildMenu.left_system_url);
} }
else if (buildMenu.drawing == 4) else if (buildMenu.left_drawing == 4)
{ {
if (buildMenu.system_url != null && buildMenu.system_url.CompareTo("http://") < 0 && buildMenu.system_url.CompareTo("https://") < 0) if (buildMenu.left_system_url != null && buildMenu.left_system_url.CompareTo("http://") < 0 && buildMenu.left_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.left_system_url = string.Format("http://{0}:{1}{2}", building.Ip_address, building.Ip_port, buildMenu.left_system_url);
} }
dictionary.Add("@riser_diagram_url", buildMenu.riser_diagram_url); dictionary.Add("@left_riser_diagram_url", buildMenu.left_riser_diagram_url);
dictionary.Add("@icon_click", buildMenu.icon_click); dictionary.Add("@left_icon_click", buildMenu.left_icon_click);
dictionary.Add("@icon_click_url", buildMenu.icon_click_url); dictionary.Add("@left_icon_click_url", buildMenu.left_icon_click_url);
dictionary.Add("@icon_click_url_width", buildMenu.icon_click_url_width); dictionary.Add("@left_icon_click_url_width", buildMenu.left_icon_click_url_width);
dictionary.Add("@icon_click_url_height", buildMenu.icon_click_url_height); dictionary.Add("@left_icon_click_url_height", buildMenu.left_icon_click_url_height);
} }
else if (buildMenu.drawing == 1) else if (buildMenu.left_drawing == 1)
{ {
dictionary.Add("@planimetric_floor_guid", buildMenu.planimetric_floor_guid); dictionary.Add("@planimetric_floor_guid", buildMenu.left_planimetric_floor_guid);
}
if (buildMenu.right_drawing == 2)
{
if (buildMenu.right_system_url != null && buildMenu.right_system_url.CompareTo("http://") < 0 && buildMenu.right_system_url.CompareTo("https://") < 0)
{
//未包含http || https 抓該棟ip + port
var building_where = @"deleted = 0 AND building_tag = @Building_tag";
var building = await backendRepository.GetOneAsync<BuildInfo>("building", building_where, new { Building_tag = buildMenu.building_tag });
buildMenu.right_system_url = string.Format("http://{0}:{1}{2}", building.Ip_address, building.Ip_port, buildMenu.right_system_url);
}
dictionary.Add("@right_system_url", buildMenu.right_system_url);
}
else if (buildMenu.right_drawing == 4)
{
if (buildMenu.right_system_url != null && buildMenu.right_system_url.CompareTo("http://") < 0 && buildMenu.right_system_url.CompareTo("https://") < 0)
{
//未包含http || https 抓該棟ip + port
var building_where = @"deleted = 0 AND building_tag = @Building_tag";
var building = await backendRepository.GetOneAsync<BuildInfo>("building", building_where, new { Building_tag = buildMenu.building_tag });
buildMenu.right_system_url = string.Format("http://{0}:{1}{2}", building.Ip_address, building.Ip_port, buildMenu.right_system_url);
}
dictionary.Add("@right_riser_diagram_url", buildMenu.right_riser_diagram_url);
dictionary.Add("@right_icon_click", buildMenu.right_icon_click);
dictionary.Add("@right_icon_click_url", buildMenu.right_icon_click_url);
dictionary.Add("@right_icon_click_url_width", buildMenu.right_icon_click_url_width);
dictionary.Add("@right_icon_click_url_height", buildMenu.right_icon_click_url_height);
}
else if (buildMenu.right_drawing == 1)
{
dictionary.Add("@right_planimetric_floor_guid", buildMenu.right_planimetric_floor_guid);
} }
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 +243,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 = "儲存成功";
} }
@ -227,47 +270,85 @@ namespace Backend.Controllers
{ {
var dictionary = new Dictionary<string, object>() var dictionary = new Dictionary<string, object>()
{ {
{"@drawing",buildMenu.drawing }, {"@left_drawing",buildMenu.left_drawing },
{"@right_drawing",buildMenu.right_drawing },
{"@updated_by",myUserInfo.Userinfo_guid }, {"@updated_by",myUserInfo.Userinfo_guid },
{"@updated_at",DateTime.Now }, {"@updated_at",DateTime.Now },
{"@planimetric_click",buildMenu.planimetric_click} {"@left_planimetric_click",buildMenu.left_planimetric_click},
{"@right_planimetric_click",buildMenu.right_planimetric_click}
}; };
if (buildMenu.drawing == 2)
if (buildMenu.left_drawing == 2)
{ {
if (buildMenu.system_url != null && buildMenu.system_url.CompareTo("http://") < 0 && buildMenu.system_url.CompareTo("https://") < 0) if (buildMenu.left_system_url != null && buildMenu.left_system_url.CompareTo("http://") < 0 && buildMenu.left_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.left_system_url = string.Format("http://{0}:{1}{2}", building.Ip_address, building.Ip_port, buildMenu.left_system_url);
} }
dictionary.Add("@system_url", buildMenu.system_url); dictionary.Add("@left_system_url", buildMenu.left_system_url);
} }
else if (buildMenu.drawing == 4) else if (buildMenu.left_drawing == 4)
{ {
if (buildMenu.system_url != null && buildMenu.system_url.CompareTo("http://") < 0 && buildMenu.system_url.CompareTo("https://") < 0) if (buildMenu.left_system_url != null && buildMenu.left_system_url.CompareTo("http://") < 0 && buildMenu.left_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.left_system_url = string.Format("http://{0}:{1}{2}", building.Ip_address, building.Ip_port, buildMenu.left_system_url);
} }
dictionary.Add("@riser_diagram_url", buildMenu.riser_diagram_url); dictionary.Add("@left_riser_diagram_url", buildMenu.left_riser_diagram_url);
dictionary.Add("@icon_click", buildMenu.icon_click); dictionary.Add("@left_icon_click", buildMenu.left_icon_click);
dictionary.Add("@icon_click_url", buildMenu.icon_click_url); dictionary.Add("@left_icon_click_url", buildMenu.left_icon_click_url);
dictionary.Add("@icon_click_url_width", buildMenu.icon_click_url_width); dictionary.Add("@left_icon_click_url_width", buildMenu.left_icon_click_url_width);
dictionary.Add("@icon_click_url_height", buildMenu.icon_click_url_height); dictionary.Add("@left_icon_click_url_height", buildMenu.left_icon_click_url_height);
} }
else if (buildMenu.drawing == 1) else if (buildMenu.left_drawing == 1)
{ {
dictionary.Add("@planimetric_floor_guid", buildMenu.planimetric_floor_guid); dictionary.Add("@left_planimetric_floor_guid", buildMenu.left_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}'"); if (buildMenu.right_drawing == 2)
{
if (buildMenu.right_system_url != null && buildMenu.right_system_url.CompareTo("http://") < 0 && buildMenu.right_system_url.CompareTo("https://") < 0)
{
//未包含http || https 抓該棟ip + port
var building_where = @"deleted = 0 AND building_tag = @Building_tag";
var building = await backendRepository.GetOneAsync<BuildInfo>("building", building_where, new { Building_tag = buildMenu.building_tag });
buildMenu.right_system_url = string.Format("http://{0}:{1}{2}", building.Ip_address, building.Ip_port, buildMenu.right_system_url);
}
dictionary.Add("@right_system_url", buildMenu.right_system_url);
}
else if (buildMenu.right_drawing == 4)
{
if (buildMenu.right_system_url != null && buildMenu.right_system_url.CompareTo("http://") < 0 && buildMenu.right_system_url.CompareTo("https://") < 0)
{
//未包含http || https 抓該棟ip + port
var building_where = @"deleted = 0 AND building_tag = @Building_tag";
var building = await backendRepository.GetOneAsync<BuildInfo>("building", building_where, new { Building_tag = buildMenu.building_tag });
buildMenu.right_system_url = string.Format("http://{0}:{1}{2}", building.Ip_address, building.Ip_port, buildMenu.right_system_url);
}
dictionary.Add("@right_riser_diagram_url", buildMenu.right_riser_diagram_url);
dictionary.Add("@right_icon_click", buildMenu.right_icon_click);
dictionary.Add("@right_icon_click_url", buildMenu.right_icon_click_url);
dictionary.Add("@right_icon_click_url_width", buildMenu.right_icon_click_url_width);
dictionary.Add("@right_icon_click_url_height", buildMenu.right_icon_click_url_height);
}
else if (buildMenu.right_drawing == 1)
{
dictionary.Add("@right_planimetric_floor_guid", buildMenu.right_planimetric_floor_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 = "儲存成功";
@ -291,15 +372,20 @@ namespace Backend.Controllers
try try
{ {
buildMenuTables = await backendRepository.GetAllAsync<BuildMenuTable>($@"select bm.*, buildMenuTables = await backendRepository.GetAllAsync<BuildMenuTable>($@"select bm.*,
case drawing when 1 then '' when 2 then '' when 4 then '' end drawing_name, case left_drawing when 1 then '' when 2 then '' when 4 then '' end left_drawing_name,
case icon_click when 1 then '開' when 0 then '關' end icon_click_name, case left_icon_click when 1 then '開' when 0 then '關' end left_icon_click_name,
case planimetric_click when 1 then '開' when 0 then '關' end planimetric_click_name, case left_planimetric_click when 1 then '開' when 0 then '關' end left_planimetric_click_name,
ms.full_name main_system_guid_name, ss.full_name sub_system_guid_name,ff.full_name floor_guid_name case right_drawing when 1 then '' when 2 then '' when 4 then '' end right_drawing_name,
case right_icon_click when 1 then '開' when 0 then '關' end right_icon_click_name,
case right_planimetric_click when 1 then '開' when 0 then '關' end right_planimetric_click_name,
mv.system_key main_system_guid_name, sv.system_key sub_system_guid_name,lf.full_name left_floor_guid_name, rf.full_name right_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 lf on lf.floor_guid = bm.left_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 }); 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 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 +410,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 bm.*, 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 +434,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 +445,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 +466,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 and sf.building_tag = f.building_tag
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 +501,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 +537,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 +561,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 +594,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 +602,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 +616,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;

View File

@ -49,25 +49,25 @@ namespace Backend.Controllers
bm.*, bm.*,
b.full_name AS bFull_name, b.full_name AS bFull_name,
b.priority AS bPriority, b.priority AS bPriority,
ms.full_name AS mFull_name, mv.system_key AS mFull_name,
ms.priority AS mPriority, mv.system_priority AS mPriority,
ss.full_name AS sFull_name, sv.system_key AS sFull_name,
ss.priority AS sPriority sv.system_priority AS sPriority
FROM building_menu bm FROM building_menu bm
LEFT JOIN building b ON bm.building_guid = b.building_guid AND b.deleted = 0 LEFT JOIN building b ON bm.building_tag = b.building_tag AND b.deleted = 0
LEFT JOIN main_system ms ON bm.main_system_guid = ms.main_system_guid AND ms.deleted = 0 LEFT JOIN variable mv ON bm.main_system_tag = mv.system_value AND mv.deleted = 0
LEFT JOIN sub_system ss ON bm.sub_system_guid = ss.sub_system_guid AND ss.deleted = 0"; LEFT JOIN variable sv ON bm.sub_system_tag = sv.system_value AND sv.deleted = 0";
if (!string.IsNullOrEmpty(filter)) if (!string.IsNullOrEmpty(filter))
{ {
sql += $@" WHERE ( sql += $@" WHERE (
b.full_name LIKE CONCAT('%', @Filter, '%') b.full_name LIKE CONCAT('%', @Filter, '%')
OR ms.full_name LIKE CONCAT('%', @Filter, '%') OR mv.system_key LIKE CONCAT('%', @Filter, '%')
OR ss.full_name LIKE CONCAT('%', @Filter, '%') OR sv.system_key LIKE CONCAT('%', @Filter, '%')
)"; )";
} }
sql += $@" ORDER BY b.priority, ms.priority, ss.priority, ss.created_at DESC"; sql += $@" ORDER BY b.priority, mv.system_priority, sv.system_priority, sv.created_at DESC";
var buildingMenuRawDatas = await backendRepository.GetAllAsync<BuildingMenuRawData>(sql, new { Filter = filter }); var buildingMenuRawDatas = await backendRepository.GetAllAsync<BuildingMenuRawData>(sql, new { Filter = filter });
@ -79,48 +79,49 @@ namespace Backend.Controllers
f.floor_map_name, f.floor_map_name,
f.priority AS fPriority f.priority AS fPriority
FROM sub_system_floor ssf FROM sub_system_floor ssf
LEFT JOIN floor f ON ssf.floor_guid = f.floor_guid AND f.deleted = 0 LEFT JOIN floor f ON ssf.floor_tag = f.full_name AND ssf.building_tag = f.building_tag AND f.deleted = 0
WHERE ssf.deleted = 0 WHERE ssf.deleted = 0
ORDER BY f.priority, f.created_at"; ORDER BY f.priority, f.created_at
";
var subSystemFloorRawDatas = await backendRepository.GetAllAsync<SubSystemFloorRawData>(sub_sql); var subSystemFloorRawDatas = await backendRepository.GetAllAsync<SubSystemFloorRawData>(sub_sql);
var buildingMenu_Group_Building_guid = buildingMenuRawDatas.GroupBy(x => x.Building_guid).ToList(); var buildingMenu_Group_Building_tag = buildingMenuRawDatas.GroupBy(x => x.building_tag).ToList();
List<BuildingCollapse> buildingCollapses = new List<BuildingCollapse>(); List<BuildingCollapse> buildingCollapses = new List<BuildingCollapse>();
foreach (var buildingMenus_Building_guid in buildingMenu_Group_Building_guid) foreach (var buildingMenus_Building_tag in buildingMenu_Group_Building_tag)
{ {
BuildingCollapse buildingCollapse = new BuildingCollapse(); BuildingCollapse buildingCollapse = new BuildingCollapse();
buildingCollapse.Building_guid = buildingMenus_Building_guid.Key; buildingCollapse.Building_tag = buildingMenus_Building_tag.Key;
buildingCollapse.Full_name = buildingMenus_Building_guid.First().bFull_name; buildingCollapse.Full_name = buildingMenus_Building_tag.First().bFull_name;
buildingCollapse.Main_systems = new List<Main_system>(); buildingCollapse.Main_systems = new List<Main_system>();
var buildingMenus_Group_Main_system_guid = buildingMenus_Building_guid.GroupBy(x => x.Main_system_guid).ToList(); var buildingMenus_Group_Main_system_tag = buildingMenus_Building_tag.GroupBy(x => x.main_system_tag).ToList();
foreach (var buildingMenus_Main_system_guid in buildingMenus_Group_Main_system_guid) foreach (var buildingMenus_Main_system_tag in buildingMenus_Group_Main_system_tag)
{ {
Main_system main_System = new Main_system(); Main_system main_System = new Main_system();
main_System.Main_system_guid = buildingMenus_Main_system_guid.Key; main_System.Main_system_tag = buildingMenus_Main_system_tag.Key;
main_System.Full_name = buildingMenus_Main_system_guid.First().mFull_name; main_System.Full_name = buildingMenus_Main_system_tag.First().mFull_name;
main_System.Sub_systems = new List<Sub_system>(); main_System.Sub_systems = new List<Sub_system>();
var buildingMenus_Group_Sub_system_guid = buildingMenus_Main_system_guid.GroupBy(x => x.Sub_system_guid).ToList(); var buildingMenus_Group_Sub_system_tag = buildingMenus_Main_system_tag.GroupBy(x => x.sub_system_tag).ToList();
foreach (var buildingMenus_Sub_system_guid in buildingMenus_Group_Sub_system_guid) foreach (var buildingMenus_Sub_system_tag in buildingMenus_Group_Sub_system_tag)
{ {
Sub_system sub_System = new Sub_system(); Sub_system sub_System = new Sub_system();
sub_System.Sub_system_guid = buildingMenus_Sub_system_guid.Key; sub_System.Sub_system_tag = buildingMenus_Sub_system_tag.Key;
sub_System.Full_name = buildingMenus_Sub_system_guid.First().sFull_name; sub_System.Full_name = buildingMenus_Sub_system_tag.First().sFull_name;
sub_System.Floors = new List<Floor>(); sub_System.Floors = new List<Floor>();
var floorRawDatas = subSystemFloorRawDatas.Where(x => x.Building_guid == buildingCollapse.Building_guid var floorRawDatas = subSystemFloorRawDatas.Where(x => x.building_tag == buildingCollapse.Building_tag
&& x.Main_system_guid == main_System.Main_system_guid && x.main_system_tag == main_System.Main_system_tag
&& x.Sub_system_guid == sub_System.Sub_system_guid).ToList(); && x.sub_system_tag == sub_System.Sub_system_tag).ToList();
foreach (var floorRawData in floorRawDatas) foreach (var floorRawData in floorRawDatas)
{ {
Floor floor = new Floor(); Floor floor = new Floor();
floor.Floor_guid = floorRawData.Floor_guid; floor.Floor_tag = floorRawData.Floor_tag;
floor.Full_name = floorRawData.fFull_name; floor.Full_name = floorRawData.fFull_name;
floor.InitMapName = floorRawData.InitMapName; floor.InitMapName = floorRawData.InitMapName;
floor.Floor_map_name = floorRawData.Floor_map_name; floor.Floor_map_name = floorRawData.Floor_map_name;
@ -165,10 +166,10 @@ namespace Backend.Controllers
var sql = $@"SELECT var sql = $@"SELECT
d.*, d.*,
d.full_name AS Device_full_name, d.device_last_name AS Device_full_name,
b.full_name AS Building_full_name, b.full_name AS Building_full_name,
ms.full_name AS Main_system_full_name, mv.system_key AS Main_system_full_name,
ss.full_name AS Sub_system_full_name, sv.system_key AS Sub_system_full_name,
f.full_name AS Floor_full_name, f.full_name AS Floor_full_name,
dk.device_image, dk.device_image,
CONCAT('{baseURL}', '{deviceKindFilePath}', dk.device_image) AS device_image_url, CONCAT('{baseURL}', '{deviceKindFilePath}', dk.device_image) AS device_image_url,
@ -179,7 +180,7 @@ namespace Backend.Controllers
dk.device_close_flashing, dk.device_close_flashing,
dk.device_error_flashing, dk.device_error_flashing,
(SELECT (SELECT
STRING_AGG( ISNULL(system_key, ' '), ',') GROUP_CONCAT( IFNULL(system_key, ' '), ',')
FROM device_disaster dd FROM device_disaster dd
JOIN variable v ON v.deleted = 0 AND v.system_type = 'disaster' AND v.system_value = dd.device_system_value JOIN variable v ON v.deleted = 0 AND v.system_type = 'disaster' AND v.system_value = dd.device_system_value
WHERE dd.device_guid = d.device_guid WHERE dd.device_guid = d.device_guid
@ -187,25 +188,27 @@ namespace Backend.Controllers
FROM ( FROM (
SELECT * SELECT *
FROM device d FROM device d
WHERE WHERE d.device_building_tag = @building_tag
d.building_guid = @Building_guid AND d.device_system_tag = @main_system_tag
AND d.main_system_guid = @Main_system_guid AND d.device_name_tag = @sub_system_tag
AND d.sub_system_guid = @Sub_system_guid AND d.device_floor_tag = @floor_tag
AND d.floor_guid = @Floor_guid
AND d.deleted = 0 AND d.deleted = 0
) d ) d
JOIN building b ON d.building_guid = b.building_guid JOIN building b ON d.device_building_tag = b.building_tag
JOIN main_system ms ON d.main_system_guid = ms.main_system_guid JOIN variable mv ON d.device_system_tag = mv.system_value AND mv.system_type = @main_system_type
JOIN sub_system ss ON d.sub_system_guid = ss.sub_system_guid JOIN variable sv ON d.device_name_tag = sv.system_value AND sv.system_type = @sub_system_type
JOIN floor f ON d.floor_guid = f.floor_guid JOIN floor f ON d.device_floor_tag = f.full_name AND d.device_building_tag = f.building_tag
LEFT JOIN device_kind dk ON dk.device_building_tag = d.device_building_tag LEFT JOIN device_kind dk ON dk.device_building_tag = d.device_building_tag AND dk.device_system_tag = d.device_system_tag AND dk.device_name_tag = d.device_name_tag
AND dk.device_system_tag = d.device_system_tag ORDER BY d.priority ASC, d.device_number ASC";
-- AND dk.device_floor_tag = d.device_floor_tag
AND dk.device_name_tag = d.device_name_tag
ORDER BY d.priority ASC, d.device_number ASC
";
var devices = await backendRepository.GetAllAsync<Device>(sql, post); var devices = await backendRepository.GetAllAsync<Device>(sql, new {
building_tag = post.building_tag,
main_system_tag = post.device_system_tag,
sub_system_tag = post.device_name_tag,
floor_tag = post.device_floor_tag,
main_system_type = main_system_type,
sub_system_type = sub_system_type
});
var sql_node = $@"SELECT var sql_node = $@"SELECT
dn.device_node_guid, dn.device_node_guid,
@ -250,8 +253,8 @@ namespace Backend.Controllers
d.*, d.*,
d.full_name AS Device_full_name, d.full_name AS Device_full_name,
b.full_name AS Building_full_name, b.full_name AS Building_full_name,
ms.full_name AS Main_system_full_name, mv.system_key AS Main_system_full_name,
ss.full_name AS Sub_system_full_name, sv.system_key AS Sub_system_full_name,
f.full_name AS Floor_full_name f.full_name AS Floor_full_name
FROM ( FROM (
SELECT * SELECT *
@ -260,13 +263,13 @@ namespace Backend.Controllers
d.device_guid = @Device_guid d.device_guid = @Device_guid
AND d.deleted = @Deleted AND d.deleted = @Deleted
) d ) d
JOIN building b ON d.building_guid = b.building_guid JOIN building b ON d.device_building_tag = b.building_tag
JOIN main_system ms ON d.main_system_guid = ms.main_system_guid JOIN variable mv ON d.device_system_tag = mv.system_value AND mv.system_type = @main_system_type
JOIN sub_system ss ON d.sub_system_guid = ss.sub_system_guid JOIN variable sv ON d.device_name_tag = sv.system_value AND sv.system_type = @sub_system_type
JOIN floor f ON d.floor_guid = f.floor_guid JOIN floor f ON d.device_floor_tag = f.full_name
"; ";
object param = new { Deleted = 0, Device_guid = guid }; object param = new { Deleted = 0, Device_guid = guid ,main_system_type = main_system_type , sub_system_type = sub_system_type };
var device = await backendRepository.GetOneAsync<Device>(sql, param); var device = await backendRepository.GetOneAsync<Device>(sql, param);
@ -358,10 +361,10 @@ namespace Backend.Controllers
Dictionary<string, object> deviceDic = new Dictionary<string, object>() Dictionary<string, object> deviceDic = new Dictionary<string, object>()
{ {
{ "@device_guid", guid}, { "@device_guid", guid},
{ "@building_guid", post.Building_guid}, { "@building_tag", post.Building_tag},
{ "@main_system_guid", post.Main_system_guid}, { "@main_system_tag", post.Main_system_tag},
{ "@sub_system_guid", post.Sub_system_guid}, { "@sub_system_tag", post.Sub_system_tag},
{ "@floor_guid", post.Floor_guid}, { "@floor_guid", post.Floor_tag},
{ "@full_name", device_name_tag + device_serial_tag}, { "@full_name", device_name_tag + device_serial_tag},
{ "@device_building_tag", device_building_tag}, { "@device_building_tag", device_building_tag},
{ "@device_system_tag", device_system_tag}, { "@device_system_tag", device_system_tag},
@ -805,7 +808,7 @@ namespace Backend.Controllers
try try
{ {
var rawDatas = await backendRepository.GetAllAsync<DeviceImportCheckTempRawData>("device_import_ckeck_temp", "is_correct = 1 ORDER BY device_building_tag, device_system_tag, device_floor_tag, device_name_tag"); var rawDatas = await backendRepository.GetAllAsync<DeviceImportCheckTempRawData>("import_niagara_tag", null,null,"device_building_tag, device_system_tag, device_floor_tag, device_name_tag");
var rawDatas_Group_Building_tag = rawDatas.GroupBy(x => x.Device_building_tag).ToList(); var rawDatas_Group_Building_tag = rawDatas.GroupBy(x => x.Device_building_tag).ToList();
List<DeviceImportCheckTempFilter> tempFilters = new List<DeviceImportCheckTempFilter>(); List<DeviceImportCheckTempFilter> tempFilters = new List<DeviceImportCheckTempFilter>();
@ -875,33 +878,31 @@ namespace Backend.Controllers
di.device_building_tag, di.device_building_tag,
di.device_system_tag, di.device_system_tag,
di.device_floor_tag, di.device_floor_tag,
di.device_name_tag, di.device_last_name_tag as device_name_tag,
di.device_serial_tag, di.device_serial_tag,
di.device_number, 0 as Device_disasters,
di.device_system_category_layer3, 0 as Device_disaster_type_text,
STRING_AGG( ISNULL(v.system_value, ' '), ',') AS Device_disasters, di.niagara_tags as device_number
STRING_AGG( ISNULL(v.system_key, ' '), ',') AS Device_disaster_type_text
FROM FROM
(SELECT (
SELECT
* *
FROM device_import_ckeck_temp di FROM
WHERE device_building_tag = @Device_building_tag import_niagara_tag intag
WHERE
device_building_tag = @Device_building_tag
AND device_system_tag = @Device_system_tag AND device_system_tag = @Device_system_tag
AND device_floor_tag = @Device_floor_tag AND device_floor_tag = @Device_floor_tag
AND device_name_tag = @Device_name_tag AND device_name_tag = @Device_name_tag
AND is_correct = 1 AND convert(intag.niagara_tags, nchar) NOT IN ( SELECT convert(d.device_number, nchar) FROM device d WHERE d.deleted = 0 )
AND device_number NOT IN (SELECT d.device_number FROM device d WHERE d.deleted = 0)
) di ) di
CROSS APPLY STRING_SPLIT(di.device_disaster, ',') dd GROUP BY
LEFT JOIN variable v ON v.system_type = 'disaster' AND v.system_value = dd.value di.device_building_tag,
GROUP BY di.device_building_tag,
di.device_system_tag, di.device_system_tag,
di.device_floor_tag, di.device_floor_tag,
di.device_name_tag, di.device_last_name_tag,
di.device_serial_tag, di.device_serial_tag,
di.device_number, di.niagara_tags";
di.device_system_category_layer3";
var deviceImports = await backendRepository.GetAllAsync<DeviceImportCheckTemp>(sql, post); var deviceImports = await backendRepository.GetAllAsync<DeviceImportCheckTemp>(sql, post);
@ -965,10 +966,10 @@ namespace Backend.Controllers
SELECT * SELECT *
FROM device d FROM device d
WHERE WHERE
d.building_guid = @Building_guid d.device_building_tag = @building_tag
AND d.main_system_guid = @Main_system_guid AND d.device_system_tag = @main_system_tag
AND d.sub_system_guid = @Sub_system_guid AND d.device_name_tag = @sub_system_tag
-- AND d.floor_guid = @Floor_guid -- AND d.floor_guid = @Floor_tag
AND d.deleted = 0 AND d.deleted = 0
) d ) d
GROUP BY d.device_building_tag, GROUP BY d.device_building_tag,
@ -978,8 +979,7 @@ namespace Backend.Controllers
LEFT JOIN device_kind dk ON dd.device_building_tag = dk.device_building_tag LEFT JOIN device_kind dk ON dd.device_building_tag = dk.device_building_tag
AND dd.device_system_tag = dk.device_system_tag AND dd.device_system_tag = dk.device_system_tag
-- AND dd.device_floor_tag = dk.device_floor_tag -- AND dd.device_floor_tag = dk.device_floor_tag
AND dd.device_name_tag = dk.device_name_tag AND dd.device_name_tag = dk.device_name_tag";
";
var deviceKinds = await backendRepository.GetAllAsync<DeviceKind>(sql, post); var deviceKinds = await backendRepository.GetAllAsync<DeviceKind>(sql, post);
@ -1259,35 +1259,26 @@ namespace Backend.Controllers
private async Task ResetDeviceGroup() private async Task ResetDeviceGroup()
{ {
//先刪除整個device_group //先刪除整個device_group
var delete_group_sql = @"IF EXISTS(SELECT* FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[device_group]') AND type in (N'U')) var delete_group_sql = @"DROP TABLE IF EXISTS `device_group` ;
BEGIN CREATE TABLE `device_group` (
DROP TABLE[dbo].[device_group] `id` int(11) NOT NULL,
END `device_disaster` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '',
`device_building_tag` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'guid',
CREATE TABLE [dbo].[device_group]( `device_floor_guid` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'guid',
[id] [int] IDENTITY(1,1) NOT NULL, `device_area_tag` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '',
[device_disaster] [varchar](50) NULL, `device_system_category_layer2` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'device_system_tag',
[device_building_guid] [varchar](36) NULL, `device_system_category_layer3` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'device_name_tag',
[device_floor_guid] [varchar](36) NULL, `device_amount` int(11) NOT NULL DEFAULT '0' COMMENT '',
[device_system_category_layer2] [varchar](50) NULL, PRIMARY KEY (`id`)
[device_system_category_layer3] [varchar](50) NULL, ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT=' - UI ';";
[device_amount] [int] NOT NULL,
CONSTRAINT [PK_device_group] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
)
ALTER TABLE [dbo].[device_group] ADD CONSTRAINT [DF_device_group_device_amount] DEFAULT ((0)) FOR [device_amount]
";
await backendRepository.ExecuteSql(delete_group_sql); await backendRepository.ExecuteSql(delete_group_sql);
//更新整個device_group //更新整個device_group
var insert_group_sql = @" var insert_group_sql = @"
INSERT INTO device_group (device_disaster, device_building_guid, device_floor_guid, device_system_category_layer2, device_system_category_layer3, device_amount) INSERT INTO device_group (device_disaster, device_building_tag, device_floor_guid, device_system_category_layer2, device_system_category_layer3, device_amount)
SELECT SELECT
dd.device_system_value AS device_disaster, dd.device_system_value AS device_disaster,
d.building_guid AS device_building_guid, d.building_tag AS device_building_tag,
d.floor_guid AS device_floor_guid, d.floor_guid AS device_floor_guid,
vv.device_system_category_layer2 AS device_system_category_layer2, vv.device_system_category_layer2 AS device_system_category_layer2,
d.device_system_category_layer3 AS device_system_category_layer3, d.device_system_category_layer3 AS device_system_category_layer3,
@ -1303,7 +1294,7 @@ namespace Backend.Controllers
) vv ON d.device_system_category_layer3 = vv.device_system_category_layer3 ) vv ON d.device_system_category_layer3 = vv.device_system_category_layer3
WHERE d.deleted = 0 WHERE d.deleted = 0
GROUP BY dd.device_system_value, GROUP BY dd.device_system_value,
d.building_guid, d.building_tag,
d.floor_guid, d.floor_guid,
vv.device_system_category_layer2, vv.device_system_category_layer2,
d.device_system_category_layer3"; d.device_system_category_layer3";
@ -1321,8 +1312,8 @@ namespace Backend.Controllers
{ {
{ "@id", deviceGroup.id}, { "@id", deviceGroup.id},
{ "@device_disaster", deviceGroup.device_disaster}, { "@device_disaster", deviceGroup.device_disaster},
{ "@device_building_guid", deviceGroup.device_building_guid}, { "@device_building_tag", deviceGroup.device_building_tag},
{ "@device_floor_guid", deviceGroup.device_floor_guid}, { "@device_floor_guid", deviceGroup.device_floor_tag},
{ "@device_system_category_layer2", deviceGroup.device_system_category_layer2}, { "@device_system_category_layer2", deviceGroup.device_system_category_layer2},
{ "@device_system_category_layer3", deviceGroup.device_system_category_layer3}, { "@device_system_category_layer3", deviceGroup.device_system_category_layer3},
{ "@device_amount", deviceGroup.device_amount}, { "@device_amount", deviceGroup.device_amount},
@ -1359,17 +1350,15 @@ namespace Backend.Controllers
SELECT * SELECT *
FROM device d FROM device d
WHERE WHERE
d.building_guid = @Building_guid d.device_building_tag = @building_tag
AND d.main_system_guid = @Main_system_guid AND d.device_system_tag = @main_system_tag
AND d.sub_system_guid = @Sub_system_guid AND d.device_name_tag = @sub_system_tag
AND d.floor_guid = @Floor_guid AND d.device_floor_tag = @floor_tag
AND d.deleted = 0 AND d.deleted = 0
) d ) d
GROUP BY d.device_building_tag, GROUP BY d.device_building_tag, d.device_name_tag) dd
d.device_name_tag) dd
LEFT JOIN device_master dm ON dd.device_building_tag = dm.device_building_tag LEFT JOIN device_master dm ON dd.device_building_tag = dm.device_building_tag
AND dd.device_name_tag = dm.device_name_tag AND dd.device_name_tag = dm.device_name_tag";
";
var deviceMasters = await backendRepository.GetAllAsync<DeviceMaster>(sql, post); var deviceMasters = await backendRepository.GetAllAsync<DeviceMaster>(sql, post);
@ -1590,15 +1579,15 @@ namespace Backend.Controllers
/// <param name="guid"></param> /// <param name="guid"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
public async Task<ApiResult<List<Device_item>>> GetDeviceItem(string sub_system_guid) public async Task<ApiResult<List<Device_item>>> GetDeviceItem(string sub_system_tag)
{ {
ApiResult<List<Device_item>> apiResult = new ApiResult<List<Device_item>>(); ApiResult<List<Device_item>> apiResult = new ApiResult<List<Device_item>>();
try try
{ {
string sWhere = "deleted = 0 AND sub_system_guid = @Sub_system_guid"; string sWhere = "deleted = 0 AND sub_system_tag = @Sub_system_tag";
object param = new { Sub_system_guid = sub_system_guid }; object param = new { Sub_system_tag = sub_system_tag };
var deviceItems = await backendRepository.GetAllAsync<Device_item>("device_item", sWhere, param); var deviceItems = await backendRepository.GetAllAsync<Device_item>("device_item", sWhere, param);

View File

@ -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)
{ {

View File

@ -29,15 +29,17 @@ namespace Backend.Controllers
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
public async Task<ApiResult<List<SystemMain>>> SystemMainList() public async Task<ApiResult<List<VariableInfo>>> SystemMainList()
{ {
ApiResult<List<SystemMain>> apiResult = new ApiResult<List<SystemMain>>(); ApiResult<List<VariableInfo>> apiResult = new ApiResult<List<VariableInfo>>();
try try
{ {
var sWhere = "deleted = 0"; var sWhere = "deleted = 0 AND system_type = @System_type";
var systemMainList = await backendRepository.GetAllAsync<SystemMain>("main_system", sWhere, null, "priority ASC, created_at DESC"); var param = new { System_type = main_system_type };
var systemMainList = await backendRepository.GetAllAsync<VariableInfo>("variable", sWhere, param, "system_priority ASC, created_at DESC");
apiResult.Code = "0000"; apiResult.Code = "0000";
apiResult.Data = systemMainList; apiResult.Data = systemMainList;
@ -57,17 +59,17 @@ namespace Backend.Controllers
/// <param name="guid"></param> /// <param name="guid"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
public async Task<ApiResult<SystemMain>> GetOneSystemMain(string guid) public async Task<ApiResult<VariableInfo>> GetOneSystemMain(int id)
{ {
ApiResult<SystemMain> apiResult = new ApiResult<SystemMain>(); ApiResult<VariableInfo> apiResult = new ApiResult<VariableInfo>();
try try
{ {
string sWhere = @$"deleted = @Deleted AND main_system_guid = @Guid"; string sWhere = @$"deleted = @Deleted AND id = @id";
object param = new { Deleted = 0, Guid = guid }; object param = new { Deleted = 0, id = id};
var systemMain = await backendRepository.GetOneAsync<SystemMain>("main_system", sWhere, param); var systemMain = await backendRepository.GetOneAsync<VariableInfo>("variable", sWhere, param);
apiResult.Code = "0000"; apiResult.Code = "0000";
apiResult.Data = systemMain; apiResult.Data = systemMain;
@ -87,82 +89,67 @@ namespace Backend.Controllers
/// <param name="post"></param> /// <param name="post"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
public async Task<ApiResult<string>> SaveSystemMain(SystemMain post) public async Task<ApiResult<string>> SaveSystemMain(VariableInfo post)
{ {
ApiResult<string> apiResult = new ApiResult<string>(); ApiResult<string> apiResult = new ApiResult<string>();
try try
{ {
string sWhere = @$"deleted = @Deleted AND main_system_guid = @Guid"; string sWhere = @$"deleted = @Deleted AND id = @id";
object param = new { Deleted = 0, Guid = post.Main_system_guid }; object param = new { Deleted = 0, id = post.id };
var systemMain = await backendRepository.GetOneAsync<SystemMain>("main_system", sWhere, param); var systemMain = await backendRepository.GetOneAsync<VariableInfo>("variable", sWhere, param);
if (systemMain == null) if (systemMain == null)
{ {
//新增 //新增
//產生一組GUID //獲取最新的大類
var guid = Guid.NewGuid(); //系統大類GUID sWhere = @$"deleted = @Deleted AND system_type = @System_type";
param = new { Deleted = 0, System_type = main_system_type };
var sOrder = @"id DESC LIMIT 1";
var latestVariable = await backendRepository.GetOneAsync<VariableInfo>("variable", sWhere, param, sOrder);
Dictionary<string, object> systemMainDic = new Dictionary<string, object>() Dictionary<string, object> variableMainDic = new Dictionary<string, object>()
{ {
{ "@main_system_guid", guid}, { "@system_type", main_system_type},
{ "@full_name", post.Full_name}, { "@system_key", post.System_key},
{ "@code", post.Code}, { "@system_value", post.system_value},
{ "@created_by", myUserInfo.Userinfo_guid} { "@system_remark", "系統類別(第2層)"},
{ "@system_priority", latestVariable.system_priority + 1},
{ "@created_by", myUserInfo.Userinfo_guid},
{ "@created_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}
}; };
await backendRepository.AddOneByCustomTable(systemMainDic, "main_system"); await backendRepository.AddOneByCustomTable(variableMainDic, "variable");
apiResult.Code = "0000"; apiResult.Code = "0000";
apiResult.Msg = "新增成功"; apiResult.Msg = "新增成功";
} }
else else
{ {
Dictionary<string, object> systemMainDic = new Dictionary<string, object>() Dictionary<string, object> variableMainDic = new Dictionary<string, object>()
{ {
{ "@full_name", post.Full_name}, { "@system_key", post.System_key},
{ "@code", post.Code}, { "@system_value", post.system_value},
{ "@updated_by", myUserInfo.Userinfo_guid}, { "@updated_by", myUserInfo.Userinfo_guid},
{ "@updated_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}, { "@updated_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")},
}; };
await backendRepository.UpdateOneByCustomTable(systemMainDic, "main_system", "main_system_guid='" + systemMain.Main_system_guid + "'"); await backendRepository.UpdateOneByCustomTable(variableMainDic, "variable", "id='" + systemMain.id + "' AND deleted = 0");
var AuthCodes = await backendRepository.GetAllAsync<string>( var AuthCodes = await backendRepository.GetAllAsync<string>(
@$"select AuthCode from auth_page ap @$"select AuthCode
join sub_system ss on ss.sub_system_guid = ap.ShowView from auth_page ap
join main_system ms on ms.main_system_guid = ss.main_system_guid join variable sv on ap.ShowView = sv.id and sv.system_type = 'device_system_category_layer1'
where ms.main_system_guid = '{systemMain.Main_system_guid}'"); where sv.system_parent_id = '{systemMain.id}'");
if(AuthCodes.Count > 0) if(AuthCodes.Count > 0)
{ {
await backendRepository.ExecuteSql($@"UPDATE auth_page await backendRepository.ExecuteSql($@"UPDATE auth_page
SET MainName = '{post.Full_name}' SET MainName = '{post.System_key}'
WHERE AuthCode IN @authCode;",new { authCode = AuthCodes }); WHERE AuthCode IN @authCode;",new { authCode = AuthCodes });
} }
#region
var auth_Pages = await backendRepository.GetAllAsync<Auth_page>("auth_page", "");
List<Dictionary<string, object>> authPagesDics = new List<Dictionary<string, object>>();
foreach (var auth_page in auth_Pages)
{
Dictionary<string, object> authPagesDic = new Dictionary<string, object>()
{
{ "@AuthCode", auth_page.AuthCode},
{ "@AuthType", auth_page.AuthType},
{ "@MainName", auth_page.MainName},
{ "@SubName", auth_page.SubName},
{ "@building_guid", auth_page.building_guid},
{ "@ShowView", auth_page.ShowView},
{ "@created_at", auth_page.created_at},
};
authPagesDics.Add(authPagesDic);
}
await backendRepository.ManualInsertBackgroundServiceTask("", "", "auth_page", "purge_all_insert", authPagesDics);
#endregion
apiResult.Code = "0000"; apiResult.Code = "0000";
apiResult.Msg = "修改成功"; apiResult.Msg = "修改成功";
} }
@ -185,17 +172,17 @@ namespace Backend.Controllers
/// <param name="guid"></param> /// <param name="guid"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
public async Task<ApiResult<string>> DeleteOneSystemMain(string guid) public async Task<ApiResult<string>> DeleteOneSystemMain(int id)
{ {
ApiResult<string> apiResult = new ApiResult<string>(); ApiResult<string> apiResult = new ApiResult<string>();
try try
{ {
string sWhere = @$"deleted = @Deleted AND main_system_guid = @Guid"; string sWhere = @$"deleted = @Deleted AND id = @id";
object param = new { Deleted = 0, Guid = guid }; object param = new { Deleted = 0, id = id };
var systemMain = await backendRepository.GetOneAsync<SystemMain>("main_system", sWhere, param); var systemMain = await backendRepository.GetOneAsync<VariableInfo>("variable", sWhere, param);
if (systemMain == null) if (systemMain == null)
{ {
@ -208,11 +195,11 @@ namespace Backend.Controllers
var sbuildMenu = $@"SELECT var sbuildMenu = $@"SELECT
b.full_name b.full_name
FROM building_menu bm FROM building_menu bm
LEFT JOIN building b ON bm.building_guid = b.building_guid AND b.deleted = 0 LEFT JOIN building b ON bm.building_tag = b.building_tag AND b.deleted = 0
WHERE bm.main_system_guid = @Guid WHERE bm.main_system_tag = @System_Value
GROUP BY b.full_name"; GROUP BY b.full_name";
var buildMenus = await backendRepository.GetAllAsync<string>(sbuildMenu, new { Guid = guid }); var buildMenus = await backendRepository.GetAllAsync<string>(sbuildMenu, new { System_Value = systemMain.system_value });
if (buildMenus.Count > 0) if (buildMenus.Count > 0)
{ {
apiResult.Code = "9997"; apiResult.Code = "9997";
@ -222,19 +209,20 @@ namespace Backend.Controllers
} }
//檢查底下是否有未刪除的系統小類 //檢查底下是否有未刪除的系統小類
string sSubWhere = @$"deleted = @Deleted AND main_system_guid = @Guid"; string sqlSub = @$"SELECT id FROM variable
object sub_param = new { Deleted = 0, Guid = systemMain.Main_system_guid }; WHERE deleted = @Deleted AND system_parent_id = @id";
var systemSubs = await backendRepository.GetAllAsync<SystemSub>("sub_system", sWhere, param); object sub_param = new { Deleted = 0, id = id };
var v = await backendRepository.GetAllAsync<VariableInfo>(sqlSub, sub_param);
if (systemSubs.Count > 0) if (v.Count > 0)
{ {
apiResult.Code = "9997"; apiResult.Code = "9997";
apiResult.Msg = "系統小類中尚有小類正在使用系統大類,故無法刪除"; apiResult.Msg = "系統小類中尚有小類正在使用系統大類,故無法刪除";
apiResult.Data = string.Join("<br>", systemSubs.Select(x => x.Full_name).ToList()); apiResult.Data = string.Join("<br>", v.Where(x => x.id == id).Select(x => x.System_key).ToList());
return apiResult; return apiResult;
} }
await backendRepository.DeleteOne(guid, "main_system", "main_system_guid"); await backendRepository.DeleteOne(id.ToString(), "variable", "id");
apiResult.Code = "0000"; apiResult.Code = "0000";
apiResult.Msg = "刪除成功"; apiResult.Msg = "刪除成功";
@ -243,7 +231,7 @@ namespace Backend.Controllers
{ {
apiResult.Code = "9999"; apiResult.Code = "9999";
apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
Logger.LogError("【" + controllerName + "/" + actionName + "】" + "main_system_guid=" + guid); Logger.LogError("【" + controllerName + "/" + actionName + "】" + "id=" + id);
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
} }
@ -256,18 +244,17 @@ namespace Backend.Controllers
/// <param name="main_system_guid"></param> /// <param name="main_system_guid"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
public async Task<ApiResult<List<SystemSub>>> SystemSubList(string main_system_guid) public async Task<ApiResult<List<VariableInfo>>> SystemSubList(int id)
{ {
ApiResult<List<SystemSub>> apiResult = new ApiResult<List<SystemSub>>(); ApiResult<List<VariableInfo>> apiResult = new ApiResult<List<VariableInfo>>();
try try
{ {
var sWhere = @"deleted = @Deleted AND system_parent_id = @id";
var sWhere = @"deleted = @Deleted AND main_system_guid = @Main_system_guid"; object param = new { Deleted = 0, id = id};
object param = new { Deleted = 0, Main_system_guid = main_system_guid }; var systemSubs = await backendRepository.GetAllAsync<VariableInfo>("variable", sWhere, param, "system_priority ASC, created_at DESC");
var systemSubs = await backendRepository.GetAllAsync<SystemSub>("sub_system", sWhere, param, "priority ASC, created_at DESC");
apiResult.Code = "0000"; apiResult.Code = "0000";
apiResult.Data = systemSubs; apiResult.Data = systemSubs;
@ -287,17 +274,17 @@ namespace Backend.Controllers
/// <param name="guid"></param> /// <param name="guid"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
public async Task<ApiResult<SystemSub>> GetOneSystemSub(string guid) public async Task<ApiResult<VariableInfo>> GetOneSystemSub(int id)
{ {
ApiResult<SystemSub> apiResult = new ApiResult<SystemSub>(); ApiResult<VariableInfo> apiResult = new ApiResult<VariableInfo>();
try try
{ {
string sWhere = @$"deleted = @Deleted AND sub_system_guid = @Guid"; string sWhere = @$"deleted = @Deleted AND id = @id";
object param = new { Deleted = 0, Guid = guid }; object param = new { Deleted = 0, id = id };
var systemSub = await backendRepository.GetOneAsync<SystemSub>("sub_system", sWhere, param); var systemSub = await backendRepository.GetOneAsync<VariableInfo>("variable", sWhere, param);
apiResult.Code = "0000"; apiResult.Code = "0000";
apiResult.Data = systemSub; apiResult.Data = systemSub;
@ -317,79 +304,86 @@ namespace Backend.Controllers
/// <param name="post"></param> /// <param name="post"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
public async Task<ApiResult<string>> SaveSystemSub(SystemSub post) public async Task<ApiResult<string>> SaveSystemSub(VariableInfo post)
{ {
ApiResult<string> apiResult = new ApiResult<string>(); ApiResult<string> apiResult = new ApiResult<string>();
try try
{ {
string sWhere = @$"deleted = @Deleted AND sub_system_guid = @Guid"; string sWhere = @$"deleted = @Deleted AND id = @id";
object param = new { Deleted = 0, Guid = post.Sub_system_guid }; object param = new { Deleted = 0, id = post.id };
var systemSub = await backendRepository.GetOneAsync<SystemSub>("sub_system", sWhere, param); var systemSub = await backendRepository.GetOneAsync<VariableInfo>("variable", sWhere, param);
sWhere = @$"deleted = 0 AND system_type = @sub_system_type AND system_value = @system_value";
param = new { sub_system_type = sub_system_type, system_value = post.system_value };
var subV = await backendRepository.GetOneAsync<VariableInfo>("variable", sWhere, param);
if (systemSub == null) if (systemSub == null)
{ {
if (subV != null)
{
apiResult.Code = "0001";
apiResult.Msg = "不可新增相同的系統小類代號。";
return apiResult;
}
//新增 //新增
//產生一組GUID //產生一組GUID
var guid = Guid.NewGuid(); //GUID //獲取最新的大類
sWhere = @$"deleted = @Deleted AND system_type = @System_type";
param = new { Deleted = 0, System_type = sub_system_type };
var sOrder = @"id DESC LIMIT 1";
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>()
{ {
{ "@sub_system_guid", guid}, { "@system_type", sub_system_type},
{ "@main_system_guid", post.Main_system_guid}, { "@system_key", post.System_key},
{ "@full_name", post.Full_name}, { "@system_value", post.system_value},
{ "@created_by", myUserInfo.Userinfo_guid} { "@system_parent_id", post.system_parent_id},
{ "@system_remark", "系統類別(第3層)"},
{ "@system_priority", latestVariable.system_priority + 1},
{ "@created_by", myUserInfo.Userinfo_guid},
{ "@created_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}
}; };
await backendRepository.AddOneByCustomTable(systemSubDic, "sub_system"); await backendRepository.AddOneByCustomTable(systemSubDic, "variable");
apiResult.Code = "0000"; apiResult.Code = "0000";
apiResult.Msg = "新增成功"; apiResult.Msg = "新增成功";
} }
else else
{ {
if (subV != null)
{
apiResult.Code = "0001";
apiResult.Msg = "不可修改成相同的系統小類代號。";
return apiResult;
}
Dictionary<string, object> systemSubDic = new Dictionary<string, object>() Dictionary<string, object> systemSubDic = new Dictionary<string, object>()
{ {
{ "@full_name", post.Full_name},
{ "@system_key", post.System_key},
{ "@system_value", post.system_value},
{ "@updated_by", myUserInfo.Userinfo_guid}, { "@updated_by", myUserInfo.Userinfo_guid},
{ "@updated_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}, { "@updated_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")},
}; };
await backendRepository.UpdateOneByCustomTable(systemSubDic, "sub_system", "sub_system_guid='" + systemSub.Sub_system_guid + "'"); await backendRepository.UpdateOneByCustomTable(systemSubDic, "variable", "id='" + systemSub.id + "'");
var AuthCodes = await backendRepository.GetAllAsync<string>( var AuthCodes = await backendRepository.GetAllAsync<string>(
@$"select AuthCode from auth_page ap @$"select AuthCode from auth_page ap
where ap.ShowView = '{systemSub.Sub_system_guid}'"); where ap.ShowView = '{systemSub.id}'");
if (AuthCodes.Count > 0) if (AuthCodes.Count > 0)
{ {
await backendRepository.ExecuteSql($@"UPDATE auth_page await backendRepository.ExecuteSql($@"UPDATE auth_page
SET SubName = '{post.Full_name}' SET SubName = '{post.System_key}'
WHERE AuthCode IN @authCode;", new { authCode = AuthCodes }); WHERE AuthCode IN @authCode;", new { authCode = AuthCodes });
} }
#region
var auth_Pages = await backendRepository.GetAllAsync<Auth_page>("auth_page", "");
List<Dictionary<string, object>> authPagesDics = new List<Dictionary<string, object>>();
foreach (var auth_page in auth_Pages)
{
Dictionary<string, object> authPagesDic = new Dictionary<string, object>()
{
{ "@AuthCode", auth_page.AuthCode},
{ "@AuthType", auth_page.AuthType},
{ "@MainName", auth_page.MainName},
{ "@SubName", auth_page.SubName},
{ "@building_guid", auth_page.building_guid},
{ "@ShowView", auth_page.ShowView},
{ "@created_at", auth_page.created_at},
};
authPagesDics.Add(authPagesDic);
}
await backendRepository.ManualInsertBackgroundServiceTask("", "", "auth_page", "purge_all_insert", authPagesDics);
#endregion
apiResult.Code = "0000"; apiResult.Code = "0000";
apiResult.Msg = "修改成功"; apiResult.Msg = "修改成功";
} }
@ -412,17 +406,17 @@ namespace Backend.Controllers
/// <param name="guid"></param> /// <param name="guid"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
public async Task<ApiResult<string>> DeleteOneSystemSub(string guid) public async Task<ApiResult<string>> DeleteOneSystemSub(string id)
{ {
ApiResult<string> apiResult = new ApiResult<string>(); ApiResult<string> apiResult = new ApiResult<string>();
try try
{ {
string sWhere = @$"deleted = @Deleted AND sub_system_guid = @Guid"; string sWhere = @$"deleted = @Deleted AND id = @id";
object param = new { Deleted = 0, Guid = guid }; object param = new { Deleted = 0, id = id };
var systemSub = await backendRepository.GetOneAsync<SystemSub>("sub_system", sWhere, param); var systemSub = await backendRepository.GetOneAsync<VariableInfo>("variable", sWhere, param);
if (systemSub == null) if (systemSub == null)
{ {
@ -433,13 +427,14 @@ namespace Backend.Controllers
//檢查是否有未刪除的區域選單 //檢查是否有未刪除的區域選單
var sbuildMenu = $@"SELECT var sbuildMenu = $@"SELECT
CONCAT(b.full_name, ' - ', ms.full_name) CONCAT(b.full_name, ' - ', sv.system_key)
FROM building_menu bm FROM building_menu bm
LEFT JOIN building b ON bm.building_guid = b.building_guid AND b.deleted = 0 LEFT JOIN building b ON bm.building_tag = b.building_tag AND b.deleted = 0
LEFT JOIN main_system ms ON bm.main_system_guid = ms.main_system_guid AND ms.deleted = 0 LEFT JOIN variable sv ON bm.sub_system_tag = sv.system_value AND sv.deleted = 0
WHERE bm.sub_system_guid = @Guid"; LEFT JOIN variable mv ON sv.system_parent_id = mv.id AND mv.deleted = 0
WHERE sv.id = @id";
var buildMenus = await backendRepository.GetAllAsync<string>(sbuildMenu, new { Guid = guid }); var buildMenus = await backendRepository.GetAllAsync<string>(sbuildMenu, new { id = id });
if (buildMenus.Count > 0) if (buildMenus.Count > 0)
{ {
apiResult.Code = "9997"; apiResult.Code = "9997";
@ -450,16 +445,15 @@ namespace Backend.Controllers
//檢查是否有未刪除的系統小類樓層 //檢查是否有未刪除的系統小類樓層
var ssubSystemFloor = $@"SELECT var ssubSystemFloor = $@"SELECT
CONCAT(b.full_name, ' - ', ms.full_name, ' - ', ss.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_guid = b.building_guid AND b.deleted = 0 LEFT JOIN building b ON ssf.building_tag = b.building_tag AND b.deleted = 0
LEFT JOIN main_system ms ON ssf.main_system_guid = ms.main_system_guid AND ms.deleted = 0 LEFT JOIN variable sv ON sv.system_value = ssf.sub_system_tag AND sv.deleted = 0
LEFT JOIN sub_system ss ON ssf.sub_system_guid = ss.sub_system_guid AND ss.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 ssf.sub_system_guid = @Guid WHERE sv.id = @id AND ssf.deleted = 0";
AND ssf.deleted = 0";
var subSystemFloor = await backendRepository.GetAllAsync<string>(sbuildMenu, new { Guid = guid }); var subSystemFloor = await backendRepository.GetAllAsync<string>(sbuildMenu, new { id = id });
if (subSystemFloor.Count > 0) if (subSystemFloor.Count > 0)
{ {
apiResult.Code = "9997"; apiResult.Code = "9997";
@ -472,10 +466,10 @@ namespace Backend.Controllers
var sdeviceItem = $@"SELECT var sdeviceItem = $@"SELECT
di.full_name di.full_name
FROM device_item di FROM device_item di
WHERE di.deleted = 0 INNER JOIN variable sv on di.device_name_tag = sv.system_value
AND di.sub_system_guid = @Guid"; WHERE sv.deleted = 0 AND sv.id = @id AND di.deleted = 0";
var deviceItems = await backendRepository.GetAllAsync<string>(sdeviceItem, new { Guid = guid }); var deviceItems = await backendRepository.GetAllAsync<string>(sdeviceItem, new { id = id });
if (deviceItems.Count > 0) if (deviceItems.Count > 0)
{ {
apiResult.Code = "9997"; apiResult.Code = "9997";
@ -484,7 +478,7 @@ namespace Backend.Controllers
return apiResult; return apiResult;
} }
await backendRepository.DeleteOne(guid, "sub_system", "sub_system_guid"); await backendRepository.DeleteOne(id, "variable", "id");
apiResult.Code = "0000"; apiResult.Code = "0000";
apiResult.Msg = "刪除成功"; apiResult.Msg = "刪除成功";
@ -493,7 +487,7 @@ namespace Backend.Controllers
{ {
apiResult.Code = "9999"; apiResult.Code = "9999";
apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
Logger.LogError("【" + controllerName + "/" + actionName + "】" + "sub_system_guid=" + guid); Logger.LogError("【" + controllerName + "/" + actionName + "】" + "id=" + id);
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
} }
@ -511,9 +505,9 @@ namespace Backend.Controllers
if(device_Item.is_show_riserDiagram == 1) if(device_Item.is_show_riserDiagram == 1)
{ {
var sql_show_riserDiagram = $@"SELECT * FROM device_item di var sql_show_riserDiagram = $@"SELECT * FROM device_item di
WHERE di.sub_system_guid = @SubSystemGuid AND di.deleted = 0 AND is_show_riserDiagram = 1"; WHERE di.id = @id AND di.deleted = 0 AND is_show_riserDiagram = 1";
var is_show_riserDiagram = await backendRepository.GetAllAsync<string>(sql_show_riserDiagram, new { SubSystemGuid = device_Item.sub_system_guid }); var is_show_riserDiagram = await backendRepository.GetAllAsync<string>(sql_show_riserDiagram, new { id = device_Item.id });
if (is_show_riserDiagram.Count() > 0) if (is_show_riserDiagram.Count() > 0)
{ {
@ -523,16 +517,15 @@ namespace Backend.Controllers
} }
} }
if (device_Item.device_item_guid == null) if (device_Item.id == 0)
{ {
var main_tag = await backendRepository.GetOneAsync<string>($@"SELECT system_value FROM variable WHERE id = @id", new { id = device_Item.device_system_tag });
var sub_tag = await backendRepository.GetOneAsync<string>($@"SELECT system_value FROM variable WHERE id = @id", new { id = device_Item.device_name_tag });
//新增 //新增
//產生一組GUID
var guid = Guid.NewGuid(); //GUID
Dictionary<string, object> Device_itemDic = new Dictionary<string, object>() Dictionary<string, object> Device_itemDic = new Dictionary<string, object>()
{ {
{ "@device_item_guid", guid}, { "@device_system_tag", main_tag},
{ "@sub_system_guid", device_Item.sub_system_guid}, { "@device_name_tag", sub_tag},
{ "@full_name", device_Item.full_name}, { "@full_name", device_Item.full_name},
{ "@points", device_Item.points}, { "@points", device_Item.points},
{ "@unit", device_Item.unit}, { "@unit", device_Item.unit},
@ -551,7 +544,6 @@ namespace Backend.Controllers
{ {
Dictionary<string, object> Device_itemDic = new Dictionary<string, object>() Dictionary<string, object> Device_itemDic = new Dictionary<string, object>()
{ {
{ "@sub_system_guid", device_Item.sub_system_guid},
{ "@full_name", device_Item.full_name}, { "@full_name", device_Item.full_name},
{ "@points", device_Item.points}, { "@points", device_Item.points},
{ "@unit", device_Item.unit}, { "@unit", device_Item.unit},
@ -563,7 +555,7 @@ namespace Backend.Controllers
{ "@updated_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}, { "@updated_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")},
}; };
await backendRepository.UpdateOneByCustomTable(Device_itemDic, "device_item", "device_item_guid='" + device_Item.device_item_guid + "'"); await backendRepository.UpdateOneByCustomTable(Device_itemDic, "device_item", "id='" + device_Item.id + "'");
apiResult.Code = "0000"; apiResult.Code = "0000";
apiResult.Msg = "修改成功"; apiResult.Msg = "修改成功";
@ -582,17 +574,21 @@ namespace Backend.Controllers
} }
[HttpPost] [HttpPost]
public async Task<ApiResult<List<Device_item>>> DeviceItemTable(string sub_system_guid) public async Task<ApiResult<List<Device_item>>> DeviceItemTable(int id)
{ {
ApiResult<List<Device_item>> apiResult = new ApiResult<List<Device_item>>(); ApiResult<List<Device_item>> apiResult = new ApiResult<List<Device_item>>();
try try
{ {
var sWhere = @"deleted = @Deleted AND sub_system_guid = @Sub_system_guid"; var sql = @"SELECT di.*
FROM device_item di
JOIN variable sv ON di.device_name_tag = sv.system_value
JOIN variable mv ON sv.system_parent_id = mv.id AND di.device_system_tag = mv.system_value
WHERE sv.id = @id AND di.deleted = @Deleted";
object param = new { Deleted = 0, Sub_system_guid = sub_system_guid }; object param = new { Deleted = 0, id = id };
var systemSubs = await backendRepository.GetAllAsync<Device_item>("device_item", sWhere, param, "created_at DESC"); var systemSubs = await backendRepository.GetAllAsync<Device_item>(sql, param);
apiResult.Code = "0000"; apiResult.Code = "0000";
apiResult.Data = systemSubs; apiResult.Data = systemSubs;
@ -607,15 +603,15 @@ namespace Backend.Controllers
} }
[HttpPost] [HttpPost]
public async Task<ApiResult<Device_item>> GetOneDeviceItem(string guid) public async Task<ApiResult<Device_item>> GetOneDeviceItem(int id)
{ {
ApiResult<Device_item> apiResult = new ApiResult<Device_item>(); ApiResult<Device_item> apiResult = new ApiResult<Device_item>();
try try
{ {
string sWhere = @$"deleted = @Deleted AND device_item_guid = @Guid"; string sWhere = @$"deleted = @Deleted AND id = @id";
object param = new { Deleted = 0, Guid = guid }; object param = new { Deleted = 0, id = id };
var Deviceitem = await backendRepository.GetOneAsync<Device_item>("device_item", sWhere, param); var Deviceitem = await backendRepository.GetOneAsync<Device_item>("device_item", sWhere, param);
@ -632,15 +628,15 @@ namespace Backend.Controllers
} }
[HttpPost] [HttpPost]
public async Task<ApiResult<string>> DeleteOneSystemSubDeviceItem(string guid) public async Task<ApiResult<string>> DeleteOneSystemSubDeviceItem(int id)
{ {
ApiResult<string> apiResult = new ApiResult<string>(); ApiResult<string> apiResult = new ApiResult<string>();
try try
{ {
string sWhere = @$"deleted = @Deleted AND device_item_guid = @Guid"; string sWhere = @$"deleted = @Deleted AND id = @id";
object param = new { Deleted = 0, Guid = guid }; object param = new { Deleted = 0, id = id};
var device_Item = await backendRepository.GetOneAsync<Device_item>("device_item", sWhere, param); var device_Item = await backendRepository.GetOneAsync<Device_item>("device_item", sWhere, param);
@ -651,7 +647,7 @@ namespace Backend.Controllers
return apiResult; return apiResult;
} }
await backendRepository.DeleteOne(guid, "device_item", "device_item_guid"); await backendRepository.DeleteOne(id.ToString(), "device_item", "id");
apiResult.Code = "0000"; apiResult.Code = "0000";
apiResult.Msg = "刪除成功"; apiResult.Msg = "刪除成功";
@ -660,7 +656,7 @@ namespace Backend.Controllers
{ {
apiResult.Code = "9999"; apiResult.Code = "9999";
apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
Logger.LogError("【" + controllerName + "/" + actionName + "】" + "device_item_guid=" + guid); Logger.LogError("【" + controllerName + "/" + actionName + "】" + "id=" + id);
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
} }
@ -672,7 +668,13 @@ namespace Backend.Controllers
ApiResult<bool> apiResult = new ApiResult<bool>(); ApiResult<bool> apiResult = new ApiResult<bool>();
try try
{ {
var point = await backendRepository.GetOneAsync<Device_item>("device_item", $" sub_system_guid = '{post.sub_system_guid}' and points = '{post.points}' and device_item_guid != '{post.device_item_guid}' and deleted = 0"); var sql = $@"SELECT *
FROM device_item di
INNER JOIN variable v ON di.device_name_tag = v.system_value
WHERE v.id = @SubId AND di.id != @Id AND points = @Points";
var param = new { SubId = post.subId, Points = post.points, id = post.id };
var point = await backendRepository.GetOneAsync<Device_item>(sql, param);
if (point != null) if (point != null)
{ {
apiResult.Data = true; apiResult.Data = true;
@ -700,9 +702,9 @@ namespace Backend.Controllers
try try
{ {
var tags = await backendRepository.GetAllAsync<Tags>( var tags = await backendRepository.GetAllAsync<Tags>(
@$"select * from (select dk.device_building_tag ,dk.device_name_tag,dk.device_system_tag from device_kind dk where dk.device_normal_point_guid = '{post.guid}') dkn @$"select * from (select dk.device_building_tag ,dk.device_name_tag,dk.device_system_tag from device_kind dk where dk.device_normal_point_id = @id) dkn
union(select dk.device_building_tag, dk.device_name_tag, dk.device_system_tag from device_kind dk where dk.device_close_point_guid = '{post.guid}') union(select dk.device_building_tag, dk.device_name_tag, dk.device_system_tag from device_kind dk where dk.device_close_point_id = @id)
union(select dk.device_building_tag, dk.device_name_tag, dk.device_system_tag from device_kind dk where dk.device_error_point_guid = '{post.guid}')"); union(select dk.device_building_tag, dk.device_name_tag, dk.device_system_tag from device_kind dk where dk.device_error_point_id = @id)", new { id = post.guid});
if (tags.Count == 0) if (tags.Count == 0)
{ {
@ -722,20 +724,24 @@ namespace Backend.Controllers
}; };
var unionsql = ""; var unionsql = "";
var last = tags.Last(); var last = tags.Last();
var sub_system = await backendRepository.GetOneAsync<VariableInfo>($@"SELECT * FROM variable WHERE id = @id", new { id = post.subguid });
foreach (var tag in tags) foreach (var tag in tags)
{ {
unionsql += $@"select d.building_guid,d.main_system_guid,d.sub_system_guid,d.device_name_tag from device d where d.sub_system_guid = '{post.subguid}' and d.device_building_tag = '{tag.device_building_tag}' and d.device_system_tag = '{tag.device_system_tag}' and d.device_name_tag = '{tag.device_name_tag}' group by d.building_guid,d.main_system_guid,d.sub_system_guid,d.device_name_tag"; unionsql += $@"select d.building_tag,d.device_system_tag,d.device_name_tag,d.device_last_name from device d where d.device_name_tag = '{sub_system.system_value}'
and d.device_building_tag = '{tag.device_building_tag}' and d.device_system_tag = '{tag.device_system_tag}' and d.device_name_tag = '{tag.device_name_tag}' group by d.building_guid,d.main_system_guid,d.sub_system_guid,d.device_name_tag";
if (!last.Equals(tag)) if (!last.Equals(tag))
{ {
unionsql += " union "; unionsql += " union ";
} }
} }
var sql = @$"select ms.full_name msname,b.full_name bname,s.full_name subname,de.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 main_system ms on ms.main_system_guid = de.main_system_guid 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_guid = de.building_guid left join building b on b.building_tag = de.building_tag
left join sub_system s on s.sub_system_guid = de.sub_system_guid"; left join variable sv on sv.system_value = de.device_name_tag and sv.system_type = @sub_system_type";
var names = await backendRepository.GetAllAsync<GetCheckName>(sql);
var param = new { main_system_type = main_system_type, sub_system_type = sub_system_type};
var names = await backendRepository.GetAllAsync<GetCheckName>(sql, param);
var count = 0; var count = 0;
foreach (var name in names) foreach (var name in names)
{ {

View File

@ -7,18 +7,27 @@ 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 left_drawing { get; set; }
public byte icon_click { get; set; } public byte left_icon_click { get; set; }
public string icon_click_url { get; set; } public string left_icon_click_url { get; set; }
public int icon_click_url_width { get; set; } public int left_icon_click_url_width { get; set; }
public int icon_click_url_height { get; set; } public int left_icon_click_url_height { get; set; }
public string system_url { get; set; } public string left_system_url { get; set; }
public string riser_diagram_url { get; set; } public string left_riser_diagram_url { get; set; }
public byte planimetric_click { get; set; } public byte left_planimetric_click { get; set; }
public string planimetric_floor_guid { get; set; } public string left_planimetric_floor_guid { get; set; }
public byte right_drawing { get; set; }
public byte right_icon_click { get; set; }
public string right_icon_click_url { get; set; }
public int right_icon_click_url_width { get; set; }
public int right_icon_click_url_height { get; set; }
public string right_system_url { get; set; }
public string right_riser_diagram_url { get; set; }
public byte right_planimetric_click { get; set; }
public string right_planimetric_floor_guid { get; set; }
} }
public class BuildMenuAddSub: BuildMenu public class BuildMenuAddSub: BuildMenu
{ {
@ -26,26 +35,29 @@ namespace Backend.Models
} }
public class SubListIn public class SubListIn
{ {
public string main { get; set; } public string main_system_tag { 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
{ {
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 drawing_name { get; set; } public string left_drawing_name { get; set; }
public string icon_click_name { get; set; } public string right_drawing_name { get; set; }
public string planimetric_click_name { get; set; } public string left_icon_click_name { get; set; }
public string left_planimetric_click_name { get; set; }
public string right_icon_click_name { get; set; }
public string right_planimetric_click_name { get; set; }
public string floor_guid_name { get; set; } public string floor_guid_name { get; set; }
} }
public class MenuIn : SubListIn public class MenuIn : SubListIn
{ {
public string sub { get; set; } public string sub_system_tag { get; set; }
} }
public class BuildMenuFloor : Actor public class BuildMenuFloor : Actor
{ {
@ -60,6 +72,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; }

View File

@ -9,6 +9,7 @@ namespace Backend.Models
public class BuildInfo : Actor public class BuildInfo : Actor
{ {
public int Priority { get; set; } public int Priority { get; set; }
public string building_tag { get; set; }
public string Building_guid { get; set; } //區域GUID public string Building_guid { get; set; } //區域GUID
public string Full_name { get; set; } //區域名稱 public string Full_name { get; set; } //區域名稱
public string Ip_address { get; set; } //監控主機 IP public string Ip_address { get; set; } //監控主機 IP
@ -22,6 +23,7 @@ namespace Backend.Models
{ {
public string Floor_guid { get; set; } //樓層GUID public string Floor_guid { get; set; } //樓層GUID
public string Building_guid { get; set; } //區域GUID public string Building_guid { get; set; } //區域GUID
public string Building_tag { get; set; } //區域GUID
public string Full_name { get; set; } //建築名稱 public string Full_name { get; set; } //建築名稱
public string InitMapName { get; set; } //使用者命名平面圖檔檔名 public string InitMapName { get; set; } //使用者命名平面圖檔檔名
public string MapUrl { get; set; } //使用者命名平面圖檔檔名 public string MapUrl { get; set; } //使用者命名平面圖檔檔名
@ -42,6 +44,7 @@ namespace Backend.Models
public class BuildInfoPriority public class BuildInfoPriority
{ {
public string Building_guid { get; set; } //區域GUID public string Building_guid { get; set; } //區域GUID
public string Building_tag { get; set; } //區域TAG
public int Priority { get; set; } public int Priority { get; set; }
} }

View File

@ -7,20 +7,20 @@ namespace Backend.Models
{ {
public class BuildingMenuRawData public class BuildingMenuRawData
{ {
public string Building_guid { get; set; } public string building_tag { get; set; }
public string bFull_name { get; set; } public string bFull_name { get; set; }
public int bPriority { get; set; } public int bPriority { get; set; }
public string Main_system_guid { get; set; } public string main_system_tag { get; set; }
public string mFull_name { get; set; } public string mFull_name { get; set; }
public int mPriority { get; set; } public int mPriority { get; set; }
public string Sub_system_guid { get; set; } public string sub_system_tag { get; set; }
public string sFull_name { get; set; } public string sFull_name { get; set; }
public int sPriority { get; set; } public int sPriority { get; set; }
} }
public class BuildingCollapse : Actor public class BuildingCollapse : Actor
{ {
public string Building_guid { get; set; } public string Building_tag { get; set; }
public string Full_name { get; set; } public string Full_name { get; set; }
public string Ip_address { get; set; } public string Ip_address { get; set; }
public int Priority { get; set; } public int Priority { get; set; }
@ -28,7 +28,7 @@ namespace Backend.Models
} }
public class Main_system public class Main_system
{ {
public string Main_system_guid { get; set; } public string Main_system_tag { get; set; }
public string Full_name { get; set; } public string Full_name { get; set; }
public int Priority { get; set; } public int Priority { get; set; }
public string Code { get; set; } public string Code { get; set; }
@ -36,7 +36,7 @@ namespace Backend.Models
} }
public class Sub_system public class Sub_system
{ {
public string Sub_system_guid { get; set; } public string Sub_system_tag { get; set; }
public string Full_name { get; set; } public string Full_name { get; set; }
public int Priority { get; set; } public int Priority { get; set; }
public byte Drawing { get; set; } public byte Drawing { get; set; }
@ -47,7 +47,7 @@ namespace Backend.Models
} }
public class Floor public class Floor
{ {
public string Floor_guid { get; set; } public string Floor_tag { get; set; }
public string Full_name { get; set; } public string Full_name { get; set; }
public string InitMapName { get; set; } public string InitMapName { get; set; }
public string Floor_map_name { get; set; } //平面圖檔名 public string Floor_map_name { get; set; } //平面圖檔名
@ -56,11 +56,11 @@ namespace Backend.Models
public class SubSystemFloorRawData public class SubSystemFloorRawData
{ {
public string Sub_system_floor_guid { get; set; } public string id { get; set; }
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 string Floor_guid { get; set; } public string Floor_tag { get; set; }
public string fFull_name { get; set; } public string fFull_name { get; set; }
public string InitMapName { get; set; } public string InitMapName { get; set; }
public string Floor_map_name { get; set; } public string Floor_map_name { get; set; }

View File

@ -8,18 +8,18 @@ namespace Backend.Models
{ {
public class PostDeviceFilter public class PostDeviceFilter
{ {
public string Building_guid { get; set; } public string building_tag { get; set; }
public string Main_system_guid { get; set; } public string device_system_tag { get; set; }
public string Sub_system_guid { get; set; } public string device_name_tag { get; set; }
public string Floor_guid { get; set; } public string device_floor_tag { get; set; }
} }
public class PostDeviceInfoAdd public class PostDeviceInfoAdd
{ {
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 string Floor_guid { get; set; } public string Floor_tag { get; set; }
public List<SelcectedDeviceAdd> SelectedDevices { get; set; } public List<SelcectedDeviceAdd> SelectedDevices { get; set; }
public IFormFile SelectedDevicesFile { get; set; } public IFormFile SelectedDevicesFile { get; set; }
} }
@ -239,8 +239,8 @@ namespace Backend.Models
{ {
public int id { get; set; } public int id { get; set; }
public string device_disaster { get; set; } public string device_disaster { get; set; }
public string device_building_guid { get; set; } public string device_building_tag { get; set; }
public string device_floor_guid { get; set; } public string device_floor_tag { get; set; }
public string device_system_category_layer2 { get; set; } public string device_system_category_layer2 { get; set; }
public string device_system_category_layer3 { get; set; } public string device_system_category_layer3 { get; set; }
public int device_amount { get; set; } public int device_amount { get; set; }

View File

@ -53,11 +53,12 @@ namespace Backend.Models
public string Logo { get; set; } public string Logo { get; set; }
} }
public class Variable public class Variable : Actor
{ {
public string System_type { get; set; } public string System_type { get; set; }
public string System_key { get; set; } public string System_key { get; set; }
public string system_value { get; set; } public string system_value { get; set; }
} }
public class VariableInfo : Variable public class VariableInfo : Variable

View File

@ -30,8 +30,12 @@ namespace Backend.Models
public class Device_item : Actor public class Device_item : Actor
{ {
public int id { get; set; }
public string device_item_guid { get; set; } public string device_item_guid { get; set; }
public string sub_system_guid { get; set; } public string device_area_tag { get; set; }
public string device_building_tag { get; set; }
public string device_system_tag { get; set; }
public string device_name_tag { get; set; }
public string full_name { get; set; } public string full_name { get; set; }
public string points { get; set; } public string points { get; set; }
public string unit { get; set; } public string unit { get; set; }
@ -39,13 +43,14 @@ namespace Backend.Models
public byte is_show_riserDiagram { get; set; } public byte is_show_riserDiagram { get; set; }
public byte is_controll { get; set; } public byte is_controll { get; set; }
public byte is_bool { get; set; } public byte is_bool { get; set; }
public byte is_link { get; set; }
} }
public class Checksame public class Checksame
{ {
public string sub_system_guid { get; set; } public int id { get; set; }
public string subId { get; set; }
public string points { get; set; } public string points { get; set; }
public string device_item_guid { get; set; }
} }
public class Tags public class Tags

View File

@ -55,7 +55,7 @@
}, },
"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;
} }
@ -87,7 +87,7 @@
], ],
//"order": [[2, "desc"]], //"order": [[2, "desc"]],
'createdRow': function (row, data, dataIndex) { 'createdRow': function (row, data, dataIndex) {
$(row).attr('data-guid', data.building_guid); $(row).attr('data-guid', data.building_tag);
}, },
"ajax": { "ajax": {
"url": "/BuildInfo/BuildInfoList", "url": "/BuildInfo/BuildInfoList",
@ -107,13 +107,13 @@
//樓層設定上方選單 //樓層設定上方選單
$("#BuildList").empty(); $("#BuildList").empty();
$.each(data, function (key, value) { $.each(data, function (key, value) {
$("#BuildList").append(`<button type="button" class="btn btn-outline-success waves-effect waves-themed ml-2 mb-2 btn-station" id="${value.building_guid}" onclick="clickBuilding('${value.building_guid}')">${value.full_name}</button>`); $("#BuildList").append(`<button type="button" class="btn btn-outline-success waves-effect waves-themed ml-2 mb-2 btn-station" id="${value.building_tag}" onclick="clickBuilding('${value.building_tag}')">${value.full_name}</button>`);
@*if (key == 0) { @*if (key == 0) {
selected_build_guid_top_name = value.full_name; selected_build_guid_top_name = value.full_name;
$("#BuildList").append(`<button type="button" class="btn btn-success waves-effect waves-themed ml-2 mb-2 btn-station" id="${value.building_guid}" onclick="clickBuilding('${value.building_guid}')">${value.full_name}</button>`); $("#BuildList").append(`<button type="button" class="btn btn-success waves-effect waves-themed ml-2 mb-2 btn-station" id="${value.building_tag}" onclick="clickBuilding('${value.building_tag}')">${value.full_name}</button>`);
} }
else { else {
$("#BuildList").append(`<button type="button" class="btn btn-outline-success waves-effect waves-themed ml-2 mb-2 btn-station" id="${value.building_guid}" onclick="clickBuilding('${value.building_guid}')">${value.full_name}</button>`); $("#BuildList").append(`<button type="button" class="btn btn-outline-success waves-effect waves-themed ml-2 mb-2 btn-station" id="${value.building_tag}" onclick="clickBuilding('${value.building_tag}')">${value.full_name}</button>`);
}*@ }*@
}); });
@ -129,7 +129,7 @@
var rowData = buildInfoTable.row(diff[i].node).data(); var rowData = buildInfoTable.row(diff[i].node).data();
var obj = { var obj = {
building_guid: rowData.building_guid, building_tag: rowData.building_tag,
priority: diff[i].newData priority: diff[i].newData
} }
@ -163,6 +163,9 @@
selected_build_guid = $(this).parents('tr').attr('data-guid'); selected_build_guid = $(this).parents('tr').attr('data-guid');
$('#build-modal .modal-title').html("區域基本資料 - 修改"); $('#build-modal .modal-title').html("區域基本資料 - 修改");
$('#build_name_tag').val(selected_build_guid);
$('#build_name_tag').prop('disabled', true);
$("#save-building-btn").attr("onClick", "EditBuild()");
$('#build_name_modal').val($(this).parents('tr')[0].children[1].innerText); $('#build_name_modal').val($(this).parents('tr')[0].children[1].innerText);
$('#ip_address_modal').val($(this).parents('tr')[0].children[2].innerText); $('#ip_address_modal').val($(this).parents('tr')[0].children[2].innerText);
$('#ip_port_modal').val($(this).parents('tr')[0].children[3].innerText); $('#ip_port_modal').val($(this).parents('tr')[0].children[3].innerText);
@ -187,7 +190,7 @@
if (result.value) { if (result.value) {
var url = "/BuildInfo/DeleteOneBuild/"; var url = "/BuildInfo/DeleteOneBuild/";
var send_data = { var send_data = {
guid: selected_build_guid tag: selected_build_guid
} }
$.post(url, send_data, function (rel) { $.post(url, send_data, function (rel) {
if (rel.code == "9999") { if (rel.code == "9999") {
@ -218,7 +221,9 @@
function AddBuild() { function AddBuild() {
selected_build_guid = "0"; selected_build_guid = "0";
BuildInfoValidate.resetForm(); BuildInfoValidate.resetForm();
$("#save-building-btn").attr("onClick", "SaveBuild()");
$("#build-modal .modal-title").html("區域基本資料 - 新增"); $("#build-modal .modal-title").html("區域基本資料 - 新增");
$('#build_name_tag').prop('disabled', false);
$("#build-form").trigger("reset"); $("#build-form").trigger("reset");
$("#build-modal").modal(); $("#build-modal").modal();
@ -253,7 +258,42 @@
$("#save-building-btn").html('<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>').attr("disabled", true); $("#save-building-btn").html('<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>').attr("disabled", true);
var url = "/BuildInfo/SaveBuildInfo"; var url = "/BuildInfo/SaveBuildInfo";
var send_data = { var send_data = {
Building_guid: selected_build_guid, building_tag: $('#build_name_tag').val(),
Full_name: $('#build_name_modal').val(),
Ip_address: $('#ip_address_modal').val(),
Ip_port: $('#ip_port_modal').val()
}
$.post(url, send_data, function (rel) {
$("#save-building-btn").html('確定').attr("disabled", false);
if (rel.code != "0000") {
if (rel.code == "9999") {
toast_error(rel.msg);
}
else {
toast_warning(rel.msg);
}
return;
}
else {
toast_ok(rel.msg);
buildInfoTable.ajax.reload(null, false);
$('#build-modal').modal('hide');
return;
}
}, 'json')
.fail(function (xhr, status, error) {
$("#save-building-btn").html('確定').attr("disabled", false);
});
}
}
function EditBuild() {
if ($("#build-form").valid()) {
$("#save-building-btn").html('<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>').attr("disabled", true);
var url = "/BuildInfo/EditBuildInfo";
var send_data = {
building_tag: selected_build_guid,
Full_name: $('#build_name_modal').val(), Full_name: $('#build_name_modal').val(),
Ip_address: $('#ip_address_modal').val(), Ip_address: $('#ip_address_modal').val(),
Ip_port: $('#ip_port_modal').val() Ip_port: $('#ip_port_modal').val()
@ -342,7 +382,7 @@
"url": "/BuildInfo/BuildFloorList", "url": "/BuildInfo/BuildFloorList",
"type": "POST", "type": "POST",
"data": function (d) { "data": function (d) {
d.BuildGuid = selected_build_guid_top; d.build_tag = selected_build_guid_top;
}, },
"dataSrc": function (rel) { "dataSrc": function (rel) {
if (rel.code == "9999") { if (rel.code == "9999") {
@ -557,7 +597,7 @@
maps = $('#map_file_modal')[0].files maps = $('#map_file_modal')[0].files
formData.append("Floor_guid", selected_floor_guid); formData.append("Floor_guid", selected_floor_guid);
formData.append("Building_guid", selected_build_guid_top); formData.append("building_tag", selected_build_guid_top);
formData.append("Full_name", $('#floor_name_modal').val()); formData.append("Full_name", $('#floor_name_modal').val());
if (maps.length > 0) { if (maps.length > 0) {

View File

@ -40,6 +40,10 @@
<div class="modal-body"> <div class="modal-body">
<form class="user-form" id="build-form"> <form class="user-form" id="build-form">
<div class="row"> <div class="row">
<div class="form-group col-12">
<label class="form-label" for="build_name_tag"><span class="text-danger">*</span>代碼</label>
<input type="text" id="build_name_tag" class="form-control" name="build_name_tag">
</div>
<div class="form-group col-12"> <div class="form-group col-12">
<label class="form-label" for="build_name_modal"><span class="text-danger">*</span>區域名稱</label> <label class="form-label" for="build_name_modal"><span class="text-danger">*</span>區域名稱</label>
<input type="text" id="build_name_modal" class="form-control" name="build_name_modal"> <input type="text" id="build_name_modal" class="form-control" name="build_name_modal">

View File

@ -51,10 +51,14 @@
<th>序</th> <th>序</th>
<th>系統大類</th> <th>系統大類</th>
<th>系統小類</th> <th>系統小類</th>
<th>預設頁面</th> <th>左邊預設頁面</th>
<th>是否顯示<br>平面圖</th> <th>左邊是否顯示<br>平面圖</th>
<th>昇位圖<br>詳細資料設定</th> <th>左邊昇位圖<br>詳細資料設定</th>
<th>昇位圖<br>詳細資料URL</th> <th>左邊昇位圖<br>詳細資料URL</th>
<th>右邊預設頁面</th>
<th>右邊是否顯示<br>平面圖</th>
<th>右邊昇位圖<br>詳細資料設定</th>
<th>右邊昇位圖<br>詳細資料URL</th>
@*<th>昇位圖URL</th>*@ @*<th>昇位圖URL</th>*@
<th>功能</th> <th>功能</th>
</tr> </tr>
@ -131,6 +135,11 @@
<select class="form-control" id="build_menu_sub_modal"> <select class="form-control" id="build_menu_sub_modal">
</select> </select>
</div> </div>
<div class="col-12" id="build_menu_position_l_div">
<label class="mb-0 t-gray">左邊區塊</label>
<hr class="mt-1" />
<div class="form-group col-12"> <div class="form-group col-12">
<label class="form-label"><span class="text-danger">*</span>預設頁面</label> <label class="form-label"><span class="text-danger">*</span>預設頁面</label>
<div class="row" id="build_menu_drawing_modal"> <div class="row" id="build_menu_drawing_modal">
@ -149,7 +158,19 @@
<div class="col" id="drawing_1_div" style="display: none;"> <div class="col" id="drawing_1_div" style="display: none;">
<input type="radio" name="drawing" id="drawing_1" value="1"> <input type="radio" name="drawing" id="drawing_1" value="1">
<label for="drawing_1"> <label for="drawing_1">
樓層平面圖 2D
</label>
</div>
<div class="col">
<input type="radio" name="drawing" id="drawing_3" value="3">
<label for="drawing_3">
3D
</label>
</div>
<div class="col">
<input type="radio" name="drawing" id="drawing_5" value="5">
<label for="drawing_5">
彈出URL
</label> </label>
</div> </div>
</div> </div>
@ -164,6 +185,10 @@
<label class="form-label" for="build_menu_systemurl_modal"><span class="text-danger">*</span>系統圖URL</label> <label class="form-label" for="build_menu_systemurl_modal"><span class="text-danger">*</span>系統圖URL</label>
<input type="text" id="build_menu_systemurl_modal" class="form-control" name="build_menu_systemurl_modal"> <input type="text" id="build_menu_systemurl_modal" class="form-control" name="build_menu_systemurl_modal">
</div> </div>
<div class="form-group col-12" id="build_menu_blankurl_modal_div" name="drawing_extend">
<label class="form-label" for="build_menu_blankurl_modal"><span class="text-danger">*</span>彈出URL</label>
<input type="text" id="build_menu_blankurl_modal" class="form-control" name="build_menu_blankurl_modal">
</div>
<div class="form-group col-12" id="build_menu_icon_click_onoff_modal_div" name="drawing_extend"> <div class="form-group col-12" id="build_menu_icon_click_onoff_modal_div" name="drawing_extend">
<label class="form-label">昇位圖 - 詳細資料設定</label> <label class="form-label">昇位圖 - 詳細資料設定</label>
@*<div class="row"> @*<div class="row">
@ -197,12 +222,12 @@
</div> </div>
<div class="form-group col-12" id="build_menu_icon_click_url_modal_div" name="drawing_extend"> <div class="form-group col-12" id="build_menu_icon_click_url_modal_div" name="drawing_extend">
<label class="form-label" for="build_menu_icon_click_url_modal">詳細資料 URL</label><br> <label class="form-label" for="build_menu_icon_click_url_modal">詳細資料 URL</label><br>
<button type="button" class="btn btn-secondary waves-effect waves-themed mb-2" onclick="AddTagIntoClickUrl('device_building_tag')">+/[device_building_tag]</button> <button type="button" class="btn btn-secondary waves-effect waves-themed mb-2" onclick="AddTagIntoClickUrl('device_building_tag', 'l')">+/[device_building_tag]</button>
<button type="button" class="btn btn-secondary waves-effect waves-themed mb-2" onclick="AddTagIntoClickUrl('device_system_tag')">+/[device_system_tag]</button> <button type="button" class="btn btn-secondary waves-effect waves-themed mb-2" onclick="AddTagIntoClickUrl('device_system_tag', 'l')">+/[device_system_tag]</button>
<button type="button" class="btn btn-secondary waves-effect waves-themed mb-2" onclick="AddTagIntoClickUrl('device_floor_tag')">+/[device_floor_tag]</button> <button type="button" class="btn btn-secondary waves-effect waves-themed mb-2" onclick="AddTagIntoClickUrl('device_floor_tag', 'l')">+/[device_floor_tag]</button>
<button type="button" class="btn btn-secondary waves-effect waves-themed mb-2" onclick="AddTagIntoClickUrl('device_name_tag')">+/[device_name_tag]</button> <button type="button" class="btn btn-secondary waves-effect waves-themed mb-2" onclick="AddTagIntoClickUrl('device_name_tag', 'l')">+/[device_name_tag]</button>
<button type="button" class="btn btn-secondary waves-effect waves-themed mb-2" onclick="AddTagIntoClickUrl('device_serial_tag')">+/[device_serial_tag]</button> <button type="button" class="btn btn-secondary waves-effect waves-themed mb-2" onclick="AddTagIntoClickUrl('device_serial_tag', 'l')">+/[device_serial_tag]</button>
<button type="button" class="btn btn-secondary waves-effect waves-themed mb-2" onclick="AddTagIntoClickUrl('tag_name')">+/[tag_name]</button> <button type="button" class="btn btn-secondary waves-effect waves-themed mb-2" onclick="AddTagIntoClickUrl('tag_name', 'l')">+/[tag_name]</button>
<input type="text" id="build_menu_icon_click_url_modal" class="form-control"> <input type="text" id="build_menu_icon_click_url_modal" class="form-control">
</div> </div>
<div class="form-group col-12" id="build_menu_icon_click_url_width_height_modal_div"> <div class="form-group col-12" id="build_menu_icon_click_url_width_height_modal_div">
@ -222,12 +247,134 @@
<label class="form-label" for="build_menu_riser_diagram_url_modal">昇位圖 URL</label><br> <label class="form-label" for="build_menu_riser_diagram_url_modal">昇位圖 URL</label><br>
<input type="text" id="build_menu_riser_diagram_url_modal" class="form-control"> <input type="text" id="build_menu_riser_diagram_url_modal" class="form-control">
</div> </div>
<div class="form-group col-6" id="build_menu_planimetric_floor_modal_div"> <div class="form-group col-6" id="build_menu_planimetric_floor_modal_div">
<label class="form-label" for="build_menu_planimetric_floor_modal"><span class="text-danger">*</span>平面圖預設樓層</label> <label class="form-label" for="build_menu_planimetric_floor_modal"><span class="text-danger">*</span>平面圖預設樓層</label>
<select class="form-control" id="build_menu_planimetric_floor_modal"> <select class="form-control" id="build_menu_planimetric_floor_modal">
</select> </select>
</div> </div>
</div>
<div class="col-12 mt-3" id="build_menu_position_r_div">
<label class="mb-0 t-gray">右邊區塊</label>
<hr class="mt-1" />
<div class="form-group col-12">
<label class="form-label"><span class="text-danger">*</span>預設頁面</label>
<div class="row" id="build_menu_drawing_modal_r">
<div class="col">
<input type="radio" name="drawing_r" id="drawing_4_r" value="4" checked>
<label for="drawing_4_r">
昇位圖
</label>
</div>
<div class="col">
<input type="radio" name="drawing_r" id="drawing_2_r" value="2">
<label for="drawing_2_r">
系統圖
</label>
</div>
<div class="col" id="drawing_1_div_r" style="display: none;">
<input type="radio" name="drawing_r" id="drawing_1_r" value="1">
<label for="drawing_1_r">
2D
</label>
</div>
<div class="col">
<input type="radio" name="drawing_r" id="drawing_3_r" value="3">
<label for="drawing_3_r">
3D
</label>
</div>
<div class="col">
<input type="radio" name="drawing_r" id="drawing_5_r" value="5">
<label for="drawing_5_r">
彈出URL
</label>
</div>
</div>
</div>
<div class="form-group col-12" id="" name="drawing_extend_r">
<div class="col-12 mb-2 custom-control custom-checkbox align-content-center">
<input type="checkbox" class="custom-control-input" name="planimetric_click_r" id="planimetric_click_r" value="1" />
<label class="custom-control-label" for="planimetric_click_r">是否顯示平面圖</label>
</div>
</div>
<div class="form-group col-12" id="build_menu_systemurl_modal_div_r" name="drawing_extend">
<label class="form-label" for="build_menu_systemurl_modal_r"><span class="text-danger">*</span>系統圖URL</label>
<input type="text" id="build_menu_systemurl_modal_r" class="form-control" name="build_menu_systemurl_modal_r">
</div>
<div class="form-group col-12" id="build_menu_blankurl_modal_div_r" name="drawing_extend_r">
<label class="form-label" for="build_menu_blankurl_modal_r"><span class="text-danger">*</span>彈出URL</label>
<input type="text" id="build_menu_blankurl_modal_r" class="form-control" name="build_menu_blankurl_modal_r">
</div>
<div class="form-group col-12" id="build_menu_icon_click_onoff_modal_div_r" name="drawing_extend_r">
<label class="form-label">昇位圖 - 詳細資料設定</label>
@*<div class="row">
<div class="col">
<input type="radio" name="icon_click_onoff" id="icon_click_on" value="1">
<label for="icon_click_on">
點擊開關
</label>
</div>
<div class="col">
<input type="radio" name="icon_click_onoff" id="icon_click_off" value="0" checked>
<label for="icon_click_off">
彈出視窗
</label>
</div>
</div>*@
<div class="row">
<div class="col" style="display:none">
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" name="icon_click[]_r" id="icon_click_switch_r" value="2">
<label class="custom-control-label" for="icon_click_switch_r">點擊開關</label>
</div>
</div>
<div class="col">
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" name="icon_click[]_r" id="icon_click_url_r" value="1">
<label class="custom-control-label" for="icon_click_url_r">顯示詳細資料</label>
</div>
</div>
</div>
</div>
<div class="form-group col-12" id="build_menu_icon_click_url_modal_div_r" name="drawing_extend_r">
<label class="form-label" for="build_menu_icon_click_url_modal_r">詳細資料 URL</label><br>
<button type="button" class="btn btn-secondary waves-effect waves-themed mb-2" onclick="AddTagIntoClickUrl('device_building_tag')">+/[device_building_tag]</button>
<button type="button" class="btn btn-secondary waves-effect waves-themed mb-2" onclick="AddTagIntoClickUrl('device_system_tag')">+/[device_system_tag]</button>
<button type="button" class="btn btn-secondary waves-effect waves-themed mb-2" onclick="AddTagIntoClickUrl('device_floor_tag')">+/[device_floor_tag]</button>
<button type="button" class="btn btn-secondary waves-effect waves-themed mb-2" onclick="AddTagIntoClickUrl('device_name_tag')">+/[device_name_tag]</button>
<button type="button" class="btn btn-secondary waves-effect waves-themed mb-2" onclick="AddTagIntoClickUrl('device_serial_tag')">+/[device_serial_tag]</button>
<button type="button" class="btn btn-secondary waves-effect waves-themed mb-2" onclick="AddTagIntoClickUrl('tag_name')">+/[tag_name]</button>
<input type="text" id="build_menu_icon_click_url_modal_r" class="form-control">
</div>
<div class="form-group col-12" id="build_menu_icon_click_url_width_height_modal_div_r">
<label class="form-label">詳細資料 顯示視窗設定</label><br>
<div class="row">
<div class="col-6 form-group">
<label class="form-label" for="build_menu_icon_click_url_width_modal_r">寬(單位px)</label>
<input type="number" step="1" id="build_menu_icon_click_url_width_modal_r" class="form-control">
</div>
<div class="col-6 form-group">
<label class="form-label" for="build_menu_icon_click_url_height_modal_r">高(單位px)</label>
<input type="number" step="1" id="build_menu_icon_click_url_height_modal_r" class="form-control">
</div>
</div>
</div>
<div class="form-group col-12" id="build_menu_riser_diagram_url_modal_div_r" style="display: none">
<label class="form-label" for="build_menu_riser_diagram_url_modal_r">昇位圖 URL</label><br>
<input type="text" id="build_menu_riser_diagram_url_modal_r" class="form-control">
</div>
<div class="form-group col-6" id="build_menu_planimetric_floor_modal_div_r">
<label class="form-label" for="build_menu_planimetric_floor_modal_r"><span class="text-danger">*</span>平面圖預設樓層</label>
<select class="form-control" id="build_menu_planimetric_floor_modal_r">
</select>
</div>
</div>
</div> </div>
</form> </form>
</div> </div>
@ -300,7 +447,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;
} }
@ -312,13 +459,13 @@
"data": "sub_system_guid_name" "data": "sub_system_guid_name"
}, },
{ {
"data": "drawing_name" "data": "left_drawing_name"
}, },
{ {
"data": "planimetric_click_name" "data": "left_planimetric_click_name"
}, },
{ {
"data": "icon_click", "data": null,
"render": function (data, type, row, meta) { "render": function (data, type, row, meta) {
var str = []; var str = [];
if (2 & parseInt(data) > 0) { if (2 & parseInt(data) > 0) {
@ -331,7 +478,29 @@
} }
}, },
{ {
"data": "icon_click_url" "data": "left_icon_click_url"
},
{
"data": "right_drawing_name"
},
{
"data": "right_planimetric_click_name"
},
{
"data": null,
"render": function (data, type, row, meta) {
var str = [];
if (2 & parseInt(data) > 0) {
str.push("點擊開關")
}
if (1 & parseInt(data) > 0) {
str.push("顯示詳細資料")
}
return str.join(";");
}
},
{
"data": "right_icon_click_url"
}, },
{ {
"data": null, "data": null,
@ -339,9 +508,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);
}, },
@ -349,7 +518,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) {
@ -364,11 +533,17 @@
} else { } else {
$.each(this.data, function (k, rel) { $.each(this.data, function (k, rel) {
rel.sub_system_guid_name = "<font color='#7c91df'>" + rel.sub_system_guid_name + "</font>" rel.sub_system_guid_name = "<font color='#7c91df'>" + rel.sub_system_guid_name + "</font>"
if (rel.drawing == 2) { if (rel.left_drawing == 2) {
rel.drawing_name = rel.drawing_name + "<br>" + '<a href = "' + rel.system_url +'" target="_blank" >點擊連結</a >' rel.left_drawing_name = rel.left_drawing_name + "<br>" + '<a href = "' + rel.system_url + '" target="_blank" >點擊連結</a >'
} }
if (rel.drawing == 1) { if (rel.left_drawing == 1) {
rel.drawing_name = rel.drawing_name + "<br>" + '[' + rel.floor_guid_name + ']' rel.left_drawing_name = rel.left_drawing_name + "<br>" + '[' + rel.floor_guid_name + ']'
}
if (rel.right_drawing == 2) {
rel.right_drawing_name = rel.right_drawing_name + "<br>" + '<a href = "' + rel.system_url + '" target="_blank" >點擊連結</a >'
}
if (rel.right_drawing == 1) {
rel.right_drawing_name = rel.right_drawing_name + "<br>" + '[' + rel.floor_guid_name + ']'
} }
}) })
} }
@ -380,7 +555,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;
} }
@ -400,15 +575,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") {
@ -474,10 +649,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") {
@ -540,8 +715,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") {
@ -589,16 +764,17 @@
$.each($("input[name='icon_click[]']"), function (index, item) { $.each($("input[name='icon_click[]']"), function (index, item) {
$(this).prop("checked", false); $(this).prop("checked", false);
}); });
$('#drawing_4').trigger('change'); changebuild_menu_drawing_modal();
GetSubList($('#build_menu_main_modal').val()); GetSubList($('#build_menu_main_modal').val());
GetFloorInSubSystem(); GetFloorInSubSystem();
$('#planimetric_click').attr("disabled", false); $('#planimetric_click').attr("disabled", false);
$('#build-menu-modal').modal(); $('#build-menu-modal').modal();
} }
//#endregion //#endregionplanimetric_click
//#region 修改選擇顯示頁面總類 //#region 修改選擇顯示頁面總類
$('#build_menu_drawing_modal').on("change", $("input[name='drawing']"), function () { $('#build-menu-form').on("change", "input[name^=drawing]", function () {
changebuild_menu_drawing_modal(); changebuild_menu_drawing_modal(this);
}); });
//#endregion //#endregion
$('#build_menu_icon_click_onoff_modal_div').on("click", "input[type=checkbox]", function () { $('#build_menu_icon_click_onoff_modal_div').on("click", "input[type=checkbox]", function () {
@ -610,6 +786,17 @@
$('#build_menu_icon_click_url_width_height_modal_div').hide(); $('#build_menu_icon_click_url_width_height_modal_div').hide();
} }
}); });
$('#build_menu_icon_click_onoff_modal_div_r').on("click", "input[type=checkbox]", function () {
if ($(this).prop("checked") && $(this).val() == 1) {
$('#build_menu_icon_click_url_modal_div_r').show();
$('#build_menu_icon_click_url_width_height_modal_div_r').show();
} else {
$('#build_menu_icon_click_url_modal_div_r').hide();
$('#build_menu_icon_click_url_width_height_modal_div_r').hide();
}
});
//#region 更改大類更換小類 //#region 更改大類更換小類
$('#build_menu_main_modal').on("change", function () { $('#build_menu_main_modal').on("change", function () {
GetSubList($('#build_menu_main_modal').val()); GetSubList($('#build_menu_main_modal').val());
@ -638,27 +825,42 @@
return; return;
} }
var icon_click = 0; var left_icon_click = 0;
var right_icon_click = 0;
$.each($("input[name='icon_click[]']"), function (index, item) { $.each($("input[name='icon_click[]']"), function (index, item) {
if (item.checked) { if (item.checked) {
icon_click += parseInt(item.value); left_icon_click += parseInt(item.value);
}
});
$.each($("input[name='icon_click[]_r']"), function (index, item) {
if (item.checked) {
right_icon_click += parseInt(item.value);
} }
}); });
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(), left_drawing: $('input[name="drawing"]:checked').val(),
system_url: $('#build_menu_systemurl_modal').val(), left_system_url: $('#build_menu_systemurl_modal').val(),
icon_click: icon_click, left_icon_click: left_icon_click,
icon_click_url: $('#build_menu_icon_click_url_modal').val(), left_icon_click_url: $('#build_menu_icon_click_url_modal').val(),
icon_click_url_width: $('#build_menu_icon_click_url_width_modal').val(), left_icon_click_url_width: $('#build_menu_icon_click_url_width_modal').val(),
icon_click_url_height: $('#build_menu_icon_click_url_height_modal').val(), left_icon_click_url_height: $('#build_menu_icon_click_url_height_modal').val(),
planimetric_click: $('input[name="planimetric_click"]:checked').val(), left_planimetric_click: $('input[name="planimetric_click"]:checked').val(),
riser_diagram_url: $('#build_menu_riser_diagram_url_modal').val(), left_riser_diagram_url: $('#build_menu_riser_diagram_url_modal').val(),
planimetric_floor_guid: $('#build_menu_planimetric_floor_modal').val() left_planimetric_floor_guid: $('#build_menu_planimetric_floor_modal').val(),
right_drawing: $('input[name="drawing_r"]:checked').val(),
right_system_url: $('#build_menu_systemurl_modal_r').val(),
right_icon_click: right_icon_click,
right_icon_click_url: $('#build_menu_icon_click_url_modal_r').val(),
right_icon_click_url_width: $('#build_menu_icon_click_url_width_modal_r').val(),
right_icon_click_url_height: $('#build_menu_icon_click_url_height_modal_r').val(),
right_planimetric_click: $('input[name="planimetric_click_r"]:checked').val(),
right_riser_diagram_url: $('#build_menu_riser_diagram_url_modal_r').val(),
right_planimetric_floor_guid: $('#build_menu_planimetric_floor_modal_r').val()
}; };
$.post(url, send_data, function (rel) { $.post(url, send_data, function (rel) {
if (rel.code != "0000") { if (rel.code != "0000") {
@ -678,51 +880,81 @@
$('#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);
if (rel.data.planimetric_click == 1) { //left
$("input[name='drawing'][value='" + rel.data.left_drawing + "']").prop("checked", true);
if (rel.data.left_planimetric_click == 1) {
$('input[name="planimetric_click"]').prop("checked", true) $('input[name="planimetric_click"]').prop("checked", true)
} else { } else {
$('input[name="planimetric_click"]').prop("checked", false) $('input[name="planimetric_click"]').prop("checked", false)
} }
$('#build_menu_systemurl_modal').val(rel.data.system_url); $('#build_menu_systemurl_modal').val(rel.data.left_system_url);
$.each($("input[name='icon_click[]']"), function (index, item) { $.each($("input[name='icon_click[]']"), function (index, item) {
if (parseInt(item.value) & rel.data.icon_click > 0) { if (parseInt(item.value) & rel.data.left_icon_click > 0) {
$(item).prop("checked", true); $(item).prop("checked", true);
} else { } else {
$(item).prop("checked", false); $(item).prop("checked", false);
} }
}); });
@*$("input[name*='icon_click_onoff'][value='" + rel.data.icon_click + "']").prop("checked", true);*@ @*$("input[name*='icon_click_onoff'][value='" + rel.data.icon_click + "']").prop("checked", true);*@
$('#build_menu_icon_click_url_modal').val(rel.data.icon_click_url); $('#build_menu_icon_click_url_modal').val(rel.data.left_icon_click_url);
if (rel.data.icon_click_url_width != undefined && rel.data.icon_click_url_width != null && rel.data.icon_click_url_width > 0) { if (rel.data.left_icon_click_url_width != undefined && rel.data.left_icon_click_url_width != null && rel.data.left_icon_click_url_width > 0) {
$('#build_menu_icon_click_url_width_modal').val(rel.data.icon_click_url_width); $('#build_menu_icon_click_url_width_modal').val(rel.data.left_icon_click_url_width);
} else { } else {
$('#build_menu_icon_click_url_width_modal').val(""); $('#build_menu_icon_click_url_width_modal').val("");
} }
if (rel.data.icon_click_url_height != undefined && rel.data.icon_click_url_height != null && rel.data.icon_click_url_height > 0) { if (rel.data.left_icon_click_url_height != undefined && rel.data.left_icon_click_url_height != null && rel.data.left_icon_click_url_height > 0) {
$('#build_menu_icon_click_url_height_modal').val(rel.data.icon_click_url_height); $('#build_menu_icon_click_url_height_modal').val(rel.data.left_icon_click_url_height);
} else { } else {
$('#build_menu_icon_click_url_height_modal').val(""); $('#build_menu_icon_click_url_height_modal').val("");
} }
//right
$("input[name*='drawing_r'][value='" + rel.data.right_drawing + "']").prop("checked", true);
if (rel.data.right_planimetric_click == 1) {
$('input[name="planimetric_click_r"]').prop("checked", true)
} else {
$('input[name="planimetric_click_r"]').prop("checked", false)
}
$('#build_menu_systemurl_modal_r').val(rel.data.right_system_url);
$.each($("input[name='icon_click[]_r']"), function (index, item) {
if (parseInt(item.value) & rel.data.left_icon_click > 0) {
$(item).prop("checked", true);
} else {
$(item).prop("checked", false);
}
});
$('#build_menu_icon_click_url_modal_r').val(rel.data.right_icon_click_url);
if (rel.data.right_icon_click_url_width != undefined && rel.data.right_icon_click_url_width != null && rel.data.right_icon_click_url_width > 0) {
$('#build_menu_icon_click_url_width_modal_r').val(rel.data.right_icon_click_url_width);
} else {
$('#build_menu_icon_click_url_width_modal_r').val("");
}
if (rel.data.right_icon_click_url_height != undefined && rel.data.right_icon_click_url_height != null && rel.data.right_icon_click_url_height > 0) {
$('#build_menu_icon_click_url_height_modal_r').val(rel.data.right_icon_click_url_height);
} else {
$('#build_menu_icon_click_url_height_modal_r').val("");
}
changebuild_menu_drawing_modal(); changebuild_menu_drawing_modal();
GetFloorInSubSystem(rel.data.planimetric_floor_guid); GetFloorInSubSystem(rel.data.left_planimetric_floor_guid);
GetFloorInSubSystem(rel.data.right_planimetric_floor_guid);
$('.modal-title').html("選單基本資料 - 修改"); $('.modal-title').html("選單基本資料 - 修改");
$('#build-menu-modal').modal(); $('#build-menu-modal').modal();
@ -730,45 +962,46 @@
}, 'json'); }, 'json');
}); });
//#endregion //#endregion
function changebuild_menu_drawing_modal() { function changebuild_menu_drawing_modal(selector = "input[name^='drawing']:checked") {
if ($('input[name="drawing"]:checked').val() == 2) {
$('#planimetric_click').attr("disabled", false);
$('#build_menu_icon_click_onoff_modal_div').hide();
$('#build_menu_icon_click_url_modal_div').hide();
$('#build_menu_systemurl_modal_div').show();
@*$('#build_menu_riser_diagram_url_modal_div').hide();*@
$('#build_menu_icon_click_url_width_height_modal_div').hide();
$('#build_menu_planimetric_floor_modal_div').hide();
} else if ($('input[name="drawing"]:checked').val() == 4) {
$('#planimetric_click').attr("disabled", false);
$('#build_menu_systemurl_modal_div').hide();
$('#build_menu_icon_click_onoff_modal_div').show();
if ($("#icon_click_url").prop('checked')) {
$('#build_menu_icon_click_url_modal_div').show();
$('#build_menu_icon_click_url_width_height_modal_div').show();
}
else {
$('#build_menu_icon_click_url_modal_div').hide();
$('#build_menu_icon_click_url_width_height_modal_div').hide();
}
@*$('#build_menu_riser_diagram_url_modal_div').show();*@
$('#build_menu_planimetric_floor_modal_div').hide(); $(selector).each(function (index, value) {
} else if ($('input[name="drawing"]:checked').val() == 1) { let drawingParent = $(value).parents("[id^=build_menu_position]")
$('#planimetric_click').prop("checked", true).attr("disabled", true); $(drawingParent).find('[id^=build_menu_icon_click_onoff_modal_div]').hide();
$('#build_menu_systemurl_modal_div').hide(); $(drawingParent).find('[id^=build_menu_blankurl_modal_div]').hide();
$('#build_menu_icon_click_onoff_modal_div').hide(); $(drawingParent).find('[id^=build_menu_icon_click_url_modal_div]').hide();
$('#build_menu_icon_click_url_modal_div').hide(); $(drawingParent).find('[id^=build_menu_icon_click_url_width_height_modal_div]').hide();
@*$('#build_menu_riser_diagram_url_modal_div').hide();*@ $(drawingParent).find('[id^=build_menu_planimetric_floor_modal_div]').hide();
$('#build_menu_icon_click_url_width_height_modal_div').hide(); $(drawingParent).find('[id^=build_menu_systemurl_modal_div]').hide();
$('#build_menu_planimetric_floor_modal_div').show();
if ($(value).val() == 2) {
$(drawingParent).find('[id^=planimetric_click]').attr("disabled", false);
$(drawingParent).find('[id^=build_menu_systemurl_modal_div]').show();
} else if ($(value).val() == 4) {
$(drawingParent).find('[id^="planimetric_click"]').attr("disabled", false);
$(drawingParent).find('[id^=build_menu_icon_click_onoff_modal_div]').show();
if ($(drawingParent).find("[id^=icon_click_url]").prop('checked')) {
$(drawingParent).find('[id^=build_menu_icon_click_url_modal_div]').show();
$(drawingParent).find('[id^=build_menu_icon_click_url_width_height_modal_div]').show();
} }
} else if ($(value).val() == 1) {
$(drawingParent).find('[id^=planimetric_click]').prop("checked", true).attr("disabled", true);
$(drawingParent).find('[id^=build_menu_planimetric_floor_modal_div]').show();
} else if ($(value).val() == 5) {
$(drawingParent).find('[id^=planimetric_click]').prop("checked", false);
$(drawingParent).find('[id^=build_menu_blankurl_modal_div]').show();
} else if ($(value).val() == 3) {
$(drawingParent).find('[id^=planimetric_click]').prop("checked", false).attr("disabled", true);
}
})
} }
$('#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(
{ {
@ -821,9 +1054,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) {
@ -835,7 +1068,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>';
}); });
@ -858,9 +1091,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/";
@ -878,7 +1111,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(
{ {
@ -932,26 +1165,28 @@
} }
buildMenuTable.ajax.reload(); buildMenuTable.ajax.reload();
} }
function AddTagIntoClickUrl(tag) { function AddTagIntoClickUrl(tag, way) {
var a = $('#build_menu_icon_click_url_modal').val(); var elem = way == "l" ? $('#build_menu_icon_click_url_modal') : $('#build_menu_icon_click_url_modal_r');
var a = elem.val();
switch (tag) { switch (tag) {
case 'device_building_tag': case 'device_building_tag':
$('#build_menu_icon_click_url_modal').val(a + '/[device_building_tag]'); elem.val(a + '/[device_building_tag]');
break; break;
case 'device_system_tag': case 'device_system_tag':
$('#build_menu_icon_click_url_modal').val(a + '/[device_system_tag]'); elem.val(a + '/[device_system_tag]');
break; break;
case 'device_floor_tag': case 'device_floor_tag':
$('#build_menu_icon_click_url_modal').val(a + '/[device_floor_tag]'); elem.val(a + '/[device_floor_tag]');
break; break;
case 'device_name_tag': case 'device_name_tag':
$('#build_menu_icon_click_url_modal').val(a + '/[device_name_tag]'); elem.val(a + '/[device_name_tag]');
break; break;
case 'device_serial_tag': case 'device_serial_tag':
$('#build_menu_icon_click_url_modal').val(a + '/[device_serial_tag]'); elem.val(a + '/[device_serial_tag]');
break; break;
case 'tag_name': case 'tag_name':
$('#build_menu_icon_click_url_modal').val(a + '/[tag_name]'); elem.val(a + '/[tag_name]');
break; break;
} }
@ -959,9 +1194,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") {
@ -969,19 +1204,21 @@
} }
else { else {
if (rel.data.length == 0) { if (rel.data.length == 0) {
$('#drawing_1_div').hide(); $('[id^=drawing_1_div]').hide();
$('#build_menu_planimetric_floor_modal_div').hide(); $('[id^=build_menu_planimetric_floor_modal_div]').hide();
} }
else { else {
$('#build_menu_planimetric_floor_modal').empty(); $('#build_menu_planimetric_floor_modal,#build_menu_planimetric_floor_modal_r').empty();
$.each(rel.data, function (index, val) { $.each(rel.data, function (index, val) {
$('#build_menu_planimetric_floor_modal').append($("<option />").val(val.value).text(val.name)); $('#build_menu_planimetric_floor_modal').append($("<option />").val(val.value).text(val.name));
$('#build_menu_planimetric_floor_modal_r').append($("<option />").val(val.value).text(val.name));
}); });
if (floor != null) { if (floor != null) {
$('#build_menu_planimetric_floor_modal').val(floor); $('#build_menu_planimetric_floor_modal').val(floor);
$('#build_menu_planimetric_floor_modal_r').val(floor);
} }
$('#drawing_1_div').show(); $('[id^=drawing_1_div]').show();
$('#build_menu_planimetric_floor_modal_div').show(); $('[id^=build_menu_planimetric_floor_modal_div]').show();
changebuild_menu_drawing_modal(); changebuild_menu_drawing_modal();
} }

View File

@ -607,7 +607,7 @@
<script src="~/js/echarts.min.js"></script> <script src="~/js/echarts.min.js"></script>
<script> <script>
var buildingCollapses; var buildingCollapses;
var selected_building_menu = {}, selected_floor_guid; var selected_building_menu = {}, selected_floor_tag;
var chartDom, myChart, option, var chartDom, myChart, option,
floor_map_mode = "view", //平面圖當前模式 floor_map_mode = "view", //平面圖當前模式
selected_temp_device, //被選擇要修改的設備 selected_temp_device, //被選擇要修改的設備
@ -747,10 +747,10 @@
"url": "/DeviceManage/DeviceTableList", "url": "/DeviceManage/DeviceTableList",
"type": "POST", "type": "POST",
"data": function (d) { "data": function (d) {
d.Building_guid = selected_building_menu.building_guid ? selected_building_menu.building_guid : ""; d.building_tag = selected_building_menu.building_tag ? selected_building_menu.building_tag : "";
d.Main_system_guid = selected_building_menu.main_system ? selected_building_menu.main_system.main_system_guid : ""; d.device_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.main_system_tag : "";
d.Sub_system_guid = selected_building_menu.main_system ? selected_building_menu.main_system.sub_system ? selected_building_menu.main_system.sub_system.sub_system_guid : "" : ""; d.device_name_tag = selected_building_menu.main_system ? selected_building_menu.main_system.sub_system ? selected_building_menu.main_system.sub_system.sub_system_tag : "" : "";
d.Floor_guid = selected_floor_guid ? selected_floor_guid : ""; d.device_floor_tag = selected_floor_tag ? selected_floor_tag : "";
}, },
"dataSrc": function (rel) { "dataSrc": function (rel) {
if (rel.code == "9999") { if (rel.code == "9999") {
@ -1050,10 +1050,10 @@
"url": "/DeviceManage/GetDeviceMasterTableList", "url": "/DeviceManage/GetDeviceMasterTableList",
"type": "POST", "type": "POST",
"data": function (d) { "data": function (d) {
d.Building_guid = selected_building_menu.building_guid ? selected_building_menu.building_guid : ""; d.Building_tag = selected_building_menu.building_tag ? selected_building_menu.building_tag : "";
d.Main_system_guid = selected_building_menu.main_system ? selected_building_menu.main_system.main_system_guid : ""; d.Main_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.main_system_tag : "";
d.Sub_system_guid = selected_building_menu.main_system ? selected_building_menu.main_system.sub_system ? selected_building_menu.main_system.sub_system.sub_system_guid : "" : ""; d.Sub_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.sub_system ? selected_building_menu.main_system.sub_system.sub_system_tag : "" : "";
d.Floor_guid = selected_floor_guid ? selected_floor_guid : ""; d.Floor_tag = selected_floor_tag ? selected_floor_tag : "";
}, },
"dataSrc": function (rel) { "dataSrc": function (rel) {
if (rel.code == "9999") { if (rel.code == "9999") {
@ -1077,11 +1077,11 @@
$("#device-master-list-btn").click(function (e) { $("#device-master-list-btn").click(function (e) {
e.preventDefault(); e.preventDefault();
var selectedBuilding_guid = selected_building_menu.building_guid ? selected_building_menu.building_guid : ""; var selectedBuilding_tag = selected_building_menu.building_tag ? selected_building_menu.building_tag : "";
var selectedMain_system_guid = selected_building_menu.main_system ? selected_building_menu.main_system.main_system_guid : ""; var selectedMain_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.main_system_tag : "";
var selectedSub_system_guid = selected_building_menu.main_system ? selected_building_menu.main_system.sub_system ? selected_building_menu.main_system.sub_system.sub_system_guid : "" : ""; var selectedSub_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.sub_system ? selected_building_menu.main_system.sub_system.sub_system_tag : "" : "";
var selectedFloor_guid = selected_floor_guid ? selected_floor_guid : ""; var selectedFloor_tag = selected_floor_tag ? selected_floor_tag : "";
if (selectedBuilding_guid == '' || selectedMain_system_guid == '' || selectedSub_system_guid == '' || selectedFloor_guid == '') { if (selectedBuilding_tag == '' || selectedMain_system_tag == '' || selectedSub_system_tag == '' || selectedFloor_tag == '') {
toast_warning("請先選擇系統類別及樓層。"); toast_warning("請先選擇系統類別及樓層。");
return; return;
} }
@ -1494,10 +1494,10 @@
"url": "/DeviceManage/DeviceKindTableList", "url": "/DeviceManage/DeviceKindTableList",
"type": "POST", "type": "POST",
"data": function (d) { "data": function (d) {
d.Building_guid = selected_building_menu.building_guid ? selected_building_menu.building_guid : ""; d.Building_tag = selected_building_menu.building_tag ? selected_building_menu.building_tag : "";
d.Main_system_guid = selected_building_menu.main_system ? selected_building_menu.main_system.main_system_guid : ""; d.Main_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.main_system_tag : "";
d.Sub_system_guid = selected_building_menu.main_system ? selected_building_menu.main_system.sub_system ? selected_building_menu.main_system.sub_system.sub_system_guid : "" : ""; d.Sub_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.sub_system ? selected_building_menu.main_system.sub_system.sub_system_tag : "" : "";
d.Floor_guid = selected_floor_guid ? selected_floor_guid : ""; d.Floor_tag = selected_floor_tag ? selected_floor_tag : "";
}, },
"dataSrc": function (rel) { "dataSrc": function (rel) {
if (rel.code == "9999") { if (rel.code == "9999") {
@ -1549,10 +1549,10 @@
device_kind_data = rel.data; device_kind_data = rel.data;
//取得單一設備基本資料 //取得單一設備基本資料
var selectedSub_system_guid = selected_building_menu.main_system ? selected_building_menu.main_system.sub_system ? selected_building_menu.main_system.sub_system.sub_system_guid : "" : ""; var selectedSub_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.sub_system ? selected_building_menu.main_system.sub_system.sub_system_tag : "" : "";
var url = "/DeviceManage/GetDeviceItem"; var url = "/DeviceManage/GetDeviceItem";
var send_data = { var send_data = {
sub_system_guid: selectedSub_system_guid sub_system_tag: selectedSub_system_tag
} }
$.post(url, send_data, function (rel) { $.post(url, send_data, function (rel) {
@ -1910,9 +1910,9 @@
html += ` html += `
<li class="list-group-item pr-0 d-flex justify-content-between"> <li class="list-group-item pr-0 d-flex justify-content-between">
<a href="javascript:;" onclick="ChangeFloorPanel(this)" <a href="javascript:;" onclick="ChangeFloorPanel(this)"
data-building-guid="${buildingCollapse.building_guid}" data-building-tag="${buildingCollapse.building_tag}"
data-main-system-guid="${main_system.main_system_guid}" data-main-system-tag="${main_system.main_system_tag}"
data-sub-system-guid="${sub_system.sub_system_guid}"> data-sub-system-tag="${sub_system.sub_system_tag}">
${sub_system.full_name} ${sub_system.full_name}
</a> </a>
</li>`; </li>`;
@ -1944,26 +1944,26 @@
function ChangeFloorPanel(dom) { function ChangeFloorPanel(dom) {
var selected_target = { var selected_target = {
"building_guid": $(dom).attr("data-building-guid") ? $(dom).attr("data-building-guid") : "", "building_tag": $(dom).attr("data-building-tag") ? $(dom).attr("data-building-tag") : "",
"main_system_guid": $(dom).attr("data-main-system-guid") ? $(dom).attr("data-main-system-guid") : "", "main_system_tag": $(dom).attr("data-main-system-tag") ? $(dom).attr("data-main-system-tag") : "",
"sub_system_guid": $(dom).attr("data-sub-system-guid") ? $(dom).attr("data-sub-system-guid") : "", "sub_system_tag": $(dom).attr("data-sub-system-tag") ? $(dom).attr("data-sub-system-tag") : "",
} }
buildingCollapses.forEach(function (building_item, building_index) { buildingCollapses.forEach(function (building_item, building_index) {
if (building_item.building_guid == selected_target.building_guid) { if (building_item.building_tag == selected_target.building_tag) {
selected_building_menu.building_guid = building_item.building_guid; selected_building_menu.building_tag = building_item.building_tag;
selected_building_menu.main_system = {}; selected_building_menu.main_system = {};
building_item.main_systems.forEach(function (main_system_item, main_system_index) { building_item.main_systems.forEach(function (main_system_item, main_system_index) {
if (main_system_item.main_system_guid == selected_target.main_system_guid) { if (main_system_item.main_system_tag == selected_target.main_system_tag) {
selected_building_menu.main_system.main_system_guid = main_system_item.main_system_guid selected_building_menu.main_system.main_system_tag = main_system_item.main_system_tag
selected_building_menu.main_system.sub_system = {}; selected_building_menu.main_system.sub_system = {};
$("#select-main-system-name").html(main_system_item.full_name); $("#select-main-system-name").html(main_system_item.full_name);
main_system_item.sub_systems.forEach(function (sub_system_item, sub_system_index) { main_system_item.sub_systems.forEach(function (sub_system_item, sub_system_index) {
if (sub_system_item.sub_system_guid == selected_target.sub_system_guid) { if (sub_system_item.sub_system_tag == selected_target.sub_system_tag) {
selected_building_menu.main_system.sub_system.sub_system_guid = sub_system_item.sub_system_guid selected_building_menu.main_system.sub_system.sub_system_tag = sub_system_item.sub_system_tag
selected_building_menu.main_system.sub_system.floors = sub_system_item.floors; selected_building_menu.main_system.sub_system.floors = sub_system_item.floors;
$("#select-sub-system-name").html(sub_system_item.full_name); $("#select-sub-system-name").html(sub_system_item.full_name);
@ -1971,7 +1971,7 @@
//匯入floor panel //匯入floor panel
$(".floor-panel-wrap").empty(); $(".floor-panel-wrap").empty();
sub_system_item.floors.forEach(function (floor_item, floor_index) { sub_system_item.floors.forEach(function (floor_item, floor_index) {
$(".floor-panel-wrap").append(`<button type="button" class="btn btn-secondary waves-effect waves-themed mr-2 mb-2 btn-floor" onclick="ChangeDevicePanel(this)" data-floor-guid="${floor_item.floor_guid}">${floor_item.full_name}</button>`) $(".floor-panel-wrap").append(`<button type="button" class="btn btn-secondary waves-effect waves-themed mr-2 mb-2 btn-floor" onclick="ChangeDevicePanel(this)" data-floor-guid="${floor_item.floor_tag}">${floor_item.full_name}</button>`)
}); });
} }
}); });
@ -1987,10 +1987,10 @@
//#region 變更平面圖與設備的控制面板 //#region 變更平面圖與設備的控制面板
function ChangeDevicePanel(dom) { function ChangeDevicePanel(dom) {
selected_floor_guid = $(dom).attr("data-floor-guid") ? $(dom).attr("data-floor-guid") : "" selected_floor_tag = $(dom).attr("data-floor-guid") ? $(dom).attr("data-floor-guid") : ""
var current_floor = selected_building_menu.main_system.sub_system.floors.filter(function (item) { var current_floor = selected_building_menu.main_system.sub_system.floors.filter(function (item) {
return item.floor_guid == selected_floor_guid return item.floor_tag == selected_floor_tag
})[0]; })[0];
$.each($(".btn-floor"), function (index, item) { $.each($(".btn-floor"), function (index, item) {
@ -2522,11 +2522,11 @@
//#region 新增設備 //#region 新增設備
function AddDevice() { function AddDevice() {
var selectedBuilding_guid = selected_building_menu.building_guid ? selected_building_menu.building_guid : ""; var selectedBuilding_tag = selected_building_menu.building_tag ? selected_building_menu.building_tag : "";
var selectedMain_system_guid = selected_building_menu.main_system ? selected_building_menu.main_system.main_system_guid : ""; var selectedMain_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.main_system_tag : "";
var selectedSub_system_guid = selected_building_menu.main_system ? selected_building_menu.main_system.sub_system ? selected_building_menu.main_system.sub_system.sub_system_guid : "" : ""; var selectedSub_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.sub_system ? selected_building_menu.main_system.sub_system.sub_system_tag : "" : "";
var selectedFloor_guid = selected_floor_guid ? selected_floor_guid : ""; var selectedFloor_tag = selected_floor_tag ? selected_floor_tag : "";
if (selectedBuilding_guid == '' || selectedMain_system_guid == '' || selectedSub_system_guid == '' || selectedFloor_guid == '') { if (selectedBuilding_tag == '' || selectedMain_system_tag == '' || selectedSub_system_tag == '' || selectedFloor_tag == '') {
toast_warning("請先選擇系統類別及樓層。"); toast_warning("請先選擇系統類別及樓層。");
return; return;
} }
@ -2676,11 +2676,11 @@
//#region 設備儲存(透過新增按鈕) //#region 設備儲存(透過新增按鈕)
function SaveDeviceAdd() { function SaveDeviceAdd() {
var selectedBuilding_guid = selected_building_menu.building_guid ? selected_building_menu.building_guid : ""; var selectedBuilding_tag = selected_building_menu.building_tag ? selected_building_menu.building_tag : "";
var selectedMain_system_guid = selected_building_menu.main_system ? selected_building_menu.main_system.main_system_guid : ""; var selectedMain_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.main_system_tag : "";
var selectedSub_system_guid = selected_building_menu.main_system ? selected_building_menu.main_system.sub_system ? selected_building_menu.main_system.sub_system.sub_system_guid : "" : ""; var selectedSub_system_tag = selected_building_menu.main_system ? selected_building_menu.main_system.sub_system ? selected_building_menu.main_system.sub_system.sub_system_tag : "" : "";
var selectedFloor_guid = selected_floor_guid ? selected_floor_guid : ""; var selectedFloor_tag = selected_floor_tag ? selected_floor_tag : "";
if (selectedBuilding_guid == '' || selectedMain_system_guid == '' || selectedSub_system_guid == '' || selectedFloor_guid == '') if (selectedBuilding_tag == '' || selectedMain_system_tag == '' || selectedSub_system_tag == '' || selectedFloor_tag == '')
{ {
toast_warning("請先選擇系統類別及樓層。"); toast_warning("請先選擇系統類別及樓層。");
return; return;
@ -2710,10 +2710,10 @@
var url = "/DeviceManage/SaveDeviceInfoAdd"; var url = "/DeviceManage/SaveDeviceInfoAdd";
@*var send_data = { @*var send_data = {
Building_guid: selectedBuilding_guid, Building_tag: selectedBuilding_tag,
Main_system_guid: selectedMain_system_guid, Main_system_tag: selectedMain_system_tag,
Sub_system_guid: selectedSub_system_guid, Sub_system_tag: selectedSub_system_tag,
Floor_guid: selectedFloor_guid, Floor_tag: selectedFloor_tag,
SelectedDevices: selectedDevices SelectedDevices: selectedDevices
} }
@ -2734,10 +2734,10 @@
var formData = new FormData(); var formData = new FormData();
formData.append("Building_guid", selectedBuilding_guid); formData.append("Building_tag", selectedBuilding_tag);
formData.append("Main_system_guid", selectedMain_system_guid); formData.append("Main_system_tag", selectedMain_system_tag);
formData.append("Sub_system_guid", selectedSub_system_guid); formData.append("Sub_system_tag", selectedSub_system_tag);
formData.append("Floor_guid", selectedFloor_guid); formData.append("Floor_tag", selectedFloor_tag);
formData.append("SelectedDevicesFile", blob); formData.append("SelectedDevicesFile", blob);
$.ajax({ $.ajax({

View File

@ -53,10 +53,10 @@
} }
}, },
{ {
"data": "full_name" "data": "system_key"
}, },
{ {
"data": "code" "data": "system_value"
}, },
{ {
"data": "created_at" "data": "created_at"
@ -67,7 +67,7 @@
} }
], ],
'createdRow': function (row, data, dataIndex) { 'createdRow': function (row, data, dataIndex) {
$(row).attr('data-guid', data.main_system_guid); $(row).attr('data-guid', data.id);
}, },
//"order": [[2, "desc"]], //"order": [[2, "desc"]],
"ajax": { "ajax": {
@ -89,12 +89,12 @@
$("#system-main-list").empty(); $("#system-main-list").empty();
$.each(data, function (key, value) { $.each(data, function (key, value) {
if (key == 0) { if (key == 0) {
selected_system_main_guid_top_name = value.full_name; selected_system_main_guid_top_name = value.system_key;
$("#system-main-list").append(`<button type="button" class="btn btn-success waves-effect waves-themed ml-2 mb-2 btn-station" id="${value.main_system_guid}" onclick="clickSystemMain('${value.main_system_guid}')">${value.full_name}</button>`); $("#system-main-list").append(`<button type="button" class="btn btn-success waves-effect waves-themed ml-2 mb-2 btn-station" id="${value.id}" onclick="clickSystemMain('${value.id}')">${value.system_key}</button>`);
$(`#${value.main_system_guid}`).trigger("click"); $(`#${value.id}`).trigger("click");
} }
else { else {
$("#system-main-list").append(`<button type="button" class="btn btn-outline-success waves-effect waves-themed ml-2 mb-2 btn-station" id="${value.main_system_guid}" onclick="clickSystemMain('${value.main_system_guid}')">${value.full_name}</button>`); $("#system-main-list").append(`<button type="button" class="btn btn-outline-success waves-effect waves-themed ml-2 mb-2 btn-station" id="${value.id}" onclick="clickSystemMain('${value.id}')">${value.system_key}</button>`);
} }
}); });
@ -115,7 +115,7 @@
var url = "/SystemCategory/GetOneSystemMain"; var url = "/SystemCategory/GetOneSystemMain";
var send_data = { var send_data = {
guid: selected_system_main_guid id: selected_system_main_guid
} }
$.post(url, send_data, function (rel) { $.post(url, send_data, function (rel) {
@ -129,8 +129,8 @@
return; return;
} }
else { else {
$("#system_main_name_modal").val(rel.data.full_name); $("#system_main_name_modal").val(rel.data.system_key);
$("#system_main_code_modal").val(rel.data.code); $("#system_main_code_modal").val(rel.data.system_value);
$("#system-main-modal").modal(); $("#system-main-modal").modal();
} }
@ -157,7 +157,7 @@
if (result.value) { if (result.value) {
var url = "/SystemCategory/DeleteOneSystemMain"; var url = "/SystemCategory/DeleteOneSystemMain";
var send_data = { var send_data = {
Guid: selected_system_main_guid id: selected_system_main_guid
} }
$.post(url, send_data, function (rel) { $.post(url, send_data, function (rel) {
if (rel.code != "0000") { if (rel.code != "0000") {
@ -226,9 +226,9 @@
var url = "/SystemCategory/SaveSystemMain"; var url = "/SystemCategory/SaveSystemMain";
var send_data = { var send_data = {
Main_system_guid: selected_system_main_guid, id: selected_system_main_guid,
Full_name: $('#system_main_name_modal').val(), System_key: $('#system_main_name_modal').val(),
Code: $('#system_main_code_modal').val() system_value : $('#system_main_code_modal').val()
} }
$.post(url, send_data, function (rel) { $.post(url, send_data, function (rel) {
@ -278,7 +278,10 @@
} }
}, },
{ {
"data": "full_name" "data": "system_key"
},
{
"data": "system_value"
}, },
{ {
"data": "created_at" "data": "created_at"
@ -289,14 +292,14 @@
} }
], ],
'createdRow': function (row, data, dataIndex) { 'createdRow': function (row, data, dataIndex) {
$(row).attr('data-guid', data.sub_system_guid); $(row).attr('data-guid', data.id);
}, },
//"order": [[2, "desc"]], //"order": [[2, "desc"]],
"ajax": { "ajax": {
"url": "/SystemCategory/SystemSubList", "url": "/SystemCategory/SystemSubList",
"type": "POST", "type": "POST",
"data": function (d) { "data": function (d) {
d.Main_system_guid = selected_system_main_guid d.id = selected_system_main_guid
}, },
"dataSrc": function (rel) { "dataSrc": function (rel) {
if (rel.code == "9999") { if (rel.code == "9999") {
@ -346,20 +349,23 @@
{ {
"data": "is_bool" "data": "is_bool"
}, },
{
"data": "is_link"
},
{ {
"data": null, "data": null,
"defaultContent": '<button class="btn btn-primary edit-btn">修改</button> <button class="btn btn-danger del-btn">刪除</button>' "defaultContent": '<button class="btn btn-primary edit-btn">修改</button> <button class="btn btn-danger del-btn">刪除</button>'
} }
], ],
'createdRow': function (row, data, dataIndex) { 'createdRow': function (row, data, dataIndex) {
$(row).attr('data-guid', data.device_item_guid); $(row).attr('data-guid', data.id);
}, },
//"order": [[2, "desc"]], //"order": [[2, "desc"]],
"ajax": { "ajax": {
"url": "/SystemCategory/DeviceItemTable", "url": "/SystemCategory/DeviceItemTable",
"type": "POST", "type": "POST",
"data": function (d) { "data": function (d) {
d.sub_system_guid = selected_system_sub_guid d.id = selected_system_sub_guid
}, },
"dataSrc": function (rel) { "dataSrc": function (rel) {
if (rel.code == "9999") { if (rel.code == "9999") {
@ -397,6 +403,12 @@
} else { } else {
rel.is_bool = "是" rel.is_bool = "是"
} }
if (rel.is_link == 0) {
rel.is_link = "否"
} else {
rel.is_link = "是"
}
}); });
return data; return data;
@ -416,7 +428,7 @@
var url = "/SystemCategory/GetOneSystemSub"; var url = "/SystemCategory/GetOneSystemSub";
var send_data = { var send_data = {
guid: selected_system_sub_guid id: selected_system_sub_guid
} }
$.post(url, send_data, function (rel) { $.post(url, send_data, function (rel) {
@ -431,7 +443,8 @@
} }
else { else {
$("#system_main_name").html(selected_system_main_guid_top_name) $("#system_main_name").html(selected_system_main_guid_top_name)
$("#system_sub_name_modal").val(rel.data.full_name); $("#system_sub_name_modal").val(rel.data.system_key);
$("#system_sub_code_modal").val(rel.data.system_value);
$("#system-sub-modal").modal(); $("#system-sub-modal").modal();
} }
@ -458,7 +471,7 @@
if (result.value) { if (result.value) {
var url = "/SystemCategory/DeleteOneSystemSub"; var url = "/SystemCategory/DeleteOneSystemSub";
var send_data = { var send_data = {
Guid: selected_system_sub_guid id: selected_system_sub_guid
} }
$.post(url, send_data, function (rel) { $.post(url, send_data, function (rel) {
if (rel.code != "0000") { if (rel.code != "0000") {
@ -539,9 +552,10 @@
var url = "/SystemCategory/SaveSystemSub"; var url = "/SystemCategory/SaveSystemSub";
var send_data = { var send_data = {
Sub_system_guid: selected_system_sub_guid, id: selected_system_sub_guid,
Main_system_guid: selected_system_main_guid, system_parent_id: selected_system_main_guid,
Full_name: $('#system_sub_name_modal').val(), system_key: $('#system_sub_name_modal').val(),
system_value: $('#system_sub_code_modal').val()
} }
$.post(url, send_data, function (rel) { $.post(url, send_data, function (rel) {
@ -610,9 +624,9 @@
var uurl = "/SystemCategory/HaveSamePoints"; var uurl = "/SystemCategory/HaveSamePoints";
var ssend_data = { var ssend_data = {
sub_system_guid: selected_system_sub_guid, subId: selected_system_sub_guid,
id: selected_system_device_item_guid,
points: $('#device_sub_points_modal').val(), points: $('#device_sub_points_modal').val(),
device_item_guid: selected_system_device_item_guid,
} }
$.post(uurl, ssend_data, function (rel) { $.post(uurl, ssend_data, function (rel) {
if (rel.code != "0000") { if (rel.code != "0000") {
@ -633,8 +647,9 @@
else { else {
var url = "/SystemCategory/Savedevice_item"; var url = "/SystemCategory/Savedevice_item";
var send_data = { var send_data = {
device_item_guid: selected_system_device_item_guid, id: selected_system_device_item_guid,
sub_system_guid: selected_system_sub_guid, device_system_tag: selected_system_main_guid,
device_name_tag: selected_system_sub_guid,
full_name: $('#device_sub_name_modal').val(), full_name: $('#device_sub_name_modal').val(),
points: $('#device_sub_points_modal').val(), points: $('#device_sub_points_modal').val(),
unit: $('#device_sub_unit_modal').val(), unit: $('#device_sub_unit_modal').val(),
@ -686,7 +701,7 @@
var url = "/SystemCategory/GetOneDeviceItem"; var url = "/SystemCategory/GetOneDeviceItem";
var send_data = { var send_data = {
guid: selected_system_device_item_guid id: selected_system_device_item_guid
} }
$.post(url, send_data, function (rel) { $.post(url, send_data, function (rel) {
@ -759,7 +774,7 @@
} else { } else {
var url = "/SystemCategory/DeleteOneSystemSubDeviceItem"; var url = "/SystemCategory/DeleteOneSystemSubDeviceItem";
var send_data = { var send_data = {
guid: selected_system_device_item_guid id: selected_system_device_item_guid
} }
$.post(url, send_data, function (rel) { $.post(url, send_data, function (rel) {
if (rel.code != "0000") { if (rel.code != "0000") {

View File

@ -17,6 +17,7 @@
<th>序</th> <th>序</th>
<th>系統大類</th> <th>系統大類</th>
<th>系統小類名稱</th> <th>系統小類名稱</th>
<th>系統小類代號</th>
<th>建立時間</th> <th>建立時間</th>
<th>功能</th> <th>功能</th>
</tr> </tr>
@ -50,6 +51,7 @@
<th>是否顯示於昇位圖(僅可擇一顯示)</th> <th>是否顯示於昇位圖(僅可擇一顯示)</th>
<th>是否加入 - 設備燈號中的點位選單</th> <th>是否加入 - 設備燈號中的點位選單</th>
<th>是否為布林值</th> <th>是否為布林值</th>
<th>是否與N4同步</th>
<th>功能</th> <th>功能</th>
</tr> </tr>
</thead> </thead>
@ -84,6 +86,10 @@
<label class="form-label" for="system_sub_name_modal"><span class="text-danger">*</span>小類名稱</label> <label class="form-label" for="system_sub_name_modal"><span class="text-danger">*</span>小類名稱</label>
<input type="text" id="system_sub_name_modal" class="form-control" name="system_sub_name_modal"> <input type="text" id="system_sub_name_modal" class="form-control" name="system_sub_name_modal">
</div> </div>
<div class="form-group col-12">
<label class="form-label" for="system_sub_code_modal"><span class="text-danger">*</span>代號</label>
<input type="text" id="system_sub_code_modal" class="form-control" name="system_sub_code_modal">
</div>
</div> </div>
</form> </form>
</div> </div>

View File

@ -3,6 +3,11 @@ for details on configuring this project to bundle and minify static web assets.
/* Sticky footer styles /* Sticky footer styles
-------------------------------------------------- */ -------------------------------------------------- */
:root {
--bims-gray:#c3c3c3;
}
html { html {
font-size: 16px; font-size: 16px;
} }
@ -38,3 +43,7 @@ label.error {
.highcharts-credits { .highcharts-credits {
display: none; display: none;
} }
.t-gray {
color:var(--bims-gray) !important;
}

View File

@ -0,0 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
<path d="M30,1h40l29,29v40l-29,29h-40l-29-29v-40z" stroke="#000" fill="none"/>
<path d="M31,3h38l28,28v38l-28,28h-38l-28-28v-38z" fill="#a23"/>
<text x="50" y="68" font-size="48" fill="#FFF" text-anchor="middle"><![CDATA[410]]></text>
</svg>

After

Width:  |  Height:  |  Size: 313 B

View File

@ -5,9 +5,11 @@
<!--<add name="DBcs" <!--<add name="DBcs"
connectionString="Data Source=210.65.10.150;Initial Catalog=STSP;Persist Security Info=True;User ID=sa;Password=jsene2wsx#EDC" connectionString="Data Source=210.65.10.150;Initial Catalog=STSP;Persist Security Info=True;User ID=sa;Password=jsene2wsx#EDC"
providerName="System.Data.SqlClient" />--> providerName="System.Data.SqlClient" />-->
<add name="dbConStr" <!--<add name="dbConStr"
connectionString="Data Source=greencloud.fic.com.tw;Initial Catalog=taipei_dome;Persist Security Info=True;User ID=webuser;Password=FICadmin99" connectionString="Data Source=192.168.0.201:33306;Initial Catalog=bims_mitsubishi;Persist Security Info=True;User ID=bims;Password=mjmdev_BIMS2022"
providerName="System.Data.SqlClient" /> providerName="MySql.Data.MySqlClient" />-->
<add name="dbConStr" connectionString="server=192.168.0.201;user=bims;Database=bims_mitsubishi;Port=33306;password=mjmdev_BIMS2022;charset='utf8';pooling=true;sslmode=none;;Connection Timeout=6000" providerName="MySql.Data.MySqlClient" />
</connectionStrings> </connectionStrings>
</configuration> </configuration>

View File

@ -74,26 +74,37 @@ namespace tpDomeWinAPP.Models
public string Device_guid { get; set; } public string Device_guid { get; set; }
public byte Deleted { get; set; } public byte Deleted { get; set; }
public byte Status { get; set; } public byte Status { get; set; }
public string Building_guid { get; set; } public int Priority { get; set; }
public string Building_full_name { get; set; } public int Is_link { get; set; }
public string Main_system_guid { get; set; } //public string Building_guid { get; set; }
public string Main_system_full_name { get; set; } //public string Building_full_name { get; set; }
public string Sub_system_guid { get; set; } //public string Main_system_guid { get; set; }
public string Sub_system_full_name { get; set; } //public string Main_system_full_name { get; set; }
public string Floor_guid { get; set; } //public string Sub_system_guid { get; set; }
public string Floor_full_name { get; set; } //public string Sub_system_full_name { get; set; }
//public string Floor_guid { get; set; }
//public string Floor_full_name { get; set; }
public string Device_coordinate { get; set; } public string Device_coordinate { get; set; }
public string Device_full_name { get; set; } public string Full_name { get; set; }
public string Device_area_tag { get; set; }
public string Device_building_tag { get; set; }
public string Device_system_tag { get; set; }
public string Device_name_tag { get; set; }
public string Device_floor_tag { get; set; }
public string Device_master { get; set; }
public string Device_last_name { get; set; }
public string Device_serial_tag { get; set; }
public string Device_number { get; set; } //設備編號 public string Device_number { get; set; } //設備編號
public string Device_model { get; set; } //設備型號 public string Device_model { get; set; } //設備型號
public string Device_disaster_type_text { get; set; } //public string Device_disaster_type_text { get; set; }
public string Device_system_category_layer3 { get; set; } public string Device_system_category_layer3 { get; set; }
public string Device_image { get; set; } //public string Device_image { get; set; }
public string Device_image_url { get; set; } //public string Device_image_url { get; set; }
public string Device_close_color { get; set; } //public string Device_close_color { get; set; }
public string Device_normal_color { get; set; } //public string Device_normal_color { get; set; }
public string Device_error_color { get; set; } //public string Device_error_color { get; set; }
public string Device_flashing { get; set; } //public string Device_flashing { get; set; }
public string Device_ip { get; set; } public string Device_ip { get; set; }
public string Device_port { get; set; } public string Device_port { get; set; }
public List<DeviceDisaster> Device_disasters { get; set; } //防災類型 public List<DeviceDisaster> Device_disasters { get; set; } //防災類型
@ -289,6 +300,27 @@ namespace tpDomeWinAPP.Models
//public string result_value { get; set; } //public string result_value { get; set; }
} }
public class device_item8
{
public string name { get; set; }
public string value { get; set; }
public string tag_name { get; set; }
public string device_area_tag { get; set; }
public string device_building_tag { get; set; }
public string device_system_tag { get; set; }
public string device_name_tag { get; set; }
public string device_floor_tag { get; set; }
public string device_master_tag { get; set; }
public string device_last_name_tag { get; set; }
public string device_serial_tag { get; set; }
public string point_name { get; set; }
//public string result_value { get; set; }
}
public class dbDevice public class dbDevice
{ {
public string device_guid { get; set; } public string device_guid { get; set; }

View File

@ -9,11 +9,24 @@ namespace tpDomeWinAPP.Models
public int id { get; set; } public int id { get; set; }
public string db_tags { get; set; } public string db_tags { get; set; }
public string niagara_tags { get; set; } public string niagara_tags { get; set; }
public string building { get; set; } public string device_area_tag { get; set; }
public string system_code1 { get; set; } public string device_building_tag { get; set; }
public string floor { get; set; } public string device_system_tag { get; set; }
public string system_code2 { get; set; } public string device_name_tag { get; set; }
public string device_serial { get; set; } public string device_floor_tag { get; set; }
public string device_master_tag { get; set; }
public string device_last_name_tag { get; set; }
public string device_serial_tag { get; set; }
public string atDateTime { get; set; } public string atDateTime { get; set; }
public int is_used { get; set; }
}
public class NiagaraTagsForItem
{
public string device_area_tag { get; set; }
public string device_building_tag { get; set; }
public string device_system_tag { get; set; }
public string device_name_tag { get; set; }
public string device_point_name { get; set; }
} }
} }

View File

@ -251,7 +251,7 @@ namespace tpDomeWinAPP.Service
//1.2.更新欄位 device_number_old //1.2.更新欄位 device_number_old
sb.Append($@" update device set device_system_tag_old = b.tagName sb.Append($@" update device set device_system_tag_old = b.tagName
from (select device_number, device_number_old, serial, tagName from (select device_number, device_number_old, serial, tagName
from dbo.device a CROSS APPLY [Func_StringSplit](a.device_number, '_') from device a CROSS APPLY [Func_StringSplit](a.device_number, '_')
where serial = 2 and device_system_tag_old is null)b where serial = 2 and device_system_tag_old is null)b
where device.device_number_old = b.device_number_old and device_system_tag_old is null"); where device.device_number_old = b.device_number_old and device_system_tag_old is null");
conn.Execute(sb.ToString()); conn.Execute(sb.ToString());
@ -307,7 +307,7 @@ namespace tpDomeWinAPP.Service
#region update niagara_tags #region update niagara_tags
sb.Clear(); sb.Clear();
sb.Append($@"update import_dbTag_niagaraTag set niagaraTag = b.niagara_tags sb.Append($@"update import_dbTag_niagaraTag set niagaraTag = b.niagara_tags
from [dbo].[importTag] b from [dbo].[import_niagara_tag] b
where import_dbTag_niagaraTag.device_number = b.niagara_tags "); where import_dbTag_niagaraTag.device_number = b.niagara_tags ");
conn.Execute(sb.ToString()); conn.Execute(sb.ToString());
#endregion #endregion

View File

@ -4,12 +4,16 @@ using System.Text;
using System.Configuration; using System.Configuration;
using tpDomeWinAPP.Models; using tpDomeWinAPP.Models;
using System.Data; using System.Data;
using System.Data.SqlClient; //using System.Data.SqlClient;
using MySql.Data.MySqlClient; using MySql.Data.MySqlClient;
using Repository.Helper; using Repository.Helper;
using Repository.BackendRepository.Interface; using Repository.BackendRepository.Interface;
using Dapper; using Dapper;
using System.Linq; using System.Linq;
using NPOI.SS.Formula.Functions;
using Microsoft.Extensions.Primitives;
using MySqlX.XDevAPI.Relational;
using static NPOI.HSSF.Util.HSSFColor;
namespace tpDomeWinAPP.Service namespace tpDomeWinAPP.Service
{ {
@ -22,62 +26,81 @@ namespace tpDomeWinAPP.Service
private readonly IBackendRepository backendRepository; private readonly IBackendRepository backendRepository;
public bool InsertNiagaraTagList(List<device_value2> dt, string building ) public bool ToInsertNiagaraTagList(List<device_value2> dt, string building )
{ {
bool result = false; bool result = false;
//tag
InsertNiagaraTagList(dt, building);
insertItemFromNiagara(dt, building);
deviceComparison();
deviceItemComparison();
insertBuildingMenu();
insertSubSystemFloor();
return result;
}
protected void InsertNiagaraTagList(List<device_value2> dt, string building)
{
var ds2 = dt.GroupBy(x => new var ds2 = dt.GroupBy(x => new
{ {
tag_name2 = x.tag_name tag_name2 = x.tag_name
}).Select( x => new device_value2 { }).Select(x => new device_value2
{
tag_name = x.Key.tag_name2 tag_name = x.Key.tag_name2
}); });
using (SqlConnection conn = new SqlConnection(Connection1)) using (MySqlConnection conn = new MySqlConnection(Connection1))
{ {
//CONCAT('{baseURL}', '{deviceKindFilePath}', dk.device_image) AS device_image_url,
conn.Open(); conn.Open();
#region Create table #region Create table
string ss = @"IF (not EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'importTag')) string ss = @" CREATE TABLE IF NOT EXISTS `import_niagara_tag` (
BEGIN `id` int(11) NOT NULL AUTO_INCREMENT,
`db_tags` varchar(50) DEFAULT NULL,
CREATE TABLE [dbo].[importTag]( `niagara_tags` varchar(50) DEFAULT NULL,
[id] [int] IDENTITY(1,1) NOT NULL, `device_area_tag` varchar(50) DEFAULT NULL,
[db_tags] [varchar](50) NULL, `device_building_tag` varchar(50) DEFAULT NULL,
[niagara_tags] [varchar](50) NULL, `device_system_tag` varchar(50) DEFAULT NULL,
[building] [varchar](10) NULL, `device_name_tag` varchar(50) DEFAULT NULL,
[system_code1] [varchar](10) NULL, `device_floor_tag` varchar(50) DEFAULT NULL,
[floor] [varchar](10) NULL, `device_master_tag` varchar(50) DEFAULT NULL,
[system_code2] [varchar](10) NULL, `device_last_name_tag` varchar(50) DEFAULT NULL,
[device_serial] [varchar](10) NULL, `device_serial_tag` varchar(50) DEFAULT NULL,
[atDateTime] [smalldatetime] NULL, `atDateTime` datetime(1) DEFAULT NULL,
CONSTRAINT [PK_importTag] PRIMARY KEY CLUSTERED `is_used` smallint(1) DEFAULT 0,
( PRIMARY KEY (`id`)
[id] ASC ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;";
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY];
END";
conn.Execute(ss.ToString()); conn.Execute(ss.ToString());
ss = "delete from importTag where building = '" + building + "'"; ss = "delete from import_niagara_tag where device_building_tag = '" + building + "'";
conn.Execute(ss.ToString()); conn.Execute(ss.ToString());
#endregion #endregion
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
int i = 0;
foreach (var row in ds2) foreach (var row in ds2)
{ {
if (string.IsNullOrEmpty(row.tag_name)) continue; if (string.IsNullOrEmpty(row.tag_name)) continue;
sb.Append($@" insert importTag(niagara_tags, building, atDateTime) values('" + string[] arrTag = row.tag_name.Split('_');
sb.Append($@" insert import_niagara_tag(niagara_tags, device_area_tag, device_building_tag, device_system_tag,
device_name_tag, device_floor_tag, device_master_tag, device_last_name_tag, device_serial_tag, atDateTime) values('" +
row.tag_name + "', '" + row.tag_name + "', '" +
building + "', getDate());"); arrTag[0] + "', '" +
i++; arrTag[1] + "', '" +
arrTag[2] + "', '" +
arrTag[3] + "', '" +
arrTag[4] + "', '" +
arrTag[5] + "', '" +
arrTag[6] + "', '" +
arrTag[7] + "', " +
"now());");
}
try try
{ {
if (i >= 100) if (sb.Length > 0)
{ {
conn.Execute(sb.ToString()); conn.Execute(sb.ToString());
sb.Clear(); sb.Clear();
i = 0;
} }
} }
catch (Exception ex) catch (Exception ex)
@ -85,55 +108,321 @@ namespace tpDomeWinAPP.Service
throw ex; throw ex;
} }
} }
if (sb.Length > 0)
{
conn.Execute(sb.ToString());
} }
#region update 4 tag protected void insertItemFromNiagara(List<device_value2> dt, string building)
sb.Clear(); {
sb.Append($@"update importTag set importTag.system_code1 = b.tagName using (MySqlConnection conn = new MySqlConnection(Connection1))
from ( {
select niagara_tags, building, serial, tagName conn.Open();
from dbo.importTag a CROSS APPLY [Func_StringSplit](a.niagara_tags, '_') #region create table
where serial = 2 and building = '{building}' string ss = @"CREATE TABLE IF NOT EXISTS `import_niagara_item` (
) b `id` int(11) NOT NULL AUTO_INCREMENT,
where importTag.niagara_tags = b.niagara_tags and importTag.building = '{building}'; `device_area_tag` varchar(50) DEFAULT NULL,
`device_building_tag` varchar(50) DEFAULT NULL,
`device_system_tag` varchar(50) DEFAULT NULL,
`device_name_tag` varchar(50) DEFAULT NULL,
`device_point_name` varchar(50) DEFAULT NULL,
`check_status` varchar(50) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=59 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;";
conn.Execute(ss.ToString());
ss = "delete from import_niagara_item where device_building_tag = '" + building + "'";
conn.Execute(ss.ToString());
#endregion
update importTag set importTag.floor = b.tagName List<device_item8> dt_item = new List<device_item8>();
from (
select niagara_tags, building, serial, tagName
from dbo.importTag a CROSS APPLY [Func_StringSplit](a.niagara_tags, '_')
where serial = 3 and building = '{building}'
) b
where importTag.niagara_tags = b.niagara_tags and importTag.building = '{building}';
foreach (var row in dt)
{
if (string.IsNullOrEmpty(row.tag_name)) continue;
string[] arrTag = row.tag_name.Split('_');
update importTag set importTag.system_code2 = b.tagName #region for item
from ( device_item8 row_item = new device_item8();
select niagara_tags, building, serial, tagName row_item.tag_name = row.tag_name;
from dbo.importTag a CROSS APPLY [Func_StringSplit](a.niagara_tags, '_') row_item.device_area_tag = arrTag[0];
where serial = 4 and building = '{building}' row_item.device_building_tag = arrTag[1];
) b row_item.device_system_tag = arrTag[2];
where importTag.niagara_tags = b.niagara_tags and importTag.building = '{building}'; row_item.device_name_tag = arrTag[3];
row_item.device_floor_tag = arrTag[4];
update importTag set importTag.device_serial = b.tagName row_item.device_master_tag = arrTag[5];
from ( row_item.device_last_name_tag = arrTag[6];
select niagara_tags, building, serial, tagName row_item.device_serial_tag = arrTag[7];
from dbo.importTag a CROSS APPLY [Func_StringSplit](a.niagara_tags, '_') row_item.point_name = row.point_name;
where serial = 5 and building = '{building}' dt_item.Add(row_item);
) b
where importTag.niagara_tags = b.niagara_tags and importTag.building = '{building}';
update importTag set db_tags = b.device_number
from dbo.device b
where niagara_tags = b.device_number and importTag.building = '{building}'
");
conn.Execute(sb.ToString());
#endregion #endregion
} }
return result; //device_item
var ds2_item = dt_item.GroupBy(x => new
{
device_area_tag2 = x.device_area_tag,
device_building_tag2 = x.device_building_tag,
device_system_tag2 = x.device_system_tag,
device_name_tag2 = x.device_name_tag,
point_name2 = x.point_name
}).Select(x => new device_item8
{
device_area_tag = x.Key.device_area_tag2,
device_building_tag = x.Key.device_building_tag2,
device_system_tag = x.Key.device_system_tag2,
device_name_tag = x.Key.device_name_tag2,
point_name = x.Key.point_name2
});
StringBuilder sb = new StringBuilder();
foreach (var row2 in ds2_item)
{
sb.Append($@" insert import_niagara_item(device_area_tag, device_building_tag, device_system_tag, device_name_tag, device_point_name)
values('" +
row2.device_area_tag + "', '" +
row2.device_building_tag + "', '" +
row2.device_system_tag + "', '" +
row2.device_name_tag + "', '" +
row2.point_name + "'" +
");");
}
try
{
if (sb.Length > 0)
{
conn.Execute(sb.ToString());
sb.Clear();
}
}
catch (Exception ex)
{
throw ex;
}
}
}
/// <summary>
/// 比對device和import_Niagara_tag並更新至device(資料表)
/// </summary>
public void deviceComparison()
{
using (MySqlConnection conn = new MySqlConnection(Connection1))
{
List<NiagaraTags> result;
conn.Open();
StringBuilder sb = new StringBuilder();
sb.Append($@" SELECT m.*
FROM import_niagara_tag m
LEFT JOIN device d
ON m.niagara_tags = d.device_number
WHERE d.device_number IS NULL");
result = conn.Query<NiagaraTags>(sb.ToString()).ToList<NiagaraTags>();
sb.Clear();
//新增至device, is_link = 1
if (result.Count > 0)
{
foreach (var data in result)
{
sb.Append($@" insert device(device_guid, deleted, status, priority, is_link, device_area_tag,
device_building_tag, device_system_tag, device_name_tag, device_floor_tag, device_master,
device_last_name, device_serial_tag, device_number, device_system_category_layer3, created_at, updated_at)
values(uuid(), 0, 1, 0, 1, '" +
data.device_area_tag + "', '" +
data.device_building_tag + "', '" +
data.device_system_tag + "', '" +
data.device_name_tag + "', '" +
data.device_floor_tag + "', '" +
data.device_master_tag + "', '" +
data.device_last_name_tag + "', '" +
data.device_serial_tag + "', '" +
data.niagara_tags + "', '" +
data.device_system_tag + "', now(), now() );");
}
if(sb.Length > 0)
{
conn.Execute(sb.ToString());
sb.Clear();
}
}
//device有niagara沒有is_link 更新成 0
sb.Append($@" SET SQL_SAFE_UPDATES = 0;
UPDATE device d LEFT JOIN import_niagara_tag m ON d.device_number = m.niagara_tags
SET d.is_link = 0
WHERE m.niagara_tags IS NULL");
conn.Execute(sb.ToString());
}
}
/// <summary>
/// 比對device_item和import_Niagara_item並更新至device_item(資料表)
/// </summary>
public void deviceItemComparison()
{
using (MySqlConnection conn = new MySqlConnection(Connection1))
{
List<NiagaraTagsForItem> result;
conn.Open();
StringBuilder sb = new StringBuilder();
sb.Append($@" SELECT m.*
FROM import_niagara_item m
LEFT JOIN device_item d
ON m.device_system_tag = d.device_system_tag and m.device_name_tag = d.device_name_tag and m.device_point_name = d.points
WHERE d.points IS NULL");
result = conn.Query<NiagaraTagsForItem>(sb.ToString()).ToList<NiagaraTagsForItem>();
sb.Clear();
//新增至device, is_link = 1
if (result.Count > 0)
{
foreach (var data in result)
{
var isControll = 0;
var isBool = 0;
if (data.device_point_name == "ER" || data.device_point_name == "AL" || data.device_point_name == "ST")
{
isControll = 1;
}
if (data.device_point_name == "ER" || data.device_point_name == "ST")
{
isBool = 1;
}
sb.Append($@"insert device_item(deleted, points, is_show, is_show_riserDiagram, is_controll, is_bool, is_link,
device_system_tag, device_name_tag, created_at, updated_at)
VALUES (0, '" +
data.device_point_name + "', 1, 0, " +
isControll + "," +
isBool + ", 1, '" +
data.device_system_tag + "', '" +
data.device_name_tag + "', " +
"now(), now());");
}
if (sb.Length > 0)
{
conn.Execute(sb.ToString());
sb.Clear();
}
}
//device有niagara沒有is_link 更新成 0
sb.Append($@" SET SQL_SAFE_UPDATES = 0;
UPDATE device_item d LEFT JOIN import_niagara_item m
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 = 0
WHERE m.device_point_name IS NULL");
conn.Execute(sb.ToString());
}
}
public void insertBuildingMenu()
{
using (MySqlConnection conn = new MySqlConnection(Connection1))
{
conn.Open();
List<NiagaraTags> result;
StringBuilder sb = new StringBuilder();
#region comparison building_menu and import_niagara_tag
sb.Append($@" select a.* from (
select device_building_tag, device_system_tag, device_name_tag
from import_niagara_tag
group by device_building_tag, device_system_tag, device_name_tag
) AS a
LEFT JOIN building_menu b
ON a.device_building_tag = b.device_building_tag and a.device_system_tag = b.device_system_tag and a.device_name_tag = b.sub_system_tag
WHERE b.device_building_tag IS NULL");
result = conn.Query<NiagaraTags>(sb.ToString()).ToList<NiagaraTags>();
#endregion
sb.Clear();
if (result.Count > 0)
{
foreach (var data in result) {
#region insert building_menu
sb.Append(@"insert building_menu(building_tag, main_system_tag, sub_system_tag, device_building_tag, device_system_tag,
is_link, created_by, created_at, updated_by, updated_at)
VALUES ('" + data.device_building_tag + "', '" +
data.device_system_tag + "', '" +
data.device_name_tag + "', '" +
data.device_building_tag + "', '" +
data.device_system_tag + "', " +
"1, 'B43E3CA7-96DD-4FC7-B6E6-974ACC3B0878', now(), 'B43E3CA7-96DD-4FC7-B6E6-974ACC3B0878', now() );");
#endregion
}
if (sb.Length > 0)
{
conn.Execute(sb.ToString());
sb.Clear();
}
}
//building_menu有import_niagara_tag沒有is_link 更新成 0
sb.Append($@" SET SQL_SAFE_UPDATES = 0;
UPDATE building_menu b LEFT JOIN (
select device_building_tag, device_system_tag, device_name_tag
from import_niagara_tag
group by device_building_tag, device_system_tag, device_name_tag
) AS a ON b.device_building_tag = a.device_building_tag
and a.device_system_tag = b.device_system_tag and a.device_name_tag = b.sub_system_tag
SET b.is_link = 0
WHERE b.device_building_tag IS NULL");
conn.Execute(sb.ToString());
}
}
public void insertSubSystemFloor()
{
using (MySqlConnection conn = new MySqlConnection(Connection1))
{
conn.Open();
List<NiagaraTags> result;
StringBuilder sb = new StringBuilder();
#region comparison sub_system_floor and import_niagara_tag
sb.Append($@" select a.* from (
select device_building_tag, device_system_tag, device_name_tag, device_floor_tag
from import_niagara_tag
group by device_building_tag, device_system_tag, device_name_tag, device_floor_tag
) AS a
LEFT JOIN sub_system_floor b
ON a.device_building_tag = b.building_tag and a.device_system_tag = b.main_system_tag and a.device_name_tag = b.sub_system_tag and a.device_floor_tag = b.floor_tag
WHERE b.building_tag IS NULL");
result = conn.Query<NiagaraTags>(sb.ToString()).ToList<NiagaraTags>();
#endregion
sb.Clear();
if(result.Count > 0)
{
foreach(var data in result)
{
#region insert building_menu
sb.Append(@"insert sub_system_floor(building_tag, main_system_tag, sub_system_tag, floor_tag,
is_link, created_by, created_at, updated_by, updated_at)
VALUES ('" +
data.device_building_tag + "', '" +
data.device_system_tag + "', '" +
data.device_name_tag + "', '" +
data.device_floor_tag + "', " +
"1, 'B43E3CA7-96DD-4FC7-B6E6-974ACC3B0878', now(), 'B43E3CA7-96DD-4FC7-B6E6-974ACC3B0878', now());");
#endregion
}
if (sb.Length > 0)
{
conn.Execute(sb.ToString());
sb.Clear();
}
}
//building_menu有import_niagara_tag沒有is_link 更新成 0
sb.Append($@" SET SQL_SAFE_UPDATES = 0;
UPDATE sub_system_floor b LEFT JOIN (
select device_building_tag, device_system_tag, device_name_tag, device_floor_tag
from import_niagara_tag
group by device_building_tag, device_system_tag, device_name_tag, device_floor_tag
) AS a ON b.building_tag = a.device_building_tag
and b.main_system_tag = a.device_system_tag and b.sub_system_tag = a.device_name_tag and b.floor_tag = a.device_floor_tag
SET b.is_link = 0
WHERE b.building_tag IS NULL");
conn.Execute(sb.ToString());
}
} }
public bool InsertDbTagList(List<device_value2> dt, string building) public bool InsertDbTagList(List<device_value2> dt, string building)
@ -147,7 +436,7 @@ namespace tpDomeWinAPP.Service
tag_name = x.Key.tag_name2 tag_name = x.Key.tag_name2
}); });
using (SqlConnection conn = new SqlConnection(Connection1)) using (MySqlConnection conn = new MySqlConnection(Connection1))
{ {
//CONCAT('{baseURL}', '{deviceKindFilePath}', dk.device_image) AS device_image_url, //CONCAT('{baseURL}', '{deviceKindFilePath}', dk.device_image) AS device_image_url,
conn.Open(); conn.Open();
@ -176,7 +465,7 @@ namespace tpDomeWinAPP.Service
) ON [PRIMARY]; ) ON [PRIMARY];
END"; END";
conn.Execute(ss.ToString()); conn.Execute(ss.ToString());
//ss = "delete from importTag where building = '" + building + "'"; //ss = "delete from import_niagara_tag where building = '" + building + "'";
//conn.Execute(ss.ToString()); //conn.Execute(ss.ToString());
#endregion #endregion
@ -192,7 +481,7 @@ namespace tpDomeWinAPP.Service
#region update niagara_tags #region update niagara_tags
sb.Clear(); sb.Clear();
sb.Append($@"update import_dbTag_niagaraTag set niagaraTag = b.niagara_tags sb.Append($@"update import_dbTag_niagaraTag set niagaraTag = b.niagara_tags
from [dbo].[importTag] b from [dbo].[import_niagara_tag] b
where import_dbTag_niagaraTag.device_number = b.niagara_tags "); where import_dbTag_niagaraTag.device_number = b.niagara_tags ");
conn.Execute(sb.ToString()); conn.Execute(sb.ToString());
#endregion #endregion
@ -205,12 +494,12 @@ namespace tpDomeWinAPP.Service
public List<NiagaraTags> GetNiagaraTags(string building) public List<NiagaraTags> GetNiagaraTags(string building)
{ {
List<NiagaraTags> result; List<NiagaraTags> result;
using (SqlConnection conn = new SqlConnection(Connection1)) using (MySqlConnection conn = new MySqlConnection(Connection1))
{ {
//CONCAT('{baseURL}', '{deviceKindFilePath}', dk.device_image) AS device_image_url, //CONCAT('{baseURL}', '{deviceKindFilePath}', dk.device_image) AS device_image_url,
conn.Open(); conn.Open();
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.Append($@" select * from importTag where building = '{building}'"); sb.Append($@" select * from import_niagara_tag where device_building_tag = '{building}'");
result = conn.Query<NiagaraTags>(sb.ToString()).ToList<NiagaraTags>(); result = conn.Query<NiagaraTags>(sb.ToString()).ToList<NiagaraTags>();
} }
return result; return result;
@ -219,7 +508,7 @@ namespace tpDomeWinAPP.Service
public List<NiagaraTags> SearchNiagaraTags(string sql) public List<NiagaraTags> SearchNiagaraTags(string sql)
{ {
List<NiagaraTags> result; List<NiagaraTags> result;
using (SqlConnection conn = new SqlConnection(Connection1)) using (MySqlConnection conn = new MySqlConnection(Connection1))
{ {
//CONCAT('{baseURL}', '{deviceKindFilePath}', dk.device_image) AS device_image_url, //CONCAT('{baseURL}', '{deviceKindFilePath}', dk.device_image) AS device_image_url,
conn.Open(); conn.Open();
@ -233,7 +522,7 @@ namespace tpDomeWinAPP.Service
public List<dbDevice> SearchDBTags(string building) public List<dbDevice> SearchDBTags(string building)
{ {
List<dbDevice> result; List<dbDevice> result;
using (SqlConnection conn = new SqlConnection(Connection1)) using (MySqlConnection conn = new MySqlConnection(Connection1))
{ {
//CONCAT('{baseURL}', '{deviceKindFilePath}', dk.device_image) AS device_image_url, //CONCAT('{baseURL}', '{deviceKindFilePath}', dk.device_image) AS device_image_url,
conn.Open(); conn.Open();
@ -254,7 +543,7 @@ namespace tpDomeWinAPP.Service
public List<dbDevice> filterDBTags(string sql) public List<dbDevice> filterDBTags(string sql)
{ {
List<dbDevice> result; List<dbDevice> result;
using (SqlConnection conn = new SqlConnection(Connection1)) using (MySqlConnection conn = new MySqlConnection(Connection1))
{ {
//CONCAT('{baseURL}', '{deviceKindFilePath}', dk.device_image) AS device_image_url, //CONCAT('{baseURL}', '{deviceKindFilePath}', dk.device_image) AS device_image_url,
conn.Open(); conn.Open();
@ -273,7 +562,7 @@ namespace tpDomeWinAPP.Service
public int updateNiagaraTag_forDBTags(string bilding) public int updateNiagaraTag_forDBTags(string bilding)
{ {
int i = -1; int i = -1;
using (SqlConnection conn = new SqlConnection(Connection1)) using (MySqlConnection conn = new MySqlConnection(Connection1))
{ {
//CONCAT('{baseURL}', '{deviceKindFilePath}', dk.device_image) AS device_image_url, //CONCAT('{baseURL}', '{deviceKindFilePath}', dk.device_image) AS device_image_url,
conn.Open(); conn.Open();
@ -293,7 +582,7 @@ namespace tpDomeWinAPP.Service
#endregion #endregion
sb.Append($@"update import_dbTag_niagaraTag set niagaraTag = b.niagara_tags sb.Append($@"update import_dbTag_niagaraTag set niagaraTag = b.niagara_tags
from [dbo].[importTag] b from [dbo].[import_niagara_tag] b
where import_dbTag_niagaraTag.device_number = b.niagara_tags where import_dbTag_niagaraTag.device_number = b.niagara_tags
and import_dbTag_niagaraTag.device_building_tag = '{bilding}'"); and import_dbTag_niagaraTag.device_building_tag = '{bilding}'");
i = conn.Execute(sb.ToString()); i = conn.Execute(sb.ToString());

View File

@ -144,28 +144,32 @@ namespace tpDomeWinAPP.Service
public List<device_value2> obixQuery(string urlString, string bql) public List<device_value2> obixQuery(string urlString, string bql)
{ {
List<device_value2> result = new List<device_value2>(); List<device_value2> result = new List<device_value2>();
String username = "stanGG"; String username = "obixUser";
String password = "St12345678"; String password = "Admin123456";
String encoded = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(username + ":" + password)); String encoded = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(username + ":" + password));
String API_Url = urlString; String API_Url = urlString;
HttpWebRequest Postrequest = (HttpWebRequest)WebRequest.Create(API_Url); //HttpWebRequest Postrequest = (HttpWebRequest)WebRequest.Create(API_Url);
Postrequest.Method = "POST"; //Postrequest.Method = "POST";
Postrequest.Headers.Add("Authorization", "Basic " + encoded); //Postrequest.Headers.Add("Authorization", "Basic " + encoded);
Postrequest.PreAuthenticate = true; //Postrequest.PreAuthenticate = true;
using (var streamWriter = new StreamWriter(Postrequest.GetRequestStream())) //using (var streamWriter = new StreamWriter(Postrequest.GetRequestStream()))
{ //{
string json = "<str val='" + bql + "'/>"; // string json = "<str val='" + bql + "'/>";
streamWriter.Write(json); // streamWriter.Write(json);
} //}
HttpWebResponse response = (HttpWebResponse)Postrequest.GetResponse(); //HttpWebResponse response = (HttpWebResponse)Postrequest.GetResponse();
var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd(); //var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
XmlDocument xmlDoc = new XmlDocument(); XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(responseString); //xmlDoc.LoadXml(responseString);
xmlDoc.Load("N4.xml");
//xmlDoc.Save("N4.xml");

View File

@ -34,7 +34,7 @@ namespace tpDomeWinAPP
this.rbM = new System.Windows.Forms.RadioButton(); this.rbM = new System.Windows.Forms.RadioButton();
this.btLoad = new System.Windows.Forms.Button(); this.btLoad = new System.Windows.Forms.Button();
this.rbDome2 = new System.Windows.Forms.RadioButton(); this.rbDome2 = new System.Windows.Forms.RadioButton();
this.rbH = new System.Windows.Forms.RadioButton(); this.rbB1 = new System.Windows.Forms.RadioButton();
this.rbCinema = new System.Windows.Forms.RadioButton(); this.rbCinema = new System.Windows.Forms.RadioButton();
this.rbOffice = new System.Windows.Forms.RadioButton(); this.rbOffice = new System.Windows.Forms.RadioButton();
this.tabControl1 = new System.Windows.Forms.TabControl(); this.tabControl1 = new System.Windows.Forms.TabControl();
@ -64,11 +64,11 @@ namespace tpDomeWinAPP
this.dataGridView2 = new System.Windows.Forms.DataGridView(); this.dataGridView2 = new System.Windows.Forms.DataGridView();
this.tabPage3 = new System.Windows.Forms.TabPage(); this.tabPage3 = new System.Windows.Forms.TabPage();
this.tabPage4 = new System.Windows.Forms.TabPage(); this.tabPage4 = new System.Windows.Forms.TabPage();
this.tabPage5 = new System.Windows.Forms.TabPage();
this.splitContainer5 = new System.Windows.Forms.SplitContainer(); this.splitContainer5 = new System.Windows.Forms.SplitContainer();
this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel(); this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label();
this.tabPage5 = new System.Windows.Forms.TabPage();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout();
@ -100,6 +100,7 @@ namespace tpDomeWinAPP
this.splitContainer1.Cursor = System.Windows.Forms.Cursors.VSplit; this.splitContainer1.Cursor = System.Windows.Forms.Cursors.VSplit;
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer1.Location = new System.Drawing.Point(0, 0); this.splitContainer1.Location = new System.Drawing.Point(0, 0);
this.splitContainer1.Margin = new System.Windows.Forms.Padding(2);
this.splitContainer1.Name = "splitContainer1"; this.splitContainer1.Name = "splitContainer1";
// //
// splitContainer1.Panel1 // splitContainer1.Panel1
@ -109,7 +110,7 @@ namespace tpDomeWinAPP
this.splitContainer1.Panel1.Controls.Add(this.rbM); this.splitContainer1.Panel1.Controls.Add(this.rbM);
this.splitContainer1.Panel1.Controls.Add(this.btLoad); this.splitContainer1.Panel1.Controls.Add(this.btLoad);
this.splitContainer1.Panel1.Controls.Add(this.rbDome2); this.splitContainer1.Panel1.Controls.Add(this.rbDome2);
this.splitContainer1.Panel1.Controls.Add(this.rbH); this.splitContainer1.Panel1.Controls.Add(this.rbB1);
this.splitContainer1.Panel1.Controls.Add(this.rbCinema); this.splitContainer1.Panel1.Controls.Add(this.rbCinema);
this.splitContainer1.Panel1.Controls.Add(this.rbOffice); this.splitContainer1.Panel1.Controls.Add(this.rbOffice);
this.splitContainer1.Panel1.Cursor = System.Windows.Forms.Cursors.Arrow; this.splitContainer1.Panel1.Cursor = System.Windows.Forms.Cursors.Arrow;
@ -117,8 +118,9 @@ namespace tpDomeWinAPP
// splitContainer1.Panel2 // splitContainer1.Panel2
// //
this.splitContainer1.Panel2.Controls.Add(this.tabControl1); this.splitContainer1.Panel2.Controls.Add(this.tabControl1);
this.splitContainer1.Size = new System.Drawing.Size(1502, 764); this.splitContainer1.Size = new System.Drawing.Size(1168, 603);
this.splitContainer1.SplitterDistance = 225; this.splitContainer1.SplitterDistance = 174;
this.splitContainer1.SplitterWidth = 3;
this.splitContainer1.TabIndex = 0; this.splitContainer1.TabIndex = 0;
// //
// rbDome3 // rbDome3
@ -126,9 +128,10 @@ namespace tpDomeWinAPP
this.rbDome3.AutoSize = true; this.rbDome3.AutoSize = true;
this.rbDome3.Cursor = System.Windows.Forms.Cursors.Hand; this.rbDome3.Cursor = System.Windows.Forms.Cursors.Hand;
this.rbDome3.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); this.rbDome3.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.rbDome3.Location = new System.Drawing.Point(20, 248); this.rbDome3.Location = new System.Drawing.Point(16, 196);
this.rbDome3.Margin = new System.Windows.Forms.Padding(2);
this.rbDome3.Name = "rbDome3"; this.rbDome3.Name = "rbDome3";
this.rbDome3.Size = new System.Drawing.Size(125, 29); this.rbDome3.Size = new System.Drawing.Size(100, 24);
this.rbDome3.TabIndex = 5; this.rbDome3.TabIndex = 5;
this.rbDome3.TabStop = true; this.rbDome3.TabStop = true;
this.rbDome3.Tag = "D3"; this.rbDome3.Tag = "D3";
@ -141,9 +144,10 @@ namespace tpDomeWinAPP
this.rbM.AutoSize = true; this.rbM.AutoSize = true;
this.rbM.Cursor = System.Windows.Forms.Cursors.Hand; this.rbM.Cursor = System.Windows.Forms.Cursors.Hand;
this.rbM.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); this.rbM.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.rbM.Location = new System.Drawing.Point(20, 288); this.rbM.Location = new System.Drawing.Point(16, 227);
this.rbM.Margin = new System.Windows.Forms.Padding(2);
this.rbM.Name = "rbM"; this.rbM.Name = "rbM";
this.rbM.Size = new System.Drawing.Size(118, 29); this.rbM.Size = new System.Drawing.Size(95, 24);
this.rbM.TabIndex = 4; this.rbM.TabIndex = 4;
this.rbM.TabStop = true; this.rbM.TabStop = true;
this.rbM.Tag = "M"; this.rbM.Tag = "M";
@ -153,9 +157,10 @@ namespace tpDomeWinAPP
// //
// btLoad // btLoad
// //
this.btLoad.Location = new System.Drawing.Point(41, 32); this.btLoad.Location = new System.Drawing.Point(32, 25);
this.btLoad.Margin = new System.Windows.Forms.Padding(2);
this.btLoad.Name = "btLoad"; this.btLoad.Name = "btLoad";
this.btLoad.Size = new System.Drawing.Size(94, 29); this.btLoad.Size = new System.Drawing.Size(73, 23);
this.btLoad.TabIndex = 0; this.btLoad.TabIndex = 0;
this.btLoad.Text = "LoadData"; this.btLoad.Text = "LoadData";
this.btLoad.UseVisualStyleBackColor = true; this.btLoad.UseVisualStyleBackColor = true;
@ -166,9 +171,10 @@ namespace tpDomeWinAPP
this.rbDome2.AutoSize = true; this.rbDome2.AutoSize = true;
this.rbDome2.Cursor = System.Windows.Forms.Cursors.Hand; this.rbDome2.Cursor = System.Windows.Forms.Cursors.Hand;
this.rbDome2.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); this.rbDome2.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.rbDome2.Location = new System.Drawing.Point(20, 208); this.rbDome2.Location = new System.Drawing.Point(16, 164);
this.rbDome2.Margin = new System.Windows.Forms.Padding(2);
this.rbDome2.Name = "rbDome2"; this.rbDome2.Name = "rbDome2";
this.rbDome2.Size = new System.Drawing.Size(125, 29); this.rbDome2.Size = new System.Drawing.Size(100, 24);
this.rbDome2.TabIndex = 3; this.rbDome2.TabIndex = 3;
this.rbDome2.TabStop = true; this.rbDome2.TabStop = true;
this.rbDome2.Tag = "D2"; this.rbDome2.Tag = "D2";
@ -176,29 +182,31 @@ namespace tpDomeWinAPP
this.rbDome2.UseVisualStyleBackColor = true; this.rbDome2.UseVisualStyleBackColor = true;
this.rbDome2.CheckedChanged += new System.EventHandler(this.rbM_CheckedChanged); this.rbDome2.CheckedChanged += new System.EventHandler(this.rbM_CheckedChanged);
// //
// rbH // rbB1
// //
this.rbH.AutoSize = true; this.rbB1.AutoSize = true;
this.rbH.Cursor = System.Windows.Forms.Cursors.Hand; this.rbB1.Cursor = System.Windows.Forms.Cursors.Hand;
this.rbH.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); this.rbB1.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.rbH.Location = new System.Drawing.Point(20, 88); this.rbB1.Location = new System.Drawing.Point(16, 69);
this.rbH.Name = "rbH"; this.rbB1.Margin = new System.Windows.Forms.Padding(2);
this.rbH.Size = new System.Drawing.Size(129, 29); this.rbB1.Name = "rbB1";
this.rbH.TabIndex = 0; this.rbB1.Size = new System.Drawing.Size(78, 24);
this.rbH.TabStop = true; this.rbB1.TabIndex = 0;
this.rbH.Tag = "H"; this.rbB1.TabStop = true;
this.rbH.Text = "旅館 Hotel"; this.rbB1.Tag = "B1";
this.rbH.UseVisualStyleBackColor = true; this.rbB1.Text = "三菱B1";
this.rbH.CheckedChanged += new System.EventHandler(this.rbM_CheckedChanged); this.rbB1.UseVisualStyleBackColor = true;
this.rbB1.CheckedChanged += new System.EventHandler(this.rbM_CheckedChanged);
// //
// rbCinema // rbCinema
// //
this.rbCinema.AutoSize = true; this.rbCinema.AutoSize = true;
this.rbCinema.Cursor = System.Windows.Forms.Cursors.Hand; this.rbCinema.Cursor = System.Windows.Forms.Cursors.Hand;
this.rbCinema.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); this.rbCinema.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.rbCinema.Location = new System.Drawing.Point(20, 168); this.rbCinema.Location = new System.Drawing.Point(16, 133);
this.rbCinema.Margin = new System.Windows.Forms.Padding(2);
this.rbCinema.Name = "rbCinema"; this.rbCinema.Name = "rbCinema";
this.rbCinema.Size = new System.Drawing.Size(169, 29); this.rbCinema.Size = new System.Drawing.Size(137, 24);
this.rbCinema.TabIndex = 2; this.rbCinema.TabIndex = 2;
this.rbCinema.TabStop = true; this.rbCinema.TabStop = true;
this.rbCinema.Tag = "C"; this.rbCinema.Tag = "C";
@ -211,9 +219,10 @@ namespace tpDomeWinAPP
this.rbOffice.AutoSize = true; this.rbOffice.AutoSize = true;
this.rbOffice.Cursor = System.Windows.Forms.Cursors.Hand; this.rbOffice.Cursor = System.Windows.Forms.Cursors.Hand;
this.rbOffice.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); this.rbOffice.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.rbOffice.Location = new System.Drawing.Point(20, 128); this.rbOffice.Location = new System.Drawing.Point(16, 101);
this.rbOffice.Margin = new System.Windows.Forms.Padding(2);
this.rbOffice.Name = "rbOffice"; this.rbOffice.Name = "rbOffice";
this.rbOffice.Size = new System.Drawing.Size(154, 29); this.rbOffice.Size = new System.Drawing.Size(123, 24);
this.rbOffice.TabIndex = 1; this.rbOffice.TabIndex = 1;
this.rbOffice.TabStop = true; this.rbOffice.TabStop = true;
this.rbOffice.Tag = "O"; this.rbOffice.Tag = "O";
@ -229,14 +238,14 @@ namespace tpDomeWinAPP
this.tabControl1.Controls.Add(this.tabPage3); this.tabControl1.Controls.Add(this.tabPage3);
this.tabControl1.Controls.Add(this.tabPage4); this.tabControl1.Controls.Add(this.tabPage4);
this.tabControl1.Controls.Add(this.tabPage5); this.tabControl1.Controls.Add(this.tabPage5);
this.tabControl1.Cursor = System.Windows.Forms.Cursors.Arrow;
this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill; this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tabControl1.HotTrack = true; this.tabControl1.HotTrack = true;
this.tabControl1.ItemSize = new System.Drawing.Size(150, 40); this.tabControl1.ItemSize = new System.Drawing.Size(150, 40);
this.tabControl1.Location = new System.Drawing.Point(0, 0); this.tabControl1.Location = new System.Drawing.Point(0, 0);
this.tabControl1.Margin = new System.Windows.Forms.Padding(2);
this.tabControl1.Name = "tabControl1"; this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0; this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(1273, 764); this.tabControl1.Size = new System.Drawing.Size(991, 603);
this.tabControl1.TabIndex = 0; this.tabControl1.TabIndex = 0;
this.tabControl1.SelectedIndexChanged += new System.EventHandler(this.tabControl1_SelectedIndexChanged); this.tabControl1.SelectedIndexChanged += new System.EventHandler(this.tabControl1_SelectedIndexChanged);
// //
@ -246,10 +255,10 @@ namespace tpDomeWinAPP
this.tabPage1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; this.tabPage1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.tabPage1.Controls.Add(this.splitContainer2); this.tabPage1.Controls.Add(this.splitContainer2);
this.tabPage1.Location = new System.Drawing.Point(4, 44); this.tabPage1.Location = new System.Drawing.Point(4, 44);
this.tabPage1.Margin = new System.Windows.Forms.Padding(5); this.tabPage1.Margin = new System.Windows.Forms.Padding(4);
this.tabPage1.Name = "tabPage1"; this.tabPage1.Name = "tabPage1";
this.tabPage1.Padding = new System.Windows.Forms.Padding(5); this.tabPage1.Padding = new System.Windows.Forms.Padding(4);
this.tabPage1.Size = new System.Drawing.Size(1265, 716); this.tabPage1.Size = new System.Drawing.Size(983, 555);
this.tabPage1.TabIndex = 0; this.tabPage1.TabIndex = 0;
this.tabPage1.Text = "Niagara Tag"; this.tabPage1.Text = "Niagara Tag";
// //
@ -257,7 +266,8 @@ namespace tpDomeWinAPP
// //
this.splitContainer2.Cursor = System.Windows.Forms.Cursors.HSplit; this.splitContainer2.Cursor = System.Windows.Forms.Cursors.HSplit;
this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill; this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer2.Location = new System.Drawing.Point(5, 5); this.splitContainer2.Location = new System.Drawing.Point(4, 4);
this.splitContainer2.Margin = new System.Windows.Forms.Padding(2);
this.splitContainer2.Name = "splitContainer2"; this.splitContainer2.Name = "splitContainer2";
this.splitContainer2.Orientation = System.Windows.Forms.Orientation.Horizontal; this.splitContainer2.Orientation = System.Windows.Forms.Orientation.Horizontal;
// //
@ -273,24 +283,27 @@ namespace tpDomeWinAPP
// splitContainer2.Panel2 // splitContainer2.Panel2
// //
this.splitContainer2.Panel2.Controls.Add(this.splitContainer4); this.splitContainer2.Panel2.Controls.Add(this.splitContainer4);
this.splitContainer2.Size = new System.Drawing.Size(1251, 702); this.splitContainer2.Size = new System.Drawing.Size(971, 543);
this.splitContainer2.SplitterDistance = 87; this.splitContainer2.SplitterDistance = 67;
this.splitContainer2.SplitterWidth = 3;
this.splitContainer2.TabIndex = 1; this.splitContainer2.TabIndex = 1;
// //
// fp_tab1 // fp_tab1
// //
this.fp_tab1.Dock = System.Windows.Forms.DockStyle.Right; this.fp_tab1.Dock = System.Windows.Forms.DockStyle.Right;
this.fp_tab1.Location = new System.Drawing.Point(399, 0); this.fp_tab1.Location = new System.Drawing.Point(308, 0);
this.fp_tab1.Margin = new System.Windows.Forms.Padding(2);
this.fp_tab1.Name = "fp_tab1"; this.fp_tab1.Name = "fp_tab1";
this.fp_tab1.Size = new System.Drawing.Size(852, 87); this.fp_tab1.Size = new System.Drawing.Size(663, 67);
this.fp_tab1.TabIndex = 10; this.fp_tab1.TabIndex = 10;
// //
// lbMsg // lbMsg
// //
this.lbMsg.AutoSize = true; this.lbMsg.AutoSize = true;
this.lbMsg.Location = new System.Drawing.Point(14, 79); this.lbMsg.Location = new System.Drawing.Point(11, 62);
this.lbMsg.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lbMsg.Name = "lbMsg"; this.lbMsg.Name = "lbMsg";
this.lbMsg.Size = new System.Drawing.Size(18, 19); this.lbMsg.Size = new System.Drawing.Size(16, 15);
this.lbMsg.TabIndex = 2; this.lbMsg.TabIndex = 2;
this.lbMsg.Text = "..."; this.lbMsg.Text = "...";
// //
@ -298,9 +311,10 @@ namespace tpDomeWinAPP
// //
this.rball.AutoSize = true; this.rball.AutoSize = true;
this.rball.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); this.rball.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.rball.Location = new System.Drawing.Point(14, 47); this.rball.Location = new System.Drawing.Point(11, 37);
this.rball.Margin = new System.Windows.Forms.Padding(2);
this.rball.Name = "rball"; this.rball.Name = "rball";
this.rball.Size = new System.Drawing.Size(73, 29); this.rball.Size = new System.Drawing.Size(59, 24);
this.rball.TabIndex = 1; this.rball.TabIndex = 1;
this.rball.Text = "全部"; this.rball.Text = "全部";
this.rball.UseVisualStyleBackColor = true; this.rball.UseVisualStyleBackColor = true;
@ -311,9 +325,10 @@ namespace tpDomeWinAPP
this.rb100.AutoSize = true; this.rb100.AutoSize = true;
this.rb100.Checked = true; this.rb100.Checked = true;
this.rb100.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); this.rb100.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.rb100.Location = new System.Drawing.Point(14, 12); this.rb100.Location = new System.Drawing.Point(11, 9);
this.rb100.Margin = new System.Windows.Forms.Padding(2);
this.rb100.Name = "rb100"; this.rb100.Name = "rb100";
this.rb100.Size = new System.Drawing.Size(94, 29); this.rb100.Size = new System.Drawing.Size(74, 24);
this.rb100.TabIndex = 0; this.rb100.TabIndex = 0;
this.rb100.TabStop = true; this.rb100.TabStop = true;
this.rb100.Text = "100 筆"; this.rb100.Text = "100 筆";
@ -325,6 +340,7 @@ namespace tpDomeWinAPP
this.splitContainer4.Cursor = System.Windows.Forms.Cursors.VSplit; this.splitContainer4.Cursor = System.Windows.Forms.Cursors.VSplit;
this.splitContainer4.Dock = System.Windows.Forms.DockStyle.Fill; this.splitContainer4.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer4.Location = new System.Drawing.Point(0, 0); this.splitContainer4.Location = new System.Drawing.Point(0, 0);
this.splitContainer4.Margin = new System.Windows.Forms.Padding(2);
this.splitContainer4.Name = "splitContainer4"; this.splitContainer4.Name = "splitContainer4";
// //
// splitContainer4.Panel1 // splitContainer4.Panel1
@ -334,32 +350,33 @@ namespace tpDomeWinAPP
// splitContainer4.Panel2 // splitContainer4.Panel2
// //
this.splitContainer4.Panel2.Cursor = System.Windows.Forms.Cursors.Arrow; this.splitContainer4.Panel2.Cursor = System.Windows.Forms.Cursors.Arrow;
this.splitContainer4.Size = new System.Drawing.Size(1251, 611); this.splitContainer4.Size = new System.Drawing.Size(971, 473);
this.splitContainer4.SplitterDistance = 849; this.splitContainer4.SplitterDistance = 658;
this.splitContainer4.SplitterWidth = 10; this.splitContainer4.SplitterWidth = 8;
this.splitContainer4.TabIndex = 0; this.splitContainer4.TabIndex = 0;
// //
// dataGridView1 // dataGridView1
// //
this.dataGridView1.AllowUserToOrderColumns = true; this.dataGridView1.AllowUserToOrderColumns = true;
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.Cursor = System.Windows.Forms.Cursors.Arrow;
this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill; this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
this.dataGridView1.Location = new System.Drawing.Point(0, 0); this.dataGridView1.Location = new System.Drawing.Point(0, 0);
this.dataGridView1.Margin = new System.Windows.Forms.Padding(2);
this.dataGridView1.Name = "dataGridView1"; this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.RowHeadersWidth = 51; this.dataGridView1.RowHeadersWidth = 51;
this.dataGridView1.Size = new System.Drawing.Size(849, 611); this.dataGridView1.Size = new System.Drawing.Size(658, 473);
this.dataGridView1.TabIndex = 1; this.dataGridView1.TabIndex = 1;
this.dataGridView1.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentClick);
this.dataGridView1.DataBindingComplete += new System.Windows.Forms.DataGridViewBindingCompleteEventHandler(this.dataGridView1_DataBindingComplete); this.dataGridView1.DataBindingComplete += new System.Windows.Forms.DataGridViewBindingCompleteEventHandler(this.dataGridView1_DataBindingComplete);
// //
// tabPage2 // tabPage2
// //
this.tabPage2.Controls.Add(this.splitContainer3); this.tabPage2.Controls.Add(this.splitContainer3);
this.tabPage2.Location = new System.Drawing.Point(4, 44); this.tabPage2.Location = new System.Drawing.Point(4, 44);
this.tabPage2.Margin = new System.Windows.Forms.Padding(5); this.tabPage2.Margin = new System.Windows.Forms.Padding(4);
this.tabPage2.Name = "tabPage2"; this.tabPage2.Name = "tabPage2";
this.tabPage2.Padding = new System.Windows.Forms.Padding(5); this.tabPage2.Padding = new System.Windows.Forms.Padding(4);
this.tabPage2.Size = new System.Drawing.Size(1265, 716); this.tabPage2.Size = new System.Drawing.Size(983, 555);
this.tabPage2.TabIndex = 1; this.tabPage2.TabIndex = 1;
this.tabPage2.Text = "Niagara -> DB"; this.tabPage2.Text = "Niagara -> DB";
this.tabPage2.UseVisualStyleBackColor = true; this.tabPage2.UseVisualStyleBackColor = true;
@ -368,7 +385,8 @@ namespace tpDomeWinAPP
// //
this.splitContainer3.Cursor = System.Windows.Forms.Cursors.HSplit; this.splitContainer3.Cursor = System.Windows.Forms.Cursors.HSplit;
this.splitContainer3.Dock = System.Windows.Forms.DockStyle.Fill; this.splitContainer3.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer3.Location = new System.Drawing.Point(5, 5); this.splitContainer3.Location = new System.Drawing.Point(4, 4);
this.splitContainer3.Margin = new System.Windows.Forms.Padding(2);
this.splitContainer3.Name = "splitContainer3"; this.splitContainer3.Name = "splitContainer3";
this.splitContainer3.Orientation = System.Windows.Forms.Orientation.Horizontal; this.splitContainer3.Orientation = System.Windows.Forms.Orientation.Horizontal;
// //
@ -383,8 +401,9 @@ namespace tpDomeWinAPP
// splitContainer3.Panel2 // splitContainer3.Panel2
// //
this.splitContainer3.Panel2.Controls.Add(this.dataGridView2); this.splitContainer3.Panel2.Controls.Add(this.dataGridView2);
this.splitContainer3.Size = new System.Drawing.Size(1255, 706); this.splitContainer3.Size = new System.Drawing.Size(975, 547);
this.splitContainer3.SplitterDistance = 86; this.splitContainer3.SplitterDistance = 66;
this.splitContainer3.SplitterWidth = 3;
this.splitContainer3.TabIndex = 2; this.splitContainer3.TabIndex = 2;
// //
// tableLayoutPanel1 // tableLayoutPanel1
@ -406,85 +425,95 @@ namespace tpDomeWinAPP
this.tableLayoutPanel1.Controls.Add(this.cbShowEmpty, 0, 0); this.tableLayoutPanel1.Controls.Add(this.cbShowEmpty, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.btSearch_N4vsDB, 0, 1); this.tableLayoutPanel1.Controls.Add(this.btSearch_N4vsDB, 0, 1);
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Right; this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Right;
this.tableLayoutPanel1.Location = new System.Drawing.Point(300, 0); this.tableLayoutPanel1.Location = new System.Drawing.Point(232, 0);
this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(2);
this.tableLayoutPanel1.Name = "tableLayoutPanel1"; this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.Padding = new System.Windows.Forms.Padding(5); this.tableLayoutPanel1.Padding = new System.Windows.Forms.Padding(4);
this.tableLayoutPanel1.RowCount = 2; this.tableLayoutPanel1.RowCount = 2;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(955, 86); this.tableLayoutPanel1.Size = new System.Drawing.Size(743, 66);
this.tableLayoutPanel1.TabIndex = 4; this.tableLayoutPanel1.TabIndex = 4;
// //
// lbSec2 // lbSec2
// //
this.lbSec2.AutoSize = true; this.lbSec2.AutoSize = true;
this.lbSec2.Location = new System.Drawing.Point(197, 5); this.lbSec2.Location = new System.Drawing.Point(153, 4);
this.lbSec2.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lbSec2.Name = "lbSec2"; this.lbSec2.Name = "lbSec2";
this.lbSec2.Size = new System.Drawing.Size(167, 19); this.lbSec2.Size = new System.Drawing.Size(133, 15);
this.lbSec2.TabIndex = 1; this.lbSec2.TabIndex = 1;
this.lbSec2.Text = "第二碼 - system_code1"; this.lbSec2.Text = "第二碼 - system_code1";
// //
// lbSec3 // lbSec3
// //
this.lbSec3.AutoSize = true; this.lbSec3.AutoSize = true;
this.lbSec3.Location = new System.Drawing.Point(386, 5); this.lbSec3.Location = new System.Drawing.Point(300, 4);
this.lbSec3.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lbSec3.Name = "lbSec3"; this.lbSec3.Name = "lbSec3";
this.lbSec3.Size = new System.Drawing.Size(101, 19); this.lbSec3.Size = new System.Drawing.Size(81, 15);
this.lbSec3.TabIndex = 2; this.lbSec3.TabIndex = 2;
this.lbSec3.Text = "第三碼 - floor"; this.lbSec3.Text = "第三碼 - floor";
// //
// lbSec4 // lbSec4
// //
this.lbSec4.AutoSize = true; this.lbSec4.AutoSize = true;
this.lbSec4.Location = new System.Drawing.Point(575, 5); this.lbSec4.Location = new System.Drawing.Point(447, 4);
this.lbSec4.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lbSec4.Name = "lbSec4"; this.lbSec4.Name = "lbSec4";
this.lbSec4.Size = new System.Drawing.Size(167, 19); this.lbSec4.Size = new System.Drawing.Size(133, 15);
this.lbSec4.TabIndex = 3; this.lbSec4.TabIndex = 3;
this.lbSec4.Text = "第四碼 - system_code2"; this.lbSec4.Text = "第四碼 - system_code2";
// //
// lbSec5 // lbSec5
// //
this.lbSec5.AutoSize = true; this.lbSec5.AutoSize = true;
this.lbSec5.Location = new System.Drawing.Point(764, 5); this.lbSec5.Location = new System.Drawing.Point(594, 4);
this.lbSec5.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lbSec5.Name = "lbSec5"; this.lbSec5.Name = "lbSec5";
this.lbSec5.Size = new System.Drawing.Size(157, 19); this.lbSec5.Size = new System.Drawing.Size(125, 15);
this.lbSec5.TabIndex = 4; this.lbSec5.TabIndex = 4;
this.lbSec5.Text = "第五碼 - device_serial"; this.lbSec5.Text = "第五碼 - device_serial";
// //
// tbSec2 // tbSec2
// //
this.tbSec2.Location = new System.Drawing.Point(197, 46); this.tbSec2.Location = new System.Drawing.Point(153, 35);
this.tbSec2.Margin = new System.Windows.Forms.Padding(2);
this.tbSec2.Name = "tbSec2"; this.tbSec2.Name = "tbSec2";
this.tbSec2.Size = new System.Drawing.Size(125, 27); this.tbSec2.Size = new System.Drawing.Size(98, 23);
this.tbSec2.TabIndex = 5; this.tbSec2.TabIndex = 5;
// //
// tbSec3 // tbSec3
// //
this.tbSec3.Location = new System.Drawing.Point(386, 46); this.tbSec3.Location = new System.Drawing.Point(300, 35);
this.tbSec3.Margin = new System.Windows.Forms.Padding(2);
this.tbSec3.Name = "tbSec3"; this.tbSec3.Name = "tbSec3";
this.tbSec3.Size = new System.Drawing.Size(125, 27); this.tbSec3.Size = new System.Drawing.Size(98, 23);
this.tbSec3.TabIndex = 6; this.tbSec3.TabIndex = 6;
// //
// tbSec4 // tbSec4
// //
this.tbSec4.Location = new System.Drawing.Point(575, 46); this.tbSec4.Location = new System.Drawing.Point(447, 35);
this.tbSec4.Margin = new System.Windows.Forms.Padding(2);
this.tbSec4.Name = "tbSec4"; this.tbSec4.Name = "tbSec4";
this.tbSec4.Size = new System.Drawing.Size(125, 27); this.tbSec4.Size = new System.Drawing.Size(98, 23);
this.tbSec4.TabIndex = 7; this.tbSec4.TabIndex = 7;
// //
// tbSec5 // tbSec5
// //
this.tbSec5.Location = new System.Drawing.Point(764, 46); this.tbSec5.Location = new System.Drawing.Point(594, 35);
this.tbSec5.Margin = new System.Windows.Forms.Padding(2);
this.tbSec5.Name = "tbSec5"; this.tbSec5.Name = "tbSec5";
this.tbSec5.Size = new System.Drawing.Size(125, 27); this.tbSec5.Size = new System.Drawing.Size(98, 23);
this.tbSec5.TabIndex = 8; this.tbSec5.TabIndex = 8;
// //
// cbShowEmpty // cbShowEmpty
// //
this.cbShowEmpty.AutoSize = true; this.cbShowEmpty.AutoSize = true;
this.cbShowEmpty.Location = new System.Drawing.Point(8, 8); this.cbShowEmpty.Location = new System.Drawing.Point(6, 6);
this.cbShowEmpty.Margin = new System.Windows.Forms.Padding(2);
this.cbShowEmpty.Name = "cbShowEmpty"; this.cbShowEmpty.Name = "cbShowEmpty";
this.cbShowEmpty.Size = new System.Drawing.Size(136, 23); this.cbShowEmpty.Size = new System.Drawing.Size(110, 19);
this.cbShowEmpty.TabIndex = 0; this.cbShowEmpty.TabIndex = 0;
this.cbShowEmpty.Text = "只顯示缺失部分"; this.cbShowEmpty.Text = "只顯示缺失部分";
this.cbShowEmpty.UseVisualStyleBackColor = true; this.cbShowEmpty.UseVisualStyleBackColor = true;
@ -492,9 +521,10 @@ namespace tpDomeWinAPP
// //
// btSearch_N4vsDB // btSearch_N4vsDB
// //
this.btSearch_N4vsDB.Location = new System.Drawing.Point(8, 46); this.btSearch_N4vsDB.Location = new System.Drawing.Point(6, 35);
this.btSearch_N4vsDB.Margin = new System.Windows.Forms.Padding(2);
this.btSearch_N4vsDB.Name = "btSearch_N4vsDB"; this.btSearch_N4vsDB.Name = "btSearch_N4vsDB";
this.btSearch_N4vsDB.Size = new System.Drawing.Size(94, 29); this.btSearch_N4vsDB.Size = new System.Drawing.Size(73, 23);
this.btSearch_N4vsDB.TabIndex = 9; this.btSearch_N4vsDB.TabIndex = 9;
this.btSearch_N4vsDB.Text = "查詢"; this.btSearch_N4vsDB.Text = "查詢";
this.btSearch_N4vsDB.UseVisualStyleBackColor = true; this.btSearch_N4vsDB.UseVisualStyleBackColor = true;
@ -502,9 +532,10 @@ namespace tpDomeWinAPP
// //
// btTagCompare // btTagCompare
// //
this.btTagCompare.Location = new System.Drawing.Point(14, 8); this.btTagCompare.Location = new System.Drawing.Point(11, 6);
this.btTagCompare.Margin = new System.Windows.Forms.Padding(2);
this.btTagCompare.Name = "btTagCompare"; this.btTagCompare.Name = "btTagCompare";
this.btTagCompare.Size = new System.Drawing.Size(121, 38); this.btTagCompare.Size = new System.Drawing.Size(94, 30);
this.btTagCompare.TabIndex = 3; this.btTagCompare.TabIndex = 3;
this.btTagCompare.Text = "資料比對"; this.btTagCompare.Text = "資料比對";
this.btTagCompare.UseVisualStyleBackColor = true; this.btTagCompare.UseVisualStyleBackColor = true;
@ -513,9 +544,10 @@ namespace tpDomeWinAPP
// lbMsg2 // lbMsg2
// //
this.lbMsg2.AutoSize = true; this.lbMsg2.AutoSize = true;
this.lbMsg2.Location = new System.Drawing.Point(14, 51); this.lbMsg2.Location = new System.Drawing.Point(11, 40);
this.lbMsg2.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lbMsg2.Name = "lbMsg2"; this.lbMsg2.Name = "lbMsg2";
this.lbMsg2.Size = new System.Drawing.Size(258, 19); this.lbMsg2.Size = new System.Drawing.Size(207, 15);
this.lbMsg2.TabIndex = 2; this.lbMsg2.TabIndex = 2;
this.lbMsg2.Text = "依據上頁 Niagara 查詢結果與DB比對"; this.lbMsg2.Text = "依據上頁 Niagara 查詢結果與DB比對";
// //
@ -523,21 +555,22 @@ namespace tpDomeWinAPP
// //
this.dataGridView2.AllowUserToOrderColumns = true; this.dataGridView2.AllowUserToOrderColumns = true;
this.dataGridView2.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dataGridView2.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView2.Cursor = System.Windows.Forms.Cursors.Arrow;
this.dataGridView2.Dock = System.Windows.Forms.DockStyle.Fill; this.dataGridView2.Dock = System.Windows.Forms.DockStyle.Fill;
this.dataGridView2.Location = new System.Drawing.Point(0, 0); this.dataGridView2.Location = new System.Drawing.Point(0, 0);
this.dataGridView2.Margin = new System.Windows.Forms.Padding(2);
this.dataGridView2.Name = "dataGridView2"; this.dataGridView2.Name = "dataGridView2";
this.dataGridView2.RowHeadersWidth = 51; this.dataGridView2.RowHeadersWidth = 51;
this.dataGridView2.Size = new System.Drawing.Size(1255, 616); this.dataGridView2.Size = new System.Drawing.Size(975, 478);
this.dataGridView2.TabIndex = 0; this.dataGridView2.TabIndex = 0;
this.dataGridView2.DataBindingComplete += new System.Windows.Forms.DataGridViewBindingCompleteEventHandler(this.dataGridView1_DataBindingComplete); this.dataGridView2.DataBindingComplete += new System.Windows.Forms.DataGridViewBindingCompleteEventHandler(this.dataGridView1_DataBindingComplete);
// //
// tabPage3 // tabPage3
// //
this.tabPage3.Location = new System.Drawing.Point(4, 44); this.tabPage3.Location = new System.Drawing.Point(4, 44);
this.tabPage3.Margin = new System.Windows.Forms.Padding(2);
this.tabPage3.Name = "tabPage3"; this.tabPage3.Name = "tabPage3";
this.tabPage3.Padding = new System.Windows.Forms.Padding(3); this.tabPage3.Padding = new System.Windows.Forms.Padding(2);
this.tabPage3.Size = new System.Drawing.Size(1265, 716); this.tabPage3.Size = new System.Drawing.Size(983, 555);
this.tabPage3.TabIndex = 2; this.tabPage3.TabIndex = 2;
this.tabPage3.Text = "DB -> Niagara"; this.tabPage3.Text = "DB -> Niagara";
this.tabPage3.UseVisualStyleBackColor = true; this.tabPage3.UseVisualStyleBackColor = true;
@ -545,13 +578,25 @@ namespace tpDomeWinAPP
// tabPage4 // tabPage4
// //
this.tabPage4.Location = new System.Drawing.Point(4, 44); this.tabPage4.Location = new System.Drawing.Point(4, 44);
this.tabPage4.Margin = new System.Windows.Forms.Padding(2);
this.tabPage4.Name = "tabPage4"; this.tabPage4.Name = "tabPage4";
this.tabPage4.Padding = new System.Windows.Forms.Padding(3); this.tabPage4.Padding = new System.Windows.Forms.Padding(2);
this.tabPage4.Size = new System.Drawing.Size(1265, 716); this.tabPage4.Size = new System.Drawing.Size(983, 555);
this.tabPage4.TabIndex = 3; this.tabPage4.TabIndex = 3;
this.tabPage4.Text = "Excel 匯入"; this.tabPage4.Text = "Excel 匯入";
this.tabPage4.UseVisualStyleBackColor = true; this.tabPage4.UseVisualStyleBackColor = true;
// //
// tabPage5
//
this.tabPage5.Location = new System.Drawing.Point(4, 44);
this.tabPage5.Margin = new System.Windows.Forms.Padding(2);
this.tabPage5.Name = "tabPage5";
this.tabPage5.Padding = new System.Windows.Forms.Padding(2);
this.tabPage5.Size = new System.Drawing.Size(983, 555);
this.tabPage5.TabIndex = 4;
this.tabPage5.Text = "即時狀態";
this.tabPage5.UseVisualStyleBackColor = true;
//
// splitContainer5 // splitContainer5
// //
this.splitContainer5.Cursor = System.Windows.Forms.Cursors.HSplit; this.splitContainer5.Cursor = System.Windows.Forms.Cursors.HSplit;
@ -586,7 +631,7 @@ namespace tpDomeWinAPP
this.label1.AutoSize = true; this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(43, 0); this.label1.Location = new System.Drawing.Point(43, 0);
this.label1.Name = "label1"; this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(34, 171); this.label1.Size = new System.Drawing.Size(34, 90);
this.label1.TabIndex = 1; this.label1.TabIndex = 1;
this.label1.Text = "第二碼 - system_code1"; this.label1.Text = "第二碼 - system_code1";
// //
@ -599,22 +644,13 @@ namespace tpDomeWinAPP
this.label2.TabIndex = 2; this.label2.TabIndex = 2;
this.label2.Text = "第三碼 - floor"; this.label2.Text = "第三碼 - floor";
// //
// tabPage5
//
this.tabPage5.Location = new System.Drawing.Point(4, 44);
this.tabPage5.Name = "tabPage5";
this.tabPage5.Padding = new System.Windows.Forms.Padding(3);
this.tabPage5.Size = new System.Drawing.Size(1265, 716);
this.tabPage5.TabIndex = 4;
this.tabPage5.Text = "即時狀態";
this.tabPage5.UseVisualStyleBackColor = true;
//
// fmCheckTagName // fmCheckTagName
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 19F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1502, 764); this.ClientSize = new System.Drawing.Size(1168, 603);
this.Controls.Add(this.splitContainer1); this.Controls.Add(this.splitContainer1);
this.Margin = new System.Windows.Forms.Padding(2);
this.Name = "fmCheckTagName"; this.Name = "fmCheckTagName";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Niagara Tag Management"; this.Text = "Niagara Tag Management";
@ -660,7 +696,7 @@ namespace tpDomeWinAPP
private System.Windows.Forms.RadioButton rbDome2; private System.Windows.Forms.RadioButton rbDome2;
private System.Windows.Forms.RadioButton rbCinema; private System.Windows.Forms.RadioButton rbCinema;
private System.Windows.Forms.RadioButton rbOffice; private System.Windows.Forms.RadioButton rbOffice;
private System.Windows.Forms.RadioButton rbH; private System.Windows.Forms.RadioButton rbB1;
private System.Windows.Forms.TabControl tabControl1; private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.TabPage tabPage1; private System.Windows.Forms.TabPage tabPage1;
private System.Windows.Forms.SplitContainer splitContainer2; private System.Windows.Forms.SplitContainer splitContainer2;

View File

@ -141,7 +141,7 @@ namespace tpDomeWinAPP
if (ds != null && ds.Count > 0) if (ds != null && ds.Count > 0)
{ {
svcCompare.InsertNiagaraTagList(ds, building); svcCompare.ToInsertNiagaraTagList(ds, building);
lbMsg2.Text = "Done!" + Environment.NewLine + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); lbMsg2.Text = "Done!" + Environment.NewLine + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
} }
else else
@ -424,7 +424,7 @@ namespace tpDomeWinAPP
} }
} }
} }
sb.Insert(0, $@"select * from importTag where building = '{building}' "); sb.Insert(0, $@"select * from import_niagara_tag where building = '{building}' ");
if (cbShowEmpty.Checked) if (cbShowEmpty.Checked)
{ {
sb.Append( $@" and db_tags is null;"); sb.Append( $@" and db_tags is null;");
@ -436,6 +436,11 @@ namespace tpDomeWinAPP
} }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
//public async void getFireAsync(int deviceKind, IEnumerable<device> ds, DataGridView gv) //public async void getFireAsync(int deviceKind, IEnumerable<device> ds, DataGridView gv)
//{ //{
// ///消防設備一次報警1http://greencloud.fic.com.tw:8080/obix/config/NHI/Taipei/Fire/Fire1Level1/out // ///消防設備一次報警1http://greencloud.fic.com.tw:8080/obix/config/NHI/Taipei/Fire/Fire1Level1/out