服务端的TigerApi 框架,基于.NET6 2024 版本
Ben Lin
2024-08-20 37fc700892a509346d5be0a1af2d3de1fe8d3a9e
Tiger.Business.MES/Transaction/Position.cs
@@ -17,7 +17,7 @@
    /// <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)
        {
@@ -56,7 +56,7 @@
        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();
@@ -73,7 +73,8 @@
        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
@@ -125,6 +126,11 @@
                    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)
@@ -181,6 +187,24 @@
            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>
@@ -330,15 +354,6 @@
            return result;
        }
        public object Clone()
        {
            var newObject = this.MemberwiseClone() as Position;
            newObject.Steps = Steps.Clone();
            newObject.CurWipSNs = CurWipSNs.Clone();
            return newObject;
        }
        /// <summary>
        /// 保存工步的数据库提交操作到数据库
        /// </summary>
@@ -374,25 +389,6 @@
                    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()
@@ -503,7 +499,7 @@
                            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 "";
                            }