质检任务生成计划
This commit is contained in:
64
taskschedule/Tnb.TaskScheduler/Listener/QcTaskTimeWorker.cs
Normal file
64
taskschedule/Tnb.TaskScheduler/Listener/QcTaskTimeWorker.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using JNPF;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.Systems.Entitys.System;
|
||||
using JNPF.TaskScheduler;
|
||||
using JNPF.TaskScheduler.Entitys;
|
||||
using SqlSugar;
|
||||
using Tnb.EquipMgr.Entities;
|
||||
using Tnb.QcMgr.Entities;
|
||||
using Tnb.QcMgr.Entities.Entity;
|
||||
using TimeTaskEntity = JNPF.TaskScheduler.Entitys.TimeTaskEntity;
|
||||
|
||||
namespace Tnb.TaskScheduler.Listener
|
||||
{
|
||||
/// <summary>
|
||||
/// 生成质检任务
|
||||
/// </summary>
|
||||
public class QcTaskTimeWorker : ISpareTimeWorker
|
||||
{
|
||||
private ISqlSugarRepository<QcCheckPlanH> repository => App.GetService<ISqlSugarRepository<QcCheckPlanH>>();
|
||||
[SpareTime("0 0 0 * * ?", "生成质检任务", ExecuteType = SpareTimeExecuteTypes.Serial, StartNow = false)]
|
||||
public async void CreateTask(SpareTimer timer, long count)
|
||||
{
|
||||
var timeTaskEntity = await repository.AsSugarClient().Queryable<TimeTaskEntity>().Where(p => p.Id == timer.WorkerName).FirstAsync();
|
||||
if (timeTaskEntity == null)
|
||||
return;
|
||||
var PlanH = await repository.AsQueryable().Where(p => p.id == timeTaskEntity.Description).FirstAsync();
|
||||
var PlanDs = await repository.AsSugarClient().Queryable<QcCheckPlanD>().Where(p => p.mainid == timeTaskEntity.Description).ToListAsync();
|
||||
if (PlanH == null || PlanDs.Count == 0)
|
||||
return;
|
||||
var DictionaryType = await repository.AsSugarClient().Queryable<DictionaryTypeEntity>().Where(p => p.FullName == "质检状态").FirstAsync();
|
||||
var DictionaryData = await repository.AsSugarClient().Queryable<DictionaryDataEntity>().Where(p => p.DictionaryTypeId == DictionaryType.Id && p.FullName == "待执行").FirstAsync();
|
||||
QcCheckExecH qcCheckExecH = new QcCheckExecH();
|
||||
qcCheckExecH.id = SnowflakeIdHelper.NextId();
|
||||
qcCheckExecH.checktype = PlanH.checktype;
|
||||
qcCheckExecH.status = DictionaryData.Id;
|
||||
qcCheckExecH.tasktime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
var ExecDs = new List<QcCheckExecD>();
|
||||
foreach (var PlanD in PlanDs)
|
||||
{
|
||||
QcCheckExecD QcCheckExecD = new QcCheckExecD();
|
||||
QcCheckExecD.mainid = qcCheckExecH.id;
|
||||
QcCheckExecD.extype = PlanD.extype;
|
||||
QcCheckExecD.excontent = PlanD.excontent;
|
||||
QcCheckExecD.check = PlanD.check;
|
||||
QcCheckExecD.errorcause = PlanD.errorcause;
|
||||
QcCheckExecD.errorlevel = PlanD.errorlevel;
|
||||
QcCheckExecD.remark = PlanD.remark;
|
||||
QcCheckExecD.attachment = PlanD.attachment;
|
||||
QcCheckExecD.isexec = PlanD.isexec;
|
||||
QcCheckExecD.custom = PlanD.custom;
|
||||
QcCheckExecD.typeid = PlanD.typeid;
|
||||
QcCheckExecD.itemid = PlanD.itemid;
|
||||
ExecDs.Add(QcCheckExecD);
|
||||
}
|
||||
await repository.AsSugarClient().Insertable(qcCheckExecH).ExecuteCommandAsync();
|
||||
await repository.AsSugarClient().Insertable(ExecDs).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@
|
||||
<ProjectReference Include="..\..\common\Tnb.Common.Core\Tnb.Common.Core.csproj" />
|
||||
<ProjectReference Include="..\..\EquipMgr\Tnb.EquipMgr.Entities\Tnb.EquipMgr.Entities.csproj" />
|
||||
<ProjectReference Include="..\..\message\Tnb.Message\Tnb.Message.csproj" />
|
||||
<ProjectReference Include="..\..\QcMgr\Tnb.QcMgr.Entities\Tnb.QcMgr.Entities.csproj" />
|
||||
<ProjectReference Include="..\..\system\Tnb.Systems.Interfaces\Tnb.Systems.Interfaces.csproj" />
|
||||
<ProjectReference Include="..\Tnb.TaskScheduler.Interfaces\Tnb.TaskScheduler.Interfaces.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user