| | |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Core.Enums; |
| | | using WIDESEA_Core.Helper; |
| | | using WIDESEA_DTO.Stock; |
| | | using WIDESEA_Model.Models; |
| | | |
| | | namespace WIDESEA_TaskInfoService |
| | |
| | | { |
| | | throw new Exception("所选出库单明细存在出库中或已完成"); |
| | | } |
| | | if (outboundOrderDetails.FirstOrDefault()?.LPNNo == null) |
| | | { |
| | | try |
| | | { |
| | | List<StockSelectViewDTO> stockSelectViews = new List<StockSelectViewDTO>(); |
| | | List<Dt_StockInfo> stockInfos = new List<Dt_StockInfo>(); |
| | | foreach (int key in keys) |
| | | { |
| | | |
| | | (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_NewOutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) result = NEWOutboundTaskDataHandle(keys); |
| | | if (result.Item2 != null && result.Item2.Count > 0) |
| | | { |
| | | stockInfos.AddRange(result.Item2); |
| | | } |
| | | if (result.Item3 != null && result.Item3.Count > 0) |
| | | { |
| | | outboundOrderDetails.AddRange(result.Item3); |
| | | } |
| | | if (result.Item4 != null && result.Item4.Count > 0) |
| | | { |
| | | outStockLockInfos.AddRange(result.Item4); |
| | | } |
| | | if (result.Item5 != null && result.Item5.Count > 0) |
| | | { |
| | | locationInfos.AddRange(result.Item5); |
| | | } |
| | | if (result.Item1 != null && result.Item1.Count > 0) |
| | | { |
| | | tasks.AddRange(result.Item1); |
| | | } |
| | | if (locationInfos.First().RoadwayNo.Contains("DW") || locationInfos.First().RoadwayNo.Contains("YS")) |
| | | { |
| | | break; |
| | | } |
| | | |
| | | } |
| | | |
| | | WebResponseContent content = NEWGenerateOutboundTaskDataUpdate(tasks, stockInfos, outboundOrderDetails, outStockLockInfos, locationInfos); |
| | | return content; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | var lpngroup = outboundOrderDetails.GroupBy(x => x.LPNNo); |
| | | |
| | | |
| | |
| | | _basicService.LocationInfoService.Repository.UpdateLocationStatus(locationInfos, LocationStatusEnum.Lock); |
| | | |
| | | _unitOfWorkManage.CommitTran(); |
| | | |
| | | } |
| | | //将任务推送到WCS |
| | | return PushTasksWCS(tasks); |
| | | } |
| | |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | |
| | | |
| | | public (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_NewOutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) NEWOutboundTaskDataHandle(int[] keys) |
| | | { |
| | | List<Dt_Task> tasks = new List<Dt_Task>(); |
| | | List<Dt_NewOutboundOrderDetail> outboundOrderDetails = _outboundService.NewOutboundOrderDetailService.Repository.QueryData(x => keys.Contains(x.Id)); |
| | | |
| | | if (outboundOrderDetails == null || outboundOrderDetails.Count == 0) |
| | | { |
| | | throw new Exception("未找到出库单明细信息"); |
| | | } |
| | | if (outboundOrderDetails.FirstOrDefault(x => x.OrderDetailStatus > OrderDetailStatusEnum.New.ObjToInt() && x.OrderDetailStatus != OrderDetailStatusEnum.AssignOverPartial.ObjToInt()) != null) |
| | | { |
| | | throw new Exception("所选出库单明细存在出库中或已完成"); |
| | | } |
| | | List<Dt_StockInfo>? stockInfos = null; |
| | | List<Dt_NewOutboundOrderDetail>? orderDetails = null; |
| | | List<Dt_OutStockLockInfo>? outStockLockInfos = null; |
| | | List<Dt_LocationInfo>? locationInfos = null; |
| | | //if (outboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.New.ObjToInt()) |
| | | { |
| | | Dt_OutboundOrder dt_OutboundOrder = _outboundService.OutboundOrderService.Repository.QueryData(x => x.Id == outboundOrderDetails.First().OrderId).First(); |
| | | (List<Dt_StockInfo>, List<Dt_NewOutboundOrderDetail>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = new(); |
| | | |
| | | result = _outboundService.NewOutboundOrderDetailService.CPAssignStockOutbound(outboundOrderDetails); |
| | | |
| | | if (result.Item1 != null && result.Item1.Count > 0) |
| | | { |
| | | Dt_OutboundOrder outboundOrder = _outboundService.OutboundOrderService.Repository.QueryFirst(x => x.Id == outboundOrderDetails.FirstOrDefault().OrderId); |
| | | TaskTypeEnum typeEnum = outboundOrder.OrderType switch |
| | | { |
| | | (int)OrderTypeEnum.生产出库单 => TaskTypeEnum.Outbound, |
| | | (int)OrderTypeEnum.调拨出库单 => TaskTypeEnum.OutAllocate, |
| | | (int)OrderTypeEnum.反拣出库单 => TaskTypeEnum.ReverseOut, |
| | | _ => new TaskTypeEnum() |
| | | }; |
| | | tasks = GetTasks(result.Item1, typeEnum); |
| | | tasks.ForEach(x => |
| | | { |
| | | x.OrderNo = outboundOrder.OrderNo; |
| | | }); |
| | | if (dt_OutboundOrder.OutWareHouse.Contains("DW") || dt_OutboundOrder.OutWareHouse.Contains("YS")) |
| | | { |
| | | result.Item2.ForEach(x => |
| | | { |
| | | if (x.LockQuantity == x.OrderQuantity) |
| | | { |
| | | x.OrderDetailStatus = OrderDetailStatusEnum.Outbound.ObjToInt(); |
| | | } |
| | | }); |
| | | } |
| | | else |
| | | { |
| | | result.Item2.ForEach(x => |
| | | { |
| | | x.OrderDetailStatus = OrderDetailStatusEnum.Outbound.ObjToInt(); |
| | | }); |
| | | } |
| | | |
| | | result.Item3.ForEach(x => |
| | | { |
| | | |
| | | x.Status = OutStockStatus.出库中.ObjToInt(); |
| | | }); |
| | | |
| | | stockInfos = result.Item1; |
| | | orderDetails = result.Item2; |
| | | outStockLockInfos = result.Item3; |
| | | locationInfos = result.Item4; |
| | | } |
| | | else |
| | | { |
| | | throw new Exception("无库存"); |
| | | } |
| | | } |
| | | //else |
| | | //{ |
| | | // List<Dt_OutStockLockInfo> stockLockInfos = _outboundService.OutboundStockLockInfoService.GetByOrderDetailId(outboundOrderDetail.OrderId, OutLockStockStatusEnum.已分配); |
| | | // if (stockLockInfos != null && stockLockInfos.Count > 0) |
| | | // { |
| | | // List<Dt_StockInfo> stocks = _stockService.StockInfoService.Repository.GetStockInfosByPalletCodes(stockLockInfos.Select(x => x.PalletCode).Distinct().ToList()); |
| | | // tasks = GetTasks(stocks); |
| | | // } |
| | | //} |
| | | |
| | | return (tasks, stockInfos, orderDetails, outStockLockInfos, locationInfos); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 生成出库任务后数据更新到数据库 |
| | | /// </summary> |
| | | /// <param name="tasks"></param> |
| | | /// <param name="stockInfos"></param> |
| | | /// <param name="outboundOrderDetails"></param> |
| | | /// <param name="outStockLockInfos"></param> |
| | | /// <param name="locationInfos"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent NEWGenerateOutboundTaskDataUpdate(List<Dt_Task> tasks, List<Dt_StockInfo>? stockInfos = null, List<Dt_NewOutboundOrderDetail>? outboundOrderDetails = null, List<Dt_OutStockLockInfo>? outStockLockInfos = null, List<Dt_LocationInfo>? locationInfos = null) |
| | | { |
| | | try |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | _unitOfWorkManage.BeginTran(); |
| | | |
| | | BaseDal.AddData(tasks); |
| | | //判断移库 |
| | | //content = RelocationTasks(tasks.OrderBy(x => x.Depth).ToList()); |
| | | //if (content.Status) |
| | | //{ |
| | | // _unitOfWorkManage.CommitTran(); |
| | | //} |
| | | //else |
| | | //{ |
| | | // _unitOfWorkManage.RollbackTran(); |
| | | // return content; |
| | | //} |
| | | //BaseDal.AddData(tasks); |
| | | |
| | | if (stockInfos != null && outboundOrderDetails != null && outStockLockInfos != null && locationInfos != null) |
| | | { |
| | | Dt_NewOutboundOrder outboundOrder = _outboundService.NewOutboundOrderService.Repository.QueryFirst(x => x.Id == outboundOrderDetails.FirstOrDefault().OrderId); |
| | | outboundOrder.OrderStatus = OutboundStatusEnum.出库中.ObjToInt(); |
| | | _outboundService.NewOutboundOrderService.Repository.UpdateData(outboundOrder); |
| | | content = _outboundService.NewOutboundOrderDetailService.CPLockOutboundStockDataUpdate(stockInfos, outboundOrderDetails, outStockLockInfos, locationInfos, tasks: tasks); |
| | | |
| | | if (!content.Status) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return content; |
| | | } |
| | | } |
| | | else if (outboundOrderDetails != null && outboundOrderDetails.Count > 0) |
| | | { |
| | | outboundOrderDetails.ForEach(x => |
| | | { |
| | | x.OrderDetailStatus = OrderDetailStatusEnum.Outbound.ObjToInt(); |
| | | }); |
| | | |
| | | _outboundService.NewOutboundOrderDetailService.Repository.UpdateData(outboundOrderDetails); |
| | | } |
| | | _unitOfWorkManage.CommitTran(); |
| | | //将任务推送到WCS |
| | | |
| | | if (tasks.FirstOrDefault().Roadway.Contains("SC01_BC")) |
| | | { |
| | | PushTasksToWCS(tasks); |
| | | } |
| | | else |
| | | { |
| | | PushTasksWCS(tasks); |
| | | } |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | |
| | | } |
| | | |
| | | public List<Dt_Task> GetTask(List<Dt_StockInfo> stockInfos, TaskTypeEnum taskType, string orderNo) |
| | | { |
| | | List<Dt_Task> tasks = new List<Dt_Task>(); |