1
This commit is contained in:
@@ -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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 保养计划模具列表输出参数
|
||||||
|
/// </summary>
|
||||||
|
public class MaintainPlanMoldLstOutput
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 模具Id
|
||||||
|
/// </summary>
|
||||||
|
public string mold_id { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 模具编码
|
||||||
|
/// </summary>
|
||||||
|
public string mold_code { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 模具名称
|
||||||
|
/// </summary>
|
||||||
|
public string mold_name { get;}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 模具保养计划制定-计划关联模具输入参数
|
||||||
|
/// </summary>
|
||||||
|
public class RelevanceMoldFromPlanInput : BaseMoldMaintainInput
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -46,9 +46,8 @@ namespace Tnb.EquipMgr
|
|||||||
{
|
{
|
||||||
var pk = id;
|
var pk = id;
|
||||||
TDest entity = new();
|
TDest entity = new();
|
||||||
entity.id = SnowflakeIdHelper.NextId();
|
|
||||||
entity.PropertySetValue(mColumnName, input.item_group_id);
|
entity.PropertySetValue(mColumnName, input.item_group_id);
|
||||||
entity.PropertySetValue(name,pk);
|
entity.PropertySetValue(name, pk);
|
||||||
entities.Add(entity);
|
entities.Add(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -56,19 +55,27 @@ namespace Tnb.EquipMgr
|
|||||||
if (row < 1) throw Oops.Oh(ErrorCode.COM1000);
|
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, bool>> masterFilterExp,
|
||||||
Expression<Func<TRelaction, string>> masterSelector,
|
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();
|
var config = new TypeAdapterConfig();
|
||||||
config.ForType<TDest, TOutput>();
|
config.ForType<TDest, TOutput>().Map(destMap, srcMap);
|
||||||
var list = new List<TOutput>();
|
var list = new List<TOutput>();
|
||||||
var itemIds = await _db.Queryable<TRelaction>().Where(masterFilterExp).Select(masterSelector).ToListAsync();
|
var itemIds = await _db.Queryable<TRelaction>().Where(masterFilterExp).Select(masterSelector).ToListAsync();
|
||||||
if (itemIds?.Count > 0)
|
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>>();
|
list = items.Adapt<List<TOutput>>();
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ using Microsoft.AspNetCore.Mvc;
|
|||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
using Tnb.BasicData;
|
using Tnb.BasicData;
|
||||||
using Tnb.EquipMgr.Entities;
|
using Tnb.EquipMgr.Entities;
|
||||||
|
using Tnb.EquipMgr.Entities.Dto;
|
||||||
using Tnb.EquipMgr.Interfaces;
|
using Tnb.EquipMgr.Interfaces;
|
||||||
|
|
||||||
namespace Tnb.EquipMgr
|
namespace Tnb.EquipMgr
|
||||||
@@ -22,14 +23,14 @@ namespace Tnb.EquipMgr
|
|||||||
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
|
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
|
||||||
[Route("api/[area]/[controller]/[action]")]
|
[Route("api/[area]/[controller]/[action]")]
|
||||||
[OverideVisualDev(ModuleId)]
|
[OverideVisualDev(ModuleId)]
|
||||||
public class ToolMoldMaintainPlanService : IOverideVisualDevService, IToolMoldMaintainPlanService, IDynamicApiController, ITransient
|
public class ToolMoldMaintainPlanService : BaseMoldMaintainService, IOverideVisualDevService, IToolMoldMaintainPlanService, IDynamicApiController, ITransient
|
||||||
{
|
{
|
||||||
private const string ModuleId = "26165768858389";
|
private const string ModuleId = "26165768858389";
|
||||||
private readonly ISqlSugarClient _db;
|
private readonly ISqlSugarClient _db;
|
||||||
private readonly IRunService _runService;
|
private readonly IRunService _runService;
|
||||||
private readonly IVisualDevService _visualDevService;
|
private readonly IVisualDevService _visualDevService;
|
||||||
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
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();
|
_db = repository.AsSugarClient();
|
||||||
_runService = runService;
|
_runService = runService;
|
||||||
@@ -54,6 +55,36 @@ namespace Tnb.EquipMgr
|
|||||||
return await Task.FromResult("ok");
|
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