From ce40df5daffae0d17b4e9fa7cb6d677afaa4d66f Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期五, 17 十月 2025 11:20:30 +0800
Subject: [PATCH] 更新最新程序,ERP代码,MES代码等

---
 项目代码/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Inbound.cs |  291 +++++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 197 insertions(+), 94 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 5490b32..7949c9a 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"
@@ -1,4 +1,6 @@
-锘縰sing OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup;
+锘縰sing Autofac.Core;
+using Microsoft.IdentityModel.Tokens;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup;
 using SqlSugar;
 using System;
 using System.Collections;
@@ -116,7 +118,12 @@
             WebResponseContent content = new WebResponseContent();
             try
             {
-                Dt_Task task = Repository.QueryFirst(x => x.PalletCode == palletCode);
+                Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.QueryFirst(x => x.RfidCode == palletCode);
+                if (stockInfo == null)
+                {
+                    return content.Error($"鏈壘鍒扮粍鐩樹俊鎭�");
+                }
+                Dt_Task task = Repository.QueryFirst(x => x.PalletCode == stockInfo.PalletCode);
                 if (task != null)
                 {
                     PushTasksToWCS(new List<Dt_Task> { task });
@@ -126,11 +133,6 @@
                 if (Repository.QueryFirst(x => x.SourceAddress == stationCode && x.TaskStatus == TaskStatusEnum.New.ObjToInt()) != null)
                 {
                     return content.Error($"璇ョ珯鐐瑰凡鏈夋湭鎵ц鐨勪换鍔�");
-                }
-                Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == palletCode);
-                if (stockInfo == null)
-                {
-                    return content.Error($"鏈壘鍒扮粍鐩樹俊鎭�");
                 }
                 if (stockInfo.StockStatus != StockStatusEmun.鎵嬪姩缁勭洏鏆傚瓨.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.鑰佸巶閫�搴�.ObjToInt())
                 {
@@ -148,7 +150,8 @@
                     CurrentAddress = stationCode,
                     Grade = 0,
                     NextAddress = "",
-                    PalletCode = palletCode,
+                    PalletCode = stockInfo.PalletCode,
+                    RfidCode=stockInfo.RfidCode,
                     Roadway = rowWay,
                     SourceAddress = stationCode,
                     TargetAddress = "",
@@ -184,82 +187,106 @@
             }
             return content;
         }
+        private readonly static object lockerYLBoxing = new object();
         /// <summary>
-        /// 鍘熸枡璇锋眰缁勭洏
+        /// 鍘熸枡璇锋眰
         /// </summary>
