| | |
| | | using Tiger.IBusiness; |
| | | using Tiger.Model.MES.Yada; |
| | | using Apache.NMS.ActiveMQ.Commands; |
| | | using System.Diagnostics; |
| | | |
| | | namespace Tiger.Business.WMS.Transaction |
| | | { |
| | |
| | | action.LocaleMsg = Biz.L("WMS.RePrint.ScanItem.SnEmptyFailure"); |
| | | return SetOutPutMqttMsg(action, input.Locale); |
| | | } |
| | | var LotNos = Biz.DataSource["YadaU9C"].Client.Queryable<mes_WhLotCodeQtyInfo>().Where(t => t.Bin == input.SN).ToList(); |
| | | var LotNos = Biz.DataSource["YadaU9C"].Client.Ado.SqlQuery<mes_WhLotCodeQtyInfo>($"select *,'' as ID from mes_WhLotCodeQtyInfo where Bin = '{input.SN}'"); |
| | | //Biz.DataSource["YadaU9C"].Client.Queryable<mes_WhLotCodeQtyInfo>().Where(t => t.Bin == input.SN).ToList(); |
| | | CurScanShelf = new ScanShelfInfo(); |
| | | // 查询货架信息 |
| | | var whUnit = await Biz.Db.Queryable<V_WH_UNIT>().Where(t => (t.SHELF_CODE.ToUpper() == input.SN || t.LOCATION_CODE.ToUpper() == input.SN) && t.AUTH_ORG == OrgCode).IncludesAllFirstLayer().FirstAsync(); |
| | |
| | | CurScanShelf.IsSmartRack = false; |
| | | LocationCode = whUnit.LOCATION_CODE; |
| | | } |
| | | else { |
| | | action.IsSuccessed = false; |
| | | //action.LocaleMsg = Biz.L("请输入或扫描有效的货架/储位码"); |
| | | action.LocaleMsg = Biz.L("WMS.Default.ScanShelf.ShelfCanNotEmpty"); |
| | | return action; |
| | | } |
| | | var temps = new List<TemplateInput>(); |
| | | foreach (var item in LotNos) |
| | | { |
| | |
| | | }; |
| | | temps.Add(temp); |
| | | } |
| | | Biz.Db.Storageable(LotNos, UserCode).ExecuteCommand(); |
| | | |
| | | var y = Biz.Db.Storageable(LotNos, UserCode) |
| | | .WhereColumns(t => new { t.ItemCode, t.LotCode }) |
| | | .ToStorage(); |
| | | y.AsInsertable.ExecuteCommand(); |
| | | y.AsUpdateable.IgnoreColumns(x => x.ID).ExecuteCommand(); |
| | | action.Data.Data = temps; |
| | | action.LocaleMsg = Biz.L("WMS.RePrint.ScanItem.ScanSuccessed"); |
| | | } |
| | |
| | | } |
| | | 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() ?? ""; |
| | |
| | | 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, |
| | |
| | | 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, |
| | | }; |
| | |
| | | } |
| | | 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; |
| | | } |
| | |
| | | //} |
| | | |
| | | //执行上架 |
| | | 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; |
| | | //} |
| | | |
| | | LocationCode = ""; |
| | | action.Data.Data = rePrints; |
| | | action.LocaleMsg = Biz.L("库位批次条码上架成功"); |
| | | } |