heshaofeng
2025-12-29 266e4bf654c55ce2f7e9271048e4625f1b8b49f6
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Inbound.cs
@@ -29,11 +29,23 @@
        {
            try
            {
                Dt_Task dbtask = Repository.QueryFirst(x => x.PalletCode == palletCode);
                Dt_Task dbtask = Repository.Db.Queryable<Dt_Task>().Where(x => x.PalletCode == palletCode).OrderByDescending(x=>x.CreateDate).First();
                if (dbtask != null)
                {
                    return WebResponseContent.Instance.Error($"该托盘已生成任务");
                }
                    _logger.LogInformation($"任务类型{dbtask.TaskType.ToString()} ,{dbtask.TaskNum}  ");
                    if (dbtask.TaskType == TaskTypeEnum.Outbound.ObjToInt())
                    {
                        return WebResponseContent.Instance.Error($"出库待分拣任务");
                    }
                    else if (dbtask.TaskType == TaskTypeEnum.OutAllocate.ObjToInt())
                    {
                        return WebResponseContent.Instance.Error($"出库待分拣任务");
                    }
                    else
                    {
                        return WebResponseContent.Instance.Error($"该托盘已生成任务");
                    }
                }
                Dt_StockInfo stockInfo = _stockRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == palletCode).Includes(x => x.Details).First();
                if (stockInfo == null)
@@ -41,7 +53,7 @@
                    return WebResponseContent.Instance.Error($"未找到组盘信息");
                }
                if (stockInfo.StockStatus != StockStatusEmun.组盘暂存.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.手动组盘暂存.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.拣选完成.ObjToInt())
                if (stockInfo.StockStatus != StockStatusEmun.组盘暂存.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.手动组盘暂存.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.拣选完成.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.智仓入智仓组盘暂存.ObjToInt())
                {
                    return WebResponseContent.Instance.Error($"该托盘状态不正确,不可申请入库");
                }
@@ -58,25 +70,40 @@
                var newTask = new Dt_Task()
                {
                    CurrentAddress = stationCode,
                {
                    CurrentAddress = stations.GetValueOrDefault(stationCode) ?? "",
                    Grade = 0,
                    NextAddress = stations.GetValueOrDefault(stationCode) ?? "",
                    NextAddress = locationInfo.LocationCode,
                    PalletCode = palletCode,
                    Roadway = locationInfo.RoadwayNo,
                    SourceAddress = stationCode,
                    SourceAddress = stations.GetValueOrDefault(stationCode) ?? "",
                    TargetAddress = locationInfo.LocationCode,
                    TaskType = TaskTypeEnum.Inbound.ObjToInt(),
                    TaskStatus = TaskStatusEnum.New.ObjToInt(),
                    WarehouseId = stockInfo.WarehouseId,
                    PalletType = stockInfo.PalletType,
                    OrderNo= stockInfo.Details.FirstOrDefault()?.OrderNo
                };
                //空箱
                if (stockInfo.PalletType == PalletTypeEnum.Empty.ObjToInt())
                {
                    _unitOfWorkManage.BeginTran();
                    newTask.TaskType = TaskTypeEnum.InEmpty.ObjToInt();
                    int taskId = BaseDal.AddData(newTask);
                    newTask.TaskId = taskId;
                    locationInfo.LocationStatus = LocationStatusEnum.Lock.ObjToInt();
                    _locationInfoService.UpdateData(locationInfo);
                    stockInfo.StockStatus = StockStatusEmun.入库确认.ObjToInt();
                    _stockRepository.UpdateData(stockInfo);
                    _unitOfWorkManage.CommitTran();
                }
                //智仓入智仓
                if (stockInfo.StockStatus == StockStatusEmun.智仓入智仓组盘暂存.ObjToInt())
                {
                    _unitOfWorkManage.BeginTran();
                    newTask.TaskType = TaskTypeEnum.AllocateInWarehouse.ObjToInt();
                    int taskId = BaseDal.AddData(newTask);
                    newTask.TaskId = taskId;
@@ -114,33 +141,33 @@
                    _stockRepository.UpdateData(stockInfo);
                    _unitOfWorkManage.CommitTran();
                }
                TaskModel esstask = new TaskModel()
                {
                    taskType = "putaway",
                    taskGroupCode = "",
                    groupPriority = 0,
                    tasks = new List<TasksType>
                    {
                            new()
                            {
                                taskCode=newTask.TaskNum.ToString(),
                                taskPriority=0,
                                taskDescribe=new TaskDescribeType{
                                containerCode=palletCode,
                                containerType= "CT_KUBOT_STANDARD",
                                fromLocationCode=stations.GetValueOrDefault(stationCode)??"",
                                toStationCode="",
                                toLocationCode=locationInfo.LocationCode,
                                deadline=0,storageTag=""
                                }
                            }
                    }
                };
                //TaskModel esstask = new TaskModel()
                //{
                //    taskType = "putaway",
                //    taskGroupCode = "",
                //    groupPriority = 0,
                //    tasks = new List<TasksType>
                //    {
                //            new()
                //            {
                //                taskCode=newTask.TaskNum.ToString(),
                //                taskPriority=0,
                //                taskDescribe=new TaskDescribeType{
                //                containerCode=palletCode,
                //                containerType= "CT_KUBOT_STANDARD",
                //                fromLocationCode=stations.GetValueOrDefault(stationCode)??"",
                //                toStationCode="",
                //                toLocationCode=locationInfo.LocationCode,
                //                deadline=0,storageTag=""
                //                }
                //            }
                //    }
                //};
 
                var result = await _eSSApiService.CreateTaskAsync(esstask);
                //var result = await _eSSApiService.CreateTaskAsync(esstask);
                _logger.LogInformation("创建任务返回:  " + result);
                if (result)
                //_logger.LogInformation("创建任务返回:  " + result);
                //if (result)
                {
                    try
                    {
@@ -156,10 +183,10 @@
                    }
                    return WebResponseContent.Instance.OK();
                }
                else
                {
                    return WebResponseContent.Instance.Error("下发机器人任务失败!");
                }
                //else
                //{
                //    return WebResponseContent.Instance.Error("下发机器人任务失败!");
                //}
            }
            catch (Exception ex)
            {