67 lines
2.9 KiB
C#
67 lines
2.9 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.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 EqpSubEquipService : IEqpSubEquipService, IDynamicApiController, ITransient
|
|
{
|
|
private readonly ISqlSugarRepository<EqpSubEquip> _repository;
|
|
private readonly IUserManager _userManager;
|
|
|
|
public EqpSubEquipService(ISqlSugarRepository<EqpSubEquip> repository,
|
|
IUserManager userManager)
|
|
{
|
|
_repository = repository;
|
|
_userManager = userManager;
|
|
}
|
|
|
|
[HttpPost]
|
|
public async Task<dynamic> GetSubEquipList(EquipQueryInput input)
|
|
{
|
|
var db = _repository.AsSugarClient();
|
|
Dictionary<string, string>? queryJson = new Dictionary<string, string>();
|
|
if (!string.IsNullOrEmpty(input.queryJson))
|
|
{
|
|
queryJson = JsonConvert.DeserializeObject<Dictionary<string, string>>(input.queryJson);
|
|
}
|
|
var result = await db.Queryable<EqpSubEquip>()
|
|
.LeftJoin<UserEntity>((a, b) => a.create_id == b.Id)
|
|
.LeftJoin<UserEntity>((a, b, c) => a.modify_id == c.Id)
|
|
.LeftJoin<EqpEquipment>((a, b, c, d) => a.equip_id == d.id)
|
|
.Where((a, b, c, d) => a.equip_id == input.equip_id)
|
|
.WhereIF(queryJson != null && queryJson.ContainsKey("code"), (a, b, c, d) => a.code.Contains(queryJson!["code"]))
|
|
.WhereIF(queryJson != null && queryJson.ContainsKey("name"), (a, b, c, d) => a.name.Contains(queryJson!["name"]))
|
|
.Select((a, b, c, d) => new SubEquipQueryOutput
|
|
{
|
|
id = a.id,
|
|
create_id = b.RealName,
|
|
create_id_id = a.create_id,
|
|
create_time = a.create_time == null ? null : a.create_time.Value.ToString("yyyy-MM-dd"),
|
|
equip_id = d.name,
|
|
equip_id_id = a.equip_id,
|
|
code = a.code,
|
|
modify_id = c.RealName,
|
|
modify_time = a.modify_time == null ? null : a.modify_time.Value.ToString("yyyy-MM-dd"),
|
|
name = a.name,
|
|
org_id = a.org_id,
|
|
specification = a.specification,
|
|
}).ToPagedListAsync(input.currentPage, input.pageSize);
|
|
|
|
return PageResult<SubEquipQueryOutput>.SqlSugarPageResult(result);
|
|
}
|
|
}
|
|
} |