|
@ -246,37 +246,53 @@ async function delPosition (ctx, next) { |
|
|
if (pointOne) { |
|
|
if (pointOne) { |
|
|
const patrolPlanLIst = await models.PatrolPlan.findAll({ |
|
|
const patrolPlanLIst = await models.PatrolPlan.findAll({ |
|
|
where: { |
|
|
where: { |
|
|
structureId: pointOne.id, |
|
|
structureId: pointOne.projectId, |
|
|
}, |
|
|
}, |
|
|
attributes: ['id', 'structureId', 'points'], |
|
|
|
|
|
}) |
|
|
}) |
|
|
patrolPlanLIst.map(async v => { |
|
|
|
|
|
|
|
|
for (var u of patrolPlanLIst) { |
|
|
const points = [] |
|
|
const points = [] |
|
|
v.points.map(r => { |
|
|
u.points.map(r => { |
|
|
if (r.id !== id) { |
|
|
if (r.id == id) { |
|
|
|
|
|
} else { |
|
|
points.push(r) |
|
|
points.push(r) |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
v.points = points |
|
|
u.points = points |
|
|
|
|
|
|
|
|
await models.PatrolRecord.destroy({ |
|
|
await models.PatrolRecord.destroy({ |
|
|
where: { |
|
|
where: { |
|
|
pointId: id, |
|
|
pointId: id, |
|
|
patrolPlanId: v.id |
|
|
patrolPlanId: u.id |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
if (points.length > 0) { |
|
|
if (points.length > 0) { |
|
|
await models.PatrolPlan.create(v) |
|
|
let data = { |
|
|
|
|
|
name: u.dataValues.name, |
|
|
|
|
|
way: u.dataValues.way, |
|
|
|
|
|
structureId: u.dataValues.structureId, |
|
|
|
|
|
startTime: u.dataValues.startTime, |
|
|
|
|
|
endTime: u.dataValues.endTime, |
|
|
|
|
|
frequency: u.dataValues.frequency, |
|
|
|
|
|
points: u.dataValues.points, |
|
|
|
|
|
userId: u.dataValues.userId, |
|
|
|
|
|
patrolCount: u.dataValues.patrolCount |
|
|
|
|
|
} |
|
|
|
|
|
await models.PatrolPlan.update(data,{ |
|
|
|
|
|
where: { |
|
|
|
|
|
id: u.dataValues.id |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
} else { |
|
|
} else { |
|
|
await models.PatrolPlan.destroy({ |
|
|
await models.PatrolPlan.destroy({ |
|
|
where: { |
|
|
where: { |
|
|
id: v.id |
|
|
id: u.id |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
await models.Point.destroy({ |
|
|
await models.Point.destroy({ |
|
|