647556386
2025-10-18 d01658c63cd541fe4ea5cec5c4bd7f23b9408cdb
WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Inbound.cs
@@ -18,6 +18,8 @@
using WIDESEA_Core.LogHelper;
using WIDESEA_DTO.Task;
using WIDESEA_Core.TaskEnum;
using WIDESEA_Model.Models.Inbound;
using WIDESEA_Common.OrderEnum;
namespace WIDESEA_TaskInfoService
{
@@ -40,42 +42,69 @@
                    PushTasksToWCS(new List<Dt_Task> { task });
                    return WebResponseContent.Instance.OK($"该托盘已生成任务", _mapper.Map<WMSTaskDTO>(task));
                }
                if (Repository.QueryFirst(x => x.SourceAddress == stationCode && x.TaskStatus == TaskStatusEnum.New.ObjToInt()) != null)
                {
                    return WebResponseContent.Instance.Error($"该站点已有未执行的任务");
                }
                Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == palletCode).Includes(x => x.Details).First();
                var details = stockInfo.Details.FirstOrDefault();
                if (stockInfo == null)
                {
                    return WebResponseContent.Instance.Error($"未找到组盘信息");
                }
                ///判断是否存在回库单,进行回原库位逻辑
                string returnOrderNo = stockInfo.Details?.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.OrderNo;
                Dt_ReturnOrder returnOrder = _returnOrderRepository.QueryFirst(x => x.OrderNo == returnOrderNo && x.OrderStatus == InOrderStatusEnum.未开始.ObjToInt());
                Dt_RoadwayInfo returnRoadwayInfo = new Dt_RoadwayInfo();
                if(returnOrder != null && !string.IsNullOrEmpty(returnOrder.LocationCode))
                {
                    Dt_LocationInfo locationInfo1 = _locationInfoService.Repository.QueryFirst(x => x.LocationCode == returnOrder.LocationCode);
                    if(locationInfo1 == null)
                    {
                        return WebResponseContent.Instance.Error($"回库单中该库位{returnOrder.LocationCode}未找到");
                    }
                    returnRoadwayInfo = _basicRepository.RoadwayInfoRepository.QueryFirst(x => x.RoadwayNo == locationInfo1.RoadwayNo);
                }
                if (Repository.QueryFirst(x => x.SourceAddress == (returnRoadwayInfo.InStationCode != null ? returnRoadwayInfo.InStationCode:stationCode) && x.TaskStatus == TaskStatusEnum.New.ObjToInt()) != null)
                {
                    return WebResponseContent.Instance.Error($"该站点已有未执行的任务");
                }
                var details = stockInfo.Details.FirstOrDefault();
                if (!string.IsNullOrEmpty(stockInfo.LocationCode))
                {
                    return WebResponseContent.Instance.Error($"该托盘已绑定货位");
                }
                Dt_RoadwayInfo roadwayInfo = _basicRepository.RoadwayInfoRepository.QueryFirst(x => x.InStationCode == stationCode);
                Dt_RoadwayInfo roadwayInfo = _basicRepository.RoadwayInfoRepository.QueryFirst(x => x.InStationCode == (returnRoadwayInfo.InStationCode != null ? returnRoadwayInfo.InStationCode : stationCode));
                if (roadwayInfo == null)
                {
                    return WebResponseContent.Instance.Error($"未找到刚入库站台地址");
                    return WebResponseContent.Instance.Error($"未找到该入库站台地址");
                }
                Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == roadwayInfo.RoadwayNo);
                if (warehouse == null)
                {
                    return WebResponseContent.Instance.Error("未找到改仓库");
                    return WebResponseContent.Instance.Error("未找到该仓库");
                }
                Dt_LocationInfo? locationInfo = _basicService.LocationInfoService.AssignLocation(roadwayInfo.RoadwayNo, stockInfo.PalletType, warehouse.WarehouseId, "", heightType);//, stockInfo.WarehouseId
                if (locationInfo == null)
                Dt_LocationInfo? locationInfo = new Dt_LocationInfo();
                if (returnOrder != null && !string.IsNullOrEmpty(returnOrder.LocationCode))
                {
                    return WebResponseContent.Instance.Error($"货位分配失败,未找到可分配货位");
                    locationInfo = _locationInfoService.Repository.QueryFirst(x => x.LocationCode == returnOrder.LocationCode);
                    if (locationInfo.LocationStatus != LocationStatusEnum.Lock.ObjToInt() || locationInfo.EnableStatus == EnableStatusEnum.Disable.ObjToInt() || locationInfo.EnableStatus == EnableStatusEnum.OnlyOut.ObjToInt())
                    {
                        return WebResponseContent.Instance.Error($"该回库单货位{locationInfo.LocationCode}非锁定状态或货位启用状态不正确,请检查");
                    }
                }
                else
                {
                    locationInfo = _basicService.LocationInfoService.AssignLocation(roadwayInfo.RoadwayNo, stockInfo.PalletType, warehouse.WarehouseId, "", heightType);//, stockInfo.WarehouseId
                    if (locationInfo == null)
                    {
                        return WebResponseContent.Instance.Error($"货位分配失败,未找到可分配货位");
                    }
                }
                Dt_Task newTask = new Dt_Task()
                {
                    CurrentAddress = "",
                    Grade = 0,
                    NextAddress = stationCode,
                    NextAddress = returnRoadwayInfo.InStationCode != null ? returnRoadwayInfo.InStationCode : stationCode,
                    PalletCode = palletCode,
                    OrderNo = details.OrderNo,
                    Roadway = roadwayInfo.RoadwayNo,
@@ -95,7 +124,18 @@
                    newTask.MaterielCode = MaterielCode;
                    newTask.Quantity = (float)Quantity;
                }
                if(stockInfo.StockStatus == StockStatusEmun.余料退库.ObjToInt())
                {
                    newTask.TaskType = TaskTypeEnum.SurplusReturn.ObjToInt();
                }
                if(stockInfo.StockStatus == StockStatusEmun.反拣入库.ObjToInt())
                {
                    newTask.TaskType = TaskTypeEnum.ReverseIn.ObjToInt();
                }
                if(stockInfo.StockStatus == StockStatusEmun.盘点库存完成.ObjToInt())
                {
                    newTask.TaskType = TaskTypeEnum.InInventory.ObjToInt();
                }
                //if (stockInfo.StockStatus == StockStatusEmun.手动组盘暂存.ObjToInt())
                //{
                //    stockInfo.StockStatus = StockStatusEmun.手动组盘入库确认.ObjToInt();
