| | |
| | | private readonly IStockInfoDetailRepository _stockInfoDetailRepository; |
| | | public ITaskRepository Repository => BaseDal; |
| | | |
| | | public TaskService(ITaskRepository BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IMaterielInfoService materielInfoService, IInboundOrderDetail_HtyService inboundOrderDetail_HtyService, IOutboundOrder_HtyService outboundOrder_HtyService, IOutboundOrderDetail_HtyService outboundOrderDetail_HtyService, IInboundOrder_HtyService inboundOrder_HtyService, IStockRepository stockRepository, IInboundOrderDetailService inboundOrderDetailService, IBasicService basicService, IOutboundService outboundService, IInboundService inboundService, IRecordService recordService, IStockService stockService, ITask_HtyService taskHtyService, ILocationInfoService locationInfoService, IOutboundOrderDetailRepository outboundOrderDetailRepository, IBasicRepository basicRepository, IStockInfoDetailRepository stockInfoDetailRepository) : base(BaseDal) |
| | | public TaskService(ITaskRepository BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IMaterielInfoService materielInfoService, IInboundOrderDetail_HtyService inboundOrderDetail_HtyService, IOutboundOrder_HtyService outboundOrder_HtyService, IOutboundOrderDetail_HtyService outboundOrderDetail_HtyService, IInboundOrder_HtyService inboundOrder_HtyService, IStockRepository stockRepository, IInboundOrderDetailService inboundOrderDetailService, IBasicService basicService, IOutboundService outboundService, IInboundService inboundService, IRecordService recordService, IStockService stockService, ITask_HtyService taskHtyService, ILocationInfoService locationInfoService, IOutboundOrderDetailRepository outboundOrderDetailRepository, IBasicRepository basicRepository, IStockInfoDetailRepository stockInfoDetailRepository, IPalletTypeInfoRepository palletTypeInfoRepository) : base(BaseDal) |
| | | { |
| | | _mapper = mapper; |
| | | _stockRepository = stockRepository; |
| | |
| | | _outboundOrderDetailRepository = outboundOrderDetailRepository; |
| | | _basicRepository = basicRepository; |
| | | _stockInfoDetailRepository = stockInfoDetailRepository; |
| | | _palletTypeInfoRepository = palletTypeInfoRepository; |
| | | } |
| | | |
| | | public string ReceiveWMSTaskin = WIDESEA_Core.Helper.AppSettings.Configuration["ReceiveWMSTaskin"]; |
| | |
| | | UpdateInboundOrder(inboundOrder, inboundOrderDetail); |
| | | |
| | | // 单据数量全部上架完成,处理WMS回传 |
| | | if (inboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()) |
| | | { |
| | | var stockInfoDetail = stockInfo.Details.FirstOrDefault(); |
| | | SendInboundInfoToWMS(task, inboundOrder, stockInfo); |
| | | } |
| | | //if (inboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()) |
| | | //{ |
| | | // var stockInfoDetail = stockInfo.Details.FirstOrDefault(); |
| | | // SendInboundInfoToWMS(task, inboundOrder, stockInfo); |
| | | //} |
| | | |
| | | _unitOfWorkManage.CommitTran(); |
| | | return WebResponseContent.Instance.OK(); |
| | |
| | | private WebResponseContent ProcessAllocateInbound(Dt_Task task, Dt_StockInfo stockInfo, Dt_LocationInfo locationInfo, |
| | | int lastStatus, Dt_InboundOrder inboundOrder, Dt_InboundOrderDetail inboundOrderDetail) |
| | | { |
| | | // 如果是最后一条明细 |
| | | if (inboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()) |
| | | //// 如果是最后一条明细 |
| | | //if (inboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()) |
| | | //{ |
| | | // try |
| | | // { |
| | | // _unitOfWorkManage.BeginTran(); |
| | | |
| | | // // 处理调拨入库单 |
| | | // ProcessAllocateInboundOrder(inboundOrder, inboundOrderDetail); |
| | | |
| | | // // 获取相关库存信息 |
| | | // var relatedStockInfo = _stockService.StockInfoService.Repository |
| | | // .QueryData(x => x.BatchNo == inboundOrderDetail.BatchNo); |
| | | |
| | | // // 发送调拨信息到WMS |
| | | // SendAllocateInfoToWMS(task, inboundOrder, relatedStockInfo); |
| | | |
| | | // _unitOfWorkManage.CommitTran(); |
| | | // } |
| | | // catch |
| | | // { |
| | | // _unitOfWorkManage.RollbackTran(); |
| | | // throw; |
| | | // } |
| | | //} |
| | | |
| | | //// 添加历史记录 |
| | | //AddInboundOrderDetailHistory(inboundOrderDetail); |
| | | |
| | | //return WebResponseContent.Instance.OK(); |
| | | // 更新入库单明细状态 |
| | | UpdateInboundOrderDetails(stockInfo, inboundOrder, ref inboundOrderDetail); |
| | | |
| | | // 更新库存明细状态 |
| | | stockInfo.Details.ForEach(x => x.Status = StockStatusEmun.入库完成.ObjToInt()); |
| | | |
| | | try |
| | | { |
| | | try |
| | | { |
| | | _unitOfWorkManage.BeginTran(); |
| | | _unitOfWorkManage.BeginTran(); |
| | | |
| | | // 处理调拨入库单 |
| | | //ProcessAllocateInboundOrder(inboundOrder, inboundOrderDetail); |
| | | // 更新任务状态 |
| | | UpdateTaskStatus(task); |
| | | |
| | | // 获取相关库存信息 |
| | | var relatedStockInfo = _stockService.StockInfoService.Repository |
| | | .QueryData(x => x.BatchNo == inboundOrderDetail.BatchNo); |
| | | // 更新货位状态 |
| | | UpdateLocationStatus(locationInfo, lastStatus); |
| | | |
| | | // 发送调拨信息到WMS |
| | | SendAllocateInfoToWMS(task, inboundOrder, relatedStockInfo); |
| | | // 更新库存信息 |
| | | UpdateStockInfo(stockInfo); |
| | | |
| | | _unitOfWorkManage.CommitTran(); |
| | | } |
| | | catch |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | throw; |
| | | } |
| | | // 添加记录 |
| | | AddRecords(task, stockInfo, locationInfo, lastStatus); |
| | | |
| | | // 更新入库单 |
| | | UpdateInboundOrder(inboundOrder, inboundOrderDetail); |
| | | |
| | | // 单据数量全部上架完成,处理WMS回传 |
| | | //if (inboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()) |
| | | //{ |
| | | // var stockInfoDetail = stockInfo.Details.FirstOrDefault(); |
| | | // SendInboundInfoToWMS(task, inboundOrder, stockInfo); |
| | | //} |
| | | |
| | | _unitOfWorkManage.CommitTran(); |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | |
| | | // 添加历史记录 |
| | | AddInboundOrderDetailHistory(inboundOrderDetail); |
| | | |
| | | return WebResponseContent.Instance.OK(); |
| | | catch |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | throw; |
| | | } |
| | | } |
| | | |
| | | #region Helper Methods |
| | |
| | | private void SendInboundInfoToWMS(Dt_Task task, Dt_InboundOrder inboundOrder, Dt_StockInfo stockInfo) |
| | | { |
| | | |
| | | List<Dt_StockInfoDetail> dt_StockInfo = _stockInfoDetailRepository.QueryData(x => x.BatchNo == stockInfo.BatchNo).ToList(); |
| | | if (dt_StockInfo.Count == 0) return; |
| | | |
| | | List<Dt_StockInfo> StockInfos = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.WarehouseId == task.WarehouseId).Includes(x => x.Details).Where(x => x.Details.Any(v => v.OrderNo == inboundOrder.OrderNo)).ToList(); |
| | | //var dt_StockInfo = _stockRepository.StockInfoRepository.QueryData(x => x.Id == stockInfo.Id).ToList(); |
| | | //List<Dt_StockInfo> StockInfos = new List<Dt_StockInfo>(); |
| | | //foreach (var item in dt_StockInfo) |
| | | //{ |
| | | // Dt_StockInfo StockInfo = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.Id == item.Id).Includes(x => x.Details).First(); |
| | | // StockInfos.Add(StockInfo); |
| | | //} |
| | | |
| | | if (StockInfos.Count == 0) throw new Exception("未找到库存信息"); |
| | | var houseInboundPassBack = new HouseInboundPassBack |
| | | { |
| | | ApiType = "AsnController", |
| | |
| | | { |
| | | new data.data1 |
| | | { |
| | | AsnNo = task.OrderNo, |
| | | InWarehouse = task.Roadway, |
| | | AsnNo = inboundOrder.OrderNo, |
| | | //InWarehouse = task.Roadway, |
| | | TransactionCode = inboundOrder.TransactionCode, |
| | | InoutType = inboundOrder.OrderType, |
| | | OrderType = inboundOrder.InoutType, |
| | | // 遍历所有库存明细,添加到 DetailList |
| | | DetailList = dt_StockInfo.Select(d => new data.data1.Inbound |
| | | DetailList = StockInfos.Select(d => new data.data1.Inbound |
| | | { |
| | | LinId = d.LinId, |
| | | MaterielCode = d.MaterielCode, |
| | | OrderQuantity = d.StockQuantity, |
| | | LinId = d.Details.FirstOrDefault()?.LinId?? "", |
| | | MaterielCode = d.Details.FirstOrDefault()?.MaterielCode?? "", |
| | | OrderQuantity = d.Details.FirstOrDefault().StockQuantity, |
| | | BatchNo = d.BatchNo, |
| | | LPNNo = task.PalletCode, |
| | | FinishQty = d.StockQuantity, |
| | | LocationName = task.TargetAddress |
| | | LPNNo = d.PalletCode, |
| | | FinishQty = d.Details.FirstOrDefault().StockQuantity, |
| | | LocationName = d.LocationCode |
| | | }).ToList() |
| | | } |
| | | } |
| | |
| | | |
| | | foreach (var lockInfo in outStockLockInfos) |
| | | { |
| | | var detail = _outboundService.OutboundOrderDetailService.Repository.QueryFirst(x => x.Id == lockInfo.OrderDetailId); |
| | | var detail = _outboundService.OutboundOrderDetailService.Repository.QueryFirst(x => x.BatchNo == lockInfo.BatchNo); |
| | | if (detail != null) |
| | | { |
| | | detail.OverOutQuantity = detail.LockQuantity; |
| | | detail.OverOutQuantity = lockInfo.OriginalQuantity; |
| | | if (detail.LockQuantity == detail.OrderQuantity) |
| | | { |
| | | detail.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt(); |
| | |
| | | |
| | | // 根据订单类型处理不同逻辑 |
| | | var outDetail = _outboundService.OutboundOrderDetailService.Db.Queryable<Dt_OutboundOrderDetail>() |
| | | .Where(x => x.LPNNo == stockInfo.PalletCode).First(); |
| | | .Where(x => x.BatchNo == outboundOrderDetails.FirstOrDefault().BatchNo).First(); |
| | | var outboundOrder = _outboundService.OutboundOrderService.Db.Queryable<Dt_OutboundOrder>() |
| | | .Where(x => x.Id == outDetail.OrderId).Includes(x => x.Details).First(); |
| | | |
| | | if (outboundOrder.OrderType == 1) // 普通出库 |
| | | if (outboundOrder.OrderType == 1) // 普通出库 && outDetail.OrderDetailStatus = OutboundStatusEnum.出库完成 |
| | | { |
| | | ProcessNormalOutbound(task, stockInfo, outboundOrder, outDetail); |
| | | } |
| | |
| | | var stockInfoDetail = _stockRepository.StockInfoDetailRepository.Db.Queryable<Dt_StockInfoDetail>() |
| | | .Where(x => x.StockId == stockInfo.Id).First(); |
| | | |
| | | if (outboundOrder.Details.Count == 1) |
| | | if (outboundOrder.OrderStatus == OutboundStatusEnum.出库完成.ObjToInt()) |
| | | { |
| | | MoveOutboundOrderToHistory(outboundOrder); |
| | | var history = new Dt_OutboundOrder_Hty |
| | | { |
| | | OrderStatus = outboundOrder.OrderStatus, |
| | | CreateType = outboundOrder.CreateType, |
| | | UpperOrderNo = outboundOrder.UpperOrderNo, |
| | | OrderNo = outboundOrder.OrderNo, |
| | | OutWareHouse = outboundOrder.OutWareHouse, |
| | | TransactionCode = outboundOrder.TransactionCode, |
| | | InoutType = outboundOrder.InoutType, |
| | | OrderType = outboundOrder.OrderType, |
| | | Creater = "WMS", |
| | | CreateDate = DateTime.Now, |
| | | }; |
| | | _outboundOrder_HtyService.AddData(history); |
| | | _outboundService.OutboundOrderService.DeleteData(outboundOrder); |
| | | } |
| | | |
| | | MoveOutboundDetailToHistory(outDetail); |
| | |
| | | |
| | | if (outboundOrder.Details.Count == 1) |
| | | { |
| | | MoveOutboundOrderToHistory(outboundOrder); |
| | | var history = new Dt_OutboundOrder_Hty |
| | | { |
| | | OrderStatus = outboundOrder.OrderStatus, |
| | | CreateType = outboundOrder.CreateType, |
| | | UpperOrderNo = outboundOrder.UpperOrderNo, |
| | | OrderNo = outboundOrder.OrderNo, |
| | | OutWareHouse = outboundOrder.OutWareHouse, |
| | | TransactionCode = outboundOrder.TransactionCode, |
| | | InoutType = outboundOrder.InoutType, |
| | | OrderType = outboundOrder.OrderType, |
| | | Creater = "WMS", |
| | | CreateDate = DateTime.Now, |
| | | }; |
| | | _outboundOrder_HtyService.AddData(history); |
| | | _outboundService.OutboundOrderService.DeleteData(outboundOrder); |
| | | } |
| | | |
| | | MoveOutboundDetailToHistory(outDetail); |
| | |
| | | DeleteStockInfo(stockInfo); |
| | | } |
| | | |
| | | private void MoveOutboundOrderToHistory(Dt_OutboundOrder outboundOrder) |
| | | { |
| | | var history = new Dt_OutboundOrder_Hty |
| | | { |
| | | OrderStatus = outboundOrder.OrderStatus, |
| | | CreateType = outboundOrder.CreateType, |
| | | UpperOrderNo = outboundOrder.UpperOrderNo, |
| | | OrderNo = outboundOrder.OrderNo, |
| | | OutWareHouse = outboundOrder.OutWareHouse, |
| | | TransactionCode = outboundOrder.TransactionCode, |
| | | InoutType = outboundOrder.InoutType, |
| | | OrderType = outboundOrder.OrderType, |
| | | Creater = "WMS", |
| | | CreateDate = DateTime.Now, |
| | | }; |
| | | _outboundOrder_HtyService.AddData(history); |
| | | _outboundService.OutboundOrderService.DeleteData(outboundOrder); |
| | | } |
| | | |
| | | private void MoveOutboundDetailToHistory(Dt_OutboundOrderDetail outDetail) |
| | | { |
| | |
| | | private void SendNormalOutboundToWMS(Dt_Task task, Dt_OutboundOrder outboundOrder, |
| | | Dt_StockInfoDetail stockInfoDetail, Dt_OutboundOrderDetail outDetail) |
| | | { |
| | | |
| | | |
| | | List<Dt_StockInfo> StockInfos = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.WarehouseId == task.WarehouseId).Includes(x => x.Details).Where(x => x.Details.Any(v => v.OrderNo == outboundOrder.OrderNo)).ToList(); |
| | | //var dt_StockInfo = _stockRepository.StockInfoRepository.QueryData(x => x.Id == stockInfo.Id).ToList(); |
| | | //List<Dt_StockInfo> StockInfos = new List<Dt_StockInfo>(); |
| | | //foreach (var item in dt_StockInfo) |
| | | //{ |
| | | // Dt_StockInfo StockInfo = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.Id == item.Id).Includes(x => x.Details).First(); |
| | | // StockInfos.Add(StockInfo); |
| | | //} |
| | | |
| | | if (StockInfos.Count == 0) throw new Exception("未找到库存信息"); |
| | | |
| | | var passBack = new HouseoutboundPassBack |
| | | { |
| | | ApiType = "ShippingOrderController", |