From aa5a0ac9a7d35d3a072fbe164ded24adbaa68b17 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期二, 04 十一月 2025 12:29:05 +0800
Subject: [PATCH] Merge branch 'master' of http://115.159.85.185:8098/r/ZhiHuiQiCe/FangCangZhiNeng

---
 新建文件夹/WIDESEA_WMSServer/WIDESEA_Common/MessageEnum.cs                                    |    6 +++
 新建文件夹/WMS/src/extension/stock/Dt_Inventory_Batch.js                                      |   13 +++---
 新建文件夹/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/NewBusiness.cs                       |    4 +-
 新建文件夹/WIDESEA_WMSServer/WIDESEA_ISquareCabinServices/IInventoryServices.cs               |    2 
 新建文件夹/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/SquareCabin/InventoryController.cs |    4 +-
 新建文件夹/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/InventoryServices.cs                 |   77 +++++++++++++++++++++++---------------
 6 files changed, 65 insertions(+), 41 deletions(-)

diff --git "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_Common/MessageEnum.cs" "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_Common/MessageEnum.cs"
index efb06df..18ca791 100644
--- "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_Common/MessageEnum.cs"
+++ "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_Common/MessageEnum.cs"
@@ -42,6 +42,12 @@
         /// </summary>
         [Description("鍑哄簱鍗曟姤璀�")]
         OutOrderAlarm,
+
+        /// <summary>
+        /// ERP鍚屾涓婃父鎶ヨ
+        /// </summary>
+        [Description("涓嶦RP鍚屾鎶ヨ")]
+        SynchronismAlarm
     }
 
     public enum MessageStatusEnum
diff --git "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_ISquareCabinServices/IInventoryServices.cs" "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_ISquareCabinServices/IInventoryServices.cs"
index 9ca543d..f5f223d 100644
--- "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_ISquareCabinServices/IInventoryServices.cs"
+++ "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_ISquareCabinServices/IInventoryServices.cs"
@@ -21,7 +21,7 @@
       /// <param name="goods_no">鐗╂枡缂栫爜</param>
       /// <param name="batch_num">鎵规鍙�</param>
       /// <returns></returns>
-        public WebResponseContent GetInventoryList(string goods_no,string batch_num);
+        public WebResponseContent GetInventoryList(int[] key);
 
         //public WebResponseContent CreateAllocatInOut(Dt_MaterielInfo materielInfo);
 
diff --git "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/InventoryServices.cs" "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/InventoryServices.cs"
index d0f0bb3..ec8fbe9 100644
--- "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/InventoryServices.cs"
+++ "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/InventoryServices.cs"
@@ -1,12 +1,7 @@
 锘縰sing HslCommunication;
-using MailKit.Search;
 using Newtonsoft.Json;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection.Metadata;
-using System.Text;
-using System.Threading.Tasks;
+using SqlSugar;
+using WIDESEA_Common;
 using WIDESEA_Common.OrderEnum;
 using WIDESEA_Common.StockEnum;
 using WIDESEA_Common.TaskEnum;
@@ -31,11 +26,15 @@
         private readonly ICabinOrderServices _cabinOrderServices;
         private readonly IDeliveryOrderServices _deliveryOrderServices;
         private readonly ISupplyTaskService _supplyTaskService;
-        public InventoryServices(IRepository<Dt_Inventory> BaseDal, ICabinOrderServices cabinOrderServices, IDeliveryOrderServices deliveryOrderServices, ISupplyTaskService supplyTaskService) : base(BaseDal)
+        private readonly IInventory_BatchServices _inventoryBatchServices;
+        private readonly IMessageInfoService _infoService;
+        public InventoryServices(IRepository<Dt_Inventory> BaseDal, ICabinOrderServices cabinOrderServices, IDeliveryOrderServices deliveryOrderServices, ISupplyTaskService supplyTaskService, IInventory_BatchServices inventoryBatchServices, IMessageInfoService infoService) : base(BaseDal)
         {
             _cabinOrderServices = cabinOrderServices;
             _deliveryOrderServices = deliveryOrderServices;
             _supplyTaskService = supplyTaskService;
+            _inventoryBatchServices = inventoryBatchServices;
+            _infoService = infoService;
         }
 
         /// <summary>
