This commit is contained in:
FanLian
2023-08-15 16:53:59 +08:00
5 changed files with 104 additions and 39 deletions

View File

@@ -8,12 +8,16 @@ using System.Threading.Tasks;
using JNPF;
using JNPF.Common.Const;
using JNPF.Common.Core.Manager;
using JNPF.Common.Dtos.VisualDev;
using JNPF.Common.Enums;
using JNPF.Common.Extension;
using JNPF.Common.Manager;
using JNPF.Common.Security;
using JNPF.FriendlyException;
using JNPF.Systems.Interfaces.System;
using JNPF.VisualDev;
using JNPF.VisualDev.Entitys;
using JNPF.VisualDev.Interfaces;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using NPOI.SS.Formula;
@@ -36,6 +40,7 @@ namespace Tnb.WarehouseMgr
/// 齐套分拣服务类
/// </summary>
[ServiceModule(BizTypeId)]
[OverideVisualDev(ModuleConsts.MODULE_WMSSETSORTING_ID)]
public class WmsSetSortingService : BaseWareHouseService, IWmsSetSortingService
{
private readonly ISqlSugarClient _db;
@@ -43,15 +48,46 @@ namespace Tnb.WarehouseMgr
private readonly IBillRullService _billRullService;
private readonly IUserManager _userManager;
private readonly ICacheManager _cacheManager;
private readonly IRunService _runService;
private readonly IVisualDevService _visualDevService;
private const string BizTypeId = "26186830379045";
public WmsSetSortingService(ISqlSugarRepository<WmsSetsortingH> repository, IWareHouseService wareHouseService, IUserManager userManager, IBillRullService billRullService, ICacheManager cacheManager)
public WmsSetSortingService(
ISqlSugarRepository<WmsSetsortingH> repository,
IWareHouseService wareHouseService,
IUserManager userManager, IBillRullService billRullService,
ICacheManager cacheManager,
IRunService runService,
IVisualDevService visualDevService,
ITaskMessageNotify taskMessageNotify
) : base(taskMessageNotify.Writer)
{
_db = repository.AsSugarClient();
_wareHouseService = wareHouseService;
_billRullService = billRullService;
_userManager = userManager;
_cacheManager = cacheManager;
_runService = runService;
_visualDevService = visualDevService;
OverideFuncs.CreateAsync = Create;
}
private async Task<dynamic> Create(VisualDevModelDataCrInput input)
{
//在线开发
try
{
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSEMPTYINSTOCK_ID, true);
await _runService.Create(templateEntity, input);
await PackSortingByAdd();
}
catch (Exception)
{
throw;
}
return Task.FromResult(1);
}
/// <summary>
@@ -188,12 +224,12 @@ namespace Tnb.WarehouseMgr
{
var leftCarrys = carrys[..mid];
var rightCarrys = carrys[mid..];
await InnerGenPreTask(leftCarrys, locIds, firstLocationId, singleSorting.id, singleSorting.bill_code, preTasks, endLocation, curUser);
await InnerGenPreTask(rightCarrys, locIds, secondLocationId, singleSorting.id, singleSorting.bill_code, preTasks, endLocation, curUser);
await InnerGenPreTask(leftCarrys, locIds, firstLocationId, singleSorting.id, singleSorting.bill_code, preTasks, endLocation);
await InnerGenPreTask(rightCarrys, locIds, secondLocationId, singleSorting.id, singleSorting.bill_code, preTasks, endLocation);
}
else
{
await InnerGenPreTask(carrys, locIds, firstLocationId, singleSorting.id, singleSorting.bill_code, preTasks, endLocation, curUser);
await InnerGenPreTask(carrys, locIds, firstLocationId, singleSorting.id, singleSorting.bill_code, preTasks, endLocation);
}
List<WmsPretaskCode> pretaskCodes = new();
foreach (var pt in preTasks)
@@ -225,19 +261,13 @@ 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 timedTaskEx;
throw;
}
}
private async Task InnerGenPreTask(WmsCarryH[] carrys, List<string> locIds, string eLocationId, string requireId, string requireCode, List<WmsPretaskH> preTasks, BasLocation endLocation, ClaimsPrincipal curUser)
private async Task InnerGenPreTask(WmsCarryH[] carrys, List<string> locIds, string eLocationId, string requireId, string requireCode, List<WmsPretaskH> preTasks, BasLocation endLocation)
{
foreach (var carry in carrys)
{
@@ -262,7 +292,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!,
@@ -279,7 +309,7 @@ namespace Tnb.WarehouseMgr
area_code = it.Key,
require_id = requireId,
require_code = requireCode,
create_id = curUser.FindFirst(ClaimConst.CLAINMUSERID)?.Value!,
create_id = _userManager.UserId,
create_time = DateTime.Now,
source_id = carry.source_id,
source_code = carry.source_code,