From a0a0df2e824b6fe7e5a3c0afce78127fecf84fc9 Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期一, 03 十一月 2025 08:23:05 +0800
Subject: [PATCH] ERP接口代码更新,WCS代码优化,出入库分配优化

---
 项目代码/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Inbound.cs |  240 +++++++++++++++++++++++++++++++----------------------------
 1 files changed, 126 insertions(+), 114 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Inbound.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Inbound.cs"
index 5c52f40..50996d6 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Inbound.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Inbound.cs"
@@ -197,7 +197,7 @@
         /// </summary>
         /// <param name="palletCode">RFID淇℃伅</param>
         /// <returns></returns>
-        public WebResponseContent YLPurchaseBoxing(string palletCode, decimal weight = 0, decimal thickness = 0, decimal wide = 0)
+        public WebResponseContent YLPurchaseBoxing(string palletCode, decimal weight = 0, decimal thickness = 0, decimal wide = 0, string stationCode = "")
         {
             WebResponseContent content = new WebResponseContent();
             try
@@ -210,106 +210,87 @@
                         UpdateStock(stockInfoOld, weight, thickness, wide);
                         return content.OK($"涓存椂鍏ュ簱{stockInfoOld.RfidCode}");
                     }
-                    else if (stockInfoOld != null && stockInfoOld.MaterielInvOrgId == MaterielInvOrgEnum.鑰佸巶.ObjToInt() && stockInfoOld.StockStatus == StockStatusEmun.鑰佸巶閫�搴�.ObjToInt())
+                    else if (stockInfoOld != null && stockInfoOld.MaterielInvOrgId == MaterielInvOrgEnum.鑰佸巶.ObjToInt() && stockInfoOld.StockStatus == StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt() && stockInfoOld.IsPick==WhetherEnum.False.ObjToInt() && stationCode.IsNotEmptyOrNull())
                     {
+                        stockInfoOld.StockStatus = StockStatusEmun.鑰佸巶閫�搴�.ObjToInt();
+                        stockInfoOld.IsFull = WhetherEnum.True.ObjToInt();
+                        stockInfoOld.StockOutLength = 0;
+                        stockInfoOld.WarehouseId = WarehouseEnum.LLDYL.ObjToInt();
                         UpdateStock(stockInfoOld, weight, thickness, wide);
-                        return content.OK($"鑰佸巶閫�搴搟stockInfoOld.RfidCode}");
+                        return content.OK($"鑰佸巶鏈鏂欓��搴搟stockInfoOld.RfidCode}");
+                    }
+                    else if (stockInfoOld != null && stockInfoOld.MaterielInvOrgId == MaterielInvOrgEnum.鑰佸巶.ObjToInt() && stockInfoOld.StockStatus == StockStatusEmun.鑰佸巶閫�鏂欐殏瀛�.ObjToInt() && stationCode.IsNotEmptyOrNull())
+                    {
+                        stockInfoOld.StockStatus = StockStatusEmun.鑰佸巶閫�搴�.ObjToInt();
+                        stockInfoOld.IsFull = WhetherEnum.True.ObjToInt();
+                        stockInfoOld.IsPick = WhetherEnum.False.ObjToInt();
+                        stockInfoOld.StockOutLength = 0;
+                        stockInfoOld.WarehouseId = WarehouseEnum.LLDYL.ObjToInt();
+                        UpdateStock(stockInfoOld, weight, thickness, wide);
+                        return content.OK($"鑰佸巶棰嗘枡閫�搴搟stockInfoOld.RfidCode}");
                     }
                     else if (stockInfoOld != null)
                     {
-                        return content.Error("RFID淇℃伅宸插瓨鍦�");
+                        throw new Exception($"{palletCode}RFID淇℃伅宸插瓨鍦�");
                     }
