This commit is contained in:
余宇波 2025-04-27 13:44:26 +08:00
parent f1aab7790a
commit 7d3a84e9b0
4 changed files with 69 additions and 48 deletions

View File

@ -174,7 +174,10 @@ namespace MyCode.Project.Domain.Message.Response.InvoiceOrder
/// </summary> /// </summary>
public string FPurchaseOrgName { get; set; } public string FPurchaseOrgName { get; set; }
/// <summary>
/// 每包数量
/// </summary>
public decimal CuseQty { get; set; }
} }
} }

View File

@ -191,5 +191,12 @@ namespace MyCode.Project.Domain.Model
/// </summary> /// </summary>
public int? EntityId {get;set;} public int? EntityId {get;set;}
/// <summary>
/// Desc:每包数量
/// Default:
/// Nullable:True
/// </summary>
public decimal? CuseQty {get;set;}
} }
} }

View File

@ -78,7 +78,7 @@ namespace MyCode.Project.Repositories
,[Remark] ,[Remark]
,b.[PurchaseOrderId] ,b.[PurchaseOrderId]
,[InvoiceOrderId] ,[InvoiceOrderId]
,b.CuseQty
,[UnitName] ,[UnitName]
,[TaxRate] ,[TaxRate]
,[FBillTaxAmount] ,[FBillTaxAmount]

View File

@ -240,57 +240,68 @@ namespace MyCode.Project.Services.Implementation
{ {
throw new BaseException("不正确的ID值"); 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<TiaoMa> addList = new List<TiaoMa>(); List<TiaoMa> addList = new List<TiaoMa>();
// 条码 物料编码数量收料通知单号供应商批号key if (orderItem.CuseQty == act.CuseQty)
for (int i = 0; i < baoShu; i++)
{ {
var barcodeList = _tiaoMaRepository.Queryable().Where(t => t.InvoceOrderItemId == orderItem.Id).ToList();
addList = barcodeList;
string FBarCode = $@"{orderItem.MaterialCode}*{act.CuseQty.ToString("F2")}*{orderItem.FBillNo}*{orderItem.FSupplierLot}";
TiaoMa tiaoMa = new TiaoMa();
tiaoMa = AutoMapperHelper.AutoMappToSingle<TiaoMa, InvoiceOrderItem>(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) else
{ {
string FBarCode = $@"{orderItem.MaterialCode}*{decimal.Parse(yu.ToString()).ToString("F2")}*{orderItem.FBillNo}*{orderItem.FSupplierLot}"; orderItem.CuseQty = act.CuseQty;
TiaoMa tiaoMa = new TiaoMa(); _invoiceOrderItemRepository.Update(orderItem);
tiaoMa = AutoMapperHelper.AutoMappToSingle<TiaoMa, InvoiceOrderItem>(orderItem); var order = _invoiceOrderRepository.Queryable().Where(t => t.Id == orderItem.InvoiceOrderId).First();
tiaoMa.Id = Guid.NewGuid();
tiaoMa.FBarCode = FBarCode; decimal zongQty = orderItem.Qty.SafeValue();
tiaoMa.Qty = yu; int yu = (int)Math.Ceiling(zongQty % act.CuseQty);
tiaoMa.SortNum = baoShu+1; int baoShu = 0;
tiaoMa.PurchaseBillNo = orderItem.FBillNo; baoShu = (int)(zongQty / act.CuseQty);
tiaoMa.FBillNo = order.FBillNo;
addList.Add(tiaoMa); // 条码 物料编码数量收料通知单号供应商批号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<TiaoMa, InvoiceOrderItem>(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<TiaoMa, InvoiceOrderItem>(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<AddTiaoMa> addTiaoMas = new List<AddTiaoMa>();
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<IKingDeeService>(this.MerchantId, "AddTiaoMa", "生成条码档案", JsonHelper.ToJson(addTiaoMas), 5);
} }
_tiaoMaRepository.Add(addList);
List<AddTiaoMa> addTiaoMas = new List<AddTiaoMa>();
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<IKingDeeService>(this.MerchantId, "AddTiaoMa", "生成条码档案", JsonHelper.ToJson(addTiaoMas), 5);
TiaoMaResp result = new TiaoMaResp(); TiaoMaResp result = new TiaoMaResp();
result.Id = orderItem.Id; result.Id = orderItem.Id;
result.BarCodeList = addList.Select(t => t.FBarCode).ToList(); result.BarCodeList = addList.Select(t => t.FBarCode).ToList();