Merge branch 'dev' of https://git.tuotong-tech.com/tnb/tnb.server into dev
This commit is contained in:
13
PerMgr/Tnb.PerMgr.Entities/Dto/ProcessChildDataInput.cs
Normal file
13
PerMgr/Tnb.PerMgr.Entities/Dto/ProcessChildDataInput.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
namespace Tnb.PerMgr.Entities.Dto
|
||||
{
|
||||
public class ProcessChildDataInput
|
||||
{
|
||||
|
||||
public string process_standards_id { get; set; }
|
||||
/// <summary>
|
||||
/// 工艺参数id
|
||||
/// </summary>
|
||||
public string process_param_id { get; set; }
|
||||
public decimal value { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
namespace Tnb.PerMgr.Entities.Dto
|
||||
{
|
||||
public class ProcessParamTypeChildrenOutput
|
||||
{
|
||||
/// <summary>
|
||||
/// 工艺标准子表id
|
||||
/// </summary>
|
||||
public string id { get; set; }
|
||||
/// <summary>
|
||||
/// 工艺参数id
|
||||
/// </summary>
|
||||
public string process_param_id { get; set; }
|
||||
public string name { get; set; }
|
||||
public decimal? value { get; set; }
|
||||
public decimal upper_value { get; set; }
|
||||
public decimal lower_value { get; set; }
|
||||
}
|
||||
}
|
||||
42
PerMgr/Tnb.PerMgr.Entities/Entity/PerProcessStandardsD.cs
Normal file
42
PerMgr/Tnb.PerMgr.Entities/Entity/PerProcessStandardsD.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.PerMgr.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// 工艺标准子表
|
||||
/// </summary>
|
||||
[SugarTable("per_process_standards_d")]
|
||||
public partial class PerProcessStandardsD : BaseEntity<string>
|
||||
{
|
||||
public PerProcessStandardsD()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
/// <summary>
|
||||
/// 工艺标准主表id
|
||||
/// </summary>
|
||||
public string process_standards_id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 工艺参数id
|
||||
/// </summary>
|
||||
public string process_param_id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 设定值
|
||||
/// </summary>
|
||||
public decimal value { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 上限
|
||||
/// </summary>
|
||||
public decimal? upper_value { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 下限
|
||||
/// </summary>
|
||||
public decimal? lower_value { get; set; }
|
||||
|
||||
}
|
||||
28
PerMgr/Tnb.PerMgr.Interfaces/IPerProcessParamTypeService.cs
Normal file
28
PerMgr/Tnb.PerMgr.Interfaces/IPerProcessParamTypeService.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using Tnb.PerMgr.Entities.Dto;
|
||||
namespace Tnb.PerMgr.Interfaces
|
||||
{
|
||||
public interface IPerProcessParamTypeService
|
||||
{
|
||||
/// <summary>
|
||||
/// 根据设备id获取工艺参数类型和对应工艺参数
|
||||
/// </summary>
|
||||
/// <param name="dic"></param>
|
||||
/// <returns></returns>
|
||||
public Task<dynamic> GetProcessParamType(Dictionary<string, string> dic);
|
||||
|
||||
/// <summary>
|
||||
/// 保存工艺参数子表
|
||||
/// </summary>
|
||||
/// <param name="inpuy"></param>
|
||||
/// <returns></returns>
|
||||
public Task<string> SaveData(List<ProcessChildDataInput> input);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 根据id获取修改信息
|
||||
/// </summary>
|
||||
/// <param name="dic"></param>
|
||||
/// <returns></returns>
|
||||
public Task<dynamic> GetProcessStandardsChildrenInfo(Dictionary<string, string> dic);
|
||||
}
|
||||
}
|
||||
131
PerMgr/Tnb.PerMgr/PerProcessParamTypeService.cs
Normal file
131
PerMgr/Tnb.PerMgr/PerProcessParamTypeService.cs
Normal file
@@ -0,0 +1,131 @@
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Enums;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.FriendlyException;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Tnb.EquipMgr.Entities;
|
||||
using Tnb.PerMgr.Entities;
|
||||
using Tnb.PerMgr.Entities.Dto;
|
||||
using Tnb.PerMgr.Interfaces;
|
||||
|
||||
namespace Tnb.PerMgr
|
||||
{
|
||||
/// <summary>
|
||||
/// 工艺参数类型
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings
|
||||
(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
public class PerProcessParamTypeService : IPerProcessParamTypeService, IDynamicApiController, ITransient
|
||||
{
|
||||
private readonly ISqlSugarRepository<PerProcessParamType> _repository;
|
||||
private readonly IUserManager _userManager;
|
||||
|
||||
public PerProcessParamTypeService(ISqlSugarRepository<PerProcessParamType> repository, IUserManager userManager)
|
||||
{
|
||||
_userManager = userManager;
|
||||
_repository = repository;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<dynamic> GetProcessParamType(Dictionary<string, string> dic)
|
||||
{
|
||||
string equipId = dic["equip_id"];
|
||||
var db = _repository.AsSugarClient();
|
||||
var equipment = await db.Queryable<EqpEquipment>().Where(x => x.id == equipId).SingleAsync();
|
||||
string equipTypeId = equipment?.equip_type_id;
|
||||
|
||||
//List<PerProcessParamType> perProcessParamTypes = await _repository.GetListAsync(x => x.equip_type_id == equipTypeId);
|
||||
var result = await db.Queryable<PerProcessParamType>()
|
||||
.Where(x => x.equip_type_id == equipTypeId)
|
||||
.OrderBy(x=>x.ordinal)
|
||||
.Select(x => new
|
||||
{
|
||||
tab_id = x.id,
|
||||
tab_name = x.name,
|
||||
children = SqlFunc.Subqueryable<PerProcessParam>()
|
||||
.LeftJoin<PerToleranceCategory>((y,z)=>y.tolerance_category_id==z.id)
|
||||
.Where(y=>y.process_param_type_id==x.id)
|
||||
.OrderBy((y,z)=>y.ordinal)
|
||||
.ToList<ProcessParamTypeChildrenOutput>((y,z)=>new ProcessParamTypeChildrenOutput
|
||||
{
|
||||
process_param_id = y.id,
|
||||
name = y.name,
|
||||
upper_value = z.upper_value,
|
||||
lower_value = z.lower_value
|
||||
}),
|
||||
}).ToListAsync();
|
||||
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<string> SaveData(List<ProcessChildDataInput> input)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
|
||||
List<PerProcessStandardsD> list = new List<PerProcessStandardsD>();
|
||||
if (input != null && input.Count > 0)
|
||||
{
|
||||
foreach (var item in input)
|
||||
{
|
||||
list.Add(new PerProcessStandardsD()
|
||||
{
|
||||
process_standards_id = item.process_standards_id,
|
||||
process_param_id = item.process_param_id,
|
||||
value = item.value
|
||||
});
|
||||
}
|
||||
|
||||
await db.Insertable<PerProcessStandardsD>(list).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
});
|
||||
if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
|
||||
|
||||
return result.IsSuccess ? "保存成功" : result.ErrorMessage;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<dynamic> GetProcessStandardsChildrenInfo(Dictionary<string, string> dic)
|
||||
{
|
||||
string id = dic["id"];
|
||||
var db = _repository.AsSugarClient();
|
||||
var perProcessStandardsH = await db.Queryable<PerProcessStandardsH>().SingleAsync(x => x.id == id);
|
||||
var equipment = await db.Queryable<EqpEquipment>().Where(x => x.id == perProcessStandardsH.equip_id).SingleAsync();
|
||||
string equipTypeId = equipment?.equip_type_id;
|
||||
|
||||
var result = await db.Queryable<PerProcessParamType>()
|
||||
.Where(a => a.equip_type_id == equipTypeId)
|
||||
.OrderBy(a=>a.ordinal)
|
||||
.Select(a => new
|
||||
{
|
||||
tab_id = a.id,
|
||||
tab_name = a.name,
|
||||
children = SqlFunc.Subqueryable<PerProcessStandardsD>()
|
||||
.LeftJoin<PerProcessParam>((b,c)=>b.process_param_id==c.id)
|
||||
.LeftJoin<PerToleranceCategory>((b,c,d)=>c.tolerance_category_id==d.id)
|
||||
.Where((b,c,d)=>c.process_param_type_id==a.id && b.process_standards_id==id)
|
||||
.OrderBy((b,c,d)=>c.ordinal)
|
||||
.ToList<ProcessParamTypeChildrenOutput>((b,c,d)=>new ProcessParamTypeChildrenOutput
|
||||
{
|
||||
id = b.id,
|
||||
process_param_id = c.id,
|
||||
name = c.name,
|
||||
value = b.value,
|
||||
upper_value = d.upper_value,
|
||||
lower_value = d.lower_value
|
||||
}),
|
||||
}).ToListAsync();
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\EquipMgr\Tnb.EquipMgr.Entities\Tnb.EquipMgr.Entities.csproj" />
|
||||
<ProjectReference Include="..\..\visualdev\Tnb.VisualDev.Engine\Tnb.VisualDev.Engine.csproj" />
|
||||
<ProjectReference Include="..\Tnb.PerMgr.Interfaces\Tnb.PerMgr.Interfaces.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -187,5 +187,6 @@
|
||||
"DoMainPc": "http://localhost:3000", // 前端PC外网能访问的地址(域名), 回调的时候拼接接口地址用
|
||||
"DoMainApp": "http://localhost:8081", // 前端App外网能访问的地址(域名), 回调的时候拼接接口地址用
|
||||
"AppPushUrl": "https://8e84eea8-6922-4033-8e86-67ad7442e692.bspapp.com/unipush"
|
||||
}
|
||||
},
|
||||
"IsStartTimeJob": true //是否开启定时任务
|
||||
}
|
||||
@@ -109,6 +109,8 @@ public class Startup : AppStartup
|
||||
|
||||
SnowflakeIdHelper.InitYitIdWorker();
|
||||
|
||||
//serviceProvider.GetRequiredService<ITimeTaskService>().StartTimerJob();
|
||||
bool isStartTimeJob = App.GetConfig<bool>("IsStartTimeJob");
|
||||
if(isStartTimeJob)
|
||||
serviceProvider.GetRequiredService<ITimeTaskService>().StartTimerJob();
|
||||
}
|
||||
}
|
||||
@@ -405,11 +405,7 @@ public class DataBaseService : IDynamicApiController, ITransient
|
||||
string sResult = string.Empty;
|
||||
foreach (var item in entities)
|
||||
{
|
||||
sResult = _viewEngine.RunCompileFromCached(tplContent, item, builderAction: builder =>
|
||||
{
|
||||
builder.AddUsing("System.Collections.Generic");
|
||||
builder.AddAssemblyReferenceByName("System.Collections");
|
||||
});
|
||||
sResult = _viewEngine.RunCompileFromCached(tplContent, item);
|
||||
var dir = Path.Combine(FileVariable.GenerateCodePath, item.nsName);
|
||||
Directory.CreateDirectory(dir);
|
||||
File.WriteAllText(Path.Combine(dir, item.clsName + ".cs"), sResult);
|
||||
|
||||
@@ -60,13 +60,18 @@ namespace JNPF.TaskScheduler.Listener
|
||||
// }
|
||||
// }
|
||||
|
||||
//丢失精度补齐 例如设定10分钟执行 但是这个破框架会再9:59 时进入这个方法导致不能正常执行
|
||||
//精确到分的定时任务可以不使用本地任务 采用数据接口的方式规避掉这个问题
|
||||
int second = DateTime.Now.Second;//当前的秒数
|
||||
int offsetMinute = second > 30 ? 1 : 0;
|
||||
|
||||
//整除表示一个周期到了
|
||||
foreach (var item in eqpSpotInsTemEquipHsByCirculate)
|
||||
{
|
||||
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 * 10 / 60 % (10 * (double)item.plan_cycle)==0)
|
||||
if ((ts3.TotalMinutes+offsetMinute) * 10 / 60 % (10 * (double)item.plan_cycle)==0)
|
||||
{
|
||||
tobeCreateTemplets.Add(item);
|
||||
}
|
||||
|
||||
@@ -284,7 +284,7 @@ public class TimeTaskService : ITimeTaskService, IDynamicApiController, ITransie
|
||||
// 非多租户模式启动自启任务
|
||||
if (!KeyVariable.MultiTenancy)
|
||||
{
|
||||
//_repository.AsQueryable().Where(x => x.DeleteMark == null && x.EnabledMark == 1).ToList().ForEach(AddTimerJob);
|
||||
_repository.AsQueryable().Where(x => x.DeleteMark == null && x.EnabledMark == 1).ToList().ForEach(x=>AddTimerJob(x,false));//modifyby zhoukeda 20230607
|
||||
}
|
||||
}
|
||||
|
||||
@@ -332,16 +332,17 @@ public class TimeTaskService : ITimeTaskService, IDynamicApiController, ITransie
|
||||
/// 新增定时任务.
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
private async void AddTimerJob(TimeTaskEntity input)
|
||||
private async void AddTimerJob(TimeTaskEntity input,bool startNow = true)
|
||||
{
|
||||
Action<SpareTimer, long>? action = null;
|
||||
ContentModel? comtentModel = input.ExecuteContent.ToObject<ContentModel>();
|
||||
input.ExecuteCycleJson = comtentModel.cron;
|
||||
TaskMethodInfo? taskMethod = null;
|
||||
switch (input.ExecuteType)
|
||||
{
|
||||
case "3":
|
||||
// 查询符合条件的任务方法
|
||||
TaskMethodInfo? taskMethod = GetTaskMethods()?.Result.FirstOrDefault(m => m.id == comtentModel.localHostTaskId);
|
||||
taskMethod = GetTaskMethods()?.Result.FirstOrDefault(m => m.id == comtentModel.localHostTaskId);
|
||||
if (taskMethod == null) break;
|
||||
|
||||
// 创建任务对象
|
||||
@@ -368,20 +369,19 @@ public class TimeTaskService : ITimeTaskService, IDynamicApiController, ITransie
|
||||
{
|
||||
interval = (starTime.ParseToDateTime() - DateTime.Now).TotalMilliseconds.ParseToInt();
|
||||
}
|
||||
SpareTime.DoOnce(interval, action, "Once_" + input.Id);
|
||||
SpareTime.Do(
|
||||
() =>
|
||||
{
|
||||
var isRun = comtentModel.endTime.IsNullOrEmpty() ? DateTime.Now >= starTime : DateTime.Now >= starTime && DateTime.Now < endTime;
|
||||
if (isRun)
|
||||
{
|
||||
return SpareTime.GetCronNextOccurrence(comtentModel.cron);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
},
|
||||
if (startNow) //modifyby zhoukeda 20230516
|
||||
{
|
||||
SpareTime.DoOnce(interval, action, "Once_" + input.Id);
|
||||
}
|
||||
|
||||
Func<DateTimeOffset?> nextHandle = null;
|
||||
var isRun = comtentModel.endTime.IsNullOrEmpty() ? DateTime.Now >= starTime : DateTime.Now >= starTime && DateTime.Now < endTime;
|
||||
if (isRun)
|
||||
{
|
||||
nextHandle = ()=>SpareTime.GetCronNextOccurrence(comtentModel.cron);
|
||||
}
|
||||
SpareTime.Do(nextHandle
|
||||
,
|
||||
action, input.Id, comtentModel.ConnectionConfig.ToJsonString(), true, executeType: SpareTimeExecuteTypes.Parallel, cancelInNoneNextTime: false);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user