|
@@ -405,16 +405,11 @@ module.exports = app => {
|
|
|
const submitted = Array(12).fill(0);
|
|
const submitted = Array(12).fill(0);
|
|
|
const completed = Array(12).fill(0);
|
|
const completed = Array(12).fill(0);
|
|
|
const needsRectification = Array(12).fill(0);
|
|
const needsRectification = Array(12).fill(0);
|
|
|
- const currentYear = moment().year();
|
|
|
|
|
- let firstYear = Math.min(year, currentYear);
|
|
|
|
|
for (const row of rows) {
|
|
for (const row of rows) {
|
|
|
const reportYear = Number(row.report_year);
|
|
const reportYear = Number(row.report_year);
|
|
|
const completedYear = Number(row.completed_year);
|
|
const completedYear = Number(row.completed_year);
|
|
|
const reportMonth = Number(row.report_month);
|
|
const reportMonth = Number(row.report_month);
|
|
|
const completedMonth = Number(row.completed_month);
|
|
const completedMonth = Number(row.completed_month);
|
|
|
- for (const value of [reportYear, completedYear]) {
|
|
|
|
|
- if (value >= 1970 && value <= currentYear) firstYear = Math.min(firstYear, value);
|
|
|
|
|
- }
|
|
|
|
|
if (reportYear === year && reportMonth >= 1 && reportMonth <= 12) {
|
|
if (reportYear === year && reportMonth >= 1 && reportMonth <= 12) {
|
|
|
submitted[reportMonth - 1] += Number(row.inspection_count);
|
|
submitted[reportMonth - 1] += Number(row.inspection_count);
|
|
|
needsRectification[reportMonth - 1] += Number(row.rectification_count);
|
|
needsRectification[reportMonth - 1] += Number(row.rectification_count);
|
|
@@ -423,10 +418,8 @@ module.exports = app => {
|
|
|
completed[completedMonth - 1] += Number(row.inspection_count);
|
|
completed[completedMonth - 1] += Number(row.inspection_count);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- const years = [];
|
|
|
|
|
- for (let value = currentYear; value >= firstYear; value--) years.push(value);
|
|
|
|
|
return {
|
|
return {
|
|
|
- year, years, months: submitted.map((count, index) => (index + 1) + '月'), submitted, completed,
|
|
|
|
|
|
|
+ year, months: submitted.map((count, index) => year + '年' + (index + 1) + '月'), submitted, completed,
|
|
|
ratios: submitted.map((count, index) => (count ? Number((needsRectification[index] * 100 / count).toFixed(1)) : 0)),
|
|
ratios: submitted.map((count, index) => (count ? Number((needsRectification[index] * 100 / count).toFixed(1)) : 0)),
|
|
|
hasData: submitted.some(count => count > 0) || completed.some(count => count > 0),
|
|
hasData: submitted.some(count => count > 0) || completed.some(count => count > 0),
|
|
|
};
|
|
};
|