| | |
| | | /// <summary> |
| | | /// MES岗位事务 |
| | | /// </summary> |
| | | public class Position : MESTransactionBase, IPosition, ICloneable |
| | | public class Position : MESTransactionBase, IPosition |
| | | { |
| | | public IPosition Init(string id, string apiHost, string userCode, string postCode) |
| | | { |
| | |
| | | public WorkBatch CurBatch { get; set; } |
| | | public IWorkBatch WorkBatch => CurBatch; |
| | | public List<MES_WIP_DATA> CurWipSNs { get; set; } = new(); |
| | | public string CurSN => CurWipSNs.Any() ? (CurWipSNs.First().TRAY_SN.IsNullOrEmpty() ? CurWipSNs.First().SN : CurWipSNs.First().TRAY_SN) : ""; |
| | | public string CurSN => (CurWipSNs.Any() ? (CurWipSNs.First().TRAY_SN.IsNullOrEmpty() ? CurWipSNs.First().SN : CurWipSNs.First().TRAY_SN) : ""); |
| | | public List<MES_WIP_HIS> CurWipSNHiss { get; set; } = new(); |
| | | public List<MES_WIP_DFT> CurDefects { get; set; } = new(); |
| | | public Dictionary<string, object> Context { get; set; } = new(); |
| | |
| | | public bool NeedTemporaryStoreDBCommitAction { get; set; } = false; |
| | | protected List<Action> DBCommitList { get; set; } = new(); |
| | | protected List<Position> NodeCommitList { get; set; } = new(); |
| | | |
| | | protected Dictionary<string, OperInfo> OperInfoDic { get; set; } = new(); |
| | | protected OperInfo CurOperInfo { get; set; } |
| | | #endregion Propertys & Variables |
| | | |
| | | #region Functions |
| | |
| | | WoContext.WoBatchDic.Add(wb.Batch.BATCH_NO, wb); |
| | | } |
| | | CurBatch = WoContext.GetBatch(input.OrderNo, CurLine.LINE_CODE); |
| | | if (!OperInfoDic.ContainsKey(CurBatch.Batch.BATCH_NO)) |
| | | { |
| | | OperInfoDic.Add(CurBatch.Batch.BATCH_NO, new()); |
| | | } |
| | | |
| | | action.Data = new { WorkOrder = CurBatch.WO, Bacth = CurBatch.Batch }; |
| | | } |
| | | catch (Exception ex) |
| | |
| | | CurWipSNHiss.Clear(); |
| | | CurStep = null; |
| | | CurDefects.Clear(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 设置当前条码的工序信息 |
| | | /// </summary> |
| | | public OperInfo SetOperNodeInfo(OperInfo info) |
| | | { |
| | | if (CurWipSNs.Any()) |
| | | { |
| | | info.CurNode = CurWipSNs.First().NODE_NAME; |
| | | info.NextNode = string.Join(",", CurBatch.GetNextNodes(CurWipSNs.First()).Select(q => q.NODE_NAME)); |
| | | } |
| | | else |
| | | { |
| | | info.CurNode = " — "; |
| | | info.NextNode = " — "; |
| | | } |
| | | return info; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | return result; |
| | | } |
| | | |
| | | public object Clone() |
| | | { |
| | | var newObject = this.MemberwiseClone() as Position; |
| | | newObject.Steps = Steps.Clone(); |
| | | newObject.CurWipSNs = CurWipSNs.Clone(); |
| | | |
| | | return newObject; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 保存工步的数据库提交操作到数据库 |
| | | /// </summary> |
| | |
| | | throw dbTran.ErrorException; |
| | | } |
| | | } |
| | | |
| | | |
| | | //if (NeedTemporaryStoreDBCommitAction) |
| | | //{ |
| | | |
| | | |
| | | // NodeCommitList.Add(this.Clone() as Position); |
| | | //} |
| | | //else |
| | | //{ |
| | | // //保存成功则清空提交操作列表 |
| | | // foreach (var item in NodeCommitList) |
| | | // { |
| | | // item?.DoSaveToDB(); |
| | | // item?.Dispose(); |
| | | // } |
| | | // DoSaveToDB(); |
| | | // NodeCommitList.Clear(); |
| | | //} |
| | | } |
| | | |
| | | protected void DoSaveToDB() |
| | |
| | | switch (pv.VAR_METHOD) |
| | | { |
| | | case "GetCartonGenerate": |
| | | return Biz.CodeRule[lv.BARCODE_RULE].Generate($"{WorkBatch.Batch.BATCH_NO}-{WorkBatch.Batch.PLAN_QTY}-").Data.ToString(); |
| | | return Biz.CodeRule[lv.BARCODE_RULE ?? ""]?.Generate($"{WorkBatch.Batch.BATCH_NO}-{WorkBatch.Batch.PLAN_QTY}-").Data.ToString() ?? ""; |
| | | default: |
| | | return ""; |
| | | } |