去除引用common.props

This commit is contained in:
2023-11-06 19:35:59 +08:00
parent 6a2154edd9
commit c6b8dfc861
810 changed files with 3910 additions and 6695 deletions

View File

@@ -1,6 +1,5 @@
using JNPF.Common.Security;
using JNPF.Logging;
using Microsoft.AspNetCore.Components;
using SqlSugar;
using Tnb.EquipMgr.Entities;
@@ -17,7 +16,7 @@ namespace JNPF.TaskScheduler.Listener
// _repository = repository;
// }
[SpareTime("0 0 0 * * ?", "生成设备保养计划", ExecuteType = SpareTimeExecuteTypes.Serial,StartNow = false)]
[SpareTime("0 0 0 * * ?", "生成设备保养计划", ExecuteType = SpareTimeExecuteTypes.Serial, StartNow = false)]
public async void GenerateSpotInspectionPlan(SpareTimer timer, long count)
{
Log.Information("----------------------开始生成设备保养计划----------------------");
@@ -25,12 +24,12 @@ namespace JNPF.TaskScheduler.Listener
try
{
var db = _repository.CopyNew();
List<EqpMaintainTemEquipH> eqpSpotInsTemEquipHsByOne = await db.Queryable<EqpMaintainTemEquipH>().Where(x => x.is_start=="1" && x.plan_cycle_unit == "1").ToListAsync();
List<EqpMaintainTemEquipH> eqpSpotInsTemEquipHsByCirculate = await db.Queryable<EqpMaintainTemEquipH>().Where(x => x.is_start=="1" && x.plan_cycle_unit == "2").ToListAsync();
List<EqpMaintainTemEquipH> eqpSpotInsTemEquipHsByOne = await db.Queryable<EqpMaintainTemEquipH>().Where(x => x.is_start == "1" && x.plan_cycle_unit == "1").ToListAsync();
List<EqpMaintainTemEquipH> eqpSpotInsTemEquipHsByCirculate = await db.Queryable<EqpMaintainTemEquipH>().Where(x => x.is_start == "1" && x.plan_cycle_unit == "2").ToListAsync();
List<EqpMaintainRecordH> tobeCreateList = new List<EqpMaintainRecordH>();
List<EqpMaintainTemEquipH> tobeCreateTemplets = new List<EqpMaintainTemEquipH>();
foreach (var item in eqpSpotInsTemEquipHsByOne)
{
if (item.start_time.AddDays((double)item.plan_cycle).ToString("yyyy-MM-dd") == DateTime.Now.ToString("yyyy-MM-dd"))
@@ -38,7 +37,7 @@ namespace JNPF.TaskScheduler.Listener
tobeCreateTemplets.Add(item);
}
}
if (eqpSpotInsTemEquipHsByCirculate != null && eqpSpotInsTemEquipHsByCirculate.Count > 0)
{
@@ -48,24 +47,24 @@ namespace JNPF.TaskScheduler.Listener
TimeSpan ts1 = new TimeSpan(Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")).Ticks);
TimeSpan ts2 = new TimeSpan(Convert.ToDateTime(item.start_time.ToString("yyyy-MM-dd")).Ticks);
TimeSpan ts3 = ts1.Subtract(ts2).Duration();
if (ts3.TotalDays * 10 % (10 * (double)item.plan_cycle)==0)
if (ts3.TotalDays * 10 % (10 * (double)item.plan_cycle) == 0)
{
tobeCreateTemplets.Add(item);
}
}
}
if (tobeCreateTemplets != null && tobeCreateTemplets.Count > 0)
{
List<EqpEquipment> equipments = await db.Queryable<EqpEquipment>().Where(x => x.life==Tnb.EquipMgr.EquipmentLife.ENABLE).ToListAsync();
List<EqpEquipment> equipments = await db.Queryable<EqpEquipment>().Where(x => x.life == Tnb.EquipMgr.EquipmentLife.ENABLE).ToListAsync();
int index = 1;
foreach (var item in tobeCreateTemplets)
{
//只有启用设备才生成计划
if (equipments.FirstOrDefault(x => x.id == item.equip_id) == null)
continue;
string code = $"{DateTime.Now.ToString("yyyyMMdd")+(index++).ToString().PadLeft(3,'0')}";
string code = $"{DateTime.Now.ToString("yyyyMMdd") + (index++).ToString().PadLeft(3, '0')}";
tobeCreateList.Add(new EqpMaintainRecordH()
{
code = code,
@@ -94,7 +93,7 @@ namespace JNPF.TaskScheduler.Listener
List<string> spotInsItemIDs = spotInsTemEquipDs.Select(x => x.maintain_item_id).ToList();
List<EqpMaintainItem> spotCheckItems = await db.Queryable<EqpMaintainItem>().Where(x => spotInsItemIDs.Contains(x.id)).ToListAsync();
List<EqpMaintainRecordD> spotInsRecordDs = new List<EqpMaintainRecordD>();
foreach (var tobeCreatePlan in tobeCreateList)
{
@@ -120,7 +119,7 @@ namespace JNPF.TaskScheduler.Listener
}
}
if (spotInsRecordDs.Count<=0)
if (spotInsRecordDs.Count <= 0)
{
return;
}
@@ -151,7 +150,7 @@ namespace JNPF.TaskScheduler.Listener
Log.Error(e.Message);
}
Log.Information("----------------------结束生成设备保养计划----------------------");
}
}

View File

@@ -11,8 +11,8 @@ namespace JNPF.TaskScheduler.Listener
public class GenerateSpEquipCheckPlanTimeWorker : ISpareTimeWorker
{
private ISqlSugarRepository<EqpSpEquipCheckRecord> _repository => App.GetService<ISqlSugarRepository<EqpSpEquipCheckRecord>>();
[SpareTime("0 0 0 * * ?", "生成特种设备检验计划", ExecuteType = SpareTimeExecuteTypes.Serial,StartNow = false)]
[SpareTime("0 0 0 * * ?", "生成特种设备检验计划", ExecuteType = SpareTimeExecuteTypes.Serial, StartNow = false)]
public void GenerateSpotInspectionPlan(SpareTimer timer, long count)
{
Log.Information("----------------------开始生成特种设备检验计划----------------------");
@@ -23,20 +23,20 @@ namespace JNPF.TaskScheduler.Listener
List<string?> ids = _repository.GetList(x => x.status == "0").Select(x => x.equip_id).Distinct()
.ToList();
List<EqpSpEquipCheckRecord> list = db.Queryable<EqpSpEquipCheckRecord>().GroupBy(x=>new
{
x.equip_id,
}).Where(x => x.status == "1" && !ids.Contains(x.equip_id))//排除有未检验的
.Select(x=>new
List<EqpSpEquipCheckRecord> list = db.Queryable<EqpSpEquipCheckRecord>().GroupBy(x => new
{
x.equip_id,
}).Where(x => x.status == "1" && !ids.Contains(x.equip_id))//排除有未检验的
.Select(x => new
{
equip_id = x.equip_id,
create_time = SqlFunc.AggregateMax(x.create_time),
})
.MergeTable()
.LeftJoin<EqpSpEquipCheckRecord>((x,y)=>x.equip_id==y.equip_id && x.create_time!.Value.ToString("yyyy-MM-dd")==y.create_time!.Value.ToString("yyyy-MM-dd"))
.Select((x,y)=>y)
.LeftJoin<EqpSpEquipCheckRecord>((x, y) => x.equip_id == y.equip_id && x.create_time!.Value.ToString("yyyy-MM-dd") == y.create_time!.Value.ToString("yyyy-MM-dd"))
.Select((x, y) => y)
.ToList();
List<EqpSpEquipCheckRecord> insertList = new List<EqpSpEquipCheckRecord>();
@@ -44,7 +44,7 @@ namespace JNPF.TaskScheduler.Listener
{
foreach (var item in list)
{
if (item.end_time != null && item.warn_unit!=null)
if (item.end_time != null && item.warn_unit != null)
{
if (item.warn_unit == "1")
{
@@ -58,8 +58,9 @@ namespace JNPF.TaskScheduler.Listener
status = "0"
});
}
}else if (item.warn_unit == "2")
}
else if (item.warn_unit == "2")
{
if (item.end_time.Value.AddDays(-item.warm_time!.Value).ToString("yyyy-MM-dd") ==
DateTime.Now.ToString("yyyy-MM-dd"))
@@ -72,9 +73,9 @@ namespace JNPF.TaskScheduler.Listener
});
}
}
}
}
_repository.InsertRange(insertList);
@@ -86,7 +87,7 @@ namespace JNPF.TaskScheduler.Listener
Log.Error(e.Message);
}
Log.Information("----------------------结束生成特种设备检验计划----------------------");
}
}

