This commit is contained in:
alex
2023-08-15 14:53:19 +08:00
parent 386dd57782
commit 6efbf6f066
8 changed files with 72 additions and 50 deletions

View File

@@ -47,7 +47,9 @@ namespace Tnb.WarehouseMgr
IWareHouseService wareHouseService, IWareHouseService wareHouseService,
IUserManager userManager, IUserManager userManager,
IBillRullService billRullService, IBillRullService billRullService,
IWmsCarryService wmsCarryService) IWmsCarryService wmsCarryService,
ITaskMessageNotify taskMessageNotify
) : base(taskMessageNotify.Writer)
{ {
_db = repository.AsSugarClient(); _db = repository.AsSugarClient();
_runService = runService; _runService = runService;
@@ -160,6 +162,10 @@ namespace Tnb.WarehouseMgr
await _db.Ado.RollbackTranAsync(); await _db.Ado.RollbackTranAsync();
throw; throw;
} }
finally
{
await Publish(nameof(IWareHouseService.GenTaskExecute));
}
return Task.FromResult(true); return Task.FromResult(true);
} }
public override async Task ModifyAsync(WareHouseUpInput input) public override async Task ModifyAsync(WareHouseUpInput input)

View File

@@ -58,7 +58,8 @@ namespace Tnb.WarehouseMgr
IUserManager userManager, IUserManager userManager,
IBillRullService billRullService, IBillRullService billRullService,
IWmsCarryMoveInStockService wmsCarryMoveInStockService, IWmsCarryMoveInStockService wmsCarryMoveInStockService,
IWmsCarryService wareCarryService) IWmsCarryService wareCarryService,
ITaskMessageNotify taskMessageNotify) : base(taskMessageNotify.Writer)
{ {
_db = repository.AsSugarClient(); _db = repository.AsSugarClient();
_dictionaryDataService = dictionaryDataService; _dictionaryDataService = dictionaryDataService;
@@ -281,9 +282,6 @@ namespace Tnb.WarehouseMgr
} }
await _db.Ado.CommitTranAsync(); await _db.Ado.CommitTranAsync();
} }
catch (Exception) catch (Exception)
@@ -291,6 +289,10 @@ namespace Tnb.WarehouseMgr
await _db.Ado.RollbackTranAsync(); await _db.Ado.RollbackTranAsync();
throw; throw;
} }
finally
{
await Publish(nameof(IWareHouseService.GenTaskExecute));
}
return Task.FromResult(true); return Task.FromResult(true);
} }
@@ -551,7 +553,11 @@ namespace Tnb.WarehouseMgr
isSuccessful = false; isSuccessful = false;
JNPF.Logging.Log.Error(ex.Message); JNPF.Logging.Log.Error(ex.Message);
await _db.Ado.RollbackTranAsync(); await _db.Ado.RollbackTranAsync();
throw ex; throw;
}
finally
{
await Publish(nameof(IWareHouseService.GenTaskExecute));
} }
return isSuccessful; return isSuccessful;
} }

View File

@@ -30,7 +30,7 @@ namespace Tnb.WarehouseMgr
/// </summary> /// </summary>
[OverideVisualDev(ModuleId)] [OverideVisualDev(ModuleId)]
[ServiceModule(BizTypeId)] [ServiceModule(BizTypeId)]
public class WmsPDACarryMoveInStockService : BaseWareHouseService,IPdaStroage public class WmsPDACarryMoveInStockService : BaseWareHouseService, IPdaStroage
{ {
private const string BizTypeId = "26121988909861"; private const string BizTypeId = "26121988909861";
private const string ModuleId = "26476127634469"; private const string ModuleId = "26476127634469";
@@ -48,7 +48,8 @@ namespace Tnb.WarehouseMgr
IVisualDevService visualDevService, IVisualDevService visualDevService,
IWareHouseService wareHouseService, IWareHouseService wareHouseService,
IUserManager userManager, IUserManager userManager,
IBillRullService billRullService) IBillRullService billRullService,
ITaskMessageNotify taskMessageNotify) : base(taskMessageNotify.Writer)
{ {
_db = repository.AsSugarClient(); _db = repository.AsSugarClient();
_runService = runService; _runService = runService;
@@ -155,6 +156,10 @@ namespace Tnb.WarehouseMgr
await _db.Ado.RollbackTranAsync(); await _db.Ado.RollbackTranAsync();
throw; throw;
} }
finally
{
await Publish(nameof(IWareHouseService.GenTaskExecute));
}
return Task.FromResult(true); return Task.FromResult(true);
} }

View File

