67 lines
2.5 KiB
C#
67 lines
2.5 KiB
C#
using JNPF.Common.Dtos.VisualDev;
|
|
using JNPF.Common.Enums;
|
|
using JNPF.DependencyInjection;
|
|
using JNPF.DynamicApiController;
|
|
using JNPF.FriendlyException;
|
|
using JNPF.VisualDev;
|
|
using JNPF.VisualDev.Entitys;
|
|
using JNPF.VisualDev.Interfaces;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using SqlSugar;
|
|
using Tnb.EquipMgr.Entities;
|
|
using Tnb.EquipMgr.Entities.Dto;
|
|
using Tnb.EquipMgr.Interfaces;
|
|
using Tnb.ProductionMgr.Entities;
|
|
|
|
namespace Tnb.EquipMgr
|
|
{
|
|
/// <summary>
|
|
/// 模具归还接口
|
|
/// </summary>
|
|
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
|
|
[Route("api/[area]/[controller]/[action]")]
|
|
[OverideVisualDev(ModuleId)]
|
|
public class ToolMoldReturnService : IOverideVisualDevService, IToolMoldReturnService,IDynamicApiController, ITransient
|
|
{
|
|
private const string ModuleId = "27275901607701";
|
|
private readonly ISqlSugarClient _db;
|
|
private readonly IRunService _runService;
|
|
private readonly IVisualDevService _visualDevService;
|
|
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
|
|
|
public ToolMoldReturnService(
|
|
ISqlSugarRepository<ToolMoldReturn> repository,
|
|
IRunService runService,
|
|
IVisualDevService visualDevService
|
|
)
|
|
{
|
|
_db = repository.AsSugarClient();
|
|
_runService = runService;
|
|
_visualDevService = visualDevService;
|
|
OverideFuncs.CreateAsync = Create;
|
|
}
|
|
|
|
private async Task<dynamic> Create(VisualDevModelDataCrInput input)
|
|
{
|
|
DbResult<bool> result = await _db.Ado.UseTranAsync(async () =>
|
|
{
|
|
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true);
|
|
await _runService.Create(templateEntity, input);
|
|
|
|
|
|
string locationId = "";
|
|
if (input.data.TryGetValue("location_id", out var value))
|
|
{
|
|
locationId = value.ToString();
|
|
}
|
|
await _db.Updateable<ToolMolds>()
|
|
.SetColumns(x => x.mold_status == Tnb.BasicData.DictConst.ZKTypeId)
|
|
.SetColumnsIF(!string.IsNullOrEmpty(locationId),x=>x.location_id==locationId)
|
|
.Where(X => X.id == input.data["mold_id"]).ExecuteCommandAsync();
|
|
});
|
|
|
|
if (!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
|
|
return result.IsSuccess ? "保存成功" : result.ErrorMessage;
|
|
}
|
|
}
|
|
} |