mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-10-06 05:22:08 +00:00
feat(work-orders): add domain enums and aggregate root fields
This commit is contained in:
parent
12fd5efe8b
commit
568961642f
6 changed files with 251 additions and 110 deletions
|
|
@ -1,92 +1,171 @@
|
||||||
namespace Data.SeaHavenIndustries.Enums
|
namespace Data.SeaHavenIndustries.Enums
|
||||||
{
|
{
|
||||||
public enum WorkOrderStatus
|
/// <summary>Legacy enum — prefer LifecycleStatus for board operations.</summary>
|
||||||
{
|
public enum WorkOrderStatus
|
||||||
Open = 1,
|
{
|
||||||
InProgress = 2,
|
Open = 1,
|
||||||
Completed = 3,
|
InProgress = 2,
|
||||||
Cancelled = 4,
|
Completed = 3,
|
||||||
OnHold = 5
|
Cancelled = 4,
|
||||||
}
|
OnHold = 5
|
||||||
|
}
|
||||||
public enum WorkOrderPriority
|
|
||||||
{
|
/// <summary>10 operational lifecycle values aligned with SHOC board (FE labels).</summary>
|
||||||
Low = 1,
|
public enum LifecycleStatus
|
||||||
Medium = 2,
|
{
|
||||||
High = 3,
|
Incomplete = 1,
|
||||||
Critical = 4
|
Pending = 2,
|
||||||
}
|
Scheduled = 3,
|
||||||
|
EnRoute = 4,
|
||||||
public enum AuditAction
|
OnSite = 5,
|
||||||
{
|
InProgress = 6,
|
||||||
Create = 1,
|
Completed = 7,
|
||||||
Edit = 2,
|
Rescheduled = 8,
|
||||||
Delete = 3,
|
Canceled = 9,
|
||||||
StatusChange = 4,
|
PendingQuote = 10
|
||||||
AssignmentChange = 5,
|
}
|
||||||
Dispatch = 6,
|
|
||||||
DispatchUpdate = 7,
|
/// <summary>Board work-order types. Legacy values retained for backward compatibility.</summary>
|
||||||
DispatchVerify = 8
|
public enum WorkOrderType
|
||||||
}
|
{
|
||||||
|
PO = 1,
|
||||||
public enum ContactType
|
PM = 2,
|
||||||
{
|
Emergency = 3,
|
||||||
Primary = 1,
|
Project = 4,
|
||||||
Secondary = 2,
|
Inspection = 5,
|
||||||
Billing = 3,
|
Reactive = 6,
|
||||||
Technical = 4
|
AddOn = 7,
|
||||||
}
|
Other = 99
|
||||||
|
}
|
||||||
public enum AssetStatus
|
|
||||||
{
|
public enum DocStatus
|
||||||
Active = 1,
|
{
|
||||||
Inactive = 2,
|
Yes = 1,
|
||||||
UnderMaintenance = 3,
|
No = 2,
|
||||||
Retired = 4
|
NotNeeded = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum DispatchStatus
|
[Flags]
|
||||||
{
|
public enum OperationalFlags
|
||||||
Pending = 1,
|
{
|
||||||
Assigned = 2,
|
None = 0,
|
||||||
InProgress = 3,
|
PastDue = 1
|
||||||
Completed = 4,
|
}
|
||||||
Cancelled = 5
|
|
||||||
}
|
public enum AuditEventType
|
||||||
|
{
|
||||||
public enum FollowUpStatus
|
Manual = 1,
|
||||||
{
|
System = 2,
|
||||||
Open = 1,
|
Sync = 3,
|
||||||
InProgress = 2,
|
Vendor = 4
|
||||||
Resolved = 3,
|
}
|
||||||
Closed = 4
|
|
||||||
}
|
public enum AuditActorType
|
||||||
|
{
|
||||||
public enum PMScheduleFrequency
|
Dispatcher = 1,
|
||||||
{
|
Vendor = 2,
|
||||||
Daily = 1,
|
System = 3,
|
||||||
Weekly = 2,
|
Sync = 4
|
||||||
Monthly = 3,
|
}
|
||||||
Quarterly = 4,
|
|
||||||
SemiAnnual = 5,
|
public enum AuditActionType
|
||||||
Annual = 6
|
{
|
||||||
}
|
FieldChanged = 1,
|
||||||
|
StatusChanged = 2,
|
||||||
public enum CommentType
|
AssignmentChanged = 3,
|
||||||
{
|
WeekRolled = 4,
|
||||||
General = 1,
|
SyncRejected = 5,
|
||||||
Internal = 2,
|
Create = 6,
|
||||||
Customer = 3,
|
Delete = 7
|
||||||
Vendor = 4,
|
}
|
||||||
System = 5
|
|
||||||
}
|
public enum WorkOrderPriority
|
||||||
|
{
|
||||||
public enum RecordType
|
Low = 1,
|
||||||
{
|
Medium = 2,
|
||||||
WorkOrder = 1,
|
High = 3,
|
||||||
Dispatch = 2,
|
Critical = 4
|
||||||
Quote = 3,
|
}
|
||||||
Contact = 4,
|
|
||||||
Asset = 5
|
public enum AuditAction
|
||||||
}
|
{
|
||||||
}
|
Create = 1,
|
||||||
|
Edit = 2,
|
||||||
|
Delete = 3,
|
||||||
|
StatusChange = 4,
|
||||||
|
AssignmentChange = 5,
|
||||||
|
Dispatch = 6,
|
||||||
|
DispatchUpdate = 7,
|
||||||
|
DispatchVerify = 8
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum ContactType
|
||||||
|
{
|
||||||
|
Primary = 1,
|
||||||
|
Secondary = 2,
|
||||||
|
Billing = 3,
|
||||||
|
Technical = 4
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum AssetStatus
|
||||||
|
{
|
||||||
|
Active = 1,
|
||||||
|
Inactive = 2,
|
||||||
|
UnderMaintenance = 3,
|
||||||
|
Retired = 4
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum DispatchStatus
|
||||||
|
{
|
||||||
|
Pending = 1,
|
||||||
|
Assigned = 2,
|
||||||
|
InProgress = 3,
|
||||||
|
Completed = 4,
|
||||||
|
Cancelled = 5
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum FollowUpStatus
|
||||||
|
{
|
||||||
|
Open = 1,
|
||||||
|
InProgress = 2,
|
||||||
|
Resolved = 3,
|
||||||
|
Closed = 4
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum PMScheduleFrequency
|
||||||
|
{
|
||||||
|
Daily = 1,
|
||||||
|
Weekly = 2,
|
||||||
|
Monthly = 3,
|
||||||
|
Quarterly = 4,
|
||||||
|
SemiAnnual = 5,
|
||||||
|
Annual = 6
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum CommentType
|
||||||
|
{
|
||||||
|
General = 1,
|
||||||
|
Internal = 2,
|
||||||
|
Customer = 3,
|
||||||
|
Vendor = 4,
|
||||||
|
System = 5
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum RecordType
|
||||||
|
{
|
||||||
|
WorkOrder = 1,
|
||||||
|
Dispatch = 2,
|
||||||
|
Quote = 3,
|
||||||
|
Contact = 4,
|
||||||
|
Asset = 5
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum WorkOrderMediaCategory
|
||||||
|
{
|
||||||
|
Before = 1,
|
||||||
|
After = 2,
|
||||||
|
Extra = 3,
|
||||||
|
Completion = 4
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
namespace Data.SeaHavenIndustries
|
namespace Data.SeaHavenIndustries
|
||||||
|
|
@ -26,6 +27,10 @@ namespace Data.SeaHavenIndustries
|
||||||
public string? AcceptToken { get; set; }
|
public string? AcceptToken { get; set; }
|
||||||
public string? VerifiedBy { get; set; }
|
public string? VerifiedBy { get; set; }
|
||||||
public DateTime? VerifiedAt { get; set; }
|
public DateTime? VerifiedAt { get; set; }
|
||||||
|
|
||||||
|
[Timestamp]
|
||||||
|
public byte[]? RowVersion { get; set; }
|
||||||
|
|
||||||
public ICollection<Comments>? Comments { get; set; }
|
public ICollection<Comments>? Comments { get; set; }
|
||||||
public ICollection<DispatchWorkOrder>? DispatchWorkOrders { get; set; }
|
public ICollection<DispatchWorkOrder>? DispatchWorkOrders { get; set; }
|
||||||
public ICollection<DispatchChecklistItem>? ChecklistItems { get; set; }
|
public ICollection<DispatchChecklistItem>? ChecklistItems { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,10 @@ namespace Data.SeaHavenIndustries
|
||||||
public string? OldValue { get; set; }
|
public string? OldValue { get; set; }
|
||||||
public string? NewValue { get; set; }
|
public string? NewValue { get; set; }
|
||||||
public string? Action { get; set; }
|
public string? Action { get; set; }
|
||||||
|
public string? EventType { get; set; }
|
||||||
|
public string? ActorType { get; set; }
|
||||||
|
public int? DispatchId { get; set; }
|
||||||
|
public string? CorrelationId { get; set; }
|
||||||
public DateTime CreatedAt { get; set; }
|
public DateTime CreatedAt { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,6 @@ namespace Data.SeaHavenIndustries
|
||||||
public int? WorkorderId { get; set; }
|
public int? WorkorderId { get; set; }
|
||||||
[ForeignKey(nameof(WorkorderId))]
|
[ForeignKey(nameof(WorkorderId))]
|
||||||
public virtual WorkOrder? WorkOrder { get; set; }
|
public virtual WorkOrder? WorkOrder { get; set; }
|
||||||
|
public string? Notes { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
18
Data.SeaHavenIndustries/Models/WorkOrderFieldLock.cs
Normal file
18
Data.SeaHavenIndustries/Models/WorkOrderFieldLock.cs
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace Data.SeaHavenIndustries
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// ManualEditFlag — blocks Sync overwrite after first SHOC edit per field.
|
||||||
|
/// </summary>
|
||||||
|
public class WorkOrderFieldLock
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int WorkOrderId { get; set; }
|
||||||
|
[ForeignKey(nameof(WorkOrderId))]
|
||||||
|
public virtual WorkOrder? WorkOrder { get; set; }
|
||||||
|
public string FieldName { get; set; } = "";
|
||||||
|
public DateTime LockedAt { get; set; }
|
||||||
|
public string? LockedByUserId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,11 +1,16 @@
|
||||||
using System;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
using Data.SeaHavenIndustries.Enums;
|
||||||
|
|
||||||
namespace Data.SeaHavenIndustries
|
namespace Data.SeaHavenIndustries
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Work Order aggregate root. Domain slices (Core, Scheduling, Tracking, Analytics, Completion)
|
||||||
|
/// are persisted as flat columns on workOrders for Fase 0 backward compatibility.
|
||||||
|
/// </summary>
|
||||||
public class WorkOrder : FullAuditEntity
|
public class WorkOrder : FullAuditEntity
|
||||||
{
|
{
|
||||||
|
// --- Core slice ---
|
||||||
public string? InternalWONumber { get; set; }
|
public string? InternalWONumber { get; set; }
|
||||||
public string? ExternalWorkOrderId { get; set; }
|
public string? ExternalWorkOrderId { get; set; }
|
||||||
public string? WorkerOrderNumber { get; set; }
|
public string? WorkerOrderNumber { get; set; }
|
||||||
|
|
@ -15,34 +20,59 @@ namespace Data.SeaHavenIndustries
|
||||||
public string? SiteCode { get; set; }
|
public string? SiteCode { get; set; }
|
||||||
public string? Building { get; set; }
|
public string? Building { get; set; }
|
||||||
public string? Severity { get; set; }
|
public string? Severity { get; set; }
|
||||||
public DateTime? DateReported { get; set; }
|
public DateTime? DueDate { get; set; }
|
||||||
|
public string? AssignTo { get; set; }
|
||||||
|
[ForeignKey(nameof(AssignTo))]
|
||||||
|
public virtual ApplicationUser? AssignToUser { get; set; }
|
||||||
|
public int? LocationId { get; set; }
|
||||||
|
[ForeignKey(nameof(LocationId))]
|
||||||
|
public virtual Locations? Locations { get; set; }
|
||||||
|
public LifecycleStatus? LifecycleStatus { get; set; }
|
||||||
|
public string? LegacyStatus { get; set; }
|
||||||
|
public WorkOrderType? WorkOrderType { get; set; }
|
||||||
|
/// <summary>SHOC board "Service" column (PM type label). Not Trade/Problem.</summary>
|
||||||
|
public string? Service { get; set; }
|
||||||
|
public int? PrimaryDispatchId { get; set; }
|
||||||
|
[ForeignKey(nameof(PrimaryDispatchId))]
|
||||||
|
public virtual Dispatch? PrimaryDispatch { get; set; }
|
||||||
|
|
||||||
|
// --- Scheduling slice ---
|
||||||
|
public DateTime? ScheduledDate { get; set; }
|
||||||
public DateTime? ScheduledStart { get; set; }
|
public DateTime? ScheduledStart { get; set; }
|
||||||
|
public DateTime? ScheduledEnd { get; set; }
|
||||||
|
public DateOnly? TargetWeek { get; set; }
|
||||||
|
public bool? ScheduleWeekOnly { get; set; }
|
||||||
|
|
||||||
|
// --- Tracking slice (set-once) ---
|
||||||
|
public DateOnly? OriginalWeek { get; set; }
|
||||||
|
public DateOnly? OriginalDate { get; set; }
|
||||||
|
|
||||||
|
// --- Analytics slice ---
|
||||||
|
public int RescheduleCount { get; set; }
|
||||||
|
public int CarriedOver { get; set; }
|
||||||
|
public OperationalFlags OperationalFlags { get; set; }
|
||||||
|
|
||||||
|
// --- Completion slice ---
|
||||||
|
public DocStatus? DocStatus { get; set; }
|
||||||
|
|
||||||
|
// --- Legacy SQL columns (drift reconciliation) ---
|
||||||
|
public string? AvettaTask { get; set; }
|
||||||
|
public DateOnly? AssignDate { get; set; }
|
||||||
|
|
||||||
|
// --- Legacy fields (retained for Blazor / coexistence) ---
|
||||||
|
public DateTime? DateReported { get; set; }
|
||||||
public string? SourceEmailS3Key { get; set; }
|
public string? SourceEmailS3Key { get; set; }
|
||||||
public string? Problem { get; set; }
|
public string? Problem { get; set; }
|
||||||
public string? Trade { get; set; }
|
public string? Trade { get; set; }
|
||||||
public string? SubTrade { get; set; }
|
public string? SubTrade { get; set; }
|
||||||
public decimal? VendorNTE { get; set; }
|
public decimal? VendorNTE { get; set; }
|
||||||
public DateTime? ScheduledDate { get; set; }
|
|
||||||
public DateTime? CompletedDate { get; set; }
|
public DateTime? CompletedDate { get; set; }
|
||||||
public string? Source { get; set; }
|
public string? Source { get; set; }
|
||||||
public bool? istemplate { get; set; }
|
public bool? istemplate { get; set; }
|
||||||
public string? PO { get; set; }
|
public string? PO { get; set; }
|
||||||
public string? TT { get; set; }
|
public string? TT { get; set; }
|
||||||
//public int? ContactId { get; set; }
|
|
||||||
//[ForeignKey(nameof(ContactId))]
|
|
||||||
//public virtual Contacts? POC { get; set; }
|
|
||||||
public string? AssignTo { get; set; }
|
|
||||||
[ForeignKey(nameof(AssignTo))]
|
|
||||||
public virtual ApplicationUser? AssignToUser { get; set; }
|
|
||||||
public DateTime? DueDate { get; set; }
|
|
||||||
public string? Priority { get; set; }
|
public string? Priority { get; set; }
|
||||||
public string? Status { get; set; }
|
public string? Status { get; set; }
|
||||||
public int? LocationId { get; set; }
|
|
||||||
[ForeignKey(nameof(LocationId))]
|
|
||||||
public virtual Locations? Locations { get; set; }
|
|
||||||
//public int? CategoryId { get; set; }
|
|
||||||
//[ForeignKey(nameof(CategoryId))]
|
|
||||||
//public virtual Category? Category { get; set; }
|
|
||||||
public string? Attachments { get; set; }
|
public string? Attachments { get; set; }
|
||||||
public string? BeforPhotoIssue { get; set; }
|
public string? BeforPhotoIssue { get; set; }
|
||||||
public string? BeforPhotoAttachment { get; set; }
|
public string? BeforPhotoAttachment { get; set; }
|
||||||
|
|
@ -51,11 +81,16 @@ namespace Data.SeaHavenIndustries
|
||||||
public string? SignOffName { get; set; }
|
public string? SignOffName { get; set; }
|
||||||
public string? SignOffAttachment { get; set; }
|
public string? SignOffAttachment { get; set; }
|
||||||
public string? SignOffSignature { get; set; }
|
public string? SignOffSignature { get; set; }
|
||||||
|
|
||||||
|
[Timestamp]
|
||||||
|
public byte[]? RowVersion { get; set; }
|
||||||
|
|
||||||
public ICollection<Comments>? Comments { get; set; }
|
public ICollection<Comments>? Comments { get; set; }
|
||||||
public ICollection<Quotes>? Quotes { get; set; }
|
public ICollection<Quotes>? Quotes { get; set; }
|
||||||
public ICollection<WorkOrderContacts>? WorkOrderContacts { get; set; }
|
public ICollection<WorkOrderContacts>? WorkOrderContacts { get; set; }
|
||||||
public ICollection<WorkOrderAttachments>? workOrderAttachments { get; set; }
|
public ICollection<WorkOrderAttachments>? workOrderAttachments { get; set; }
|
||||||
public ICollection<WorkOrderCategories>? WorkOrderCategories { get; set; }
|
public ICollection<WorkOrderCategories>? WorkOrderCategories { get; set; }
|
||||||
public ICollection<Dispatch>? Dispatches { get; set; }
|
public ICollection<Dispatch>? Dispatches { get; set; }
|
||||||
|
public ICollection<WorkOrderFieldLock>? FieldLocks { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue