using JNPF.Common.Enums; using JNPF.DependencyInjection; using JNPF.DynamicApiController; using JNPF.FriendlyException; using Microsoft.AspNetCore.Mvc; using SqlSugar; using Tnb.EquipMgr.Entities; using Tnb.EquipMgr.Interfaces; namespace Tnb.EquipMgr { /// /// 设备保养设备模板 /// [ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)] [Route("api/[area]/[controller]/[action]")] public class EqpMaintainTemEquipService : IEqpMaintainTemEquipService, IDynamicApiController, ITransient { private readonly ISqlSugarRepository _repository; public EqpMaintainTemEquipService(ISqlSugarRepository repository) { _repository = repository; } [HttpPost] public async Task Stop(Dictionary parameters) { string id = parameters["id"]; DbResult result = await _repository.AsSugarClient().Ado.UseTranAsync(async () => { _ = await _repository.UpdateAsync(x => new EqpMaintainTemEquipH() { is_start = "0" }, x => x.id == id); List ids = await _repository.AsSugarClient().Queryable() .Where(x => x.maintain_tem_equip_id == id && x.status == SpotInsRecordExecutionStatus.TOBEEXECUTED) .Select(x => x.id).ToListAsync(); _ = await _repository.AsSugarClient().Deleteable() .Where(x => x.maintain_tem_equip_id == id && x.status == SpotInsRecordExecutionStatus.TOBEEXECUTED).ExecuteCommandAsync(); _ = await _repository.AsSugarClient().Deleteable() .Where(x => ids.Contains(x.maintain_record_id)).ExecuteCommandAsync(); }); if (!result.IsSuccess) { throw Oops.Oh(ErrorCode.COM1008); } } } }