Merge branch 'dev' of https://git.tuotong-tech.com/tnb/tnb.server into dev
This commit is contained in:
70
EquipMgr/Tnb.EquipMgr/EquSpotInsTemEquipService.cs
Normal file
70
EquipMgr/Tnb.EquipMgr/EquSpotInsTemEquipService.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
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
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备管理
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
public class EquSpotInsTemEquipService : IEquSpotInsTemEquipService, IDynamicApiController, ITransient
|
||||
{
|
||||
private readonly ISqlSugarRepository<EqpSpotInsTemEquipH> _repository;
|
||||
|
||||
public EquSpotInsTemEquipService(ISqlSugarRepository<EqpSpotInsTemEquipH> repository)
|
||||
{
|
||||
_repository = repository;
|
||||
}
|
||||
|
||||
// public async Task<dynamic> GetTree()
|
||||
// {
|
||||
// List<EqpEquipment> eqpEquipments =
|
||||
// var data = _repository.AsSugarClient().Queryable<EqpEquipType>()
|
||||
// .Where(x => x.status == 1)
|
||||
// .Select((x) => new TreeModel
|
||||
// {
|
||||
// id = x.id,
|
||||
// parentId = "-1",
|
||||
// hasChildren = SqlFunc.Subqueryable<EqpEquipment>().Where(y=>y.eqp_type_id==x.id).Any(),
|
||||
// isLeaf = false,
|
||||
// num = SqlFunc.Subqueryable<EqpEquipment>().Where(y=>y.eqp_type_id==x.id).Count(),
|
||||
// children = SqlFunc.Subqueryable<EqpEquipment>().Where(y=>y.eqp_type_id==x.id).Select(y=>new TreeModel()
|
||||
// {
|
||||
//
|
||||
// }).ToList(model => ),
|
||||
// });
|
||||
// return new { list = 1 };
|
||||
// }
|
||||
|
||||
public async Task Stop(Dictionary<string, string> parameters)
|
||||
{
|
||||
string id = parameters["id"];
|
||||
DbResult<bool> result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
|
||||
{
|
||||
await _repository.UpdateAsync(x => new EqpSpotInsTemEquipH()
|
||||
{
|
||||
is_start = "0"
|
||||
}, x => x.id == id);
|
||||
List<string> ids = await _repository.AsSugarClient().Queryable<EqpSpotInsRecordH>()
|
||||
.Where(x => x.spot_ins_tem_equip_id == id && x.status == SpotInsRecordExecutionStatus.TOBEEXECUTED)
|
||||
.Select(x => x.id).ToListAsync();
|
||||
await _repository.AsSugarClient().Deleteable<EqpSpotInsRecordH>()
|
||||
.Where(x => x.spot_ins_tem_equip_id == id && x.status == SpotInsRecordExecutionStatus.TOBEEXECUTED).ExecuteCommandAsync();
|
||||
|
||||
await _repository.AsSugarClient().Deleteable<EqpSpotInsRecordD>()
|
||||
.Where(x => ids.Contains(x.spot_ins_record_id)).ExecuteCommandAsync();
|
||||
|
||||
});
|
||||
|
||||
if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user