重写模具保养

This commit is contained in:
2024-08-01 10:11:23 +08:00
parent 5df23e01ee
commit f6da16904d
23 changed files with 1532 additions and 50 deletions

View File

@@ -2,6 +2,7 @@
using JNPF.Common.Core.Manager;
using JNPF.Common.Enums;
using JNPF.Common.Filter;
using JNPF.Common.Security;
using JNPF.DependencyInjection;
using JNPF.DynamicApiController;
using JNPF.FriendlyException;
@@ -9,7 +10,11 @@ using JNPF.Logging;
using JNPF.Systems.Entitys.Permission;
using JNPF.Systems.Entitys.System;
using JNPF.Systems.Interfaces.System;
using JNPF.VisualDev;
using JNPF.VisualDev.Entitys.Dto.VisualDevModelData;
using JNPF.VisualDev.Interfaces;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
using SqlSugar;
using StackExchange.Profiling.Internal;
using Tnb.BasicData;
@@ -25,18 +30,71 @@ namespace Tnb.EquipMgr
/// </summary>
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
[Route("api/[area]/[controller]/[action]")]
public class ToolMoldMaintainPlanRunService : IToolMoldMaintainPlanRunService, IDynamicApiController, ITransient
[OverideVisualDev(ModuleId)]
public class ToolMoldMaintainPlanRunService : IOverideVisualDevService,IToolMoldMaintainPlanRunService, IDynamicApiController, ITransient
{
private const string ModuleId = "26186915586085";
private readonly IRunService _runService;
private readonly IVisualDevService _visualDevService;
private readonly ISqlSugarClient _db;
private readonly IUserManager _userManager;
private readonly IDictionaryDataService _dictionaryDataService;
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
public ToolMoldMaintainPlanRunService(ISqlSugarRepository<ToolMoldMaintainRule> repository, IUserManager userManager, IDictionaryDataService dictionaryDataService)
public ToolMoldMaintainPlanRunService(ISqlSugarRepository<ToolMoldMaintainRule> repository,
IUserManager userManager,
IRunService runService,
IVisualDevService visualDevService,
IDictionaryDataService dictionaryDataService)
{
_db = repository.AsSugarClient();
_runService = runService;
_visualDevService = visualDevService;
_userManager = userManager;
_dictionaryDataService = dictionaryDataService;
OverideFuncs.GetListAsync = GetList;
}
/// <summary>
/// 生产bom列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public async Task<dynamic> GetList(VisualDevModelListQueryInput input)
{
Dictionary<string, object> queryJson = string.IsNullOrEmpty(input.queryJson) ? new Dictionary<string, object>() : input.queryJson.ToObject<Dictionary<string, object>>();
string planCode = queryJson.GetValueOrDefault("plan_code", "").ToString();
string status = queryJson.GetValueOrDefault("status", "").ToString();
DateTime[] planStartDateArr = queryJson.ContainsKey("plan_start_date") ? queryJson["plan_start_date"].ToObject<long[]>().Select(x => DateTimeOffset.FromUnixTimeSeconds(x / 1000).ToLocalTime().DateTime).ToArray() : null;
DateTime[] planEndDateArr = queryJson.ContainsKey("plan_end_date") ? queryJson["plan_end_date"].ToObject<long[]>().Select(x => DateTimeOffset.FromUnixTimeSeconds(x / 1000).ToLocalTime().DateTime).ToArray() : null;
SqlSugarPagedList<ToolMoldMaintainPlanRunListOutput> list = await _db.Queryable<ToolMoldMaintainPlan, DictionaryDataEntity, UserEntity,DictionaryDataEntity,UserEntity>((a, b, c, d,e) => new object[]
{
JoinType.Left, a.mode == b.Id,
JoinType.Left, a.create_id == c.Id,
JoinType.Left,a.status==d.EnCode && d.DictionaryTypeId==DictConst.MaintainStatusTypeId,
JoinType.Left, a.starter_id == e.Id,
})
.WhereIF(!string.IsNullOrEmpty(planCode), (a, b, c, d) => a.plan_code.Contains(planCode))
.WhereIF(!string.IsNullOrEmpty(status), (a, b, c, d) => a.status==status)
.WhereIF(planStartDateArr!=null,(a, b, c, d) =>a.plan_start_date>=planStartDateArr[0] && a.plan_start_date<=planStartDateArr[1])
.WhereIF(planEndDateArr!=null,(a, b, c, d) =>a.plan_end_date>=planEndDateArr[0] && a.plan_end_date<=planEndDateArr[1])
.Select((a, b, c, d,e) => new ToolMoldMaintainPlanRunListOutput
{
id = a.id,
plan_code = a.plan_code,
mode = b.FullName,
status = d.FullName,
create_id = c.RealName,
create_time = a.create_time == null ? "" : a.create_time.Value.ToString(DbTimeFormat.SS),
plan_start_date = a.plan_start_date == null ? "" : a.plan_start_date.Value.ToString(DbTimeFormat.SS),
plan_end_date = a.plan_end_date == null ? "" : a.plan_end_date.Value.ToString(DbTimeFormat.SS),
remark = a.remark,
act_start_date = a.act_start_date == null ? "" : a.act_start_date.Value.ToString(DbTimeFormat.SS),
starter_id = e.RealName,
}).ToPagedListAsync(input.currentPage, input.pageSize);
return PageResult<ToolMoldMaintainPlanRunListOutput>.SqlSugarPageResult(list);
}
/// <summary>
@@ -367,6 +425,13 @@ namespace Tnb.EquipMgr
if (plan is not null)
{
await _db.Updateable<ToolMoldMaintainPlan>()
.SetColumns(x => x.act_start_date == DateTime.Now)
.SetColumns(x => x.starter_id == _userManager.UserId)
.Where(x => x.id == plan.id)
.ExecuteCommandAsync();
//插入保养计划记录
ToolMoldMaintainRunRecord record = new()
{