MesModel.cs 16 KB

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