using LocalhostMES.Enums; using Prism.Mvvm; using SqlSugar; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace LocalhostMES.Models { public class MesModel { } #region 通用响应模型 public class ApiResponse { public string code { get; set; } = "200"; public bool success { get; set; } = true; public string msg { get; set; } = "请求成功"; public string msgTime { get; set; } = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); public string traceId { get; set; } = Guid.NewGuid().ToString("N").Substring(0, 24); public T data { get; set; } } public class ErrorResponse { public string code { get; set; } = "55000"; public bool success { get; set; } = false; public string msg { get; set; } public string msgTime { get; set; } = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); public string traceId { get; set; } = Guid.NewGuid().ToString("N").Substring(0, 24); public object data { get; set; } = null; } #endregion #region 2.1 厂级MES下发工单信息 public class WorkOrderRequest { public string WorkOrderNo { get; set; } // 工单号 public string MaterialCode { get; set; } // 成品物料号 public string MaterialName { get; set; } // 成品物料名称 public string OrderNo { get; set; } // 订单号 public string SequenceNo { get; set; } // 工单顺序号 public string WorkOrderNum { get; set; } // 工单生产数量 public string PlanOnlineTime { get; set; } // 计划上线时间 public string PlanOfflineTime { get; set; } // 计划下线时间 public string Status { get; set; } // 工单状态 public string FrozenStatus { get; set; } // 冻结状态 public string ReleaseStatus { get; set; } // 下发状态 public string LineCode { get; set; } // 线体编码 } public class WorkOrderInfo:BindableBase { private string _WorkOrderNo; private string _status; [SqlSugar.SugarColumn(IsPrimaryKey = true)] public string WorkOrderNo { get => _WorkOrderNo; set { SetProperty(ref _WorkOrderNo, value); } } public bool IsLocalhost { get; set;}=false; public string OrderNo { get; set; } = "0"; public string MaterialCode { get; set; } public string MaterialName { get; set; } public int PlannedQuantity { get; set; } public int CompletedQuantity { get; set; } public string Status { get => _status; set { if (SetProperty(ref _status, value)) { RaisePropertyChanged(nameof(StatusDisplay)); } } } [SqlSugar.SugarColumn(IsIgnore = true)] public string StatusDisplay => GetStatusDisplay(Status); public string LineCode { get; set; } public DateTime CreateTime { get; set; } public DateTime? StartTime { get; set; } public DateTime? EndTime { get; set; } public static string GetStatusDisplay(string status) { switch (status) { case "0": return "已创建"; case "1": return "已排产"; case "2": return "已发布"; case "3": return "关闭"; case "4": return "已锁定"; case "5": return "已开工"; case "6": return "已完成"; case "7": return "异常完工"; default: return status; } } } #endregion #region 2.2 SN打印请求 public class SnPrintRequest { public string plant { get; set; } // 工厂编码 public string workShop { get; set; } // 车间 public string line { get; set; } // 产线 public string station { get; set; } // 工位编码 public string site { get; set; } // 站点编码 public string equipment { get; set; } // 设备编码 public string orderNo { get; set; } // 订单号 public string workOrderNo { get; set; } // 工单号 public int count { get; set; } // 数量 public int printType { get; set; } // 条码类型 public string messageTime { get; set; } // 接口同步时间 } public class SnInfo { [SqlSugar.SugarColumn(IsPrimaryKey = true)] public string Sn { get; set; } // SN条码 public DateTime GenerateTime { get; set; } // 生成时间 public string WorkOrderNo { get; set; } // 所属工单 public string PrintType { get; set; } // 条码类型 public bool IsUsed { get; set; } = false; // 是否已使用 } public class SnPrintResponseData { public List Sn { get; set; } // SN列表 public string OrderNo { get; set; } // 订单号 public string WorkOrderNo { get; set; } // 工单号 public string Line { get; set; } // 产线 public string VehicleCode { get; set; } // 成品物料编码 public string MaterialDesc { get; set; } // 成品物料名称 } public class SnItem { public string Sn { get; set; } } #endregion #region 2.3 接收SN和关键件 public class SnKeyComponentRequest { public string businessTpye { get; set; } = "SCAN_TASK"; // 业务类型 public string plant { get; set; } // 工厂编码 public string workShop { get; set; } // 车间 public string lineCode { get; set; } // 产线 public string stationCode { get; set; } // 工位编码 public string positionCode { get; set; } // 站点编码 public string barcodeBoundProcInfo { get; set; } = "1"; // 绑定关键件加工信息 public string equipment { get; set; } // 设备编码 public string scanTime { get; set; } // 扫描时间 public string taskCode { get; set; } // 任务编码 public string scanTpye { get; set; } = "1"; // 扫描执行类型 public string sn { get; set; } // SN public string gbCode { get; set; } // 国标码 public string snStatus { get; set; } // 产品状态 public string employee { get; set; } // 人员 public List part { get; set; } // 关键件信息 } public class PartInfo { public string partNum { get; set; } // 关键件条码 public decimal partQty { get; set; } // 关键件数量 public string materialCode { get; set; } // 关键件物料 public string oldPartNum { get; set; } // 原关键件条码 public string materialType { get; set; } // 关键件类型 public string positionNo { get; set; } // 位置序号 } /// /// 本地维护的关键件清单(工站类型 + 关键件号 + 数量 + 物料/工位/站点/名称)。 /// public class LocalhostPartInfo : BindableBase { private StationType _stationType; private string _partNum; private decimal _partQty; private string _materialCode; private string _stationCode; private string _positionCode; private string _partInfoName; [SqlSugar.SugarColumn(IsPrimaryKey = true)] public StationType StationType { get => _stationType; set => SetProperty(ref _stationType, value); } [SqlSugar.SugarColumn(IsPrimaryKey = true, Length = 128)] public string PartNum { get => _partNum; set => SetProperty(ref _partNum, value); } public decimal PartQty { get => _partQty; set => SetProperty(ref _partQty, value); } public string MaterialCode { get => _materialCode; set => SetProperty(ref _materialCode, value); } public string StationCode { get => _stationCode; set => SetProperty(ref _stationCode, value); } public string PositionCode { get => _positionCode; set => SetProperty(ref _positionCode, value); } public string PartInfoName { get => _partInfoName; set => SetProperty(ref _partInfoName, value); } } public class BindRecord { [SqlSugar.SugarColumn(IsPrimaryKey = true,IsIdentity =true)] public int id { get; set; } public string Sn { get; set; } public string PartNum { get; set; } public string StationCode { get; set; } public DateTime BindTime { get; set; } public string Employee { get; set; } public string ScanType { get; set; } } #endregion #region 2.4 接收工件加工参数 public class ProcessParameterRequest { public string businessTpye { get; set; } // 业务类型 public string plant { get; set; } // 工厂编码 public string workShop { get; set; } // 车间 public string line { get; set; } // 产线 public string station { get; set; } // 工位编码 public string site { get; set; } // 站点编码 public string sn { get; set; } // SN public string barcode { get; set; } // 关键件条码 public string materialCode { get; set; } // 物料号 public string equipment { get; set; } // 设备编号 public string overallResult { get; set; } // 总结果 public List tightenResultDetail { get; set; } // 拧紧任务结果详情 public List stepResultDetail { get; set; } // 工步任务结果详情 public string reservedField1 { get; set; } // 预留字段1 public string reservedField2 { get; set; } // 预留字段2 public string reservedField3 { get; set; } // 预留字段3 public string messageTime { get; set; } // 接口同步时间 } public class TightenResult { public int point_num { get; set; } // 拧紧序号 public int pset { get; set; } // 拧紧程序编号 public decimal torque { get; set; } // 拧紧扭矩 public decimal angle { get; set; } // 拧紧角度 public string tighten_status { get; set; } // 单次拧紧结果 public string tighten_dt { get; set; } // 拧紧时间 } public class StepResult { public string tagCode { get; set; } // 参数名 public string tagValue { get; set; } // 实际值 public string tagRage { get; set; } // 参数上下限范围 public string tagResult { get; set; } // 参数结果 public string tagUnit { get; set; } // 参数单位 public List ngCode { get; set; } // 异常代码 } public class NgCodeInfo { public string ngCode { get; set; } // 异常代码 public string ngDes { get; set; } // 异常描述 } public class ProcessRecord { [SqlSugar.SugarColumn(IsPrimaryKey = true)] public string Sn { get; set; } public string Station { get; set; } public string OverallResult { get; set; } public DateTime ProcessTime { get; set; } public string Equipment { get; set; } } #endregion #region /// /// 生产数据 /// public class ProductionToStation : BindableBase { private Guid _id = Guid.NewGuid(); private string _SN; private string _PartNum; private DateTime _CreateTime; private string _FormulaName; private FormulaPartType _formulaPart; private string _Result; private List _resultContent = new List(); public Guid Id { get => _id; set { SetProperty(ref _id, value); } } public DateTime CreateTime { get => _CreateTime; set { SetProperty(ref _CreateTime, value); } } public string FormulaName { get => _FormulaName; set { SetProperty(ref _FormulaName, value); } } public FormulaPartType FormulaPart { get => _formulaPart; set { SetProperty(ref _formulaPart, value); } } public string Result { get => _Result; set { SetProperty(ref _Result, value); } } [SqlSugar.SugarColumn(IsJson = true, ColumnDataType = "nvarchar(2000)")]//必填 public List ResultContent { get => _resultContent; set { SetProperty(ref _resultContent, value); } } public string SN { get => _SN; set { SetProperty(ref _SN, value); } } public string PartNum { get => _PartNum; set { SetProperty(ref _PartNum, value); } } } /// /// 本地零件目录(名称 + 数量)。 /// public class ParkingLot : BindableBase { private int _id; private string _partName; private decimal _quantity; [SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true)] public int Id { get => _id; set => SetProperty(ref _id, value); } [SqlSugar.SugarColumn(Length = 200)] public string PartName { get => _partName; set => SetProperty(ref _partName, value); } public decimal Quantity { get => _quantity; set => SetProperty(ref _quantity, value); } } public class ResultInfo : BindableBase { private string resultName; private string resultValue; private string result; public string ResultName { get => resultName; set { SetProperty(ref resultName, value); } } public string ResultValue { get => resultValue; set { SetProperty(ref resultValue, value); } } public string Result { get => result; set { SetProperty(ref result, value); } } } /// /// 正在工作的订单左右信息 下发 /// public class OrderToMesInfo { private int _id=1; private string _LeftOrderNo; private string _LeftCheckCode; private string _RightOrderNo; private string _RightCheckCode; private DateTime _CreateTime; private string _CurrMarkCode=string.Empty; [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] public int Id { get => _id; set => _id = value; } public string LeftOrderNo { get => _LeftOrderNo; set => _LeftOrderNo = value; } public string RightOrderNo { get => _RightOrderNo; set => _RightOrderNo = value; } public string LeftCheckCode { get => _LeftCheckCode; set => _LeftCheckCode = value; } public string RightCheckCode { get => _RightCheckCode; set => _RightCheckCode = value; } public string CurrMarkCode { get => _CurrMarkCode; set => _CurrMarkCode = value; } public DateTime CreateTime { get => _CreateTime; set => _CreateTime = value; } } #endregion }