From 67c93bff19a49325a97f5f46de0185d28d21ceac Mon Sep 17 00:00:00 2001 From: FanLian Date: Tue, 15 Aug 2023 17:04:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=BC=82=E5=B8=B8=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PDATransferSignService.cs | 32 +++++++++++++------ .../Tnb.WarehouseMgr/WmsSetSortingService.cs | 10 ++++-- .../Tnb.WarehouseMgr/WmskittingOutService.cs | 20 ++++++++++-- 3 files changed, 49 insertions(+), 13 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/PDATransferSignService.cs b/WarehouseMgr/Tnb.WarehouseMgr/PDATransferSignService.cs index 30f22cd2..1b2c9902 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/PDATransferSignService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/PDATransferSignService.cs @@ -19,11 +19,14 @@ using System.Collections.Immutable; using JNPF.Common.Core.Manager; using Tnb.WarehouseMgr.Interfaces; using Senparc.Weixin.Work.Entities; +using JNPF; +using Tnb.WarehouseMgr.Entities.Exceptions; +using JNPF.Common.Const; //using JNPF.Extras.CollectiveOAuth.Utils; namespace Tnb.WarehouseMgr { - public class PDATransferSignService : BaseWareHouseService + public class PDATransferSignService : BaseWareHouseService, IWmsPDATransferSignService { private readonly ISqlSugarClient _db; private readonly IDictionaryDataService _dictionaryDataService; @@ -148,10 +151,13 @@ namespace Tnb.WarehouseMgr [HttpPost] public async Task IsMinStorage(CancellationTokenSource? cts = default) { + if (UserManager.AsscessToken.IsNullOrWhiteSpace()) return; + var curUser = await GetUserIdentity(); + var curDb = _db.CopyNew(); try { List> dics = new List>(); - var sgs = await _db.Queryable().LeftJoin((a, b) => a.id == b.bill_id) + var sgs = await curDb.Queryable().LeftJoin((a, b) => a.id == b.bill_id) .Select((a, b) => new { sendWh = a.sendwh_id, @@ -160,7 +166,7 @@ namespace Tnb.WarehouseMgr b.box_num, }) .ToListAsync(); - var items = await _db.Queryable() + var items = await curDb.Queryable() .LeftJoin((a, b) => a.material_id == b.id) .LeftJoin((a, b, c) => b.material_id == c.id) .Where(a => sgs.Select(x => x.receiveWh).Contains(a.warehouse_id)) @@ -182,16 +188,16 @@ namespace Tnb.WarehouseMgr dics.Add(dic); } //查找符合条件的出库库位 - //var locs = await _db.Queryable().Where(it => it.is_type == ((int)EnumLocationType.存储库位).ToString() && it.wh_id == "2" && it.is_lock == 0 && it.is_use == ((int)EnumCarryStatus.空闲).ToString()).ToListAsync(); + //var locs = await curDb.Queryable().Where(it => it.is_type == ((int)EnumLocationType.存储库位).ToString() && it.wh_id == "2" && it.is_lock == 0 && it.is_use == ((int)EnumCarryStatus.空闲).ToString()).ToListAsync(); MESCreateOutstockInput input = new() { outstock = { - org_id = _userManager.User.OrganizeId, + org_id = curUser.FindFirst(ClaimConst.CLAINMORGID)?.Value, bill_date = DateTime.Now, bill_type = "28135837838101",//单据类型:自动补货单 warehouse_id = "1", - create_id= _userManager.UserId, + create_id= curUser.FindFirst(ClaimConst.CLAINMUSERID)!.Value, } }; foreach (var d in dics) @@ -208,10 +214,18 @@ namespace Tnb.WarehouseMgr } } } - catch (Exception) + catch (Exception ex) { - - throw; + 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; } } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs index 4bc01a0c..1ae618ae 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs @@ -261,9 +261,15 @@ namespace Tnb.WarehouseMgr { JNPF.Logging.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; + throw timedTaskEx; } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs index 56c37089..25cb141d 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs @@ -166,8 +166,16 @@ 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; + throw timedTaskEx; } } /// @@ -265,8 +273,16 @@ 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; + throw timedTaskEx; } finally {