wangxinhui
10 天以前 834294889ab62bafaf034b1b87c2ead961c33476
ÏîÄ¿´úÂë/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;
@@ -163,7 +164,9 @@
                    TaskStatus = TaskStatusEnum.New.ObjToInt(),
                    WarehouseId = stockInfo.WarehouseId,
                    PalletType = stockInfo.PalletType,
                    TaskLength = (int)stockInfo.MaterielWide
                    TaskLength = (int)stockInfo.MaterielWide,
                    MaterielCode=stockInfo.MaterielCode,
                    Quantity=stockInfo.StockLength
                };
                //更新状态
                if (stockInfo.StockStatus == StockStatusEmun.手动组盘暂存.ObjToInt())
@@ -212,22 +215,25 @@
                    }
                    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();
                        decimal oldQty = stockInfoOld.StockLength;
                        //调用更新退料库存
                        stockInfoOld = ReturnStockUp(stockInfoOld, thickness);
                        //更新数据
                        UpdateStock(stockInfoOld, weight, thickness, wide);
                        return content.OK($"老厂未领料退库{stockInfoOld.RfidCode}");
                        //记录库存变动
                        _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfoOld, oldQty, oldQty < stockInfoOld.StockLength ? stockInfoOld.StockLength - oldQty : oldQty - stockInfoOld.StockLength, StockChangeTypeEnum.MaterielGroup);
                        return content.OK($"老厂未领料退库RFID{stockInfoOld.RfidCode}条码{stockInfoOld.PalletCode}");
                    }
                    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();
                        decimal oldQty = stockInfoOld.StockLength;
                        //调用更新退料库存
                        stockInfoOld = ReturnStockUp(stockInfoOld, thickness);
                        //更新数据
                        UpdateStock(stockInfoOld, weight, thickness, wide);
                        return content.OK($"老厂领料退库{stockInfoOld.RfidCode}");
                        //记录库存变动
                        _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfoOld, oldQty, oldQty < stockInfoOld.StockLength ? stockInfoOld.StockLength- oldQty: oldQty- stockInfoOld.StockLength, StockChangeTypeEnum.MaterielGroup);
                        return content.OK($"老厂领料退库RFID{stockInfoOld.RfidCode}条码{stockInfoOld.PalletCode}");
                    }
                    else if (stockInfoOld != null)
                    {
@@ -236,52 +242,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}已绑定RFID{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}已绑定RFID{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($"采购入库RFID{ExistStockInfo.RfidCode}绑定{ExistStockInfo.PalletCode}");
                                }
                                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}已绑定RFID{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)
                    {
@@ -301,6 +345,37 @@
            }
            return content;
        }
        /// <summary>
        /// æ›´æ–°é€€æ–™åº“å­˜
        /// </summary>
        /// <returns></returns>
        public Dt_StockInfo ReturnStockUp(Dt_StockInfo stockInfoOld,decimal thickness)
        {
            BSTResponse<BSTStockInfoDTO> bSTResponse = _invokeERPService.BSTStockAsync(stockInfoOld.PalletCode).DeserializeObject<BSTResponse<BSTStockInfoDTO>>();
            if (bSTResponse.Code == 500)
            {
                throw new Exception($"未找到条码{stockInfoOld.PalletCode}一期ERP库存不存在");
            }
            BSTStockInfoDTO bSTStockInfoDTO = bSTResponse.Data ?? throw new Exception($"一期ERP未返回{stockInfoOld.PalletCode}的库存信息");
            if (stockInfoOld.StockStatus == StockStatusEmun.老厂退料暂存.ObjToInt())
            {
                stockInfoOld.IsPick = WhetherEnum.False.ObjToInt();
            }
            stockInfoOld.StockStatus = StockStatusEmun.老厂退库.ObjToInt();
            stockInfoOld.MaterielThickness = bSTStockInfoDTO.Thick;
            stockInfoOld.MaterielWeight = bSTStockInfoDTO.Qty;
            stockInfoOld.MaterielWide = bSTStockInfoDTO.W;
            stockInfoOld.StockLength = bSTStockInfoDTO.StockMeter;
            stockInfoOld.IsFull = WhetherEnum.True.ObjToInt();
            stockInfoOld.StockOutLength = 0;
            stockInfoOld.WarehouseId = WarehouseEnum.LLDYL.ObjToInt();
            if (thickness < 400)
            {
                throw new Exception($"RFID{stockInfoOld.RfidCode}条码{stockInfoOld.PalletCode}直径小于400mm");
            }
            return stockInfoOld;
        }
        public void UpdateStock(Dt_StockInfo stockInfo, decimal weight = 0, decimal thickness = 0, decimal wide = 0)
        {
            stockInfo.CheckWeight = weight;
@@ -314,7 +389,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 +401,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}采购信息并一期ERP库存也不存在");
                        throw new Exception($"未找到条码{palletCode}入库单据信息");
                    }
                    BSTStockInfoDTO bSTStockInfoDTO=bSTResponse.Data ?? throw new Exception($"一期ERP未返回{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 < 690)
                    {
                        throw new Exception($"条码{palletCode}已扫码");
                        return content.Error("新厂物料幅宽限制为690-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 +440,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 +458,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 +488,167 @@
                            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}采购信息并一期ERP库存也不存在");
                        }
                        BSTStockInfoDTO bSTStockInfoDTO = bSTResponse.Data ?? throw new Exception($"一期ERP未返回{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)
            {
@@ -529,10 +707,10 @@
                if (stockInfo.MaterielInvOrgId==MaterielInvOrgEnum.新厂.ObjToInt())
                {
                    //限制直径
                    if (stockInfo.MaterielThickness >= 300 && stockInfo.MaterielThickness <= 1300 && stockInfo.MaterielWide >= 700 && stockInfo.MaterielWide <= 2700)
                    if (stockInfo.CheckThickness >= 300 && stockInfo.CheckThickness <= 1300 && stockInfo.MaterielWide >= 690 && 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) }).OrderBy(x => x.RoadwayNo).ToList();
                        roadwayNo = HandleRoadway(locationCounts, warehouse);
                    }
@@ -540,19 +718,26 @@
                else
                {
                    //限制
                    if (stockInfo.MaterielThickness >= 800 && stockInfo.MaterielThickness <= 1500 && stockInfo.MaterielWide >= 700 && stockInfo.MaterielWide <= 2500)
                    if (stockInfo.CheckThickness >= 800 && stockInfo.CheckThickness <= 1500 && stockInfo.MaterielWide >= 700 && stockInfo.MaterielWide <= 2500)
                    {
                        bool LayerLimit = false;
                        if (stockInfo.MaterielThickness>1300)
                        if (stockInfo.CheckThickness > 1300)
                        {
                            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) }).OrderBy(x => x.RoadwayNo).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) }).OrderBy(x => x.RoadwayNo).ToList();
                        }
                        roadwayNo = HandleRoadway(locationCounts, warehouse);
                    }
                    else if (stockInfo.CheckThickness >= 400 && stockInfo.CheckThickness < 800 && stockInfo.MaterielWide >= 700 && stockInfo.MaterielWide <= 2500)
                    {
                        //获取分配
                        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) }).OrderBy(x => x.RoadwayNo).ToList();
                        roadwayNo = HandleRoadway(locationCounts, warehouse);
                    }
