This commit is contained in:
2023-09-07 10:13:10 +08:00
7 changed files with 36 additions and 6 deletions

View File

@@ -70,8 +70,9 @@ namespace Tnb.WarehouseMgr
}
}
protected Task<ClaimsPrincipal> GetUserIdentity()
protected Task<ClaimsPrincipal> GetUserIdentity(string? token = null)
{
var at = token ?? UserManager.AsscessToken;
var claims = JWTEncryption.ReadJwtToken(UserManager.AsscessToken)?.Claims;
ClaimsIdentity toKen = new ClaimsIdentity();
foreach (Claim item in claims)

View File

@@ -1,15 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Channels;
using System.Threading.Tasks;
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.Security;
using JNPF.FriendlyException;
using JNPF.Systems.Entitys.Permission;
using JNPF.Systems.Interfaces.System;
using JNPF.VisualDev;
using JNPF.VisualDev.Entitys;
@@ -90,6 +93,18 @@ namespace Tnb.WarehouseMgr
ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == endLocations[0].id);
}
if (_userManager.User == null)
{
var ui = await GetUserIdentity(_userManager.ToKen);
var curUserPI = _userManager.GetType().GetProperty(nameof(_userManager.User), BindingFlags.Instance | BindingFlags.NonPublic);
if (curUserPI != null)
{
var curUid = ui.FindFirst(ClaimConst.CLAINMUSERID)?.Value;
var curUser = await _db.Queryable<UserEntity>().SingleAsync(it => it.Id == curUid);
curUserPI.SetValue(_userManager,curUser, null);
}
}
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_CARRYMOVEINSTOCK_ID, true);
await _runService.Create(templateEntity, input);

View File

@@ -1,4 +1,6 @@
namespace JNPF.TaskScheduler.Interfaces.TaskScheduler;
using JNPF.TaskScheduler.Entitys;
namespace JNPF.TaskScheduler.Interfaces.TaskScheduler;
/// <summary>
    /// 定时任务
@@ -13,4 +15,6 @@ public interface ITimeTaskService
/// 启动自启动任务.
/// </summary>
void StartTimerJob();
List<TimeTaskEntity> GetTasks();
}

View File

@@ -8,6 +8,7 @@ using JNPF.Common.Security;
using JNPF.Systems.Entitys.System;
using JNPF.TaskScheduler;
using JNPF.TaskScheduler.Entitys.Model;
using JNPF.TaskScheduler.Interfaces.TaskScheduler;
using SqlSugar;
using Tnb.EquipMgr.Entities;
using Tnb.ProductionMgr.Entities;
@@ -19,12 +20,14 @@ namespace Tnb.TaskScheduler.Listener
public class MoldMaintainTask : ISpareTimeWorker
{
private ISqlSugarRepository<ToolMoldMaintainRule> repository => App.GetService<ISqlSugarRepository<ToolMoldMaintainRule>>();
private ITimeTaskService timeTaskService => App.GetService<ITimeTaskService>();
[SpareTime("0 0 0 * * ?", "生成模具保养任务", ExecuteType = SpareTimeExecuteTypes.Serial, StartNow = false)]
public async void CreateTask(SpareTimer timer, long count)
{
try
{
var timeTaskEntity = await repository.AsSugarClient().Queryable<TimeTaskEntity>().Where(p => p.Id == timer.WorkerName && p.EnabledMark == 1).FirstAsync();
var TimeTasks = timeTaskService.GetTasks();
var timeTaskEntity = TimeTasks.Where(p => p.Id == timer.WorkerName && p.EnabledMark == 1).First();
if (timeTaskEntity == null)
return;
ContentModel? comtentModel = timeTaskEntity.ExecuteContent.ToObject<ContentModel>();

View File

@@ -9,6 +9,7 @@ using JNPF.Systems.Entitys.System;
using JNPF.TaskScheduler;
using JNPF.TaskScheduler.Entitys;
using JNPF.TaskScheduler.Entitys.Model;
using JNPF.TaskScheduler.Interfaces.TaskScheduler;
using SqlSugar;
using Tnb.BasicData.Entities;
using Tnb.EquipMgr.Entities;
@@ -25,13 +26,14 @@ namespace Tnb.TaskScheduler.Listener
public class QcTaskTimeWorker : ISpareTimeWorker
{
private ISqlSugarRepository<QcCheckPlanH> repository => App.GetService<ISqlSugarRepository<QcCheckPlanH>>();
private ITimeTaskService timeTaskService => App.GetService<ITimeTaskService>();
[SpareTime("0 0 0 * * ?", "生成质检任务", ExecuteType = SpareTimeExecuteTypes.Serial, StartNow = false)]
public async void CreateTask(SpareTimer timer, long count)
{
try
{
var timeTaskEntity = await repository.AsSugarClient().Queryable<TimeTaskEntity>().Where(p => p.Id == timer.WorkerName && p.EnabledMark == 1).FirstAsync();
var TimeTasks = timeTaskService.GetTasks();
var timeTaskEntity = TimeTasks.Where(p => p.Id == timer.WorkerName && p.EnabledMark == 1).First();
if (timeTaskEntity == null)
return;
ContentModel? comtentModel = timeTaskEntity.ExecuteContent.ToObject<ContentModel>();

View File

@@ -136,6 +136,12 @@ public class TimeTaskService : ITimeTaskService, IDynamicApiController, ITransie
#endregion
#region Post
public List<TimeTaskEntity> GetTasks()
{
var list= _repository.AsQueryable().ToList();
return list;
}
/// <summary>
/// 新建.

View File

@@ -4,7 +4,6 @@
/////////////////////////////////////////////////////////////////////////////////
using JNPF.Common.Configuration;
using JNPF.Systems.Entitys.Dto.Database;
using JNPF;
using Mapster;
using Microsoft.AspNetCore.Mvc;