|
|
@ -6,7 +6,7 @@ const moment = require("moment"); |
|
|
|
function getPlanCount(startTime,endTime,frequencyUnit){ |
|
|
|
switch(frequencyUnit){ |
|
|
|
case '天': |
|
|
|
return Math.ceil(moment(endTime).diff(startTime, 'days')) |
|
|
|
return Math.ceil(moment(endTime).diff(startTime, 'days'))+1 |
|
|
|
case '周': |
|
|
|
return Math.ceil(moment(endTime).diff(startTime, 'weeks')) |
|
|
|
case '月': |
|
|
@ -61,7 +61,7 @@ async function findPatrolRecords(ctx, next) { |
|
|
|
}) |
|
|
|
planCount=getPlanCount(startTime,endTime,frequencyUnit) |
|
|
|
|
|
|
|
} else if (moment(c.startTime).isSameOrAfter(moment(startTime)) && moment(c.startTime).isSameOrBefore(moment(endTime))) { |
|
|
|
} else if (moment(c.startTime).isSameOrAfter(moment(startTime)) && moment(c.endTime).isSameOrBefore(moment(endTime))) { |
|
|
|
done = await models.PatrolRecord.count({ |
|
|
|
where: { |
|
|
|
inspectionTime: { $between: [c.startTime, endTime] }, |
|
|
@ -77,15 +77,15 @@ async function findPatrolRecords(ctx, next) { |
|
|
|
patrolPlanId: c.id |
|
|
|
} |
|
|
|
}) |
|
|
|
planCount=getPlanCount(c.startTime,endTime,frequencyUnit) |
|
|
|
} else if (moment(c.startTime).isAfter(moment(startTime)) && moment(c.endTime).isBefore(moment(endTime))) { |
|
|
|
planCount=getPlanCount(startTime,c.endTime,frequencyUnit) |
|
|
|
} else if (moment(c.startTime).isAfter(moment(startTime)) && moment(c.startTime).isBefore(moment(endTime))) { |
|
|
|
done = await models.PatrolRecord.count({ |
|
|
|
where: { |
|
|
|
inspectionTime: { $between: [c.startTime, c.endTime] }, |
|
|
|
patrolPlanId: c.id |
|
|
|
} |
|
|
|
}) |
|
|
|
planCount=getPlanCount(startTime,c.endTime,frequencyUnit) |
|
|
|
planCount=getPlanCount(c.startTime,endTime,frequencyUnit) |
|
|
|
} |
|
|
|
let dones = await models.PatrolRecord.count({ |
|
|
|
where: { |
|
|
|