From f54b7815d8451f362554e3d2d09b4991ce13d4ff Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期三, 12 十一月 2025 09:01:16 +0800
Subject: [PATCH] 前端优化,PDA更新,分配库存优化

---
 项目代码/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Inbound.cs |  513 ++++++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 382 insertions(+), 131 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 50996d6..f36d870 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"
@@ -6,6 +6,7 @@
 using System;
 using System.Collections;
 using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
 using System.Linq;
 using System.Reflection.Metadata;
 using System.Text;
@@ -236,52 +237,90 @@
 
                     if (stationCode.IsNullOrEmpty())
                     {
-                        #region 澶勭悊閲囪喘缁戝畾RFID閫昏緫
-                        Dt_YLInboundCache? yLInboundCache = _inboundRepository.YLInboundCacheRepository.QueryData(x => x.InvOrg == MaterielInvOrgEnum.鑰佸巶.ToString()).FirstOrDefault();
-                        if (yLInboundCache == null)
+                        //鏂板巶RFID缁戝畾閫昏緫
+                        if (palletCode.StartsWith("A"))
                         {
-                            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("鏈壘鍒板師鏂欑紦瀛樻潯鐮佷俊鎭�");
                             }
-                            else if(ExistStockInfo != null && ExistStockInfo.MaterielInvOrgId == MaterielInvOrgEnum.鑰佸巶.ObjToInt() && ExistStockInfo.StockStatus == StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt())
+                            if (yLInboundCache.BindStatus == WhetherEnum.True.ObjToInt())
                             {
-                                //鑾峰彇閲囪喘淇℃伅
-                                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}");
+                                return content.Error($"鍘熸枡缂撳瓨鏉$爜{yLInboundCache.BarCode}宸茬粦瀹歊FID{yLInboundCache.RfidCode}");
                             }
                             else
                             {
-                                throw new Exception("鏈煡閿欒");
+                                Dt_StockInfo ExistStockInfo = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == yLInboundCache.BarCode);
+                                if (ExistStockInfo != null && ExistStockInfo.MaterielInvOrgId == MaterielInvOrgEnum.鏂板巶.ObjToInt() && ExistStockInfo.StockStatus == StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt())
+                                {
+                                    //鑾峰彇閲囪喘淇℃伅
+                                    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}");
+                                }
+                                else
+                                {
+                                    throw new Exception("鏈煡閿欒");
+                                }
                             }
+                            #endregion
                         }
