1
This commit is contained in:
@@ -2,11 +2,14 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Dynamic;
|
||||
using System.Linq;
|
||||
using System.Reactive;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Aop.Api.Domain;
|
||||
using Aspose.Cells.Drawing;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Dtos.VisualDev;
|
||||
using JNPF.Common.Enums;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.DependencyInjection;
|
||||
@@ -14,11 +17,18 @@ using JNPF.DynamicApiController;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.Logging;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using JNPF.TaskScheduler;
|
||||
using JNPF.TaskScheduler.Entitys.Dto.TaskScheduler;
|
||||
using JNPF.TaskScheduler.Entitys.Model;
|
||||
using JNPF.VisualDev;
|
||||
using JNPF.VisualDev.Entitys;
|
||||
using JNPF.VisualDev.Interfaces;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.EquipMgr.Entities;
|
||||
using Tnb.EquipMgr.Entities.Dto;
|
||||
using Tnb.EquipMgr.Interfaces;
|
||||
@@ -30,17 +40,78 @@ namespace Tnb.EquipMgr
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
public class ToolMoldMaintainRuleService : IToolMoldMaintainRuleService, IDynamicApiController, ITransient
|
||||
[OverideVisualDev(ModuleId)]
|
||||
public class ToolMoldMaintainRuleService : IOverideVisualDevService, IToolMoldMaintainRuleService, IDynamicApiController, ITransient
|
||||
{
|
||||
|
||||
private const string ModuleId = "26164864904981";
|
||||
private readonly ISqlSugarClient _db;
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly IDictionaryDataService _dictionaryDataService;
|
||||
|
||||
public ToolMoldMaintainRuleService(ISqlSugarRepository<ToolMoldMaintainRule> repository, IUserManager userManager, IDictionaryDataService dictionaryDataService)
|
||||
private readonly TimeTaskService _timeTaskService;
|
||||
private readonly IVisualDevService _visualDevService;
|
||||
private readonly IRunService _runService;
|
||||
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
||||
public ToolMoldMaintainRuleService(ISqlSugarRepository<ToolMoldMaintainRule> repository, IUserManager userManager, IDictionaryDataService dictionaryDataService, TimeTaskService timeTaskService, IVisualDevService visualDevService, IRunService runService)
|
||||
{
|
||||
_db = repository.AsSugarClient();
|
||||
_userManager = userManager;
|
||||
_dictionaryDataService = dictionaryDataService;
|
||||
_timeTaskService = timeTaskService;
|
||||
_visualDevService = visualDevService;
|
||||
_runService = runService;
|
||||
OverideFuncs.DeleteAsync = Delete;
|
||||
OverideFuncs.CreateAsync = Create;
|
||||
}
|
||||
private async Task<dynamic> Create(VisualDevModelDataCrInput input)
|
||||
{
|
||||
int cycle = int.Parse(input.data["cycle"].ToString()!);
|
||||
var startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)).AddMilliseconds(long.Parse(input.data["startandend_date"].ToString()!));
|
||||
ToolMoldMaintainRule toolMoldMaintainRule = new ToolMoldMaintainRule();
|
||||
toolMoldMaintainRule.id = SnowflakeIdHelper.NextId();
|
||||
toolMoldMaintainRule.mode = input.data["mode"].ToString();
|
||||
toolMoldMaintainRule.cycle = cycle;
|
||||
toolMoldMaintainRule.startandend_date = startTime.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
await _db.Insertable(toolMoldMaintainRule).ExecuteCommandAsync();
|
||||
if (toolMoldMaintainRule.mode == "27118635748885")
|
||||
{
|
||||
string id = toolMoldMaintainRule.id;
|
||||
var comtentModel = new ContentModel();
|
||||
comtentModel.cron = "0 0 9 "+ startTime.Day + "/"+ toolMoldMaintainRule.cycle + " * ?";
|
||||
comtentModel.interfaceId = "";
|
||||
comtentModel.interfaceName = "";
|
||||
comtentModel.parameter = new List<InterfaceParameter>();
|
||||
comtentModel.parameter!.Add(new InterfaceParameter() { field = "id", value = id, defaultValue = "" });
|
||||
comtentModel.localHostTaskId = "MoldMaintainTask/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 = "生成模具保养任务" + id,
|
||||
executeType = "3",
|
||||
executeContent = comtentModel.ToJsonString(),
|
||||
description = "",
|
||||
sortCode = 99,
|
||||
enabledMark = 1,
|
||||
};
|
||||
await _timeTaskService.DeleteByName(timeTaskCrInput.fullName);
|
||||
await _timeTaskService.Create(timeTaskCrInput, false);
|
||||
}
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
private async Task Delete(string id)
|
||||
{
|
||||
var ToolMoldMaintainRule = await _db.Queryable<ToolMoldMaintainRule>().Where(p => p.id == id).FirstAsync();
|
||||
var ToolMoldMaintainRuleRelations = await _db.Queryable<ToolMoldMaintainRuleRelation>().Where(p => p.rule_id == id).ToListAsync();
|
||||
await _timeTaskService.DeleteByName("生成模具保养任务" + id);
|
||||
await _db.Ado.BeginTranAsync();
|
||||
await _db.Deleteable(ToolMoldMaintainRule).ExecuteCommandAsync();
|
||||
await _db.Deleteable(ToolMoldMaintainRuleRelations).ExecuteCommandAsync();
|
||||
await _db.Ado.CommitTranAsync();
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据规则Id获取匹配的模具列表
|
||||
|
||||
Reference in New Issue
Block a user