服务端的TigerApi 框架,基于.NET6 2024 版本
Ben Lin
23 小时以前 a960900364d19bbf0ad7923a57989609e7fce798
Tiger.Business.WMS/Transaction/ReprintLabel.cs
@@ -150,11 +150,11 @@
                }
                else
                {
                    if (Biz.Db.Queryable<WMS_ITEM>().Any(q=>q.SUPP_LOTNO == rePrints.BatchNo) && (Biz.Db.Queryable<WMS_ITEM>().Where(q=>q.SUPP_LOTNO == rePrints.BatchNo).Sum(x=>x.QTY)>= rePrints.BatchQty)) {
                        action.IsSuccessed = false;
                        action.LocaleMsg = Biz.L($"此库位[{LocationCode}]上的批次[{rePrints.BatchNo}]数量已经够数,不能再上架生成标签");
                        return action;
                    }
                    //if (Biz.Db.Queryable<WMS_ITEM>().Any(q=>q.SUPP_LOTNO == rePrints.BatchNo) && (Biz.Db.Queryable<WMS_ITEM>().Where(q=>q.SUPP_LOTNO == rePrints.BatchNo && q.STATUS == WMS_ITEM.STATUSs.InStore.GetValue()).Sum(x=>x.QTY)>= rePrints.BatchQty)) {
                    //    action.IsSuccessed = false;
                    //    action.LocaleMsg = Biz.L($"此库位[{LocationCode}]上的批次[{rePrints.BatchNo}]数量已经够数,不能再上架生成标签");
                    //    return action;
                    //}
                    foreach (var ent in rePrints.SnList)
                    {
                        string CurSN = DI.Resolve<ICodeRuleCache>()["InitialBarcode"]?.Generate($"{ent.SN}").Data.ToString() ?? "";
@@ -199,7 +199,7 @@
                                ITEM_CODE = inv.Barcode.ItemCode,
                                AUTH_ORG = input.AuthOption.CurOrg,
                                STATUS = WMS_ITEM.STATUSs.WaitIn.GetValue(),
                                QTY = inv.Barcode.Qty.ToDecimal(),
                                QTY = inv.Barcode.Qty.ToDouble(),
                                PROD_DATE = inv.Barcode.DateCode.ToDateTime(),
                                ERP_WH = CurScanShelf.WarehouseCode,
                                UNIT = inv.Barcode.Unit,
@@ -212,7 +212,7 @@
                                SN = inv.Barcode.SN,
                                AUTH_ORG = input.AuthOption.CurOrg,
                                ITEM_CODE = inv.Barcode.ItemCode,
                                QTY = inv.Barcode.Qty.ToDecimal(),
                                QTY = inv.Barcode.Qty.ToDouble(),
                                ERP_WH = CurScanShelf.WarehouseCode,
                                UNIT = inv.Barcode.Unit,
                            };
@@ -235,11 +235,11 @@
                        }
                        else if (inv.Items.Count == 1)
                        {
                            inv.Items.First().QTY = inv.Barcode.Qty.ToDecimal();
                            inv.Items.First().QTY = inv.Barcode.Qty.ToDouble();
                            inv.Items.First().ERP_WH = CurScanShelf.WarehouseCode;
                            inv.Items.First().AUTH_ORG = input.AuthOption.CurOrg;
                            inv.Packages.First().QTY = inv.Barcode.Qty.ToDecimal();
                            inv.Packages.First().QTY = inv.Barcode.Qty.ToDouble();
                            inv.Packages.First().ERP_WH = CurScanShelf.WarehouseCode;
                            inv.Packages.First().AUTH_ORG = input.AuthOption.CurOrg;
                        }
@@ -289,43 +289,43 @@
                        //}
                        //执行上架
                        foreach (var item in inv.Items)
                        {
                            item.TRANS_CODE = "ReprintLabel";
                            item.TRANS_NO = $"ReprintLabel{DateTime.Now:yyyyMMdd}";
                        }
                        Result<PutOnInfo> putonResult = WMS_ITEM_Biz.WmsItem.PutOn(inv, input.AuthOption, nLocation.LOCATION_CODE);
                        if (!putonResult.IsSuccessed)
                        {
                            action.IsSuccessed = false;
                            action.LocaleMsg = putonResult.LocaleMsg;
                            inv = null;
                            CurSN = "";
                            return action;
                        }
                        PutOnInfo putOnInfo = putonResult.Data;
                        items.AddRange(putOnInfo.Items);
                        itemhiss.AddRange(putOnInfo.History);
                        itemPkgs.AddRange(putOnInfo.Packages);
                        itemExts.AddRange(putOnInfo.ItemsExt);
                        //foreach (var item in inv.Items)
                        //{
                        //    item.TRANS_CODE = "ReprintLabel";
                        //    item.TRANS_NO = $"ReprintLabel{DateTime.Now:yyyyMMdd}";
                        //}
                        //Result<PutOnInfo> putonResult = WMS_ITEM_Biz.WmsItem.PutOn(inv, input.AuthOption, nLocation.LOCATION_CODE);
                        //if (!putonResult.IsSuccessed)
                        //{
                        //    action.IsSuccessed = false;
                        //    action.LocaleMsg = putonResult.LocaleMsg;
                        //    inv = null;
                        //    CurSN = "";
                        //    return action;
                        //}
                        //PutOnInfo putOnInfo = putonResult.Data;
                        //items.AddRange(putOnInfo.Items);
                        //itemhiss.AddRange(putOnInfo.History);
                        //itemPkgs.AddRange(putOnInfo.Packages);
                        //itemExts.AddRange(putOnInfo.ItemsExt);
                    }
                    //保存到数据库
                    var db = Business.Biz.Db;
                    var dbTran = db.UseTran(() =>
                    {
                        //入库
                        db.Storageable(items, UserCode).ExecuteCommand();
                        db.Storageable(itemPkgs, UserCode).ExecuteCommand();
                        db.Insertable(itemhiss, UserCode).ExecuteCommand();
                        var x = db.Storageable(itemExts, UserCode).ToStorage();
                        x.AsInsertable.ExecuteCommand();//不存在插入
                        x.AsUpdateable.ExecuteCommand();//存在更新
                    });
                    if (!dbTran.IsSuccess)
                    {
                        Logger.Default.Fatal(dbTran.ErrorException, "Database transaction save exception");
                        throw dbTran.ErrorException;
                    }
                    //var db = Business.Biz.Db;
                    //var dbTran = db.UseTran(() =>
                    //{
                    //    //入库
                    //    db.Storageable(items, UserCode).ExecuteCommand();
                    //    db.Storageable(itemPkgs, UserCode).ExecuteCommand();
                    //    db.Insertable(itemhiss, UserCode).ExecuteCommand();
                    //    var x = db.Storageable(itemExts, UserCode).ToStorage();
                    //    x.AsInsertable.ExecuteCommand();//不存在插入
                    //    x.AsUpdateable.ExecuteCommand();//存在更新
                    //});
                    //if (!dbTran.IsSuccess)
                    //{
                    //    Logger.Default.Fatal(dbTran.ErrorException, "Database transaction save exception");
                    //    throw dbTran.ErrorException;
                    //}
                    action.Data.Data = rePrints;
                    action.LocaleMsg = Biz.L("库位批次条码上架成功");