设备保养执行 复核 设备报废
This commit is contained in:
58
EquipMgr/Tnb.EquipMgr/EqpEquipScrapService.cs
Normal file
58
EquipMgr/Tnb.EquipMgr/EqpEquipScrapService.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using JNPF.Common.Core.Manager;
|
||||
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 Newtonsoft.Json;
|
||||
using SqlSugar;
|
||||
using Tnb.EquipMgr.Entities;
|
||||
using Tnb.EquipMgr.Entities.Dto;
|
||||
using Tnb.EquipMgr.Interfaces;
|
||||
|
||||
namespace Tnb.EquipMgr
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备保养计划执行管理
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
public class EqpEquipScrapService : IEqpEquipScrapService, IDynamicApiController, ITransient
|
||||
{
|
||||
private readonly ISqlSugarRepository<EqpEquipScrap> _repository;
|
||||
private readonly IUserManager _userManager;
|
||||
|
||||
public EqpEquipScrapService(ISqlSugarRepository<EqpEquipScrap> repository,
|
||||
IUserManager userManager)
|
||||
{
|
||||
_repository = repository;
|
||||
_userManager = userManager;
|
||||
// OverideFuncs.UpdateAsync = ExecuteSpotIns;
|
||||
}
|
||||
|
||||
|
||||
[HttpPost]
|
||||
public async Task<string> Scrap(EqpEquipScrap eqpEquipScrap)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
eqpEquipScrap.create_id = _userManager.UserId;
|
||||
eqpEquipScrap.create_time = DateTime.Now;
|
||||
|
||||
await _repository.InsertAsync(eqpEquipScrap);
|
||||
|
||||
await db.Updateable<EqpEquipment>().SetColumns(x => x.life == EquipmentLife.SCRAP)
|
||||
.Where(x => x.id == eqpEquipScrap.equip_id).ExecuteCommandAsync();
|
||||
});
|
||||
if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
|
||||
|
||||
return result.IsSuccess ? "报废成功" : result.ErrorMessage;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user