-                        #endregion
+                        else //鑰佸巶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_StockInfo ExistStockInfo = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == yLInboundCache.BarCode);
+                                if (ExistStockInfo != null && ExistStockInfo.MaterielInvOrgId == MaterielInvOrgEnum.鑰佸巶.ObjToInt() && ExistStockInfo.StockStatus == StockStatusEmun.鍗氭�濋�氱粍鐩樻殏瀛�.ObjToInt())
+                                {
+                                    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}");
+                                }
+                                else if (ExistStockInfo != null && ExistStockInfo.MaterielInvOrgId == MaterielInvOrgEnum.鑰佸巶.ObjToInt() && ExistStockInfo.StockStatus == StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt())
+                                {
+                                    //鑾峰彇閲囪喘淇℃伅
+                                    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
+                                {
+                                    throw new Exception("鏈煡閿欒");
+                                }
+                            }
+                            #endregion
+                        }
                     }
                     else if (!stationCode.IsNullOrEmpty() && stockInfoOld == null)
                     {
@@ -314,7 +353,7 @@
         /// <param name="palletCode">绾稿嵎鏉$爜</param>
         /// <param name="rfidCode">绾稿嵎RIFD</param>
         /// <returns></returns>
-        public WebResponseContent PurchaseBoxing(string palletCode)
+        public WebResponseContent PurchaseBoxing(string palletCode, int orderType = 0)
         {
             WebResponseContent content=new WebResponseContent();
             try
@@ -326,83 +365,34 @@
                 Dt_StockInfo stockInfoOld = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == palletCode);
                 if (stockInfoOld != null)
                 {
-                    throw new Exception("鏉$爜淇℃伅搴撳瓨涓凡瀛樺湪");
+                    throw new Exception($"鏉$爜淇℃伅{palletCode}搴撳瓨涓凡瀛樺湪");
                 }
-                //鑾峰彇閲囪喘淇℃伅
-                Dt_PurchaseBSTOrderDetail purchaseBSTOrderDetail = _inboundRepository.PurchaseBSTOrderDetailRepository.QueryFirst(x => x.Barcode == palletCode);
-                if (purchaseBSTOrderDetail == null)
+                if (orderType>0) //鏂板巶绾稿嵎骞冲彴鍏ュ簱
                 {
-                    BSTResponse<BSTStockInfoDTO> bSTResponse = _invokeERPService.BSTStockAsync(palletCode).DeserializeObject<BSTResponse<BSTStockInfoDTO>>();
-                    if (bSTResponse.Code == 500)
+                    //鑾峰彇涓诲崟
+                    Dt_InboundOrder inboundOrder = BaseDal.Db.Queryable<Dt_InboundOrder>().Where(x=>x.OrderType==orderType).Includes(x=>x.Details).Where(x=>x.Details.Any(v=>v.BarCode==palletCode)).First();
+                    if (inboundOrder==null)
                     {
-                        throw new Exception($"鏈壘鍒版潯鐮亄palletCode}閲囪喘淇℃伅骞朵竴鏈烢RP搴撳瓨涔熶笉瀛樺湪");
+                        throw new Exception($"鏈壘鍒版潯鐮亄palletCode}鍏ュ簱鍗曟嵁淇℃伅");
                     }
-
-                    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()
+                    Dt_InboundOrderDetail inboundOrderDetail = inboundOrder.Details.FirstOrDefault(x=>x.BarCode == palletCode);
+                    if (inboundOrderDetail==null)
                     {
-                        MaterielInvOrgId = materielInfo.MaterielInvOrgId,
-                        PalletCode = palletCode,
-                        RfidCode = "",
-                        LocationCode = "",
-                        PalletType = 1,
-                        WarehouseId = materielInfo.WarehouseId,
-                        StockAttribute = materielInfo.MaterielSourceType,
-                        StockStatus = StockStatusEmun.鍗氭�濋�氱粍鐩樻殏瀛�.ObjToInt(),
-                        MaterielSpec = materielInfo.MaterielSpec,
-                        Unit = materielInfo.MaterielUnit,
-                        MaterielThickness = bSTStockInfoDTO.Thick,
-                        MaterielWide = bSTStockInfoDTO.W,
-                        MaterielWeight = bSTStockInfoDTO.Qty,
-                        MaterielCode = materielInfo.MaterielCode,
-                        MaterielName = materielInfo.MaterielName,
-                        StockLength = bSTStockInfoDTO.StockMeter,
-                        MaterielId = materielInfo.MaterialSourceId
-                    };
-                    if (bSTStockInfoDTO.W > 1200)
-                    {
-                        stockInfo.PalletType = 2;
+                        throw new Exception($"鏈壘鍒板叆搴撳崟鍙蜂负{inboundOrder.UpperOrderNo}鏉$爜{palletCode}鍗曟嵁淇℃伅");
                     }
-                    Dt_YLInboundCache? yLInboundCache = _inboundRepository.YLInboundCacheRepository.QueryData(x => x.InvOrg == MaterielInvOrgEnum.鑰佸巶.ToString()).FirstOrDefault() ?? throw new Exception("鏈壘鍒板師鏂欐潯鐮佺紦瀛樹俊鎭�");
-                    int Id = yLInboundCache.Id;
-                    if (yLInboundCache.BarCode == palletCode)
+                    if (inboundOrderDetail.MaterialWide < 700)
                     {
-                        throw new Exception($"鏉$爜{palletCode}宸叉壂鐮�");
+                        return content.Error("鏂板巶鐗╂枡骞呭闄愬埗涓�700-2700mm");
                     }
-                    else if (yLInboundCache.BarCode != palletCode && yLInboundCache.BindStatus == WhetherEnum.True.ObjToInt())
+                    if (inboundOrderDetail.MaterialThick<=0)
                     {
-                        yLInboundCache = _mapper.Map<Dt_YLInboundCache>(stockInfo);
-                        yLInboundCache.Id = Id;
-                        _unitOfWorkManage.BeginTran();
-                        //鏂板缁勭洏淇℃伅
-                        _stockRepository.StockInfoRepository.AddData(stockInfo);
-                        _inboundRepository.YLInboundCacheRepository.UpdateData(yLInboundCache);
-                        //鍚姩绾夸綋
-                        WebResponseContent webResponse = YLPurchasePush();
-                        if (!webResponse.Status)
-                        {
-                            throw new Exception(webResponse.Message);
-                        }
-                        _unitOfWorkManage.CommitTran();
-                        return content.OK("鎴愬姛", yLInboundCache);
+                        return content.Error("鐗╂枡鐩村緞闇�瑕佸ぇ浜�0");
                     }
-                    else
+                    if (inboundOrderDetail.OrderDetailStatus != InOrderStatusEnum.鏈紑濮�.ObjToInt())
                     {
-                        throw new Exception($"涓婂嵎鏉$爜{yLInboundCache.BarCode}杩樻湭杩涜缁戝畾");
+                        throw new Exception($"鏉$爜{palletCode}淇℃伅宸插叆搴撴垨鍏ュ簱涓�");
                     }
-                    
-                }
-                else
-                {
-                    if (purchaseBSTOrderDetail.PurchaseBSTOrderDetailStatus != InOrderStatusEnum.鏈紑濮�.ObjToInt())
-                    {
-                        throw new Exception($"鏉$爜{palletCode}閲囪喘淇℃伅宸插叆搴撴垨鍏ュ簱涓�");
-                    }
-                    Dt_YLInboundCache? yLInboundCache = _inboundRepository.YLInboundCacheRepository.QueryData(x => x.InvOrg == MaterielInvOrgEnum.鑰佸巶.ToString()).FirstOrDefault();
+                    Dt_YLInboundCache? yLInboundCache = _inboundRepository.YLInboundCacheRepository.QueryData(x => x.InvOrg == MaterielInvOrgEnum.鏂板巶.ToString()).FirstOrDefault();
                     if (yLInboundCache == null)
                     {
                         throw new Exception("鏈壘鍒板師鏂欐潯鐮佺紦瀛樹俊鎭�");
@@ -414,17 +404,16 @@
                     }
                     else if (yLInboundCache.BarCode != palletCode && yLInboundCache.BindStatus == WhetherEnum.True.ObjToInt())
                     {
-                        yLInboundCache = _mapper.Map<Dt_YLInboundCache>(purchaseBSTOrderDetail);
+                        yLInboundCache = _mapper.Map<Dt_YLInboundCache>(inboundOrderDetail);
                         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_MaterielInfo materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterielCode == inboundOrderDetail.MaterialCode);
                         //鐢熸垚搴撳瓨缁勭洏淇℃伅
                         Dt_StockInfo stockInfo = new Dt_StockInfo()
                         {
                             MaterielInvOrgId = materielInfo.MaterielInvOrgId,
-                            PalletCode = purchaseBSTOrderDetail.Barcode,
+                            PalletCode = inboundOrderDetail.BarCode,
                             RfidCode = "",
                             LocationCode = "",
                             PalletType = 1,
@@ -433,29 +422,29 @@
                             StockStatus = StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt(),
                             MaterielSpec = materielInfo.MaterielSpec,
                             Unit = materielInfo.MaterielUnit,
-                            MaterielThickness = purchaseBSTOrderDetail.MaterialThick,
-                            MaterielWide = purchaseBSTOrderDetail.MaterialWide,
-                            MaterielWeight = purchaseBSTOrderDetail.DeliveryQty,
+                            MaterielThickness = inboundOrderDetail.MaterialThick,
+                            MaterielWide = inboundOrderDetail.MaterialWide,
+                            MaterielWeight = inboundOrderDetail.MaterialWeight,
                             MaterielCode = materielInfo.MaterielCode,
                             MaterielName = materielInfo.MaterielName,
-                            StockLength = purchaseBSTOrderDetail.ProcurementLength,
-                            MaterielId = purchaseBSTOrderDetail.MaterialId
+                            BatchNo=inboundOrderDetail.MaterialLot,
+                            StockLength = inboundOrderDetail.OrderQuantity
                         };
-                        if (purchaseBSTOrderDetail.MaterialWide > 1200)
+                        if (inboundOrderDetail.MaterialWide > 1200)
                         {
                             stockInfo.PalletType = 2;
                         }
-                        purchaseBSTOrderDetail.PurchaseBSTOrderDetailStatus = InOrderStatusEnum.鍏ュ簱涓�.ObjToInt();
+                        inboundOrderDetail.OrderDetailStatus = InOrderStatusEnum.鍏ュ簱涓�.ObjToInt();
                         _unitOfWorkManage.BeginTran();
                         _inboundRepository.YLInboundCacheRepository.UpdateData(yLInboundCache);
                         //鏂板缁勭洏淇℃伅
                         _stockRepository.StockInfoRepository.AddData(stockInfo);
-                        if (purchaseBSTOrder.PurchaseOrderStatus == InOrderStatusEnum.鏈紑濮�.ObjToInt())
+                        if (inboundOrder.InboundOrderStatus == InOrderStatusEnum.鏈紑濮�.ObjToInt())
                         {
-                            purchaseBSTOrder.PurchaseOrderStatus = InOrderStatusEnum.鍏ュ簱涓�.ObjToInt();
-                            _inboundRepository.PurchaseBSTOrderRepository.UpdateData(purchaseBSTOrder);
+                            inboundOrder.InboundOrderStatus = InOrderStatusEnum.鍏ュ簱涓�.ObjToInt();
+                            _inboundRepository.InboundOrderRepository.UpdateData(inboundOrder);
                         }
-                        _inboundRepository.PurchaseBSTOrderDetailRepository.UpdateData(purchaseBSTOrderDetail);
+                        _inboundRepository.InboundOrderDetailRepository.UpdateData(inboundOrderDetail);
                         //鍚姩绾夸綋
                         WebResponseContent webResponse = YLPurchasePush();
                         if (!webResponse.Status)
@@ -463,14 +452,164 @@
                             throw new Exception(webResponse.Message);
                         }
                         _unitOfWorkManage.CommitTran();
+                        Dt_StockInfo stockInfoAdd = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == stockInfo.PalletCode);
+                        _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfoAdd, 0, stockInfoAdd.StockLength, StockChangeTypeEnum.MaterielGroup);
                         return content.OK("鎴愬姛", yLInboundCache);
                     }
                     else
                     {
-                       throw new Exception($"涓婂嵎鏉$爜{yLInboundCache.BarCode}杩樻湭杩涜缁戝畾");
+                        throw new Exception($"涓婂嵎鏉$爜{yLInboundCache.BarCode}杩樻湭杩涜缁戝畾");
                     }
                 }
