Browse Source

[完善]消防设施网络获取失败

guangxi
邵佳豪 3 years ago
parent
commit
a29982e204
  1. 4
      src/app/http-interceptors/base-interceptor.ts
  2. 129
      src/app/key-unit/fire-fighting-device/fire-fighting-device.component.ts

4
src/app/http-interceptors/base-interceptor.ts

@ -72,9 +72,7 @@ export class BaseInterceptor implements HttpInterceptor {
} else {
// 服务端返回http状态码
// 服务端返回错误信息
console.error(
`Backend returned code ${error.status}, ` +
`body was: ${error.error}`);
console.error(error);
}
// 返回带有面向用户的错误信息
return throwError(

129
src/app/key-unit/fire-fighting-device/fire-fighting-device.component.ts

@ -51,7 +51,8 @@ export class FireFightingDeviceComponent implements OnInit {
element.selectBuiltInGrouping = []
element.facilityItems.forEach((elements, index) => {
elements.total = element.facilityCount[index]
elements.expanded = false});
elements.expanded = false
});
});
}) //http
} //if
@ -67,7 +68,8 @@ export class FireFightingDeviceComponent implements OnInit {
if (data) {
e.facilityItems.push(data)
this.tabbarService.sendMessage('changeScore');//通知服务改变分数
} });
}
});
}
//保存单位消防设施内置分组项
@ -80,7 +82,8 @@ export class FireFightingDeviceComponent implements OnInit {
details: element.details,
name: element.name,
isEachFloor: element.isEachFloor,
order: element.order}
order: element.order
}
data.push(msg)
if (index == e.facilityItems.length - 1) {
this.http.post('/api/CompanyFacilityItems/Batch', data, { params: header }).subscribe(data => {
@ -89,7 +92,8 @@ export class FireFightingDeviceComponent implements OnInit {
config.duration = 3000
this.snackBar.open('数据更新成功', '确定', config);
this.tabbarService.sendMessage('changeScore');//通知服务改变分数
}) }
})
}
}); //forEach
}
@ -162,22 +166,26 @@ export class FireFightingDeviceComponent implements OnInit {
item.assets[0].propertyInfos.forEach(element => { //表头
if (element.propertyType != 3) {
let unit = element.physicalUnit ? '(' + element.physicalUnit + ')' : '' //单位
tableMsg.header.push(element.propertyName+unit)}
tableMsg.header.push(element.propertyName + unit)
}
});
item.assets.forEach(element => { //表格内容
let everyBody = {}
element.propertyInfos.forEach((elements, index) => {
if (elements.propertyType != 3 && elements.propertyName != '图片' && elements.propertyType != 6) {
let unit = elements.physicalUnit ? '(' + elements.physicalUnit + ')' : '' //单位
everyBody[elements.propertyName+unit] = elements.propertyValue }
everyBody[elements.propertyName + unit] = elements.propertyValue
}
if (elements.propertyType == 6) {
let unit = elements.physicalUnit ? '(' + elements.physicalUnit + ')' : '' //单位
everyBody[elements.propertyName+unit] = elements.propertyValue=='1'?'是':'否' }
everyBody[elements.propertyName + unit] = elements.propertyValue == '1' ? '是' : '否'
}
if (elements.propertyType != 3 && elements.propertyName == '图片') {
let imgLength = []
element.propertyInfos.find(item => { if (item.propertyType == 3) { imgLength.push(item) } })
let unit = elements.physicalUnit ? '(' + elements.physicalUnit + ')' : '' //单位
everyBody[elements.propertyName+unit] = String(imgLength.length) }
everyBody[elements.propertyName + unit] = String(imgLength.length)
}
}); //propertyInfos
tableMsg.body.push(everyBody)
@ -194,22 +202,26 @@ export class FireFightingDeviceComponent implements OnInit {
data[0].propertyInfos.forEach(element => { //表头
if (element.propertyType != 3) {
let unit = element.physicalUnit ? '(' + element.physicalUnit + ')' : '' //单位
e.header.push(element.propertyName+unit)}
e.header.push(element.propertyName + unit)
}
});
data.forEach(element => { //表格内容
let everyBody = {}
element.propertyInfos.forEach((elements, index) => {
if (elements.propertyType != 3 && elements.propertyName != '图片' && elements.propertyType != 6) {
let unit = elements.physicalUnit ? '(' + elements.physicalUnit + ')' : '' //单位
everyBody[elements.propertyName+unit] = elements.propertyValue }
everyBody[elements.propertyName + unit] = elements.propertyValue
}
if (elements.propertyType == 6) {
let unit = elements.physicalUnit ? '(' + elements.physicalUnit + ')' : '' //单位
everyBody[elements.propertyName+unit] = elements.propertyValue=='1'?'是':'否' }
everyBody[elements.propertyName + unit] = elements.propertyValue == '1' ? '是' : '否'
}
if (elements.propertyType != 3 && elements.propertyName == '图片') {
let imgLength = []
element.propertyInfos.find(item => { if (item.propertyType == 3) { imgLength.push(item) } })
let unit = elements.physicalUnit ? '(' + elements.physicalUnit + ')' : '' //单位
everyBody[elements.propertyName+unit] = String(imgLength.length) }
everyBody[elements.propertyName + unit] = String(imgLength.length)
}
});
e.body.push(everyBody)
@ -229,9 +241,11 @@ export class FireFightingDeviceComponent implements OnInit {
//获取所有建筑
getAllBuilding() {
let companyId = this.route.snapshot.queryParams.id
this.http.get('/api/Buildings',{params:{
this.http.get('/api/Buildings', {
params: {
companyId: companyId
}}).subscribe((data:any)=>{
}
}).subscribe((data: any) => {
this.allBuildingGrouping = data
// console.log(888,data)
if (this.allBuildingGrouping.length) {
@ -297,19 +311,25 @@ export class FireFightingDeviceComponent implements OnInit {
FacilityStat: any//存放当前建筑手动输入的值
selectedChange($event) {
//获得手动输入的值
this.http.get('/api/BuildingFacilities/FacilityStat',{params:{
this.http.get('/api/BuildingFacilities/FacilityStat', {
params: {
buildingId: this.allBuildingGrouping[$event].id
}}).subscribe(data=>{
}
}).subscribe(data => {
this.FacilityStat = data
this.changeData()
})
}
//获取所有建筑的消防设施
getAllBuildingFacilities () {
async getAllBuildingFacilities() {
let companyId = this.route.snapshot.queryParams.id
let index = 0
this.allBuildingGrouping.forEach(element => {
for (let index = 0; index < this.allBuildingGrouping.length; index++) {
const element = this.allBuildingGrouping[index];
let header = { buildingId: element.id, buildingType: element.buildingTypes[0].id, companyId: companyId }
await new Promise<void>((resolve, reject) => {
this.http.get('/api/BuildingFacilities', { params: header }).subscribe(data => {
element.buildingFacilityGroups = data[0].summary.buildingFacilityGroups
element.buildingOptionalGroups = data[0].summary.buildingOptionalGroups
@ -319,10 +339,19 @@ export class FireFightingDeviceComponent implements OnInit {
elements.selectBuiltInGrouping = []
elements.facilityItems.forEach((newElement, index) => {
newElement.total = elements.facilityCount[index]
newElement.expanded = false });
newElement.expanded = false
});
})
});
// console.log(element.name, data)
resolve()
}, err => {
console.log(element.name + '消防设施网络获取失败', err)
})
})
}
}
//清空手动输入的值
@ -498,7 +527,8 @@ export class FireFightingDeviceComponent implements OnInit {
details: element.details,
name: element.name,
isEachFloor: element.isEachFloor,
order: element.order}
order: element.order
}
data.push(msg)
if (index == item.facilityItems.length - 1) {
this.http.post('/api/BuildingFacilityItems/Batch', data, { params: header }).subscribe(data => {
@ -590,9 +620,11 @@ export class FireFightingDeviceComponent implements OnInit {
item.propertyInfos.forEach((element, index) => {
element.propertyValue = String(element.propertyValue)
if (index == item.propertyInfos.length - 1) {
this.http.post('/api/BuildingOptionalGroups',item,{params:{
this.http.post('/api/BuildingOptionalGroups', item, {
params: {
companyId: companyId
}}).subscribe(data=>{
}
}).subscribe(data => {
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
@ -616,22 +648,26 @@ export class FireFightingDeviceComponent implements OnInit {
item.assets[0].propertyInfos.forEach(element => { //表头
if (element.propertyType != 3) {
let unit = element.physicalUnit ? '(' + element.physicalUnit + ')' : '' //单位
tableMsg.header.push(element.propertyName+unit)}
tableMsg.header.push(element.propertyName + unit)
}
});
item.assets.forEach(element => { //表格内容
let everyBody = {}
element.propertyInfos.forEach((elements, index) => {
if (elements.propertyType != 3 && elements.propertyName != '图片' && elements.propertyType != 6) {
let unit = elements.physicalUnit ? '(' + elements.physicalUnit + ')' : '' //单位
everyBody[elements.propertyName+unit] = elements.propertyValue }
everyBody[elements.propertyName + unit] = elements.propertyValue
}
if (elements.propertyType == 6) {
let unit = elements.physicalUnit ? '(' + elements.physicalUnit + ')' : '' //单位
everyBody[elements.propertyName+unit] = elements.propertyValue=='1'?'是':'否' }
everyBody[elements.propertyName + unit] = elements.propertyValue == '1' ? '是' : '否'
}
if (elements.propertyType != 3 && elements.propertyName == '图片') {
let imgLength = []
element.propertyInfos.find(item => { if (item.propertyType == 3) { imgLength.push(item) } })
let unit = elements.physicalUnit ? '(' + elements.physicalUnit + ')' : '' //单位
everyBody[elements.propertyName+unit] = String(imgLength.length) }
everyBody[elements.propertyName + unit] = String(imgLength.length)
}
}); //propertyInfos
tableMsg.body.push(everyBody)
@ -648,22 +684,26 @@ export class FireFightingDeviceComponent implements OnInit {
data[0].propertyInfos.forEach(element => { //表头
if (element.propertyType != 3) {
let unit = element.physicalUnit ? '(' + element.physicalUnit + ')' : '' //单位
e.header.push(element.propertyName+unit)}
e.header.push(element.propertyName + unit)
}
});
data.forEach(element => { //表格内容
let everyBody = {}
element.propertyInfos.forEach((elements, index) => {
if (elements.propertyType != 3 && elements.propertyName != '图片' && elements.propertyType != 6) {
let unit = elements.physicalUnit ? '(' + elements.physicalUnit + ')' : '' //单位
everyBody[elements.propertyName+unit] = elements.propertyValue }
everyBody[elements.propertyName + unit] = elements.propertyValue
}
if (elements.propertyType == 6) {
let unit = elements.physicalUnit ? '(' + elements.physicalUnit + ')' : '' //单位
everyBody[elements.propertyName+unit] = elements.propertyValue=='1'?'是':'否' }
everyBody[elements.propertyName + unit] = elements.propertyValue == '1' ? '是' : '否'
}
if (elements.propertyType != 3 && elements.propertyName == '图片') {
let imgLength = []
element.propertyInfos.find(item => { if (item.propertyType == 3) { imgLength.push(item) } })
let unit = elements.physicalUnit ? '(' + elements.physicalUnit + ')' : '' //单位
everyBody[elements.propertyName+unit] = String(imgLength.length) }
everyBody[elements.propertyName + unit] = String(imgLength.length)
}
});
e.body.push(everyBody)
@ -690,7 +730,9 @@ export class FireFightingDeviceComponent implements OnInit {
if (elements.propertyName.includes('名称')) { imgName = elements.propertyValue }
if (elements.propertyType === 3) {
elements.propertyName = imgName
data.images.push(elements)} });
data.images.push(elements)
}
});
});
}); //newDate
@ -707,7 +749,8 @@ export class FireFightingDeviceComponent implements OnInit {
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('暂无图片数据','确定',config); }
this.snackBar.open('暂无图片数据', '确定', config);
}
} else { //非逐层统计时
let newData = this.companyDetails[e.name]
let imgName
@ -718,7 +761,9 @@ export class FireFightingDeviceComponent implements OnInit {
if (elements.propertyName.includes('名称')) { imgName = elements.propertyValue }
if (elements.propertyType === 3) {
elements.propertyName = imgName
data.images.push(elements)} });
data.images.push(elements)
}
});
});
if (data.images.length) {
let dialogRef = this.dialog.open(ImagesData, { data }); //打开图片弹窗
@ -733,7 +778,8 @@ export class FireFightingDeviceComponent implements OnInit {
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('暂无图片数据','确定',config); }
this.snackBar.open('暂无图片数据', '确定', config);
}
}
}
@ -751,7 +797,9 @@ export class FireFightingDeviceComponent implements OnInit {
if (elements.propertyName.includes('名称')) { imgName = elements.propertyValue }
if (elements.propertyType === 3) {
elements.propertyName = imgName
data.images.push(elements)} });
data.images.push(elements)
}
});
});
}); //newDate
@ -768,7 +816,8 @@ export class FireFightingDeviceComponent implements OnInit {
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('暂无图片数据','确定',config); }
this.snackBar.open('暂无图片数据', '确定', config);
}
} else { //非逐层统计时
let newData = item.buildingDetails[e.name]
let imgName
@ -779,7 +828,8 @@ export class FireFightingDeviceComponent implements OnInit {
if (elements.propertyName.includes('名称')) { imgName = elements.propertyValue }
if (elements.propertyType === 3) {
elements.propertyName = imgName
data.images.push(elements)}
data.images.push(elements)
}
});
});
if (data.images.length) {
@ -795,7 +845,8 @@ export class FireFightingDeviceComponent implements OnInit {
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('暂无图片数据','确定',config); }
this.snackBar.open('暂无图片数据', '确定', config);
}
}
}

Loading…
Cancel
Save