Гант: красная черта крайнего срока (не позже, до); веха с крайним сроком стоит на прогнозе по предшественникам
All checks were successful
ci / test (push) Successful in 23s
ci / deploy (push) Successful in 1m28s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-17 17:03:25 +03:00
parent b4cf3d8c9a
commit 82cb6ba0a6
3 changed files with 38 additions and 6 deletions

View File

@@ -5,6 +5,8 @@ export interface ParsedConstraint {
end: number | null;
/** «день N» без «не позже / около / до»: точная дата, а не предел */
exact: boolean;
/** «не позже» / «до»: крайний срок (на Ганте - красная черта); «около» крайним сроком не считается */
deadline: boolean;
recurring: "weekly" | "daily" | null;
}
@@ -16,7 +18,7 @@ const numbers = (s: string): number[] => [...s.matchAll(/(?<!\d)-\d+|\d+/g)].map
* «день 7», «не позже дня 7», «около дня 45», «день 45–47», «день 80 → день 90», «день 120 …; день 135 …», «еженедельно …».
*/
export function parseConstraint(text: string | null): ParsedConstraint {
const none: ParsedConstraint = { start: null, end: null, exact: false, recurring: null };
const none: ParsedConstraint = { start: null, end: null, exact: false, deadline: false, recurring: null };
if (!text) return none;
const t = text.toLowerCase();
if (/еженедельно/.test(t)) return { ...none, recurring: "weekly" };
@@ -27,7 +29,8 @@ export function parseConstraint(text: string | null): ParsedConstraint {
}
const n = numbers(t);
if (n.length === 0) return none;
if (n.length === 1) return { ...none, end: n[0] ?? null, exact: /^\s*день\s+\d+\s*$/.test(t) };
const deadline = /не\s+позже|(^|\s)до\s/.test(t);
if (n.length === 1) return { ...none, end: n[0] ?? null, exact: /^\s*день\s+\d+\s*$/.test(t), deadline };
return { ...none, start: n[0] ?? null, end: n.at(-1) ?? null };
}
@@ -84,6 +87,8 @@ export interface Timing {
fromConstraint: boolean;
/** «около», «до», «не позже»: срок не точный */
approx: boolean;
/** крайний срок («не позже», «до»): день, где рисуется красная черта; null - крайнего срока нет */
deadline: number | null;
recurring: "weekly" | "daily" | null;
}
export interface ScheduleWarning { id: string; message: string }
@@ -132,7 +137,11 @@ export function computeSchedule(rows: ProcessRow[]): Schedule {
end = c.end;
} else if (c.end !== null) {
end = c.end;
if (c.exact || isCheckpoint(id)) start = d !== null && !c.exact ? Math.max(0, end - d) : end;
if (isCheckpoint(id) && c.deadline && !c.exact && row.dependsOn.length > 0) {
// веха с крайним сроком стоит на прогнозе (по предшественникам), а сам срок рисуется красной чертой (Timing.deadline)
start = depEnd;
end = depEnd;
} else if (c.exact || isCheckpoint(id)) start = d !== null && !c.exact ? Math.max(0, end - d) : end;
else start = d !== null ? Math.max(0, end - d) : Math.min(depEnd, end);
} else {
start = depEnd;
@@ -146,11 +155,13 @@ export function computeSchedule(rows: ProcessRow[]): Schedule {
kind: c.recurring ? "recurring" : start === end ? "milestone" : "task",
fromConstraint: c.start !== null || c.end !== null,
approx: c.end !== null && c.start === null && !c.exact,
deadline: c.deadline && c.end !== null && c.start === null ? c.end : null,
recurring: c.recurring,
};
timings.set(id, t);
if (!c.recurring && t.fromConstraint && row.dependsOn.length > 0 && end < depEnd) warnings.push({ id, message: `срок (день ${end}) раньше окончания предшественников (день ${depEnd})` });
if (t.deadline !== null && isCheckpoint(id) && row.dependsOn.length > 0 && depEnd > t.deadline) warnings.push({ id, message: `прогноз (день ${depEnd}) позже крайнего срока (день ${t.deadline})` });
if (c.start !== null && c.end !== null && d !== null && Math.abs(end - start - d) > 7) warnings.push({ id, message: `срок ${start}→${end} (${end - start} дн.) не сходится с длительностью ${d} дн.` });
return t;
};