diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Dto/MaintainPlanMoldLstOutput.cs b/EquipMgr/Tnb.EquipMgr.Entities/Dto/MaintainPlanMoldLstOutput.cs new file mode 100644 index 00000000..c3d04d08 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Dto/MaintainPlanMoldLstOutput.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using NPOI.HSSF.Record.Chart; + +namespace Tnb.EquipMgr.Entities.Dto +{ + /// + /// 保养计划模具列表输出参数 + /// + public class MaintainPlanMoldLstOutput + { + /// + /// 模具Id + /// + public string mold_id { get; set; } + /// + /// 模具编码 + /// + public string mold_code { get; set; } + /// + /// 模具名称 + /// + public string mold_name { get;} + } +} diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Dto/RelevanceMoldFromPlanInput.cs b/EquipMgr/Tnb.EquipMgr.Entities/Dto/RelevanceMoldFromPlanInput.cs new file mode 100644 index 00000000..59a4b291 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Dto/RelevanceMoldFromPlanInput.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.EquipMgr.Entities.Dto +{ + /// + /// 模具保养计划制定-计划关联模具输入参数 + /// + public class RelevanceMoldFromPlanInput : BaseMoldMaintainInput + { + + } +} diff --git a/EquipMgr/Tnb.EquipMgr/BaseMoldMaintainService.cs b/EquipMgr/Tnb.EquipMgr/BaseMoldMaintainService.cs index 00d96f74..965c764a 100644 --- a/EquipMgr/Tnb.EquipMgr/BaseMoldMaintainService.cs +++ b/EquipMgr/Tnb.EquipMgr/BaseMoldMaintainService.cs @@ -46,9 +46,8 @@ namespace Tnb.EquipMgr { var pk = id; TDest entity = new(); - entity.id = SnowflakeIdHelper.NextId(); entity.PropertySetValue(mColumnName, input.item_group_id); - entity.PropertySetValue(name,pk); + entity.PropertySetValue(name, pk); entities.Add(entity); } } @@ -56,19 +55,27 @@ namespace Tnb.EquipMgr if (row < 1) throw Oops.Oh(ErrorCode.COM1000); } + protected async Task Delete(Expression> delFilter) where T : BaseEntity, new() + { + var row = await _db.Deleteable().Where(delFilter).ExecuteCommandAsync(); + if (row < 1) throw Oops.Oh(ErrorCode.COM1002); + } - protected async Task GetListByMasterId(string masterId, + + protected async Task GetListById(string masterId, Expression> masterFilterExp, Expression> masterSelector, - Expression> relactionFilterExp) + Expression> srcMap, + Expression> destMap + ) where TDest : BaseEntity, new() { var config = new TypeAdapterConfig(); - config.ForType(); + config.ForType().Map(destMap, srcMap); var list = new List(); var itemIds = await _db.Queryable().Where(masterFilterExp).Select(masterSelector).ToListAsync(); if (itemIds?.Count > 0) { - var items = await _db.Queryable().Where(relactionFilterExp).ToListAsync(); + var items = await _db.Queryable().Where(it=>itemIds.Contains(it.id)).ToListAsync(); list = items.Adapt>(); } return list; diff --git a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainPlanService.cs b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainPlanService.cs index e232378e..d7a993ed 100644 --- a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainPlanService.cs +++ b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainPlanService.cs @@ -15,6 +15,7 @@ using Microsoft.AspNetCore.Mvc; using SqlSugar; using Tnb.BasicData; using Tnb.EquipMgr.Entities; +using Tnb.EquipMgr.Entities.Dto; using Tnb.EquipMgr.Interfaces; namespace Tnb.EquipMgr @@ -22,14 +23,14 @@ namespace Tnb.EquipMgr [ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)] [Route("api/[area]/[controller]/[action]")] [OverideVisualDev(ModuleId)] - public class ToolMoldMaintainPlanService : IOverideVisualDevService, IToolMoldMaintainPlanService, IDynamicApiController, ITransient + public class ToolMoldMaintainPlanService : BaseMoldMaintainService, IOverideVisualDevService, IToolMoldMaintainPlanService, IDynamicApiController, ITransient { private const string ModuleId = "26165768858389"; private readonly ISqlSugarClient _db; private readonly IRunService _runService; private readonly IVisualDevService _visualDevService; public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc(); - public ToolMoldMaintainPlanService(ISqlSugarRepository repository, IRunService runService, IVisualDevService visualDevService) + public ToolMoldMaintainPlanService(ISqlSugarRepository repository, IRunService runService, IVisualDevService visualDevService) : base(repository.AsSugarClient()) { _db = repository.AsSugarClient(); _runService = runService; @@ -54,6 +55,36 @@ namespace Tnb.EquipMgr return await Task.FromResult("ok"); } + [HttpGet] + public async Task GetMoldListByPlanId(RelevanceMoldFromPlanInput input) + { + var list = await _db.Queryable().Where(it => it.maintain_plan_id == input.item_group_id).ToListAsync(); + if (list?.Count > 0) + { + var ids = list.Select(it => it.mold_id).Distinct().ToList(); + if (ids?.Count > 0) + { + } + } + return null; + } + + /// + /// 计划关联模具 + /// + /// + [HttpPost] + public async Task RelevanceMoldFromPlan(RelevanceMoldFromPlanInput input) => + await Relevance(input, nameof(ToolMoldMaintainPlanRelation.maintain_plan_id), nameof(ToolMoldMaintainPlanRelation.mold_id), it => it.maintain_plan_id == input.item_group_id); + /// + /// 删除计划与模具关联关系 + /// + /// + /// + [HttpPost] + public async Task DeleteMold(RelevanceMoldFromPlanInput input) => + await Delete(it => it.maintain_plan_id == input.item_group_id && input.ids.Contains(it.mold_id)); } + }