diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/ModuleConsts.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/ModuleConsts.cs index 82c65e85..921904e4 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/ModuleConsts.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/ModuleConsts.cs @@ -156,5 +156,9 @@ public class ModuleConsts /// 模块标识-盘点任务 /// public const string MODULE_WMSCHECKTASK_ID = "27582377555221"; + /// + /// 模块标识-库存报表 + /// + public const string MODULE_WMSSTOCKREPORT_ID = "27895417124373"; } \ No newline at end of file diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsStockReportCode.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsStockReportCode.cs new file mode 100644 index 00000000..28376aa5 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsStockReportCode.cs @@ -0,0 +1,87 @@ +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.WarehouseMgr.Entities; + +/// +/// 库存报表条码表 +/// +[SugarTable("wms_stock_report_code")] +public partial class WmsStockReportCode : BaseEntity +{ + public WmsStockReportCode() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 主表ID + /// + public string? report_id { get; set; } + + /// + /// 载具ID + /// + public string? carry_id { get; set; } + + /// + /// 载具编号 + /// + public string? carry_code { get; set; } + + /// + /// 物料ID + /// + public string? material_id { get; set; } + + /// + /// 物料编号 + /// + public string? material_code { get; set; } + + /// + /// 条码编号 + /// + public string? barcode { get; set; } + + /// + /// 批次 + /// + public string? code_batch { get; set; } + + /// + /// 条码数量 + /// + public decimal? codeqty { get; set; } + + /// + /// 单位ID + /// + public string? unit_id { get; set; } + + /// + /// 创建用户 + /// + public string? create_id { get; set; } + + /// + /// 创建时间 + /// + public DateTime? create_time { get; set; } + + /// + /// 修改用户 + /// + public string? modify_id { get; set; } + + /// + /// 修改时间 + /// + public DateTime? modify_time { get; set; } + + /// + /// 时间戳 + /// + public DateTime? time_stamp { get; set; } + +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsStockReportH.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsStockReportH.cs new file mode 100644 index 00000000..683f1780 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsStockReportH.cs @@ -0,0 +1,113 @@ +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.WarehouseMgr.Entities; + +/// +/// 库存报表 +/// +[SugarTable("wms_stock_report_h")] +public partial class WmsStockReportH : BaseEntity +{ + public WmsStockReportH() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 所属组织 + /// + public string? org_id { get; set; } + + /// + /// 物料ID + /// + public string? material_id { get; set; } + + /// + /// 物料编号 + /// + public string? material_code { get; set; } + + /// + /// 仓库ID + /// + public string? warehouse_id { get; set; } + + /// + /// 现有库存 + /// + public decimal? existing_stock_qty { get; set; } + + /// + /// 最大库存 + /// + public int? max_stock { get; set; } + + /// + /// 安全库存 + /// + public int? safe_stock { get; set; } + + /// + /// 最小库存 + /// + public int? min_stock { get; set; } + + /// + /// 库存有效期(天) + /// + public int? storage_valid_day { get; set; } + + /// + /// 预警提前期(天) + /// + public int? early_warn_day { get; set; } + + /// + /// 过期预警数量 + /// + public decimal? expired_warning_qty { get; set; } + + /// + /// 创建用户 + /// + public string? create_id { get; set; } + + /// + /// 创建时间 + /// + public DateTime? create_time { get; set; } + + /// + /// 修改用户 + /// + public string? modify_id { get; set; } + + /// + /// 修改时间 + /// + public DateTime? modify_time { get; set; } + + /// + /// 扩展 + /// + public string? extras { get; set; } + + /// + /// 时间戳 + /// + public DateTime? timestamp { get; set; } + + /// + /// 流程任务Id + /// + public string? f_flowtaskid { get; set; } + + /// + /// 流程引擎Id + /// + public string? f_flowid { get; set; } + +} + diff --git a/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs index 9fdd5303..f51c99cb 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs @@ -3,13 +3,16 @@ using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Reflection; +using System.Security.Claims; using System.Text; using System.Threading.Tasks; using Aspose.Cells.Drawing; using JNPF; using JNPF.Common.Contracts; +using JNPF.Common.Core.Manager; using JNPF.Common.Enums; using JNPF.Common.Extension; +using JNPF.DataEncryption; using JNPF.DependencyInjection; using JNPF.DynamicApiController; using JNPF.Systems.Interfaces.System; @@ -49,6 +52,19 @@ namespace Tnb.WarehouseMgr } } } + + protected Task GetUserIdentity(string aToken) + { + var claims = JWTEncryption.ReadJwtToken(aToken)?.Claims; + ClaimsIdentity toKen = new ClaimsIdentity(); + foreach (Claim item in claims) + { + toKen.AddClaim(item); + } + var curUser = new ClaimsPrincipal(toKen); + return Task.FromResult(curUser); + } + /// /// 判断最终目标库位是否可以放置当前载具 /// diff --git a/WarehouseMgr/Tnb.WarehouseMgr/ConditionalBackgroundService.cs b/WarehouseMgr/Tnb.WarehouseMgr/ConditionalBackgroundService.cs new file mode 100644 index 00000000..745a3cf2 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr/ConditionalBackgroundService.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Extensions.Hosting; + +namespace Tnb.WarehouseMgr +{ + public class ConditionalBackgroundService : IHostedService + { + private readonly IHostedService _backgroundService; + //private readonly Func _condition; + + public ConditionalBackgroundService(IHostedService backgroundService) + { + _backgroundService = backgroundService; + } + + public async Task StartAsync(CancellationToken cancellationToken) + { + await _backgroundService.StartAsync(cancellationToken); + } + public async Task StopAsync(CancellationToken cancellationToken) + { + await _backgroundService.StopAsync(cancellationToken); + } + + } +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr/TimedTaskBackgroundService.cs b/WarehouseMgr/Tnb.WarehouseMgr/TimedTaskBackgroundService.cs index 67bf6a95..ca071cb4 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/TimedTaskBackgroundService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/TimedTaskBackgroundService.cs @@ -25,31 +25,30 @@ namespace Tnb.WarehouseMgr public class TimedTaskBackgroundService : BackgroundService { private ISendMessageService? _sendService; - protected override async Task ExecuteAsync(CancellationToken stoppingToken) + + protected override Task ExecuteAsync(CancellationToken stoppingToken) { - - await Task.Run(() => - { - _sendService = App.GetRequiredService(); - var userManager = App.GetRequiredService(); - List toUserIds = new List() { "25398501929509" }; - //生成任务执行 - CancellationTokenSource genTaskCTS = new(); - CancellationTokenSource kittingOutAddCts = new(); - CancellationTokenSource kittingOutShippedCts = new(); - CancellationTokenSource setSortingCts = new(); + return Task.Run(() => + { + //_sendService = App.GetRequiredService(); + List toUserIds = new List() { "25398501929509" }; + //生成任务执行 + CancellationTokenSource genTaskCTS = new(); + CancellationTokenSource kittingOutAddCts = new(); + CancellationTokenSource kittingOutShippedCts = new(); + CancellationTokenSource setSortingCts = new(); - var wareHouseService = App.GetRequiredService(); - TimedTask(cts => wareHouseService.GenTaskExecute(cts), genTaskCTS, toUserIds); - //齐套出库 + var wareHouseService = App.GetRequiredService(); + TimedTask(cts => wareHouseService.GenTaskExecute(cts), genTaskCTS, toUserIds); + //齐套出库 - var kittingOutService = App.GetRequiredService(); - TimedTask(cts => kittingOutService.KittingOutByAdd(cts), kittingOutAddCts, toUserIds); - TimedTask(cts => kittingOutService.KittingOutByIsToBeShipped(cts), kittingOutShippedCts, toUserIds); - //齐套分拣 - var setSortingService = App.GetRequiredService(); - TimedTask(cts => setSortingService.PackSortingByAdd(cts), setSortingCts, toUserIds); - }); + var kittingOutService = App.GetRequiredService(); + TimedTask(cts => kittingOutService.KittingOutByAdd(cts), kittingOutAddCts, toUserIds); + TimedTask(cts => kittingOutService.KittingOutByIsToBeShipped(cts), kittingOutShippedCts, toUserIds); + //齐套分拣 + var setSortingService = App.GetRequiredService(); + TimedTask(cts => setSortingService.PackSortingByAdd(cts), setSortingCts, toUserIds); + }); } private Task TimedTask(Func action, CancellationTokenSource cts, List? toUserIds = default) { diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs index 78fabc26..e3a1ca22 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs @@ -217,7 +217,7 @@ namespace Tnb.WarehouseMgr [HttpPost] public async Task GenTaskExecute(CancellationTokenSource? cts = default) { - + Stopwatch sw = Stopwatch.StartNew(); var db = _db.CopyNew(); try @@ -283,7 +283,6 @@ namespace Tnb.WarehouseMgr start = end; end = Math.Min((end + moveNum), arrary.Length); } - foreach (var arr in arrList) { for (int j = 1, len = arr.Length; j <= len; j++) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsRobotCallbackService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsRobotCallbackService.cs index 53a612da..eb14d720 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsRobotCallbackService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsRobotCallbackService.cs @@ -99,8 +99,8 @@ namespace Tnb.WarehouseMgr visualDevModelCrInput.data[nameof(WmsKittingInstock.create_time)] = DateTime.Now; visualDevModelCrInput.data[nameof(WmsKittingInstock.location_id)] = carry!.location_id!; visualDevModelCrInput.data[nameof(WmsKittingInstock.bill_code)] = _billRullService.GetBillNumber("WmsKittingInStk").GetAwaiter().GetResult(); - visualDevModelCrInput.data[nameof(WmsKittingInstock.source_id)] = kittingout.source_id; - visualDevModelCrInput.data[nameof(WmsKittingInstock.source_code)] = kittingout.source_code; + visualDevModelCrInput.data[nameof(WmsKittingInstock.source_id)] = kittingout.id; + visualDevModelCrInput.data[nameof(WmsKittingInstock.source_code)] = kittingout.bill_code; var location = await _db.Queryable().SingleAsync(it => it.id == kittingout.location_id); diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsStockReportService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsStockReportService.cs new file mode 100644 index 00000000..b4205ab5 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsStockReportService.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using JNPF.VisualDev; +using JNPF.VisualDev.Entitys.Dto.VisualDevModelData; +using MimeKit.Cryptography; +using SqlSugar; + +namespace Tnb.WarehouseMgr +{ + /// + /// 库存报表服务类 + /// + [OverideVisualDev(ModuleConsts.MODULE_WMSSTOCKREPORT_ID)] + public class WmsStockReportService:BaseWareHouseService + { + public WmsStockReportService() + { + OverideFuncs.GetListAsync = GetListAsync; + } + + private async Task GetListAsync(VisualDevModelListQueryInput input) + { + + return null; + } + } +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs index adbee72a..0f6c0518 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs @@ -4,18 +4,25 @@ using System.Data; using System.Data.Common; using System.Linq; using System.Linq.Expressions; +using System.Net.Http; +using System.Security.Claims; using System.Text; using System.Threading.Tasks; using System.Transactions; using Aop.Api.Domain; +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.DataEncryption; using JNPF.FriendlyException; using JNPF.LinqBuilder; using JNPF.Logging; +using JNPF.Systems.Entitys.Permission; using JNPF.Systems.Interfaces.System; using Mapster; using Microsoft.AspNetCore.Http; @@ -45,14 +52,23 @@ namespace Tnb.WarehouseMgr private readonly IUserManager _userManager; private readonly IBillRullService _billRullService; private readonly IWmsCarryService _carryService; + private readonly ICacheManager _cacheManager; private const string BizTypeId = "26169472620837"; - public WmskittingOutService(ISqlSugarRepository repository, IWareHouseService warehouseService, IUserManager userManager, IBillRullService billRullService, IWmsCarryService carryService) + public WmskittingOutService( + ISqlSugarRepository repository, + IWareHouseService warehouseService, + IUserManager userManager, + IBillRullService billRullService, + IWmsCarryService carryService, + ICacheManager cacheManager + ) { _db = repository.AsSugarClient(); _warehouseService = warehouseService; _userManager = userManager; _billRullService = billRullService; _carryService = carryService; + _cacheManager = cacheManager; } /// /// 齐套出库(新增状态) @@ -61,6 +77,10 @@ namespace Tnb.WarehouseMgr [HttpPost] 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 { @@ -114,8 +134,8 @@ namespace Tnb.WarehouseMgr setSortingH.id = SnowflakeIdHelper.NextId(); setSortingH.kittingout_id = ko.id; setSortingH.seq = ko.seq; - setSortingH.org_id = _userManager.User.OrganizeId; - setSortingH.create_id = _userManager.UserId; + setSortingH.org_id = curUser.FindFirst(ClaimConst.CLAINMORGID)?.Value; + setSortingH.create_id = curUser.FindFirst(ClaimConst.CLAINMUSERID)?.Value!; setSortingH.create_time = DateTime.Now; await curDb.Insertable(setSortingH).ExecuteCommandAsync(); @@ -155,6 +175,10 @@ namespace Tnb.WarehouseMgr [HttpPost] 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 { @@ -193,7 +217,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!, @@ -214,7 +238,7 @@ namespace Tnb.WarehouseMgr area_code = it.Key, require_id = ko.id, require_code = ko.bill_code, - create_id = _userManager.UserId, + create_id = curUser.FindFirst(ClaimConst.CLAINMUSERID)?.Value!, create_time = DateTime.Now, source_id = ko.source_id, source_code = ko.source_code @@ -234,14 +258,6 @@ namespace Tnb.WarehouseMgr } } } - else - { - throw new AppFriendlyException("无可用的载具", 500); - } - } - else - { - throw new AppFriendlyException("无可用的库位", 500); } } } diff --git a/apihost/Tnb.API.Entry/Startup.cs b/apihost/Tnb.API.Entry/Startup.cs index dd5e6ed7..d7748aae 100644 --- a/apihost/Tnb.API.Entry/Startup.cs +++ b/apihost/Tnb.API.Entry/Startup.cs @@ -63,9 +63,10 @@ public class Startup : AppStartup services.AddOverideVisualDev(); + #if !DEBUG //定时任务 services.AddHostedService(); - + #endif } public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IServiceProvider serviceProvider, IOptions senparcSetting, IOptions senparcWeixinSetting) diff --git a/common/Tnb.Common.Core/Manager/User/UserManager.cs b/common/Tnb.Common.Core/Manager/User/UserManager.cs index d71c492f..bc1e0a60 100644 --- a/common/Tnb.Common.Core/Manager/User/UserManager.cs +++ b/common/Tnb.Common.Core/Manager/User/UserManager.cs @@ -21,7 +21,7 @@ namespace JNPF.Common.Core.Manager; /// /// 用户管理 . /// -public class UserManager : IUserManager, IScoped +public partial class UserManager : IUserManager, IScoped { /// /// 用户表仓储. @@ -76,7 +76,6 @@ public class UserManager : IUserManager, IScoped public UserEntity User { get => _repository.GetSingle(u => u.Id == UserId); - } /// diff --git a/common/Tnb.Common.Core/Manager/User/UserManager.part.cs b/common/Tnb.Common.Core/Manager/User/UserManager.part.cs new file mode 100644 index 00000000..75597582 --- /dev/null +++ b/common/Tnb.Common.Core/Manager/User/UserManager.part.cs @@ -0,0 +1,27 @@ +using JNPF.Common.Const; +using JNPF.Common.Enums; +using JNPF.Common.Extension; +using JNPF.Common.Manager; +using JNPF.Common.Models.Authorize; +using JNPF.Common.Models.User; +using JNPF.Common.Net; +using JNPF.Common.Security; +using JNPF.DataEncryption; +using JNPF.DependencyInjection; +using JNPF.Systems.Entitys.Entity.Permission; +using JNPF.Systems.Entitys.Permission; +using JNPF.Systems.Entitys.System; +using Mapster; +using Microsoft.AspNetCore.Http; +using SqlSugar; +using System.Security.Claims; + +namespace JNPF.Common.Core.Manager; + +/// +/// 用户管理 . +/// +public partial class UserManager +{ + public static string AsscessToken { get; set; } +} \ No newline at end of file diff --git a/system/Tnb.OAuth/OAuthService.cs b/system/Tnb.OAuth/OAuthService.cs index afebf9dd..9c389e8f 100644 --- a/system/Tnb.OAuth/OAuthService.cs +++ b/system/Tnb.OAuth/OAuthService.cs @@ -41,6 +41,8 @@ using JNPF.Common.Core.Handlers; using JNPF.Message.Interfaces.Message; using JNPF.Extras.DatabaseAccessor.SqlSugar.Models; using Aop.Api.Domain; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace JNPF.OAuth; @@ -140,6 +142,8 @@ public class OAuthService : IDynamicApiController, ITransient private readonly IMHandler _imHandler; + + /// /// 初始化一个类型的新实例. /// @@ -382,6 +386,8 @@ public class OAuthService : IDynamicApiController, ITransient [HttpGet("Logout")] public async Task Logout([FromQuery] string ticket) { + await _cacheManager.DelAsync("AsscessToken"); + var tenantId = _userManager.TenantId ?? "default"; var userId = _userManager.UserId ?? "admim"; var httpContext = _httpContextAccessor.HttpContext; @@ -600,6 +606,10 @@ public class OAuthService : IDynamicApiController, ITransient { ClaimConst.LOGINTYPE,input.login_type} }, tokenTimeout); + //modify by ly on 20230804 + UserManager.AsscessToken = accessToken; + await _cacheManager.SetAsync("AsscessToken", accessToken,TimeSpan.FromMinutes(30)); + // 单点登录标识缓存 if (_oauthOptions.Enabled) _cacheManager.Set("OnlineTicket_" + input.online_ticket, options.ConfigId); @@ -671,7 +681,6 @@ public class OAuthService : IDynamicApiController, ITransient } } } - return new { theme = user.Theme == null ? "classic" : user.Theme, diff --git a/taskschedule/Tnb.TaskScheduler/TimeTaskService.cs b/taskschedule/Tnb.TaskScheduler/TimeTaskService.cs index 41e779a2..9b62e4c1 100644 --- a/taskschedule/Tnb.TaskScheduler/TimeTaskService.cs +++ b/taskschedule/Tnb.TaskScheduler/TimeTaskService.cs @@ -302,7 +302,7 @@ public class TimeTaskService : ITimeTaskService, IDynamicApiController, ITransie // 非多租户模式启动自启任务 if (!KeyVariable.MultiTenancy) { - _repository.AsQueryable().Where(x => x.DeleteMark == null && x.EnabledMark == 1).ToList().ForEach(x=>AddTimerJob(x,false));//modifyby zhoukeda 20230607 + _repository.AsSugarClient().CopyNew().Queryable().Where(x => x.DeleteMark == null && x.EnabledMark == 1).ToList().ForEach(x=>AddTimerJob(x,false));//modifyby zhoukeda 20230607 } }