using System; using System.Collections.Generic; using System.Linq; namespace TeamAAS_VP.Core.Sfis { public static class SfisDelimiters { public const char Field = (char)127; } public class SfisResponse { public string Raw { get; set; } public string[] Fields { get; set; } = new string[0]; public int ReturnCode { get; set; } public string Message { get; set; } public bool IsSuccess => ReturnCode == 1; public string GetField(int index) { if (Fields == null || index < 0 || index >= Fields.Length) return null; return Fields[index]; } public static SfisResponse Parse(string raw) { var response = new SfisResponse { Raw = raw ?? string.Empty }; if (string.IsNullOrWhiteSpace(raw)) { response.ReturnCode = 0; response.Message = "SFIS 返回为空"; return response; } response.Fields = raw.Split(SfisDelimiters.Field); if (response.Fields.Length > 0 && int.TryParse(response.Fields[0], out int code)) response.ReturnCode = code; else response.ReturnCode = 0; response.Message = response.Fields.Length > 1 ? response.Fields[1] : raw; return response; } } public class SfisUnitContext { public string Isn { get; set; } public string ReelIdSn { get; set; } public string MoNumber { get; set; } public string PassType { get; set; } public string AoiLocTag { get; set; } public bool TestPassed { get; set; } = true; public string ErrorCode { get; set; } public IList TestRecords { get; set; } = new List(); } public class SfisTestRecord { public string TestName { get; set; } public bool Passed { get; set; } public string Value { get; set; } } public class SfisWorkflowStepResult { public string StepName { get; set; } public SfisResponse Response { get; set; } } public class SfisWorkflowResult { public bool Success { get; set; } public string Isn { get; set; } public IList Steps { get; set; } = new List(); public string ErrorMessage { get; set; } public SfisWorkflowStepResult GetStep(string stepName) { return Steps.FirstOrDefault(s => s.StepName == stepName); } } public class SfisInputDataPayload { public string PassType { get; set; } public string MoNumber { get; set; } public string ReelIdSn { get; set; } public string AoiLocTag { get; set; } public string Isn { get; set; } public string BuildDataString() { return string.Join( SfisDelimiters.Field.ToString(), PassType ?? string.Empty, MoNumber ?? string.Empty, ReelIdSn ?? string.Empty, AoiLocTag ?? string.Empty, Isn ?? string.Empty); } } }