[後台] 修改區域設定
This commit is contained in:
		
							parent
							
								
									bf61f7aef6
								
							
						
					
					
						commit
						abf63105ef
					
				@ -19,6 +19,8 @@ namespace Backend.Controllers
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        private readonly IBackendRepository backendRepository;
 | 
					        private readonly IBackendRepository backendRepository;
 | 
				
			||||||
        private string mapFileSaveAsPath = "";
 | 
					        private string mapFileSaveAsPath = "";
 | 
				
			||||||
 | 
					        private string main_system_name = "device_system_category_layer2";
 | 
				
			||||||
 | 
					        private string sub_system_name = "device_system_category_layer1";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public BuildInfoController(IBackendRepository backendRepository)
 | 
					        public BuildInfoController(IBackendRepository backendRepository)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
@ -44,7 +46,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 +80,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,46 +89,92 @@ namespace Backend.Controllers
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                if (!judgeIPAddressRepeat)
 | 
					                if (!judgeIPAddressRepeat)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
 | 
					                    //Check for duplicate building tag
 | 
				
			||||||
 | 
					                    sWhere = $@"deleted = 0 AND building_tag = @Building_tag";
 | 
				
			||||||
 | 
					                    buildInfos = await backendRepository.GetAllAsync<BuildInfo>("building", sWhere, new { building_tag = post.building_tag });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    if (buildInfos.Count > 0)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        apiResult.Code = "0002";
 | 
				
			||||||
 | 
					                        apiResult.Msg = "區域代號不可重複";
 | 
				
			||||||
 | 
					                        return apiResult;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    //新增
 | 
					                    //新增
 | 
				
			||||||
                    if (post.Building_guid == "0")
 | 
					                    //抓取當前的Priority
 | 
				
			||||||
 | 
					                    var current_priority = await backendRepository.GetCurrentPriority("building");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    Dictionary<string, object> building = new Dictionary<string, object>();
 | 
				
			||||||
 | 
					                    building = new Dictionary<string, object>()
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        //產生一組GUID
 | 
					                        { "@building_tag", post.building_tag},
 | 
				
			||||||
                        var guid = Guid.NewGuid();  //大樓GUID
 | 
					                        { "@full_name", post.Full_name},
 | 
				
			||||||
 | 
					                        { "@ip_address", post.Ip_address},
 | 
				
			||||||
 | 
					                        { "@ip_port", post.Ip_port},
 | 
				
			||||||
 | 
					                        { "@priority", current_priority + 1},
 | 
				
			||||||
 | 
					                        { "@created_by", myUserInfo.Userinfo_guid}
 | 
				
			||||||
 | 
					                    };
 | 
				
			||||||
 | 
					                    await backendRepository.AddOneByCustomTable(building, "building");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        //抓取當前的Priority
 | 
					                    apiResult.Code = "0000";
 | 
				
			||||||
                        var current_priority = await backendRepository.GetCurrentPriority("building");
 | 
					                    apiResult.Msg = "新增成功";
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    apiResult.Code = "0001";
 | 
				
			||||||
 | 
					                    apiResult.Msg = "監控主機IP不可重複";
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        Dictionary<string, object> building = new Dictionary<string, object>();
 | 
					            }
 | 
				
			||||||
                        building = new Dictionary<string, object>()
 | 
					            catch (Exception exception)
 | 
				
			||||||
                        {
 | 
					            {
 | 
				
			||||||
                            { "@building_guid", guid},
 | 
					                apiResult.Code = "9999";
 | 
				
			||||||
                            { "@full_name", post.Full_name},
 | 
					                apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
 | 
				
			||||||
                            { "@ip_address", post.Ip_address},
 | 
					                string json = System.Text.Json.JsonSerializer.Serialize(post);
 | 
				
			||||||
                            { "@ip_port", post.Ip_port},
 | 
					                Logger.LogError("【" + controllerName + "/" + actionName + "】" + json);
 | 
				
			||||||
                            { "@priority", current_priority + 1},
 | 
					                Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
 | 
				
			||||||
                            { "@created_by", myUserInfo.Userinfo_guid}
 | 
					            }
 | 
				
			||||||
                        };
 | 
					 | 
				
			||||||
                        await backendRepository.AddOneByCustomTable(building, "building");
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        apiResult.Code = "0000";
 | 
					            return apiResult;
 | 
				
			||||||
                        apiResult.Msg = "新增成功";
 | 
					        }
 | 
				
			||||||
                    }
 | 
					
 | 
				
			||||||
                    else //修改
 | 
					        /// <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>();
 | 
				
			||||||
 | 
					                    building = new Dictionary<string, object>()
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        Dictionary<string, object> building = new Dictionary<string, object>();
 | 
					                        { "@full_name", post.Full_name},
 | 
				
			||||||
                        building = new Dictionary<string, object>()
 | 
					                        { "@ip_address", post.Ip_address},
 | 
				
			||||||
                        {
 | 
					                        { "@ip_port", post.Ip_port},
 | 
				
			||||||
                            { "@full_name", post.Full_name},
 | 
					                        { "@updated_by", myUserInfo.Userinfo_guid},
 | 
				
			||||||
                            { "@ip_address", post.Ip_address},
 | 
					                        { "@updated_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}
 | 
				
			||||||
                            { "@ip_port", post.Ip_port},
 | 
					                    };
 | 
				
			||||||
                            { "@updated_by", myUserInfo.Userinfo_guid},
 | 
					                    await backendRepository.UpdateOneByCustomTable(building, "building", "building_tag='" + post.building_tag + "'");
 | 
				
			||||||
                            { "@updated_at", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}
 | 
					 | 
				
			||||||
                        };
 | 
					 | 
				
			||||||
                        await backendRepository.UpdateOneByCustomTable(building, "building", "building_guid='" + post.Building_guid + "'");
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        apiResult.Code = "0000";
 | 
					                    apiResult.Code = "0000";
 | 
				
			||||||
                        apiResult.Msg = "修改成功";
 | 
					                    apiResult.Msg = "修改成功";
 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                else
 | 
					                else
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
@ -148,14 +196,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 +215,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 +226,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 +237,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 +247,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 +271,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 +280,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 +304,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 +314,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 +391,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 +419,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 +459,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 +505,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 +546,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, ' - ', v1.system_key, ' - ', v2.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 v1 ON ssf.main_system_tag = v1.system_value AND v1.system_type = @main_system_type AND v1.deleted = 0
 | 
				
			||||||
                                            LEFT JOIN sub_system ss ON ssf.sub_system_guid = ss.sub_system_guid AND ss.deleted = 0";
 | 
					                                        LEFT JOIN variable v2 ON ssf.sub_system_tag = v2.system_value AND v2.system_type = @sub_system_type AND v2.deleted = 0";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                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_name, sub_system_type = sub_system_name });
 | 
				
			||||||
                if (sub_system_floors.Count > 0)
 | 
					                if (sub_system_floors.Count > 0)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    apiResult.Code = "9997";
 | 
					                    apiResult.Code = "9997";
 | 
				
			||||||
 | 
				
			|||||||
@ -23,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; } //使用者命名平面圖檔檔名
 | 
				
			||||||
@ -43,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; }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -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();
 | 
				
			||||||
@ -252,6 +257,41 @@
 | 
				
			|||||||
            if ($("#build-form").valid()) {
 | 
					            if ($("#build-form").valid()) {
 | 
				
			||||||
                $("#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 = {
 | 
				
			||||||
 | 
					                    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 = {
 | 
					                var send_data = {
 | 
				
			||||||
                    building_tag: selected_build_guid,
 | 
					                    building_tag: selected_build_guid,
 | 
				
			||||||
                    Full_name: $('#build_name_modal').val(),
 | 
					                    Full_name: $('#build_name_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") {
 | 
				
			||||||
 | 
				
			|||||||
@ -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">
 | 
				
			||||||
 | 
				
			|||||||
@ -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  | 
		Loading…
	
		Reference in New Issue
	
	Block a user