完善日志 bug处理
This commit is contained in:
@@ -31,6 +31,7 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
private const string BizTypeId = "26191496816421";
|
||||
private readonly ISqlSugarClient _db;
|
||||
private ISqlSugarClient _dbScanInStockByRedis;
|
||||
private readonly IDictionaryDataService _dictionaryDataService;
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly IWareHouseService _wareHouseService;
|
||||
@@ -47,6 +48,7 @@ namespace Tnb.WarehouseMgr
|
||||
)
|
||||
{
|
||||
_db = repository.AsSugarClient();
|
||||
_dbScanInStockByRedis = repository.AsSugarClient();
|
||||
_dictionaryDataService = dictionaryDataService;
|
||||
_userManager = userManager;
|
||||
_billRullService = billRullService;
|
||||
@@ -213,7 +215,7 @@ namespace Tnb.WarehouseMgr
|
||||
points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
|
||||
if (points.Count <= 2)
|
||||
{
|
||||
throw new AppFriendlyException("该路径不存在", 500);
|
||||
throw new AppFriendlyException($"sPoint {sPoint.point_code} ePoint{ePoint.point_code}该路径不存在", 500);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -353,7 +355,7 @@ namespace Tnb.WarehouseMgr
|
||||
Logger.LogInformation($"【ScanInStockByRedis】执行入库 {JsonConvert.SerializeObject(input)}");
|
||||
try
|
||||
{
|
||||
await _db.Ado.BeginTranAsync();
|
||||
await _dbScanInStockByRedis.Ado.BeginTranAsync();
|
||||
WmsInstockCode? item = null;
|
||||
BasMaterial? mat = null;
|
||||
WmsCarryH? carry = null;
|
||||
@@ -369,19 +371,19 @@ namespace Tnb.WarehouseMgr
|
||||
throw new AppFriendlyException("请输入入库数量", 500);
|
||||
}
|
||||
carryCode = item.barcode;
|
||||
carry = await _db.Queryable<WmsCarryH>().FirstAsync(it => it.carry_code == carryCode);
|
||||
carry = await _dbScanInStockByRedis.Queryable<WmsCarryH>().FirstAsync(it => it.carry_code == carryCode);
|
||||
if (carry == null)
|
||||
{
|
||||
throw new AppFriendlyException("载具有误", 500);
|
||||
}
|
||||
|
||||
mat = await _db.Queryable<BasMaterial>().FirstAsync(it => it.code == item.material_code);
|
||||
mat = await _dbScanInStockByRedis.Queryable<BasMaterial>().FirstAsync(it => it.code == item.material_code);
|
||||
if (mat == null)
|
||||
{
|
||||
throw new AppFriendlyException("物料有误", 500);
|
||||
}
|
||||
|
||||
loc = await _db.Queryable<BasLocation>().FirstAsync(it => it.location_code == item.extras);
|
||||
loc = await _dbScanInStockByRedis.Queryable<BasLocation>().FirstAsync(it => it.location_code == item.extras);
|
||||
if (loc == null)
|
||||
{
|
||||
throw new AppFriendlyException("库位有误", 500);
|
||||
@@ -472,13 +474,13 @@ namespace Tnb.WarehouseMgr
|
||||
};
|
||||
}
|
||||
|
||||
_ = await _db.Insertable(instock).ExecuteCommandAsync();
|
||||
_ = await _dbScanInStockByRedis.Insertable(instock).ExecuteCommandAsync();
|
||||
Logger.LogInformation($"【ScanInStockByRedis】插入WmsInstockH {JsonConvert.SerializeObject(instock)}");
|
||||
_ = await _db.Insertable(instockDs).ExecuteCommandAsync();
|
||||
_ = await _dbScanInStockByRedis.Insertable(instockDs).ExecuteCommandAsync();
|
||||
Logger.LogInformation($"【ScanInStockByRedis】插入WmsInstockD {JsonConvert.SerializeObject(instockDs)}");
|
||||
if (instockCode != null)
|
||||
{
|
||||
_ = await _db.Insertable(instockCode).ExecuteCommandAsync();
|
||||
_ = await _dbScanInStockByRedis.Insertable(instockCode).ExecuteCommandAsync();
|
||||
Logger.LogInformation($"【ScanInStockByRedis】插入WmsInstockCode {JsonConvert.SerializeObject(instockCode)}");
|
||||
}
|
||||
|
||||
@@ -488,16 +490,16 @@ namespace Tnb.WarehouseMgr
|
||||
WmsPointH ePoint = new();
|
||||
if (endLocations?.Count > 0)
|
||||
{
|
||||
BasLocation eloc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == endLocations[0].id);
|
||||
BasLocation eloc = await _dbScanInStockByRedis.Queryable<BasLocation>().SingleAsync(it => it.id == endLocations[0].id);
|
||||
bool isMatch = await IsCarryAndLocationMatchByCarryStd(carry, eloc);
|
||||
if (!isMatch)
|
||||
{
|
||||
throw new AppFriendlyException("库位与载具规格不匹配", 500);
|
||||
}
|
||||
|
||||
ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == endLocations[0].id);
|
||||
ePoint = await _dbScanInStockByRedis.Queryable<WmsPointH>().FirstAsync(it => it.location_id == endLocations[0].id);
|
||||
}
|
||||
sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == loc.id);
|
||||
sPoint = await _dbScanInStockByRedis.Queryable<WmsPointH>().FirstAsync(it => it.location_id == loc.id);
|
||||
|
||||
Logger.LogInformation($"【ScanInStockByRedis】sPoint:{JsonConvert.SerializeObject(sPoint)} ePoint:{JsonConvert.SerializeObject(ePoint)}");
|
||||
if (sPoint != null && ePoint != null)
|
||||
@@ -509,7 +511,7 @@ namespace Tnb.WarehouseMgr
|
||||
Logger.LogInformation($"【ScanInStockByRedis】 路径点数量为:{points.Count}");
|
||||
if (points.Count <= 2)
|
||||
{
|
||||
throw new AppFriendlyException("该路径不存在", 500);
|
||||
throw new AppFriendlyException($"sPoint {sPoint.point_code} ePoint{ePoint.point_code}该路径不存在", 500);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -615,22 +617,28 @@ namespace Tnb.WarehouseMgr
|
||||
await _wareHouseService.GenInStockTaskHandleAfter(preTaskUpInput,
|
||||
it => new WmsCarryH { carry_code = instock!.carry_code!, is_lock = 1, carry_status = ((int)EnumCarryStatus.占用).ToString(), location_id = preTaskUpInput.CarryStartLocationId, location_code = preTaskUpInput.CarryStartLocationCode },
|
||||
it => new BasLocation { is_lock = 1 });
|
||||
_ = await _db.Updateable<WmsInstockD>().SetColumns(it => new WmsInstockD { line_status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => instockCode.bill_d_id == it.id).ExecuteCommandAsync();
|
||||
_ = await _db.Updateable<WmsInstockH>().SetColumns(it => new WmsInstockH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == instock!.id).ExecuteCommandAsync();
|
||||
_ = await _dbScanInStockByRedis.Updateable<WmsInstockD>().SetColumns(it => new WmsInstockD { line_status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => instockCode.bill_d_id == it.id).ExecuteCommandAsync();
|
||||
_ = await _dbScanInStockByRedis.Updateable<WmsInstockH>().SetColumns(it => new WmsInstockH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == instock!.id).ExecuteCommandAsync();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
await _db.Ado.CommitTranAsync();
|
||||
await _dbScanInStockByRedis.Ado.CommitTranAsync();
|
||||
}
|
||||
catch (AggregateException ex)
|
||||
{
|
||||
Console.WriteLine("【ScanInStockByRedis】 AggregateException" + ex.Message);
|
||||
_dbScanInStockByRedis = _dbScanInStockByRedis.CopyNew();
|
||||
await _dbScanInStockByRedis.Ado.RollbackTranAsync();
|
||||
throw;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
await _dbScanInStockByRedis.Ado.RollbackTranAsync();
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
_ = InvokeGenPretaskExcute();
|
||||
}
|
||||
return Task.FromResult(true);
|
||||
|
||||
Reference in New Issue
Block a user