diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs index 56c8009e..47739623 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs @@ -2,11 +2,14 @@ using System.ArrayExtensions; using System.Collections.Generic; using System.Linq; +using System.Security.Claims; using System.Text; using System.Threading.Tasks; +using JNPF.Common.Const; using JNPF.Common.Core.Manager; using JNPF.Common.Enums; using JNPF.Common.Extension; +using JNPF.Common.Manager; using JNPF.Common.Security; using JNPF.FriendlyException; using JNPF.Systems.Interfaces.System; @@ -36,14 +39,16 @@ namespace Tnb.WarehouseMgr private readonly IWareHouseService _wareHouseService; private readonly IBillRullService _billRullService; private readonly IUserManager _userManager; + private readonly ICacheManager _cacheManager; private const string BizTypeId = "26186830379045"; - public WmsSetSortingService(ISqlSugarRepository repository, IWareHouseService wareHouseService, IUserManager userManager, IBillRullService billRullService) + public WmsSetSortingService(ISqlSugarRepository repository, IWareHouseService wareHouseService, IUserManager userManager, IBillRullService billRullService, ICacheManager cacheManager) { _db = repository.AsSugarClient(); _wareHouseService = wareHouseService; _billRullService = billRullService; _userManager = userManager; + _cacheManager = cacheManager; } /// @@ -53,6 +58,10 @@ namespace Tnb.WarehouseMgr [HttpPost] public async Task PackSortingByAdd(CancellationTokenSource? cts = default) { + var aToken = await _cacheManager.GetAsync("AccessToken"); + if (aToken.IsNullOrWhiteSpace()) return; + var curUser = await GetUserIdentity(aToken); + var curDb = _db.CopyNew(); string firstLocationId = "27010980724501", secondLocationId = "27010987857941"; var endLocation = await curDb.Queryable().SingleAsync(it => it.id == secondLocationId); @@ -144,12 +153,14 @@ namespace Tnb.WarehouseMgr carryIds = carryMats.Select(x => x.carry_id).Distinct().ToList(); await curDb.Updateable() - .SetColumns(it => new WmsCarryH { - out_status = ((int)EnumOutStatus.全部出).ToString(), - collocation_scheme_id = singleSorting.collocation_scheme_id, - collocation_scheme_code = singleSorting.collocation_scheme_code, - source_id = singleSorting.source_id, - source_code = singleSorting.source_code }) + .SetColumns(it => new WmsCarryH + { + out_status = ((int)EnumOutStatus.全部出).ToString(), + collocation_scheme_id = singleSorting.collocation_scheme_id, + collocation_scheme_code = singleSorting.collocation_scheme_code, + source_id = singleSorting.source_id, + source_code = singleSorting.source_code + }) .Where(it => carryIds.Contains(it.id)).ExecuteCommandAsync(); //await curDb.Updateable().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.全部出).ToString(), collocation_scheme_id = singleSorting.collocation_scheme_id, collocation_scheme_code = singleSorting.collocation_scheme_code }).Where(it => carryIds.Contains(it.id)).ExecuteCommandAsync(); @@ -170,17 +181,17 @@ namespace Tnb.WarehouseMgr List locIds = new(); var mid = 6; - + if (carrys.Length > mid) { var leftCarrys = carrys[..mid]; var rightCarrys = carrys[mid..]; - await InnerGenPreTask(leftCarrys, locIds, firstLocationId, singleSorting.id, singleSorting.bill_code, preTasks, endLocation); - await InnerGenPreTask(rightCarrys, locIds, secondLocationId, singleSorting.id, singleSorting.bill_code, preTasks, endLocation); + 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); } else { - await InnerGenPreTask(carrys, locIds, firstLocationId, singleSorting.id, singleSorting.bill_code, preTasks, endLocation); + await InnerGenPreTask(carrys, locIds, firstLocationId, singleSorting.id, singleSorting.bill_code, preTasks, endLocation, curUser); } List pretaskCodes = new(); foreach (var pt in preTasks) @@ -217,7 +228,7 @@ namespace Tnb.WarehouseMgr } } - private async Task InnerGenPreTask(WmsCarryH[] carrys, List locIds, string eLocationId, string requireId, string requireCode, List preTasks, BasLocation endLocation) + private async Task InnerGenPreTask(WmsCarryH[] carrys, List locIds, string eLocationId, string requireId, string requireCode, List preTasks, BasLocation endLocation, ClaimsPrincipal curUser) { foreach (var carry in carrys) { @@ -242,7 +253,7 @@ namespace Tnb.WarehouseMgr WmsPretaskH preTask = new() { - org_id = _userManager.User.OrganizeId, + org_id = curUser.FindFirst(ClaimConst.CLAINMORGID)?.Value, startlocation_id = sPoint?.location_id!, startlocation_code = sPoint?.location_code!, endlocation_id = ePoint?.location_id!, @@ -259,7 +270,7 @@ namespace Tnb.WarehouseMgr area_code = it.Key, require_id = requireId, require_code = requireCode, - create_id = _userManager.UserId, + create_id = curUser.FindFirst(ClaimConst.CLAINMUSERID)?.Value!, create_time = DateTime.Now, source_id = carry.source_id, source_code = carry.source_code, @@ -301,7 +312,7 @@ namespace Tnb.WarehouseMgr x.id = SnowflakeIdHelper.NextId(); x.bill_id = input.requireId; x.bill_d_id = billDId!; - x.org_id = ssds?.Select(xx=>xx.org_id).FirstOrDefault() ?? string.Empty; + x.org_id = ssds?.Select(xx => xx.org_id).FirstOrDefault() ?? string.Empty; x.create_id = _userManager.UserId; x.create_time = DateTime.Now; }); diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsStockReportService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsStockReportService.cs index bf83ccf9..fc79a0b9 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsStockReportService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsStockReportService.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using JNPF.Common.Core.Manager; +using JNPF.Common.Filter; using JNPF.Common.Security; using JNPF.VisualDev; using JNPF.VisualDev.Entitys.Dto.VisualDevModelData; @@ -84,7 +85,19 @@ namespace Tnb.WarehouseMgr }); return stockReport; }); - return result; + + var pages = result.Skip(input.currentPage * input.pageSize).Take(input.pageSize).ToList(); + SqlSugarPagedList pagedList = new() + { + list = pages, + pagination = new() + { + CurrentPage = input.currentPage, + PageSize = input.pageSize, + Total = result.Count() + } + }; + return PageResult.SqlSugarPageResult(pagedList); } } }