-                    #region 澶勭悊閲囪喘缁戝畾RFID閫昏緫
-                    Dt_YLInboundCache? yLInboundCache = _inboundRepository.YLInboundCacheRepository.QueryData(x => x.InvOrg == MaterielInvOrgEnum.鑰佸巶.ToString()).FirstOrDefault();
-                    if (yLInboundCache == null)
+
+                    if (stationCode.IsNullOrEmpty())
                     {
-                        return content.Error("鏈壘鍒板師鏂欑紦瀛樻潯鐮佷俊鎭�");
-                    }
-                    if (yLInboundCache.BindStatus == WhetherEnum.True.ObjToInt())
-                    {
-                        return content.Error($"鍘熸枡缂撳瓨鏉$爜{yLInboundCache.BarCode}宸茬粦瀹歊FID{yLInboundCache.RfidCode}");
-                    }
-                    else
-                    {
-                        Dt_StockInfo ExistStockInfo = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == yLInboundCache.BarCode);
-                        if (ExistStockInfo != null && ExistStockInfo.MaterielInvOrgId == MaterielInvOrgEnum.鑰佸巶.ObjToInt() && ExistStockInfo.StockStatus == StockStatusEmun.鍗氭�濋�氱粍鐩樻殏瀛�.ObjToInt())
+                        #region 澶勭悊閲囪喘缁戝畾RFID閫昏緫
+                        Dt_YLInboundCache? yLInboundCache = _inboundRepository.YLInboundCacheRepository.QueryData(x => x.InvOrg == MaterielInvOrgEnum.鑰佸巶.ToString()).FirstOrDefault();
+                        if (yLInboundCache == null)
                         {
-                            yLInboundCache.RfidCode = palletCode;
-                            yLInboundCache.BindStatus = WhetherEnum.True.ObjToInt();
-                            ExistStockInfo.RfidCode = palletCode;
-                            _unitOfWorkManage.BeginTran();
-                            //鏇存柊缁勭洏淇℃伅
-                            UpdateStock(ExistStockInfo, weight, thickness, wide);
-                            _inboundRepository.YLInboundCacheRepository.UpdateData(yLInboundCache);
-                            _unitOfWorkManage.CommitTran();
-                            return content.OK($"鍗氭�濋�氬簱瀛樿浆瀛榹ExistStockInfo.RfidCode}");
+                            return content.Error("鏈壘鍒板師鏂欑紦瀛樻潯鐮佷俊鎭�");
+                        }
+                        if (yLInboundCache.BindStatus == WhetherEnum.True.ObjToInt())
+                        {
+                            return content.Error($"鍘熸枡缂撳瓨鏉$爜{yLInboundCache.BarCode}宸茬粦瀹歊FID{yLInboundCache.RfidCode}");
                         }
                         else
                         {
-                            //鑾峰彇閲囪喘淇℃伅
-                            Dt_PurchaseBSTOrderDetail purchaseBSTOrderDetail = _purchaseBSTOrderDetailRepository.QueryFirst(x => x.Barcode == yLInboundCache.BarCode);
-                            if (purchaseBSTOrderDetail == null)
+                            Dt_StockInfo ExistStockInfo = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == yLInboundCache.BarCode);
+                            if (ExistStockInfo != null && ExistStockInfo.MaterielInvOrgId == MaterielInvOrgEnum.鑰佸巶.ObjToInt() && ExistStockInfo.StockStatus == StockStatusEmun.鍗氭�濋�氱粍鐩樻殏瀛�.ObjToInt())
                             {
-                                return content.Error($"鏈壘鍒版潯鐮亄yLInboundCache.BarCode}閲囪喘淇℃伅");
+                                yLInboundCache.RfidCode = palletCode;
+                                yLInboundCache.BindStatus = WhetherEnum.True.ObjToInt();
+                                ExistStockInfo.RfidCode = palletCode;
+                                _unitOfWorkManage.BeginTran();
+                                //鏇存柊缁勭洏淇℃伅
+                                UpdateStock(ExistStockInfo, weight, thickness, wide);
+                                _inboundRepository.YLInboundCacheRepository.UpdateData(yLInboundCache);
+                                _unitOfWorkManage.CommitTran();
+                                return content.OK($"鍗氭�濋�氬簱瀛樿浆瀛榹ExistStockInfo.RfidCode}");
                             }
