From 70ab6b916205843cc59df63a7e07e16188bda23b Mon Sep 17 00:00:00 2001 From: yuyubo <1870149533@qq.com> Date: Thu, 5 Jun 2025 17:26:42 +0800 Subject: [PATCH] 11 --- MyCode.Project.Domain/Model/TiaoMa.cs | 14 ++ .../InvoiceOrder/InvoiceOrderService.cs | 18 +- .../PurchaseOrder/PurchaseOrderService.cs | 183 +----------------- 3 files changed, 30 insertions(+), 185 deletions(-) diff --git a/MyCode.Project.Domain/Model/TiaoMa.cs b/MyCode.Project.Domain/Model/TiaoMa.cs index e457867..8166f82 100644 --- a/MyCode.Project.Domain/Model/TiaoMa.cs +++ b/MyCode.Project.Domain/Model/TiaoMa.cs @@ -135,5 +135,19 @@ namespace MyCode.Project.Domain.Model /// public string FBillNo {get;set;} + /// + /// Desc:销售订单号 + /// Default: + /// Nullable:True + /// + public string Fdemandbillno {get;set;} + + /// + /// Desc:备注 + /// Default: + /// Nullable:True + /// + public string Remart {get;set;} + } } diff --git a/MyCode.Project.Services/Implementation/InvoiceOrder/InvoiceOrderService.cs b/MyCode.Project.Services/Implementation/InvoiceOrder/InvoiceOrderService.cs index d6f8e09..d6dfcb0 100644 --- a/MyCode.Project.Services/Implementation/InvoiceOrder/InvoiceOrderService.cs +++ b/MyCode.Project.Services/Implementation/InvoiceOrder/InvoiceOrderService.cs @@ -256,7 +256,7 @@ namespace MyCode.Project.Services.Implementation { throw new BaseException("每包数量必须大于0"); } - //_tiaoMaRepository.Delete(t => t.InvoceOrderItemId == act.Id); + //_tiaoMaRepository.Delete(t => t.InvoceOrderItemId == act.Id); purchaseOrderItem.F_TSPR_Text_qtr1 var orderItem = _invoiceOrderItemRepository.Queryable().Where(t => t.Id == act.Id).First(); if (orderItem == null) { @@ -267,6 +267,12 @@ namespace MyCode.Project.Services.Implementation { throw new BaseException("不正确的ID数据"); } + var purchaseOrderItem = _purchaseOrderItemRepository.Queryable().Where(t => t.Id == orderItem.PurchaseOrderItemId).First(); + if (purchaseOrderItem == null) + { + throw new BaseException("不正确的ID数据"); + } + List addList = new List(); if (orderItem.CuseQty == act.CuseQty) { @@ -276,6 +282,8 @@ namespace MyCode.Project.Services.Implementation { t.SupplierId = order.SupplierId; t.SupplierName = order.SupplierName; + t.Fdemandbillno = purchaseOrderItem.F_TSPR_Text_qtr1; + t.Remart = purchaseOrderItem.Remark; }); @@ -310,6 +318,8 @@ namespace MyCode.Project.Services.Implementation tiaoMa.SupplierId = order.SupplierId; tiaoMa.SupplierName = order.SupplierName; tiaoMa.InvoceOrderItemId = orderItem.Id; + tiaoMa.Fdemandbillno = purchaseOrderItem.F_TSPR_Text_qtr1; + tiaoMa.Remart = purchaseOrderItem.Remark; addList.Add(tiaoMa); } if (yu > 0) @@ -326,6 +336,8 @@ namespace MyCode.Project.Services.Implementation tiaoMa.SupplierId = order.SupplierId; tiaoMa.SupplierName = order.SupplierName; tiaoMa.InvoceOrderItemId = orderItem.Id; + tiaoMa.Fdemandbillno = purchaseOrderItem.F_TSPR_Text_qtr1; + tiaoMa.Remart = purchaseOrderItem.Remark; addList.Add(tiaoMa); } if (addList.Count > 0) @@ -345,8 +357,8 @@ namespace MyCode.Project.Services.Implementation FSupplierLot = t.FSupplierLot == null ? "" : t.FSupplierLot, FMaterialId = t.MaterialCode, FLot = t.MSSSupplierLot, - FQty = t.Qty.Value.ToString() - }).ToList(); + FQty = t.Qty.Value.ToString(), + }).ToList(); _workProcessService.Add(this.MerchantId, "AddTiaoMa", "生成条码档案", JsonHelper.ToJson(addTiaoMas), 5); } diff --git a/MyCode.Project.Services/Implementation/PurchaseOrder/PurchaseOrderService.cs b/MyCode.Project.Services/Implementation/PurchaseOrder/PurchaseOrderService.cs index e6a2c74..d7cbea0 100644 --- a/MyCode.Project.Services/Implementation/PurchaseOrder/PurchaseOrderService.cs +++ b/MyCode.Project.Services/Implementation/PurchaseOrder/PurchaseOrderService.cs @@ -298,188 +298,7 @@ namespace MyCode.Project.Services.Implementation } #endregion - //#region BatchAddInvoiceOrder(选中明细生成发货通知单) - ///// - ///// 选中明细生成发货通知单 - ///// - ///// - ///// - ///// - //[TransactionCallHandler] - //public string BatchAddInvoiceOrderOld(AddOrder act , LoginInfo loginInfo) - //{ - // if (!act.FaHuoDate.HasValue) - // act.FaHuoDate = DateTime.Now; - // List updateList = act.UpDateList; - // string supplierId = loginInfo.SupplierId; - // var ids = updateList.Select(t => t.Id).ToList(); ; - // var list = _purchaseOrderItemRepository.Queryable().Where(t => t.SupplierId == supplierId && ids.Contains(t.Id)).ToList(); - // var fidList = list.Select(t => t.Fid).ToList(); - // var orderHeadList = _purchaseOrderRepository.Queryable().Where(t => fidList.Contains( t.FiD)).ToList(); - // if (orderHeadList == null) - // { - // throw new BaseException("订单不属于此供应商"); - // } - // var FPurchaseOrgIdList = orderHeadList.Select(t => t.FPurchaseOrgId).Distinct().ToList(); - // if (FPurchaseOrgIdList.Count > 1) - // { - // throw new BaseException("不能跨采购组织创建发货通知单"); - // } - - // if (loginInfo.IfForeign == 1 && string.IsNullOrWhiteSpace(act.F_VHUB_Text)) - // { - // throw new BaseException("国外的供应商发票号和发票日期是必填."); - // } - - // InvoiceOrder NewInvoiceOrder = new InvoiceOrder(); - // NewInvoiceOrder.Id = Guid.NewGuid(); - // NewInvoiceOrder.FiD = null; - // NewInvoiceOrder.Status = 1; - // NewInvoiceOrder.EditTime = DateTime.Now; - // NewInvoiceOrder.Editor = loginInfo.Name; - // NewInvoiceOrder.CreateTime = DateTime.Now; - // NewInvoiceOrder.Creater = loginInfo.Name; - // NewInvoiceOrder.SupplierId = supplierId; - // NewInvoiceOrder.SupplierName = orderHeadList.FirstOrDefault().SupplierName; - // NewInvoiceOrder.FDate = act.FaHuoDate; - // NewInvoiceOrder.Sheet = DateTime.Now.ToString("yyMMddhhmmssfff"); - // NewInvoiceOrder.PurchaseOrderId = 0; - // NewInvoiceOrder.F_VHUB_Text = act.F_VHUB_Text; - - // NewInvoiceOrder.F_URXD_Date = act.F_URXD_Date; - // NewInvoiceOrder.FPurchaseOrgId = orderHeadList.FirstOrDefault().FPurchaseOrgId; - // NewInvoiceOrder.FPurchaseOrgName = orderHeadList.FirstOrDefault().FPurchaseOrgName; - // List invoiceOrderItems = new List(); - // //invoiceOrderItems=list.Select(t=>new InvoiceOrderItem {Id=Guid.NewGuid(), Amount1=t.Amount1, Amount2=t.Amount2,t }) - // var allInvoiceOrderItem = _invoiceOrderItemRepository.Queryable().Where(t => ids.Contains(t.PurchaseOrderItemId.Value)).ToList(); - // List errorList = new List(); - - // string FormId = "PUR_PurchaseOrder"; - // var entityIdList = list.Select(t => t.EntityId).ToList(); - // BillPush billPush = new BillPush(); - // billPush.EntryIds = string.Join(",", entityIdList); - // billPush.TargetFormId = "PUR_ReceiveBill"; - // billPush.IsEnableDefaultRule = true; - // billPush.CustomParams = new CustomParams(); - // billPush.CustomParams.AutoAudit = false; - // billPush.CustomParams.ScanEntry = new List(); - - // List addTiaoMas = new List(); - - // list.ForEach(t => - // { - // //var allqty = allInvoiceOrderItem.Where(h => h.PurchaseOrderItemId == t.Id ).Sum(h => h.Qty).SafeValue(); - // var temp = updateList.Where(h => h.Id == t.Id).FirstOrDefault(); - // if (temp != null) - // { - // var purchaseOrder = orderHeadList.FirstOrDefault(h=>h.FiD==t.Fid); - // if (purchaseOrder == null) - // throw new BaseException("找不到对应的采购订单主表信息"); - // if ((temp.Qty ) > (t.Qty - t.MSSReceiveQty)) - // { - // string error = $@"{t.MaterialName}"; - // errorList.Add(error); - // } - // //else if ((temp.Qty + allqty) == t.Qty) - // //{ - - // //} - // else - // { - // InvoiceOrderItem invoiceOrderItemTemp = new InvoiceOrderItem(); - // invoiceOrderItemTemp.Id = Guid.NewGuid(); - // invoiceOrderItemTemp.InvoiceOrderId = NewInvoiceOrder.Id; - // invoiceOrderItemTemp.NewChengNuoJiaoQi = t.NewChengNuoJiaoQi; - // invoiceOrderItemTemp.ChengNuoJiaoQi = t.ChengNuoJiaoQi; - // invoiceOrderItemTemp.UnitPrice = t.UnitPrice; - // invoiceOrderItemTemp.PurchaseOrderId = t.Fid; - // invoiceOrderItemTemp.MaterialCode = t.MaterialCode; - // invoiceOrderItemTemp.MaterialName = t.MaterialName; - // invoiceOrderItemTemp.Amount1 = t.UnitPrice * temp.Qty; - // invoiceOrderItemTemp.Amount2 = t.UnitPrice * temp.Qty * t.TaxRate; - // invoiceOrderItemTemp.DeliveryDate = act.FaHuoDate; - // invoiceOrderItemTemp.Qty = temp.Qty; - // invoiceOrderItemTemp.Remark = t.Remark; - // invoiceOrderItemTemp.SpecificationModel = t.SpecificationModel; - // invoiceOrderItemTemp.TaxAmount = t.TaxAmount; - // invoiceOrderItemTemp.PurchaseOrderItemId = t.Id; - // invoiceOrderItemTemp.FSupplierLot = temp.FSupplierLot==null ?"" : temp.FSupplierLot; - // invoiceOrderItemTemp.MSSSupplierLot = t.MSSSupplierLot; - // invoiceOrderItemTemp.UnitName = t.UnitName; - // invoiceOrderItemTemp.FBillNo = purchaseOrder.FBillNo; - // invoiceOrderItemTemp.PurchaseEntityId = t.EntityId; - // invoiceOrderItems.Add(invoiceOrderItemTemp); - // ScanEntry tempUpdate = new ScanEntry(); - // tempUpdate.Qty = (int)temp.Qty; - // tempUpdate.FENTRYID = t.EntityId.SafeValue(); - // tempUpdate.FSupplierLot = temp.FSupplierLot; - // billPush.CustomParams.ScanEntry.Add(tempUpdate); - // billPush.CustomParams.FPH= act.F_VHUB_Text; - // billPush.CustomParams.F_URXD_Date = act.F_URXD_Date; - // if (string.IsNullOrWhiteSpace(billPush.CustomParams.F_URXD_Date)) - // billPush.CustomParams.F_URXD_Date = null; - // t.FReceiveQty = t.FReceiveQty + temp.Qty; - // t.FRemainReceiveQty = t.FRemainReceiveQty - temp.Qty; - - - // } - - // } - // }); - - // if (errorList.Count > 0) - // { - // string e = string.Join(",", errorList); - // if(loginInfo.IfForeign==0) - // e = e + "的总发货数量大于总采购数量,请检查"; - // else - // e=e+" The delivery QTY exceeds the PO's maximum QTY!"; - // throw new BaseException(e); - // } - // else - // { - // try - // { - // var resultKD= _kingDeeService.Push(FormId, billPush); - // LogHelper.Info("推送收料订单"); - // LogHelper.Info(resultKD); - // //var sda = resultKD.GetProperty("IsSuccess") [["SuccessEntitys"]; - // dynamic data = JsonHelper.ToObject(resultKD); - // int row = 0; - // foreach (var item in data) - // { - // NewInvoiceOrder.FBillNo = item["Number"]; - // NewInvoiceOrder.FiD = item["Id"]; - // row++; - // } - // _invoiceOrderRepository.Add(NewInvoiceOrder); - // _invoiceOrderItemRepository.Add(invoiceOrderItems); - // _purchaseOrderItemRepository.Update(list); - - // ////物料编码,数量,收料通知单号,供应商批号,key - // //AddTiaoMa addTiao = new AddTiaoMa(); - - // //addTiaoMas = invoiceOrderItems.Select(t => new AddTiaoMa { - // // FBarCode = $@"{t.MaterialCode}*{t.Qty.Value.ToString("F2")}*{NewInvoiceOrder.FBillNo}*{t.FSupplierLot}" - // //, FBarCodeRule= "03", FBillCode= NewInvoiceOrder.FBillNo, FSupplierLot=t.FSupplierLot==null?"": t.FSupplierLot, FMaterialId=t.MaterialCode, FQty=t.Qty.Value.ToString() - // //}).ToList(); - // _workProcessService.Add(this.MerchantId, "SetMSSSupplierLot", "写入金蝶的美塞斯批号", NewInvoiceOrder.Sheet, 1); - - - // } - // catch (Exception ex) - // { - // LogHelper.Error("推送收料订单出错"); - // LogHelper.Error(ex); - // throw new BaseException(ex.Message); - // } - - // } - - // return NewInvoiceOrder.Sheet; - //} - //#endregion - + /// /// 抓取金蝶的采购订单 ///