View File

@@ -1,6 +1,5 @@
using JNPF.Common.Security;
using JNPF.Logging;
using Microsoft.AspNetCore.Components;
using SqlSugar;
using Tnb.EquipMgr.Entities;
@@ -17,7 +16,7 @@ namespace JNPF.TaskScheduler.Listener
// _repository = repository;
// }
[SpareTime("0 0,30 * * * ?", "生成点巡检计划", ExecuteType = SpareTimeExecuteTypes.Serial,StartNow = false)]
[SpareTime("0 0,30 * * * ?", "生成点巡检计划", ExecuteType = SpareTimeExecuteTypes.Serial, StartNow = false)]
public async void GenerateSpotInspectionPlan(SpareTimer timer, long count)
{
Log.Information("----------------------开始生成点巡检计划----------------------");
@@ -25,11 +24,11 @@ namespace JNPF.TaskScheduler.Listener
try
{
var db = _repository.CopyNew();
List<EqpSpotInsTemEquipH> eqpSpotInsTemEquipHsByOne = await db.Queryable<EqpSpotInsTemEquipH>().Where(x => x.is_start=="1" && x.plan_cycle_unit == "1").ToListAsync();
List<EqpSpotInsTemEquipH> eqpSpotInsTemEquipHsByCirculate = await db.Queryable<EqpSpotInsTemEquipH>().Where(x => x.is_start=="1" && x.plan_cycle_unit == "2").ToListAsync();
List<EqpSpotInsTemEquipH> eqpSpotInsTemEquipHsByOne = await db.Queryable<EqpSpotInsTemEquipH>().Where(x => x.is_start == "1" && x.plan_cycle_unit == "1").ToListAsync();
List<EqpSpotInsTemEquipH> eqpSpotInsTemEquipHsByCirculate = await db.Queryable<EqpSpotInsTemEquipH>().Where(x => x.is_start == "1" && x.plan_cycle_unit == "2").ToListAsync();
List<EqpSpotInsRecordH> tobeCreateList = new List<EqpSpotInsRecordH>();
List<EqpSpotInsTemEquipH> tobeCreateTemplets = new List<EqpSpotInsTemEquipH>();
foreach (var item in eqpSpotInsTemEquipHsByOne)
{
if (item.start_time.AddHours((double)item.plan_cycle).ToString("yyyy-MM-dd HH:mm") == DateTime.Now.ToString("yyyy-MM-dd HH:mm"))
@@ -37,7 +36,7 @@ namespace JNPF.TaskScheduler.Listener
tobeCreateTemplets.Add(item);
}
}
if (eqpSpotInsTemEquipHsByCirculate != null && eqpSpotInsTemEquipHsByCirculate.Count > 0)
{
//查询最后一条数据加上周期是否等于现在等于表示周期到了 已废除
@@ -71,24 +70,24 @@ namespace JNPF.TaskScheduler.Listener
TimeSpan ts1 = new TimeSpan(Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm")).Ticks);
TimeSpan ts2 = new TimeSpan(Convert.ToDateTime(item.start_time.ToString("yyyy-MM-dd HH:mm")).Ticks);
TimeSpan ts3 = ts1.Subtract(ts2).Duration();
if ((ts3.TotalMinutes+offsetMinute) * 10 / 60 % (10 * (double)item.plan_cycle)==0)
if ((ts3.TotalMinutes + offsetMinute) * 10 / 60 % (10 * (double)item.plan_cycle) == 0)
{
tobeCreateTemplets.Add(item);
}
}
}
if (tobeCreateTemplets != null && tobeCreateTemplets.Count > 0)
{
List<EqpEquipment> equipments = await db.Queryable<EqpEquipment>().Where(x => x.life==Tnb.EquipMgr.EquipmentLife.ENABLE).ToListAsync();
List<EqpEquipment> equipments = await db.Queryable<EqpEquipment>().Where(x => x.life == Tnb.EquipMgr.EquipmentLife.ENABLE).ToListAsync();
int index = 1;
foreach (var item in tobeCreateTemplets)
{
//只有启用设备才生成计划
if (equipments.FirstOrDefault(x => x.id == item.equip_id) == null)
continue;
string code = $"{DateTime.Now.ToString("yyyyMMddHHmm")+(index++).ToString().PadLeft(3,'0')}";
string code = $"{DateTime.Now.ToString("yyyyMMddHHmm") + (index++).ToString().PadLeft(3, '0')}";
tobeCreateList.Add(new EqpSpotInsRecordH()
{
id = SnowflakeIdHelper.NextId(),
@@ -118,7 +117,7 @@ namespace JNPF.TaskScheduler.Listener
List<string> spotInsItemIDs = spotInsTemEquipDs.Select(x => x.spot_ins_item_id).ToList();
List<EqpSpotInsItem> spotCheckItems = await db.Queryable<EqpSpotInsItem>().Where(x => spotInsItemIDs.Contains(x.id)).ToListAsync();
List<EqpSpotInsRecordD> spotInsRecordDs = new List<EqpSpotInsRecordD>();
foreach (var tobeCreatePlan in tobeCreateList)
{
@@ -147,9 +146,9 @@ namespace JNPF.TaskScheduler.Listener
remark = tobeCreateItem.remark
});
}
}
if (spotInsRecordDs.Count<=0)
if (spotInsRecordDs.Count <= 0)
{
return;
}
@@ -180,9 +179,9 @@ namespace JNPF.TaskScheduler.Listener
Log.Error(e.Message);
}
Log.Information("----------------------结束生成点巡检计划----------------------");
}
}
}