+        /// <param name="palletCode">RFID淇℃伅</param>
         /// <returns></returns>
         public WebResponseContent YLPurchaseBoxing(string palletCode)
         {
             WebResponseContent content = new WebResponseContent();
             try
             {
-                Dt_StockInfo stockInfoOld = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == palletCode);
-                if (stockInfoOld != null && stockInfoOld.MaterielInvOrgId==MaterielInvOrgEnum.鏂板巶.ObjToInt())
+                lock (lockerYLBoxing)
                 {
-                    return content.OK($"鏂板巶涓存椂鍏ュ簱{stockInfoOld.PalletCode}");
-                }
-                else if (stockInfoOld != null && stockInfoOld.MaterielInvOrgId==MaterielInvOrgEnum.鑰佸巶.ObjToInt() && stockInfoOld.StockStatus == StockStatusEmun.鑰佸巶閫�搴�.ObjToInt())
-                {
-                    return content.OK($"鑰佸巶涓存椂閫�搴搟stockInfoOld.PalletCode}");
-                }
-                else if (stockInfoOld != null)
-                {
-                    return content.Error($"鏉$爜{stockInfoOld.PalletCode}淇℃伅宸插瓨鍦�");
+                    Dt_StockInfo stockInfoOld = _stockRepository.StockInfoRepository.QueryFirst(x => x.RfidCode == palletCode);
+                    if (stockInfoOld != null && stockInfoOld.StockStatus == StockStatusEmun.鎵嬪姩缁勭洏鏆傚瓨.ObjToInt())
+                    {
+                        return content.OK($"涓存椂鍏ュ簱{stockInfoOld.RfidCode}");
+                    }
+                    else if (stockInfoOld != null && stockInfoOld.MaterielInvOrgId == MaterielInvOrgEnum.鑰佸巶.ObjToInt() && stockInfoOld.StockStatus == StockStatusEmun.鑰佸巶閫�搴�.ObjToInt())
+                    {
+                        return content.OK($"鑰佸巶閫�搴搟stockInfoOld.RfidCode}");
+                    }
+                    else if (stockInfoOld != null)
+                    {
+                        return content.Error("RFID淇℃伅宸插瓨鍦�");
+                    }
+                    #region 澶勭悊閲囪喘缁戝畾RFID閫昏緫
+                    Dt_YLInboundCache? yLInboundCache = _inboundRepository.YLInboundCacheRepository.QueryData(x => x.InvOrg == MaterielInvOrgEnum.鑰佸巶.ToString()).FirstOrDefault();
+                    if (yLInboundCache == null)
+                    {
+                        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)
+                        {
+                            return content.Error($"鏈壘鍒版潯鐮亄yLInboundCache.BarCode}閲囪喘淇℃伅");
+                        }
+                        if (purchaseBSTOrderDetail.PurchaseBSTOrderDetailStatus != InOrderStatusEnum.鏈紑濮�.ObjToInt())
+                        {
+                            return content.Error($"閲囪喘{purchaseBSTOrderDetail.Barcode}淇℃伅宸插叆搴撴垨鍏ュ簱涓�");
+                        }
+                        else
+                        {
+                            purchaseBSTOrderDetail.PurchaseBSTOrderDetailStatus = InOrderStatusEnum.鍏ュ簱涓�.ObjToInt();
+                            purchaseBSTOrderDetail.RfidCode = palletCode;
+                        }
+                        //鑾峰彇閲囪喘涓诲崟
+                        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,
+                            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
+                    content.OK("缁戝畾鎴愬姛");
                 }
                 
-                //鑾峰彇閲囪喘淇℃伅
-                Dt_PurchaseBSTOrderDetail purchaseBSTOrderDetail = _purchaseBSTOrderDetailRepository.QueryFirst(x=>x.Barcode== palletCode);
-                if (purchaseBSTOrderDetail == null)
-                {
-                    return content.Error($"鏈壘鍒版潯鐮亄palletCode}閲囪喘淇℃伅");
-                }
-                if (purchaseBSTOrderDetail.PurchaseBSTOrderDetailStatus!=InOrderStatusEnum.鏈紑濮�.ObjToInt())
-                {
-                    return content.Error($"閲囪喘{purchaseBSTOrderDetail.Barcode}淇℃伅宸插叆搴撴垨鍏ュ簱涓�");
-                }
-                else
-                {
-                    purchaseBSTOrderDetail.PurchaseBSTOrderDetailStatus = InOrderStatusEnum.鍏ュ簱涓�.ObjToInt();
-                }
-                //鑾峰彇閲囪喘涓诲崟
-                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,
-                    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;
-                }
-                _unitOfWorkManage.BeginTran();
-                //鏂板缁勭洏淇℃伅
-                _stockRepository.StockInfoRepository.AddData(stockInfo);
-                if (purchaseBSTOrder.PurchaseOrderStatus==InOrderStatusEnum.鏈紑濮�.ObjToInt())
-                {
-                    purchaseBSTOrder.PurchaseOrderStatus = InOrderStatusEnum.鍏ュ簱涓�.ObjToInt();
-                    _purchaseBSTOrderRepository.UpdateData(purchaseBSTOrder);
-                }
-                _purchaseBSTOrderDetailRepository.UpdateData(purchaseBSTOrderDetail);
-                _unitOfWorkManage.CommitTran();
-                content.OK("璇锋眰鎴愬姛");
             }
             catch (Exception ex)
             {
@@ -267,8 +294,74 @@
                 content.Error(ex.Message);
             }
             return content;