-                
+                else //鑰佸巶绾稿嵎骞冲彴鍏ュ簱
+                {
+                    //鑾峰彇閲囪喘淇℃伅
+                    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)
+                        {
+                            throw new Exception($"鏈壘鍒版潯鐮亄palletCode}閲囪喘淇℃伅骞朵竴鏈烢RP搴撳瓨涔熶笉瀛樺湪");
+                        }
+
+                        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()
+                        {
+                            MaterielInvOrgId = materielInfo.MaterielInvOrgId,
+                            PalletCode = palletCode,
+                            RfidCode = "",
+                            LocationCode = "",
+                            PalletType = 1,
+                            WarehouseId = materielInfo.WarehouseId,
+                            StockAttribute = materielInfo.MaterielSourceType,
+                            StockStatus = StockStatusEmun.鍗氭�濋�氱粍鐩樻殏瀛�.ObjToInt(),
+                            MaterielSpec = materielInfo.MaterielSpec,
+                            Unit = materielInfo.MaterielUnit,
+                            MaterielThickness = bSTStockInfoDTO.Thick,
+                            MaterielWide = bSTStockInfoDTO.W,
+                            MaterielWeight = bSTStockInfoDTO.Qty,
+                            MaterielCode = materielInfo.MaterielCode,
+                            MaterielName = materielInfo.MaterielName,
+                            StockLength = bSTStockInfoDTO.StockMeter,
+                            MaterielId = materielInfo.MaterialSourceId
+                        };
+                        if (bSTStockInfoDTO.W > 1200)
+                        {
+                            stockInfo.PalletType = 2;
+                        }
+                        Dt_YLInboundCache? yLInboundCache = _inboundRepository.YLInboundCacheRepository.QueryData(x => x.InvOrg == MaterielInvOrgEnum.鑰佸巶.ToString()).FirstOrDefault() ?? throw new Exception("鏈壘鍒板師鏂欐潯鐮佺紦瀛樹俊鎭�");
+                        int Id = yLInboundCache.Id;
+                        if (yLInboundCache.BarCode == palletCode)
+                        {
+                            throw new Exception($"鏉$爜{palletCode}宸叉壂鐮�");
+                        }
+                        else if (yLInboundCache.BarCode != palletCode && yLInboundCache.BindStatus == WhetherEnum.True.ObjToInt())
+                        {
+                            yLInboundCache = _mapper.Map<Dt_YLInboundCache>(stockInfo);
+                            yLInboundCache.Id = Id;
+                            _unitOfWorkManage.BeginTran();
+                            //鏂板缁勭洏淇℃伅
+                            _stockRepository.StockInfoRepository.AddData(stockInfo);
+                            _inboundRepository.YLInboundCacheRepository.UpdateData(yLInboundCache);
+                            //鍚姩绾夸綋
+                            WebResponseContent webResponse = YLPurchasePush();
+                            if (!webResponse.Status)
+                            {
+                                throw new Exception(webResponse.Message);
+                            }
+                            _unitOfWorkManage.CommitTran();
+                            Dt_StockInfo stockInfoAdd = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == stockInfo.PalletCode);
+                            _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfoAdd, 0, stockInfoAdd.StockLength, StockChangeTypeEnum.MaterielGroup);
+                            return content.OK("鎴愬姛", yLInboundCache);
+                        }
+                        else
+                        {
+                            throw new Exception($"涓婂嵎鏉$爜{yLInboundCache.BarCode}杩樻湭杩涜缁戝畾");
+                        }
+
+                    }
+                    else
+                    {
+                        if (purchaseBSTOrderDetail.PurchaseBSTOrderDetailStatus != InOrderStatusEnum.鏈紑濮�.ObjToInt())
+                        {
+                            throw new Exception($"鏉$爜{palletCode}閲囪喘淇℃伅宸插叆搴撴垨鍏ュ簱涓�");
+                        }
+                        Dt_YLInboundCache? yLInboundCache = _inboundRepository.YLInboundCacheRepository.QueryData(x => x.InvOrg == MaterielInvOrgEnum.鑰佸巶.ToString()).FirstOrDefault();
+                        if (yLInboundCache == null)
+                        {
+                            throw new Exception("鏈壘鍒板師鏂欐潯鐮佺紦瀛樹俊鎭�");
+                        }
+                        int Id = yLInboundCache.Id;
+                        if (yLInboundCache.BarCode == 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)
+                            {
+                                throw new Exception(webResponse.Message);
+                            }
+                            _unitOfWorkManage.CommitTran();
+                            Dt_StockInfo stockInfoAdd = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == stockInfo.PalletCode);
+                            _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfoAdd, 0, stockInfoAdd.StockLength, StockChangeTypeEnum.MaterielGroup);
+                            return content.OK("鎴愬姛", yLInboundCache);
+                        }
+                        else
+                        {
+                            throw new Exception($"涓婂嵎鏉$爜{yLInboundCache.BarCode}杩樻湭杩涜缁戝畾");
+                        }
+                    }
+                }
             }
             catch (Exception ex)
             {
@@ -532,7 +671,7 @@
                     if (stockInfo.MaterielThickness >= 300 && stockInfo.MaterielThickness <= 1300 && stockInfo.MaterielWide >= 700 && stockInfo.MaterielWide <= 2700)
                     {
                         //鑾峰彇鍒嗛厤
-                        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();
+                        List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => x.WarehouseId == warehouse.WarehouseId && x.LocationStatus == LocationStatusEnum.Free.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);
                     }