@@ -45,7 +45,9 @@ namespace Tnb.WarehouseMgr
IVisualDevService visualDevService, IVisualDevService visualDevService,
IWareHouseService wareHouseService, IWareHouseService wareHouseService,
IUserManager userManager, IUserManager userManager,
IBillRullService billRullService) IBillRullService billRullService,
ITaskMessageNotify taskMessageNotify
) : base(taskMessageNotify.Writer)
{ {
_db = repository.AsSugarClient(); _db = repository.AsSugarClient();
_runService = runService; _runService = runService;
@@ -154,6 +156,10 @@ namespace Tnb.WarehouseMgr
await _db.Ado.RollbackTranAsync(); await _db.Ado.RollbackTranAsync();
throw; throw;
} }
finally
{
await Publish(nameof(IWareHouseService.GenTaskExecute));
}
return Task.FromResult(true); return Task.FromResult(true);
} }

View File

@@ -50,8 +50,9 @@ namespace Tnb.WarehouseMgr
IBasLocationService basLocationService, IBasLocationService basLocationService,
IBillRullService billRullService, IBillRullService billRullService,
IWareHouseService wareHouseService, IWareHouseService wareHouseService,
IUserManager userManager IUserManager userManager,
) ITaskMessageNotify taskMessageNotify
) : base(taskMessageNotify.Writer)
{ {
_db = repository.AsSugarClient(); _db = repository.AsSugarClient();
_runService = runService; _runService = runService;
@@ -188,6 +189,10 @@ namespace Tnb.WarehouseMgr
{ {
return await Task.FromResult(false); return await Task.FromResult(false);
} }
finally
{
await Publish(nameof(IWareHouseService.GenTaskExecute));
}
return await Task.FromResult(true); return await Task.FromResult(true);
} }
public override async Task ModifyAsync(WareHouseUpInput input) public override async Task ModifyAsync(WareHouseUpInput input)

View File

@@ -47,7 +47,8 @@ namespace Tnb.WarehouseMgr
IVisualDevService visualDevService, IVisualDevService visualDevService,
IWareHouseService wareHouseService, IWareHouseService wareHouseService,
IUserManager userManager, IUserManager userManager,
IBillRullService billRullService) IBillRullService billRullService,
ITaskMessageNotify taskMessageNotify) : base(taskMessageNotify.Writer)
{ {
_db = repository.AsSugarClient(); _db = repository.AsSugarClient();
_runService = runService; _runService = runService;
@@ -124,7 +125,7 @@ namespace Tnb.WarehouseMgr
preTask.create_time = DateTime.Now; preTask.create_time = DateTime.Now;
return preTask; return preTask;
}).ToList(); }).ToList();
var isOk = await _wareHouseService.GenPreTask(preTasks,null!); var isOk = await _wareHouseService.GenPreTask(preTasks, null!);
if (isOk) if (isOk)
{ {
var preTaskUpInput = new GenPreTaskUpInput(); var preTaskUpInput = new GenPreTaskUpInput();
@@ -165,6 +166,10 @@ namespace Tnb.WarehouseMgr
await _db.Ado.RollbackTranAsync(); await _db.Ado.RollbackTranAsync();
throw; throw;
} }
finally
{
await Publish(nameof(IWareHouseService.GenTaskExecute));
}
return Task.FromResult(true); return Task.FromResult(true);
} }

View File

@@ -48,7 +48,9 @@ namespace Tnb.WarehouseMgr
IVisualDevService visualDevService, IVisualDevService visualDevService,
IWareHouseService wareHouseService, IWareHouseService wareHouseService,
IUserManager userManager, IUserManager userManager,
IBillRullService billRullService) IBillRullService billRullService,
ITaskMessageNotify taskMessageNotify
) : base(taskMessageNotify.Writer)
{ {
_db = repository.AsSugarClient(); _db = repository.AsSugarClient();
_runService = runService; _runService = runService;
@@ -76,7 +78,7 @@ namespace Tnb.WarehouseMgr
var setQty = await _db.Queryable<WmsEmptyOutstockH>().FirstAsync(it => it.bill_code == input.data[nameof(WmsEmptyOutstockH.bill_code)].ToString()); var setQty = await _db.Queryable<WmsEmptyOutstockH>().FirstAsync(it => it.bill_code == input.data[nameof(WmsEmptyOutstockH.bill_code)].ToString());
var carrys = await _db.Queryable<WmsCarryH>().LeftJoin<BasLocation>((a, b) => a.location_id == b.id) var carrys = await _db.Queryable<WmsCarryH>().LeftJoin<BasLocation>((a, b) => a.location_id == b.id)
.Where((a, b) => a.carrystd_id == input.data[nameof(WmsEmptyOutstockH.carrystd_id)].ToString() .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(); .ToListAsync();
WmsPointH sPoint = null!; WmsPointH sPoint = null!;
@@ -202,10 +204,14 @@ namespace Tnb.WarehouseMgr
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error("空载具出库错误",ex); Log.Error("空载具出库错误", ex);
await _db.Ado.RollbackTranAsync(); await _db.Ado.RollbackTranAsync();
throw; throw;
} }
finally
{
await Publish(nameof(IWareHouseService.GenTaskExecute));
}
return Task.FromResult(true); return Task.FromResult(true);
} }