@@ -599,7 +784,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 +805,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 +824,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.Inbound);
                    }
                    else
                    {
@@ -676,8 +862,11 @@
                    _stockService.StockInfoService.Repository.UpdateData(stockInfo);
                    _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.自动完成);
                    _unitOfWorkManage.CommitTran();
                    //记录库存变动
                    _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, stockInfo.StockLength, 0, StockChangeTypeEnum.Inbound,taskNum:task.TaskNum);
                    //上报老厂ERP
                    if (stockInfo.MaterielInvOrgId == MaterielInvOrgEnum.老厂.ObjToInt() && task.TaskType==TaskTypeEnum.Inbound.ObjToInt())
                    if (stockInfo.MaterielInvOrgId == MaterielInvOrgEnum.老厂.ObjToInt() && task.TaskType == TaskTypeEnum.Inbound.ObjToInt())
                    {
                        int Qty = Convert.ToInt32(stockInfo.MaterielWeight);
                        BSTPurchaseUpModel bSTPurchaseUpModel = new BSTPurchaseUpModel()
@@ -688,15 +877,10 @@
                            RfidUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
                        };
                        BSTResponse<object> bSTResponse = _invokeERPService.BSTPurchaseUp(bSTPurchaseUpModel).DeserializeObject<BSTResponse<object>>();
                        if (bSTResponse.Code == 500)
                        {
                            throw new Exception($"BST一期ERP同步入库信息失败,错误信息:{bSTResponse.Msg}");
                        }
                        content.Message = bSTResponse.Msg;
                        content.Message = bSTResponse?.Msg;
                    }
                    _unitOfWorkManage.CommitTran();
                }
                return content.OK();
                content.OK();
            }
            catch (Exception ex)
            {
@@ -715,7 +899,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 +969,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 +981,9 @@
                return WebResponseContent.Instance.Error(ex.Message);
            }
        }
        /// <summary>
        /// ç©ºæ¡†å›žåº“
        /// æˆå“ç©ºæ‰˜å›žåº“
        /// </summary>
        public WebResponseContent EmptyBackTask(string barCode, string startPoint)
        {
@@ -986,6 +1170,227 @@
                }
                return content;
            }
        }
        /// <summary>
        /// è¾…æ–™(成品)采购/期初入库
        /// </summary>
        /// <returns></returns>
        public WebResponseContent InboundOrderInTask(string bindCode,string barCode,string startPoint, int orderType = 0)
        {
            WebResponseContent content=new WebResponseContent();
            try
            {
                InOrderTypeEnum inOrderTypeEnum = (InOrderTypeEnum)orderType;
                if (inOrderTypeEnum == InOrderTypeEnum.InventoryIn)
                {
                    //获取主单
                    Dt_InboundOrder inboundOrder = BaseDal.Db.Queryable<Dt_InboundOrder>().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,
                        ProInOrderNo = inboundOrder.UpperOrderNo,
                        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,
                        OrderNo = inboundOrder.UpperOrderNo,
                        MaterielCode = inboundOrderDetail.MaterialCode,
                        Quantity = inboundOrderDetail.OrderQuantity,
                        PalletType = 1
                    };
                    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");
                }
                else if (inOrderTypeEnum == InOrderTypeEnum.PurchaseIn)
                {
                    //获取主单
                    Dt_PurchaseOrder inboundOrder = BaseDal.Db.Queryable<Dt_PurchaseOrder>().Includes(x => x.Details).Where(x => x.Details.Any(v => v.BarCode == bindCode)).First();
                    if (inboundOrder == null)
                    {
                        throw new Exception($"未找到条码{bindCode}采购入库单据信息");
                    }
                    Dt_PurchaseOrderDetail inboundOrderDetail = inboundOrder.Details.FirstOrDefault(x => x.BarCode == bindCode);
                    if (inboundOrderDetail == null)
                    {
                        throw new Exception($"未找到入库单号为{inboundOrder.PurchaseOrderNo}条码{bindCode}单据信息");
                    }
                    if (inboundOrderDetail.PurchaseDetailStatus != 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.PurchaseDetailQuantity,
                        ProStockDetailStatus = StockStatusEmun.入库确认.ObjToInt()
                    };
                    Dt_ProStockInfo proStockInfo = new Dt_ProStockInfo()
                    {
                        PalletCode = barCode,
                        ProInOrderNo = inboundOrder.PurchaseOrderNo,
                        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,
                        OrderNo = inboundOrder.PurchaseOrderNo,
                        MaterielCode=inboundOrderDetail.MaterialCode,
                        Quantity=inboundOrderDetail.PurchaseDetailQuantity,
                        PalletType = 1
                    };
                    inboundOrderDetail.PurchaseDetailStatus = InOrderStatusEnum.入库中.ObjToInt();
                    _unitOfWorkManage.BeginTran();
                    if (inboundOrder.PurchaseOrderStatus == InOrderStatusEnum.未开始.ObjToInt())
                    {
                        inboundOrder.PurchaseOrderStatus = InOrderStatusEnum.入库中.ObjToInt();
                        _inboundRepository.PurchaseOrderRepository.UpdateData(inboundOrder);
                    }
                    _inboundRepository.PurchaseOrderDetailRepository.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");
                }
                else
                {
                    return content.Error($"未找到对应单据类型");
                }
                content.OK("发送成功");
            }
            catch (Exception ex)
            {
                _unitOfWorkManage.RollbackTran();
                content.Error(ex.Message);
            }
            return content;
        }
        /// <summary>
        /// å°åˆ·ä½™æ–™é€€æ–™ä»»åŠ¡
