wangxinhui
2025-11-18 b513ce3a4527e998da66c6f179a279472c7262a8
ÏîÄ¿´úÂë/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Inbound.cs
@@ -164,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())
@@ -213,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)
                    {
@@ -263,7 +268,7 @@
                                    UpdateStock(ExistStockInfo, weight, thickness, wide);
                                    _inboundRepository.YLInboundCacheRepository.UpdateData(yLInboundCache);
                                    _unitOfWorkManage.CommitTran();
                                    return content.OK($"采购入库{ExistStockInfo.RfidCode}");
                                    return content.OK($"采购入库RFID{ExistStockInfo.RfidCode}绑定{ExistStockInfo.PalletCode}");
                                }
                                else
                                {
@@ -339,6 +344,37 @@
                content.Error(ex.Message);
            }
            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 < 800)
            {
                throw new Exception($"RFID{stockInfoOld.RfidCode}条码{stockInfoOld.PalletCode}直径小于800mm");
            }
            return stockInfoOld;
        }
        public void UpdateStock(Dt_StockInfo stockInfo, decimal weight = 0, decimal thickness = 0, decimal wide = 0)
        {
@@ -453,6 +489,7 @@
                        }
                        _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);
                    }
@@ -524,6 +561,7 @@
                            }
                            _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);
                        }
@@ -601,6 +639,7 @@
                            }
                            _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);
                        }
@@ -671,7 +710,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.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);
                    }
@@ -679,7 +718,7 @@
                else
                {
                    //限制
                    if (stockInfo.MaterielThickness >= 800 && stockInfo.MaterielThickness <= 1500 && stockInfo.MaterielWide >= 700 && stockInfo.MaterielWide <= 2500)
                    if ((stockInfo.MaterielThickness >= 800 || (stockInfo.CheckThickness >= 800 && stockInfo.StockStatus==StockStatusEmun.老厂退库.ObjToInt())) && stockInfo.MaterielThickness <= 1500 && stockInfo.MaterielWide >= 700 && stockInfo.MaterielWide <= 2500)
                    {
                        bool LayerLimit = false;
                        if (stockInfo.MaterielThickness>1300)
@@ -687,10 +726,10 @@
                            LayerLimit = true;
                        }
                        //获取分配
                        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();
                        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.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);
@@ -778,7 +817,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);
                        _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(proStockInfo, 0, proStockInfo.proStockInfoDetails.Sum(x => x.StockQty), StockChangeTypeEnum.Inbound);
                    }
                    else
                    {
@@ -816,8 +855,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()
@@ -828,16 +870,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();
                    _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, stockInfo.StockLength, 0, StockChangeTypeEnum.Inbound,taskNum:task.TaskNum);
                }
                return content.OK();
                content.OK();
            }
            catch (Exception ex)
            {
@@ -1137,97 +1173,208 @@
            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)
                InOrderTypeEnum inOrderTypeEnum = (InOrderTypeEnum)orderType;
                if (inOrderTypeEnum == InOrderTypeEnum.InventoryIn)
                {
                    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_InboundOrder inboundOrder = BaseDal.Db.Queryable<Dt_InboundOrder>().Includes(x => x.Details).Where(x => x.Details.Any(v => v.BarCode == bindCode)).First();
                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);
                    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");
                }
                _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("发送成功");
            }