-                            if (purchaseBSTOrderDetail.PurchaseBSTOrderDetailStatus != InOrderStatusEnum.鏈紑濮�.ObjToInt())
+                            else if(ExistStockInfo != null && ExistStockInfo.MaterielInvOrgId == MaterielInvOrgEnum.鑰佸巶.ObjToInt() && ExistStockInfo.StockStatus == StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt())
                             {
-                                return content.Error($"閲囪喘{purchaseBSTOrderDetail.Barcode}淇℃伅宸插叆搴撴垨鍏ュ簱涓�");
+                                //鑾峰彇閲囪喘淇℃伅
+                                Dt_PurchaseBSTOrderDetail purchaseBSTOrderDetail = _inboundRepository.PurchaseBSTOrderDetailRepository.QueryFirst(x => x.Barcode == yLInboundCache.BarCode);
+                                yLInboundCache.RfidCode = palletCode;
+                                yLInboundCache.BindStatus = WhetherEnum.True.ObjToInt();
+                                ExistStockInfo.RfidCode = palletCode;
+                                purchaseBSTOrderDetail.RfidCode= palletCode;
+                                _unitOfWorkManage.BeginTran();
+                                UpdateStock(ExistStockInfo, weight, thickness, wide);
+                                _inboundRepository.YLInboundCacheRepository.UpdateData(yLInboundCache);
+                                _inboundRepository.PurchaseBSTOrderDetailRepository.UpdateData(purchaseBSTOrderDetail);
+                                _unitOfWorkManage.CommitTran();
+                                return content.OK($"閲囪喘鍏ュ簱{ExistStockInfo.RfidCode}");
                             }
                             else
                             {
-                                purchaseBSTOrderDetail.PurchaseBSTOrderDetailStatus = InOrderStatusEnum.鍏ュ簱涓�.ObjToInt();
-                                purchaseBSTOrderDetail.RfidCode = palletCode;
+                                throw new Exception("鏈煡閿欒");
                             }
-                            //鑾峰彇閲囪喘涓诲崟
-                            Dt_PurchaseBSTOrder purchaseBSTOrder = _purchaseBSTOrderRepository.QueryFirst(x => x.Id == purchaseBSTOrderDetail.PurchaseBSTOrderId);
-                            //鑾峰彇鐗╂枡
-                            Dt_MaterielInfo materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterialSourceId == purchaseBSTOrderDetail.MaterialId);
-                            //鐢熸垚搴撳瓨缁勭洏淇℃伅
-                            Dt_StockInfo stockInfo = new Dt_StockInfo()
-                            {
-                                MaterielInvOrgId = materielInfo.MaterielInvOrgId,
-                                PalletCode = purchaseBSTOrderDetail.Barcode,
-                                RfidCode = palletCode,
-                                LocationCode = "",
-                                PalletType = 1,
-                                WarehouseId = materielInfo.WarehouseId,
-                                StockAttribute = materielInfo.MaterielSourceType,
-                                StockStatus = StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt(),
-                                MaterielSpec = materielInfo.MaterielSpec,
-                                Unit = materielInfo.MaterielUnit,
-                                MaterielThickness = purchaseBSTOrderDetail.MaterialThick,
-                                MaterielWide = purchaseBSTOrderDetail.MaterialWide,
-                                MaterielWeight = purchaseBSTOrderDetail.DeliveryQty,
-                                CheckWeight=weight,
-                                CheckThickness=thickness,
-                                CheckWide=wide,
-                                MaterielCode = materielInfo.MaterielCode,
-                                MaterielName = materielInfo.MaterielName,
-                                StockLength = purchaseBSTOrderDetail.ProcurementLength,
-                                MaterielId = purchaseBSTOrderDetail.MaterialId
-                            };
-                            if (purchaseBSTOrderDetail.MaterialWide > 1200)
-                            {
-                                stockInfo.PalletType = 2;
-                            }
-                            yLInboundCache.RfidCode = palletCode;
-                            yLInboundCache.BindStatus = WhetherEnum.True.ObjToInt();
-                            _unitOfWorkManage.BeginTran();
-                            //鏂板缁勭洏淇℃伅
-                            _stockRepository.StockInfoRepository.AddData(stockInfo);
-                            if (purchaseBSTOrder.PurchaseOrderStatus == InOrderStatusEnum.鏈紑濮�.ObjToInt())
-                            {
-                                purchaseBSTOrder.PurchaseOrderStatus = InOrderStatusEnum.鍏ュ簱涓�.ObjToInt();
-                                _purchaseBSTOrderRepository.UpdateData(purchaseBSTOrder);
-                            }
-                            _inboundRepository.YLInboundCacheRepository.UpdateData(yLInboundCache);
-                            _purchaseBSTOrderDetailRepository.UpdateData(purchaseBSTOrderDetail);
-                            _unitOfWorkManage.CommitTran();
                         }
