| | |
| | | using AutoMapper; |
| | | using SqlSugar; |
| | | using System.Dynamic; |
| | | using System.Text.RegularExpressions; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Common.CommonEnum; |
| | | using WIDESEA_Common.OrderEnum; |
| | |
| | | |
| | | private IStockService _stockService; |
| | | private readonly IMaterialUnitService _materialUnitService; |
| | | private readonly IMaterielInfoService _materielInfoService; |
| | | private readonly IInboundOrderDetailService _inboundOrderDetailService; |
| | | private readonly IRepository<Dt_InboundOrderDetail> _inboundOrderDetailRepository; |
| | | private readonly IRepository<Dt_StockInfoDetail> _stockDetailRepository; |
| | |
| | | private readonly IRepository<Dt_StockInfo> _stockRepository; |
| | | public IRepository<Dt_InboundOrder> Repository => BaseDal; |
| | | |
| | | public InboundOrderService(IRepository<Dt_InboundOrder> BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IRepository<Dt_InboundOrderDetail> inboundOrderDetailRepository, IRepository<Dt_Task> taskRepository, IStockService stockService, IInboundOrderDetailService inboundOrderDetailService, IMaterialUnitService materialUnitService, IRepository<Dt_StockInfoDetail> stockDetailRepository, IRepository<Dt_InboundOrder> inboundOrderRepository, IRepository<Dt_WarehouseArea> warehouseAreaRepository, IRepository<Dt_StockInfo> stockRepository, IRepository<Dt_LocationType> locationTypeRepository) : base(BaseDal) |
| | | public InboundOrderService(IRepository<Dt_InboundOrder> BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IRepository<Dt_InboundOrderDetail> inboundOrderDetailRepository, IRepository<Dt_Task> taskRepository, IStockService stockService, IInboundOrderDetailService inboundOrderDetailService, IMaterialUnitService materialUnitService, IRepository<Dt_StockInfoDetail> stockDetailRepository, IRepository<Dt_InboundOrder> inboundOrderRepository, IRepository<Dt_WarehouseArea> warehouseAreaRepository, IRepository<Dt_StockInfo> stockRepository, IRepository<Dt_LocationType> locationTypeRepository, IMaterielInfoService materielInfoService) : base(BaseDal) |
| | | { |
| | | _mapper = mapper; |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | |
| | | _warehouseAreaRepository = warehouseAreaRepository; |
| | | _stockRepository = stockRepository; |
| | | _locationTypeRepository = locationTypeRepository; |
| | | _materielInfoService = materielInfoService; |
| | | } |
| | | |
| | | public async Task<WebResponseContent> ReceiveInboundOrder(List<Dt_InboundOrder> models, int operateType) |
| | |
| | | { |
| | | if (BaseDal.QueryFirst(x => x.UpperOrderNo == model.UpperOrderNo) != null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"å
¥åºåå·éå¤"); |
| | | return WebResponseContent.Instance.Error($"{model.UpperOrderNo}å
¥åºåå·éå¤"); |
| | | } |
| | | } |
| | | |
| | | foreach (var model in models) |
| | | { |
| | | var materielCodes = model.Details.Select(x => x.MaterielCode).Distinct().ToList(); |
| | | var materielInfos = _materielInfoService.Db.Queryable<Dt_MaterielInfo>().Where(x => materielCodes.Contains(x.MaterielCode)).ToList(); |
| | | |
| | | foreach (var item in model.Details) |
| | | { |
| | | var purchaseToStockResult = await _materialUnitService.ConvertPurchaseToStockAsync(item.MaterielCode, item.BarcodeQty); |
| | | item.Unit = purchaseToStockResult.Unit; |
| | | item.OrderQuantity = purchaseToStockResult.Quantity; |
| | | if (materielInfos.Any()) |
| | | { |
| | | item.MaterielName = materielInfos.FirstOrDefault(x => x.MaterielCode == item.MaterielCode)?.MaterielName ?? ""; |
| | | } |
| | | } |
| | | if (model.OrderType != InOrderTypeEnum.AllocatInbound.ObjToInt()) |
| | | { |
| | |
| | | List<Dt_InboundOrderDetail> inboundOrderDetails = new List<Dt_InboundOrderDetail>(); |
| | | List<Dt_InboundOrderDetail> updateInboundOrderDetails = new List<Dt_InboundOrderDetail>(); |
| | | List<int> detailIds = new List<int>(); |
| | | var materielCodes = model.Details.Select(x => x.MaterielCode).Distinct().ToList(); |
| | | var materielInfos = _materielInfoService.Db.Queryable<Dt_MaterielInfo>().Where(x => materielCodes.Contains(x.MaterielCode)).ToList(); |
| | | |
| | | foreach (var item in model.Details) |
| | | { |
| | | if (string.IsNullOrEmpty(item.Barcode)) |
| | | { |
| | | |
| | | } |
| | | else |
| | | if (!string.IsNullOrEmpty(item.Barcode)) |
| | | { |
| | | Dt_InboundOrderDetail? inboundOrderDetail = inboundOrder.Details.FirstOrDefault(x => x.Barcode == item.Barcode); |
| | | if (inboundOrderDetail == null) |
| | |
| | | var purchaseToStockResult = await _materialUnitService.ConvertPurchaseToStockAsync(item.MaterielCode, item.BarcodeQty); |
| | | inboundOrderDetail.Unit = purchaseToStockResult.Unit; |
| | | inboundOrderDetail.OrderQuantity = purchaseToStockResult.Quantity; |
| | | |
| | | if (materielInfos.Any()) |
| | | { |
| | | inboundOrderDetail.MaterielName = materielInfos.FirstOrDefault(x => x.MaterielCode == item.MaterielCode)?.MaterielName ?? ""; |
| | | } |
| | | inboundOrderDetails.Add(inboundOrderDetail); |
| | | } |
| | | else |
| | | { |
| | | if (materielInfos.Any()) |
| | | { |
| | | inboundOrderDetail.MaterielName = materielInfos.FirstOrDefault(x => x.MaterielCode == item.MaterielCode)?.MaterielName ?? ""; |
| | | } |
| | | inboundOrderDetail.lineNo = item.lineNo; |
| | | inboundOrderDetail.MaterielCode = item.MaterielCode; |
| | | inboundOrderDetail.SupplyCode = item.SupplyCode; |
| | |
| | | |
| | | public WebResponseContent UndoPalletGroup(string palletCode, string barcode = "") |
| | | { |
| | | |
| | | |
| | | if (string.IsNullOrWhiteSpace(palletCode)) |
| | | { |
| | | return WebResponseContent.Instance.Error("æçå·ä¸è½ä¸ºç©º"); |
| | | } |
| | | |
| | | |
| | | |
| | | try |
| | | { |
| | | _unitOfWorkManage.BeginTran(); |
| | | _unitOfWorkManage.BeginTran(); |
| | | |
| | | // 2. æ¥è¯¢æçåºå主记å½ï¼é¿å
æ æ°æ®æå¼å¸¸ï¼ |
| | | var stock = _stockRepository.Db.Queryable<Dt_StockInfo>() |
| | |
| | | return WebResponseContent.Instance.Error($"æç{palletCode}䏿ªæ¾å°æ¡ç {barcode}çæç»è®°å½"); |
| | | } |
| | | |
| | | ResetInboundOrderStatus(new List<string> { targetDetail.OrderNo},new List<string> { targetDetail.Barcode}); |
| | | ResetInboundOrderStatus(new List<string> { targetDetail.OrderNo }, new List<string> { targetDetail.Barcode }); |
| | | // å é¤æå®æç» |
| | | _stockDetailRepository.DeleteData(targetDetail); |
| | | |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error($"æçæ¤é失败ï¼{ex.Message}"); |
| | | } |
| | | } |
| | |
| | | public override PageGridData<Dt_InboundOrder> GetPageData(PageDataOptions options) |
| | | { |
| | | string wheres = ValidatePageOptions(options); |
| | | |
| | | string pattern = @"inboundOrderNo like '[^']+'\s*and\s*"; |
| | | wheres = Regex.Replace(wheres, pattern, "", RegexOptions.IgnoreCase); |
| | | |
| | | //è·åæåºå段 |
| | | Dictionary<string, SqlSugar.OrderByType> orderbyDic = GetPageDataSort(options, TProperties); |
| | | List<OrderByModel> orderByModels = new List<OrderByModel>(); |
| | |
| | | // return new PageGridData<Dt_InboundOrder>(); |
| | | //} |
| | | |
| | | public WebResponseContent UnPalletGroupBarcode(string orderNo) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | var inbound = _inboundOrderRepository.Db.Queryable<Dt_InboundOrder>().Where(x => x.InboundOrderNo == orderNo).First(); |
| | | if(inbound == null) |
| | | { |
| | | return content.Error(); |
| | | } |
| | | |
| | | var details = _inboundOrderDetailRepository.Db.Queryable<Dt_InboundOrderDetail>().Where(x => x.OrderId == inbound.Id && x.ReceiptQuantity == 0).ToList(); |
| | | |
| | | return content.OK(data:details); |
| | | } |
| | | } |
| | | } |