服务端的TigerApi 框架,基于.NET6 2024 版本
Rodney Chen
2024-08-07 243e732e8adabbe19fd2ecd87a44b2373260aab2
Tiger.Business.MES/WorkAction/PackingAction.cs
@@ -402,7 +402,7 @@
                        //最外层包装已经完成包装,保存包装数据到数据库
                        else
                        {
                            action = SaveToDB();
                            action = CompletePkg();
                        }
                    }
                    //当前处理的包装层级已经处理完,继续往上保存
@@ -506,36 +506,9 @@
            return list;
        }
        public ApiAction<SubmitOutput> SaveToDB()
        public ApiAction<SubmitOutput> CompletePkg()
        {
            var action = new ApiAction<SubmitOutput>(new SubmitOutput());
            var pkgList = GetPackageList(CurPkg.Item);
            //包装信息保存到在制品信息表
            foreach (var wipSN in CurPosition.CurWipSNs)
            {
                wipSN.TRAY_SN = CurPkg.Item.Package.SN;
                wipSN.CARTON_SN = CurPkg.Item.Package.SN;
            }
            //包装信息保存到工单条码明细表
            var woSNs = CurPosition.WorkBatch.WoSNs.Where(q => CurPosition.CurWipSNs.Any(w => q.SN == w.SN)).ToList();
            foreach (var woSN in woSNs)
            {
                woSN.TRAY_SN = CurPkg.Item.Package.SN;
                woSN.OUTER_SN = CurPkg.Item.Package.SN;
            }
            //保存数据库
            var db = Biz.Db;
            var dbTran = db.UseTran(() =>
            {
                db.Insertable(pkgList, CurPosition.UserCode).ExecuteCommand();
            });
            if (!dbTran.IsSuccess)
            {
                throw dbTran.ErrorException;
            }
            var data = new PackingActionOutput() { PkgInfo = CurPkg };
            data.ExecCode = "Complete";
@@ -599,15 +572,35 @@
                };
                wipActs.Add(wipAct);
            }
            //var woSNs = CurPosition.WorkBatch.WoSNs.Where(q => CurPosition.CurWipSNs.Any(w => q.SN == w.SN)).ToList();
            //创建变量克隆对象用于传入DBSubmitAction中保存当前需要暂存的数据值
            var _wipActs = wipActs.Clone();
            var _pkgList = CurPkg.IsFinished ? GetPackageList(CurPkg.Item) : new();
            //保存数据
            CurStep.DBSubmitAction = () =>
            {
                var db = CurPosition.GetCommitDB();
                db.Storageable(wipActs, CurPosition.UserCode).ExecuteCommand();
                //db.Storageable(CurPosition.CurWipSNs, CurPosition.UserCode).ExecuteCommand();
                //db.Storageable(woSNs, CurPosition.UserCode).ExecuteCommand();
                db.Storageable(_wipActs, CurPosition.UserCode).ExecuteCommand();
                if (_pkgList.Any())
                {
                    db.Insertable(_pkgList, CurPosition.UserCode).ExecuteCommand();
                    foreach (var pkg in _pkgList)
                    {
                        //包装信息保存到在制品信息表
                        db.Updateable<MES_WIP_DATA>()
                            .SetColumns(q => q.TRAY_SN == CurPkg.Item.Package.SN)
                            .SetColumns(q => q.CONTAINER_SN == q.CARTON_SN)
                            .SetColumns(q => q.CARTON_SN == CurPkg.Item.Package.SN)
                            .Where(q => q.WORK_ORDER == pkg.WORK_ORDER && q.SN == pkg.SN)
                            .ExecuteCommand();
                        //包装信息保存到工单条码明细表
                        db.Updateable<BIZ_MES_WO_SN>()
                            .SetColumns(q => q.TRAY_SN == CurPkg.Item.Package.SN)
                            .SetColumns(q => q.OUTER_SN == CurPkg.Item.Package.SN)
                            .Where(q => q.WORK_ORDER == pkg.WORK_ORDER && q.SN == pkg.SN)
                            .ExecuteCommand();
                    }
                }
            };
            if (CurPkg.IsFinished)