|
|
|
@ -23,16 +23,18 @@ export class CreateTestScoreComponent implements OnInit {
|
|
|
|
|
this.selectedTab = index |
|
|
|
|
} |
|
|
|
|
ngOnInit(): void { |
|
|
|
|
// this.getUnitData()
|
|
|
|
|
// .then(()=>{
|
|
|
|
|
// this.getAround()
|
|
|
|
|
this.getUnitData().then(()=>{ |
|
|
|
|
this.getAround().then(()=>{ |
|
|
|
|
this.getKeySite().then(()=>{ |
|
|
|
|
this.getFunDiv().then(()=>{ |
|
|
|
|
this.getFireFac() |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
// Promise.all([this.getUnitData(),this.getAround(),this.getKeySite(),this.getFunDiv()]).then(()=>{
|
|
|
|
|
// this.getFireFac()
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
|
|
this.getUnitData() |
|
|
|
|
this.getAround() |
|
|
|
|
this.getKeySite() |
|
|
|
|
this.getFunDiv() |
|
|
|
|
this.getFireFac() |
|
|
|
|
} |
|
|
|
|
//当前选中的单位
|
|
|
|
|
selectedUnitIndex = 0 |
|
|
|
@ -48,18 +50,19 @@ export class CreateTestScoreComponent implements OnInit {
|
|
|
|
|
unitId:any = JSON.parse(sessionStorage.getItem('checkedWork'))
|
|
|
|
|
|
|
|
|
|
//获取单位基本信息
|
|
|
|
|
getUnitData(){ |
|
|
|
|
|
|
|
|
|
this.unitId.forEach((element,index) => { |
|
|
|
|
element.score = 0 |
|
|
|
|
element.basicInfoScore = 0 |
|
|
|
|
element.basicInfoItemScore = 0 |
|
|
|
|
|
|
|
|
|
async getUnitData(){ |
|
|
|
|
let that = this |
|
|
|
|
for (let y = 0, length = this.unitId.length; y < length; y++){ |
|
|
|
|
let element = this.unitId[y] |
|
|
|
|
element.score = 0 |
|
|
|
|
element.basicInfoScore = 0 |
|
|
|
|
element.basicInfoItemScore = 0 |
|
|
|
|
let result1 = await new Promise((resolve, reject) => { |
|
|
|
|
this.http.get(`/api/Companies/${element.id}`).subscribe((data:any)=>{ |
|
|
|
|
let unitData = { |
|
|
|
|
name: '单位信息', |
|
|
|
|
type:'基本信息', |
|
|
|
|
expanded: false, |
|
|
|
|
expanded: true, |
|
|
|
|
key:(Math.random()*10000000).toString(16).substr(0,4)+(new Date()).getTime()+Math.random().toString().substr(2,5), |
|
|
|
|
children:[] |
|
|
|
|
} |
|
|
|
@ -84,113 +87,117 @@ export class CreateTestScoreComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
element.basicInfoNodes = [] |
|
|
|
|
element.basicInfoNodes.push(unitData) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
resolve(1) |
|
|
|
|
})
|
|
|
|
|
}).then(async ()=>{ |
|
|
|
|
let result2 = await new Promise((resolve, reject) => { |
|
|
|
|
var buildingsData:any |
|
|
|
|
this.http.get("/api/Buildings",{ |
|
|
|
|
params:{ |
|
|
|
|
companyId:element.id |
|
|
|
|
} |
|
|
|
|
}).subscribe(async (data:any)=>{ |
|
|
|
|
buildingsData = data |
|
|
|
|
for (let i = 0, length = data.length; i < length; i++){ |
|
|
|
|
const result = await new Promise((resolve) =>{ |
|
|
|
|
this.http.get("/api/BuildingBasicInfos",{ // 循环请求当前单位建筑每一个建筑的信息保存到数组中
|
|
|
|
|
params:{ |
|
|
|
|
companyId :element.id, |
|
|
|
|
buildingId:data[i].id, |
|
|
|
|
buildingType:data[i].buildingTypes[0].id |
|
|
|
|
} |
|
|
|
|
}).subscribe((buildingsData:any)=>{ |
|
|
|
|
buildingsData.name = data[i].name |
|
|
|
|
buildingsData.buildingType = data[i].buildingTypes[0].name |
|
|
|
|
buildingsData[0].buildingBasicGroups.forEach((y,m) => { |
|
|
|
|
let propertyInfosArr = [] |
|
|
|
|
let tabledata |
|
|
|
|
if(y.type == 1){//如果是表格类
|
|
|
|
|
var map = {}, |
|
|
|
|
dest:any = []; |
|
|
|
|
for(var i = 0; i < y.propertyInfos.length; i++){ |
|
|
|
|
var ai = y.propertyInfos[i]; |
|
|
|
|
if(!map[ai.propertyName]){ |
|
|
|
|
dest.push({ |
|
|
|
|
propertyName: ai.propertyName, |
|
|
|
|
data: [ai] |
|
|
|
|
}); |
|
|
|
|
map[ai.propertyName] = ai; |
|
|
|
|
}else{ |
|
|
|
|
for(var j = 0; j < dest.length; j++){ |
|
|
|
|
var dj = dest[j]; |
|
|
|
|
if(dj.propertyName == ai.propertyName){ |
|
|
|
|
dj.data.push(ai); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
await getAllBuildingData(data) |
|
|
|
|
resolve(2) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
async function getAllBuildingData(data){ |
|
|
|
|
for (let i = 0, length = data.length; i < length; i++){ |
|
|
|
|
const result = await new Promise((resolve) =>{ |
|
|
|
|
that.http.get("/api/BuildingBasicInfos",{ // 循环请求当前单位建筑每一个建筑的信息保存到数组中
|
|
|
|
|
params:{ |
|
|
|
|
companyId :element.id, |
|
|
|
|
buildingId:data[i].id, |
|
|
|
|
buildingType:data[i].buildingTypes[0].id |
|
|
|
|
} |
|
|
|
|
}).subscribe((buildingsData:any)=>{ |
|
|
|
|
buildingsData.name = data[i].name |
|
|
|
|
buildingsData.buildingType = data[i].buildingTypes[0].name |
|
|
|
|
buildingsData[0].buildingBasicGroups.forEach((y,m) => { |
|
|
|
|
let propertyInfosArr = [] |
|
|
|
|
let tabledata |
|
|
|
|
if(y.type == 1){//如果是表格类
|
|
|
|
|
var map = {}, |
|
|
|
|
dest:any = []; |
|
|
|
|
for(var i = 0; i < y.propertyInfos.length; i++){ |
|
|
|
|
var ai = y.propertyInfos[i]; |
|
|
|
|
if(!map[ai.propertyName]){ |
|
|
|
|
dest.push({ |
|
|
|
|
propertyName: ai.propertyName, |
|
|
|
|
data: [ai] |
|
|
|
|
}); |
|
|
|
|
map[ai.propertyName] = ai; |
|
|
|
|
}else{ |
|
|
|
|
for(var j = 0; j < dest.length; j++){ |
|
|
|
|
var dj = dest[j]; |
|
|
|
|
if(dj.propertyName == ai.propertyName){ |
|
|
|
|
dj.data.push(ai); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//根据行数确定在循环数组中的index
|
|
|
|
|
dest.forEach(item => { |
|
|
|
|
item.data.sort(function(a,b){ |
|
|
|
|
return Number(a.tag) - Number(b.tag)
|
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
y.tabledata = dest |
|
|
|
|
tabledata = dest |
|
|
|
|
y.tabledata[0].data.forEach((x,key) => { |
|
|
|
|
if(x.propertyValue){ |
|
|
|
|
x.key = (Math.random()*10000000).toString(16).substr(0,4)+(new Date()).getTime()+Math.random().toString().substr(2,5) |
|
|
|
|
x.isLeaf = true |
|
|
|
|
x.name = x.propertyValue |
|
|
|
|
propertyInfosArr.push(x) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}else{ |
|
|
|
|
y.propertyInfos.forEach((x,key) => { |
|
|
|
|
if(x.propertyValue){ |
|
|
|
|
x.key = (Math.random()*10000000).toString(16).substr(0,4)+(new Date()).getTime()+Math.random().toString().substr(2,5) |
|
|
|
|
x.isLeaf = true |
|
|
|
|
x.name = x.propertyName |
|
|
|
|
propertyInfosArr.push(x) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
//根据行数确定在循环数组中的index
|
|
|
|
|
dest.forEach(item => { |
|
|
|
|
item.data.sort(function(a,b){ |
|
|
|
|
return Number(a.tag) - Number(b.tag)
|
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
y.tabledata = dest |
|
|
|
|
tabledata = dest |
|
|
|
|
y.tabledata[0].data.forEach((x,key) => { |
|
|
|
|
if(x.propertyValue){ |
|
|
|
|
x.key = (Math.random()*10000000).toString(16).substr(0,4)+(new Date()).getTime()+Math.random().toString().substr(2,5) |
|
|
|
|
x.isLeaf = true |
|
|
|
|
x.name = x.propertyValue |
|
|
|
|
propertyInfosArr.push(x) |
|
|
|
|
} |
|
|
|
|
if(propertyInfosArr.length != 0){ |
|
|
|
|
element.basicInfoNodes.push({ |
|
|
|
|
name:y.name != '基本信息' ? buildingsData.name + '-' + y.name : buildingsData.name , |
|
|
|
|
type:'基本信息', |
|
|
|
|
expanded: false, |
|
|
|
|
key:(Math.random()*10000000).toString(16).substr(0,4)+(new Date()).getTime()+Math.random().toString().substr(2,5), |
|
|
|
|
children:propertyInfosArr, |
|
|
|
|
tabledata:tabledata ? tabledata : null |
|
|
|
|
}) |
|
|
|
|
element.basicInfoNodes = [...element.basicInfoNodes] |
|
|
|
|
}) |
|
|
|
|
}else{ |
|
|
|
|
y.propertyInfos.forEach((x,key) => { |
|
|
|
|
if(x.propertyValue){ |
|
|
|
|
x.key = (Math.random()*10000000).toString(16).substr(0,4)+(new Date()).getTime()+Math.random().toString().substr(2,5) |
|
|
|
|
x.isLeaf = true |
|
|
|
|
x.name = x.propertyName |
|
|
|
|
propertyInfosArr.push(x) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
resolve(i) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
if(propertyInfosArr.length != 0){ |
|
|
|
|
element.basicInfoNodes.push({ |
|
|
|
|
name:y.name != '基本信息' ? buildingsData.name + '-' + y.name : buildingsData.name , |
|
|
|
|
type:'基本信息', |
|
|
|
|
expanded: true, |
|
|
|
|
key:(Math.random()*10000000).toString(16).substr(0,4)+(new Date()).getTime()+Math.random().toString().substr(2,5), |
|
|
|
|
children:propertyInfosArr, |
|
|
|
|
tabledata:tabledata ? tabledata : null |
|
|
|
|
}) |
|
|
|
|
element.basicInfoNodes = [...element.basicInfoNodes] |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
resolve(i) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//获取四周毗邻数据
|
|
|
|
|
getAround(){ |
|
|
|
|
|
|
|
|
|
this.unitId.forEach((element,index) => { |
|
|
|
|
element.aroundScore = 0 |
|
|
|
|
element.aroundItemScore = 0 |
|
|
|
|
element.aroundNodes = [] |
|
|
|
|
//获得当前单位的单位毗邻
|
|
|
|
|
let id = {companyId:element.id} |
|
|
|
|
async getAround(){ |
|
|
|
|
let that = this |
|
|
|
|
for (let y = 0, length = this.unitId.length; y < length; y++){ |
|
|
|
|
let element = this.unitId[y] |
|
|
|
|
element.aroundScore = 0 |
|
|
|
|
element.aroundItemScore = 0 |
|
|
|
|
element.aroundNodes = [] |
|
|
|
|
//获得当前单位的单位毗邻
|
|
|
|
|
let id = {companyId:element.id} |
|
|
|
|
let result1 = await new Promise((resolve, reject) => { |
|
|
|
|
this.http.get('/api/CompanyAdjoins',{params:id}).subscribe((data:any)=>{ |
|
|
|
|
// console.log(index+'四周毗邻',data)
|
|
|
|
|
data.forEach(item => { |
|
|
|
|
item.direction == 0 ? item.title = '东方向' : null |
|
|
|
|
item.direction == 1 ? item.title = '西方向' : null |
|
|
|
@ -205,95 +212,113 @@ export class CreateTestScoreComponent implements OnInit {
|
|
|
|
|
}) |
|
|
|
|
//如果存在单位毗邻
|
|
|
|
|
if(data.length != 0){ |
|
|
|
|
this.unitId[index].aroundNodes.push({ |
|
|
|
|
this.unitId[y].aroundNodes.push({ |
|
|
|
|
name: '单位毗邻', |
|
|
|
|
key: (Math.random()*10000000).toString(16).substr(0,4)+(new Date()).getTime()+Math.random().toString().substr(2,5), |
|
|
|
|
expanded: false, |
|
|
|
|
expanded: true, |
|
|
|
|
type:'四周毗邻', |
|
|
|
|
children: data |
|
|
|
|
}) |
|
|
|
|
element.aroundNodes = [...element.aroundNodes] |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
resolve(1) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
}).then(async ()=>{ |
|
|
|
|
//获得当前单位的建筑毗邻
|
|
|
|
|
this.http.get('/api/Buildings',{params:id}).subscribe((data:any)=>{ |
|
|
|
|
if (data.length) {
|
|
|
|
|
getAllArchitecture(data) |
|
|
|
|
} |
|
|
|
|
let result2 = await new Promise((resolve, reject) => { |
|
|
|
|
this.http.get('/api/Buildings',{params:id}).subscribe(async (data:any)=>{ |
|
|
|
|
if (data.length) {
|
|
|
|
|
await getAllArchitecture(data) |
|
|
|
|
resolve(2) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
let that = this |
|
|
|
|
async function getAllArchitecture(buildingsdata){ |
|
|
|
|
for (let i = 0, length = buildingsdata.length; i < length; i++){ |
|
|
|
|
let id = {buildingId:buildingsdata[i].id} |
|
|
|
|
let result = await new Promise((resolve, reject) => { |
|
|
|
|
that.http.get('/api/BuildingAdjoins',{params:id}).subscribe((data:any)=>{ |
|
|
|
|
data.forEach(item => { |
|
|
|
|
item.direction == 0 ? item.title = '东方向' : null |
|
|
|
|
item.direction == 1 ? item.title = '西方向' : null |
|
|
|
|
item.direction == 2 ? item.title = '南方向' : null |
|
|
|
|
item.direction == 3 ? item.title = '北方向' : null |
|
|
|
|
item.direction == 4 ? item.title = '东南方向' : null |
|
|
|
|
item.direction == 5 ? item.title = '西南方向' : null |
|
|
|
|
item.direction == 6 ? item.title = '东北方向' : null |
|
|
|
|
item.direction == 7 ? item.title = '西北方向' : null |
|
|
|
|
item.isLeaf = true |
|
|
|
|
item.key = item.id |
|
|
|
|
}) |
|
|
|
|
if(data.length != 0){ |
|
|
|
|
that.unitId[index].aroundNodes.push({ |
|
|
|
|
name: buildingsdata[i].name, |
|
|
|
|
key: (Math.random()*10000000).toString(16).substr(0,4)+(new Date()).getTime()+Math.random().toString().substr(2,5), |
|
|
|
|
expanded: false, |
|
|
|
|
type:'四周毗邻', |
|
|
|
|
children: data |
|
|
|
|
}) |
|
|
|
|
element.aroundNodes = [...element.aroundNodes] |
|
|
|
|
} |
|
|
|
|
resolve('1') |
|
|
|
|
}) |
|
|
|
|
async function getAllArchitecture(buildingsdata){ |
|
|
|
|
for (let i = 0, length = buildingsdata.length; i < length; i++){ |
|
|
|
|
let id = {buildingId:buildingsdata[i].id} |
|
|
|
|
let result = await new Promise((resolve, reject) => { |
|
|
|
|
that.http.get('/api/BuildingAdjoins',{params:id}).subscribe((data:any)=>{ |
|
|
|
|
data.forEach(item => { |
|
|
|
|
item.direction == 0 ? item.title = '东方向' : null |
|
|
|
|
item.direction == 1 ? item.title = '西方向' : null |
|
|
|
|
item.direction == 2 ? item.title = '南方向' : null |
|
|
|
|
item.direction == 3 ? item.title = '北方向' : null |
|
|
|
|
item.direction == 4 ? item.title = '东南方向' : null |
|
|
|
|
item.direction == 5 ? item.title = '西南方向' : null |
|
|
|
|
item.direction == 6 ? item.title = '东北方向' : null |
|
|
|
|
item.direction == 7 ? item.title = '西北方向' : null |
|
|
|
|
item.isLeaf = true |
|
|
|
|
item.key = item.id |
|
|
|
|
}) |
|
|
|
|
})
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(data.length != 0){ |
|
|
|
|
that.unitId[y].aroundNodes.push({ |
|
|
|
|
name: buildingsdata[i].name, |
|
|
|
|
key: (Math.random()*10000000).toString(16).substr(0,4)+(new Date()).getTime()+Math.random().toString().substr(2,5), |
|
|
|
|
expanded: true, |
|
|
|
|
type:'四周毗邻', |
|
|
|
|
children: data |
|
|
|
|
}) |
|
|
|
|
element.aroundNodes = [...element.aroundNodes] |
|
|
|
|
} |
|
|
|
|
resolve(1) |
|
|
|
|
}) |
|
|
|
|
})
|
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//获取重点部位
|
|
|
|
|
getKeySite(){ |
|
|
|
|
async getKeySite(){ |
|
|
|
|
let that = this |
|
|
|
|
this.unitId.forEach((element,index) =>{ |
|
|
|
|
for (let y = 0, length = this.unitId.length; y < length; y++){ |
|
|
|
|
console.log("xiba") |
|
|
|
|
let element = this.unitId[y] |
|
|
|
|
element.keySiteScore = 0 |
|
|
|
|
element.keySiteItemScore = 0 |
|
|
|
|
element.keySiteNodes = [] |
|
|
|
|
//获得单位重点部位
|
|
|
|
|
let id = {companyId:element.id} |
|
|
|
|
this.http.get('/api/CompanyImportantLocations',{params:id}).subscribe((data:any)=>{ |
|
|
|
|
//如果存在单位毗邻
|
|
|
|
|
let newData = [] |
|
|
|
|
data.forEach(item => { |
|
|
|
|
item.isLeaf = true |
|
|
|
|
item.key = item.id |
|
|
|
|
item.name ? newData.push(item) : null |
|
|
|
|
|
|
|
|
|
let result1 = await new Promise((resolve, reject) => { |
|
|
|
|
this.http.get('/api/CompanyImportantLocations',{params:id}).subscribe((data:any)=>{ |
|
|
|
|
//如果存在单位毗邻
|
|
|
|
|
let newData = [] |
|
|
|
|
data.forEach(item => { |
|
|
|
|
item.isLeaf = true |
|
|
|
|
item.key = item.id |
|
|
|
|
item.name ? newData.push(item) : null |
|
|
|
|
}) |
|
|
|
|
if(data.length != 0){ |
|
|
|
|
this.unitId[y].keySiteNodes.push({ |
|
|
|
|
name: '单位重点部位', |
|
|
|
|
key: (Math.random()*10000000).toString(16).substr(0,4)+(new Date()).getTime()+Math.random().toString().substr(2,5), |
|
|
|
|
expanded: true, |
|
|
|
|
type:'重点部位', |
|
|
|
|
children: newData |
|
|
|
|
}) |
|
|
|
|
element.keySiteNodes = [...element.keySiteNodes] |
|
|
|
|
} |
|
|
|
|
resolve(1) |
|
|
|
|
}) |
|
|
|
|
if(data.length != 0){ |
|
|
|
|
this.unitId[index].keySiteNodes.push({ |
|
|
|
|
name: '单位重点部位', |
|
|
|
|
key: (Math.random()*10000000).toString(16).substr(0,4)+(new Date()).getTime()+Math.random().toString().substr(2,5), |
|
|
|
|
expanded: false, |
|
|
|
|
type:'重点部位', |
|
|
|
|
children: newData |
|
|
|
|
}).then(async ()=>{ |
|
|
|
|
//获得建筑重点部位
|
|
|
|
|
let result2 = await new Promise((resolve, reject) => { |
|
|
|
|
this.http.get('/api/Buildings',{params:id}).subscribe(async (data:any)=>{ |
|
|
|
|
if (data.length) {
|
|
|
|
|
await getAllBuildingPositon(data) |
|
|
|
|
resolve(2) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
element.keySiteNodes = [...element.keySiteNodes] |
|
|
|
|
}}) |
|
|
|
|
|
|
|
|
|
//获得建筑重点部位
|
|
|
|
|
this.http.get('/api/Buildings',{params:id}).subscribe((data:any)=>{ |
|
|
|
|
if (data.length) {
|
|
|
|
|
getAllBuildingPositon(data) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取当前单位所有建筑重点部位
|
|
|
|
|
async function getAllBuildingPositon (buildingsdata) { |
|
|
|
|
for (let i = 0, length = buildingsdata.length; i < length; i++){ |
|
|
|
@ -307,10 +332,10 @@ export class CreateTestScoreComponent implements OnInit {
|
|
|
|
|
item.name ? newData.push(item) : null |
|
|
|
|
}) |
|
|
|
|
if(newData.length != 0){ |
|
|
|
|
that.unitId[index].keySiteNodes.push({ |
|
|
|
|
that.unitId[y].keySiteNodes.push({ |
|
|
|
|
name: buildingsdata[i].name, |
|
|
|
|
key: (Math.random()*10000000).toString(16).substr(0,4)+(new Date()).getTime()+Math.random().toString().substr(2,5), |
|
|
|
|
expanded: false, |
|
|
|
|
expanded: true, |
|
|
|
|
type:'重点部位', |
|
|
|
|
children: newData |
|
|
|
|
}) |
|
|
|
@ -322,46 +347,54 @@ export class CreateTestScoreComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
//获取单位重点部位
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
} |
|
|
|
|
//获取功能分区
|
|
|
|
|
getFunDiv(){ |
|
|
|
|
async getFunDiv(){ |
|
|
|
|
let that = this |
|
|
|
|
this.unitId.forEach((element,index) =>{ |
|
|
|
|
for (let y = 0, length = this.unitId.length; y < length; y++){ |
|
|
|
|
let element = this.unitId[y] |
|
|
|
|
element.funDivScore = 0 |
|
|
|
|
element.funDivItemScore = 0 |
|
|
|
|
element.funDivNodes = [] |
|
|
|
|
let id = {companyId:element.id} |
|
|
|
|
//单位功能分区
|
|
|
|
|
this.http.get('/api/CompanyFunctionalDivisions',{params:id}).subscribe((data:any)=>{ |
|
|
|
|
//如果存在单位的单位功能分区
|
|
|
|
|
let newData = [] |
|
|
|
|
data.forEach(item => { |
|
|
|
|
item.isLeaf = true |
|
|
|
|
item.key = item.id |
|
|
|
|
item.region ? newData.push(item) : null |
|
|
|
|
let result1 = await new Promise((resolve, reject) => { |
|
|
|
|
this.http.get('/api/CompanyFunctionalDivisions',{params:id}).subscribe((data:any)=>{ |
|
|
|
|
//如果存在单位的单位功能分区
|
|
|
|
|
let newData = [] |
|
|
|
|
data.forEach(item => { |
|
|
|
|
item.isLeaf = true |
|
|
|
|
item.key = item.id |
|
|
|
|
item.region ? newData.push(item) : null |
|
|
|
|
}) |
|
|
|
|
if(data.length != 0){ |
|
|
|
|
this.unitId[y].funDivNodes.push({ |
|
|
|
|
name: '单位功能分区', |
|
|
|
|
key: (Math.random()*10000000).toString(16).substr(0,4)+(new Date()).getTime()+Math.random().toString().substr(2,5), |
|
|
|
|
expanded: true, |
|
|
|
|
type:'功能分区', |
|
|
|
|
children: newData |
|
|
|
|
}) |
|
|
|
|
element.funDivNodes = [...element.funDivNodes] |
|
|
|
|
}
|
|
|
|
|
resolve(1) |
|
|
|
|
}) |
|
|
|
|
if(data.length != 0){ |
|
|
|
|
this.unitId[index].funDivNodes.push({ |
|
|
|
|
name: '单位功能分区', |
|
|
|
|
key: (Math.random()*10000000).toString(16).substr(0,4)+(new Date()).getTime()+Math.random().toString().substr(2,5), |
|
|
|
|
expanded: false, |
|
|
|
|
type:'功能分区', |
|
|
|
|
children: newData |
|
|
|
|
}).then(async ()=>{ |
|
|
|
|
//建筑功能分区
|
|
|
|
|
let result2 = await new Promise((resolve, reject) => { |
|
|
|
|
this.http.get('/api/Buildings',{params:id}).subscribe(async (data:any)=>{ |
|
|
|
|
if (data.length) {
|
|
|
|
|
await getAllBuildingFunDiv(data) |
|
|
|
|
resolve(2) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
element.funDivNodes = [...element.funDivNodes] |
|
|
|
|
}
|
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
//建筑功能分区
|
|
|
|
|
this.http.get('/api/Buildings',{params:id}).subscribe((data:any)=>{ |
|
|
|
|
if (data.length) {
|
|
|
|
|
getAllBuildingFunDiv(data) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取当前单位所有建筑功能分区
|
|
|
|
|
async function getAllBuildingFunDiv (buildingsdata) { |
|
|
|
|
for (let i = 0, length = buildingsdata.length; i < length; i++){ |
|
|
|
@ -377,10 +410,10 @@ export class CreateTestScoreComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
}) |
|
|
|
|
if(newData.length != 0){ |
|
|
|
|
that.unitId[index].funDivNodes.push({ |
|
|
|
|
that.unitId[y].funDivNodes.push({ |
|
|
|
|
name: buildingsdata[i].name, |
|
|
|
|
key: (Math.random()*10000000).toString(16).substr(0,4)+(new Date()).getTime()+Math.random().toString().substr(2,5), |
|
|
|
|
expanded: false, |
|
|
|
|
expanded: true, |
|
|
|
|
type:'功能分区', |
|
|
|
|
children: newData |
|
|
|
|
}) |
|
|
|
@ -393,7 +426,7 @@ export class CreateTestScoreComponent implements OnInit {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//获取消防设施
|
|
|
|
|
getFireFac(){ |
|
|
|
@ -426,7 +459,7 @@ export class CreateTestScoreComponent implements OnInit {
|
|
|
|
|
this.unitId[index].fireFacNodes.push({ |
|
|
|
|
name: '单位消防设施', |
|
|
|
|
key: (Math.random()*10000000).toString(16).substr(0,4)+(new Date()).getTime()+Math.random().toString().substr(2,5), |
|
|
|
|
expanded: false, |
|
|
|
|
expanded: true, |
|
|
|
|
type:'消防设施', |
|
|
|
|
children: newData |
|
|
|
|
}) |
|
|
|
@ -442,6 +475,7 @@ export class CreateTestScoreComponent implements OnInit {
|
|
|
|
|
}}).subscribe((data:any)=>{ |
|
|
|
|
if (data.length != 0) { getAllBuildingFireFac(data) } |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
async function getAllBuildingFireFac (buildingsdata) { |
|
|
|
|
// console.log('建筑'+index,buildingsdata)
|
|
|
|
|
for (let i = 0, length = buildingsdata.length; i < length; i++){ |
|
|
|
@ -467,7 +501,7 @@ export class CreateTestScoreComponent implements OnInit {
|
|
|
|
|
that.unitId[index].fireFacNodes.push({ |
|
|
|
|
name: buildingsdata[i].name, |
|
|
|
|
key: buildingsdata[i].id, |
|
|
|
|
expanded: false, |
|
|
|
|
expanded: true, |
|
|
|
|
type:'消防设施', |
|
|
|
|
children: newData |
|
|
|
|
}) |
|
|
|
@ -677,13 +711,13 @@ export class CreateTestScoreComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
//添加预案
|
|
|
|
|
addPlan(){ |
|
|
|
|
let companyId = { |
|
|
|
|
companyId : this.unitId[this.selectedUnitIndex].id |
|
|
|
|
let companyData = { |
|
|
|
|
companyData : this.unitId[this.selectedUnitIndex] |
|
|
|
|
} |
|
|
|
|
const dialogRef = this.dialog.open(AddPlanDialog, { |
|
|
|
|
width: '380px', |
|
|
|
|
height: '136px', |
|
|
|
|
data: companyId |
|
|
|
|
data: companyData |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
dialogRef.afterClosed().subscribe(result => { |
|
|
|
@ -803,8 +837,9 @@ export class CreateTestScoreComponent implements OnInit {
|
|
|
|
|
i.children = newChildren |
|
|
|
|
delete i.selected |
|
|
|
|
}) |
|
|
|
|
console.log(111,item) |
|
|
|
|
//建筑的重点部位模块处理
|
|
|
|
|
item.keySiteNodes.forEach((i,key) => { |
|
|
|
|
item.keySiteNodes ? item.keySiteNodes.forEach((i,key) => { |
|
|
|
|
i.selected ? i.selected = null : null |
|
|
|
|
//如果顶级节点未选中则需要筛除没有选中的数据
|
|
|
|
|
if(!i.checked){ |
|
|
|
@ -878,9 +913,9 @@ export class CreateTestScoreComponent implements OnInit {
|
|
|
|
|
delete i.selected |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
|
|
}) : null |
|
|
|
|
//建筑的功能分区模块处理
|
|
|
|
|
item.funDivNodes.forEach((i,key) => { |
|
|
|
|
item.funDivNodes ? item.funDivNodes.forEach((i,key) => { |
|
|
|
|
|
|
|
|
|
//如果顶级节点未选中则需要筛除没有选中的数据
|
|
|
|
|
if(!i.checked){ |
|
|
|
@ -935,9 +970,9 @@ export class CreateTestScoreComponent implements OnInit {
|
|
|
|
|
}) |
|
|
|
|
i.children = newChildren |
|
|
|
|
delete i.selected |
|
|
|
|
}) |
|
|
|
|
}) : null |
|
|
|
|
//建筑的数据核验模块处理
|
|
|
|
|
item.fireFacNodes.forEach((i,key) => { |
|
|
|
|
item.fireFacNodes ? item.fireFacNodes.forEach((i,key) => { |
|
|
|
|
i.selected ? i.selected = null : null |
|
|
|
|
//如果顶级节点未选中则需要筛除没有选中的数据
|
|
|
|
|
if(!i.checked){ |
|
|
|
@ -962,7 +997,7 @@ export class CreateTestScoreComponent implements OnInit {
|
|
|
|
|
}) |
|
|
|
|
i.children = newChildren |
|
|
|
|
delete i.selected |
|
|
|
|
}) |
|
|
|
|
}) : null |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
//循环每个建筑处理数据
|
|
|
|
@ -974,15 +1009,15 @@ export class CreateTestScoreComponent implements OnInit {
|
|
|
|
|
paperDataInfo[key].id = null |
|
|
|
|
paperDataInfo[key].paperId = null |
|
|
|
|
paperDataInfo[key].companyId = item.id |
|
|
|
|
paperDataInfo[key].basicInfoData = JSON.stringify(item.basicInfoNodes)
|
|
|
|
|
paperDataInfo[key].basicInfoData = item.basicInfoNodes ? JSON.stringify(item.basicInfoNodes) : '[]' |
|
|
|
|
paperDataInfo[key].basicInfoScore = item.basicInfoScore |
|
|
|
|
paperDataInfo[key].adjoinData = JSON.stringify(item.aroundNodes) |
|
|
|
|
paperDataInfo[key].adjoinData = item.aroundNodes ? JSON.stringify(item.aroundNodes) : '[]' |
|
|
|
|
paperDataInfo[key].adjoinScore = item.aroundScore |
|
|
|
|
paperDataInfo[key].importLocationData = JSON.stringify(item.keySiteNodes) |
|
|
|
|
paperDataInfo[key].importLocationData = item.keySiteNodes ? JSON.stringify(item.keySiteNodes) : '[]' |
|
|
|
|
paperDataInfo[key].importLocationScore = item.keySiteScore |
|
|
|
|
paperDataInfo[key].functionalDivisionData = JSON.stringify(item.funDivNodes) |
|
|
|
|
paperDataInfo[key].functionalDivisionData = item.funDivNodes ? JSON.stringify(item.funDivNodes) : '[]' |
|
|
|
|
paperDataInfo[key].functionalDivisionScore = item.funDivScore |
|
|
|
|
paperDataInfo[key].facilityData = JSON.stringify(item.fireFacNodes) |
|
|
|
|
paperDataInfo[key].facilityData = item.fireFacNodes ? JSON.stringify(item.fireFacNodes) : '[]' |
|
|
|
|
paperDataInfo[key].facilityScore = item.fireFacScore |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
@ -1026,7 +1061,7 @@ export class AddPlanDialog {
|
|
|
|
|
selectType(type){ |
|
|
|
|
let obj = { |
|
|
|
|
type:type, |
|
|
|
|
companyId:this.data.companyId |
|
|
|
|
companyData:this.data |
|
|
|
|
} |
|
|
|
|
const dialogRef = this.dialog.open(AddPlanTwoDialog, { |
|
|
|
|
id:'addPlanTwo', |
|
|
|
@ -1034,7 +1069,7 @@ export class AddPlanDialog {
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
dialogRef.afterClosed().subscribe(result => { |
|
|
|
|
console.log('The dialog was closed'); |
|
|
|
|
this.dialogRef.close(); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -1048,27 +1083,27 @@ export class AddPlanDialog {
|
|
|
|
|
}) |
|
|
|
|
export class AddPlanTwoDialog { |
|
|
|
|
|
|
|
|
|
constructor(private http: HttpClient,public dialog: MatDialog,public dialogRef: MatDialogRef<AddPlanTwoDialog>,@Inject(MAT_DIALOG_DATA) public data: any) {} |
|
|
|
|
constructor(public snackBar: MatSnackBar,private http: HttpClient,public dialog: MatDialog,public dialogRef: MatDialogRef<AddPlanTwoDialog>,@Inject(MAT_DIALOG_DATA) public data: any) {} |
|
|
|
|
|
|
|
|
|
planType:any = this.data.type == 1 ? true : false//显示的预案类型
|
|
|
|
|
displayedColumns: string[] = ['select', 'name', 'people', 'time', 'level']; |
|
|
|
|
dataSource : any //列表数据
|
|
|
|
|
selectedradio |
|
|
|
|
selectedRadioData:any//当前选择的二维预案
|
|
|
|
|
customPlanName:any//自定义预案名称
|
|
|
|
|
radioChange(e){ |
|
|
|
|
console.log(e) |
|
|
|
|
this.selectedRadioData = e |
|
|
|
|
} |
|
|
|
|
ngOnInit(): void { |
|
|
|
|
// console.log(this.data.companyId)
|
|
|
|
|
this.get2DPlan() |
|
|
|
|
console.log(this.data) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//获取当前公司的二维预案
|
|
|
|
|
get2DPlan(){ |
|
|
|
|
let planArr = [] |
|
|
|
|
this.http.get('/api/PlanComponents',{params:{ |
|
|
|
|
companyId:this.data.companyId |
|
|
|
|
companyId:this.data.companyData.companyData.id |
|
|
|
|
}}).subscribe((data:any) => { |
|
|
|
|
console.log(123,data) |
|
|
|
|
data.items.forEach(item => { |
|
|
|
|
item.planType == 1 ? planArr.push(item) : null |
|
|
|
|
}) |
|
|
|
@ -1081,10 +1116,44 @@ export class AddPlanTwoDialog {
|
|
|
|
|
} |
|
|
|
|
//确定
|
|
|
|
|
confirm(){ |
|
|
|
|
if(this.planType == 1){ |
|
|
|
|
|
|
|
|
|
}else{ |
|
|
|
|
if(this.planType){//如果选择的是已存在预案
|
|
|
|
|
if(this.selectedRadioData){ |
|
|
|
|
this.dialogRef.close(); |
|
|
|
|
sessionStorage.setItem('companyName',this.data.companyData.companyData.name) |
|
|
|
|
sessionStorage.setItem('planId',this.selectedRadioData.id) |
|
|
|
|
sessionStorage.setItem('buildingTypeId',this.data.companyData.companyData.buildingTypes[0].id) |
|
|
|
|
sessionStorage.setItem('companyId',this.data.companyData.companyData.id) |
|
|
|
|
window.open('/canvasTool') |
|
|
|
|
}else{ |
|
|
|
|
const config = new MatSnackBarConfig(); |
|
|
|
|
config.verticalPosition = 'top'; |
|
|
|
|
config.duration = 3000 |
|
|
|
|
this.snackBar.open('请选择要添加的预案','确定',config); |
|
|
|
|
} |
|
|
|
|
}else{//如果选择的是自定义预案
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let level = sessionStorage.getItem('level') |
|
|
|
|
let body = { |
|
|
|
|
id: "", |
|
|
|
|
name: this.customPlanName, |
|
|
|
|
planType:1, |
|
|
|
|
planMode: 2, |
|
|
|
|
planLevel:Number(level), |
|
|
|
|
url: "", |
|
|
|
|
attachmentUrls: null |
|
|
|
|
} |
|
|
|
|
this.http.post("/api/PlanComponents2D",body,{params:{ |
|
|
|
|
companyId : this.data.companyData.companyData.id |
|
|
|
|
}}).subscribe((data:any)=>{ |
|
|
|
|
// console.log("创建成功")
|
|
|
|
|
this.dialogRef.close(data); |
|
|
|
|
sessionStorage.setItem("planId",data.id); |
|
|
|
|
sessionStorage.setItem("companyId",this.data.companyData.companyData.id) |
|
|
|
|
sessionStorage.setItem("buildingTypeId",this.data.companyData.companyData.buildingTypes[0].id) |
|
|
|
|
sessionStorage.setItem("editable","1") |
|
|
|
|
window.open('/canvasTool') |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//取消
|
|
|
|
|