+        }
+
+        /// <summary>
+        /// 鍘熸枡閲囪喘缁戝畾RFID
+        /// </summary>
+        /// <param name="palletCode">绾稿嵎鏉$爜</param>
+        /// <param name="rfidCode">绾稿嵎RIFD</param>
+        /// <returns></returns>
+        public WebResponseContent PurchaseBoxing(string palletCode)
+        {
+            WebResponseContent content=new WebResponseContent();
+            try
+            {
+                if (string.IsNullOrEmpty(palletCode))
+                {
+                    return content.Error("鏉$爜涓嶈兘涓虹┖");
+                }
+                Dt_StockInfo stockInfoOld = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == palletCode);
+                if (stockInfoOld != null)
+                {
+                    return content.Error("鏉$爜淇℃伅搴撳瓨涓凡瀛樺湪");
+                }
+                //鑾峰彇閲囪喘淇℃伅
+                Dt_PurchaseBSTOrderDetail purchaseBSTOrderDetail = _purchaseBSTOrderDetailRepository.QueryFirst(x => x.Barcode == palletCode);
+                if (purchaseBSTOrderDetail == null)
+                {
+                    return content.Error($"鏈壘鍒版潯鐮亄palletCode}閲囪喘淇℃伅");
+                }
+                if (purchaseBSTOrderDetail.PurchaseBSTOrderDetailStatus != InOrderStatusEnum.鏈紑濮�.ObjToInt())
+                {
+                    return content.Error($"鏉$爜{palletCode}閲囪喘淇℃伅宸插叆搴撴垨鍏ュ簱涓�");
+                }
+                Dt_YLInboundCache? yLInboundCache = _inboundRepository.YLInboundCacheRepository.QueryData(x=>x.InvOrg==MaterielInvOrgEnum.鑰佸巶.ToString()).FirstOrDefault();
+                if (yLInboundCache == null)
+                {
+                    return content.Error("鏈壘鍒板師鏂欐潯鐮佺紦瀛樹俊鎭�");
+                }
+                int Id = yLInboundCache.Id;
+                if (yLInboundCache.BarCode==palletCode)
+                {
+                    return content.Error($"鏉$爜{palletCode}宸叉壂鐮�");
+                }
+                else if (yLInboundCache.BarCode != palletCode && yLInboundCache.BindStatus==WhetherEnum.True.ObjToInt())
+                {
+                    yLInboundCache = _mapper.Map<Dt_YLInboundCache>(purchaseBSTOrderDetail);
+                    yLInboundCache.Id = Id;
+                    _inboundRepository.YLInboundCacheRepository.UpdateData(yLInboundCache);
+                    return content.OK("鎴愬姛", yLInboundCache);
+                }
+                else
+                {
+                    return content.Error($"涓婂嵎鏉$爜{yLInboundCache.BarCode}杩樻湭杩涜缁戝畾");
+                }
+                
+            }
+            catch (Exception ex)
+            {
+                content.Error(ex.Message);
+            }
+            return content;
             
         }
+        /// <summary>
+        /// 鍘熸枡鍒嗛厤宸烽亾
+        /// </summary>
+        /// <param name="palletCode">鏉$爜鍙�</param>
+        /// <returns></returns>
+        /// <exception cref="Exception"></exception>
         public string AssignYLRoadwayNo(string palletCode)
         {
             try
@@ -292,13 +385,8 @@
                     //闄愬埗鐩村緞
                     if (stockInfo.MaterielThickness >= 300 && stockInfo.MaterielThickness <= 1300 && stockInfo.MaterielWide >= 700 && stockInfo.MaterielWide <= 2700)
                     {
-                        bool LayerLimit = false;
-                        if (stockInfo.MaterielThickness >= 800)
-                        {
-                            LayerLimit = true;
-                        }
                         //鑾峰彇鍒嗛厤
-                        List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => x.WarehouseId == warehouse.WarehouseId && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && x.RoadwayNo.Contains("YLDual")).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList();
+                        List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => x.WarehouseId == warehouse.WarehouseId && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && x.RoadwayNo.Contains("YLDual") && (stockInfo.PalletType == LocationTypeEnum.MediumPallet.ObjToInt() ? x.LocationType == LocationTypeEnum.MediumPallet.ObjToInt(): x.LocationType == LocationTypeEnum.SmallPallet.ObjToInt())).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList();
 
                         roadwayNo = HandleRoadway(locationCounts, warehouse);
                     }
@@ -365,7 +453,7 @@
                     {
                         return content.Error($"鏈壘鍒板搴旂殑缁堢偣璐т綅淇℃伅");
                     }
