[CLAUDE] Office: P11-D ItTicket auto-assign round-robin + SLA timer (Wave 2, Mig 46)
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 4m17s
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 4m17s
Mig 46 AddSlaFieldsToItTicket (SlaDueAt/SlaWarnedSent/SlaBreached). CreateItTicketHandler: round-robin least-loaded assign cho IT staff (dept Code=IT, tie-break Id) + SlaDueAt theo Priority (Urgent 4h/High 8h/Medium 24h/Low 72h). ItTicketSlaJob background (breach+warning notify, KHONG auto-transition). PUT /{id}/assign admin override. DbInitializer seed dept IT + 2 sample staff (nv.cao/nv.truong). FE ItTicketsPage +MaTicket+assignee+SLA badge (2 app SHA256 mirror). +9 test (191->200). Self-review PASS (seed<->query dept-code verified; em main solo review do session-limit kill reviewer-spawn).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@ -88,6 +88,10 @@ public static class DbInitializer
|
||||
await SeedAdminAsync(userManager, logger);
|
||||
await SeedDepartmentsAsync(db, logger);
|
||||
await SeedDemoUsersAsync(db, userManager, logger);
|
||||
// Phase 11 P11-D (Mig 46 — Wave 2) — gán 2 sample user vào Phòng CNTT (IT staff)
|
||||
// cho round-robin auto-assign ticket. PHẢI sau SeedDemoUsersAsync (reconcile dept
|
||||
// trước → method này override về IT). Infrastructure data (NOT gated DemoSeed).
|
||||
await SeedItDepartmentStaffAsync(db, userManager, logger);
|
||||
// Plan B G-H1 (Mig 34 S33 2026-05-26) — seed EmployeeProfile 1-1 với
|
||||
// mọi user @solutions.com.vn. Idempotent. NOT gated DemoSeed flag
|
||||
// (infrastructure data, mirror Mig 32 SeedSampleContractWorkflowV2
|
||||
@ -2074,6 +2078,7 @@ public static class DbInitializer
|
||||
("EQU", "Phòng Thiết bị", "Equipment — thuê/mua máy móc"),
|
||||
("HRA", "Phòng Nhân sự - Hành chính", "HRA/ISO — đóng dấu HĐ sau BOD ký"),
|
||||
("BOD", "Ban Giám đốc", "Board of Directors — ký duyệt HĐ"),
|
||||
("IT", "Phòng CNTT", "IT helpdesk — tiếp nhận + xử lý ticket CNTT (P11-D round-robin assign)"),
|
||||
};
|
||||
|
||||
var existingCodes = await db.Departments.Select(d => d.Code).ToListAsync();
|
||||
@ -2091,6 +2096,52 @@ public static class DbInitializer
|
||||
}
|
||||
}
|
||||
|
||||
// P11-D (Wave 2) — gán 2 SAMPLE demo user vào Phòng CNTT (IT) làm IT staff
|
||||
// để round-robin auto-assign ticket có người nhận ngày 1. CHỈ đụng 2 sample
|
||||
// user (nv.cao + nv.truong — prefix nv.* = sample, KHÔNG phải 14 Solutions
|
||||
// real user). Idempotent: chỉ set DepartmentId nếu user CHƯA thuộc IT.
|
||||
//
|
||||
// ⚠️ PHẢI chạy SAU SeedDemoUsersAsync: method đó reconcile DepartmentId 2 user
|
||||
// này về PRO/CCM (hardcoded deptCode) mỗi lần boot. Chạy sau → override về IT.
|
||||
// End-state sau mỗi full SeedAsync = deterministic (IT). Infrastructure data
|
||||
// (NOT gated DemoSeed flag, gotcha #51).
|
||||
private static async Task SeedItDepartmentStaffAsync(
|
||||
ApplicationDbContext db, UserManager<User> userManager, ILogger logger)
|
||||
{
|
||||
var itDept = await db.Departments.FirstOrDefaultAsync(d => d.Code == "IT" && !d.IsDeleted);
|
||||
if (itDept is null)
|
||||
{
|
||||
logger.LogWarning("SeedItDepartmentStaffAsync: skip — phòng IT chưa seed (chạy SeedDepartmentsAsync trước).");
|
||||
return;
|
||||
}
|
||||
|
||||
// 2 sample user (Drafter-only) chuyển sang IT staff. KHÔNG đụng real user.
|
||||
var sampleItStaffEmails = new[]
|
||||
{
|
||||
"nv.cao@solutions.com.vn", // Cao Văn Long
|
||||
"nv.truong@solutions.com.vn", // Trương Minh Quân
|
||||
};
|
||||
|
||||
int assigned = 0;
|
||||
foreach (var email in sampleItStaffEmails)
|
||||
{
|
||||
var user = await userManager.FindByEmailAsync(email);
|
||||
if (user is null)
|
||||
{
|
||||
logger.LogWarning("SeedItDepartmentStaffAsync: sample user {Email} not found — skip.", email);
|
||||
continue;
|
||||
}
|
||||
if (user.DepartmentId == itDept.Id) continue; // đã thuộc IT → idempotent skip
|
||||
user.DepartmentId = itDept.Id;
|
||||
user.UpdatedAt = DateTime.UtcNow;
|
||||
await userManager.UpdateAsync(user);
|
||||
assigned++;
|
||||
}
|
||||
|
||||
if (assigned > 0)
|
||||
logger.LogInformation("SeedItDepartmentStaffAsync: gán {Count} sample user vào Phòng CNTT (IT staff).", assigned);
|
||||
}
|
||||
|
||||
// Sample master data for UAT/demo — per-code idempotent (skip Code đã có,
|
||||
// add Code mới). Cho phép admin add/sửa supplier/project mà restart không
|
||||
// clobber, đồng thời cho phép expand seed list theo thời gian.
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace SolutionErp.Infrastructure.Persistence.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddSlaFieldsToItTicket : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "SlaBreached",
|
||||
table: "ItTickets",
|
||||
type: "bit",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "SlaDueAt",
|
||||
table: "ItTickets",
|
||||
type: "datetime2",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "SlaWarnedSent",
|
||||
table: "ItTickets",
|
||||
type: "bit",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "SlaBreached",
|
||||
table: "ItTickets");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "SlaDueAt",
|
||||
table: "ItTickets");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "SlaWarnedSent",
|
||||
table: "ItTickets");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3793,6 +3793,15 @@ namespace SolutionErp.Infrastructure.Persistence.Migrations
|
||||
b.Property<DateTime?>("ResolvedAt")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<bool>("SlaBreached")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<DateTime?>("SlaDueAt")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<bool>("SlaWarnedSent")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user