@@ -45,50 +44,68 @@
         /// <param name="batch_num">鎵瑰彿</param>
         /// <returns></returns>
         /// <exception cref="NotImplementedException"></exception>
-        public WebResponseContent GetInventoryList(string goods_no, string batch_num)
+        public WebResponseContent GetInventoryList(int[] key)
         {
             var responseContent = new WebResponseContent();
             try
             {
-                var url = "http://121.37.118.63/GYZ2/95fck/repositoryInfo";
-                var result = HttpHelper.Post(url, new { goods_no, batch_num }.ToJsonString());
 
-                var response = JsonConvert.DeserializeObject<UpstreamResponse<InventoryInfo>>(result);
+                List<Dt_Inventory_Batch> UpdateBatches = new List<Dt_Inventory_Batch>();
+                //鏍规嵁id鏌ヨ搴撳瓨鎵规淇℃伅琛紝鑾峰彇鍒颁粬浠殑鍟嗗搧缂栫爜鍜屾壒娆″彿
+                var inventoryBatches = _inventoryBatchServices.Repository.QueryData(); //鏌ュ叏閮�
 
-                if (response.resultCode != "0")
+                var inventory = inventoryBatches.Where(x => key.Contains(x.Id)).Select(x => new { x.MaterielCode, x.BatchNo }).ToList();
+                if (inventory.Count < 1)
                 {
-                    //SendErrorToUpstream(8, "", response.resultMsg ?? "涓婃父鎺ュ彛杩斿洖澶辫触", "");
-                    return responseContent.Error(response.resultMsg ?? "涓婃父鎺ュ彛杩斿洖澶辫触");
+                    return WebResponseContent.Instance.Error("娌℃湁鎵惧埌搴撳瓨鎵规淇℃伅");
                 }
 
-                if (response.data == null || !response.data.Any())
-                {
-                    return responseContent.OK("鏃犳柊搴撳瓨鏁版嵁");
-                }
+                var requestData = inventory.Select(x => new { goods_no = x.MaterielCode, batch_num = x.BatchNo }).Distinct().ToList();
 
-                Db.Ado.BeginTran();
-                foreach (var item in response.data)
+                foreach (var item in requestData)
                 {
-                    // 浣跨敤 FirstOrDefault 閬垮厤鎵句笉鍒拌褰曟椂鎶涘嚭寮傚父
-                    var Inver = Db.Queryable<Dt_Inventory_Batch>()
-                        .First(x => x.MaterielCode == item.goods_no && x.BatchNo == item.batch_num);
+                   
+                    var url = "http://127.0.0.1:4523/m2/5660322-5340849-default/370999979?apifoxApiId=370999979";
+                    var result = HttpHelper.Post(url, new { item.goods_no, item.batch_num }.ToJsonString());
 
-                    if (Inver != null)
+                    var response = JsonConvert.DeserializeObject<UpstreamResponse<InventoryInfo>>(result);
+
+                    if (response.resultCode != "0")
                     {
-                        Inver.ERPStockQuantity = item.business_qty;
-                        Db.Updateable(Inver).ExecuteCommand();
+                        //return responseContent.Error(response.resultMsg ?? "涓婃父鎺ュ彛杩斿洖澶辫触");
+                        _infoService.AddMessageInfo(MessageGroupByEnum.SynchronismAlarm, "Erp鍚屾澶辫触", "涓婃父鎺ュ彛杩斿洖澶辫触");
+                        continue;
+                        
+                    }
+
+                    if (response.data == null || !response.data.Any())
+                    {
+                        return responseContent.OK("鏃犳柊搴撳瓨鏁版嵁");
+                    }
+                    var materialCodes = response.data.Select(x => x.goods_no).Distinct().ToList();
+                    var batchNos = response.data.Select(x => x.batch_num).Distinct().ToList();
+                    foreach (var inventoryInfo in response.data)
+                    {
+                        //// 浣跨敤 FirstOrDefault 閬垮厤鎵句笉鍒拌褰曟椂鎶涘嚭寮傚父
+                        var Inver = inventoryBatches.FirstOrDefault(x => x.MaterielCode == item.goods_no && x.BatchNo == item.batch_num);
+
+                        if (Inver != null)
+                        {
+                            Inver.ERPStockQuantity = inventoryInfo.business_qty;
+                            UpdateBatches.Add(Inver);
+                        }
                     }
                 }
-                Db.Ado.CommitTran();
+                _inventoryBatchServices.UpdateData(UpdateBatches);
                 return responseContent.OK("搴撳瓨淇℃伅鍚屾瀹屾垚");
+
             }
             catch (Exception ex)
             {
-                Db.Ado.RollbackTran();
-                //SendErrorToUpstream(8, "", ex.Message, "");
                 return responseContent.Error("鍚屾澶辫触: " + ex.Message);
             }
         }
