mirror of
https://github.com/n08i40k/schedule-parser-next.git
synced 2025-12-06 17:57:45 +03:00
Compare commits
2 Commits
f44fce2a0e
...
8c3f83ed00
| Author | SHA1 | Date | |
|---|---|---|---|
|
8c3f83ed00
|
|||
|
4d9b790c93
|
10
package-lock.json
generated
10
package-lock.json
generated
@@ -49,6 +49,7 @@
|
|||||||
"@types/express": "^5.0.0",
|
"@types/express": "^5.0.0",
|
||||||
"@types/jest": "^29.5.14",
|
"@types/jest": "^29.5.14",
|
||||||
"@types/jsdom": "^21.1.7",
|
"@types/jsdom": "^21.1.7",
|
||||||
|
"@types/lodash": "^4.17.16",
|
||||||
"@types/multer": "^1.4.12",
|
"@types/multer": "^1.4.12",
|
||||||
"@types/node": "^22.10.9",
|
"@types/node": "^22.10.9",
|
||||||
"@types/object-hash": "^3.0.6",
|
"@types/object-hash": "^3.0.6",
|
||||||
@@ -3946,6 +3947,13 @@
|
|||||||
"@types/node": "*"
|
"@types/node": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/lodash": {
|
||||||
|
"version": "4.17.16",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.16.tgz",
|
||||||
|
"integrity": "sha512-HX7Em5NYQAXKW+1T+FiuG27NGwzJfCX3s1GjOa7ujxZa52kjJLOr4FUxT+giF6Tgxv1e+/czV/iTtBw27WTU9g==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/@types/long": {
|
"node_modules/@types/long": {
|
||||||
"version": "4.0.2",
|
"version": "4.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.2.tgz",
|
||||||
@@ -9602,6 +9610,8 @@
|
|||||||
},
|
},
|
||||||
"node_modules/lodash": {
|
"node_modules/lodash": {
|
||||||
"version": "4.17.21",
|
"version": "4.17.21",
|
||||||
|
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
||||||
|
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/lodash.camelcase": {
|
"node_modules/lodash.camelcase": {
|
||||||
|
|||||||
@@ -61,6 +61,7 @@
|
|||||||
"@types/express": "^5.0.0",
|
"@types/express": "^5.0.0",
|
||||||
"@types/jest": "^29.5.14",
|
"@types/jest": "^29.5.14",
|
||||||
"@types/jsdom": "^21.1.7",
|
"@types/jsdom": "^21.1.7",
|
||||||
|
"@types/lodash": "^4.17.16",
|
||||||
"@types/multer": "^1.4.12",
|
"@types/multer": "^1.4.12",
|
||||||
"@types/node": "^22.10.9",
|
"@types/node": "^22.10.9",
|
||||||
"@types/object-hash": "^3.0.6",
|
"@types/object-hash": "^3.0.6",
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import * as XLSX from "xlsx";
|
|||||||
import { Range, WorkSheet } from "xlsx";
|
import { Range, WorkSheet } from "xlsx";
|
||||||
import { toNormalString, trimAll } from "../../../utility/string.util";
|
import { toNormalString, trimAll } from "../../../utility/string.util";
|
||||||
import { plainToInstance, Type } from "class-transformer";
|
import { plainToInstance, Type } from "class-transformer";
|
||||||
import * as objectHash from "object-hash";
|
|
||||||
import LessonTime from "../../entities/lesson-time.entity";
|
import LessonTime from "../../entities/lesson-time.entity";
|
||||||
import { LessonType } from "../../enum/lesson-type.enum";
|
import { LessonType } from "../../enum/lesson-type.enum";
|
||||||
import LessonSubGroup from "../../entities/lesson-sub-group.entity";
|
import LessonSubGroup from "../../entities/lesson-sub-group.entity";
|
||||||
@@ -25,6 +24,8 @@ import {
|
|||||||
import { ClassProperties } from "../../../utility/class-trasformer/class-transformer-ctor";
|
import { ClassProperties } from "../../../utility/class-trasformer/class-transformer-ctor";
|
||||||
import { ToMap } from "create-map-transform-fn";
|
import { ToMap } from "create-map-transform-fn";
|
||||||
|
|
||||||
|
import * as objectHash from "object-hash";
|
||||||
|
|
||||||
type InternalId = {
|
type InternalId = {
|
||||||
/**
|
/**
|
||||||
* Индекс строки
|
* Индекс строки
|
||||||
@@ -353,74 +354,56 @@ export class ScheduleParser {
|
|||||||
private static convertGroupsToTeachers(
|
private static convertGroupsToTeachers(
|
||||||
groups: Map<string, Group>,
|
groups: Map<string, Group>,
|
||||||
): Map<string, Teacher> {
|
): Map<string, Teacher> {
|
||||||
const result = new Map<string, Teacher>();
|
const teachers = new Map<string, Teacher>();
|
||||||
|
|
||||||
for (const groupName of groups.keys()) {
|
const days = (() => {
|
||||||
const group = groups.get(groupName);
|
const group = groups.values().next().value as Group;
|
||||||
|
|
||||||
for (const day of group.days) {
|
return group.days.map((day) => {
|
||||||
for (const lesson of day.lessons) {
|
return new TeacherDay({
|
||||||
if (lesson.type !== LessonType.DEFAULT) continue;
|
name: day.name,
|
||||||
|
street: day.street,
|
||||||
|
date: day.date,
|
||||||
|
lessons: [],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
|
||||||
for (const subGroup of lesson.subGroups) {
|
const cloneDays = () => structuredClone(days);
|
||||||
let teacherDto: Teacher = result.get(subGroup.teacher);
|
|
||||||
|
|
||||||
if (!teacherDto) {
|
for (const group of groups.values()) {
|
||||||
teacherDto = new Teacher({
|
group.days.forEach((day, dayIndex) => {
|
||||||
name: subGroup.teacher,
|
for (const groupLesson of day.lessons) {
|
||||||
days: [],
|
if (groupLesson.type !== LessonType.DEFAULT) continue;
|
||||||
});
|
|
||||||
|
|
||||||
result.set(subGroup.teacher, teacherDto);
|
for (const subGroup of groupLesson.subGroups) {
|
||||||
|
if (!teachers.has(subGroup.teacher)) {
|
||||||
|
teachers.set(
|
||||||
|
subGroup.teacher,
|
||||||
|
new Teacher({
|
||||||
|
name: subGroup.teacher,
|
||||||
|
days: cloneDays(),
|
||||||
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let teacherDay = teacherDto.days[
|
const teacherDay = teachers.get(subGroup.teacher).days[
|
||||||
day.name
|
dayIndex
|
||||||
] as TeacherDay;
|
];
|
||||||
|
|
||||||
if (!teacherDay) {
|
const lesson = structuredClone(
|
||||||
teacherDay = teacherDto.days[day.name] =
|
groupLesson,
|
||||||
new TeacherDay({
|
|
||||||
name: day.name,
|
|
||||||
date: day.date,
|
|
||||||
lessons: [],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const teacherLesson = structuredClone(
|
|
||||||
lesson,
|
|
||||||
) as TeacherLesson;
|
) as TeacherLesson;
|
||||||
teacherLesson.group = groupName;
|
|
||||||
|
|
||||||
teacherDay.lessons.push(teacherLesson);
|
lesson.group = group.name;
|
||||||
|
|
||||||
|
teacherDay.lessons.push(lesson);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const teacherName of result.keys()) {
|
return teachers;
|
||||||
const teacher = result.get(teacherName);
|
|
||||||
|
|
||||||
const days = teacher.days;
|
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-for-in-array
|
|
||||||
for (const dayName in days) {
|
|
||||||
const day = days[dayName];
|
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-array-delete
|
|
||||||
delete days[dayName];
|
|
||||||
|
|
||||||
day.lessons.sort(
|
|
||||||
(a, b) => a.time.start.valueOf() - b.time.start.valueOf(),
|
|
||||||
);
|
|
||||||
|
|
||||||
days.push(day);
|
|
||||||
}
|
|
||||||
|
|
||||||
days.sort((a, b) => a.date.valueOf() - b.date.valueOf());
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user