|
@ -240,12 +240,22 @@ async function addPatrolRecord(ctx, next) { |
|
|
const filterRecord = curPlanRecord.rows.filter(r => moment(r.inspectionTime).diff(sTime) >= 0 && moment(r.inspectionTime).diff(eTime) <= 0); |
|
|
const filterRecord = curPlanRecord.rows.filter(r => moment(r.inspectionTime).diff(sTime) >= 0 && moment(r.inspectionTime).diff(eTime) <= 0); |
|
|
const groupRecord = filterRecord.group(({ pointId }) => pointId); |
|
|
const groupRecord = filterRecord.group(({ pointId }) => pointId); |
|
|
let isComplete = true; |
|
|
let isComplete = true; |
|
|
curPatrolPlan.points.forEach(p => { |
|
|
for (const p of curPatrolPlan.points) { |
|
|
if (!groupRecord[p.id] || (pointId === p.id ? groupRecord[p.id].length + 1 : groupRecord[p.id].length) < frequency) { |
|
|
if (!groupRecord[p.id]) { |
|
|
isComplete = false; |
|
|
if (curPatrolPlan.points.length === 1 && frequency === 1) { |
|
|
return; |
|
|
continue; |
|
|
|
|
|
} else { |
|
|
|
|
|
isComplete = false; |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
if ((pointId === p.id ? groupRecord[p.id].length + 1 : groupRecord[p.id].length) < frequency) { |
|
|
|
|
|
isComplete = false; |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
}); |
|
|
} |
|
|
|
|
|
|
|
|
await models.PatrolPlan.update({ patrolCount, nextTime: isComplete ? eTime.format() : sTime.format() }, { |
|
|
await models.PatrolPlan.update({ patrolCount, nextTime: isComplete ? eTime.format() : sTime.format() }, { |
|
|
where: { id: patrolPlanId }, |
|
|
where: { id: patrolPlanId }, |
|
|
transaction |
|
|
transaction |
|
|