@@ -154,90 +154,91 @@ else if (cell.getColumnIndex() >= (fullDistantForm ? 3 : 2)) { // перебор
154154
155155 for (Group group : indexedDistantGroups ) {
156156
157- Schedule schedule = new Schedule ();
157+ // у заочной формы нет четности недели
158+ for (int w = 1 ; w <= 2 ; w ++) {
158159
159- StringBuilder name = new StringBuilder (currentCell .subject .trim ());
160- String type = "" ;
161- if (name .toString ().contains ("Экзамен" ) || name .toString ().contains ("Зачёт" )) {
162- String [] tempSplit = name .toString ().split (":" );
163- type = tempSplit [0 ];
164- log .info ("type: " + type );
165- name = new StringBuilder ();
166- for (int part = 1 ; part < tempSplit .length ; part ++) {
167- String add = (part == 1 ) ? tempSplit [part ].substring (1 ) : tempSplit [part ];
168- name .append (add );
160+ Schedule schedule = new Schedule ();
161+
162+ StringBuilder name = new StringBuilder (currentCell .subject .trim ());
163+ String type = "" ;
164+ if (name .toString ().contains ("Экзамен" ) || name .toString ().contains ("Зачёт" )) {
165+ String [] tempSplit = name .toString ().split (":" );
166+ type = tempSplit [0 ];
167+ log .info ("type: " + type );
168+ name = new StringBuilder ();
169+ for (int part = 1 ; part < tempSplit .length ; part ++) {
170+ String add = (part == 1 ) ? tempSplit [part ].substring (1 ) : tempSplit [part ];
171+ name .append (add );
172+ }
169173 }
170- }
171174
172- byte [] rgb = new byte []{(byte ) 255 , (byte ) 255 , (byte ) 255 };
173- Color color = fileName .contains (".xlsx" ) ? new XSSFColor (rgb , null ) : HSSFColor .HSSFColorPredefined .WHITE .getColor ();
174- Color cellColor = cell .getCellStyle ().getFillForegroundColorColor ();
175+ byte [] rgb = new byte []{(byte ) 255 , (byte ) 255 , (byte ) 255 };
176+ Color color = fileName .contains (".xlsx" ) ? new XSSFColor (rgb , null ) : HSSFColor .HSSFColorPredefined .WHITE .getColor ();
177+ Color cellColor = cell .getCellStyle ().getFillForegroundColorColor ();
175178
176- log .info ("color: " + color );
177- log .info ("cellColor: " + cellColor );
179+ log .info ("color: " + color );
180+ log .info ("cellColor: " + cellColor );
178181
179- // если цвет ячейки красный
180- if (cellColor != null && !isWhiteColor (cellColor , color ) && !(type .contains ("Экзамен" ) || type .contains ("Зачёт" ))) type = "Вводная пара" ;
182+ // если цвет ячейки красный
183+ if (cellColor != null && !isWhiteColor (cellColor , color ) && !(type .contains ("Экзамен" ) || type .contains ("Зачёт" ))) type = "Вводная пара" ;
181184
182- schedule .setLessonName (name .toString ());
183- schedule .setLessonType (type );
185+ schedule .setLessonName (name .toString ());
186+ schedule .setLessonType (type );
184187
185- // идемпотентность для сохранения (анти-дубликат)
186- if (currentCell .teacher != null && !currentCell .teacher .isBlank ()) {
188+ // идемпотентность для сохранения (анти-дубликат)
189+ if (currentCell .teacher != null && !currentCell .teacher .isBlank ()) {
187190
188- Teacher teacher = null ;
189- String [] tempSplit = currentCell .teacher .trim ().split (" " );
191+ Teacher teacher = null ;
192+ String [] tempSplit = currentCell .teacher .trim ().split (" " );
190193
191- if (!teacherCache .isEmpty ()) {
194+ if (!teacherCache .isEmpty ()) {
192195
193- for (String teacherLabel : teacherCache .keySet ()) {
196+ for (String teacherLabel : teacherCache .keySet ()) {
197+
198+ // Наличие приставки или звания
199+ if (tempSplit .length == 3 && teacherLabel .contains (tempSplit [1 ])) {
200+ teacher = teacherCache .get (teacherLabel );
201+ break ;
202+ } // Отсутствие приставки или звания
203+ else if (tempSplit .length == 2 && teacherLabel .contains (tempSplit [0 ])) {
204+ teacher = teacherCache .get (teacherLabel );
205+ break ;
206+ }
207+ else {
208+ Teacher t = new Teacher ();
209+ if (tempSplit .length == 3 ) t .setLabel (tempSplit [1 ] + " " + tempSplit [2 ]);
210+ else t .setLabel (currentCell .teacher .trim ());
211+ teacher = t ;
212+ break ;
213+ }
194214
195- // Наличие приставки или звания
196- if (tempSplit .length == 3 && teacherLabel .contains (tempSplit [1 ])) {
197- teacher = teacherCache .get (teacherLabel );
198- break ;
199- } // Отсутствие приставки или звания
200- else if (tempSplit .length == 2 && teacherLabel .contains (tempSplit [0 ])) {
201- teacher = teacherCache .get (teacherLabel );
202- break ;
203- }
204- else {
205- Teacher t = new Teacher ();
206- if (tempSplit .length == 3 ) t .setLabel (tempSplit [1 ] + " " + tempSplit [2 ]);
207- else t .setLabel (currentCell .teacher .trim ());
208- teacher = t ;
209- break ;
210215 }
211216
212217 }
218+ else {
219+ Teacher t = new Teacher ();
220+ if (tempSplit .length == 3 ) t .setLabel (tempSplit [1 ] + " " + tempSplit [2 ]);
221+ else t .setLabel (currentCell .teacher .trim ());
222+ teacher = t ;
223+ }
213224
214- }
215- else {
216- Teacher t = new Teacher ();
217- if (tempSplit .length == 3 ) t .setLabel (tempSplit [1 ] + " " + tempSplit [2 ]);
218- else t .setLabel (currentCell .teacher .trim ());
219- teacher = t ;
225+ schedule .setTeacher (teacher );
226+ teacherCache .put (currentCell .teacher .trim (), teacher );
220227 }
221228
222- schedule .setTeacher (teacher );
223- teacherCache .put (currentCell .teacher .trim (), teacher );
224- }
225-
226- // день недели (0 - день недели | 1 - дата)
227- String cellDate = getCellValueWithMerge (sheet , row .getRowNum (), 1 ).value .trim ();
228- String dayWeek = (!cellDate .isBlank () && !cellDate .isEmpty ()) ? cellDate .split (" " )[0 ] : getCellValueWithMerge (sheet , row .getRowNum () + 1 , 1 ).value .trim ().split (" " )[0 ];;
229- String pinnedDate = (!cellDate .isBlank () && !cellDate .isEmpty ()) ? cellDate .split (" " )[1 ] : getCellValueWithMerge (sheet , row .getRowNum () + 1 , 1 ).value .trim ().split (" " )[1 ];;
230- if (!dayWeek .isBlank ()) dayWeek = dayWeek .substring (0 , 1 ).toUpperCase () + dayWeek .substring (1 ).toLowerCase ();
229+ // день недели (0 - день недели | 1 - дата)
230+ String cellDate = getCellValueWithMerge (sheet , row .getRowNum (), 1 ).value .trim ();
231+ String dayWeek = (!cellDate .isBlank () && !cellDate .isEmpty ()) ? cellDate .split (" " )[0 ] : getCellValueWithMerge (sheet , row .getRowNum () + 1 , 1 ).value .trim ().split (" " )[0 ];;
232+ String pinnedDate = (!cellDate .isBlank () && !cellDate .isEmpty ()) ? cellDate .split (" " )[1 ] : getCellValueWithMerge (sheet , row .getRowNum () + 1 , 1 ).value .trim ().split (" " )[1 ];;
233+ if (!dayWeek .isBlank ()) dayWeek = dayWeek .substring (0 , 1 ).toUpperCase () + dayWeek .substring (1 ).toLowerCase ();
231234
232- // время занятия
233- String timePeriod = getCellValueWithMerge (sheet , row .getRowNum (), 2 ).value .trim ();
234- timePeriod = timePeriod .equals ("8:00" ) ? "08:00" : timePeriod .equals ("9:40" ) ? "09:40" : timePeriod ;
235+ // время занятия
236+ String timePeriod = getCellValueWithMerge (sheet , row .getRowNum (), 2 ).value .trim ();
237+ timePeriod = timePeriod .equals ("8:00" ) ? "08:00" : timePeriod .equals ("9:40" ) ? "09:40" : timePeriod ;
235238
236- log .info ("timePeriod: " + timePeriod );
237- log .info ("count: " + lessonDistantMap .get (timePeriod ));
239+ log .info ("timePeriod: " + timePeriod );
240+ log .info ("count: " + lessonDistantMap .get (timePeriod ));
238241
239- // у заочной формы нет четности недели
240- for (int w = 1 ; w <= 2 ; w ++) {
241242 schedule .setGroup (group );
242243 schedule .setAuditory (currentCell .location == null ? "Нет аудитории" : currentCell .location .trim ());
243244 schedule .setDayWeek (dayWeek );
@@ -255,18 +256,19 @@ else if (tempSplit.length == 2 && teacherLabel.contains(tempSplit[0])) {
255256 schedule .setPinnedDate (pinnedDate );
256257
257258 schedules .add (schedule );
258- }
259259
260- log .info ("Индексировано занятие: {}:{}:{} | {} | {} - {} - {} - {}" ,
261- schedule .getDayWeek (),
262- schedule .getTimePeriod (),
263- schedule .getWeekCount (),
264- schedule .getGroup ().getName (),
265- schedule .getLessonType (),
266- schedule .getLessonName (),
267- schedule .getTeacher () == null ? "Нет преподавателя" : schedule .getTeacher ().getLabel (),
268- schedule .getAuditory () == null ? "Нет аудитории" : schedule .getAuditory ()
269- );
260+ log .info ("Индексировано занятие: {}:{}:{} | {} | {} - {} - {} - {}" ,
261+ schedule .getDayWeek (),
262+ schedule .getTimePeriod (),
263+ schedule .getWeekCount (),
264+ schedule .getGroup ().getName (),
265+ schedule .getLessonType (),
266+ schedule .getLessonName (),
267+ schedule .getTeacher () == null ? "Нет преподавателя" : schedule .getTeacher ().getLabel (),
268+ schedule .getAuditory () == null ? "Нет аудитории" : schedule .getAuditory ()
269+ );
270+
271+ }
270272
271273 }
272274
0 commit comments