| | |
| | | using WIDESEA_IRecordService; |
| | | using WIDESEA_IStockService; |
| | | using WIDESEA_Model.Models; |
| | | using WIDESEA_Model.Models.Check; |
| | | using static HslCommunication.Profinet.Knx.KnxCode; |
| | | |
| | | namespace WIDESEA_OutboundService |
| | |
| | | foreach (var detail in materielCalc.Details) |
| | | { |
| | | if (remainingToLock <= 0) break; |
| | | decimal maxLockableQty = detail.OrderQuantity - detail.OverOutQuantity - detail.LockQuantity; |
| | | decimal maxLockableQty = detail.OrderQuantity - detail.OverOutQuantity; |
| | | if (maxLockableQty <= 0) continue; |
| | | decimal currentLockQty = Math.Min(remainingToLock, maxLockableQty); |
| | | detail.LockQuantity += currentLockQty; |
| | |
| | | UpdateStockStatus(pickedDetails.Select(x => x.PalletCode).ToList(), StockStatusEmun.åºåºéå®.ObjToInt()); |
| | | UpdateLocationStatus(pickedDetails.Select(x => x.LocationCode).ToList(), LocationStatusEnum.Lock.ObjToInt()); |
| | | } |
| | | UpdateOutStockLockInfo(outStockLockInfos); |
| | | //鿣å䏿£éï¼å»æéå®è®°å½ååºï¼å次ç»çæ¶æ£é¤åæ¡ç |
| | | if (outboundOrder.OrderType != InOrderTypeEnum.ReCheck.ObjToInt()) |
| | | { |
| | | UpdateOutStockLockInfo(outStockLockInfos); |
| | | } |
| | | |
| | | if (tasks.Any()) _taskRepository.AddData(tasks); |
| | | |
| | | _unitOfWorkManage.CommitTran(); |
| | | |
| | | _unitOfWorkManage.CommitTran(); |
| | | |
| | | // 4. æé ååºï¼åºåãå
¨é¨åé
ãåãé¨ååé
ã |
| | | string responseMsg = totalActualAllocate == totalNeedAllocate |
| | |
| | | x => request.StockDetailIds.Contains(x.Id) |
| | | && x.MaterielCode == materielCalc.MaterielCode |
| | | && x.StockQuantity > 0 |
| | | && (x.Status == (int)StockStatusEmun.å
¥åºå®æ || x.Status == (int)StockStatusEmun.æå¨è§£é)); |
| | | && (x.Status == (int)StockStatusEmun.å
¥åºå®æ || x.Status == (int)StockStatusEmun.æå¨å»ç» || x.Status == (int)StockStatusEmun.æå¨è§£é || x.Status == (int)StockStatusEmun.è¿æ)); |
| | | |
| | | if (!specifiedStockDetails.Any()) |
| | | { |
| | |
| | | |
| | | List<int> stockIds = stockDetailList.GroupBy(x => x.StockId).Select(x => x.Key).ToList(); |
| | | List<Dt_StockInfo> stockInfos = _stockInfoRepository.QueryData(x => |
| | | stockIds.Contains(x.Id) && (x.StockStatus == StockStatusEmun.å
¥åºå®æ.ObjToInt() || x.StockStatus == StockStatusEmun.åºåºéå®.ObjToInt()) |
| | | stockIds.Contains(x.Id) && (x.StockStatus == StockStatusEmun.å
¥åºå®æ.ObjToInt()) |
| | | && !string.IsNullOrEmpty(x.LocationCode) && locationCodes.Contains(x.LocationCode)); |
| | | |
| | | foreach (var stockInfo in stockInfos) |
| | |
| | | decimal totalAllocatedQuantity = CalcTotalAllocatedQuantity(lockInfos, stockInfo.Id, detail.MaterielCode); |
| | | lockInfo.AssignQuantity += actualAllocatedQuantity; |
| | | lockInfo.AllocatedQuantity = totalAllocatedQuantity; |
| | | // åééå®è®°å½ä¹æ´æ°OriginalQuantity为æçæ»åºåï¼å¯éï¼ä¿ææ°æ®ä¸è´ï¼ |
| | | if (palletMaterielTotalStock > 0) |
| | | lockInfo.OriginalQuantity = palletMaterielTotalStock; |
| | | lockInfoList.Add(lockInfo); |
| | | } |
| | | else |
| | | { |
| | | // ===== æ ¸å¿ä¼å2ï¼OriginalQuantityèµå¼ä¸ºæçç©ææ»åºå ===== |
| | | decimal originalQuantity = palletMaterielTotalStock; // æ¿ä»£åæå±é¨æç»æ°é |
| | | decimal originalQuantity = palletMaterielTotalStock; |
| | | |
| | | List<string> allDetailIds = outboundOrder.Details.Where(x => |
| | | x.OrderId == outboundOrder.Id && x.MaterielCode == detail.MaterielCode |
| | |
| | | Dt_OutboundOrder outboundOrder = _outboundRepository.QueryFirst(x => x.OrderNo == orderNo); |
| | | if (outboundOrder == null) return false; |
| | | outboundOrder.OrderStatus = status; |
| | | if(outboundOrder.CreateType == OrderCreateTypeEnum.CreateInSystem.ObjToInt()) |
| | | { |
| | | outboundOrder.ReturnToMESStatus = 5; |
| | | } |
| | | _outboundRepository.UpdateData(outboundOrder); |
| | | return true; |
| | | } |
| | |
| | | // æ´ç®±åºåºæ éæå
|
| | | PerformFullOutboundOperation(stockInfo, request, lockInfo.TaskNum.GetValueOrDefault()); |
| | | |
| | | if (outboundOrder.OrderType != 0) |
| | | if (outboundOrder.OrderType == InOrderTypeEnum.InternalAllocat.ObjToInt()) |
| | | { |
| | | Dt_AllocateOrder allocateOrder = _allocateOrderRepository.QueryFirst(x => x.OrderNo == outboundOrder.OrderNo); |
| | | if (allocateOrder != null) |
| | |
| | | } |
| | | _allocateMaterialInfoRepository.AddData(allocateMaterialInfos); |
| | | } |
| | | } |
| | | else if(outboundOrder.OrderType == InOrderTypeEnum.ReCheck.ObjToInt()) |
| | | { |
| | | List<Dt_AllocateMaterialInfo> allocateMaterialInfos = new List<Dt_AllocateMaterialInfo>(); |
| | | foreach (var item in stockInfo.Details) |
| | | { |
| | | Dt_AllocateMaterialInfo allocateMaterialInfo = new Dt_AllocateMaterialInfo() |
| | | { |
| | | Barcode = item.Barcode??"", |
| | | BatchNo = item.BatchNo, |
| | | FactoryArea = item.FactoryArea, |
| | | MaterialCode = item.MaterielCode, |
| | | MaterialName = item.MaterielName, |
| | | OrderId = outboundOrder.Id, |
| | | OrderNo = outboundOrder.OrderNo, |
| | | Quantity = item.StockQuantity, |
| | | SupplyCode = item.SupplyCode??"", |
| | | Unit = item.Unit, |
| | | WarehouseCode = item.WarehouseCode??"" |
| | | }; |
| | | allocateMaterialInfos.Add(allocateMaterialInfo); |
| | | } |
| | | _allocateMaterialInfoRepository.AddData(allocateMaterialInfos); |
| | | } |
| | | |
| | | decimal allocatedQuantity = actualOutboundQuantity; |
| | |
| | | { |
| | | barcodeQuantity = item.LockQuantity - item.OverOutQuantity; |
| | | allocatedQuantity -= (item.LockQuantity - item.OverOutQuantity); |
| | | item.CurrentDeliveryQty = item.LockQuantity - item.OverOutQuantity; |
| | | item.OverOutQuantity = item.LockQuantity; |
| | | item.CurrentDeliveryQty = item.LockQuantity; |
| | | } |
| | | |
| | | updateDetails.Add(item); |
| | |
| | | |
| | | MaterialCodeReturnDTO returnDTO = returnDTOs.First(x => x.Barcode == newBarcode); |
| | | |
| | | if (outboundOrder.OrderType != 0) |
| | | if (outboundOrder.OrderType == InOrderTypeEnum.ReCheck.ObjToInt()||outboundOrder.OrderType == InOrderTypeEnum.InternalAllocat.ObjToInt()) |
| | | { |
| | | allocateMaterialInfo = new Dt_AllocateMaterialInfo() |
| | | { |
| | |
| | | { |
| | | PerformFullOutboundOperation(stockDetail, stockInfo, actualOutboundQuantity, request, beforeQuantity, lockInfo.TaskNum.GetValueOrDefault()); |
| | | |
| | | if (outboundOrder.OrderType != 0) |
| | | if (outboundOrder.OrderType == InOrderTypeEnum.ReCheck.ObjToInt() || outboundOrder.OrderType == InOrderTypeEnum.InternalAllocat.ObjToInt()) |
| | | { |
| | | allocateMaterialInfo = new Dt_AllocateMaterialInfo() |
| | | { |
| | |
| | | |
| | | } |
| | | |
| | | // 夿æ¯å¦æ¯è°æ¨å |
| | | if (outboundOrder.OrderType != 0) |
| | | // 夿æ¯å¦æ¯æºä»è°æºä»å |
| | | if ( outboundOrder.OrderType == InOrderTypeEnum.InternalAllocat.ObjToInt()) |
| | | { |
| | | Dt_AllocateOrder allocateOrder = _allocateOrderRepository.QueryFirst(x => x.OrderNo == outboundOrder.OrderNo); |
| | | if (allocateOrder != null) |
| | |
| | | _feedbackMesService.BarcodeFeedback(newBarcode); |
| | | } |
| | | |
| | | // å é¤éå®è®°å½ï¼å¦æåºåºæç»å
¨é¨å®æï¼ ä¸CalculateActualOutboundQuantityæ¹æ³é颿³¨é代ç 2é1ä½¿ç¨ |
| | | if (CheckOutboundOrderDetailCompletedByMatCode(request.OrderNo, lockInfo.MaterielCode, outboundOrderDetails.First())) |
| | | { |
| | | Func<Dt_OutStockLockInfo, bool> supWhere = x => string.IsNullOrEmpty(outboundOrderDetails.First().SupplyCode) ? true : x.SupplyCode == outboundOrderDetails.First().SupplyCode; |
| | |
| | | _outboundLockInfoRepository.DeleteAndMoveIntoHty(stockLockInfos, WIDESEA_Core.Enums.OperateTypeEnum.èªå¨å é¤); |
| | | } |
| | | } |
| | | |
| | | |
| | | // æ£æ¥åºåºåæ¯å¦å®æ |
| | | if (CheckOutboundOrderCompleted(request.OrderNo)) |
| | | { |
| | | UpdateOutboundOrderStatus(request.OrderNo, OutOrderStatusEnum.åºåºå®æ.ObjToInt()); |
| | | |
| | | if (outboundOrder.OrderType != OutOrderTypeEnum.InternalAllocat.ObjToInt()) |
| | | if (outboundOrder.OrderType != OutOrderTypeEnum.InternalAllocat.ObjToInt() && outboundOrder.CreateType!=OrderCreateTypeEnum.CreateInSystem.ObjToInt()) |
| | | { |
| | | _feedbackMesService.OutboundFeedback(outboundOrder.OrderNo); |
| | | } |
| | | } |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | { |
| | | var stock = await _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Includes(x => x.Details).Where(x => x.PalletCode == palletCode).FirstAsync(); |
| | | |
| | | Dt_Task task = _taskRepository.QueryFirst(x => x.PalletCode == palletCode); |
| | | if (task != null) |
| | | { |
| | | return WebResponseContent.Instance.Error("ä»»å¡ä¿¡æ¯å表åå¨è¯¥æççä»»å¡ä¿¡æ¯ï¼ä¸å¯å走空箱ï¼è¯·æ£æ¥ä»»å¡æ¯å¦å®æ"); |
| | | } |
| | | |
| | | if (stock == null) |
| | | { |
| | | return content.Error($"æªæ¾å°æç{palletCode}åºåä¿¡æ¯"); |
| | |
| | | } |
| | | } |
| | | |
| | | public WebResponseContent RecheckPicking(RecheckPickingDTO pickingDTO) |
| | | { |
| | | try |
| | | { |
| | | Dt_ReCheckOrder reCheckOrder = _outboundRepository.Db.Queryable<Dt_ReCheckOrder>().Where(x => x.OrderNo == pickingDTO.orderNo && x.Result == 0).First(); |
| | | if(reCheckOrder == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°è¯¥å¾
鿣çåæ®{pickingDTO.orderNo}"); |
| | | } |
| | | Dt_StockInfoDetail stockInfoDetail = _stockDetailRepository.QueryFirst(x=>x.Barcode == pickingDTO.barCode && x.Status == StockStatusEmun.æå¨å»ç».ObjToInt() ); |
| | | if(stockInfoDetail == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªå¨åºå䏿¾å°è¯¥å»ç»/é离æ¡ç {pickingDTO.barCode}"); |
| | | } |
| | | if (stockInfoDetail.MaterielCode != reCheckOrder.MaterielCode || stockInfoDetail.BatchNo != reCheckOrder.BatchNo) |
| | | { |
| | | return WebResponseContent.Instance.Error("该æ¡ç çç©æç¼ç åæ¹æ¬¡åè¯¥éæ£åä¸ç¬¦"); |
| | | } |
| | | stockInfoDetail.OrderNo = pickingDTO.orderNo; |
| | | stockInfoDetail.Status = StockStatusEmun.鿣ä¸.ObjToInt(); |
| | | var currentRemark = _outboundRepository.Db.Queryable<Dt_OutboundOrder>() |
| | | .Where(x => x.OrderNo == pickingDTO.orderNo) |
| | | .Select(x => x.Remark) |
| | | .First(); |
| | | |
| | | string newRemark; |
| | | if (string.IsNullOrWhiteSpace(currentRemark)) |
| | | { |
| | | newRemark = pickingDTO.barCode; |
| | | } |
| | | else |
| | | { |
| | | var existingCodes = currentRemark.Split(',', StringSplitOptions.RemoveEmptyEntries) |
| | | .Select(s => s.Trim()) |
| | | .ToList(); |
| | | |
| | | if (!existingCodes.Contains(pickingDTO.barCode)) |
| | | { |
| | | existingCodes.Add(pickingDTO.barCode); |
| | | newRemark = string.Join(",", existingCodes); |
| | | } |
| | | else |
| | | { |
| | | newRemark = currentRemark; |
| | | } |
| | | } |
| | | _outboundRepository.Db.Updateable<Dt_OutboundOrder>() |
| | | .SetColumns(x => x.Remark == newRemark) |
| | | .SetColumns(x=>x.OrderStatus == (int)OutOrderStatusEnum.åºåºå®æ) |
| | | .Where(x => x.OrderNo == pickingDTO.orderNo) |
| | | .ExecuteCommand(); |
| | | _stockDetailRepository.UpdateData(stockInfoDetail); |
| | | |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch(Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | } |
| | | } |