From 6efbf6f06610266acd5aeec6267547337b7aebb2 Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 15 Aug 2023 14:53:19 +0800 Subject: [PATCH] 1 --- .../Tnb.WarehouseMgr/WmsOutBaleService.cs | 8 ++- .../Tnb.WarehouseMgr/WmsOutStockService.cs | 16 ++++-- .../WmsPDACarryMoveInStockService.cs | 11 +++-- .../WmsPDACarryMoveOutStockService.cs | 8 ++- .../Tnb.WarehouseMgr/WmsPDADeliveryService.cs | 9 +++- .../WmsPDAEmptyInstockService.cs | 9 +++- .../WmsPDAEmptyOutstockService .cs | 12 +++-- .../Tnb.WarehouseMgr/WmskittingOutService.cs | 49 ++++++------------- 8 files changed, 72 insertions(+), 50 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutBaleService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutBaleService.cs index f63fcc9d..1c9f302f 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutBaleService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutBaleService.cs @@ -47,7 +47,9 @@ namespace Tnb.WarehouseMgr IWareHouseService wareHouseService, IUserManager userManager, IBillRullService billRullService, - IWmsCarryService wmsCarryService) + IWmsCarryService wmsCarryService, + ITaskMessageNotify taskMessageNotify + ) : base(taskMessageNotify.Writer) { _db = repository.AsSugarClient(); _runService = runService; @@ -160,6 +162,10 @@ namespace Tnb.WarehouseMgr await _db.Ado.RollbackTranAsync(); throw; } + finally + { + await Publish(nameof(IWareHouseService.GenTaskExecute)); + } return Task.FromResult(true); } public override async Task ModifyAsync(WareHouseUpInput input) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs index 3ce127dc..d5fcf14a 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs @@ -58,7 +58,8 @@ namespace Tnb.WarehouseMgr IUserManager userManager, IBillRullService billRullService, IWmsCarryMoveInStockService wmsCarryMoveInStockService, - IWmsCarryService wareCarryService) + IWmsCarryService wareCarryService, + ITaskMessageNotify taskMessageNotify) : base(taskMessageNotify.Writer) { _db = repository.AsSugarClient(); _dictionaryDataService = dictionaryDataService; @@ -281,9 +282,6 @@ namespace Tnb.WarehouseMgr } - - - await _db.Ado.CommitTranAsync(); } catch (Exception) @@ -291,6 +289,10 @@ namespace Tnb.WarehouseMgr await _db.Ado.RollbackTranAsync(); throw; } + finally + { + await Publish(nameof(IWareHouseService.GenTaskExecute)); + } return Task.FromResult(true); } @@ -551,7 +553,11 @@ namespace Tnb.WarehouseMgr isSuccessful = false; JNPF.Logging.Log.Error(ex.Message); await _db.Ado.RollbackTranAsync(); - throw ex; + throw; + } + finally + { + await Publish(nameof(IWareHouseService.GenTaskExecute)); } return isSuccessful; } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveInStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveInStockService.cs index f9251001..0dd8a177 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveInStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveInStockService.cs @@ -30,7 +30,7 @@ namespace Tnb.WarehouseMgr /// [OverideVisualDev(ModuleId)] [ServiceModule(BizTypeId)] - public class WmsPDACarryMoveInStockService : BaseWareHouseService,IPdaStroage + public class WmsPDACarryMoveInStockService : BaseWareHouseService, IPdaStroage { private const string BizTypeId = "26121988909861"; private const string ModuleId = "26476127634469"; @@ -48,7 +48,8 @@ namespace Tnb.WarehouseMgr IVisualDevService visualDevService, IWareHouseService wareHouseService, IUserManager userManager, - IBillRullService billRullService) + IBillRullService billRullService, + ITaskMessageNotify taskMessageNotify) : base(taskMessageNotify.Writer) { _db = repository.AsSugarClient(); _runService = runService; @@ -86,7 +87,7 @@ namespace Tnb.WarehouseMgr VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true); await _runService.Create(templateEntity, input); - + if (sPoint != null && ePoint != null) { var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id); @@ -155,6 +156,10 @@ namespace Tnb.WarehouseMgr await _db.Ado.RollbackTranAsync(); throw; } + finally + { + await Publish(nameof(IWareHouseService.GenTaskExecute)); + } return Task.FromResult(true); } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveOutStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveOutStockService.cs index 73c4274e..e04b6d4e 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveOutStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveOutStockService.cs @@ -45,7 +45,9 @@ namespace Tnb.WarehouseMgr IVisualDevService visualDevService, IWareHouseService wareHouseService, IUserManager userManager, - IBillRullService billRullService) + IBillRullService billRullService, + ITaskMessageNotify taskMessageNotify + ) : base(taskMessageNotify.Writer) { _db = repository.AsSugarClient(); _runService = runService; @@ -154,6 +156,10 @@ namespace Tnb.WarehouseMgr await _db.Ado.RollbackTranAsync(); throw; } + finally + { + await Publish(nameof(IWareHouseService.GenTaskExecute)); + } return Task.FromResult(true); } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDADeliveryService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDADeliveryService.cs index 335f1de7..e17b2dac 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDADeliveryService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDADeliveryService.cs @@ -50,8 +50,9 @@ namespace Tnb.WarehouseMgr IBasLocationService basLocationService, IBillRullService billRullService, IWareHouseService wareHouseService, - IUserManager userManager - ) + IUserManager userManager, + ITaskMessageNotify taskMessageNotify + ) : base(taskMessageNotify.Writer) { _db = repository.AsSugarClient(); _runService = runService; @@ -188,6 +189,10 @@ namespace Tnb.WarehouseMgr { return await Task.FromResult(false); } + finally + { + await Publish(nameof(IWareHouseService.GenTaskExecute)); + } return await Task.FromResult(true); } public override async Task ModifyAsync(WareHouseUpInput input) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyInstockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyInstockService.cs index 71b40265..91280a06 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyInstockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyInstockService.cs @@ -47,7 +47,8 @@ namespace Tnb.WarehouseMgr IVisualDevService visualDevService, IWareHouseService wareHouseService, IUserManager userManager, - IBillRullService billRullService) + IBillRullService billRullService, + ITaskMessageNotify taskMessageNotify) : base(taskMessageNotify.Writer) { _db = repository.AsSugarClient(); _runService = runService; @@ -124,7 +125,7 @@ namespace Tnb.WarehouseMgr preTask.create_time = DateTime.Now; return preTask; }).ToList(); - var isOk = await _wareHouseService.GenPreTask(preTasks,null!); + var isOk = await _wareHouseService.GenPreTask(preTasks, null!); if (isOk) { var preTaskUpInput = new GenPreTaskUpInput(); @@ -165,6 +166,10 @@ namespace Tnb.WarehouseMgr await _db.Ado.RollbackTranAsync(); throw; } + finally + { + await Publish(nameof(IWareHouseService.GenTaskExecute)); + } return Task.FromResult(true); } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyOutstockService .cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyOutstockService .cs index 1081258c..05ea05d0 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyOutstockService .cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyOutstockService .cs @@ -48,7 +48,9 @@ namespace Tnb.WarehouseMgr IVisualDevService visualDevService, IWareHouseService wareHouseService, IUserManager userManager, - IBillRullService billRullService) + IBillRullService billRullService, + ITaskMessageNotify taskMessageNotify + ) : base(taskMessageNotify.Writer) { _db = repository.AsSugarClient(); _runService = runService; @@ -76,7 +78,7 @@ namespace Tnb.WarehouseMgr var setQty = await _db.Queryable().FirstAsync(it => it.bill_code == input.data[nameof(WmsEmptyOutstockH.bill_code)].ToString()); var carrys = await _db.Queryable().LeftJoin((a, b) => a.location_id == b.id) .Where((a, b) => a.carrystd_id == input.data[nameof(WmsEmptyOutstockH.carrystd_id)].ToString() - && a.carry_status == ((int)EnumCarryStatus.空闲).ToString() && a.is_lock == 0 && b.is_lock == 0 && b.is_type == ((int)EnumLocationType.存储库位).ToString() ) + && a.carry_status == ((int)EnumCarryStatus.空闲).ToString() && a.is_lock == 0 && b.is_lock == 0 && b.is_type == ((int)EnumLocationType.存储库位).ToString()) .ToListAsync(); WmsPointH sPoint = null!; @@ -202,10 +204,14 @@ namespace Tnb.WarehouseMgr } catch (Exception ex) { - Log.Error("空载具出库错误",ex); + Log.Error("空载具出库错误", ex); await _db.Ado.RollbackTranAsync(); throw; } + finally + { + await Publish(nameof(IWareHouseService.GenTaskExecute)); + } return Task.FromResult(true); } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs index 7b603c0f..66c17f44 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs @@ -61,8 +61,9 @@ namespace Tnb.WarehouseMgr IUserManager userManager, IBillRullService billRullService, IWmsCarryService carryService, - ICacheManager cacheManager - ) + ICacheManager cacheManager, + ITaskMessageNotify taskMessageNotify + ) : base(taskMessageNotify.Writer) { _db = repository.AsSugarClient(); _warehouseService = warehouseService; @@ -70,6 +71,7 @@ namespace Tnb.WarehouseMgr _billRullService = billRullService; _carryService = carryService; _cacheManager = cacheManager; + } /// /// 齐套出库(新增状态) @@ -78,10 +80,6 @@ namespace Tnb.WarehouseMgr [HttpPost, Timed(Name = nameof(KittingOutByAdd))] public async Task KittingOutByAdd(CancellationTokenSource? cts = default) { - var aToken = await _cacheManager.GetAsync("AsscessToken"); - if (aToken.IsNullOrWhiteSpace()) return; - var curUser = await GetUserIdentity(aToken); - var curDb = _db.CopyNew(); try { @@ -135,8 +133,8 @@ namespace Tnb.WarehouseMgr setSortingH.id = SnowflakeIdHelper.NextId(); setSortingH.kittingout_id = ko.id; setSortingH.seq = ko.seq; - setSortingH.org_id = curUser.FindFirst(ClaimConst.CLAINMORGID)?.Value; - setSortingH.create_id = curUser.FindFirst(ClaimConst.CLAINMUSERID)?.Value!; + setSortingH.org_id = _userManager.User.OrganizeId; + setSortingH.create_id = _userManager.UserId; setSortingH.create_time = DateTime.Now; await curDb.Insertable(setSortingH).ExecuteCommandAsync(); @@ -164,20 +162,12 @@ namespace Tnb.WarehouseMgr catch (Exception ex) { Log.Error("齐套出库,新增时出现错误", ex); - await curDb.Ado.RollbackTranAsync(); - TimedTaskErrorInfo ei = new() - { - RequestURL = App.HttpContext?.Request?.Path, - RequestMethod = App.HttpContext?.Request?.Method, - userIdentity = curUser, - }; - var timedTaskEx = ex.ToTimedTaskException(ei); cts?.Cancel(); - throw timedTaskEx; + throw; } - finally + finally { - + await Publish(nameof(IWareHouseService.GenTaskExecute)); } } /// @@ -187,10 +177,6 @@ namespace Tnb.WarehouseMgr [HttpPost, Timed(Name = nameof(KittingOutByIsToBeShipped))] public async Task KittingOutByIsToBeShipped(CancellationTokenSource? cts = default) { - var aToken = await _cacheManager.GetAsync("AsscessToken"); - if (aToken.IsNullOrWhiteSpace()) return; - var curUser = await GetUserIdentity(aToken); - var curDb = _db.CopyNew(); try { @@ -229,7 +215,7 @@ namespace Tnb.WarehouseMgr WmsPretaskH preTask = new() { - org_id = curUser.FindFirst(ClaimConst.CLAINMORGID)?.Value, + org_id = _userManager.User.OrganizeId, startlocation_id = sPoint?.location_id!, startlocation_code = sPoint?.location_code!, endlocation_id = ePoint?.location_id!, @@ -250,7 +236,7 @@ namespace Tnb.WarehouseMgr area_code = it.Key, require_id = ko.id, require_code = ko.bill_code, - create_id = curUser.FindFirst(ClaimConst.CLAINMUSERID)?.Value!, + create_id = _userManager.UserId, create_time = DateTime.Now, source_id = ko.source_id, source_code = ko.source_code @@ -277,15 +263,12 @@ namespace Tnb.WarehouseMgr catch (Exception ex) { Log.Error("齐套出库,待配送时出现错误", ex); - TimedTaskErrorInfo ei = new() - { - RequestURL = App.HttpContext?.Request?.Path, - RequestMethod = App.HttpContext?.Request?.Method, - userIdentity = curUser, - }; - var timedTaskEx = ex.ToTimedTaskException(ei); cts?.Cancel(); - throw timedTaskEx; + throw; + } + finally + { + await Publish(nameof(IWareHouseService.GenTaskExecute)); } }