Rules.cs 2.61 KB
namespace RobotProductionSystem.Api.Services;

public static class Rules
{
    public static readonly string[] DeviceTypeCategories = ["robot", "controller", "vision", "chassis", "communication", "power", "sensor", "actuator", "other"];
    public static readonly string[] WorkOrderStatuses = ["draft", "pending_dispatch", "running", "paused", "pending_qc", "completed", "closed"];
    public static readonly string[] SnStatuses = ["pending", "in_process", "completed", "frozen", "scrapped"];
    public static readonly string[] SnExceptionStatuses = ["none", "open", "rework", "closed"];
    public static readonly string[] OperationStatuses = ["pending", "in_progress", "pending_test", "failed", "rework", "completed", "skipped"];
    public static readonly string[] MemberRoles = ["member", "admin", "customer"];
    public static readonly string[] DashboardStatuses = ["pending_dispatch", "running", "pending_qc", "in_exception", "completed"];

    public static readonly Dictionary<string, string[]> WorkOrderAllowedTransitions = new()
    {
        ["draft"] = ["edit_draft", "dispatch"],
        ["pending_dispatch"] = ["pause", "resume", "close"],
        ["running"] = ["pause", "close"],
        ["paused"] = ["resume", "close"],
        ["pending_qc"] = ["close"],
        ["completed"] = ["close"],
        ["closed"] = []
    };

    public static readonly Dictionary<string, string> WorkOrderActionToStatus = new()
    {
        ["dispatch"] = "pending_dispatch",
        ["pause"] = "paused",
        ["resume"] = "running",
        ["close"] = "closed"
    };

    public static readonly Dictionary<string, string[]> SnAllowedActions = new()
    {
        ["pending"] = ["freeze", "scrap"],
        ["in_process"] = ["freeze", "scrap"],
        ["completed"] = ["freeze", "scrap"],
        ["frozen"] = ["unfreeze", "scrap"],
        ["scrapped"] = []
    };

    public static readonly Dictionary<string, string[]> OperationAllowedActions = new()
    {
        ["pending"] = ["start", "skip"],
        ["in_progress"] = ["complete_assembly", "submit_test", "skip"],
        ["pending_test"] = ["submit_test", "skip"],
        ["failed"] = ["complete_rework", "skip"],
        ["rework"] = ["complete_rework", "skip"],
        ["completed"] = [],
        ["skipped"] = []
    };

    public static readonly Dictionary<string, string> OperationNextAction = new()
    {
        ["pending"] = "start",
        ["in_progress"] = "complete_assembly",
        ["pending_test"] = "submit_test",
        ["failed"] = "complete_rework",
        ["rework"] = "complete_rework",
        ["completed"] = "go_next_step",
        ["skipped"] = "audit_review"
    };
}