@@ -548,10 +687,10 @@
                             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("YL") && !x.RoadwayNo.Contains("YLDual") && (LayerLimit ? x.Columns>=56 : x.Columns<=55)).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.Normal.ObjToInt() && x.RoadwayNo.Contains("YL") && !x.RoadwayNo.Contains("YLDual") && (LayerLimit ? x.Columns>=56 : x.Columns<=55)).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList();
                         if (stockInfo.MaterielWide > 2200)
                         {
-                            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 == "SC02_YL" && (LayerLimit ? x.Columns >= 56 : x.Columns <= 55)).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList();
+                            locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => x.WarehouseId == warehouse.WarehouseId && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && x.EnableStatus == EnableStatusEnum.Normal.ObjToInt() && x.RoadwayNo == "SC02_YL" && (LayerLimit ? x.Columns >= 56 : x.Columns <= 55)).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList();
                         }
 
                         roadwayNo = HandleRoadway(locationCounts, warehouse);
@@ -599,7 +738,7 @@
                     {
                         return content.Error($"鏈壘鍒板搴旂殑缁堢偣璐т綅淇℃伅");
                     }
-                    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.涓�妤兼棤绾烘穻鑶�)));
+                    Dt_AGVStationInfo agvstation = _basicRepository.AGVStationInfoRepository.QueryFirst(x => x.AGVStationCode == task.SourceAddress && ( x.StationArea == nameof(StationAreaEnum.涓�妤兼湀鍙扮爜澶�) || x.StationArea == nameof(StationAreaEnum.涓�妤兼棤绾虹粐甯�) || x.StationArea == nameof(StationAreaEnum.涓�妤兼棤绾烘穻鑶�) || x.StationArea == nameof(StationAreaEnum.涓�妤兼棤绾烘穻鑶�)));
                     if (agvstation != null)
                     {
                         agvstation.IsOccupied = WhetherEnum.False.ObjToInt();
@@ -620,7 +759,7 @@
                         BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? WIDESEA_Core.Enums.OperateTypeEnum.浜哄伐瀹屾垚 : WIDESEA_Core.Enums.OperateTypeEnum.鑷姩瀹屾垚);
                         _unitOfWorkManage.CommitTran();
                     }
