From 950fac9fd7b9477fc2bbe3253d217f62ac7608e5 Mon Sep 17 00:00:00 2001
From: wxw <Administrator@DESKTOP-5BIMHQ3>
Date: 星期一, 21 七月 2025 17:01:21 +0800
Subject: [PATCH] SAP接口开发

---
 Wms/WMS.BLL/BllAsnServer/ArrivalNoticeServer.cs |   44 +++++++++++++++++++++++++++++---------------
 1 files changed, 29 insertions(+), 15 deletions(-)

diff --git a/Wms/WMS.BLL/BllAsnServer/ArrivalNoticeServer.cs b/Wms/WMS.BLL/BllAsnServer/ArrivalNoticeServer.cs
index 715a0b7..46d5205 100644
--- a/Wms/WMS.BLL/BllAsnServer/ArrivalNoticeServer.cs
+++ b/Wms/WMS.BLL/BllAsnServer/ArrivalNoticeServer.cs
@@ -4,12 +4,14 @@
 using Model.ModelDto.SysDto;
 using Model.ModelVm;
 using Model.ModelVm.SysVm;
+using Newtonsoft.Json;
 using SqlSugar;
 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Linq.Expressions;
 using System.Threading.Tasks;
+using Utility.Tools;
 using WMS.BLL.LogServer;
 using WMS.DAL;
 using WMS.Entity.BllAsnEntity;
@@ -1324,6 +1326,7 @@
 
                     var detailModel = new BllArrivalNoticeDetail()
                     {
+                        OrderDetailCode = asnDetailModel.lineNo,
                         ASNNo = asnNo,
                         SkuNo = asnDetailModel.skuNo.ToString(),
                         SkuName = skuModel.SkuName,
@@ -1334,9 +1337,9 @@
                         FactQty = 0,
                         CompleteQty = 0,
                         PackagNo = skuModel.PackagNo,
-                        SupplierLot = asnDetailModel.supplyBatch,//鐢熶骇鏃ユ湡
-                        Lot1 = asnDetailModel.productionDate,//杩囨湡鏃ユ湡
-                        Lot2 = asnDetailModel.expireDate,
+                        SupplierLot = asnDetailModel.supplyBatch,
+                        Lot1 = asnDetailModel.productionDate,//鐢熶骇鏃ユ湡
+                        Lot2 = asnDetailModel.expireDate,//杩囨湡鏃ユ湡
                         Status = "0",
                         IsSampling = "0",
                         InspectStatus = "0",
@@ -1389,28 +1392,39 @@
                 {
                     throw new Exception("澶嶆牳澶辫触锛屽鏍镐汉鍛樺拰鍏抽棴璁㈠崟浜哄憳涓嶈兘鐩稿悓锛�");
                 }
-                var list = new List<AsnDetail>();
+                var list = new List<BackAsnDetail>();
                 foreach (var d in detail)
                 {
-                    var item = new AsnDetail()
+                    var mater = Db.Queryable<SysMaterials>().First(w => w.IsDel == "0" && w.SkuNo == d.SkuNo);
+                    if (mater == null)
                     {
-                        SkuNo = d.SkuNo,
-                        LotNo = d.LotNo,
-                        Qty = d.CompleteQty,
-                        PackagNo = d.PackagNo,
-                        SupplierLot = d.SupplierLot
+                        throw new Exception($"澶嶆牳澶辫触锛岀墿鏂欑紪鐮�:{d.SkuNo}鐨勭墿鏂欎俊鎭笉瀛樺湪");
+                    }
+                    var item = new BackAsnDetail()
+                    {
+                        POSNR=d.OrderDetailCode,
+                        MATNR = d.SkuNo,
+                        MAKTX=d.SkuName,
+                        LFIMG = d.CompleteQty.ToString(),
+                        MEINS= mater.UnitNo,
+                        CHARG = d.LotNo,
+                        HSDAT = d.Lot1,
+                        VFDAT = d.Lot2
                     };
                     list.Add(item);
                 }
-                var soInfo = new AsnInfo()
+                var soInfo = new BackAsnVm()
                 {
-                    OrderCode = notice.OrderCode,
-                    AsnDetails = list
+                    ZUUID = Guid.NewGuid().ToString(),
+                    VBELN = notice.OrderCode,
+                    LFART = notice.Type,
+                    WADAT_IST = Convert.ToDateTime(notice.CompleteTime).ToString("yyyy-MM-dd"),
+                    ITEM = list
                 };
 
                 #region 閫氳繃鎺ュ彛鍙戦�佽嚦erp 
                 //绯荤粺瀵规帴鍚庢斁寮�
-                /*var jsonData = JsonConvert.SerializeObject(soInfo);
+                var jsonData = JsonConvert.SerializeObject(soInfo);
 
                 var response = HttpHelper.DoPost(url, jsonData, "鍏ュ簱鍗曞畬鎴愪笂浼�", "ERP");
 
@@ -1418,7 +1432,7 @@
                 if (obj.Success != 0)
                 {
                     throw new Exception("涓婁紶澶辫触" + obj.Message);
-                }*/
+                }
                 #endregion
 
                 notice.Status = "4";

--
Gitblit v1.8.0