| | |
| | | return webResponse.Error($"æ¹å·ã{batchNo}ã已质æ£å
¥åº"); |
| | | List<Dt_InventoryInfo> _InventoryInfos = _inventoryInfoRepository.QueryData(x => x.BatchNo == batchNo && x.StockStatus == StockStatusEmun.å·²å
¥åº.ObjToInt()).OrderByDescending(x => x.InDate).Take(qty).ToList(); |
| | | if (_InventoryInfos.Count < 1) return webResponse.Error($"æªæ¾å°æ¹å·ã{batchNo}ãçåºå"); |
| | | Dt_LocationInfo locationInfo = _basicRepository.LocationInfoRepository.QueryFirst(x => x.LocationCode == _InventoryInfos.First().LocationCode); |
| | | List<Dt_LocationInfo> locationInfos = _basicRepository.LocationInfoRepository.QueryData(x => _InventoryInfos.Select(x => x.LocationCode).ToList().Contains(x.LocationCode)); |
| | | List<Dt_Task> tasks = new List<Dt_Task>(); |
| | | List<Dt_OutStockLockInfo> OutStockLockInfos = new List<Dt_OutStockLockInfo>(); |
| | | #region çæè´¨æ£åºåºå |
| | |
| | | #endregion |
| | | foreach (var item in _InventoryInfos) |
| | | { |
| | | var locationInfo = locationInfos.First(x => x.LocationCode == item.LocationCode); |
| | | orderDetail.MaterielCode = item.MaterielCode; |
| | | orderDetail.MaterielName = item.MaterielName; |
| | | orderDetail.OrderQuantity += item.StockQuantity; |
| | |
| | | Grade = 0, |
| | | PalletCode = item.PalletCode, |
| | | SourceIsPickPlace = item.SerialNumber == locationInfo.MaxQty, |
| | | NextAddress = "1005", |
| | | NextAddress = "1008", |
| | | Roadway = "SC01", |
| | | SourceAddress = item.LocationCode, |
| | | TargetAddress = "1005", |
| | | TargetAddress = "1008", |
| | | TaskState = OutTaskStatusEnum.OutNew.ObjToInt(), |
| | | TaskType = TaskTypeEnum.OutQuality.ObjToInt(), |
| | | TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)) |
| | |
| | | OutStockLockInfos.Add(outStockLockInfo); |
| | | #endregion |
| | | } |
| | | |
| | | bool CreateQCIn = AppSettings.app(nameof(CreateQCIn)).ObjToBool(); |
| | | #region çæè´¨æ£å
¥åºå |
| | | Dt_InboundOrderDetail inboundOrderDetail = new Dt_InboundOrderDetail() |
| | | { |
| | |
| | | BaseDal.AddData(tasks); |
| | | _outboundService.OutboundOrderService.Repository.Db.InsertNav(outboundOrder).Include(x => x.Details).ExecuteCommand(); |
| | | _outboundService.OutboundStockLockInfoService.Repository.AddData(OutStockLockInfos); |
| | | _inboundService.InbounOrderService.Repository.Db.InsertNav(inboundOrder).Include(x => x.Details).ExecuteCommand(); |
| | | if (CreateQCIn) _inboundService.InbounOrderService.Repository.Db.InsertNav(inboundOrder).Include(x => x.Details).ExecuteCommand(); |
| | | _inventoryInfoRepository.UpdateData(_InventoryInfos); |
| | | _inventoryBatchRepository.UpdateData(inventory_Batch); |
| | | #region ä¸åä»»å¡ç»WCS |
| | |
| | | if (inventoryInfo == null) throw new Exception("æªæ¾å°æçä¿¡æ¯"); |
| | | if (inventoryInfo.StockStatus != StockStatusEmun.ç»çæå.ObjToInt() && inventoryInfo.StockStatus != StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt() && inventoryInfo.StockStatus != StockStatusEmun.å
¥åºä¸.ObjToInt()) |
| | | throw new Exception($"æçéå
¥åºä¸,ä¸å¯ä¿®æ¹æ°é"); |
| | | Dt_InboundOrderDetail orderDetail = _inboundService.InboundOrderDetailService.Repository.QueryFirst(x => x.BatchNo == inventoryInfo.BatchNo); |
| | | //Dt_InboundOrderDetail orderDetail = _inboundService.InboundOrderDetailService.Repository.QueryFirst(x => x.BatchNo == inventoryInfo.BatchNo); |
| | | var StockQty = inventoryInfo.StockQuantity; |
| | | inventoryInfo.StockQuantity = qty; |
| | | inventoryInfo.BoxQuantity = qty % 8 > 0 ? qty / 8 + 1 : qty / 8; |
| | | if (orderDetail != null) |
| | | { |
| | | orderDetail.ReceiptQuantity -= StockQty - qty; |
| | | _inboundService.InboundOrderDetailService.Repository.UpdateData(orderDetail); |
| | | } |
| | | //if (orderDetail != null) |
| | | //{ |
| | | // orderDetail.ReceiptQuantity -= StockQty - qty; |
| | | // _inboundService.InboundOrderDetailService.Repository.UpdateData(orderDetail); |
| | | //} |
| | | _inventoryInfoRepository.UpdateData(inventoryInfo); |
| | | return webResponseContent.OK(); |
| | | } |
| | |
| | | return webResponseContent.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | public override WebResponseContent UpdateData(SaveModel saveModel) |
| | | { |
| | | WebResponseContent webResponseContent = new WebResponseContent(); |
| | | try |
| | | { |
| | | Dt_Task dt_Task = BaseDal.QueryFirst(x => x.TaskId == saveModel.MainData["taskId"].ObjToInt()); |
| | | string newBarcode = saveModel.MainData["palletCode"].ToString(); |
| | | if (TaskEnumHelper.GetTaskTypeGroup(dt_Task.TaskType) != TaskTypeGroup.InboundGroup) |
| | | throw new Exception($"åªå¯ä¿®æ¹å
¥åºä»»å¡,å¦éä¿®æ¹å
¶ä»ä»»å¡ç±»å请è系管çåï¼"); |
| | | Dt_InventoryInfo inventoryInfo = _inventoryInfoRepository.QueryFirst(x => x.PalletCode == newBarcode); |
| | | if (inventoryInfo != null) throw new Exception($"æçå·ã{newBarcode}ãå·²åå¨åºåä¿¡æ¯ï¼"); |
| | | inventoryInfo = _inventoryInfoRepository.QueryFirst(x => x.PalletCode == dt_Task.PalletCode); |
| | | if (inventoryInfo == null) throw new Exception($"æçå·ã{dt_Task.PalletCode}ãæªæ¾å°åºåä¿¡æ¯ï¼"); |
| | | inventoryInfo.PalletCode = newBarcode; |
| | | dt_Task.PalletCode = newBarcode; |
| | | Db.Ado.BeginTran(); |
| | | WMSTaskDTO wMSTaskDTOs = _mapper.Map<WMSTaskDTO>(dt_Task); |
| | | var ResultData = HttpHelper.PostAsync(WCSInterfaceAddress.ModifyBarcode, wMSTaskDTOs.ToJson(), headers: new Dictionary<string, string>()); |
| | | if (ResultData.Result == null) throw new Exception($"WCSååºè¶
æ¶"); |
| | | WebResponseContent content = JsonConvert.DeserializeObject<WebResponseContent>(ResultData.Result); |
| | | if (content == null) throw new Exception($"WCSæ ååº"); |
| | | if (!content.Status) throw new Exception(content.Message); |
| | | BaseDal.UpdateData(dt_Task); |
| | | _inventoryInfoRepository.UpdateData(inventoryInfo); |
| | | Db.Ado.CommitTran(); |
| | | return webResponseContent.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return webResponseContent.Error(ex.Message); |
| | | } |
| | | } |
| | | public WebResponseContent ModifyBarcode(string barcode, string newBarcode) |
| | | { |
| | | WebResponseContent webResponseContent = new WebResponseContent(); |
| | |
| | | { |
| | | Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == WMStask.TaskNum && x.TaskType == WMStask.TaskType); |
| | | if (task == null) return WebResponseContent.Instance.Error("æªæ¾å°ä»»å¡ä¿¡æ¯"); |
| | | Dt_StockInfo? _StockInfo = _stockService.StockInfoService.GetStockByPalletCode(task.PalletCode); |
| | | if (_StockInfo != null) |
| | | Dt_InventoryInfo? inventoryInfo = _inventoryInfoRepository.QueryFirst(x => x.PalletCode == task.PalletCode); |
| | | if (inventoryInfo != null) |
| | | { |
| | | Dt_StockInfoDetail? detail = _StockInfo.Details.FirstOrDefault(); |
| | | if (detail != null) |
| | | Dt_InboundOrderDetail? inboundOrderDetail = _inboundService.InboundOrderDetailService.Repository.QueryFirst(x => x.BatchNo == inventoryInfo.BatchNo); |
| | | if (inboundOrderDetail != null) |
| | | { |
| | | Dt_InboundOrder dt_InboundOrder = _inboundService.InbounOrderService.GetInboundOrder(detail.OrderNo); |
| | | Dt_InboundOrderDetail? inboundOrderDetail = dt_InboundOrder.Details.FirstOrDefault(x => x.BatchNo == detail.BatchNo); |
| | | if (inboundOrderDetail != null) |
| | | { |
| | | inboundOrderDetail.ReceiptQuantity--; |
| | | _inboundService.InboundOrderDetailService.Repository.UpdateData(inboundOrderDetail); |
| | | } |
| | | _stockService.StockInfoDetailService.Repository.DeleteAndMoveIntoHty(_StockInfo.Details, OperateType.AGVå é¤); |
| | | inboundOrderDetail.ReceiptQuantity--; |
| | | _inboundService.InboundOrderDetailService.Repository.UpdateData(inboundOrderDetail); |
| | | } |
| | | _stockService.StockInfoService.Repository.DeleteAndMoveIntoHty(_StockInfo, OperateType.AGVå é¤); |
| | | _inventoryInfoRepository.DeleteAndMoveIntoHty(inventoryInfo, OperateType.AGVå é¤); |
| | | } |
| | | #region MyRegion |
| | | //Dt_StockInfo? _StockInfo = _stockService.StockInfoService.GetStockByPalletCode(task.PalletCode); |
| | | //if (_StockInfo != null) |
| | | //{ |
| | | // Dt_StockInfoDetail? detail = _StockInfo.Details.FirstOrDefault(); |
| | | // if (detail != null) |
| | | // { |
| | | // Dt_InboundOrder dt_InboundOrder = _inboundService.InbounOrderService.GetInboundOrder(detail.OrderNo); |
| | | // Dt_InboundOrderDetail? inboundOrderDetail = dt_InboundOrder.Details.FirstOrDefault(x => x.BatchNo == detail.BatchNo); |
| | | // if (inboundOrderDetail != null) |
| | | // { |
| | | // inboundOrderDetail.ReceiptQuantity--; |
| | | // _inboundService.InboundOrderDetailService.Repository.UpdateData(inboundOrderDetail); |
| | | // } |
| | | // _stockService.StockInfoDetailService.Repository.DeleteAndMoveIntoHty(_StockInfo.Details, OperateType.AGVå é¤); |
| | | // } |
| | | // _stockService.StockInfoService.Repository.DeleteAndMoveIntoHty(_StockInfo, OperateType.AGVå é¤); |
| | | //} |
| | | #endregion |
| | | BaseDal.DeleteAndMoveIntoHty(task, /*App.User.UserId == 0 ? OperateType.èªå¨å®æ :*/ OperateType.AGVå é¤); |
| | | } |
| | | catch (Exception ex) |
| | |
| | | { |
| | | Db.Ado.BeginTran(); |
| | | Dt_OutStockLockInfo? outStockLockInfo = _outboundService.OutboundStockLockInfoService.Repository.QueryFirst(x => x.TaskNum == task.TaskNum && x.PalletCode == task.PalletCode); |
| | | Dt_OutboundOrder? outboundOrder = null; |
| | | Dt_OutboundOrderDetail? outboundOrderDetail = null; |
| | | //Dt_OutboundOrder? outboundOrder = null; |
| | | //Dt_OutboundOrderDetail? outboundOrderDetail = null; |
| | | int overCount = 0; |
| | | if (outStockLockInfo != null) |
| | | { |
| | | outboundOrderDetail = _outboundService.OutboundOrderDetailService.Repository.QueryFirst(x => x.Id == outStockLockInfo.OrderDetailId); |
| | | if (outboundOrderDetail != null) |
| | | { |
| | | outboundOrder = Db.Queryable<Dt_OutboundOrder>().Where(x => x.Id == outboundOrderDetail.OrderId).Includes(x => x.Details).First(); |
| | | if (outboundOrder != null) |
| | | { |
| | | outboundOrderDetail.OverOutQuantity++; |
| | | overCount = outboundOrder.Details.Where(x => x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()).Count(); |
| | | if (outboundOrderDetail.OverOutQuantity == outboundOrderDetail.OrderQuantity) |
| | | { |
| | | var outboundOrderdetail = outboundOrder.Details.First(x => x.Id == outboundOrderDetail.Id); |
| | | outboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt(); |
| | | outboundOrderdetail.OverOutQuantity = outboundOrderDetail.OverOutQuantity; |
| | | outboundOrderdetail.OrderDetailStatus = outboundOrderDetail.OrderDetailStatus; |
| | | overCount++; |
| | | } |
| | | } |
| | | } |
| | | //outboundOrderDetail = _outboundService.OutboundOrderDetailService.Repository.QueryFirst(x => x.Id == outStockLockInfo.OrderDetailId); |
| | | //if (outboundOrderDetail != null) |
| | | //{ |
| | | // outboundOrder = Db.Queryable<Dt_OutboundOrder>().Where(x => x.Id == outboundOrderDetail.OrderId).Includes(x => x.Details).First(); |
| | | // if (outboundOrder != null) |
| | | // { |
| | | // outboundOrderDetail.OverOutQuantity += outStockLockInfo.AssignQuantity; |
| | | // overCount = outboundOrder.Details.Where(x => x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()).Count(); |
| | | // if (outboundOrderDetail.OverOutQuantity == outboundOrderDetail.OrderQuantity) |
| | | // { |
| | | // var outboundOrderdetail = outboundOrder.Details.First(x => x.Id == outboundOrderDetail.Id); |
| | | // outboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt(); |
| | | // outboundOrderdetail.OverOutQuantity = outboundOrderDetail.OverOutQuantity; |
| | | // outboundOrderdetail.OrderDetailStatus = outboundOrderDetail.OrderDetailStatus; |
| | | // overCount++; |
| | | // } |
| | | // } |
| | | //} |
| | | outStockLockInfo.Status = OutLockStockStatusEnum.åºåºå®æ.ObjToInt(); |
| | | } |
| | | if (outboundOrder != null && outboundOrder.Details.Count == overCount) |
| | | { |
| | | outboundOrder.OrderStatus = OutboundStatusEnum.åºåºå®æ.ObjToInt(); |
| | | _outboundService.OutboundOrderDetailService.Repository.DeleteAndMoveIntoHty(outboundOrder.Details, App.User.UserId == 0 ? OperateType.èªå¨å®æ : OperateType.äººå·¥å®æ); |
| | | outboundOrder.Details = null; |
| | | _outboundService.OutboundOrderService.Repository.DeleteAndMoveIntoHty(outboundOrder, App.User.UserId == 0 ? OperateType.èªå¨å®æ : OperateType.äººå·¥å®æ); |
| | | } |
| | | else |
| | | { |
| | | if (outboundOrderDetail != null) |
| | | _outboundService.OutboundOrderDetailService.Repository.UpdateData(outboundOrderDetail); |
| | | } |
| | | //if (outboundOrder != null && outboundOrder.Details.Count == overCount) |
| | | //{ |
| | | // outboundOrder.OrderStatus = OutboundStatusEnum.åºåºå®æ.ObjToInt(); |
| | | // _outboundService.OutboundOrderDetailService.Repository.DeleteAndMoveIntoHty(outboundOrder.Details, App.User.UserId == 0 ? OperateType.èªå¨å®æ : OperateType.äººå·¥å®æ); |
| | | // outboundOrder.Details = null; |
| | | // _outboundService.OutboundOrderService.Repository.DeleteAndMoveIntoHty(outboundOrder, App.User.UserId == 0 ? OperateType.èªå¨å®æ : OperateType.äººå·¥å®æ); |
| | | //} |
| | | //else |
| | | //{ |
| | | // if (outboundOrderDetail != null) |
| | | // _outboundService.OutboundOrderDetailService.Repository.UpdateData(outboundOrderDetail); |
| | | //} |
| | | BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateType.èªå¨å®æ : OperateType.äººå·¥å®æ); |
| | | if (outStockLockInfo != null) _outboundService.OutboundStockLockInfoService.Repository.UpdateData(outStockLockInfo); |
| | | Db.Ado.CommitTran(); |