-                    else if (proStockInfo != null && proStockInfo.StockStatus == StockStatusEmun.鎵嬪姩缁勭洏鍏ュ簱纭.ObjToInt())
+                    else if (proStockInfo != null &&( proStockInfo.StockStatus == StockStatusEmun.鎵嬪姩缁勭洏鍏ュ簱纭.ObjToInt() || proStockInfo.StockStatus == StockStatusEmun.鍏ュ簱纭.ObjToInt()))
                     {
                         task.TaskStatus = TaskStatusEnum.Finish.ObjToInt();
                         proStockInfo.proStockInfoDetails.ForEach(x =>
@@ -639,6 +778,7 @@
                         _basicService.LocationInfoService.UpdateLocationStatus(locationInfoEnd, proStockInfo.PalletType, LocationStatusEnum.InStock, proStockInfo.WarehouseId);
                         BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? WIDESEA_Core.Enums.OperateTypeEnum.浜哄伐瀹屾垚 : WIDESEA_Core.Enums.OperateTypeEnum.鑷姩瀹屾垚);
                         _unitOfWorkManage.CommitTran();
+                        _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(proStockInfo, 0, proStockInfo.proStockInfoDetails.Sum(x => x.StockQty), StockChangeTypeEnum.MaterielGroup);
                     }
                     else
                     {
@@ -695,6 +835,7 @@
                         content.Message = bSTResponse.Msg;
                     }
                     _unitOfWorkManage.CommitTran();
