| | |
| | | using WIDESEA_Core.BaseRepository; |
| | | using WIDESEA_Core.BaseServices; |
| | | using WIDESEA_DTO.Outbound; |
| | | using WIDESEA_IBasicService; |
| | | using WIDESEA_IOutboundService; |
| | | using WIDESEA_IStockService; |
| | | using WIDESEA_Model.Models; |
| | |
| | | private readonly IStockInfoService _stockInfoService; |
| | | private readonly IStockInfoDetailService _stockInfoDetailService; |
| | | private readonly IOutStockLockInfoService _outStockLockInfoService; |
| | | private readonly IDailySequenceService _dailySequenceService; |
| | | |
| | | public SplitPackageService(IRepository<Dt_SplitPackageRecord> BaseDal, IUnitOfWorkManage unitOfWorkManage, IStockInfoService stockInfoService, IOutStockLockInfoService outStockLockInfoService, IStockInfoDetailService stockInfoDetailService) : base(BaseDal) |
| | | public SplitPackageService(IRepository<Dt_SplitPackageRecord> BaseDal, IUnitOfWorkManage unitOfWorkManage, IStockInfoService stockInfoService, IOutStockLockInfoService outStockLockInfoService, IStockInfoDetailService stockInfoDetailService, IDailySequenceService dailySequenceService) : base(BaseDal) |
| | | { |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | | _stockInfoService = stockInfoService; |
| | | _outStockLockInfoService = outStockLockInfoService; |
| | | _stockInfoDetailService = stockInfoDetailService; |
| | | _dailySequenceService = dailySequenceService; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | _unitOfWorkManage.BeginTran(); |
| | | |
| | | // 1. éªè¯åºåºéå®ä¿¡æ¯ |
| | | var lockInfo = await _stockInfoDetailService.Db.Queryable<Dt_OutStockLockInfo>() |
| | | var lockInfo = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>() |
| | | .Where(x => x.OrderNo == request.OrderNo && |
| | | x.PalletCode == request.PalletCode && |
| | | x.CurrentBarcode == request.OriginalBarcode && |
| | | x.Status == 0) |
| | | x.Status == 1) |
| | | .FirstAsync(); |
| | | |
| | | if (lockInfo == null) |
| | |
| | | .Where(x => x.Barcode == request.OriginalBarcode) |
| | | .FirstAsync(); |
| | | |
| | | var seq = await _dailySequenceService.GetNextSequenceAsync(); |
| | | // 3. çææ°æ¡ç |
| | | string newBarcode = ""; |
| | | string newBarcode = "WSLOT" + DateTime.Now.ToString("yyyyMMdd") + seq.ToString()?.PadLeft(5, '0'); |
| | | |
| | | // 4. å建æ°çåºåºéå®ä¿¡æ¯ï¼æ°æ¡ç ï¼ |
| | | var newLockInfo = new Dt_OutStockLockInfo |
| | | { |
| | | |
| | | OrderNo = lockInfo.OrderNo, |
| | | OrderDetailId = lockInfo.OrderDetailId, |
| | | BatchNo = lockInfo.BatchNo, |
| | |
| | | TaskNum = lockInfo.TaskNum, |
| | | Status = (int)OutLockStockStatusEnum.åºåºä¸, |
| | | Unit = lockInfo.Unit, |
| | | |
| | | SupplyCode = lockInfo.SupplyCode, |
| | | OrderType=lockInfo.OrderType, |
| | | CurrentBarcode = newBarcode, // æ°æ¡ç |
| | | OriginalLockQuantity = request.SplitQuantity, |
| | | IsSplitted = 1, |
| | | ParentLockId = lockInfo.Id // è®°å½ç¶çº§éå®ID |
| | | }; |
| | | await Db.Insertable(newLockInfo).ExecuteCommandAsync(); |
| | | await _outStockLockInfoService.Db.Insertable(newLockInfo).ExecuteCommandAsync(); |
| | | |
| | | // 5. æ´æ°åéå®ä¿¡æ¯çåé
æ°éï¼åå°æå
æ°éï¼ |
| | | lockInfo.AssignQuantity -= request.SplitQuantity; |
| | | await Db.Updateable(lockInfo).ExecuteCommandAsync(); |
| | | await _outStockLockInfoService.Db.Updateable(lockInfo).ExecuteCommandAsync(); |
| | | |
| | | // 6. è®°å½æå
åå²ï¼ç¨äºè¿½è¸ªï¼ |
| | | var splitHistory = new Dt_SplitPackageRecord |
| | | { |
| | | FactoryArea = lockInfo.FactoryArea, |
| | | TaskNum=lockInfo.TaskNum, |
| | | OutStockLockInfoId = lockInfo.Id, |
| | | StockId = stockDetail?.StockId ?? 0, |
| | | Operator = App.User.UserName, |
| | | IsReverted = false, |
| | | OriginalBarcode = lockInfo.CurrentBarcode, |
| | | NewBarcode = newBarcode, |
| | | SplitQty = request.SplitQuantity, |
| | |
| | | }; |
| | | await Db.Insertable(splitHistory).ExecuteCommandAsync(); |
| | | |
| | | Db.Ado.CommitTran(); |
| | | _unitOfWorkManage.CommitTran(); |
| | | |
| | | // 7. åä¼ æ°æ¡ç ç»MES |
| | | // await SendBarcodeToMES(newBarcode, request.MaterielCode, request.SplitQuantity); |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Db.Ado.RollbackTran(); |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error($"æå
失败: {ex.Message}"); |
| | | } |
| | | } |
| | |
| | | .Where(x => x.CurrentBarcode == splitPackage.NewBarcode) |
| | | .FirstAsync(); |
| | | |
| | | if (newOutStockInfo.Status == 1) |
| | | if (newOutStockInfo.Status == 2) |
| | | return WebResponseContent.Instance.Error("æ°æ¡ç å·²æ£éï¼æ æ³æ¤éæå
"); |
| | | |
| | | // è¿åååºåºè¯¦æ
æ°é |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error($"æ¤éæå
失败ï¼{ex.Message}"); |
| | | } |
| | | } |
| | |
| | | .Where(x => x.OrderNo == orderNo && |
| | | x.PalletCode == palletCode && |
| | | x.CurrentBarcode == barcode && |
| | | x.Status == 0) |
| | | x.Status == 1) |
| | | .FirstAsync(); |
| | | |
| | | if (outStockInfo == null) |
| | | return WebResponseContent.Instance .Error("æªæ¾å°å¯¹åºçåºåºä¿¡æ¯"); |
| | | |
| | | var stockDetail = await _stockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>() |
| | | .Where(x => x.Barcode == barcode) |
| | | .FirstAsync(); |
| | | //var stockDetail = await _stockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>() |
| | | // .Where(x => x.Barcode == barcode) |
| | | // .FirstAsync(); |
| | | |
| | | return WebResponseContent.Instance .OK("",new |
| | | { |
| | | MaterielCode = outStockInfo.MaterielCode, |
| | | RemainQuantity = outStockInfo.RemainQuantity, |
| | | Unit = "个" // æ ¹æ®å®é
æ
åµè·ååä½ |
| | | Unit = outStockInfo.Unit |
| | | }); |
| | | } |
| | | /// <summary> |