| | |
| | | Dt_Task task = Repository.QueryFirst(x => x.PalletCode == palletCode); |
| | | if (task != null) |
| | | { |
| | | //PushTasksToWCS(new List<Dt_Task> { task }); |
| | | return WebResponseContent.Instance.Error($"该托盘{palletCode}已生成任务"); |
| | | } |
| | | Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == palletCode).Includes(x => x.Details).First(); |
| | |
| | | if (stockInfo == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"未找到组盘信息"); |
| | | } |
| | | if (stockInfo.StockStatus == StockStatusEmun.合托出库完成.ObjToInt()) |
| | | { |
| | | |
| | | } |
| | | ///判断是否存在回库单,进行回原库位逻辑 |
| | | string returnOrderNo = stockInfo.Details?.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.OrderNo; |
| | |
| | | |
| | | _unitOfWorkManage.CommitTran(); |
| | | WMSTaskDTO wMSTaskDTO = _mapper.Map<WMSTaskDTO>(newTask); |
| | | if (warehouse.WarehouseCode.Contains("CP")) |
| | | { |
| | | PushTasksWCS(new List<Dt_Task> { newTask }); |
| | | } |
| | | else |
| | | { |
| | | PushTasksToWCS(new List<Dt_Task> { newTask }); |
| | | } |
| | | return WebResponseContent.Instance.OK(data: wMSTaskDTO); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | PushTasksToWCS(new List<Dt_Task> { newTask }); |
| | | public WebResponseContent CPDeviceRequestInboundTaskSimple(string stationCode, string palletCode, int heightType, string courceAddress) |
| | | { |
| | | try |
| | | { |
| | | Dt_Task task = Repository.QueryFirst(x => x.PalletCode == palletCode); |
| | | if (task != null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"该托盘{palletCode}已生成任务"); |
| | | } |
| | | Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == palletCode).Includes(x => x.Details).First(); |
| | | |
| | | if (stockInfo == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"未找到组盘信息"); |
| | | } |
| | | |
| | | Dt_RoadwayInfo returnRoadwayInfo = new Dt_RoadwayInfo(); |
| | | if (stockInfo.StockStatus == StockStatusEmun.合托出库完成.ObjToInt()) |
| | | { |
| | | Dt_LocationInfo locationInfo1 = _locationInfoService.Repository.QueryFirst(x => x.LocationCode == stockInfo.LocationCode); |
| | | if (locationInfo1 == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"回库单中该库位{stockInfo.LocationCode}未找到"); |
| | | } |
| | | returnRoadwayInfo = _basicRepository.RoadwayInfoRepository.QueryFirst(x => x.RoadwayNo == locationInfo1.RoadwayNo && x.InStationCode == (returnRoadwayInfo.InStationCode != null ? returnRoadwayInfo.InStationCode : stationCode)); |
| | | } |
| | | ///判断是否存在回库单,进行回原库位逻辑 |
| | | string returnOrderNo = stockInfo.Details?.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.OrderNo; |
| | | Dt_ReturnOrder returnOrder = _returnOrderRepository.QueryFirst(x => (x.OrderNo == returnOrderNo || x.LPNNo == palletCode) && x.OrderStatus == InOrderStatusEnum.未开始.ObjToInt()); |
| | | 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 && x.InStationCode == (returnRoadwayInfo.InStationCode != null ? returnRoadwayInfo.InStationCode : stationCode)); |
| | | } |
| | | |
| | | 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 == (returnRoadwayInfo.InStationCode != null ? returnRoadwayInfo.InStationCode : stationCode)); |
| | | if (roadwayInfo == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"未找到该入库站台地址"); |
| | | } |
| | | |
| | | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == roadwayInfo.RoadwayNo); |
| | | if (warehouse == null) |
| | | { |
| | | return WebResponseContent.Instance.Error("未找到该仓库"); |
| | | } |
| | | |
| | | Dt_LocationInfo? locationInfo = new Dt_LocationInfo(); |
| | | if (returnOrder != null && !string.IsNullOrEmpty(returnOrder.LocationCode)) |
| | | { |
| | | 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 = courceAddress, |
| | | Grade = 0, |
| | | NextAddress = returnRoadwayInfo.InStationCode != null ? returnRoadwayInfo.InStationCode : stationCode, |
| | | PalletCode = palletCode, |
| | | OrderNo = details.OrderNo, |
| | | Roadway = roadwayInfo.RoadwayNo, |
| | | SourceAddress = courceAddress, |
| | | TargetAddress = locationInfo.LocationCode, |
| | | TaskType = TaskTypeEnum.Inbound.ObjToInt(), |
| | | TaskStatus = TaskStatusEnum.New.ObjToInt(), |
| | | WarehouseId = stockInfo.WarehouseId, |
| | | PalletType = GetPalletType(warehouse, palletCode),//GetPalletType(warehouse, palletCode) |
| | | Creater = "WCS", |
| | | CreateDate = DateTime.Now |
| | | }; |
| | | string MaterielCode = stockInfo.Details?.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.MaterielCode; |
| | | float Quantity = (float)stockInfo.Details?.Where(x => x.StockId == stockInfo.Id).Sum(x => x.StockQuantity); |
| | | if (MaterielCode != null && Quantity != null) |
| | | { |
| | | 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()) |
| | | { |
| | | newTask.TaskType = TaskTypeEnum.InSyncretism.ObjToInt(); |
| | | } |
| | | //if (stockInfo.StockStatus == StockStatusEmun.手动组盘暂存.ObjToInt()) |
| | | //{ |
| | | // stockInfo.StockStatus = StockStatusEmun.手动组盘入库确认.ObjToInt(); |
| | | //} |
| | | //else if (stockInfo.StockStatus == StockStatusEmun.MES退库.ObjToInt()) |
| | | //{ |
| | | // newTask.TaskType = TaskTypeEnum.MesMatReturn.ObjToInt(); |
| | | //} |
| | | //else if (stockInfo.StockStatus == StockStatusEmun.MES空托退库.ObjToInt()) |
| | | //{ |
| | | // Dt_PalletTypeInfo palletTypeInfo = _palletTypeInfoRepository.QueryFirst(x => x.WarehouseId == stockInfo.WarehouseId && x.PalletType == stockInfo.PalletType); |
| | | // //todo 小托盘暂时未启用 |
| | | // if (palletTypeInfo.LocaitonCount == 2) |
| | | // { |
| | | // newTask.TaskType = TaskTypeEnum.MesPalletLargeReturn.ObjToInt(); |
| | | // } |
| | | // else |
| | | // { |
| | | // newTask.TaskType = TaskTypeEnum.MesPalletSmallReturn.ObjToInt(); |
| | | // } |
| | | //} |
| | | //else |
| | | //{ |
| | | else |
| | | { |
| | | stockInfo.StockStatus = StockStatusEmun.入库确认.ObjToInt(); |
| | | } |
| | | locationInfo.LocationStatus = LocationStatusEnum.Lock.ObjToInt(); |
| | | //} |
| | | |
| | | _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); |
| | | |
| | | PushTasksWCS(new List<Dt_Task> { newTask }); |
| | | |
| | | return WebResponseContent.Instance.OK(data: wMSTaskDTO); |
| | | } |
| | | catch (Exception ex) |
| | |
| | | { |
| | | return WebResponseContent.Instance.Error($"未找到组盘信息"); |
| | | } |
| | | return WebResponseContent.Instance.OK(data:stockInfo.WarehouseId); |
| | | return WebResponseContent.Instance.OK(data: stockInfo.WarehouseId); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | // } |
| | | // return palletTypeInfo.PalletType; |
| | | //} |
| | | return -1; |
| | | return 3; |
| | | } |
| | | |
| | | |