+                    _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, stockInfo.StockLength, 0, StockChangeTypeEnum.Inbound,taskNum:task.TaskNum);
                 }
                 return content.OK();
             }
@@ -715,7 +856,7 @@
             {
                 string roadwayNo = "";
                 //鑾峰彇宸烽亾鍙垎閰嶇殑璐т綅鏁伴噺
-                List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => x.WarehouseId == WarehouseEnum.LLDCP.ObjToInt() && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && x.RoadwayNo.Contains("CP")).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 == WarehouseEnum.LLDCP.ObjToInt() && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && x.EnableStatus == EnableStatusEnum.Normal.ObjToInt() && x.RoadwayNo.Contains("CP")).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList();
                 //绛涢�夊綋鍓嶅叆搴撲换鍔′腑宸插垎閰嶅贩閬撲换鍔℃暟閲�
                 List<LocationCount> useLocationCounts = Db.Queryable<Dt_Task>().Where(x => (x.WarehouseId == WarehouseEnum.LLDCP.ObjToInt()|| x.WarehouseId == WarehouseEnum.LLDFL.ObjToInt())
                 && locationCounts.Select(j=>j.RoadwayNo).Distinct().Contains(x.Roadway)
@@ -785,7 +926,7 @@
                 LocationStatusEnum lastStatus = (LocationStatusEnum)locationInfo.LocationStatus;
                 //鏇存柊閿佸畾璐т綅
                 _unitOfWorkManage.BeginTran();
-                _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, lastStatus, LocationStatusEnum.Lock, LocationChangeType.InboundAssignLocation);
+                _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, lastStatus, LocationStatusEnum.Lock, LocationChangeType.InboundAssignLocation,taskNum: taskNum);
                 _basicService.LocationInfoService.UpdateLocationStatus(locationInfo, task.PalletType, LocationStatusEnum.Lock, task.WarehouseId);
                 BaseDal.UpdateData(task);
                 _unitOfWorkManage.CommitTran();