View File

@@ -61,8 +61,9 @@ namespace Tnb.WarehouseMgr
IUserManager userManager, IUserManager userManager,
IBillRullService billRullService, IBillRullService billRullService,
IWmsCarryService carryService, IWmsCarryService carryService,
ICacheManager cacheManager ICacheManager cacheManager,
) ITaskMessageNotify taskMessageNotify
) : base(taskMessageNotify.Writer)
{ {
_db = repository.AsSugarClient(); _db = repository.AsSugarClient();
_warehouseService = warehouseService; _warehouseService = warehouseService;
@@ -70,6 +71,7 @@ namespace Tnb.WarehouseMgr
_billRullService = billRullService; _billRullService = billRullService;
_carryService = carryService; _carryService = carryService;
_cacheManager = cacheManager; _cacheManager = cacheManager;
} }
/// <summary> /// <summary>
/// 齐套出库(新增状态) /// 齐套出库(新增状态)
@@ -78,10 +80,6 @@ namespace Tnb.WarehouseMgr
[HttpPost, Timed(Name = nameof(KittingOutByAdd))] [HttpPost, Timed(Name = nameof(KittingOutByAdd))]
public async Task KittingOutByAdd(CancellationTokenSource? cts = default) 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(); var curDb = _db.CopyNew();
try try
{ {
@@ -135,8 +133,8 @@ namespace Tnb.WarehouseMgr
setSortingH.id = SnowflakeIdHelper.NextId(); setSortingH.id = SnowflakeIdHelper.NextId();
setSortingH.kittingout_id = ko.id; setSortingH.kittingout_id = ko.id;
setSortingH.seq = ko.seq; setSortingH.seq = ko.seq;
setSortingH.org_id = curUser.FindFirst(ClaimConst.CLAINMORGID)?.Value; setSortingH.org_id = _userManager.User.OrganizeId;
setSortingH.create_id = curUser.FindFirst(ClaimConst.CLAINMUSERID)?.Value!; setSortingH.create_id = _userManager.UserId;
setSortingH.create_time = DateTime.Now; setSortingH.create_time = DateTime.Now;
await curDb.Insertable(setSortingH).ExecuteCommandAsync(); await curDb.Insertable(setSortingH).ExecuteCommandAsync();
@@ -164,20 +162,12 @@ namespace Tnb.WarehouseMgr
catch (Exception ex) catch (Exception ex)
{ {
Log.Error("齐套出库,新增时出现错误", 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(); cts?.Cancel();
throw timedTaskEx; throw;
} }
finally finally
{ {
await Publish(nameof(IWareHouseService.GenTaskExecute));
} }
} }
/// <summary> /// <summary>
@@ -187,10 +177,6 @@ namespace Tnb.WarehouseMgr
[HttpPost, Timed(Name = nameof(KittingOutByIsToBeShipped))] [HttpPost, Timed(Name = nameof(KittingOutByIsToBeShipped))]
public async Task KittingOutByIsToBeShipped(CancellationTokenSource? cts = default) 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(); var curDb = _db.CopyNew();
try try
{ {
@@ -229,7 +215,7 @@ namespace Tnb.WarehouseMgr
WmsPretaskH preTask = new() WmsPretaskH preTask = new()
{ {
org_id = curUser.FindFirst(ClaimConst.CLAINMORGID)?.Value, org_id = _userManager.User.OrganizeId,
startlocation_id = sPoint?.location_id!, startlocation_id = sPoint?.location_id!,
startlocation_code = sPoint?.location_code!, startlocation_code = sPoint?.location_code!,
endlocation_id = ePoint?.location_id!, endlocation_id = ePoint?.location_id!,
@@ -250,7 +236,7 @@ namespace Tnb.WarehouseMgr
area_code = it.Key, area_code = it.Key,
require_id = ko.id, require_id = ko.id,
require_code = ko.bill_code, require_code = ko.bill_code,
create_id = curUser.FindFirst(ClaimConst.CLAINMUSERID)?.Value!, create_id = _userManager.UserId,
create_time = DateTime.Now, create_time = DateTime.Now,
source_id = ko.source_id, source_id = ko.source_id,
source_code = ko.source_code source_code = ko.source_code
@@ -277,15 +263,12 @@ namespace Tnb.WarehouseMgr
catch (Exception ex) catch (Exception ex)
{ {
Log.Error("齐套出库,待配送时出现错误", 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(); cts?.Cancel();
throw timedTaskEx; throw;
}
finally
{
await Publish(nameof(IWareHouseService.GenTaskExecute));
} }
} }