服务端的TigerApi 框架,基于.NET6 2024 版本
Rodney Chen
2024-08-16 04dcc3ed97efac23ec778dec4a6afddc6cd9aa65
Tiger.Business.MES/WorkAction/PackingAction.cs
@@ -32,6 +32,7 @@
        public Dictionary<int, BAS_LABEL_TEMP> LabelDic { get; set; }    = new();
        public List<BAS_LABEL_PV> LabelPV { get; set; } = new();
        public int FinishLevel = 0;
        public bool NeedWeighing { get; set; } = false;
        #endregion Propertys & Variables
        #region Functions
@@ -65,6 +66,8 @@
                LabelDic.Add(code.PKG_LEVEL, label);
            }
            LabelPV = Biz.Db.Queryable<BAS_LABEL_PV>().ToList();
            //获取是否包装完后需要称重
            NeedWeighing = Setting.OPTION_2 == "Y";
            //如果工序上下文中没有包装记录则新建一个,有则获取当前的包装记录
            if (CurPosition.Context.ContainsKey("CurPackage") && !CurPosition.Context["CurPackage"].IsNullOrEmpty())
            {
@@ -267,7 +270,41 @@
                    {
                        CurCmd = null;
                        PrintTimes = 0;
                        if (NeedWeighing)
                        {
                            var data = new PackingActionOutput() { PkgInfo = CurPkg };
                            data.ExecCode = "Weighing";
                            data.PkgLevel = CurPkgItem.PKG_LEVEL;
                            CurCmd = data;
                            action.Data.Data = data;
                            //action.LocaleMsg = new($"请把包装[{CurPkgItem.Package.SN}]上称称重");
                            action.LocaleMsg = new("MES.WorkAction.PackingAction.PleaseWeighing", CurPkgItem.Package.SN);
                        }
                        else
                        {
                        action = End();
                        }
                    }
                    break;
                // Complete:完成,完成全部包装后结束行为
                case "Weighing":
                    if (CurCmd.ExecCode == "Weighing")
                    {
                        if (!pInput.WeightInfo.IsNullOrEmpty() && pInput.WeightInfo.Weight > 0)
                        {
                            CurCmd = null;
                            PrintTimes = 0;
                            CurPkgItem.Package.WEIGHT = pInput.WeightInfo.Weight;
                            CurPkgItem.Package.WEIGHT_UNIT = pInput.WeightInfo.Unit;
                            action = End();
                        }
                        else
                        {
                            action.IsSuccessed = false;
                            //action.LocaleMsg = new($"包装[{CurPkgItem.Package.SN}]称重数据异常,请重新上称称重");
                            action.LocaleMsg = new("MES.WorkAction.PackingAction.PleaseWeighingAgain", CurPkgItem.Package.SN);
                            return action;
                        }
                    }
                    break;
                // 手动结束包装,保存暂存的包装数据
@@ -529,10 +566,10 @@
            action.LocaleMsg = new("MES.WorkAction.PackingAction.PackageComplete", CurPkg.Item.PKG_LEVEL, CurPkg.Item.PKG_NAME);
            //手动结束包装则标记行为完成
            if (CurStep.IsNullOrEmpty())
            {
                IsFinished = true;
            }
            //if (CurStep.IsNullOrEmpty())
            //{
            //    IsFinished = true;
            //}
            return action;
        }
@@ -547,6 +584,9 @@
            //记录行为操作记录
            var wipActs = new List<MES_WIP_ACT>();
            //不是手动结束包装则保存行为操作记录
            if (!CurStep.IsNullOrEmpty())
            {
            foreach (var wipSn in CurPosition.CurWipSNs)
            {
                var wipAct = new MES_WIP_ACT()
@@ -587,6 +627,7 @@
                };
                wipActs.Add(wipAct);
            }
            }
            //创建变量克隆对象用于传入DBSubmitAction中保存当前需要暂存的数据值
            var _wipActs = wipActs.Clone();
@@ -595,7 +636,10 @@
            CurStep.DBSubmitAction = () =>
            {
                var db = CurPosition.GetCommitDB();
                if (_wipActs.Any())
                {
                db.Storageable(_wipActs, CurPosition.UserCode).ExecuteCommand();
                }
                if (_pkgList.Any())
                {
                    db.Insertable(_pkgList, CurPosition.UserCode).ExecuteCommand();