MesModel.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. using LocalhostMES.Enums;
  2. using Prism.Mvvm;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace LocalhostMES.Models
  9. {
  10. public class MesModel
  11. {
  12. }
  13. #region 通用响应模型
  14. public class ApiResponse<T>
  15. {
  16. public string code { get; set; } = "200";
  17. public bool success { get; set; } = true;
  18. public string msg { get; set; } = "请求成功";
  19. public string msgTime { get; set; } = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  20. public string traceId { get; set; } = Guid.NewGuid().ToString("N").Substring(0, 24);
  21. public T data { get; set; }
  22. }
  23. public class ErrorResponse
  24. {
  25. public string code { get; set; } = "55000";
  26. public bool success { get; set; } = false;
  27. public string msg { get; set; }
  28. public string msgTime { get; set; } = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  29. public string traceId { get; set; } = Guid.NewGuid().ToString("N").Substring(0, 24);
  30. public object data { get; set; } = null;
  31. }
  32. #endregion
  33. #region 2.1 厂级MES下发工单信息
  34. public class WorkOrderRequest
  35. {
  36. public string WorkOrderNo { get; set; } // 工单号
  37. public string MaterialCode { get; set; } // 成品物料号
  38. public string MaterialName { get; set; } // 成品物料名称
  39. public string OrderNo { get; set; } // 订单号
  40. public string SequenceNo { get; set; } // 工单顺序号
  41. public string WorkOrderNum { get; set; } // 工单生产数量
  42. public string PlanOnlineTime { get; set; } // 计划上线时间
  43. public string PlanOfflineTime { get; set; } // 计划下线时间
  44. public string Status { get; set; } // 工单状态
  45. public string FrozenStatus { get; set; } // 冻结状态
  46. public string ReleaseStatus { get; set; } // 下发状态
  47. public string LineCode { get; set; } // 线体编码
  48. }
  49. public class WorkOrderInfo:BindableBase
  50. {
  51. private string _WorkOrderNo;
  52. private string _status;
  53. [SqlSugar.SugarColumn(IsPrimaryKey = true)]
  54. public string WorkOrderNo { get => _WorkOrderNo; set { SetProperty(ref _WorkOrderNo, value); } }
  55. public bool IsLocalhost { get; set;}=false;
  56. public string OrderNo { get; set; } = "0";
  57. public string MaterialCode { get; set; }
  58. public string MaterialName { get; set; }
  59. public int PlannedQuantity { get; set; }
  60. public int CompletedQuantity { get; set; }
  61. public string Status
  62. {
  63. get => _status;
  64. set
  65. {
  66. if (SetProperty(ref _status, value))
  67. {
  68. RaisePropertyChanged(nameof(StatusDisplay));
  69. }
  70. }
  71. }
  72. [SqlSugar.SugarColumn(IsIgnore = true)]
  73. public string StatusDisplay => GetStatusDisplay(Status);
  74. public string LineCode { get; set; }
  75. public DateTime CreateTime { get; set; }
  76. public DateTime? StartTime { get; set; }
  77. public DateTime? EndTime { get; set; }
  78. public static string GetStatusDisplay(string status)
  79. {
  80. switch (status)
  81. {
  82. case "0":
  83. return "已创建";
  84. case "1":
  85. return "已排产";
  86. case "2":
  87. return "已发布";
  88. case "3":
  89. return "关闭";
  90. case "4":
  91. return "已锁定";
  92. case "5":
  93. return "已开工";
  94. case "6":
  95. return "已完成";
  96. case "7":
  97. return "异常完工";
  98. default:
  99. return status;
  100. }
  101. }
  102. }
  103. #endregion
  104. #region 2.2 SN打印请求
  105. public class SnPrintRequest
  106. {
  107. public string plant { get; set; } // 工厂编码
  108. public string workShop { get; set; } // 车间
  109. public string line { get; set; } // 产线
  110. public string station { get; set; } // 工位编码
  111. public string site { get; set; } // 站点编码
  112. public string equipment { get; set; } // 设备编码
  113. public string orderNo { get; set; } // 订单号
  114. public string workOrderNo { get; set; } // 工单号
  115. public int count { get; set; } // 数量
  116. public int printType { get; set; } // 条码类型
  117. public string messageTime { get; set; } // 接口同步时间
  118. }
  119. public class SnInfo
  120. {
  121. [SqlSugar.SugarColumn(IsPrimaryKey = true)]
  122. public string Sn { get; set; } // SN条码
  123. public DateTime GenerateTime { get; set; } // 生成时间
  124. public string WorkOrderNo { get; set; } // 所属工单
  125. public string PrintType { get; set; } // 条码类型
  126. public bool IsUsed { get; set; } = false; // 是否已使用
  127. }
  128. public class SnPrintResponseData
  129. {
  130. public List<SnItem> Sn { get; set; } // SN列表
  131. public string OrderNo { get; set; } // 订单号
  132. public string WorkOrderNo { get; set; } // 工单号
  133. public string Line { get; set; } // 产线
  134. public string VehicleCode { get; set; } // 成品物料编码
  135. public string MaterialDesc { get; set; } // 成品物料名称
  136. }
  137. public class SnItem
  138. {
  139. public string Sn { get; set; }
  140. }
  141. #endregion
  142. #region 2.3 接收SN和关键件
  143. public class SnKeyComponentRequest
  144. {
  145. public string businessTpye { get; set; } = "SCAN_TASK"; // 业务类型
  146. public string plant { get; set; } // 工厂编码
  147. public string workShop { get; set; } // 车间
  148. public string lineCode { get; set; } // 产线
  149. public string stationCode { get; set; } // 工位编码
  150. public string positionCode { get; set; } // 站点编码
  151. public string barcodeBoundProcInfo { get; set; } = "1"; // 绑定关键件加工信息
  152. public string equipment { get; set; } // 设备编码
  153. public string scanTime { get; set; } // 扫描时间
  154. public string taskCode { get; set; } // 任务编码
  155. public string scanTpye { get; set; } = "1"; // 扫描执行类型
  156. public string sn { get; set; } // SN
  157. public string gbCode { get; set; } // 国标码
  158. public string snStatus { get; set; } // 产品状态
  159. public string employee { get; set; } // 人员
  160. public List<PartInfo> part { get; set; } // 关键件信息
  161. }
  162. public class PartInfo
  163. {
  164. public string partNum { get; set; } // 关键件条码
  165. public decimal partQty { get; set; } // 关键件数量
  166. public string materialCode { get; set; } // 关键件物料
  167. public string oldPartNum { get; set; } // 原关键件条码
  168. public string materialType { get; set; } // 关键件类型
  169. public string positionNo { get; set; } // 位置序号
  170. }
  171. /// <summary>
  172. /// 本地维护的关键件清单(工站类型 + 关键件号 + 数量)。
  173. /// </summary>
  174. public class LocalhostPartInfo : BindableBase
  175. {
  176. private KeyPartStationType _stationType;
  177. private string _partNum;
  178. private decimal _partQty;
  179. [SqlSugar.SugarColumn(IsPrimaryKey = true)]
  180. public KeyPartStationType StationType { get => _stationType; set => SetProperty(ref _stationType, value); }
  181. [SqlSugar.SugarColumn(IsPrimaryKey = true, Length = 128)]
  182. public string PartNum { get => _partNum; set => SetProperty(ref _partNum, value); }
  183. public decimal PartQty { get => _partQty; set => SetProperty(ref _partQty, value); }
  184. }
  185. public class BindRecord
  186. {
  187. [SqlSugar.SugarColumn(IsPrimaryKey = true,IsIdentity =true)]
  188. public int id { get; set; }
  189. public string Sn { get; set; }
  190. public string PartNum { get; set; }
  191. public string StationCode { get; set; }
  192. public DateTime BindTime { get; set; }
  193. public string Employee { get; set; }
  194. public string ScanType { get; set; }
  195. }
  196. #endregion
  197. #region 2.4 接收工件加工参数
  198. public class ProcessParameterRequest
  199. {
  200. public string businessTpye { get; set; } // 业务类型
  201. public string plant { get; set; } // 工厂编码
  202. public string workShop { get; set; } // 车间
  203. public string line { get; set; } // 产线
  204. public string station { get; set; } // 工位编码
  205. public string site { get; set; } // 站点编码
  206. public string sn { get; set; } // SN
  207. public string barcode { get; set; } // 关键件条码
  208. public string materialCode { get; set; } // 物料号
  209. public string equipment { get; set; } // 设备编号
  210. public string overallResult { get; set; } // 总结果
  211. public List<TightenResult> tightenResultDetail { get; set; } // 拧紧任务结果详情
  212. public List<StepResult> stepResultDetail { get; set; } // 工步任务结果详情
  213. public string reservedField1 { get; set; } // 预留字段1
  214. public string reservedField2 { get; set; } // 预留字段2
  215. public string reservedField3 { get; set; } // 预留字段3
  216. public string messageTime { get; set; } // 接口同步时间
  217. }
  218. public class TightenResult
  219. {
  220. public int point_num { get; set; } // 拧紧序号
  221. public int pset { get; set; } // 拧紧程序编号
  222. public decimal torque { get; set; } // 拧紧扭矩
  223. public decimal angle { get; set; } // 拧紧角度
  224. public string tighten_status { get; set; } // 单次拧紧结果
  225. public string tighten_dt { get; set; } // 拧紧时间
  226. }
  227. public class StepResult
  228. {
  229. public string tagCode { get; set; } // 参数名
  230. public string tagValue { get; set; } // 实际值
  231. public string tagRage { get; set; } // 参数上下限范围
  232. public string tagResult { get; set; } // 参数结果
  233. public string tagUnit { get; set; } // 参数单位
  234. public List<NgCodeInfo> ngCode { get; set; } // 异常代码
  235. }
  236. public class NgCodeInfo
  237. {
  238. public string ngCode { get; set; } // 异常代码
  239. public string ngDes { get; set; } // 异常描述
  240. }
  241. public class ProcessRecord
  242. {
  243. [SqlSugar.SugarColumn(IsPrimaryKey = true)]
  244. public string Sn { get; set; }
  245. public string Station { get; set; }
  246. public string OverallResult { get; set; }
  247. public DateTime ProcessTime { get; set; }
  248. public string Equipment { get; set; }
  249. }
  250. #endregion
  251. #region
  252. /// <summary>
  253. /// 生产数据
  254. /// </summary>
  255. public class ProductionToStation : BindableBase
  256. {
  257. private Guid _id = Guid.NewGuid();
  258. private string _SN;
  259. private string _PartNum;
  260. private DateTime _CreateTime;
  261. private string _FormulaName;
  262. private FormulaPartType _formulaPart;
  263. private string _Result;
  264. private List<ResultInfo> _resultContent = new List<ResultInfo>();
  265. public Guid Id { get => _id; set { SetProperty(ref _id, value); } }
  266. public DateTime CreateTime { get => _CreateTime; set { SetProperty(ref _CreateTime, value); } }
  267. public string FormulaName { get => _FormulaName; set { SetProperty(ref _FormulaName, value); } }
  268. public FormulaPartType FormulaPart { get => _formulaPart; set { SetProperty(ref _formulaPart, value); } }
  269. public string Result { get => _Result; set { SetProperty(ref _Result, value); } }
  270. [SqlSugar.SugarColumn(IsJson = true, ColumnDataType = "nvarchar(2000)")]//必填
  271. public List<ResultInfo> ResultContent { get => _resultContent; set { SetProperty(ref _resultContent, value); } }
  272. public string SN { get => _SN; set { SetProperty(ref _SN, value); } }
  273. public string PartNum { get => _PartNum; set { SetProperty(ref _PartNum, value); } }
  274. }
  275. /// <summary>
  276. /// 本地零件目录(名称 + 数量)。
  277. /// </summary>
  278. public class ParkingLot : BindableBase
  279. {
  280. private int _id;
  281. private string _partName;
  282. private decimal _quantity;
  283. [SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
  284. public int Id { get => _id; set => SetProperty(ref _id, value); }
  285. [SqlSugar.SugarColumn(Length = 200)]
  286. public string PartName { get => _partName; set => SetProperty(ref _partName, value); }
  287. public decimal Quantity { get => _quantity; set => SetProperty(ref _quantity, value); }
  288. }
  289. public class ResultInfo : BindableBase
  290. {
  291. private string resultName;
  292. private string resultValue;
  293. private string result;
  294. public string ResultName { get => resultName; set { SetProperty(ref resultName, value); } }
  295. public string ResultValue { get => resultValue; set { SetProperty(ref resultValue, value); } }
  296. public string Result { get => result; set { SetProperty(ref result, value); } }
  297. }
  298. #endregion
  299. }