diff --git a/src/app/ui/collection-tools/collection-tools.component.ts b/src/app/ui/collection-tools/collection-tools.component.ts index e0427b3..af298b3 100644 --- a/src/app/ui/collection-tools/collection-tools.component.ts +++ b/src/app/ui/collection-tools/collection-tools.component.ts @@ -1614,7 +1614,46 @@ export class CollectionToolsComponent implements OnInit { sitePlanId: data.id } this.http.post('/api/CompanyAccount/SitePlanData',newData).subscribe(data=>{ - this.renovateSitePlan() + this.canvasData.originaleveryStoreyData = data || {} // 楼层原数据 + this.canvasData.originaleveryStoreyData.data ? this.canvasData.originaleveryStoreyData.data = JSON.parse(this.canvasData.originaleveryStoreyData.data) : this.canvasData.originaleveryStoreyData.data = {} + Object.keys(this.canvasData.originaleveryStoreyData.data).forEach((key) => { + this.canvasData.originalcompanyBuildingData.data[key] = this.canvasData.originaleveryStoreyData.data[key]; + }); + let list = [] + //保存建筑数据 + let CompanyData = JSON.parse(JSON.stringify(this.canvasData.originalcompanyBuildingData)); + CompanyData.data = JSON.stringify(CompanyData.data) + this.http.post("/api/CompanyAccount/CompanyData", CompanyData).subscribe(data => { + list.push(1) + if (list.length === 4) { this.updateCurrentFloor() } + }) + //批量保存单位毗邻 + let CompanyAdjoins = this.canvasData.getCompanyAdjoinInfo() + this.http.post("/api/CompanyAccount/CompanyAdjoins/Batch", CompanyAdjoins).subscribe(data => { + list.push(1) + if (list.length === 4) { this.updateCurrentFloor() } + }, err => { + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + if (err == 'infos 有重复方向!') { + this.snackBar.open('单位毗邻同步失败,存在相同方向', '确定', config); + } else { + this.snackBar.open('单位毗邻同步失败', '确定', config); + } + }) + //批量保存单位重点部位 + let CompanyImportantLocations = this.canvasData.getCompanyImportantLocations() + this.http.post("/api/CompanyAccount/CompanyImportantLocations/Batch", CompanyImportantLocations).subscribe(data => { + list.push(1) + if (list.length === 4) { this.updateCurrentFloor() } + }) + //批量保存单位消防设施素材 + let CompanyFacilityAssets = this.canvasData.getAllCompanyFacilityAssetInfo() + this.http.post("/api/CompanyAccount/CompanyFacilityAssets/Batch", CompanyFacilityAssets).subscribe(data => { + list.push(1) + if (list.length === 4) { this.updateCurrentFloor() } + }) }) }) @@ -1631,13 +1670,86 @@ export class CollectionToolsComponent implements OnInit { buildingAreaId: data.id } this.http.post('/api/CompanyAccount/BuildingAreaData',newData).subscribe(data=>{ - this.renovateBuilding() + this.canvasData.originaleveryStoreyData = data || {} // 楼层原数据 + this.canvasData.originaleveryStoreyData.data ? this.canvasData.originaleveryStoreyData.data = JSON.parse(this.canvasData.originaleveryStoreyData.data) : this.canvasData.originaleveryStoreyData.data = {} + Object.keys(this.canvasData.originaleveryStoreyData.data).forEach((key) => { + this.canvasData.originalcompanyBuildingData.data[key] = this.canvasData.originaleveryStoreyData.data[key]; + }); + let list = [] + //建筑数据 + let CompanyData = JSON.parse(JSON.stringify(this.canvasData.originalcompanyBuildingData)); + CompanyData.data = JSON.stringify(CompanyData.data) + this.http.post("/api/CompanyAccount/BuildingData", CompanyData).subscribe(data => { + list.push(1) + if (list.length === 4) { this.updateCurrentFloor() } + }) + //批量保存建筑毗邻 + let buildingAdjoins = this.canvasData.getBuildingAdjoinInfo() + this.http.post(`/api/CompanyAccount/BuildingAdjoins/Batch?buildingId=${this.canvasData.selectStorey.buildingId}`, buildingAdjoins).subscribe(data => { + list.push(1) + if (list.length === 4) { this.updateCurrentFloor() } + }, err => { + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + if (err == 'infos 有重复方向!') { + this.snackBar.open('建筑毗邻同步失败,存在相同方向', '确定', config); + } else { + this.snackBar.open('建筑毗邻同步失败', '确定', config); + } + }) + //批量保存建筑重点部位 + let buildingImportantLocations = this.canvasData.getBuildingImportantLocations() + this.http.post(`/api/CompanyAccount/BuildingImportantLocations/Batch?buildingId=${this.canvasData.selectStorey.buildingId}`, buildingImportantLocations).subscribe(data => { + list.push(1) + if (list.length === 4) { this.updateCurrentFloor() } + }) + //批量保存建筑消防设施素材 + let buildingFacilityAssets = this.canvasData.getAllBuildingFacilityAssetInfo() + this.http.post(`/api/CompanyAccount/BuildingFacilityAssets/Batch?buildingId=${this.canvasData.selectStorey.buildingId}`, buildingFacilityAssets).subscribe(data => { + list.push(1) + if (list.length === 4) { this.updateCurrentFloor() } + }) }) }) } } + //复制完楼层后 刷新视图 + updateCurrentFloor() { + if (this.checkedBuildingIndex == -1) { //总平面图 + let fireData = this.getFireElements(sessionStorage.getItem('buildingTypeId')) //获取单位下 消防要素 + let planData = this.getSitePlanCompanyData() //获取 单位 数据 + this.http.get('/api/CompanyAccount/SitePlans').subscribe(data => { + this.sitePlanData = data + this.selectingSitePlan = this.sitePlanData[this.sitePlanData.length-1] || {} + this.canvasData.selectStorey = this.sitePlanData[this.sitePlanData.length-1] || {} //服务中 存一份数据 + this.selectSitePlanIndex = this.sitePlanData.length-1 + + Promise.all([fireData, planData]).then((res) => { + this.getSitePlanStorey(this.selectingSitePlan) //获取 平面图 楼层数据 + }) + + }) //重新加载 新楼层 + } else { //楼层/区域 + let params = { buildingId: this.beforeOneCheckedBuilding.id } + let fireData = this.getFireElements(this.beforeOneCheckedBuilding.buildingTypes[0].id || '') //获取建筑下 消防要素 + let planData = this.getBuildingData(params) //获取 建筑 数据 + this.http.get('/api/CompanyAccount/BuildingAreas', { params }).subscribe(data => { + this.sitePlanData = data + this.selectingSitePlan = this.sitePlanData[this.sitePlanData.length-1] || {} + this.canvasData.selectStorey = this.sitePlanData[this.sitePlanData.length-1] || {} //服务中 存一份数据 + this.selectSitePlanIndex = this.sitePlanData.length-1 + + Promise.all([fireData, planData]).then((res) => { + this.getBuildingStorey(this.selectingSitePlan) //获取 建筑 楼层数据 + }) + + }) //重新加载 新楼层 + } + } + //平面图 楼层/区域 替换底图 replaceBaseMap (e,item) { e.stopPropagation(); @@ -1645,6 +1757,13 @@ export class CollectionToolsComponent implements OnInit { let fileSize = file.size || null //上传文件的总大小 let maxSize = 5 * 1024 * 1024 //5MB一个分片 let tenSize = 10 * 1024 * 1024 //10MB限制 + if (file && file.name.toLowerCase().indexOf('png') == -1 && file.name.toLowerCase().indexOf('jpg') == -1 && file.name.toLowerCase().indexOf('jpeg') == -1) { + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('请上传图片后缀为png,jpg,jpeg的文件', '确定', config); + return + } if (file && fileSize<=maxSize) { //上传文件<=5MB时 let formData = new FormData()