-                    Dt_AGVStationInfo agvstation = _agvStationInfoRepository.QueryFirst(x => x.AGVStationCode == task.SourceAddress && ( x.StationArea == AGVStationAreaEnum.AreaA.ObjToInt() || x.StationArea == AGVStationAreaEnum.AreaC.ObjToInt()));
+                    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.涓�妤兼棤绾烘穻鑶�)));
                     if (agvstation != null)
                     {
                         agvstation.IsOccupied = WhetherEnum.False.ObjToInt();
@@ -446,7 +534,7 @@
                         {
                             Barcode = stockInfo.PalletCode,
                             BarcodeQty = Qty,
-                            Rfid = stockInfo.PalletCode,
+                            Rfid = stockInfo.RfidCode,
                             RfidUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
                         };
                         BSTResponse bSTResponse = _invokeERPService.BSTPurchaseUp(bSTPurchaseUpModel).DeserializeObject<BSTResponse>();
@@ -520,8 +608,13 @@
                 {
                     return WebResponseContent.Instance.OK(data: task.TargetAddress);
                 }
+                Dt_StockInfo? stockInfo = null;
+                if (roadwayNo.Contains("YL"))
+                {
+                    stockInfo = _stockRepository.StockInfoRepository.QueryFirst(x=>x.PalletCode==task.PalletCode);
+                }
                 //鍒嗛厤璐т綅
-                Dt_LocationInfo? locationInfo = _basicService.LocationInfoService.AssignLocation(roadwayNo, task.PalletType, task.WarehouseId);
+                Dt_LocationInfo? locationInfo = _basicService.LocationInfoService.AssignLocation(roadwayNo, task.PalletType, task.WarehouseId, stockInfo);
                 if (locationInfo == null)
                 {
                     return WebResponseContent.Instance.Error($"璐т綅鍒嗛厤澶辫触,鏈壘鍒板彲鍒嗛厤璐т綅");
@@ -637,7 +730,7 @@
         /// 杈呮枡/鎴愬搧涓存椂鍏ュ簱
         /// </summary>
         /// <returns></returns>
-        public WebResponseContent InboundFLOrCPTask(string barCode, string startPoint,string matCode,int matCount)
+        public WebResponseContent InboundFLOrCPTask(string barCode, string startPoint,string matCode,int matCount, int oneCount)
         {
             lock (_lockerFLorCP)
             {
@@ -682,15 +775,21 @@
 
                     //鑾峰彇鎴愬搧搴�
                     WarehouseEnum warehouseEnum = materielInfo.MaterielSourceType == MaterielTypeEnum.鎴愬搧.ObjToInt() ? WarehouseEnum.LLDCP : WarehouseEnum.LLDFL;
-                    Dt_ProStockInfoDetail proStockInfoDetail = new Dt_ProStockInfoDetail()
+                    List<Dt_ProStockInfoDetail> proStockInfoDetails = new List<Dt_ProStockInfoDetail>();
+                    for (int i = 0; i < matCount; i++)
                     {
-                        ProductCode = materielInfo.MaterielCode,
-                        ProductName= materielInfo.MaterielName,
-                        ProductSpec=materielInfo.MaterielSpec,
-                        ProductUnit=materielInfo.MaterielUnit,
-                        StockQty = matCount,
-                        ProStockDetailStatus = StockStatusEmun.鎵嬪姩缁勭洏鍏ュ簱纭.ObjToInt()
-                    };
+                        Dt_ProStockInfoDetail proStockInfoDetail = new Dt_ProStockInfoDetail()
+                        {
+                            ProductCode = materielInfo.MaterielCode,
+                            ProductName = materielInfo.MaterielName,
+                            ProductSpec = materielInfo.MaterielSpec,
+                            ProductUnit = materielInfo.MaterielUnit,
+                            StockQty = oneCount,
+                            ProStockDetailStatus = StockStatusEmun.鎵嬪姩缁勭洏鍏ュ簱纭.ObjToInt()
+                        };
+                        proStockInfoDetails.Add(proStockInfoDetail);
+                    }
+                    
                     Dt_ProStockInfo proStockInfo = new Dt_ProStockInfo()
                     {
                         PalletCode = barCode,
@@ -699,7 +798,7 @@
                         LocationCode = "",
                         WarehouseId = warehouseEnum.ObjToInt(),
                         StockStatus = StockStatusEmun.鎵嬪姩缁勭洏鍏ュ簱纭.ObjToInt(),
-                        proStockInfoDetails = new List<Dt_ProStockInfoDetail> { proStockInfoDetail }
+                        proStockInfoDetails = proStockInfoDetails
                     };
 
                     Dt_Task newTask = new Dt_Task()
@@ -755,6 +854,10 @@
                 {
                     return content.Error("鏈壘鍒扮墿鏂欎俊鎭�");
                 }
+                if (materielInfo.MaterielSourceType != MaterielTypeEnum.鍘熸潗鏂�.ObjToInt())
+                {
+                    return content.Error($"鐗╂枡淇℃伅涓嶇鍚坽MaterielTypeEnum.鍘熸潗鏂檥");
+                }
                 Dt_StockInfo stockInfoOld = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == barcode);
                 if (stockInfoOld != null)
                 {
@@ -796,7 +899,7 @@
                     TaskType = TaskTypeEnum.PrintYLBackInbound.ObjToInt(),
                     TaskStatus = TaskStatusEnum.New.ObjToInt(),
                     WarehouseId = warehouseId,
-                    PalletType = 1,
+                    PalletType = stockInfo.PalletType,
                     TaskLength= wide
                 };
                 _unitOfWorkManage.BeginTran();
@@ -882,7 +985,7 @@
                     TaskType = TaskTypeEnum.PrintYLInbound.ObjToInt(),
                     TaskStatus = TaskStatusEnum.New.ObjToInt(),
                     WarehouseId = warehouseId,
-                    PalletType = 1,
+                    PalletType = stockInfo.PalletType,
                     TaskLength = wide
                 };
                 _unitOfWorkManage.BeginTran();

--
Gitblit v1.9.3