Гант: отрицательные дни, этапы До CP-0 / Договоры PreConstruction / Договор Construction, Пермит после договоров; предупреждение о сроке только при наличии зависимостей
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -47,11 +47,13 @@ export const clampPx = (px: number | undefined): number => {
|
||||
|
||||
/** Группы презентации «Pre-construction»: порядок сверху вниз и цвета (сплошная полоса / светлый тон для примерных сроков). */
|
||||
export const STAGE_STYLES: ReadonlyArray<{ stage: string; fill: string; stroke: string }> = [
|
||||
{ stage: "Договоры", stroke: "#7a808f", fill: "#dde0e6" },
|
||||
{ stage: "До CP-0", stroke: "#8a6bb5", fill: "#e5dcf1" },
|
||||
{ stage: "Договоры PreConstruction", stroke: "#7a808f", fill: "#dde0e6" },
|
||||
{ stage: "Пермит", stroke: "#d8622f", fill: "#f7d9cc" },
|
||||
{ stage: "Архитектура", stroke: "#3f9a78", fill: "#d4ece3" },
|
||||
{ stage: "Спецификации", stroke: "#3f7ea6", fill: "#d3e4ef" },
|
||||
{ stage: "Пермит", stroke: "#d8622f", fill: "#f7d9cc" },
|
||||
{ stage: "Финансы", stroke: "#d4982f", fill: "#f5e6c8" },
|
||||
{ stage: "Договор Construction", stroke: "#7a808f", fill: "#dde0e6" },
|
||||
{ stage: "Закупки", stroke: "#6f93ab", fill: "#dbe6ee" },
|
||||
{ stage: "Стройка", stroke: "#1f7a52", fill: "#cfe6da" },
|
||||
];
|
||||
@@ -168,7 +170,8 @@ export function renderGantt(model: ProcessModel, schedule: Schedule, opts: Gantt
|
||||
const roleName = new Map(model.roles.map((r) => [r.id, r.person ?? r.id]));
|
||||
const conflicts = new Map<string, string[]>();
|
||||
for (const w of schedule.warnings) conflicts.set(w.id, [...(conflicts.get(w.id) ?? []), w.message]);
|
||||
const x = (d: number) => GANTT_LEFT + d * px;
|
||||
const minDay = Math.min(0, ...[...schedule.timings.values()].filter((t) => t.kind !== "recurring").map((t) => t.start));
|
||||
const x = (d: number) => GANTT_LEFT + (d - minDay) * px;
|
||||
|
||||
// Группы: строки этапа по началу
|
||||
interface Group { stage: string; rows: Array<{ row: ProcessRow; t: Timing }>; summary: GroupSummary; collapsed: boolean; labels: PlacedLabel[]; levels: number; headH: number; top: number; bottom: number }
|
||||
@@ -207,7 +210,7 @@ export function renderGantt(model: ProcessModel, schedule: Schedule, opts: Gantt
|
||||
...groups.flatMap((g) => g.labels.map((l) => l.x + (l.text.length * CHAR_W) / 2)),
|
||||
...groups.flatMap((g) => (g.collapsed ? [] : g.rows.map(({ row, t }) => x(Math.max(t.start, t.end)) + 14 + (row.actionName ?? row.description ?? "").length * CHAR_W))),
|
||||
);
|
||||
const width = Math.round(Math.max(GANTT_LEFT + days * px + 30, labelRight + 16));
|
||||
const width = Math.round(Math.max(GANTT_LEFT + (days - minDay) * px + 30, labelRight + 16));
|
||||
|
||||
const out: string[] = [];
|
||||
out.push(`<text x="12" y="24" font-size="16" font-weight="600" fill="#222">Диаграмма Ганта процесса (${esc(model.set)}): дни от первой встречи с архитектором</text>`);
|
||||
@@ -216,10 +219,10 @@ export function renderGantt(model: ProcessModel, schedule: Schedule, opts: Gantt
|
||||
const steps = [1, 2, 5, 7, 14, 30, 60, 90, 180];
|
||||
const tick = steps.find((s) => s * px >= 64) ?? 180;
|
||||
const gridStep = steps.find((s) => s * px >= 8) ?? 7;
|
||||
for (let d = 0; d <= days; d += gridStep) {
|
||||
for (let d = Math.ceil(minDay / gridStep) * gridStep; d <= days; d += gridStep) {
|
||||
out.push(`<line x1="${x(d)}" y1="${HEAD - 4}" x2="${x(d)}" y2="${height - 30}" stroke="${d % tick === 0 ? "#c9c9c9" : "#eeeeee"}" stroke-width="1"/>`);
|
||||
}
|
||||
for (let d = 0; d <= days; d += tick) {
|
||||
for (let d = Math.ceil(minDay / tick) * tick; d <= days; d += tick) {
|
||||
out.push(`<line x1="${x(d)}" y1="${HEAD - 18}" x2="${x(d)}" y2="${height - 30}" stroke="#bdbdbd" stroke-width="1.2"/>`);
|
||||
out.push(`<text x="${x(d) + 3}" y="${HEAD - 38}" fill="#444" font-weight="600">день ${d}</text>`);
|
||||
const date = opts.kickoff ? addDays(opts.kickoff, d) : null;
|
||||
|
||||
@@ -8,7 +8,8 @@ export interface ParsedConstraint {
|
||||
recurring: "weekly" | "daily" | null;
|
||||
}
|
||||
|
||||
const numbers = (s: string): number[] => [...s.matchAll(/\d+/g)].map((m) => Number(m[0]));
|
||||
/** Числа в тексте; «-2» - отрицательный день только если минус не приклеен к цифре слева («0-44» - диапазон). */
|
||||
const numbers = (s: string): number[] => [...s.matchAll(/(?<!\d)-\d+|\d+/g)].map((m) => Number(m[0]));
|
||||
|
||||
/**
|
||||
* Разбор поля date_constraint (дни от первой встречи с архитектором).
|
||||
@@ -149,7 +150,7 @@ export function computeSchedule(rows: ProcessRow[]): Schedule {
|
||||
};
|
||||
timings.set(id, t);
|
||||
|
||||
if (!c.recurring && t.fromConstraint && end < depEnd) warnings.push({ id, message: `срок (день ${end}) раньше окончания предшественников (день ${depEnd})` });
|
||||
if (!c.recurring && t.fromConstraint && row.dependsOn.length > 0 && end < depEnd) warnings.push({ id, message: `срок (день ${end}) раньше окончания предшественников (день ${depEnd})` });
|
||||
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;
|
||||
};
|
||||
|
||||
@@ -11,6 +11,8 @@ const row = (o: Record<string, unknown>) => mapRow({ id: "X", ...o });
|
||||
describe("parseConstraint", () => {
|
||||
it("разбирает форматы из процесса", () => {
|
||||
expect(parseConstraint("день 0")).toMatchObject({ start: null, end: 0, exact: true });
|
||||
expect(parseConstraint("день -2 → день -1")).toMatchObject({ start: -2, end: -1 });
|
||||
expect(parseConstraint("день 0-44")).toMatchObject({ start: 0, end: 44 });
|
||||
expect(parseConstraint("не позже дня 7")).toMatchObject({ end: 7, exact: false });
|
||||
expect(parseConstraint("около дня 45")).toMatchObject({ end: 45, exact: false });
|
||||
expect(parseConstraint("день 45–47")).toMatchObject({ start: 45, end: 47 });
|
||||
@@ -340,10 +342,10 @@ describe("Гант: группы, вехи, свёртывание, масшта
|
||||
});
|
||||
|
||||
it("группы презентации: порядок и цвета фиксированы, заливка сплошная (без штриховки)", () => {
|
||||
const rows = ["Стройка", "Пермит", "Договоры", "Финансы", "Свой этап", "Спецификации", "Архитектура", "Закупки"].map((s, i) => row({ id: "S-" + i, stage: s, date_constraint: "день " + (10 + i) }));
|
||||
const rows = ["Стройка", "Пермит", "Договоры PreConstruction", "Финансы", "Свой этап", "Спецификации", "Архитектура", "Закупки"].map((s, i) => row({ id: "S-" + i, stage: s, date_constraint: "день " + (10 + i) }));
|
||||
const m: ProcessModel = { ...model, rows };
|
||||
const sc = computeSchedule(m.rows);
|
||||
expect(stageOrder(m.rows, sc)).toEqual(["Договоры", "Архитектура", "Спецификации", "Пермит", "Финансы", "Закупки", "Стройка", "Свой этап"]);
|
||||
expect(stageOrder(m.rows, sc)).toEqual(["Договоры PreConstruction", "Пермит", "Архитектура", "Спецификации", "Финансы", "Закупки", "Стройка", "Свой этап"]);
|
||||
const svg = renderGantt(m, sc, {});
|
||||
expect(svg).toContain("#7a808f"); // Договоры
|
||||
expect(svg).toContain("#d8622f"); // Пермит
|
||||
|
||||
Reference in New Issue
Block a user