1
This commit is contained in:
@@ -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<T>(Expression<Func<T, bool>> delFilter) where T : BaseEntity<string>, new()
|
||||
{
|
||||
var row = await _db.Deleteable<T>().Where(delFilter).ExecuteCommandAsync();
|
||||
if (row < 1) throw Oops.Oh(ErrorCode.COM1002);
|
||||
}
|
||||
|
||||
protected async Task<dynamic> GetListByMasterId<TRelaction, TDest, TOutput>(string masterId,
|
||||
|
||||
protected async Task<dynamic> GetListById<TRelaction, TDest, TOutput>(string masterId,
|
||||
Expression<Func<TRelaction, bool>> masterFilterExp,
|
||||
Expression<Func<TRelaction, string>> masterSelector,
|
||||
Expression<Func<TDest, bool>> relactionFilterExp)
|
||||
Expression<Func<TDest, object>> srcMap,
|
||||
Expression<Func<TOutput, object>> destMap
|
||||
) where TDest : BaseEntity<string>, new()
|
||||
{
|
||||
var config = new TypeAdapterConfig();
|
||||
config.ForType<TDest, TOutput>();
|
||||
config.ForType<TDest, TOutput>().Map(destMap, srcMap);
|
||||
var list = new List<TOutput>();
|
||||
var itemIds = await _db.Queryable<TRelaction>().Where(masterFilterExp).Select(masterSelector).ToListAsync();
|
||||
if (itemIds?.Count > 0)
|
||||
{
|
||||
var items = await _db.Queryable<TDest>().Where(relactionFilterExp).ToListAsync();
|
||||
var items = await _db.Queryable<TDest>().Where(it=>itemIds.Contains(it.id)).ToListAsync();
|
||||
list = items.Adapt<List<TOutput>>();
|
||||
}
|
||||
return list;
|
||||
|
||||
@@ -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<ToolMoldMaintainPlan> repository, IRunService runService, IVisualDevService visualDevService)
|
||||
public ToolMoldMaintainPlanService(ISqlSugarRepository<ToolMoldMaintainPlan> 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<dynamic> GetMoldListByPlanId(RelevanceMoldFromPlanInput input)
|
||||
{
|
||||
var list = await _db.Queryable<ToolMoldMaintainPlanRelation>().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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计划关联模具
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task RelevanceMoldFromPlan(RelevanceMoldFromPlanInput input) =>
|
||||
await Relevance<RelevanceMoldFromPlanInput, ToolMoldMaintainPlanRelation>(input, nameof(ToolMoldMaintainPlanRelation.maintain_plan_id), nameof(ToolMoldMaintainPlanRelation.mold_id), it => it.maintain_plan_id == input.item_group_id);
|
||||
/// <summary>
|
||||
/// 删除计划与模具关联关系
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task DeleteMold(RelevanceMoldFromPlanInput input) =>
|
||||
await Delete<ToolMoldMaintainPlanRelation>(it => it.maintain_plan_id == input.item_group_id && input.ids.Contains(it.mold_id));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user