|
|
@ -246,37 +246,53 @@ async function delPosition (ctx, next) { |
|
|
|
if (pointOne) { |
|
|
|
const patrolPlanLIst = await models.PatrolPlan.findAll({ |
|
|
|
where: { |
|
|
|
structureId: pointOne.id, |
|
|
|
structureId: pointOne.projectId, |
|
|
|
}, |
|
|
|
attributes: ['id', 'structureId', 'points'], |
|
|
|
}) |
|
|
|
patrolPlanLIst.map(async v => { |
|
|
|
|
|
|
|
for (var u of patrolPlanLIst) { |
|
|
|
const points = [] |
|
|
|
v.points.map(r => { |
|
|
|
if (r.id !== id) { |
|
|
|
u.points.map(r => { |
|
|
|
if (r.id == id) { |
|
|
|
} else { |
|
|
|
points.push(r) |
|
|
|
} |
|
|
|
}) |
|
|
|
v.points = points |
|
|
|
u.points = points |
|
|
|
|
|
|
|
await models.PatrolRecord.destroy({ |
|
|
|
where: { |
|
|
|
pointId: id, |
|
|
|
patrolPlanId: v.id |
|
|
|
patrolPlanId: u.id |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
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 { |
|
|
|
await models.PatrolPlan.destroy({ |
|
|
|
where: { |
|
|
|
id: v.id |
|
|
|
id: u.id |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
await models.Point.destroy({ |
|
|
|