@@ -126,8 +166,14 @@
                _unitOfWorkManage.BeginTran();
                int taskId = BaseDal.AddData(newTask);
                newTask.TaskId = taskId;
                if (returnOrder != null)
                {
                    returnOrder.OrderStatus = InOrderStatusEnum.入库中.ObjToInt();
                    _returnOrderRepository.UpdateData(returnOrder);
                }
                _stockRepository.StockInfoRepository.UpdateData(stockInfo);
                _locationInfoService.UpdateData(locationInfo);
                _unitOfWorkManage.CommitTran();
                WMSTaskDTO wMSTaskDTO = _mapper.Map<WMSTaskDTO>(newTask);
@@ -235,7 +281,7 @@
                    return WebResponseContent.Instance.Error(checkResult.Item2);
                // 分配库位并更新数据
                Dt_LocationInfo? locationInfo = _basicService.LocationInfoService.AssignLocation(roadwayNo, dt_Stock.PalletType);//, dt_Stock.WarehouseId
                Dt_LocationInfo? locationInfo = _basicService.LocationInfoService.AssignLocation(roadwayNo, dt_Stock.PalletType, dt_Stock.WarehouseId);//
                //Dt_LocationInfo? locationInfo = _basicService.LocationInfoService.AssignLocation(stationCode, TaskTypeEnum.Inbound.ObjToInt());
                if (locationInfo == null)
                {