| | |
| | | throw new Exception($"请勿同时操作多个单据明细"); |
| | | } |
| | | Dt_OutboundOrder outboundOrder = _outboundRepository.OutboundOrderRepository.QueryFirst(x => x.Id == outboundOrderDetails.FirstOrDefault().OrderId); |
| | | List<Dt_OutboundOrderDetail> dt_OutboundOrderDetails = _outboundRepository.OutboundOrderDetailRepository.QueryData(x => x.OrderId == outboundOrder.Id); |
| | | List<Dt_StockInfo> outStocks = new List<Dt_StockInfo>(); |
| | | List<Dt_OutboundOrderDetail> groupDetails = outboundOrderDetails.GroupBy(x => new { x.MaterielCode, x.BatchNo, x.LocationName }).Select(x => new Dt_OutboundOrderDetail { OrderQuantity = x.Sum(v => v.OrderQuantity) - x.Sum(v => v.LockQuantity), MaterielCode = x.Key.MaterielCode, BatchNo = x.Key.BatchNo, LocationName = x.Key.LocationName }).ToList(); |
| | | List<Dt_Warehouse> warehouse = new List<Dt_Warehouse>(); |
| | |
| | | } |
| | | List<Dt_StockInfo> autoAssignStocks = new List<Dt_StockInfo>(); |
| | | List<IStockInfoService.residueQuantity> newResidueQuantitys = new List<IStockInfoService.residueQuantity>(); |
| | | if (warehouse.Any(x => x.WarehouseCode.Contains("DW")) || warehouse.Any(x => x.WarehouseCode.Contains("YS"))) |
| | | { |
| | | autoAssignStocks = _stockService.StockInfoService.DWANDYSGetOutboundStocks(stockInfos,groupDetails, out List<IStockInfoService.residueQuantity> residueQuantitys); |
| | | |
| | | autoAssignStocks = _stockService.StockInfoService.DWANDYSGetOutboundStocks(stockInfos, dt_OutboundOrderDetails, out List<IStockInfoService.residueQuantity> residueQuantitys); |
| | | newResidueQuantitys.AddRange(residueQuantitys); |
| | | outStocks.AddRange(autoAssignStocks); |
| | | } |
| | | |
| | | foreach(var residueQuantity in newResidueQuantitys) |
| | | { |
| | | foreach (var item in groupDetails) |
| | | foreach (var item in dt_OutboundOrderDetails) |
| | | { |
| | | if(residueQuantity.MaterielCode == item.MaterielCode && residueQuantity.BatchNo == item.BatchNo) |
| | | { |
| | |
| | | |
| | | decimal assignQuantity = needQuantity - residueQuantity.NewNeendQuantity; |
| | | |
| | | List<Dt_OutboundOrderDetail> details = outboundOrderDetails.Where(x => !string.IsNullOrEmpty(x.BatchNo) ? x.BatchNo == item.BatchNo : true && x.MaterielCode == item.MaterielCode).ToList(); |
| | | List<Dt_OutboundOrderDetail> details = dt_OutboundOrderDetails.Where(x => !string.IsNullOrEmpty(x.BatchNo) ? x.BatchNo == item.BatchNo : true && x.MaterielCode == item.MaterielCode).ToList(); |
| | | |
| | | for (int i = 0; i < details.Count; i++) |
| | | { |
| | |
| | | palletAssignQuantity = outStockLockInfos.Where(x => x.MaterielCode == item.MaterielCode && x.PalletCode == autoAssignStocks[j].PalletCode).Sum(x => x.AssignQuantity);//出库详情已分配数量 |
| | | } |
| | | decimal palletOutboundQuantity = 0; |
| | | if (warehouse.Any(x => x.WarehouseCode.Contains("DW")) || warehouse.Any(x => x.WarehouseCode.Contains("YS"))) |
| | | { |
| | | |
| | | palletOutboundQuantity = autoAssignStocks[j].Details.Where(x => x.BatchNo == item.BatchNo && x.MaterielCode == item.MaterielCode).Sum(x => x.OutboundQuantity); |
| | | |
| | | } |
| | | |
| | | if (palletAssignQuantity < palletOutboundQuantity)//如果出库详情已分配数量小于托盘已分配数量,则可以继续添加该托盘出库信息 |
| | | { |
| | | decimal orderDetailNeedQuantity = details[i].OrderQuantity - detailAssignQuantity; |
| | |
| | | } |
| | | newResidueQuantitys = new List<IStockInfoService.residueQuantity>(); |
| | | } |
| | | return (outStocks, outboundOrderDetails, outStockLockInfos, locationInfos); |
| | | return (outStocks, dt_OutboundOrderDetails, outStockLockInfos, locationInfos); |
| | | } |
| | | |
| | | private (bool, string) CheckSelectStockDeital(Dt_OutboundOrderDetail outboundOrderDetail, List<StockSelectViewDTO> stockSelectViews) |
| | |
| | | return WebResponseContent.Instance.Error("该出库单据非ERP推送,无法取消"); |
| | | } |
| | | string ids =""; |
| | | foreach (var item in outboundOrderDetails) |
| | | try |
| | | { |
| | | ids = item.LinId; |
| | | var postContent = new MultipartFormDataContent(); |
| | | postContent.Add(new StringContent(ids), "ids"); |
| | | string result = string.Empty; |
| | | HttpClient client = null; |
| | | try |
| | | foreach (var item in outboundOrderDetails) |
| | | { |
| | | ids = item.LinId; |
| | | var postContent = new MultipartFormDataContent(); |
| | | postContent.Add(new StringContent(ids), "ids"); |
| | | string result = string.Empty; |
| | | HttpClient client = null; |
| | | using (client = new HttpClient()) |
| | | { |
| | | // 2. 发送请求 |
| | |
| | | _outboundRepository.OutboundOrderRepository.DeleteAndMoveIntoHty(outboundOrder, OperateType.人工取消); |
| | | } |
| | | _unitOfWorkManage.CommitTran(); |
| | | // 假设ERP返回成功时返回成功响应 |
| | | return WebResponseContent.Instance.OK(result); |
| | | |
| | | } |
| | | catch (HttpRequestException ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | // 处理HTTP请求相关异常 |
| | | return WebResponseContent.Instance.Error($"HTTP请求错误: {ex.Message}"); |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | // 处理其他异常 |
| | | return WebResponseContent.Instance.Error($"处理失败: {ex.Message}"); |
| | | } |
| | | // 假设ERP返回成功时返回成功响应 |
| | | return WebResponseContent.Instance.OK(); |
| | | |
| | | } |
| | | return WebResponseContent.Instance.OK(); |
| | | catch (HttpRequestException ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | // 处理HTTP请求相关异常 |
| | | return WebResponseContent.Instance.Error($"HTTP请求错误: {ex.Message}"); |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | // 处理其他异常 |
| | | return WebResponseContent.Instance.Error($"处理失败: {ex.Message}"); |
| | | } |
| | | } |
| | | |
| | | } |