| | |
| | | using MailKit.Search; |
| | | using Microsoft.AspNetCore.SignalR; |
| | | using Newtonsoft.Json; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.Database; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.Text; |
| | | using Org.BouncyCastle.Asn1.Tsp; |
| | | using SqlSugar; |
| | |
| | | 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"]; |
| | |
| | | Dt_InboundOrderDetail inboundOrderDetail = inboundOrder.Details |
| | | .FirstOrDefault(x => x.LinId == stockInfo.Details.FirstOrDefault()?.LinId); |
| | | |
| | | if (inboundOrder.OrderType == 0 && inboundOrder != null && stockInfo.StockStatus == StockStatusEmun.入库确认.ObjToInt()) |
| | | { |
| | | //入库数量回传 |
| | | return ProcessNormalInbound(task, stockInfo, locationInfo, lastStatus, inboundOrder, inboundOrderDetail); |
| | | } |
| | | else |
| | | { |
| | | //调拨出入库任务数量回传 |
| | | return ProcessAllocateInbound(task, stockInfo, locationInfo, lastStatus, inboundOrder, inboundOrderDetail); |
| | | } |
| | | //if (inboundOrder != null && stockInfo.StockStatus == StockStatusEmun.入库确认.ObjToInt()) |
| | | //{ |
| | | //入库数量回传 |
| | | return ProcessNormalInbound(task, stockInfo, locationInfo, lastStatus, inboundOrder, inboundOrderDetail); |
| | | //} |
| | | //else |
| | | //{ |
| | | // //调拨出入库任务数量回传 |
| | | // return ProcessAllocateInbound(task, stockInfo, locationInfo, lastStatus, inboundOrder, inboundOrderDetail); |
| | | //} |
| | | } |
| | | |
| | | //其他入库 |
| | | private WebResponseContent ProcessNormalInbound(Dt_Task task, Dt_StockInfo stockInfo, Dt_LocationInfo locationInfo, |
| | | int lastStatus, Dt_InboundOrder inboundOrder, Dt_InboundOrderDetail inboundOrderDetail) |
| | | { |
| | |
| | | UpdateInboundOrder(inboundOrder, inboundOrderDetail); |
| | | |
| | | // 单据数量全部上架完成,处理WMS回传 |
| | | if (inboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()) |
| | | if (inboundOrder.OrderStatus == InboundStatusEnum.入库完成.ObjToInt() && inboundOrder.OrderType == 0) |
| | | { |
| | | var stockInfoDetail = stockInfo.Details.FirstOrDefault(); |
| | | SendInboundInfoToWMS(task, inboundOrder, stockInfo); |
| | | } |
| | | else if (inboundOrder.OrderStatus == InboundStatusEnum.入库完成.ObjToInt() && inboundOrder.OrderType == 2) |
| | | { |
| | | SendAllocateInfoToWMS(task, inboundOrder, stockInfo); |
| | | } |
| | | |
| | | _unitOfWorkManage.CommitTran(); |
| | |
| | | throw; |
| | | } |
| | | } |
| | | ////调拨入库 |
| | | //private WebResponseContent ProcessAllocateInbound(Dt_Task task, Dt_StockInfo stockInfo, Dt_LocationInfo locationInfo, |
| | | // int lastStatus, Dt_InboundOrder inboundOrder, Dt_InboundOrderDetail inboundOrderDetail) |
| | | //{ |
| | | // // 更新入库单明细状态 |
| | | // UpdateInboundOrderDetails(stockInfo, inboundOrder, ref inboundOrderDetail); |
| | | |
| | | 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()) |
| | | { |
| | | try |
| | | { |
| | | _unitOfWorkManage.BeginTran(); |
| | | // // 更新库存明细状态 |
| | | // stockInfo.Details.ForEach(x => x.Status = StockStatusEmun.入库完成.ObjToInt()); |
| | | |
| | | // 处理调拨入库单 |
| | | //ProcessAllocateInboundOrder(inboundOrder, inboundOrderDetail); |
| | | // try |
| | | // { |
| | | // _unitOfWorkManage.BeginTran(); |
| | | |
| | | // 获取相关库存信息 |
| | | var relatedStockInfo = _stockService.StockInfoService.Repository |
| | | .QueryData(x => x.BatchNo == inboundOrderDetail.BatchNo); |
| | | // // 更新任务状态 |
| | | // UpdateTaskStatus(task); |
| | | |
| | | // 发送调拨信息到WMS |
| | | SendAllocateInfoToWMS(task, inboundOrder, relatedStockInfo); |
| | | // // 更新货位状态 |
| | | // UpdateLocationStatus(locationInfo, lastStatus); |
| | | |
| | | _unitOfWorkManage.CommitTran(); |
| | | } |
| | | catch |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | throw; |
| | | } |
| | | } |
| | | // // 更新库存信息 |
| | | // UpdateStockInfo(stockInfo); |
| | | |
| | | // 添加历史记录 |
| | | AddInboundOrderDetailHistory(inboundOrderDetail); |
| | | // // 添加记录 |
| | | // AddRecords(task, stockInfo, locationInfo, lastStatus); |
| | | |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | // // 更新入库单 |
| | | // 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(); |
| | | // } |
| | | // catch |
| | | // { |
| | | // _unitOfWorkManage.RollbackTran(); |
| | | // throw; |
| | | // } |
| | | //} |
| | | |
| | | #region Helper Methods |
| | | |
| | |
| | | else if (inboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.New.ObjToInt()) |
| | | { |
| | | inboundOrderDetail.OrderDetailStatus = InboundStatusEnum.入库中.ObjToInt(); |
| | | inboundOrder.OrderStatus = InboundStatusEnum.入库中.ObjToInt(); |
| | | } |
| | | } |
| | | if (inboundOrder.Details.Count == overCount) |
| | | { |
| | | inboundOrder.OrderStatus = InboundStatusEnum.入库完成.ObjToInt(); |
| | | } |
| | | } |
| | | |
| | |
| | | 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() |
| | | } |
| | | } |
| | |
| | | _inboundService.InboundOrderDetailService.DeleteData(inboundOrderDetail); |
| | | } |
| | | |
| | | private void SendAllocateInfoToWMS(Dt_Task task, Dt_InboundOrder inboundOrder, List<Dt_StockInfo> stockInfos) |
| | | private void SendAllocateInfoToWMS(Dt_Task task, Dt_InboundOrder inboundOrder, Dt_StockInfo stockInfos) |
| | | { |
| | | |
| | | var detail = _stockService.StockInfoDetailService.Repository.QueryFirst(x => x.StockId == stockInfos.FirstOrDefault().Id); |
| | | 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 inventoryAllocate = new InventoryAllocate |
| | | { |
| | | ApiType = "AsnController", |
| | | Method = "AsrsGroudingAsn", |
| | | ApiType = "InventoryAllocateController", |
| | | Method = "AsrsFinishedStockCount", |
| | | Parameters = new List<InventoryAllocate.Allocate> |
| | | { |
| | | new InventoryAllocate.Allocate |
| | | { |
| | | Value = new List<Allocate.data1> |
| | | { |
| | | new Allocate.data1 |
| | | new Allocate.data1 |
| | | { |
| | | No = inboundOrder.OrderNo, |
| | | //InWarehouse = task.Roadway, |
| | | TransactionCode = inboundOrder.TransactionCode, |
| | | InoutType = inboundOrder.OrderType, |
| | | OrderType = inboundOrder.InoutType, |
| | | // 遍历所有库存明细,添加到 DetailList |
| | | DetailList = StockInfos.Select(d => new Allocate.data1.Inventory |
| | | { |
| | | No = task.OrderNo, |
| | | InWarehouse = task.Roadway, |
| | | TransactionCode = inboundOrder.TransactionCode, |
| | | InoutType = inboundOrder.OrderType, |
| | | OrderType = inboundOrder.InoutType, |
| | | DetailList = new List<Allocate.data1.Inventory> |
| | | { |
| | | new Allocate.data1.Inventory |
| | | { |
| | | LinId = detail.LinId, |
| | | MaterielCode = detail.MaterielCode, |
| | | OrderQuantity = detail.StockQuantity, |
| | | BatchNo = detail.BatchNo, |
| | | FinishQty = detail.StockQuantity, |
| | | LocationName = task.TargetAddress |
| | | } |
| | | } |
| | | } |
| | | LinId = d.Details.FirstOrDefault()?.LinId?? "", |
| | | MaterielCode = d.Details.FirstOrDefault()?.MaterielCode?? "", |
| | | OrderQuantity = d.Details.FirstOrDefault().StockQuantity, |
| | | BatchNo = d.BatchNo, |
| | | LPN_No = d.PalletCode, |
| | | FinishQty = d.Details.FirstOrDefault().StockQuantity, |
| | | LocationName = d.LocationCode |
| | | }).ToList() |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | out var locationInfo, out var outStockLockInfos); |
| | | if (!validationResult.Status) return validationResult; |
| | | |
| | | int lastStatus = locationInfo.LocationStatus; |
| | | locationInfo.LocationStatus = LocationStatusEnum.InStock.ObjToInt(); |
| | | |
| | | |
| | | |
| | | Dt_OutboundOrderDetail outboundOrderDetails = _outboundService.OutboundOrderService.Db.Queryable<Dt_OutboundOrderDetail>() |
| | | .Where(x => x.BatchNo == stockInfo.Details.FirstOrDefault().BatchNo) |
| | | .First(); |
| | | if (outboundOrderDetails == null) return WebResponseContent.Instance.Error("未找到出库单信息"); |
| | | |
| | | Dt_OutboundOrder inboundOrder = _outboundService.OutboundOrderService.Db.Queryable<Dt_OutboundOrder>() |
| | | .Where(x => x.Id == outboundOrderDetails.OrderId) |
| | | .Includes(x => x.Details) |
| | | .First(); |
| | | |
| | | if (inboundOrder == null) return WebResponseContent.Instance.Error("未找到出库单信息"); |
| | | // 2. 处理出库订单详情 |
| | | var outboundOrderDetails = ProcessOutboundOrderDetails(outStockLockInfos); |
| | | //var outboundOrderDetails = ProcessOutboundOrderDetails(outStockLockInfos); |
| | | |
| | | UpdateOutboundOrderDetails(stockInfo, inboundOrder, ref outboundOrderDetails); |
| | | |
| | | // 3. 执行核心出库逻辑 |
| | | return ExecuteOutboundLogic(task, stockInfo, locationInfo, outboundOrderDetails); |
| | |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | |
| | | private List<Dt_OutboundOrderDetail> ProcessOutboundOrderDetails(List<Dt_OutStockLockInfo> outStockLockInfos) |
| | | { |
| | | var outboundOrderDetails = new List<Dt_OutboundOrderDetail>(); |
| | | //private List<Dt_OutboundOrderDetail> ProcessOutboundOrderDetails(List<Dt_OutStockLockInfo> outStockLockInfos) |
| | | //{ |
| | | // var outboundOrderDetails = new List<Dt_OutboundOrderDetail>(); |
| | | |
| | | foreach (var lockInfo in outStockLockInfos) |
| | | { |
| | | var detail = _outboundService.OutboundOrderDetailService.Repository.QueryFirst(x => x.Id == lockInfo.OrderDetailId); |
| | | if (detail != null) |
| | | { |
| | | detail.OverOutQuantity = detail.LockQuantity; |
| | | if (detail.LockQuantity == detail.OrderQuantity) |
| | | { |
| | | detail.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt(); |
| | | } |
| | | outboundOrderDetails.Add(detail); |
| | | } |
| | | } |
| | | // foreach (var lockInfo in outStockLockInfos) |
| | | // { |
| | | // List<Dt_OutboundOrderDetail> detail = _outboundService.OutboundOrderDetailService.Repository.QueryData(x => x.Id == lockInfo.Id); |
| | | // if (detail != null) |
| | | // { |
| | | // detail.OverOutQuantity = lockInfo.OriginalQuantity; |
| | | // if (detail.LockQuantity == detail.OrderQuantity) |
| | | // { |
| | | // detail.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt(); |
| | | // } |
| | | // outboundOrderDetails.Add(detail); |
| | | // } |
| | | // } |
| | | |
| | | return outboundOrderDetails; |
| | | } |
| | | // return outboundOrderDetails; |
| | | //} |
| | | |
| | | private WebResponseContent ExecuteOutboundLogic(Dt_Task task, Dt_StockInfo stockInfo, |
| | | Dt_LocationInfo locationInfo, List<Dt_OutboundOrderDetail> outboundOrderDetails) |
| | | Dt_LocationInfo locationInfo, Dt_OutboundOrderDetail outboundOrderDetails) |
| | | { |
| | | try |
| | | { |
| | | _unitOfWorkManage.BeginTran(); |
| | | |
| | | |
| | | // 更新出库订单详情 |
| | | _outboundService.OutboundOrderDetailService.Repository.UpdateData(outboundOrderDetails); |
| | |
| | | |
| | | // 根据订单类型处理不同逻辑 |
| | | var outDetail = _outboundService.OutboundOrderDetailService.Db.Queryable<Dt_OutboundOrderDetail>() |
| | | .Where(x => x.LPNNo == stockInfo.PalletCode).First(); |
| | | .Where(x => x.BatchNo == outboundOrderDetails.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.OrderStatus == OutboundStatusEnum.出库完成.ObjToInt()) |
| | | { |
| | | ProcessNormalOutbound(task, stockInfo, outboundOrder, outDetail); |
| | | var stockInfoDetail = stockInfo.Details.FirstOrDefault(); |
| | | //ProcessNormalOutbound(task, stockInfo, outboundOrder, outDetail); |
| | | SendNormalOutboundToWMS(task, outboundOrder, stockInfoDetail, outDetail); |
| | | } |
| | | else if (outboundOrder.OrderType == 240) // 盘点出库 |
| | | |
| | | if (outboundOrder.OrderType == 240) // 盘点出库 |
| | | { |
| | | // 盘点出库特殊处理逻辑 |
| | | } |
| | | else // 调拨出库 |
| | | { |
| | | ProcessAllocateOutbound(task, stockInfo, outboundOrder, outDetail); |
| | | } |
| | | //else // 调拨出库 |
| | | //{ |
| | | // ProcessAllocateOutbound(task, stockInfo, outboundOrder, outDetail); |
| | | //} |
| | | |
| | | _unitOfWorkManage.CommitTran(); |
| | | return WebResponseContent.Instance.OK(); |
| | |
| | | throw; |
| | | } |
| | | } |
| | | private void UpdateOutboundOrderDetails(Dt_StockInfo stockInfo, Dt_OutboundOrder inboundOrder, |
| | | ref Dt_OutboundOrderDetail inboundOrderDetail) |
| | | { |
| | | int overCount = inboundOrder.Details.Count(x => x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()); |
| | | inboundOrderDetail = inboundOrder.Details.FirstOrDefault(x => x.BatchNo == stockInfo.Details.FirstOrDefault()?.BatchNo); |
| | | |
| | | foreach (var item in stockInfo.Details) |
| | | { |
| | | if (inboundOrderDetail == null) continue; |
| | | |
| | | inboundOrderDetail.OverOutQuantity += item.OutboundQuantity; |
| | | |
| | | if (inboundOrderDetail.OverOutQuantity == inboundOrderDetail.OrderQuantity) |
| | | { |
| | | inboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt(); |
| | | overCount++; |
| | | } |
| | | else if (inboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.New.ObjToInt()) |
| | | { |
| | | inboundOrderDetail.OrderDetailStatus = OutboundStatusEnum.出库中.ObjToInt(); |
| | | inboundOrder.OrderStatus = OutboundStatusEnum.出库中.ObjToInt(); |
| | | } |
| | | } |
| | | if (inboundOrder.Details.Count == overCount) |
| | | { |
| | | inboundOrder.OrderStatus = OutboundStatusEnum.出库完成.ObjToInt(); |
| | | } |
| | | } |
| | | |
| | | private void UpdateStockStatus(Dt_StockInfo stockInfo, Dt_LocationInfo locationInfo) |
| | | { |
| | | stockInfo.LocationCode = locationInfo.LocationCode; |
| | | stockInfo.LocationCode = ""; |
| | | stockInfo.StockStatus = StockStatusEmun.出库完成.ObjToInt(); |
| | | _stockService.StockInfoService.Repository.UpdateData(stockInfo); |
| | | stockInfo.Details.ForEach(x => |
| | | { |
| | | x.Status = StockStatusEmun.出库完成.ObjToInt(); |
| | | }); |
| | | _stockRepository.StockInfoRepository.UpdateData(stockInfo); |
| | | _stockRepository.StockInfoDetailRepository.UpdateData(stockInfo.Details); |
| | | } |
| | | |
| | | private void UpdateLocationStatus(Dt_LocationInfo locationInfo) |
| | |
| | | var stockInfoDetail = _stockRepository.StockInfoDetailRepository.Db.Queryable<Dt_StockInfoDetail>() |
| | | .Where(x => x.StockId == stockInfo.Id).First(); |
| | | |
| | | if (outboundOrder.Details.Count == 1) |
| | | { |
| | | MoveOutboundOrderToHistory(outboundOrder); |
| | | } |
| | | //if (outboundOrder.OrderStatus == OutboundStatusEnum.出库完成.ObjToInt()) |
| | | //{ |
| | | // 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); |
| | | //MoveOutboundDetailToHistory(outDetail); |
| | | |
| | | // 发送出库信息到WMS |
| | | SendNormalOutboundToWMS(task, outboundOrder, stockInfoDetail, outDetail); |
| | | if (outboundOrder.OrderStatus == OutboundStatusEnum.出库完成.ObjToInt() && outboundOrder.OrderType == 0) |
| | | { |
| | | SendNormalOutboundToWMS(task, outboundOrder, stockInfoDetail, outDetail); |
| | | } |
| | | else if (outboundOrder.OrderStatus == OutboundStatusEnum.出库完成.ObjToInt() && outboundOrder.OrderType == 2) |
| | | { |
| | | SendAllocateOutboundToWMS(task, outboundOrder, stockInfoDetail, outDetail); |
| | | } |
| | | |
| | | |
| | | // 删除库存信息 |
| | | DeleteStockInfo(stockInfo); |
| | | //DeleteStockInfo(stockInfo); |
| | | } |
| | | |
| | | private void ProcessAllocateOutbound(Dt_Task task, Dt_StockInfo stockInfo, |
| | |
| | | |
| | | 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); |
| | | |
| | | // 发送调拨出库信息到WMS |
| | | SendAllocateOutboundToWMS(task, outboundOrder, outDetail, relatedStockInfos); |
| | | |
| | | |
| | | // 删除库存信息 |
| | | 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.BatchNo == outDetail.BatchNo)).ToList(); |
| | | List<Dt_OutStockLockInfo> outStockLockInfos = _outboundService.OutboundStockLockInfoService.Repository.QueryData(x => x.OrderNo == outboundOrder.OrderNo); |
| | | |
| | | |
| | | if (outStockLockInfos.Count == 0) throw new Exception("未找到库存信息"); |
| | | |
| | | // 构建回传数据,将所有匹配的库存明细加入 DetailList |
| | | var passBack = new HouseoutboundPassBack |
| | | { |
| | | ApiType = "ShippingOrderController", |
| | | Method = "AsrsOutboundSO", |
| | | ApiType = "InventoryAllocateController", |
| | | Method = "AsrsFinishedStockCount", |
| | | Parameters = new List<HouseoutboundPassBack.datas> |
| | | { |
| | | new HouseoutboundPassBack.datas |
| | | { |
| | | new HouseoutboundPassBack.datas |
| | | Value = new List<HouseoutboundPassBack.datas.data1> |
| | | { |
| | | Value = new List<HouseoutboundPassBack.datas.data1> |
| | | new HouseoutboundPassBack.datas.data1 |
| | | { |
| | | new HouseoutboundPassBack.datas.data1 |
| | | { |
| | | No = outboundOrder.OrderNo, |
| | | OutWareHouse = task.Roadway, |
| | | TransactionCode = outboundOrder.TransactionCode, |
| | | InoutType = outboundOrder.OrderType, |
| | | OrderType = outboundOrder.InoutType, |
| | | DetailList = new List<HouseoutboundPassBack.datas.data1.Inbound> |
| | | No = outboundOrder.OrderNo, |
| | | OutWareHouse = task.Roadway, |
| | | TransactionCode = outboundOrder.TransactionCode, |
| | | InoutType = outboundOrder.OrderType, |
| | | OrderType = outboundOrder.InoutType, |
| | | DetailList = outStockLockInfos.Select(d => new HouseoutboundPassBack.datas.data1.Inbound |
| | | { |
| | | new HouseoutboundPassBack.datas.data1.Inbound |
| | | { |
| | | LinId = outDetail.LinId, |
| | | LPN_No = task.PalletCode, |
| | | MaterielCode = stockInfoDetail.MaterielCode, |
| | | OrderQuantity = stockInfoDetail.OutboundQuantity, |
| | | BatchNo = stockInfoDetail.BatchNo, |
| | | FinishQty = stockInfoDetail.OutboundQuantity, |
| | | LocationName = task.SourceAddress |
| | | } |
| | | } |
| | | } |
| | | LinId = d.LinId?? "", |
| | | LPN_No = d.PalletCode, |
| | | MaterielCode = d.MaterielCode?? "", |
| | | OrderQuantity = d.OrderQuantity, |
| | | BatchNo = d.BatchNo, |
| | | FinishQty = d.OrderQuantity, |
| | | LocationName = d.LocationCode |
| | | }) |
| | | .ToList() |
| | | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }; |
| | | |
| | | var authResult = AuthenticateWithWMS(); |
| | |
| | | } |
| | | |
| | | private void SendAllocateOutboundToWMS(Dt_Task task, Dt_OutboundOrder outboundOrder, |
| | | Dt_OutboundOrderDetail outDetail, List<Dt_StockInfo> stockInfos) |
| | | Dt_StockInfoDetail stockInfoDetail, Dt_OutboundOrderDetail outDetail) |
| | | { |
| | | List<Dt_OutStockLockInfo> outStockLockInfos = _outboundService.OutboundStockLockInfoService.Repository.QueryData(x => x.OrderNo == outboundOrder.OrderNo); |
| | | |
| | | |
| | | if (outStockLockInfos.Count == 0) throw new Exception("未找到库存信息"); |
| | | var allocate = new InventoryAllocate |
| | | { |
| | | ApiType = "InventoryAllocateController", |
| | |
| | | TransactionCode = outboundOrder.TransactionCode, |
| | | InoutType = outboundOrder.OrderType, |
| | | OrderType = outboundOrder.InoutType, |
| | | DetailList = stockInfos.Select(item => |
| | | DetailList = outStockLockInfos.Select(item => |
| | | { |
| | | var detail = _stockService.StockInfoDetailService.Repository.QueryFirst(x => x.StockId == item.Id); |
| | | return new Allocate.data1.Inventory |