This commit is contained in:
FanLian
2023-08-15 14:56:43 +08:00
8 changed files with 72 additions and 50 deletions

View File

@@ -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)

View File

@@ -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;
}

View File

@@ -30,7 +30,7 @@ namespace Tnb.WarehouseMgr
/// </summary>
[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);
}

View File

@@ -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);
}

View File

@@ -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)

View File

@@ -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);
}

View File

@@ -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<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)
.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);
}

View File

@@ -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;
}
/// <summary>
/// 齐套出库(新增状态)
@@ -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));
}
}
/// <summary>
@@ -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));
}
}