Compare commits

..

2 Commits

3 changed files with 49 additions and 55 deletions

10
package-lock.json generated
View File

@@ -49,6 +49,7 @@
"@types/express": "^5.0.0",
"@types/jest": "^29.5.14",
"@types/jsdom": "^21.1.7",
"@types/lodash": "^4.17.16",
"@types/multer": "^1.4.12",
"@types/node": "^22.10.9",
"@types/object-hash": "^3.0.6",
@@ -3946,6 +3947,13 @@
"@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": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.2.tgz",
@@ -9602,6 +9610,8 @@
},
"node_modules/lodash": {
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
"license": "MIT"
},
"node_modules/lodash.camelcase": {

View File

@@ -61,6 +61,7 @@
"@types/express": "^5.0.0",
"@types/jest": "^29.5.14",
"@types/jsdom": "^21.1.7",
"@types/lodash": "^4.17.16",
"@types/multer": "^1.4.12",
"@types/node": "^22.10.9",
"@types/object-hash": "^3.0.6",

View File

@@ -4,7 +4,6 @@ import * as XLSX from "xlsx";
import { Range, WorkSheet } from "xlsx";
import { toNormalString, trimAll } from "../../../utility/string.util";
import { plainToInstance, Type } from "class-transformer";
import * as objectHash from "object-hash";
import LessonTime from "../../entities/lesson-time.entity";
import { LessonType } from "../../enum/lesson-type.enum";
import LessonSubGroup from "../../entities/lesson-sub-group.entity";
@@ -25,6 +24,8 @@ import {
import { ClassProperties } from "../../../utility/class-trasformer/class-transformer-ctor";
import { ToMap } from "create-map-transform-fn";
import * as objectHash from "object-hash";
type InternalId = {
/**
* Индекс строки
@@ -353,74 +354,56 @@ export class ScheduleParser {
private static convertGroupsToTeachers(
groups: Map<string, Group>,
): Map<string, Teacher> {
const result = new Map<string, Teacher>();
const teachers = new Map<string, Teacher>();
for (const groupName of groups.keys()) {
const group = groups.get(groupName);
const days = (() => {
const group = groups.values().next().value as Group;
for (const day of group.days) {
for (const lesson of day.lessons) {
if (lesson.type !== LessonType.DEFAULT) continue;
return group.days.map((day) => {
return new TeacherDay({
name: day.name,
street: day.street,
date: day.date,
lessons: [],
});
});
})();
for (const subGroup of lesson.subGroups) {
let teacherDto: Teacher = result.get(subGroup.teacher);
const cloneDays = () => structuredClone(days);
if (!teacherDto) {
teacherDto = new Teacher({
name: subGroup.teacher,
days: [],
});
for (const group of groups.values()) {
group.days.forEach((day, dayIndex) => {
for (const groupLesson of day.lessons) {
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[
day.name
] as TeacherDay;
const teacherDay = teachers.get(subGroup.teacher).days[
dayIndex
];
if (!teacherDay) {
teacherDay = teacherDto.days[day.name] =
new TeacherDay({
name: day.name,
date: day.date,
lessons: [],
});
}
const teacherLesson = structuredClone(
lesson,
const lesson = structuredClone(
groupLesson,
) as TeacherLesson;
teacherLesson.group = groupName;
teacherDay.lessons.push(teacherLesson);
lesson.group = group.name;
teacherDay.lessons.push(lesson);
}
}
}
});
}
for (const teacherName of result.keys()) {
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;
return teachers;
}
/**