65 lines
2.8 KiB
C#
65 lines
2.8 KiB
C#
using JNPF.Common.Core.Manager;
|
|
using JNPF.Common.Filter;
|
|
using JNPF.DependencyInjection;
|
|
using JNPF.DynamicApiController;
|
|
using JNPF.Systems.Entitys.Permission;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Newtonsoft.Json;
|
|
using SqlSugar;
|
|
using Tnb.BasicData;
|
|
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 EqpDaqService : IEqpDaqService, IDynamicApiController, ITransient
|
|
{
|
|
private readonly ISqlSugarRepository<EqpDaq> _repository;
|
|
private readonly IUserManager _userManager;
|
|
|
|
public EqpDaqService(ISqlSugarRepository<EqpDaq> repository, IUserManager userManager)
|
|
{
|
|
_userManager = userManager;
|
|
_repository = repository;
|
|
}
|
|
|
|
[HttpPost]
|
|
public async Task<dynamic> GetEquipDaqList(EquipQueryInput input)
|
|
{
|
|
ISqlSugarClient db = _repository.AsSugarClient();
|
|
Dictionary<string, string>? queryJson = new();
|
|
if (input != null && !string.IsNullOrEmpty(input.queryJson))
|
|
{
|
|
queryJson = JsonConvert.DeserializeObject<Dictionary<string, string>>(input.queryJson);
|
|
}
|
|
SqlSugarPagedList<EquipDaqQueryOutput> result = await db.Queryable<EqpDaq>()
|
|
.LeftJoin<UserEntity>((a, b) => a.create_id == b.Id)
|
|
.WhereIF(input != null, a => a.equip_id == input!.equip_id)
|
|
.WhereIF(queryJson != null && queryJson.ContainsKey("data_source"), a => a.data_source == queryJson!["data_source"])
|
|
.WhereIF(queryJson != null && queryJson.ContainsKey("label_name"), a => a.label_name.Contains(queryJson!["label_name"]))
|
|
.WhereIF(queryJson != null && queryJson.ContainsKey("label_point"), a => a.label_point.Contains(queryJson!["label_point"]))
|
|
.Select((a, b) => new EquipDaqQueryOutput
|
|
{
|
|
id = a.id,
|
|
data_source = a.data_source,
|
|
create_id = b.RealName,
|
|
create_time = a.create_time == null ? null : a.create_time.Value.ToString(DbTimeFormat.MM),
|
|
data_type = a.data_type,
|
|
enabled = a.enabled == 1 ? "是" : "否",
|
|
equip_id = a.equip_id,
|
|
equip_code = a.equip_code,
|
|
label_name = a.label_name,
|
|
label_point = a.label_point,
|
|
remark = a.remark
|
|
}).ToPagedListAsync(input?.currentPage ?? 1, input?.pageSize ?? 50);
|
|
|
|
return PageResult<EquipDaqQueryOutput>.SqlSugarPageResult(result);
|
|
}
|
|
}
|
|
} |