@@ -797,9 +938,9 @@
                 return WebResponseContent.Instance.Error(ex.Message);
             }
         }
-        
+
         /// <summary>
-        /// 绌烘鍥炲簱
+        /// 鎴愬搧绌烘墭鍥炲簱
         /// </summary>
         public WebResponseContent EmptyBackTask(string barCode, string startPoint)
         {
@@ -986,6 +1127,116 @@
                 }
                 return content;
             }
+        }
+        /// <summary>
+        /// 杈呮枡(鎴愬搧)閲囪喘/鏈熷垵鍏ュ簱
+        /// </summary>
+        /// <returns></returns>
+        public WebResponseContent InboundOrderInTask(string bindCode,string barCode,string startPoint, int orderType = 0)
+        {
+            WebResponseContent content=new WebResponseContent();
+            try
+            {
+                //鑾峰彇涓诲崟
+                Dt_InboundOrder inboundOrder = BaseDal.Db.Queryable<Dt_InboundOrder>().Where(x => x.OrderType == orderType).Includes(x => x.Details).Where(x => x.Details.Any(v => v.BarCode == bindCode)).First();
+                if (inboundOrder == null)
+                {
+                    throw new Exception($"鏈壘鍒版潯鐮亄bindCode}鍏ュ簱鍗曟嵁淇℃伅");
+                }
+                Dt_InboundOrderDetail inboundOrderDetail = inboundOrder.Details.FirstOrDefault(x => x.BarCode == bindCode);
+                if (inboundOrderDetail == null)
+                {
+                    throw new Exception($"鏈壘鍒板叆搴撳崟鍙蜂负{inboundOrder.UpperOrderNo}鏉$爜{bindCode}鍗曟嵁淇℃伅");
+                }
+                if (inboundOrderDetail.OrderDetailStatus != InOrderStatusEnum.鏈紑濮�.ObjToInt())
+                {
+                    throw new Exception($"鏉$爜{bindCode}淇℃伅宸插叆搴撴垨鍏ュ簱涓�");
+                }
+                Dt_AGVStationInfo agvstation = _basicRepository.AGVStationInfoRepository.QueryFirst(x => x.AGVStationCode == startPoint);
+                if (agvstation == null)
+                {
+                    return content.Error($"璧风偣閿欒{startPoint}");
+                }
+                //鍒ゆ柇褰撳墠鐐逛綅鏄惁閲嶅
+                Dt_Task taskOldPoint = BaseDal.QueryFirst(x => x.SourceAddress == startPoint && (x.TaskStatus == TaskStatusEnum.New.ObjToInt() || x.TaskStatus == TaskStatusEnum.AGV_Executing.ObjToInt()));
+                if (taskOldPoint != null)
+                {
+                    return content.Error($"绔欑偣{startPoint}宸插瓨鍦ㄤ换鍔�");
+                }
+                Dt_Task taskOld = BaseDal.QueryFirst(x => x.PalletCode == barCode);
+                if (taskOld != null)
+                {
+                    return content.Error($"鎵樼洏{barCode}浠诲姟宸插瓨鍦�");
+                }
+                Dt_ProStockInfo proStockInfoOld = _stockRepository.ProStockInfoRepository.QueryFirst(x => x.PalletCode == barCode);
+                if (proStockInfoOld != null)
+                {
+                    return content.Error($"鎵樼洏{barCode}宸插瓨鍦�");
+                }
+                //鍒嗛厤宸烽亾
+                string roadWay = AssignCPRoadwayNo();
+                //鑾峰彇鐗╂枡
+                Dt_MaterielInfo materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x =>x.WarehouseId==inboundOrder.WarehouseId && x.MaterielCode == inboundOrderDetail.MaterialCode);
+                Dt_ProStockInfoDetail proStockInfoDetail = new Dt_ProStockInfoDetail()
+                {
+                    ProductCode = materielInfo.MaterielCode,
+                    ProductNo=bindCode,
+                    ProductName = materielInfo.MaterielName,
+                    ProductSpec = materielInfo.MaterielSpec,
+                    LotNumber = inboundOrderDetail.MaterialLot,
+                    ProductUnit = materielInfo.MaterielUnit,
+                    StockQty = inboundOrderDetail.OrderQuantity,
+                    ProStockDetailStatus = StockStatusEmun.鍏ュ簱纭.ObjToInt()
+                };
+                Dt_ProStockInfo proStockInfo = new Dt_ProStockInfo()
+                {
+                    PalletCode = barCode,
+                    ProStockAttribute = materielInfo.MaterielSourceType,
+                    PalletType = 1,
+                    LocationCode = "",
+                    WarehouseId = materielInfo.WarehouseId,
+                    StockStatus = StockStatusEmun.鍏ュ簱纭.ObjToInt(),
+                    proStockInfoDetails = new List<Dt_ProStockInfoDetail> { proStockInfoDetail }
+                };
+
+                Dt_Task newTask = new Dt_Task()
+                {
+                    CurrentAddress = startPoint,
+                    Grade = 0,
+                    NextAddress = "",
+                    PalletCode = barCode,
+                    Roadway = roadWay,
+                    SourceAddress = startPoint,
+                    TargetAddress = "",
+                    TaskType = TaskTypeEnum.Inbound.ObjToInt(),
+                    TaskStatus = TaskStatusEnum.New.ObjToInt(),
+                    WarehouseId = inboundOrder.WarehouseId,
+                    PalletType = 1,
+                    Remark="鍒濇湡鍏ュ簱"
+                };
+                inboundOrderDetail.OrderDetailStatus=InOrderStatusEnum.鍏ュ簱涓�.ObjToInt();
+                _unitOfWorkManage.BeginTran();
+                if (inboundOrder.InboundOrderStatus==InOrderStatusEnum.鏈紑濮�.ObjToInt())
+                {
+                    inboundOrder.InboundOrderStatus = InOrderStatusEnum.鍏ュ簱涓�.ObjToInt();
+                    _inboundRepository.InboundOrderRepository.UpdateData(inboundOrder);
+                }
+                _inboundRepository.InboundOrderDetailRepository.UpdateData(inboundOrderDetail);
+                int taskId = BaseDal.AddData(newTask);
+                BaseDal.Db.InsertNav(proStockInfo).Include(x => x.proStockInfoDetails).ExecuteCommand();
+                newTask.TaskId = taskId;
+                _unitOfWorkManage.CommitTran();
+                //鎺ㄩ�佷换鍔�
+                PushTasksToWCS(new List<Dt_Task> { newTask }, "AGV");
+                content.OK("鍙戦�佹垚鍔�");
+
+            }
+            catch (Exception ex)
+            {
+                _unitOfWorkManage.RollbackTran();
+                content.Error(ex.Message);
+            }
+            return content;
         }
         /// <summary>
         /// 鍗板埛浣欐枡閫�鏂欎换鍔�
@@ -1319,7 +1570,7 @@
                     };
                     TaskTypeEnum taskTypeEnum = CheckPointCode.StationArea switch
                     {
-                        nameof(AGVStationAreaEnum.涓�妤煎嵃鍒�) => TaskTypeEnum.PrintYLInbound,
+                        nameof(StationAreaEnum.涓�妤煎嵃鍒�) => TaskTypeEnum.PrintYLInbound,
                         _ => throw new Exception("鏈壘鍒板搴斾换鍔�")
                     };
                     newTask.TaskType = taskTypeEnum.ObjToInt();

--
Gitblit v1.9.3