质检任务生成计划

This commit is contained in:
qianjiawei
2023-07-12 17:27:46 +08:00
parent afb9784735
commit 1b5d0ffdf2
3 changed files with 69 additions and 27 deletions

View File

@@ -12,6 +12,7 @@ using JNPF.DynamicApiController;
using JNPF.FriendlyException; using JNPF.FriendlyException;
using JNPF.JsonSerialization; using JNPF.JsonSerialization;
using JNPF.Systems.Entitys.Permission; using JNPF.Systems.Entitys.Permission;
using JNPF.Systems.Entitys.System;
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using SqlSugar; using SqlSugar;
@@ -45,32 +46,6 @@ namespace Tnb.QcMgr
public async Task<dynamic> GetTaskItems(string id) public async Task<dynamic> GetTaskItems(string id)
{ {
var db = _repository.AsSugarClient(); var db = _repository.AsSugarClient();
string planid = "26813180898837";
var lists= await db.Queryable<QcCheckExecD>().Where(p => p.mainid == id).ToListAsync();
if (lists.Count == 0)
{
var QcCheckPlanDs = await db.Queryable<QcCheckPlanD>().Where(p => p.mainid == planid).ToListAsync();
List<QcCheckExecD> NewQcCheckExecDs = new List<QcCheckExecD>();
foreach (var QcCheckPlanD in QcCheckPlanDs)
{
QcCheckExecD QcCheckExecD = new QcCheckExecD();
QcCheckExecD.mainid = id;
QcCheckExecD.extype = QcCheckPlanD.extype;
QcCheckExecD.excontent = QcCheckPlanD.excontent;
QcCheckExecD.check = QcCheckPlanD.check;
QcCheckExecD.errorcause = QcCheckPlanD.errorcause;
QcCheckExecD.errorlevel = QcCheckPlanD.errorlevel;
QcCheckExecD.remark = QcCheckPlanD.remark;
QcCheckExecD.attachment = QcCheckPlanD.attachment;
QcCheckExecD.isexec = QcCheckPlanD.isexec;
QcCheckExecD.custom = QcCheckPlanD.custom;
QcCheckExecD.typeid = QcCheckPlanD.typeid;
QcCheckExecD.itemid = QcCheckPlanD.itemid;
NewQcCheckExecDs.Add(QcCheckExecD);
}
await db.Insertable<QcCheckExecD>(NewQcCheckExecDs).ExecuteCommandAsync();
}
var QcCheckExecH = await db.Queryable<QcCheckExecH>().Where(p => p.id == id).FirstAsync(); var QcCheckExecH = await db.Queryable<QcCheckExecH>().Where(p => p.id == id).FirstAsync();
var QcCheckExecDs = await db.Queryable<QcCheckExecD>().Where(p => p.mainid == id).ToListAsync(); var QcCheckExecDs = await db.Queryable<QcCheckExecD>().Where(p => p.mainid == id).ToListAsync();
var QcCheckItems = await db.Queryable<QcCheckItem>().ToListAsync(); var QcCheckItems = await db.Queryable<QcCheckItem>().ToListAsync();
@@ -155,8 +130,10 @@ namespace Tnb.QcMgr
try try
{ {
var QcCheckExecH = await db.Queryable<QcCheckExecH>().Where(p => p.id == CheckTaskInput.mainid).FirstAsync(); var QcCheckExecH = await db.Queryable<QcCheckExecH>().Where(p => p.id == CheckTaskInput.mainid).FirstAsync();
var DictionaryType = await db.Queryable<DictionaryTypeEntity>().Where(p=>p.FullName== "质检状态").FirstAsync();
var DictionaryData = await db.Queryable< DictionaryDataEntity >().Where(p => p.DictionaryTypeId==DictionaryType.Id&&p.FullName== "已完成").FirstAsync();
QcCheckExecH.checknum = CheckTaskInput.checknum; QcCheckExecH.checknum = CheckTaskInput.checknum;
QcCheckExecH.status = "26745885292053"; QcCheckExecH.status = DictionaryData.Id;
QcCheckExecH.result = CheckTaskInput.result; QcCheckExecH.result = CheckTaskInput.result;
QcCheckExecH.execuser = _userManager.UserId; QcCheckExecH.execuser = _userManager.UserId;
QcCheckExecH.exectime = DateTime.Now.ToString(); QcCheckExecH.exectime = DateTime.Now.ToString();

View 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();
}
}
}

View File

@@ -14,6 +14,7 @@
<ProjectReference Include="..\..\common\Tnb.Common.Core\Tnb.Common.Core.csproj" /> <ProjectReference Include="..\..\common\Tnb.Common.Core\Tnb.Common.Core.csproj" />
<ProjectReference Include="..\..\EquipMgr\Tnb.EquipMgr.Entities\Tnb.EquipMgr.Entities.csproj" /> <ProjectReference Include="..\..\EquipMgr\Tnb.EquipMgr.Entities\Tnb.EquipMgr.Entities.csproj" />
<ProjectReference Include="..\..\message\Tnb.Message\Tnb.Message.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="..\..\system\Tnb.Systems.Interfaces\Tnb.Systems.Interfaces.csproj" />
<ProjectReference Include="..\Tnb.TaskScheduler.Interfaces\Tnb.TaskScheduler.Interfaces.csproj" /> <ProjectReference Include="..\Tnb.TaskScheduler.Interfaces\Tnb.TaskScheduler.Interfaces.csproj" />
</ItemGroup> </ItemGroup>