+                        #endregion
                     }
-                    #endregion
-                    content.OK("缁戝畾鎴愬姛");
+                    else if (!stationCode.IsNullOrEmpty() && stockInfoOld == null)
+                    {
+                        throw new Exception($"{palletCode}RFID淇℃伅涓嶅瓨鍦�");
+                    }
+                    else
+                    {
+                        throw new Exception("鏈煡閿欒");
+                    }
                 }
                 
             }
@@ -340,32 +321,27 @@
             {
                 if (string.IsNullOrEmpty(palletCode))
                 {
-                    return content.Error("鏉$爜涓嶈兘涓虹┖");
+                    throw new Exception("鏉$爜涓嶈兘涓虹┖");
                 }
                 Dt_StockInfo stockInfoOld = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == palletCode);
                 if (stockInfoOld != null)
                 {
-                    return content.Error("鏉$爜淇℃伅搴撳瓨涓凡瀛樺湪");
+                    throw new Exception("鏉$爜淇℃伅搴撳瓨涓凡瀛樺湪");
                 }
                 //鑾峰彇閲囪喘淇℃伅
-                Dt_PurchaseBSTOrderDetail purchaseBSTOrderDetail = _purchaseBSTOrderDetailRepository.QueryFirst(x => x.Barcode == palletCode);
+                Dt_PurchaseBSTOrderDetail purchaseBSTOrderDetail = _inboundRepository.PurchaseBSTOrderDetailRepository.QueryFirst(x => x.Barcode == palletCode);
                 if (purchaseBSTOrderDetail == null)
                 {
                     BSTResponse<BSTStockInfoDTO> bSTResponse = _invokeERPService.BSTStockAsync(palletCode).DeserializeObject<BSTResponse<BSTStockInfoDTO>>();
                     if (bSTResponse.Code == 500)
                     {
-                        return content.Error($"鏈壘鍒版潯鐮亄palletCode}閲囪喘淇℃伅骞朵竴鏈烢RP搴撳瓨涔熶笉瀛樺湪");
+                        throw new Exception($"鏈壘鍒版潯鐮亄palletCode}閲囪喘淇℃伅骞朵竴鏈烢RP搴撳瓨涔熶笉瀛樺湪");
                     }
-                    BSTStockInfoDTO bSTStockInfoDTO=bSTResponse.Data;
-                    if (bSTStockInfoDTO==null)
-                    {
-                        return content.Error($"涓�鏈烢RP鏈繑鍥瀧palletCode}鐨勫簱瀛樹俊鎭�");
-                    }
-                    Dt_MaterielInfo materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterialSourceId == bSTStockInfoDTO.MaterialId);
-                    if (materielInfo==null)
-                    {
-                        return content.Error($"鏈壘鍒版潯鐮亄palletCode}鐗╂枡淇℃伅{bSTStockInfoDTO.MaterialNo}");
-                    }
+
+                    BSTStockInfoDTO bSTStockInfoDTO=bSTResponse.Data ?? throw new Exception($"涓�鏈烢RP鏈繑鍥瀧palletCode}鐨勫簱瀛樹俊鎭�");
+
+                    Dt_MaterielInfo materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterialSourceId == bSTStockInfoDTO.MaterialId) ?? throw new Exception($"鏈壘鍒版潯鐮亄palletCode}鐗╂枡淇℃伅{bSTStockInfoDTO.MaterialNo}");
+
                     //鐢熸垚搴撳瓨缁勭洏淇℃伅
                     Dt_StockInfo stockInfo = new Dt_StockInfo()
                     {
@@ -391,15 +367,11 @@
                     {
                         stockInfo.PalletType = 2;
                     }
-                    Dt_YLInboundCache? yLInboundCache = _inboundRepository.YLInboundCacheRepository.QueryData(x => x.InvOrg == MaterielInvOrgEnum.鑰佸巶.ToString()).FirstOrDefault();
-                    if (yLInboundCache == null)
-                    {
-                        return content.Error("鏈壘鍒板師鏂欐潯鐮佺紦瀛樹俊鎭�");
-                    }
+                    Dt_YLInboundCache? yLInboundCache = _inboundRepository.YLInboundCacheRepository.QueryData(x => x.InvOrg == MaterielInvOrgEnum.鑰佸巶.ToString()).FirstOrDefault() ?? throw new Exception("鏈壘鍒板師鏂欐潯鐮佺紦瀛樹俊鎭�");
                     int Id = yLInboundCache.Id;
                     if (yLInboundCache.BarCode == palletCode)
                     {
-                        return content.Error($"鏉$爜{palletCode}宸叉壂鐮�");
+                        throw new Exception($"鏉$爜{palletCode}宸叉壂鐮�");
                     }
                     else if (yLInboundCache.BarCode != palletCode && yLInboundCache.BindStatus == WhetherEnum.True.ObjToInt())
                     {
@@ -409,6 +381,7 @@
                         //鏂板缁勭洏淇℃伅
                         _stockRepository.StockInfoRepository.AddData(stockInfo);
                         _inboundRepository.YLInboundCacheRepository.UpdateData(yLInboundCache);
+                        //鍚姩绾夸綋
                         WebResponseContent webResponse = YLPurchasePush();
                         if (!webResponse.Status)
                         {
@@ -419,7 +392,7 @@
                     }
                     else
                     {
-                        return content.Error($"涓婂嵎鏉$爜{yLInboundCache.BarCode}杩樻湭杩涜缁戝畾");
+                        throw new Exception($"涓婂嵎鏉$爜{yLInboundCache.BarCode}杩樻湭杩涜缁戝畾");
                     }
                     
                 }
@@ -427,24 +400,63 @@
                 {
                     if (purchaseBSTOrderDetail.PurchaseBSTOrderDetailStatus != InOrderStatusEnum.鏈紑濮�.ObjToInt())
                     {
-                        return content.Error($"鏉$爜{palletCode}閲囪喘淇℃伅宸插叆搴撴垨鍏ュ簱涓�");
+                        throw new Exception($"鏉$爜{palletCode}閲囪喘淇℃伅宸插叆搴撴垨鍏ュ簱涓�");
                     }
                     Dt_YLInboundCache? yLInboundCache = _inboundRepository.YLInboundCacheRepository.QueryData(x => x.InvOrg == MaterielInvOrgEnum.鑰佸巶.ToString()).FirstOrDefault();
                     if (yLInboundCache == null)
                     {
-                        return content.Error("鏈壘鍒板師鏂欐潯鐮佺紦瀛樹俊鎭�");
+                        throw new Exception("鏈壘鍒板師鏂欐潯鐮佺紦瀛樹俊鎭�");
                     }
                     int Id = yLInboundCache.Id;
                     if (yLInboundCache.BarCode == palletCode)
                     {
-                        return content.Error($"鏉$爜{palletCode}宸叉壂鐮�");
+                        throw new Exception($"鏉$爜{palletCode}宸叉壂鐮�");
                     }
                     else if (yLInboundCache.BarCode != palletCode && yLInboundCache.BindStatus == WhetherEnum.True.ObjToInt())
                     {
                         yLInboundCache = _mapper.Map<Dt_YLInboundCache>(purchaseBSTOrderDetail);
                         yLInboundCache.Id = Id;
+                        //鑾峰彇閲囪喘涓诲崟
+                        Dt_PurchaseBSTOrder purchaseBSTOrder = _inboundRepository.PurchaseBSTOrderRepository.QueryFirst(x => x.Id == purchaseBSTOrderDetail.PurchaseBSTOrderId);
+                        //鑾峰彇鐗╂枡
+                        Dt_MaterielInfo materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterialSourceId == purchaseBSTOrderDetail.MaterialId);
+                        //鐢熸垚搴撳瓨缁勭洏淇℃伅
+                        Dt_StockInfo stockInfo = new Dt_StockInfo()
+                        {
+                            MaterielInvOrgId = materielInfo.MaterielInvOrgId,
+                            PalletCode = purchaseBSTOrderDetail.Barcode,
+                            RfidCode = "",
+                            LocationCode = "",
+                            PalletType = 1,
+                            WarehouseId = materielInfo.WarehouseId,
+                            StockAttribute = materielInfo.MaterielSourceType,
+                            StockStatus = StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt(),
+                            MaterielSpec = materielInfo.MaterielSpec,
+                            Unit = materielInfo.MaterielUnit,
+                            MaterielThickness = purchaseBSTOrderDetail.MaterialThick,
+                            MaterielWide = purchaseBSTOrderDetail.MaterialWide,
+                            MaterielWeight = purchaseBSTOrderDetail.DeliveryQty,
+                            MaterielCode = materielInfo.MaterielCode,
+                            MaterielName = materielInfo.MaterielName,
+                            StockLength = purchaseBSTOrderDetail.ProcurementLength,
+                            MaterielId = purchaseBSTOrderDetail.MaterialId
+                        };
+                        if (purchaseBSTOrderDetail.MaterialWide > 1200)
+                        {
+                            stockInfo.PalletType = 2;
+                        }
+                        purchaseBSTOrderDetail.PurchaseBSTOrderDetailStatus = InOrderStatusEnum.鍏ュ簱涓�.ObjToInt();
                         _unitOfWorkManage.BeginTran();
                         _inboundRepository.YLInboundCacheRepository.UpdateData(yLInboundCache);
+                        //鏂板缁勭洏淇℃伅
+                        _stockRepository.StockInfoRepository.AddData(stockInfo);
+                        if (purchaseBSTOrder.PurchaseOrderStatus == InOrderStatusEnum.鏈紑濮�.ObjToInt())
+                        {
+                            purchaseBSTOrder.PurchaseOrderStatus = InOrderStatusEnum.鍏ュ簱涓�.ObjToInt();
+                            _inboundRepository.PurchaseBSTOrderRepository.UpdateData(purchaseBSTOrder);
+                        }
+                        _inboundRepository.PurchaseBSTOrderDetailRepository.UpdateData(purchaseBSTOrderDetail);
+                        //鍚姩绾夸綋
                         WebResponseContent webResponse = YLPurchasePush();
                         if (!webResponse.Status)
                         {
@@ -455,7 +467,7 @@
                     }
                     else
                     {
-                        return content.Error($"涓婂嵎鏉$爜{yLInboundCache.BarCode}杩樻湭杩涜缁戝畾");
+                       throw new Exception($"涓婂嵎鏉$爜{yLInboundCache.BarCode}杩樻湭杩涜缁戝畾");
                     }
                 }
                 
@@ -587,7 +599,7 @@
                     {
                         return content.Error($"鏈壘鍒板搴旂殑缁堢偣璐т綅淇℃伅");
                     }
-                    Dt_AGVStationInfo agvstation = _agvStationInfoRepository.QueryFirst(x => x.AGVStationCode == task.SourceAddress && ( x.StationArea == nameof(AGVStationAreaEnum.涓�妤兼湀鍙扮爜澶�) || x.StationArea == nameof(AGVStationAreaEnum.涓�妤兼棤绾虹粐甯�) || x.StationArea == nameof(AGVStationAreaEnum.涓�妤兼棤绾烘穻鑶�) || x.StationArea == nameof(AGVStationAreaEnum.涓�妤兼棤绾烘穻鑶�)));
+                    Dt_AGVStationInfo agvstation = _basicRepository.AGVStationInfoRepository.QueryFirst(x => x.AGVStationCode == task.SourceAddress && ( x.StationArea == nameof(AGVStationAreaEnum.涓�妤兼湀鍙扮爜澶�) || x.StationArea == nameof(AGVStationAreaEnum.涓�妤兼棤绾虹粐甯�) || x.StationArea == nameof(AGVStationAreaEnum.涓�妤兼棤绾烘穻鑶�) || x.StationArea == nameof(AGVStationAreaEnum.涓�妤兼棤绾烘穻鑶�)));
                     if (agvstation != null)
                     {
                         agvstation.IsOccupied = WhetherEnum.False.ObjToInt();
@@ -599,7 +611,7 @@
                         _unitOfWorkManage.BeginTran();
                         if (agvstation != null)
                         {
-                            _agvStationInfoRepository.UpdateData(agvstation);
+                            _basicRepository.AGVStationInfoRepository.UpdateData(agvstation);
                         }
                         proStockInfo.LocationCode = locationInfoEnd.LocationCode;
                         proStockInfo.StockStatus = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt();
@@ -618,7 +630,7 @@
                         _unitOfWorkManage.BeginTran();
                         if (agvstation != null)
                         {
-                            _agvStationInfoRepository.UpdateData(agvstation);
+                            _basicRepository.AGVStationInfoRepository.UpdateData(agvstation);
                         }
                         proStockInfo.LocationCode = locationInfoEnd.LocationCode;
                         proStockInfo.StockStatus = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt();
@@ -665,7 +677,7 @@
                     _basicService.LocationInfoService.UpdateLocationStatus(locationInfoEnd, stockInfo.PalletType, LocationStatusEnum.InStock, stockInfo.WarehouseId);
                     BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? WIDESEA_Core.Enums.OperateTypeEnum.浜哄伐瀹屾垚 : WIDESEA_Core.Enums.OperateTypeEnum.鑷姩瀹屾垚);
                     //涓婃姤鑰佸巶ERP
-                    if (stockInfo.MaterielInvOrgId == MaterielInvOrgEnum.鑰佸巶.ObjToInt())
+                    if (stockInfo.MaterielInvOrgId == MaterielInvOrgEnum.鑰佸巶.ObjToInt() && task.TaskType==TaskTypeEnum.Inbound.ObjToInt())
                     {
                         int Qty = Convert.ToInt32(stockInfo.MaterielWeight);
                         BSTPurchaseUpModel bSTPurchaseUpModel = new BSTPurchaseUpModel()
@@ -800,7 +812,7 @@
                 //{
                 //    return content.Error($"妗嗙爜鏍煎紡閿欒{barCode}");
                 //}
-                Dt_AGVStationInfo agvstation = _agvStationInfoRepository.QueryFirst(x=>x.AGVStationCode==startPoint);
+                Dt_AGVStationInfo agvstation = _basicRepository.AGVStationInfoRepository.QueryFirst(x=>x.AGVStationCode==startPoint);
                 if (agvstation==null)
                 {
                     return content.Error($"璧风偣閿欒{startPoint}");
@@ -892,7 +904,7 @@
                     {
                         return content.Error($"鏈壘鍒扮墿鏂欎俊鎭瘂matCode}");
                     }
-                    Dt_AGVStationInfo agvstation = _agvStationInfoRepository.QueryFirst(x => x.AGVStationCode == startPoint);
+                    Dt_AGVStationInfo agvstation = _basicRepository.AGVStationInfoRepository.QueryFirst(x => x.AGVStationCode == startPoint);
                     if (agvstation == null)
                     {
                         return content.Error($"璧风偣閿欒{startPoint}");
@@ -1170,7 +1182,7 @@
                     return content.Error($"鐗╂枡缂栫爜{nameof(MESProInDTO.MaterialCode)}:{CheckMaterialCode.MaterialCode}淇℃伅涓嶅瓨鍦�");
                 }
                 //鑾峰彇鎵�鏈堿GV鐐逛綅
-                List<Dt_AGVStationInfo> aGVStationInfos = _agvStationInfoRepository.QueryData(x => !string.IsNullOrEmpty(x.MESPointCode));
+                List<Dt_AGVStationInfo> aGVStationInfos = _basicRepository.AGVStationInfoRepository.QueryData(x => !string.IsNullOrEmpty(x.MESPointCode));
 
                 //鍒ゆ柇鏄惁瀛樺湪閲嶅
                 MESProInDTO? proInDTO = proInDTOs.FirstOrDefault(x => x.IsMantissa == false && proInOrderInfos.Select(x => x.BarCode).Contains(x.BarCode));
@@ -1246,7 +1258,7 @@
                 List<Dt_StockInfo> stockInfos = new List<Dt_StockInfo>();
                 List<Dt_Task> tasks = new List<Dt_Task>();
                 //鑾峰彇鎵�鏈堿GV鐐逛綅
-                List<Dt_AGVStationInfo> aGVStationInfos = _agvStationInfoRepository.QueryData(x => !string.IsNullOrEmpty(x.MESPointCode));
+                List<Dt_AGVStationInfo> aGVStationInfos = _basicRepository.AGVStationInfoRepository.QueryData(x => !string.IsNullOrEmpty(x.MESPointCode));
                 //鏍规嵁鍗婃垚鍝佷俊鎭懠鍙搴斾换鍔�
                 foreach (var item in mESProInOrderInfos)
                 {

--
Gitblit v1.9.3