diff --git a/MyCode.Project.Domain/Message/Response/InvoiceOrder/InvoiceOrderPageList.cs b/MyCode.Project.Domain/Message/Response/InvoiceOrder/InvoiceOrderPageList.cs index e50a1ea..6c4bfbe 100644 --- a/MyCode.Project.Domain/Message/Response/InvoiceOrder/InvoiceOrderPageList.cs +++ b/MyCode.Project.Domain/Message/Response/InvoiceOrder/InvoiceOrderPageList.cs @@ -174,7 +174,10 @@ namespace MyCode.Project.Domain.Message.Response.InvoiceOrder /// public string FPurchaseOrgName { get; set; } - + /// + /// 每包数量 + /// + public decimal CuseQty { get; set; } } } diff --git a/MyCode.Project.Domain/Model/InvoiceOrderItem.cs b/MyCode.Project.Domain/Model/InvoiceOrderItem.cs index f8dd3f3..41d1b14 100644 --- a/MyCode.Project.Domain/Model/InvoiceOrderItem.cs +++ b/MyCode.Project.Domain/Model/InvoiceOrderItem.cs @@ -191,5 +191,12 @@ namespace MyCode.Project.Domain.Model /// public int? EntityId {get;set;} + /// + /// Desc:每包数量 + /// Default: + /// Nullable:True + /// + public decimal? CuseQty {get;set;} + } } diff --git a/MyCode.Project.Repositories/InvoiceOrderRepository.cs b/MyCode.Project.Repositories/InvoiceOrderRepository.cs index ad6823e..f7263c0 100644 --- a/MyCode.Project.Repositories/InvoiceOrderRepository.cs +++ b/MyCode.Project.Repositories/InvoiceOrderRepository.cs @@ -78,7 +78,7 @@ namespace MyCode.Project.Repositories ,[Remark] ,b.[PurchaseOrderId] ,[InvoiceOrderId] - + ,b.CuseQty ,[UnitName] ,[TaxRate] ,[FBillTaxAmount] diff --git a/MyCode.Project.Services/Implementation/InvoiceOrder/InvoiceOrderService.cs b/MyCode.Project.Services/Implementation/InvoiceOrder/InvoiceOrderService.cs index 2f9cefb..184d8bc 100644 --- a/MyCode.Project.Services/Implementation/InvoiceOrder/InvoiceOrderService.cs +++ b/MyCode.Project.Services/Implementation/InvoiceOrder/InvoiceOrderService.cs @@ -240,57 +240,68 @@ namespace MyCode.Project.Services.Implementation { throw new BaseException("不正确的ID值"); } - var order = _invoiceOrderRepository.Queryable().Where(t => t.Id == orderItem.InvoiceOrderId).First(); - - decimal zongQty = orderItem.Qty.SafeValue(); - int yu =(int) Math.Ceiling( zongQty % act.CuseQty); - int baoShu = 0; - baoShu = (int)(zongQty / act.CuseQty); List addList = new List(); - // 条码 :物料编码,数量,收料通知单号,供应商批号,key - for (int i = 0; i < baoShu; i++) + if (orderItem.CuseQty == act.CuseQty) { - - string FBarCode = $@"{orderItem.MaterialCode}*{act.CuseQty.ToString("F2")}*{orderItem.FBillNo}*{orderItem.FSupplierLot}"; - TiaoMa tiaoMa = new TiaoMa(); - tiaoMa = AutoMapperHelper.AutoMappToSingle(orderItem); - tiaoMa.Id = Guid.NewGuid(); - tiaoMa.FBarCode = FBarCode; - tiaoMa.Qty = act.CuseQty; - tiaoMa.SortNum = i+1; - tiaoMa.PurchaseBillNo = orderItem.FBillNo; - tiaoMa.FBillNo = order.FBillNo; - addList.Add(tiaoMa); + var barcodeList = _tiaoMaRepository.Queryable().Where(t => t.InvoceOrderItemId == orderItem.Id).ToList(); + addList = barcodeList; + } - if (yu > 0) - { - string FBarCode = $@"{orderItem.MaterialCode}*{decimal.Parse(yu.ToString()).ToString("F2")}*{orderItem.FBillNo}*{orderItem.FSupplierLot}"; - TiaoMa tiaoMa = new TiaoMa(); - tiaoMa = AutoMapperHelper.AutoMappToSingle(orderItem); - tiaoMa.Id = Guid.NewGuid(); - tiaoMa.FBarCode = FBarCode; - tiaoMa.Qty = yu; - tiaoMa.SortNum = baoShu+1; - tiaoMa.PurchaseBillNo = orderItem.FBillNo; - tiaoMa.FBillNo = order.FBillNo; - addList.Add(tiaoMa); - } - - _tiaoMaRepository.Add(addList); - - List addTiaoMas = new List(); - addTiaoMas = addList.Select(t => new AddTiaoMa + else { - FBarCode =t.FBarCode, - FBarCodeRule = "03", - FBillCode = t.FBillNo, - FSupplierLot = t.FSupplierLot == null ? "" : t.FSupplierLot, - FMaterialId = t.MaterialCode, - FLot = t.MSSSupplierLot, - FQty = t.Qty.Value.ToString() - }).ToList(); - _workProcessService.Add(this.MerchantId, "AddTiaoMa", "生成条码档案", JsonHelper.ToJson(addTiaoMas), 5); + orderItem.CuseQty = act.CuseQty; + _invoiceOrderItemRepository.Update(orderItem); + var order = _invoiceOrderRepository.Queryable().Where(t => t.Id == orderItem.InvoiceOrderId).First(); + decimal zongQty = orderItem.Qty.SafeValue(); + int yu = (int)Math.Ceiling(zongQty % act.CuseQty); + int baoShu = 0; + baoShu = (int)(zongQty / act.CuseQty); + + // 条码 :物料编码,数量,收料通知单号,供应商批号,key + for (int i = 0; i < baoShu; i++) + { + + string FBarCode = $@"{orderItem.MaterialCode}*{act.CuseQty.ToString("F2")}*{orderItem.FBillNo}*{orderItem.FSupplierLot}"; + TiaoMa tiaoMa = new TiaoMa(); + tiaoMa = AutoMapperHelper.AutoMappToSingle(orderItem); + tiaoMa.Id = Guid.NewGuid(); + tiaoMa.FBarCode = FBarCode; + tiaoMa.Qty = act.CuseQty; + tiaoMa.SortNum = i + 1; + tiaoMa.PurchaseBillNo = orderItem.FBillNo; + tiaoMa.FBillNo = order.FBillNo; + addList.Add(tiaoMa); + } + if (yu > 0) + { + string FBarCode = $@"{orderItem.MaterialCode}*{decimal.Parse(yu.ToString()).ToString("F2")}*{orderItem.FBillNo}*{orderItem.FSupplierLot}"; + TiaoMa tiaoMa = new TiaoMa(); + tiaoMa = AutoMapperHelper.AutoMappToSingle(orderItem); + tiaoMa.Id = Guid.NewGuid(); + tiaoMa.FBarCode = FBarCode; + tiaoMa.Qty = yu; + tiaoMa.SortNum = baoShu + 1; + tiaoMa.PurchaseBillNo = orderItem.FBillNo; + tiaoMa.FBillNo = order.FBillNo; + addList.Add(tiaoMa); + } + + _tiaoMaRepository.Add(addList); + + List addTiaoMas = new List(); + addTiaoMas = addList.Select(t => new AddTiaoMa + { + FBarCode = t.FBarCode, + FBarCodeRule = "03", + FBillCode = t.FBillNo, + FSupplierLot = t.FSupplierLot == null ? "" : t.FSupplierLot, + FMaterialId = t.MaterialCode, + FLot = t.MSSSupplierLot, + FQty = t.Qty.Value.ToString() + }).ToList(); + _workProcessService.Add(this.MerchantId, "AddTiaoMa", "生成条码档案", JsonHelper.ToJson(addTiaoMas), 5); + } TiaoMaResp result = new TiaoMaResp(); result.Id = orderItem.Id; result.BarCodeList = addList.Select(t => t.FBarCode).ToList();