| | |
| | | using AutoMapper; |
| | | using SqlSugar; |
| | | using System.Dynamic; |
| | | using System.Text.RegularExpressions; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Common.CommonEnum; |
| | | using WIDESEA_Common.LocationEnum; |
| | | using WIDESEA_Common.OrderEnum; |
| | | using WIDESEA_Common.StockEnum; |
| | | using WIDESEA_Common.TaskEnum; |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Core.BaseRepository; |
| | | using WIDESEA_Core.BaseServices; |
| | |
| | | using WIDESEA_Core.Helper; |
| | | using WIDESEA_Core.Seed; |
| | | using WIDESEA_Core.Utilities; |
| | | using WIDESEA_DTO.Base; |
| | | using WIDESEA_DTO.Inbound; |
| | | using WIDESEA_DTO.Stock; |
| | | using WIDESEA_IBasicService; |
| | | using WIDESEA_IInboundService; |
| | | using WIDESEA_IRecordService; |
| | |
| | | |
| | | 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_InboundOrder> _inboundOrderRepository; |
| | | private readonly IRepository<Dt_WarehouseArea> _warehouseAreaRepository; |
| | | private readonly IRepository<Dt_LocationType> _locationTypeRepository; |
| | | private readonly IRepository<Dt_StockInfo> _stockRepository; |
| | | private readonly IRepository<Dt_LocationInfo> _locationInfoRepository; |
| | | private readonly IBasicService _basicService; |
| | | private readonly IRepository<Dt_AllocateOrder> _allocateOrderRepository; |
| | | private readonly IRepository<Dt_OutboundOrder> _outboundOrderRepository; |
| | | private readonly IRepository<Dt_OutboundOrderDetail> _outboundOrderDetailRepository; |
| | | 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) : 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, IBasicService basicService, IRepository<Dt_LocationInfo> locationInfoRepository, IRepository<Dt_AllocateOrder> allocateOrderRepository, IRepository<Dt_OutboundOrder> outboundOrderRepository, IRepository<Dt_OutboundOrderDetail> outboundOrderDetailRepository) : base(BaseDal) |
| | | { |
| | | _mapper = mapper; |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | |
| | | _inboundOrderRepository = inboundOrderRepository; |
| | | _warehouseAreaRepository = warehouseAreaRepository; |
| | | _stockRepository = stockRepository; |
| | | _locationTypeRepository = locationTypeRepository; |
| | | _materielInfoService = materielInfoService; |
| | | _basicService = basicService; |
| | | _locationInfoRepository = locationInfoRepository; |
| | | _allocateOrderRepository = allocateOrderRepository; |
| | | _outboundOrderRepository = outboundOrderRepository; |
| | | _outboundOrderDetailRepository = outboundOrderDetailRepository; |
| | | } |
| | | |
| | | 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; |
| | | Dt_MaterielInfo materielInfo = materielInfos.First(x => x.MaterielCode == item.MaterielCode); |
| | | //var purchaseToStockResult = await _materialUnitService.ConvertPurchaseToStockAsync(item.MaterielCode, item.BarcodeQty); |
| | | |
| | | UnitConvertResultDTO totalResult = _basicService.UnitQuantityConvert(item.MaterielCode, item.Unit, materielInfo.inventoryUOM, item.OrderQuantity); |
| | | item.Unit = totalResult.ToUnit; |
| | | item.OrderQuantity = totalResult.ToQuantity; |
| | | if (materielInfos.Any()) |
| | | { |
| | | item.MaterielName = materielInfos.FirstOrDefault(x => x.MaterielCode == item.MaterielCode)?.MaterielName ?? ""; |
| | | } |
| | | } |
| | | if (model.OrderType != InOrderTypeEnum.AllocatInbound.ObjToInt()) |
| | | { |
| | | model.InboundOrderNo = CreateCodeByRule(nameof(RuleCodeEnum.InboundOrderRule)); |
| | | } |
| | | |
| | | model.InboundOrderNo = CreateCodeByRule(nameof(RuleCodeEnum.InboundOrderRule)); |
| | | Db.InsertNav(model).Include(x => x.Details).ExecuteCommand(); |
| | | } |
| | | return WebResponseContent.Instance.OK(); |
| | |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°å
¥åºåæç»ä¿¡æ¯"); |
| | | } |
| | | if (inboundOrder.OrderStatus != InOrderStatusEnum.æªå¼å§.ObjToInt()) |
| | | { |
| | | return WebResponseContent.Instance.Error($"该订åç¶æä¸å
许修æ¹"); |
| | | } |
| | | 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; |
| | |
| | | inboundOrderDetail.BarcodeUnit = item.BarcodeUnit; |
| | | inboundOrderDetail.BarcodeQty = item.BarcodeQty; |
| | | inboundOrderDetail.OrderQuantity = item.OrderQuantity; |
| | | |
| | | var purchaseToStockResult = await _materialUnitService.ConvertPurchaseToStockAsync(item.MaterielCode, item.BarcodeQty); |
| | | inboundOrderDetail.Unit = purchaseToStockResult.Unit; |
| | | inboundOrderDetail.OrderQuantity = purchaseToStockResult.Quantity; |
| | | |
| | | updateInboundOrderDetails.Add(inboundOrderDetail); |
| | | detailIds.Add(inboundOrderDetail.Id); |
| | |
| | | _unitOfWorkManage.BeginTran(); |
| | | foreach (var item in deletePurchaseOrderDetails) |
| | | { |
| | | _inboundOrderDetailRepository.DeleteAndMoveIntoHty(item, OperateTypeEnum.èªå¨å é¤); |
| | | _inboundOrderDetailRepository.DeleteData(item); |
| | | //_inboundOrderDetailRepository.DeleteAndMoveIntoHty(item, OperateTypeEnum.èªå¨å é¤); |
| | | } |
| | | |
| | | _inboundOrderDetailRepository.UpdateData(updateInboundOrderDetails); |
| | |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°å
¥åºåæç»ä¿¡æ¯"); |
| | | } |
| | | if (inboundOrder.OrderStatus != InOrderStatusEnum.æªå¼å§.ObjToInt()) |
| | | { |
| | | return WebResponseContent.Instance.Error($"该订åç¶æä¸å
许å é¤"); |
| | | } |
| | | //Db.DeleteNav(inboundOrder).Include(x => x.Details).ExecuteCommand(); |
| | | _unitOfWorkManage.BeginTran(); |
| | | BaseDal.DeleteAndMoveIntoHty(inboundOrder, OperateTypeEnum.èªå¨å é¤); |
| | | //BaseDal.DeleteAndMoveIntoHty(inboundOrder, OperateTypeEnum.èªå¨å é¤); |
| | | foreach (var item in inboundOrder.Details) |
| | | { |
| | | _inboundOrderDetailRepository.DeleteAndMoveIntoHty(item, OperateTypeEnum.èªå¨å é¤); |
| | | _inboundOrderDetailRepository.DeleteData(item); |
| | | //_inboundOrderDetailRepository.DeleteAndMoveIntoHty(item, OperateTypeEnum.èªå¨å é¤); |
| | | } |
| | | BaseDal.DeleteData(inboundOrder); |
| | | _unitOfWorkManage.CommitTran(); |
| | | } |
| | | return WebResponseContent.Instance.OK(); |
| | |
| | | if (!result2.Item1) return content = WebResponseContent.Instance.Error(result2.Item2); |
| | | |
| | | // materielGroupDTO.WarehouseCode |
| | | var code = _warehouseAreaRepository.Db.Queryable<Dt_WarehouseArea>().Where(x => x.Code == materielGroupDTO.WarehouseType).Select(x=>x.Code).First(); |
| | | if(string.IsNullOrEmpty(code)) |
| | | var code = _warehouseAreaRepository.Db.Queryable<Dt_WarehouseArea>().Where(x => x.Code == materielGroupDTO.WarehouseType).Select(x => x.Code).First(); |
| | | if (string.IsNullOrEmpty(code)) |
| | | { |
| | | return content = WebResponseContent.Instance.Error($"ä»åºä¸æ²¡æè¯¥{materielGroupDTO.WarehouseType}ç¼å·ã"); |
| | | } |
| | | |
| | | |
| | | |
| | | Dt_InboundOrder inboundOrder = GetInboundOrder(materielGroupDTO.OrderNo); |
| | | |
| | |
| | | |
| | | if (stockInfo == null) |
| | | { |
| | | stockInfo = new Dt_StockInfo() { PalletType = (int)PalletTypeEnum.None,LocationType=materielGroupDTO.locationType.ObjToInt() }; |
| | | stockInfo = new Dt_StockInfo() { PalletType = (int)PalletTypeEnum.None, LocationType = materielGroupDTO.locationType.ObjToInt() }; |
| | | stockInfo.Details = new List<Dt_StockInfoDetail>(); |
| | | } |
| | | |
| | | |
| | | foreach (var item in dbinboundOrderDetails) |
| | | { |
| | | stockInfo.Details.Add(new Dt_StockInfoDetail |
| | |
| | | SupplyCode = item.SupplyCode, |
| | | WarehouseCode = materielGroupDTO.WarehouseType, |
| | | StockQuantity = item.OrderQuantity, |
| | | Status = 0, |
| | | BarcodeQty = item.BarcodeQty, |
| | | BarcodeUnit = item.BarcodeUnit, |
| | | FactoryArea = inboundOrder.FactoryArea, |
| | | Status = 0, |
| | | OrderNo = inboundOrder.InboundOrderNo, |
| | | BusinessType = inboundOrder.BusinessType, |
| | | ProductionDate = DateTime.Now.ToString("yyyy-mm-dd HH:mm:ss") |
| | | |
| | | }); |
| | | |
| | | |
| | | item.ReceiptQuantity = item.BarcodeQty; |
| | | item.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt(); |
| | | item.WarehouseCode = materielGroupDTO.WarehouseType; |
| | |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | |
| | | (bool, string, object?) result2 = ModelValidate.ValidateModelData(materielGroupDTO); |
| | | if (!result2.Item1) return content = WebResponseContent.Instance.Error(result2.Item2); |
| | | |
| | | var code = _warehouseAreaRepository.Db.Queryable<Dt_WarehouseArea>().Where(x => x.Code == materielGroupDTO.WarehouseCode).Select(x => x.Code).First(); |
| | | if (string.IsNullOrEmpty(code)) |
| | | bool code = _locationTypeRepository.Db.Queryable<Dt_LocationType>().Where(x => x.LocationType == materielGroupDTO.WarehouseCode).Any(); |
| | | bool statu = _locationInfoRepository.Db.Queryable<Dt_LocationInfo>().Where(x => x.LocationType == materielGroupDTO.WarehouseCode && x.LocationStatus == (int)LocationStatusEnum.Free && x.EnableStatus == (int)EnableStatusEnum.Normal).Any(); |
| | | if (!statu) |
| | | { |
| | | return content = WebResponseContent.Instance.Error($"ä»åºä¸æ²¡æè¯¥{materielGroupDTO.WarehouseCode}ç¼å·ã"); |
| | | return content = WebResponseContent.Instance.Error($"该åºåæ è´§ä½å¯åé
"); |
| | | } |
| | | if (!code) |
| | | { |
| | | return content = WebResponseContent.Instance.Error($"åºå䏿²¡æè¯¥{materielGroupDTO.WarehouseCode}ç¼å·ã"); |
| | | } |
| | | |
| | | if(_stockRepository.QueryFirst(x=>x.PalletCode == materielGroupDTO.PalletCode)!=null){ |
| | | if (_stockRepository.QueryFirst(x => x.PalletCode == materielGroupDTO.PalletCode) != null) |
| | | { |
| | | return WebResponseContent.Instance.Error("该æçå·²ç»ç»è¿ç"); |
| | | } |
| | | |
| | |
| | | { |
| | | if (stockInfo == null) |
| | | { |
| | | stockInfo = new Dt_StockInfo() { PalletType = PalletTypeEnum.Empty.ObjToInt(), StockStatus = StockStatusEmun.ç»çæå.ObjToInt(), PalletCode = materielGroupDTO.PalletCode,LocationType=1 }; |
| | | stockInfo = new Dt_StockInfo() { PalletType = PalletTypeEnum.Empty.ObjToInt(), StockStatus = StockStatusEmun.ç»çæå.ObjToInt(), PalletCode = materielGroupDTO.PalletCode, LocationType = materielGroupDTO.WarehouseCode.ObjToInt() }; |
| | | stockInfo.Details = new List<Dt_StockInfoDetail>(); |
| | | } |
| | | else |
| | | { |
| | | stockInfo.PalletType = PalletTypeEnum.Empty.ObjToInt(); |
| | | stockInfo.StockStatus = StockStatusEmun.ç»çæå.ObjToInt(); |
| | | stockInfo.LocationType = materielGroupDTO.WarehouseCode.ObjToInt(); |
| | | } |
| | | |
| | | _unitOfWorkManage.BeginTran(); |
| | |
| | | { |
| | | resultDTO.UniqueUnit = ""; |
| | | } |
| | | var validDetails = _stockDetailRepository.Db.Queryable<Dt_StockInfoDetail>().Where(s => s.OrderNo == orderNo).ToList(); |
| | | resultDTO.StockSumQuantity = orderDetail.Details.Sum(d => d.OrderQuantity); |
| | | resultDTO.StockCount = orderDetail.Details.Count; |
| | | if (validDetails.Any()) |
| | | { |
| | | resultDTO.StockSumQuantity -= validDetails.Sum(d => d.StockQuantity); |
| | | // æç»è®°å½æ°ï¼ç¬¦åæ¡ä»¶çææè®°å½æ¡æ° |
| | | resultDTO.StockCount -= validDetails.Count; |
| | | } |
| | | var inbound = _inboundOrderRepository.Db.Queryable<Dt_InboundOrder>().Where(x => x.InboundOrderNo == orderNo); |
| | | var inboundDetails = _inboundOrderDetailRepository.Db.Queryable<Dt_InboundOrderDetail>().Where(x => x.OrderId == inbound.First().Id).ToList(); |
| | | resultDTO.StockSumQuantity = inboundDetails.Where(x => x.ReceiptQuantity == 0).Sum(x => x.OrderQuantity); |
| | | resultDTO.StockCount = inboundDetails.Where(x => x.ReceiptQuantity == 0).Count(); |
| | | //var validDetails = _stockDetailRepository.Db.Queryable<Dt_StockInfoDetail>().Where(s => s.OrderNo == orderNo).ToList(); |
| | | //resultDTO.StockSumQuantity = orderDetail.Details.Sum(d => d.OrderQuantity); |
| | | //resultDTO.StockCount = orderDetail.Details.Count; |
| | | //if (validDetails.Any()) |
| | | //{ |
| | | // resultDTO.StockSumQuantity -= validDetails.Sum(d => d.StockQuantity); |
| | | // // æç»è®°å½æ°ï¼ç¬¦åæ¡ä»¶çææè®°å½æ¡æ° |
| | | // resultDTO.StockCount -= validDetails.Count; |
| | | //} |
| | | return content.OK("", resultDTO); |
| | | } |
| | | catch (Exception ex) |
| | |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ¤éç»çï¼æºè½è¯å«è¾å
¥æ¯æçå·ææ¡ç ï¼ |
| | | /// </summary> |
| | | /// <param name="code">æçå·ææ¡ç </param> |
| | | /// <returns>æä½ç»æ</returns> |
| | | public WebResponseContent UndoPalletGroup(string code) |
| | | { |
| | | if (string.IsNullOrWhiteSpace(code)) |
| | | { |
| | | return WebResponseContent.Instance.Error("æçå·ææ¡ç ä¸è½ä¸ºç©º"); |
| | | } |
| | | |
| | | try |
| | | { |
| | | _unitOfWorkManage.BeginTran(); |
| | | |
| | | |
| | | string palletCode = null; |
| | | string barcode = null; |
| | | int stockStatus = 0; |
| | | |
| | | // 1. å
å°è¯ææçå·æ¥è¯¢ |
| | | var stockByPallet = _stockRepository.Db.Queryable<Dt_StockInfo>() |
| | | .Includes(o => o.Details) |
| | | .First(x => x.PalletCode == code |
| | | && (x.StockStatus == (int)StockStatusEmun.ç»çæå |
| | | || x.StockStatus == StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt())); |
| | | |
| | | if (stockByPallet != null) |
| | | { |
| | | // è¯å«ä¸ºæçå· |
| | | palletCode = code; |
| | | stockStatus = stockByPallet.StockStatus; |
| | | |
| | | var task = _taskRepository.Db.Queryable<Dt_Task>().Where(t => t.PalletCode == palletCode).ToList(); |
| | | if (task != null && task.Any()) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æçå· {palletCode} å卿ªå®æçä»»å¡ï¼æ æ³æ¤é"); |
| | | } |
| | | |
| | | if (stockStatus == StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt()) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æçå· {palletCode} å¤äºå
¥åºç¡®è®¤ç¶æï¼ç¦æ¢æ´æçæ¤éï¼è¯·åç¬æ¤éæ¡ç "); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | var detail = _stockDetailRepository.Db.Queryable<Dt_StockInfoDetail>().Where(d => d.Barcode == code).First(); |
| | | |
| | | if (detail != null) |
| | | { |
| | | var stockInfo = _stockRepository |
| | | .Db.Queryable<Dt_StockInfo>() |
| | | .Where(s => s.Id == detail.StockId && (s.StockStatus == (int)StockStatusEmun.ç»çæå || s.StockStatus == StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt())) |
| | | .First(); |
| | | |
| | | if (stockInfo != null) |
| | | { |
| | | barcode = code; |
| | | palletCode = stockInfo.PalletCode; |
| | | stockStatus = stockInfo.StockStatus; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error($"æªæ¾å° {code} 对åºçæçææ¡ç è®°å½"); |
| | | } |
| | | } |
| | | |
| | | // æ ¹æ®è¯å«ç»ææ§è¡æ¤éé»è¾ |
| | | if (!string.IsNullOrWhiteSpace(barcode)) |
| | | { |
| | | // ===== æ¤éæå®æ¡ç ===== |
| | | var stock = _stockRepository.Db.Queryable<Dt_StockInfo>() |
| | | .Includes(o => o.Details) |
| | | .First(x => x.PalletCode == palletCode |
| | | && (x.StockStatus == (int)StockStatusEmun.ç»çæå |
| | | || x.StockStatus == StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt())); |
| | | |
| | | if (stock == null) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°æçå· {palletCode} 对åºçåºåè®°å½"); |
| | | } |
| | | |
| | | var targetDetail = stock.Details?.FirstOrDefault(x => x.Barcode == barcode); |
| | | if (targetDetail == null) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error($"æç {palletCode} 䏿ªæ¾å°æ¡ç {barcode} çæç»è®°å½"); |
| | | } |
| | | |
| | | if (stockStatus == StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt()) |
| | | { |
| | | var totalDetails = stock.Details?.Count ?? 0; |
| | | if (totalDetails <= 1) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error($"æç {palletCode} å¤äºå
¥åºç¡®è®¤ç¶æï¼å½åä»
å©ä½æå1æ¡æç»ï¼ç¦æ¢æ¤éï¼å¿
é¡»ä¿çè³å°1æ¡åºåæç»ï¼"); |
| | | } |
| | | } |
| | | |
| | | ResetInboundOrderStatus(new List<string> { targetDetail.OrderNo }, new List<string> { targetDetail.Barcode }); |
| | | _stockDetailRepository.DeleteData(targetDetail); |
| | | |
| | | var remainingDetails = _stockDetailRepository.Db.Queryable<Dt_StockInfoDetail>() |
| | | .Where(x => x.StockId == stock.Id) |
| | | .ToList(); |
| | | |
| | | if (!remainingDetails.Any()) |
| | | { |
| | | if (stockStatus == (int)StockStatusEmun.ç»çæå) |
| | | { |
| | | ResetInboundOrderStatus(stock.Details.Select(d => d.OrderNo).Distinct().ToList()); |
| | | _stockRepository.DeleteData(stock); |
| | | } |
| | | _unitOfWorkManage.CommitTran(); |
| | | return WebResponseContent.Instance.OK($"æ¡ç {barcode} æ¤éæåï¼æçæ å©ä½æç»ï¼å·²éç½®å
³èå
¥åºåç¶æ"); |
| | | } |
| | | |
| | | _unitOfWorkManage.CommitTran(); |
| | | return WebResponseContent.Instance.OK($"æ¡ç {barcode} æ¤éæåï¼æç仿å©ä½æç»"); |
| | | } |
| | | else |
| | | { |
| | | var stock = _stockRepository.Db.Queryable<Dt_StockInfo>() |
| | | .Includes(o => o.Details) |
| | | .First(x => x.PalletCode == palletCode |
| | | && (x.StockStatus == (int)StockStatusEmun.ç»çæå |
| | | || x.StockStatus == StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt())); |
| | | |
| | | if (stock == null) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°æçå· {palletCode} 对åºçåºåè®°å½"); |
| | | } |
| | | |
| | | if (stock.Details == null || !stock.Details.Any()) |
| | | { |
| | | _stockRepository.DeleteData(stock); |
| | | _unitOfWorkManage.CommitTran(); |
| | | return WebResponseContent.Instance.OK("æçæ æç»è®°å½ï¼å·²ç´æ¥å 餿çä¸»æ°æ®"); |
| | | } |
| | | |
| | | var relatedOrderNos = stock.Details.Select(d => d.OrderNo).Distinct().ToList(); |
| | | if (!relatedOrderNos.Any()) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error("åºåæç»æªå
³èä»»ä½å
¥åºåå·ï¼æ æ³å®ææ¤é"); |
| | | } |
| | | |
| | | ResetInboundOrderStatus(relatedOrderNos, stock.Details.Select(d => d.Barcode).ToList()); |
| | | _stockDetailRepository.DeleteData(stock.Details); |
| | | _stockRepository.DeleteData(stock); |
| | | |
| | | _unitOfWorkManage.CommitTran(); |
| | | return WebResponseContent.Instance.OK("æçæ¤éæåï¼å·²éç½®å
³èå
¥åºååæç»ç¶æ"); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error($"æçæ¤é失败ï¼{ex.Message}"); |
| | | } |
| | | } |
| | | |
| | | |
| | | private void ResetInboundOrderStatus(List<string> orderNos, List<string> barcodes = null) |
| | | { |
| | | foreach (var orderNo in orderNos) |
| | | { |
| | | var inboundOrder = _inboundOrderRepository.Db.Queryable<Dt_InboundOrder>() |
| | | .Includes(x => x.Details) |
| | | .First(x => x.InboundOrderNo == orderNo); |
| | | |
| | | if (inboundOrder == null) continue; |
| | | |
| | | bool isSingleBarcode = barcodes != null && barcodes.Count == 1; |
| | | if (!isSingleBarcode) |
| | | { |
| | | // éå个æ¡ç ï¼æ´å/å¤ä¸ªæ¡ç ï¼ï¼éç½®ä¸»è¡¨ç¶æä¸º0 |
| | | inboundOrder.OrderStatus = 0; |
| | | _inboundOrderRepository.UpdateData(inboundOrder); |
| | | } |
| | | |
| | | // éç½®å
¥åºåæç»ç¶æ |
| | | if (inboundOrder.Details == null || !inboundOrder.Details.Any()) continue; |
| | | |
| | | var targetDetails = barcodes == null |
| | | ? inboundOrder.Details.ToList() // ä¸ä¼ æ¡ç åéç½®æ´åæç» |
| | | : inboundOrder.Details.Where(d => barcodes.Contains(d.Barcode)).ToList(); |
| | | |
| | | foreach (var detail in targetDetails) |
| | | { |
| | | detail.ReceiptQuantity = 0; |
| | | detail.OrderDetailStatus = 0; |
| | | if(inboundOrder.BusinessType == "11") |
| | | { |
| | | detail.WarehouseCode = ""; |
| | | } |
| | | _inboundOrderDetailRepository.UpdateData(detail); |
| | | } |
| | | } |
| | | } |
| | | |
| | | 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>(); |
| | | foreach (var item in orderbyDic) |
| | | { |
| | | OrderByModel orderByModel = new() |
| | | { |
| | | FieldName = item.Key, |
| | | OrderByType = item.Value |
| | | }; |
| | | orderByModels.Add(orderByModel); |
| | | } |
| | | ISugarQueryable<Dt_InboundOrder> sugarQueryable1 = BaseDal.Db.Queryable<Dt_InboundOrder>(); |
| | | |
| | | int totalCount = 0; |
| | | List<SearchParameters> searchParametersList = new List<SearchParameters>(); |
| | | if (!string.IsNullOrEmpty(options.Wheres)) |
| | | { |
| | | try |
| | | { |
| | | searchParametersList = options.Wheres.DeserializeObject<List<SearchParameters>>(); |
| | | if (searchParametersList.Count > 0) |
| | | { |
| | | |
| | | SearchParameters? searchParameters = searchParametersList.FirstOrDefault(x => x.Name == nameof(Dt_InboundOrder.InboundOrderNo).FirstLetterToLower()); |
| | | if (searchParameters != null) |
| | | { |
| | | sugarQueryable1 = sugarQueryable1.Where(x => x.InboundOrderNo.Contains(searchParameters.Value.ToString()) |
| | | || x.UpperOrderNo.Contains(searchParameters.Value.ToString()) || |
| | | x.Details.Any(d => d.Barcode == searchParameters.Value.ToString()) || |
| | | x.Details.Any(d => d.OutBoxbarcodes == searchParameters.Value.ToString())); |
| | | } |
| | | searchParameters = searchParametersList.FirstOrDefault(x => x.Name == nameof(Dt_InboundOrder.OrderType).FirstLetterToLower()); |
| | | if (searchParameters != null) |
| | | { |
| | | sugarQueryable1 = sugarQueryable1.Where(x => x.OrderType.Equals(searchParameters.Value.ToString())); |
| | | } |
| | | |
| | | var detailMaterielCode = searchParametersList.FirstOrDefault(x => x.Name == "materielCode"); |
| | | if(detailMaterielCode!=null && !string.IsNullOrEmpty(detailMaterielCode.Value?.ToString())) |
| | | { |
| | | string materielCode = detailMaterielCode.Value.ToString().Trim(); |
| | | sugarQueryable1 = sugarQueryable1.Where(x => x.Details.Any(d => d.MaterielCode.Contains(materielCode))); |
| | | |
| | | } |
| | | |
| | | //var dataList = sugarQueryable1.ToPageList(options.Page, options.Rows, ref totalCount); |
| | | //return new PageGridData<Dt_InboundOrder>(totalCount, dataList); |
| | | } |
| | | options.Filter = searchParametersList; |
| | | } |
| | | catch { } |
| | | } |
| | | var data = sugarQueryable1 |
| | | .WhereIF(!wheres.IsNullOrEmpty(), wheres) |
| | | .Where(x => x.OrderType == 0) |
| | | .OrderBy(orderByModels).Includes(x => x.Details) |
| | | .ToPageList(options.Page, options.Rows, ref totalCount); |
| | | |
| | | return new PageGridData<Dt_InboundOrder>(totalCount, data); |
| | | } |
| | | |
| | | //public override PageGridData<Dt_InboundOrder> GetPageData(PageDataOptions options) |
| | | //{ |
| | | // //var pageGridData = base.GetPageData(options); |
| | | |
| | | // ISugarQueryable<Dt_InboundOrder> sugarQueryable1 = BaseDal.Db.Queryable<Dt_InboundOrder>(); |
| | | // if (!string.IsNullOrEmpty(options.Wheres)) |
| | | // { |
| | | |
| | | // List<SearchParameters> searchParametersList = options.Wheres.DeserializeObject<List<SearchParameters>>(); |
| | | // int totalCount = 0; |
| | | // if (searchParametersList.Count > 0) |
| | | // { |
| | | |
| | | // SearchParameters? searchParameters = searchParametersList.FirstOrDefault(x => x.Name == nameof(Dt_InboundOrder.InboundOrderNo).FirstLetterToLower()); |
| | | // if (searchParameters != null) |
| | | // { |
| | | // sugarQueryable1 = sugarQueryable1.Where(x => x.InboundOrderNo.Contains(searchParameters.Value.ToString()) |
| | | // || x.UpperOrderNo.Contains(searchParameters.Value.ToString()) || |
| | | // x.Details.Any(d => d.Barcode == searchParameters.Value.ToString())); |
| | | // } |
| | | // searchParameters = searchParametersList.FirstOrDefault(x => x.Name == nameof(Dt_InboundOrder.OrderType).FirstLetterToLower()); |
| | | // if (searchParameters != null) |
| | | // { |
| | | // sugarQueryable1 = sugarQueryable1.Where(x => x.OrderType.Equals(searchParameters.Value.ToString())); |
| | | // } |
| | | // var dataList = sugarQueryable1.ToPageList(options.Page, options.Rows, ref totalCount); |
| | | // return new PageGridData<Dt_InboundOrder>(totalCount, dataList); |
| | | // } |
| | | // } |
| | | // 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); |
| | | } |
| | | |
| | | public WebResponseContent GetLocationType(string code) |
| | | { |
| | | var warehouseAreaName = _warehouseAreaRepository.QueryFirst(x => x.Code == code); |
| | | if(string.IsNullOrWhiteSpace(warehouseAreaName.ToString())) |
| | | { |
| | | return WebResponseContent.Instance.Error("æªæ¾å°ä»åºåç§°"); |
| | | } |
| | | var locationTypeDesc = _locationTypeRepository.Db.Queryable<Dt_LocationType>().Where(x => string.Equals(x.LocationTypeDesc, warehouseAreaName.Name, StringComparison.OrdinalIgnoreCase)).First(); |
| | | |
| | | return WebResponseContent.Instance.OK(data:locationTypeDesc.LocationType); |
| | | } |
| | | |
| | | public WebResponseContent HandCloseOrder(List<string> orderNos) |
| | | { |
| | | try |
| | | { |
| | | foreach (var orderNo in orderNos) |
| | | { |
| | | var inbound = _inboundOrderRepository.QueryFirst(x => x.InboundOrderNo == orderNo); |
| | | var outbound = _outboundOrderRepository.QueryFirst(x=>x.OrderNo == orderNo); |
| | | |
| | | if (inbound != null) |
| | | { |
| | | if (inbound.OrderStatus != (int)InOrderStatusEnum.æªå¼å§ && inbound.OrderStatus != (int)InOrderStatusEnum.å
¥åºä¸) |
| | | { |
| | | return WebResponseContent.Instance.Error($"è¯¥åæ®ç¶æä¸å¯ä»¥å
³é"); |
| | | } |
| | | inbound.OrderStatus = (int)InOrderStatusEnum.æå¨å
³é; |
| | | inbound.Operator = App.User.UserName; |
| | | _inboundOrderRepository.UpdateData(inbound); |
| | | |
| | | var inboundItems = _inboundOrderDetailRepository.QueryData(x => x.OrderId == inbound.Id); |
| | | if(inboundItems.FirstOrDefault().OrderDetailStatus == (int)OrderDetailStatusEnum.New) |
| | | { |
| | | foreach (var item in inboundItems) |
| | | { |
| | | item.OrderDetailStatus = (int)InOrderStatusEnum.æå¨å
³é; |
| | | item.Modifier = App.User.UserName; |
| | | BaseDal.Db.Updateable<Dt_InboundOrderDetail>(item).ExecuteCommand(); |
| | | } |
| | | } |
| | | } |
| | | else if (outbound != null) |
| | | { |
| | | if(outbound.OrderStatus ==(int)OutOrderStatusEnum.åºåºå®æ) |
| | | { |
| | | return WebResponseContent.Instance.Error($"è¯¥åæ®ç¶æä¸å¯ä»¥å
³é"); |
| | | } |
| | | if(outbound.OrderStatus == (int)OutOrderStatusEnum.åºåºä¸) |
| | | { |
| | | var outboundDetails = _outboundOrderDetailRepository.QueryData(x => x.OrderId == outbound.Id); |
| | | if (outboundDetails == null) |
| | | { |
| | | return WebResponseContent.Instance.Error("è¯¥åæ®ç¶æä¸è½å
³é"); |
| | | } |
| | | var detailStatus = outboundDetails.All(x => x.LockQuantity == x.OverOutQuantity); |
| | | if (!detailStatus) |
| | | { |
| | | return WebResponseContent.Instance.Error("è¯¥åæ®ææ£å¨åºåºçç©æï¼ä¸è½å
³é"); |
| | | } |
| | | } |
| | | outbound.OrderStatus = (int)OutOrderStatusEnum.å
³é; |
| | | outbound.Operator = App.User.UserName; |
| | | _outboundOrderRepository.UpdateData(outbound); |
| | | |
| | | var outboundItems = BaseDal.Db.Queryable<Dt_OutboundOrderDetail>().Where(x => x.OrderId == outbound.Id).ToList(); |
| | | if(outboundItems.FirstOrDefault().OrderDetailStatus == (int)OrderDetailStatusEnum.New) |
| | | foreach(var item in outboundItems) |
| | | { |
| | | item.OrderDetailStatus = (int)OutOrderStatusEnum.å
³é; |
| | | item.Modifier = App.User.UserName; |
| | | BaseDal.Db.Updateable<Dt_OutboundOrderDetail>(item).ExecuteCommand(); |
| | | } |
| | | } |
| | | |
| | | } |
| | | return WebResponseContent.Instance.OK($"åæ®å
³éæå"); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | return WebResponseContent.Instance.Error(e.Message); |
| | | } |
| | | } |
| | | } |
| | | } |