119 lines
5.2 KiB
C#
119 lines
5.2 KiB
C#
using JNPF.Common.Core.Manager;
|
|
using JNPF.Common.Filter;
|
|
using JNPF.DependencyInjection;
|
|
using JNPF.DynamicApiController;
|
|
using JNPF.Systems.Entitys.Permission;
|
|
using JNPF.Systems.Entitys.System;
|
|
using JNPF.VisualDev;
|
|
using JNPF.VisualDev.Entitys.Dto.VisualDevModelData;
|
|
using JNPF.VisualDev.Interfaces;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Newtonsoft.Json;
|
|
using SqlSugar;
|
|
using Tnb.BasicData;
|
|
using Tnb.EquipMgr.Entities;
|
|
using Tnb.EquipMgr.Entities.Dto;
|
|
|
|
namespace Tnb.EquipMgr.App
|
|
{
|
|
/// <summary>
|
|
/// app设备维修登记
|
|
/// </summary>
|
|
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
|
|
[Route("api/[area]/[controller]/[action]")]
|
|
[OverideVisualDev(ModuleId)]
|
|
public class AppEqpRepairApplyService : IOverideVisualDevService, IDynamicApiController, ITransient
|
|
{
|
|
private const string ModuleId = "28621611210261";
|
|
private readonly ISqlSugarRepository<EqpRepairApply> _repository;
|
|
private readonly IUserManager _userManager;
|
|
private readonly IRunService _runService;
|
|
private readonly IVisualDevService _visualDevService;
|
|
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
|
|
|
public AppEqpRepairApplyService(ISqlSugarRepository<EqpRepairApply> repository,
|
|
IRunService runService,
|
|
IVisualDevService visualDevService,
|
|
IUserManager userManager)
|
|
{
|
|
_repository = repository;
|
|
_userManager = userManager;
|
|
_runService = runService;
|
|
_visualDevService = visualDevService;
|
|
OverideFuncs.GetListAsync = GetList;
|
|
}
|
|
|
|
private async Task<dynamic> GetList(VisualDevModelListQueryInput input)
|
|
{
|
|
ISqlSugarClient db = _repository.AsSugarClient();
|
|
Dictionary<string, object>? queryJson = !string.IsNullOrEmpty(input.queryJson) ? JsonConvert.DeserializeObject<Dictionary<string, object>>(input.queryJson) : new Dictionary<string, object>();
|
|
string? code = queryJson != null && queryJson.ContainsKey("code") ? queryJson["code"].ToString() : "";
|
|
string? name = queryJson != null && queryJson.ContainsKey("name") ? queryJson["name"].ToString() : "";
|
|
string userId = _userManager.UserId;
|
|
SqlSugarPagedList<PdaRepairApplyListOutput> result = await db.Queryable<EqpRepairApply>()
|
|
.LeftJoin<EqpEquipment>((a, b) => a.equip_id == b.id)
|
|
.LeftJoin<UserEntity>((a, b, c) => a.apply_user_id == c.Id)
|
|
.LeftJoin<DictionaryTypeEntity>((a, b, c, d) => d.EnCode == DictConst.RepairStatus)
|
|
.LeftJoin<DictionaryDataEntity>((a, b, c, d, e) => a.status == e.EnCode && d.Id == e.DictionaryTypeId)
|
|
.WhereIF(!string.IsNullOrEmpty("code"), (a, b, c) => a.code.Contains(code))
|
|
.WhereIF(!string.IsNullOrEmpty("name"), (a, b, c) => a.name.Contains(name))
|
|
.Where((a, b, c) => a.repairer_id == userId)
|
|
.Where((a, b, c) => a.status == "2" || a.status == "3")
|
|
.Select((a, b, c, d, e) => new PdaRepairApplyListOutput
|
|
{
|
|
id = a.id,
|
|
code = a.code,
|
|
name = a.name,
|
|
equip_id = b.code + "/" + b.name,
|
|
equip_id_id = a.equip_id,
|
|
expect_complete_time = a.expect_complete_time == null ? "" : a.expect_complete_time.Value.ToString("yyyy-MM-dd"),
|
|
is_ugent = a.is_ugent == null ? "" : a.is_ugent == 0 ? "否" : "是",
|
|
description = a.description,
|
|
status = e.FullName,
|
|
apply_user_id = SqlFunc.IsNull(c.RealName, "异常停机"),
|
|
apply_user_id_id = a.create_id,
|
|
// repairer_id = c.RealName,
|
|
// repairer_id_id = a.repairer_id,
|
|
}).ToPagedListAsync(input.currentPage, input.pageSize);
|
|
|
|
return PageResult<PdaRepairApplyListOutput>.SqlSugarPageResult(result);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 根据id获取维修相关信息
|
|
/// </summary>
|
|
/// <param name="dic"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public async Task<dynamic?> GetRepairInfoById(Dictionary<string, string> dic)
|
|
{
|
|
string id = dic.ContainsKey("id") ? dic["id"] : "";
|
|
if (string.IsNullOrEmpty(id))
|
|
{
|
|
return null;
|
|
}
|
|
|
|
ISqlSugarClient db = _repository.AsSugarClient();
|
|
return await db.Queryable<EqpRepairApply>()
|
|
.LeftJoin<EqpEquipment>((a, b) => a.equip_id == b.id)
|
|
.Where((a, b) => a.id == id)
|
|
.Select((a, b) => new
|
|
{
|
|
a.id,
|
|
a.code,
|
|
a.name,
|
|
a.equip_id,
|
|
equip_code = b.code,
|
|
equip_name = b.name,
|
|
expect_complete_time = a.expect_complete_time == null ? "" : a.expect_complete_time.Value.ToString("yyyy-MM-dd"),
|
|
a.is_ugent,
|
|
a.description,
|
|
a.status,
|
|
a.repairer_id,
|
|
}).FirstAsync();
|
|
|
|
}
|
|
|
|
}
|
|
} |