@@ -1207,6 +1612,10 @@
                            return content.Error($"周转位{nameof(MESReturnIssueDTO.PointCode)}{item?.PointCode}不存在,仅成品物料可不传");
                        }
                    }
                    if (materielInfo.MaterielSourceType == MaterielTypeEnum.成品.ObjToInt() && (item.Length <= 0 || item.Width <= 0 || item.Height<=0))
                    {
                        return content.Error($"箱码{item.ProPackCode},长度/宽度/高度不能为0");
                    }
                    Dt_MESProInOrderInfo AddproInOrderInfo = _mapper.Map<Dt_MESProInOrderInfo>(item);
                    AddproInOrderInfo.WarehouseId = materielInfo.WarehouseId;
                    AddproInOrderInfo.MESProOrderType = materielInfo.MaterielSourceType;
@@ -1319,7 +1728,7 @@
                    };
                    TaskTypeEnum taskTypeEnum = CheckPointCode.StationArea switch
                    {
                        nameof(AGVStationAreaEnum.一楼印刷) => TaskTypeEnum.PrintYLInbound,
                        nameof(StationAreaEnum.一楼印刷) => TaskTypeEnum.PrintYLInbound,
                        _ => throw new Exception("未找到对应任务")
                    };
                    newTask.TaskType = taskTypeEnum.ObjToInt();