+     
 
 
         public ApiResponse<Dt_InventoryInfo> OrderFeedback(EdiOrderCallbackRequest request)
diff --git "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/NewBusiness.cs" "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/NewBusiness.cs"
index 907c025..ab80e1e 100644
--- "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/NewBusiness.cs"
+++ "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/NewBusiness.cs"
@@ -29,7 +29,7 @@
                 //SearchInOrderDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                 var result = HttpHelper.Post(url, requestData.ToJsonString());
                 var response = JsonConvert.DeserializeObject<UpstreamResponse<UpstreamOrderInfo>>(result);
-                if (response == null || response.resultCode != "0") return content;
+                if (response == null) return content;
                 if (response.data.Count < 1)
                 {
                     SearchInOrderDate = GetOutOrderDate;
@@ -114,7 +114,7 @@
                 var result = HttpHelper.Post(url, requestData.ToJsonString());
                 var response = JsonConvert.DeserializeObject<UpstreamResponse<UpstramOutOrderInfo>>(result);
 
-                if (response == null || response.resultCode != "0") return content;
+                if (response == null) return content;
                 if (response.data.Count < 1)
                 {
                     SearchOutOrderDate = GetOutOrderDate;
diff --git "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/SquareCabin/InventoryController.cs" "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/SquareCabin/InventoryController.cs"
index 2f6ac4e..0cff7a1 100644
--- "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/SquareCabin/InventoryController.cs"
+++ "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/SquareCabin/InventoryController.cs"
@@ -25,9 +25,9 @@
         }
 
         [HttpPost,Route("GetInventoryList"),AllowAnonymous]
-        public WebResponseContent GetInventoryList(string goods_no, string batch_num)
+        public WebResponseContent GetInventoryList([FromBody]int[] key)
         {
-            return Service.GetInventoryList(goods_no, batch_num);
+            return Service.GetInventoryList(key);
         }
     }
 }
diff --git "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WMS/src/extension/stock/Dt_Inventory_Batch.js" "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WMS/src/extension/stock/Dt_Inventory_Batch.js"
index 6cd2ca5..0cb768c 100644
--- "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WMS/src/extension/stock/Dt_Inventory_Batch.js"
+++ "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WMS/src/extension/stock/Dt_Inventory_Batch.js"
@@ -40,18 +40,19 @@
       }
       let TB = this.buttons.find(x => x.value == 'TB');
       if (TB) {
-        TB.onClick = function () {
+        TB.onClick = ()=> {
           let rows = this.$refs.table.getSelected();
           if (rows.length == 0) return this.$error("璇烽�夋嫨鏁版嵁!");
-          if (rows.length > 1) return this.$error("璇烽�夋嫨涓�鏉℃暟鎹�!");
+          // if (rows.length > 1) return this.$error("璇烽�夋嫨涓�鏉℃暟鎹�!");
 
           // 鑾峰彇閫変腑琛岀殑鏁版嵁锛坮ows鏄暟缁勶紝鍙栫涓�涓厓绱狅級
-          const selectedRow = rows[0];
-          const materielCode = selectedRow.materielCode;
-          const batchNo = selectedRow.batchNo;
+          const selectedRow = rows.map(item => item.id);
+          // const selectedRow = rows.id[0]
+          // const materielCode = selectedRow.materielCode;
+          // const batchNo = selectedRow.batchNo;
 
           this.http
-            .post(`api/Inventory/GetInventoryList?goods_no=${materielCode}&batch_num=${batchNo}`)
+            .post(`api/Inventory/GetInventoryList`,selectedRow)
             .then((x) => {
               if (x.status) {
                 this.$Message.success('鍚屾瀹屾垚');

--
Gitblit v1.9.3