View File

@@ -1,32 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using JNPF;
using JNPF;
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;
using Tnb.QcMgr.Entities;
using Tnb.QcMgr.Entities.Entity;
namespace Tnb.TaskScheduler.Listener
{
public class MoldMaintainTask : ISpareTimeWorker
{
private ISqlSugarRepository<ToolMoldMaintainRule> repository => App.GetService<ISqlSugarRepository<ToolMoldMaintainRule>>();
private ITimeTaskService timeTaskService => App.GetService<ITimeTaskService>();
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 TimeTasks =await timeTaskService.GetTasks();
var TimeTasks = await timeTaskService.GetTasks();
var timeTaskEntity = TimeTasks.Where(p => p.Id == timer.WorkerName && p.EnabledMark == 1).FirstOrDefault();
if (timeTaskEntity == null)
return;
@@ -35,12 +26,12 @@ namespace Tnb.TaskScheduler.Listener
var ToolMoldMaintainRule = await client.Queryable<ToolMoldMaintainRule>().Where(p => p.id == comtentModel.parameter.Where(p => p.field == "id").First().value).FirstAsync();
if (ToolMoldMaintainRule == null)
return;
var ToolMoldMaintainRuleRelations= await client.Queryable<ToolMoldMaintainRuleRelation>().Where(p => p.rule_id == ToolMoldMaintainRule.id).ToListAsync();
var ToolMoldMaintainRuleRelations = await client.Queryable<ToolMoldMaintainRuleRelation>().Where(p => p.rule_id == ToolMoldMaintainRule.id).ToListAsync();
if (ToolMoldMaintainRuleRelations.Count() > 0)
{
var now = DateTime.Now;
Random rNum = new Random();
ToolMoldMaintainPlan toolMoldMaintainPlan=new ToolMoldMaintainPlan();
ToolMoldMaintainPlan toolMoldMaintainPlan = new ToolMoldMaintainPlan();
toolMoldMaintainPlan.id = SnowflakeIdHelper.NextId();
toolMoldMaintainPlan.plan_code = "JHDM" + now.ToString("yyyyMMdd") + rNum.Next(1000, 9999).ToString();
toolMoldMaintainPlan.mode = ToolMoldMaintainRule.mode;
@@ -53,7 +44,7 @@ namespace Tnb.TaskScheduler.Listener
foreach (var ToolMoldMaintainRuleRelation in ToolMoldMaintainRuleRelations)
{
ToolMoldMaintainPlanRelation toolMoldMaintainPlanRelation = new ToolMoldMaintainPlanRelation();
toolMoldMaintainPlanRelation.id= SnowflakeIdHelper.NextId();
toolMoldMaintainPlanRelation.id = SnowflakeIdHelper.NextId();
toolMoldMaintainPlanRelation.maintain_plan_id = toolMoldMaintainPlan.id;
toolMoldMaintainPlanRelation.mold_id = ToolMoldMaintainRuleRelation.mold_id;
toolMoldMaintainPlanRelation.group_id = ToolMoldMaintainRuleRelation.item_group_id;

View File

@@ -1,6 +1,5 @@
using JNPF.Common.Core.Manager;
using JNPF.Common.Dtos.Message;
using JNPF.Common.Enums;
using JNPF.Common.Security;
using JNPF.Logging;
using JNPF.Message.Entitys.Entity;
@@ -9,7 +8,6 @@ using JNPF.Systems.Entitys.Permission;
using JNPF.Systems.Entitys.System;
using JNPF.TaskScheduler.Entitys.Dto.TaskScheduler;
using JNPF.TaskScheduler.Entitys.Model;
using JNPF.TaskScheduler.Interfaces.TaskScheduler;
using Newtonsoft.Json;
using SqlSugar;
using Tnb.BasicData.Entities;
@@ -23,14 +21,14 @@ namespace JNPF.TaskScheduler.Listener
public class PushMsgTimeWorker : ISpareTimeWorker
{
private ISqlSugarRepository<BasPushRuleH> _repository => App.GetService<ISqlSugarRepository<BasPushRuleH>>();
private TimeTaskService _timeTaskService => App.GetService<TimeTaskService>();
private SendMessageService _sendMessageService => App.GetService<SendMessageService>();
private IUserManager _userManager => App.GetService<IUserManager>();
// [SpareTime(2*60, "推送消息", ExecuteType = SpareTimeExecuteTypes.Serial,StartNow = false,DoOnce = true)]
[SpareTime("* * * * * ?", "推送消息", ExecuteType = SpareTimeExecuteTypes.Serial,StartNow = false,DoOnce = true)]
[SpareTime("* * * * * ?", "推送消息", ExecuteType = SpareTimeExecuteTypes.Serial, StartNow = false, DoOnce = true)]
public async void PushMsg(SpareTimer timer, long count)
{
// Log.Information("----------------------开始生成特种设备检验计划----------------------");
@@ -40,14 +38,14 @@ namespace JNPF.TaskScheduler.Listener
var db = _repository.AsSugarClient();
BasPushRuleLog basPushRuleLog = await db.Queryable<BasPushRuleLog>().FirstAsync(x => x.timetask_id == timer.WorkerName);
if (basPushRuleLog?.is_push == 1)
{
BasPushRuleH basPushRuleH = await db.Queryable<BasPushRuleH>().FirstAsync(x=>x.id==basPushRuleLog.push_rule_id);
BasPushRuleD basPushRuleD = await db.Queryable<BasPushRuleD>().FirstAsync(x=>x.push_rule_id==basPushRuleLog.push_rule_id && x.ordinal==basPushRuleLog.ordinal);
BasPushRuleD nextBasPushRuleD = await db.Queryable<BasPushRuleD>().FirstAsync(x=>x.push_rule_id==basPushRuleLog.push_rule_id && x.ordinal==basPushRuleLog.ordinal+1);
BasPushRuleH basPushRuleH = await db.Queryable<BasPushRuleH>().FirstAsync(x => x.id == basPushRuleLog.push_rule_id);
BasPushRuleD basPushRuleD = await db.Queryable<BasPushRuleD>().FirstAsync(x => x.push_rule_id == basPushRuleLog.push_rule_id && x.ordinal == basPushRuleLog.ordinal);
BasPushRuleD nextBasPushRuleD = await db.Queryable<BasPushRuleD>().FirstAsync(x => x.push_rule_id == basPushRuleLog.push_rule_id && x.ordinal == basPushRuleLog.ordinal + 1);
if (basPushRuleH?.enabled==1 && basPushRuleD != null)
if (basPushRuleH?.enabled == 1 && basPushRuleD != null)
{
TimeTaskEntity timeTaskEntity = await db.Queryable<TimeTaskEntity>().SingleAsync(x => x.Id == timer.WorkerName);
List<MessageSendModel> list = await _sendMessageService.SendTest(basPushRuleD.send_config_id);
@@ -57,16 +55,16 @@ namespace JNPF.TaskScheduler.Listener
{
toUsers.AddRange(JsonConvert.DeserializeObject<List<string>>(basPushRuleD.user_ids));
}
if (!string.IsNullOrEmpty(basPushRuleD.position_ids))
{
toUsers.AddRange(db.Queryable<UserRelationEntity>().Where(x => basPushRuleD.position_ids.Contains(x.Id)).Select(s => s.UserId).ToList());
}
if (!string.IsNullOrEmpty(basPushRuleD.role_ids))
{
toUsers.AddRange(db.Queryable<UserRelationEntity>().Where(x => basPushRuleD.role_ids.Contains(x.Id)).Select(s => s.UserId).ToList());
}
@@ -88,7 +86,7 @@ namespace JNPF.TaskScheduler.Listener
{
DateTime executeTime = DateTime.Now.AddMinutes(nextBasPushRuleD.interval);
string cron = $"0 {executeTime.Minute} {executeTime.Hour} {executeTime.Day} {executeTime.Month} ?";
var comtentModel = new ContentModel();
var timeTaskComtentModel = JsonConvert.DeserializeObject<ContentModel>(timeTaskEntity.ExecuteContent);
// comtentModel.cron = (nextBasPushRuleD.interval * 60).ToString();
@@ -107,7 +105,7 @@ namespace JNPF.TaskScheduler.Listener
comtentModel.TenantDbName = timeTaskComtentModel?.TenantDbName;
comtentModel.ConnectionConfig = timeTaskComtentModel?.ConnectionConfig;
comtentModel.Token = timeTaskComtentModel?.Token;
List<MessageSendModel> nextMessageList = await _sendMessageService.SendTest(nextBasPushRuleD.send_config_id);
List<MessageSendParam> messageSendParams = JsonConvert.DeserializeObject<List<MessageSendParam>>(timeTaskEntity.Description);
string paramJson = "";
@@ -115,7 +113,7 @@ namespace JNPF.TaskScheduler.Listener
{
foreach (var param in item.paramJson)
{
var field = messageSendParams.FirstOrDefault(x=>x.fieldName==param.fieldName);
var field = messageSendParams.FirstOrDefault(x => x.fieldName == param.fieldName);
if (field != null)
{
param.value = field.value;
@@ -148,20 +146,20 @@ namespace JNPF.TaskScheduler.Listener
enabledMark = 1,
};
await _timeTaskService.Create(timeTaskCrInput,false);
await _timeTaskService.Create(timeTaskCrInput, false);
TimeTaskEntity timeTaskEntityNew = await db.Queryable<TimeTaskEntity>().Where(x => x.EnCode == timeTaskCrInput.enCode).FirstAsync();
string newId = timeTaskEntityNew?.Id ?? "";
await db.Updateable<BasPushRuleLog>()
.SetColumns(x=>x.timetask_id==newId)
.SetColumns(x => x.timetask_id == newId)
.SetColumns(x => x.ordinal == x.ordinal + 1)
.Where(x=>x.timetask_id==timer.WorkerName).ExecuteCommandAsync();
.Where(x => x.timetask_id == timer.WorkerName).ExecuteCommandAsync();
}
}
}
}
//进入次方法后删除次定时任务
// _timeTaskService.Delete(timer.WorkerName);
SpareTime.Cancel(timer.WorkerName);
@@ -173,10 +171,10 @@ namespace JNPF.TaskScheduler.Listener
Log.Error(e.Message);
}
// Log.Information("----------------------结束生成特种设备检验计划----------------------");
}
private List<MessageSendModel> SendTest(string id)
{
var db = _repository.AsSugarClient();

View File

@@ -1,23 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Aop.Api.Domain;
using JNPF;
using JNPF;
using JNPF.Common.Security;
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;
using Tnb.ProductionMgr.Entities;
using Tnb.QcMgr.Entities;
using Tnb.QcMgr.Entities.Entity;
using TimeTaskEntity = JNPF.TaskScheduler.Entitys.TimeTaskEntity;
namespace Tnb.TaskScheduler.Listener
{
@@ -33,12 +23,12 @@ namespace Tnb.TaskScheduler.Listener
{
try
{
var TimeTasks =await timeTaskService.GetTasks();
var TimeTasks = await timeTaskService.GetTasks();
var timeTaskEntity = TimeTasks.Where(p => p.Id == timer.WorkerName && p.EnabledMark == 1).FirstOrDefault();
if (timeTaskEntity == null)
return;
ContentModel? comtentModel = timeTaskEntity.ExecuteContent.ToObject<ContentModel>();
var client= repository.CopyNew();
var client = repository.CopyNew();
var PlanH = await client.Queryable<QcCheckPlanH>().Where(p => p.id == comtentModel.parameter.Where(p => p.field == "id").First().value).FirstAsync();
var PlanDs = await client.Queryable<QcCheckPlanD>().Where(p => p.mainid == PlanH.id).ToListAsync();
if (PlanH == null || PlanDs.Count == 0)

View File

@@ -12,14 +12,12 @@ using JNPF.DependencyInjection;
using JNPF.DynamicApiController;
using JNPF.FriendlyException;
using JNPF.LinqBuilder;
using JNPF.Schedule;
using JNPF.Systems.Interfaces.System;
using JNPF.TaskScheduler.Entitys;
using JNPF.TaskScheduler.Entitys.Dto.TaskScheduler;
using JNPF.TaskScheduler.Entitys.Enum;
using JNPF.TaskScheduler.Entitys.Model;
using JNPF.TaskScheduler.Interfaces.TaskScheduler;
using JNPF.TimeCrontab;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
@@ -149,7 +147,7 @@ public class TimeTaskService : ITimeTaskService, IDynamicApiController, ITransie
/// <param name="input">实体对象.</param>
/// <returns></returns>
[HttpPost("")]
public async Task Create([FromBody] TimeTaskCrInput input,bool startNow = true)
public async Task Create([FromBody] TimeTaskCrInput input, bool startNow = true)
{
if (await _repository.IsAnyAsync(x => (x.EnCode == input.enCode || x.FullName == input.fullName) && x.DeleteMark == null))
throw Oops.Oh(ErrorCode.COM1004);
@@ -168,7 +166,7 @@ public class TimeTaskService : ITimeTaskService, IDynamicApiController, ITransie
_ = result ?? throw Oops.Oh(ErrorCode.COM1000);
// 添加到任务调度里
AddTimerJob(result,startNow);
AddTimerJob(result, startNow);
//await AddJob(result);
}
@@ -233,11 +231,11 @@ public class TimeTaskService : ITimeTaskService, IDynamicApiController, ITransie
[HttpDelete("{fullName}")]
public async Task DeleteByName(string fullName)
{
var entitys = await _repository.AsQueryable().Where(p=>p.FullName==fullName).ToListAsync();
var entitys = await _repository.AsQueryable().Where(p => p.FullName == fullName).ToListAsync();
foreach (var entity in entitys)
{
await _repository.AsSugarClient().Deleteable(entity).ExecuteCommandAsync();
await _repository.AsSugarClient().Deleteable(entity).ExecuteCommandAsync();
// 从调度器里取消
SpareTime.Cancel(entity.Id);
}
@@ -308,7 +306,7 @@ public class TimeTaskService : ITimeTaskService, IDynamicApiController, ITransie
// 非多租户模式启动自启任务
if (!KeyVariable.MultiTenancy)
{
_repository.AsSugarClient().CopyNew().Queryable<TimeTaskEntity>().Where(x => x.DeleteMark == null && x.EnabledMark == 1).ToList().ForEach(x=>AddTimerJob(x,false));//modifyby zhoukeda 20230607
_repository.AsSugarClient().CopyNew().Queryable<TimeTaskEntity>().Where(x => x.DeleteMark == null && x.EnabledMark == 1).ToList().ForEach(x => AddTimerJob(x, false));//modifyby zhoukeda 20230607
}
}
@@ -356,7 +354,7 @@ public class TimeTaskService : ITimeTaskService, IDynamicApiController, ITransie
/// 新增定时任务.
/// </summary>
/// <param name="input"></param>
private async void AddTimerJob(TimeTaskEntity input,bool startNow = true)
private async void AddTimerJob(TimeTaskEntity input, bool startNow = true)
{
Action<SpareTimer, long>? action = null;
ContentModel? comtentModel = input.ExecuteContent.ToObject<ContentModel>();
@@ -402,7 +400,7 @@ public class TimeTaskService : ITimeTaskService, IDynamicApiController, ITransie
var isRun = comtentModel.endTime.IsNullOrEmpty() ? DateTime.Now >= starTime : DateTime.Now >= starTime && DateTime.Now < endTime;
if (isRun)
{
nextHandle = ()=>SpareTime.GetCronNextOccurrence(comtentModel.cron);
nextHandle = () => SpareTime.GetCronNextOccurrence(comtentModel.cron);
}
SpareTime.Do(nextHandle
,

View File

@@ -1,5 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(SolutionDir)\common.props" />
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>