| | |
| | | using WIDESEA_DTO.Stock; |
| | | using WIDESEA_DTO.Task; |
| | | using WIDESEA_External.ERPService; |
| | | using WIDESEA_External.Model; |
| | | using WIDESEA_IBasicRepository; |
| | | using WIDESEA_IBasicService; |
| | | using WIDESEA_IInboundRepository; |
| | |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°è¯¥ä»»å¡ä¿¡æ¯"); |
| | | } |
| | | |
| | | //if (task.TaskType != TaskTypeEnum.Inbound.ObjToInt()) |
| | | //{ |
| | | // return WebResponseContent.Instance.Error($"ä»»å¡ç±»åé误"); |
| | | //} |
| | | |
| | | Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == task.PalletCode && x.WarehouseId==task.WarehouseId).Includes(x => x.Details).First(); |
| | | if (stockInfo == null) |
| | | { |
| | |
| | | LocationStatusEnum lastStatus = (LocationStatusEnum)locationInfo.LocationStatus; |
| | | locationInfo.LocationStatus = LocationStatusEnum.InStock.ObjToInt(); |
| | | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x=>x.WarehouseId== task.WarehouseId); |
| | | |
| | | stockInfo.LocationCode = locationInfo.LocationCode; |
| | | Dt_InboundOrder? inboundOrder = _inboundRepository.InboundOrderRepository.Db.Queryable<Dt_InboundOrder>().Where(x => x.InboundOrderNo == stockInfo.Details.FirstOrDefault().OrderNo).Includes(x => x.Details).First(); |
| | | List<Dt_InboundOrderDetail> inboundOrderDetails = new List<Dt_InboundOrderDetail>(); |
| | | if (stockInfo.StockStatus == StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt()) |
| | | { |
| | | //æ¨éå
¥åºå®æç»Erp |
| | | if (inboundOrder == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"对åºå
¥åºåä¸åå¨"); |
| | | } |
| | | |
| | | List<ERPInboundDetailModel> detailModels = new List<ERPInboundDetailModel>(); |
| | | |
| | | foreach (var item in stockInfo.Details) |
| | | { |
| | | Dt_InboundOrderDetail? inboundOrderDetail = inboundOrder.Details.FirstOrDefault(x => x.RowNo == item.InboundOrderRowNo); |
| | | if (inboundOrderDetail == null) |
| | | { |
| | | continue; |
| | | } |
| | | ERPInboundDetailModel detailModel = new ERPInboundDetailModel() |
| | | { |
| | | ExpiryDate = item.EffectiveDate ?? "", |
| | | LocationCode = warehouse.WarehouseCode, |
| | | MaterialsCode = item.MaterielCode, |
| | | MfgDate = item.ProductionDate ?? "", |
| | | QtyCustoms = "0", |
| | | Quantity = item.StockQuantity.ToString(), |
| | | Rack = stockInfo.LocationCode, |
| | | ReceiptCode = inboundOrder.UpperOrderNo, |
| | | ReceiptSerNo = item.InboundOrderRowNo.ToString() |
| | | }; |
| | | inboundOrderDetail.OverInQuantity += detailModel.Quantity.ObjToInt(); |
| | | if (inboundOrderDetail.OverInQuantity == inboundOrderDetail.OrderQuantity) |
| | | { |
| | | inboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt(); |
| | | } |
| | | inboundOrderDetails.Add(inboundOrderDetail); |
| | | detailModels.Add(detailModel); |
| | | } |
| | | |
| | | //å
¥åºæç»æ°å¢å®ææ°é |
| | | int newCount = inboundOrderDetails.Select(x => x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()).ToList().Count; |
| | | //å
¥åºæç»å宿æ°é |
| | | int oldCount = inboundOrder.Details.Select(x => x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()).ToList().Count; |
| | | if (inboundOrder.Details.Count == (newCount + oldCount)) |
| | | { |
| | | inboundOrder.OrderStatus = InOrderStatusEnum.å
¥åºå®æ.ObjToInt(); |
| | | } |
| | | if (!_inboundOrderService.FeedbackInboundOrder(stockInfo, inboundOrder, detailModels).Status) |
| | | { |
| | | return WebResponseContent.Instance.Error($"å
¥åºåæ¥Erp失败"); |
| | | } |
| | | } |
| | | //æµè¯æ¶å
¥åºåºåç¶æ |
| | | if (task.TaskType == TaskTypeEnum.Inbound.ObjToInt() && warehouse.WarehouseCode==WarehouseEnum.HA64.ToString()) |
| | | { |
| | |
| | | { |
| | | x.Status = StockStatusEmun.å
¥åºå®æ.ObjToInt(); |
| | | }); |
| | | stockInfo.LocationCode = locationInfo.LocationCode; |
| | | //æ¨éå
¥åºå®æç»Erp |
| | | Dt_InboundOrder? inboundOrder = _inboundRepository.InboundOrderRepository.Db.Queryable<Dt_InboundOrder>().Where(x => x.InboundOrderNo == stockInfo.Details.FirstOrDefault().OrderNo).Includes(x=>x.Details).First(); |
| | | if (inboundOrder == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"对åºå
¥åºåä¸åå¨"); |
| | | } |
| | | if (!_inboundOrderService.FeedbackInboundOrder(stockInfo, inboundOrder).Status) |
| | | { |
| | | return WebResponseContent.Instance.Error($"å
¥åºåæ¥Erp失败"); |
| | | } |
| | | _unitOfWorkManage.BeginTran(); |
| | | BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? OperateTypeEnum.äººå·¥å®æ : OperateTypeEnum.èªå¨å®æ); |
| | | _basicService.LocationInfoService.UpdateLocationStatus(locationInfo, (PalletTypeEnum)stockInfo.PalletType, LocationStatusEnum.InStock, stockInfo.WarehouseId); |
| | |
| | | _stockRepository.StockInfoDetailRepository.UpdateData(stockInfo.Details); |
| | | _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, lastStatus, LocationChangeType.InboundCompleted); |
| | | _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, stockInfo.Details, stockInfo.Details.Sum(x => x.StockQuantity), stockInfo.Details.Sum(x => x.StockQuantity), StockChangeTypeEnum.Inbound, taskNum); |
| | | _inboundRepository.InboundOrderDetailRepository.UpdateData(inboundOrderDetails); |
| | | _inboundRepository.InboundOrderRepository.UpdateData(inboundOrder); |
| | | _unitOfWorkManage.CommitTran(); |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | |
| | | { |
| | | _outboundService.OutboundOrderDetailService.Repository.UpdateData(outboundOrderDetails); |
| | | } |
| | | stockInfo.LocationCode = locationInfo.LocationCode; |
| | | stockInfo.LocationCode = ""; |
| | | stockInfo.StockStatus = StockStatusEmun.åºåºå®æ.ObjToInt(); |
| | | _stockService.StockInfoService.Repository.UpdateData(stockInfo); |
| | | int beforeStatus = locationInfo.LocationStatus; |