66 lines
2.5 KiB
C#
66 lines
2.5 KiB
C#
using JNPF.Common.Core.Manager;
|
|
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.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 EqpRepairDelayService : IEqpRepairDelayService, IDynamicApiController, ITransient
|
|
{
|
|
private readonly ISqlSugarRepository<EqpRepairDelay> _repository;
|
|
private readonly IUserManager _userManager;
|
|
|
|
public EqpRepairDelayService(ISqlSugarRepository<EqpRepairDelay> repository,
|
|
IUserManager userManager)
|
|
{
|
|
_repository = repository;
|
|
_userManager = userManager;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 维修延期
|
|
/// </summary>
|
|
[HttpPost]
|
|
public async Task<string> Delay(RepairDelayInput input)
|
|
{
|
|
DbResult<bool> result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
|
|
{
|
|
EqpRepairApply eqpRepairApply = await _repository.AsSugarClient().Queryable<EqpRepairApply>().SingleAsync(x => x.id == input.repair_apply_id);
|
|
EqpRepairDelay repairDelay = new()
|
|
{
|
|
id = SnowflakeIdHelper.NextId(),
|
|
equip_id = eqpRepairApply?.equip_id ?? "",
|
|
repair_apply_id = input.repair_apply_id,
|
|
delay_reason = input.delay_reason,
|
|
expected_time = input.expected_time,
|
|
repair_request_sender_id = input.repair_request_sender_id,
|
|
repair_sender_id = input.repair_request_sender_id,
|
|
create_id = _userManager.UserId,
|
|
create_time = DateTime.Now,
|
|
|
|
};
|
|
_ = await _repository.InsertAsync(repairDelay);
|
|
|
|
_ = await _repository.AsSugarClient().Updateable<EqpRepairApply>()
|
|
.SetColumns(x => x.expect_complete_time == input.expected_time)
|
|
.Where(x => x.id == input.repair_apply_id).ExecuteCommandAsync();
|
|
});
|
|
|
|
return !result.IsSuccess ? throw Oops.Oh(ErrorCode.COM1008) : result.IsSuccess ? "延期成功" : result.ErrorMessage;
|
|
}
|
|
|
|
}
|
|
} |