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

Loading…
Cancel
Save