1
This commit is contained in:
15
QcMgr/Tnb.QcMgr.Entities/Enums/EnumTriggerType.cs
Normal file
15
QcMgr/Tnb.QcMgr.Entities/Enums/EnumTriggerType.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Tnb.QcMgr.Entities.Enums
|
||||
{
|
||||
public enum EnumTriggerType
|
||||
{
|
||||
一次性 = 1,
|
||||
周期触发 = 2,
|
||||
事件触发 = 3
|
||||
}
|
||||
}
|
||||
@@ -8,16 +8,22 @@ using System.Threading.Tasks;
|
||||
using Aspose.Cells.Drawing;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Enums;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.JsonSerialization;
|
||||
using JNPF.TaskScheduler;
|
||||
using JNPF.TaskScheduler.Entitys.Dto.TaskScheduler;
|
||||
using JNPF.TaskScheduler.Entitys.Model;
|
||||
using JNPF.VisualDev;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
using SqlSugar;
|
||||
using Tnb.QcMgr.Entities;
|
||||
using Tnb.QcMgr.Entities.Dto;
|
||||
using Tnb.QcMgr.Entities.Entity;
|
||||
using Tnb.QcMgr.Entities.Enums;
|
||||
using Tnb.QcMgr.Interfaces;
|
||||
|
||||
namespace Tnb.QcMgr
|
||||
@@ -31,11 +37,12 @@ namespace Tnb.QcMgr
|
||||
{
|
||||
private readonly ISqlSugarRepository<QcCheckPlanH> _repository;
|
||||
private readonly IUserManager _userManager;
|
||||
|
||||
public QcCheckPlanService(ISqlSugarRepository<QcCheckPlanH> repository, IUserManager userManager)
|
||||
private readonly TimeTaskService _timeTaskService;
|
||||
public QcCheckPlanService(ISqlSugarRepository<QcCheckPlanH> repository, IUserManager userManager, TimeTaskService timeTaskService)
|
||||
{
|
||||
_repository = repository;
|
||||
_userManager = userManager;
|
||||
_timeTaskService = timeTaskService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -190,6 +197,35 @@ namespace Tnb.QcMgr
|
||||
await db.Insertable(QcCheckPlanDs).ExecuteCommandAsync();
|
||||
await db.Insertable(QcCheckPlanAdd).ExecuteCommandAsync();
|
||||
await db.Ado.CommitTranAsync();
|
||||
if (QcCheckPlanAdd.triggertype == ((int)EnumTriggerType.周期触发).ToString()|| QcCheckPlanAdd.triggertype == ((int)EnumTriggerType.一次性).ToString())
|
||||
{
|
||||
var comtentModel = new ContentModel();
|
||||
comtentModel.cron = QcCheckPlanAdd.content!.Replace("\"", "");
|
||||
comtentModel.interfaceId = "";
|
||||
comtentModel.interfaceName = "";
|
||||
comtentModel.parameter = new List<InterfaceParameter>();
|
||||
comtentModel.parameter!.Add(new InterfaceParameter() { field = "id", value = QcCheckPlanAdd.mainid, defaultValue = "" });
|
||||
if(QcCheckPlanAdd.triggertype == ((int)EnumTriggerType.一次性).ToString())
|
||||
comtentModel.parameter!.Add(new InterfaceParameter() { field = "doonce", value = true.ToString(), defaultValue = "" });
|
||||
comtentModel.localHostTaskId = "QcTaskTimeWorker/CreateTask";
|
||||
comtentModel.startTime = DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
||||
comtentModel.TenantId = _userManager?.TenantId!;
|
||||
comtentModel.TenantDbName = _userManager?.TenantDbName!;
|
||||
comtentModel.ConnectionConfig = _userManager?.ConnectionConfig!;
|
||||
comtentModel.Token = _userManager?.ToKen!;
|
||||
TimeTaskCrInput timeTaskCrInput = new TimeTaskCrInput()
|
||||
{
|
||||
enCode = DateTime.Now.ToString("yyyyMMddHHmmss"),
|
||||
fullName = "生成质检任务" + QcCheckPlanAdd.mainid,
|
||||
executeType = "3",
|
||||
executeContent = comtentModel.ToJsonString(),
|
||||
description = "",
|
||||
sortCode = 99,
|
||||
enabledMark = 1,
|
||||
};
|
||||
await _timeTaskService.DeleteByName(timeTaskCrInput.fullName);
|
||||
await _timeTaskService.Create(timeTaskCrInput, false);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\taskschedule\Tnb.TaskScheduler\Tnb.TaskScheduler.csproj" />
|
||||
<ProjectReference Include="..\..\visualdev\Tnb.VisualDev.Engine\Tnb.VisualDev.Engine.csproj" />
|
||||
<ProjectReference Include="..\Tnb.QcMgr.Interfaces\Tnb.QcMgr.Interfaces.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user