constprojects=(awaitclient.query(`SELECT * FROM "project" WHERE type='管廊'`)).rows
// console.log(projects);
// 查所有管廊结构物下的点位
constpoints=projects.length?(awaitclient.query(`SELECT * FROM point WHERE project_id IN (${projects.map(item=>`'${item.id}'`).join(',')}, -1)`)).rows:[]
// console.log(points);
// 查所有结构物相关的巡检计划
constplans=projects.length?(awaitclient.query(`SELECT * FROM patrol_plan WHERE structure_id IN (${projects.map(item=>`'${item.id}'`).join(',')}, -1)`)).rows:[]
if(plans.length)
// 删除计划相关人员
awaitclient.query(`DELETE FROM patrol_plan_user WHERE patrol_plan_id IN (${plans.map(item=>`'${item.id}'`).join(',')},-1)`)
// 查所有巡检记录
constrecords=plans.length?(awaitclient.query(`SELECT * FROM patrol_record WHERE patrol_plan_id IN (${plans.map(item=>`'${item.id}'`).join(',')},-1)`)).rows:[]
if(records.length){
// 删除所有巡检问题
awaitclient.query(`DELETE FROM patrol_record_issue_handle WHERE patrol_record_id IN (${records.map(item=>`'${item.id}'`).join(',')},-1)`)
// 删除所有巡检记录
awaitclient.query(`DELETE FROM patrol_record WHERE patrol_plan_id IN (${plans.map(item=>`'${item.id}'`).join(',')},-1)`)
}
if(plans.length)
// 删除所有巡检计划
awaitclient.query(`DELETE FROM patrol_plan WHERE structure_id IN (${projects.map(item=>`'${item.id}'`).join(',')}, -1)`)