using JNPF.Common.Enums; using JNPF.Common.Security; using JNPF.DependencyInjection; using JNPF.DynamicApiController; using JNPF.FriendlyException; using Microsoft.AspNetCore.Mvc; using SqlSugar; using Tnb.EquipMgr.Interfaces; using Tnb.EquipMgr.Entities; namespace Tnb.EquipMgr { /// /// 设备管理 /// [ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)] [Route("api/[area]/[controller]/[action]")] public class EquSpotInsTemEquipService : IEquSpotInsTemEquipService, IDynamicApiController, ITransient { private readonly ISqlSugarRepository _repository; public EquSpotInsTemEquipService(ISqlSugarRepository repository) { _repository = repository; } // public async Task GetTree() // { // List eqpEquipments = // var data = _repository.AsSugarClient().Queryable() // .Where(x => x.status == 1) // .Select((x) => new TreeModel // { // id = x.id, // parentId = "-1", // hasChildren = SqlFunc.Subqueryable().Where(y=>y.eqp_type_id==x.id).Any(), // isLeaf = false, // num = SqlFunc.Subqueryable().Where(y=>y.eqp_type_id==x.id).Count(), // children = SqlFunc.Subqueryable().Where(y=>y.eqp_type_id==x.id).Select(y=>new TreeModel() // { // // }).ToList(model => ), // }); // return new { list = 1 }; // } public async Task Stop(Dictionary parameters) { string id = parameters["id"]; DbResult result = await _repository.AsSugarClient().Ado.UseTranAsync(async () => { await _repository.UpdateAsync(x => new EqpSpotInsTemEquipH() { is_start = "0" }, x => x.id == id); List ids = await _repository.AsSugarClient().Queryable() .Where(x => x.spot_ins_tem_equip_id == id && x.status == SpotInsRecordExecutionStatus.TOBEEXECUTED) .Select(x => x.id).ToListAsync(); await _repository.AsSugarClient().Deleteable() .Where(x => x.spot_ins_tem_equip_id == id && x.status == SpotInsRecordExecutionStatus.TOBEEXECUTED).ExecuteCommandAsync(); await _repository.AsSugarClient().Deleteable() .Where(x => ids.Contains(x.spot_ins_record_id)).ExecuteCommandAsync(); }); if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008); } } }