增加异常处理
This commit is contained in:
@@ -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<Dictionary<string, object>> dics = new List<Dictionary<string, object>>();
|
||||
var sgs = await _db.Queryable<WmsMinstrategyH>().LeftJoin<WmsMinstrategyD>((a, b) => a.id == b.bill_id)
|
||||
var sgs = await curDb.Queryable<WmsMinstrategyH>().LeftJoin<WmsMinstrategyD>((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<WmsCarryCode>()
|
||||
var items = await curDb.Queryable<WmsCarryCode>()
|
||||
.LeftJoin<BasMaterialSendWarehouse>((a, b) => a.material_id == b.id)
|
||||
.LeftJoin<BasMaterial>((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<BasLocation>().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<BasLocation>().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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user