82 lines
3.3 KiB
C#
82 lines
3.3 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 EqpRepairOutApplyService : IEqpRepairOutApplyService, IDynamicApiController, ITransient
|
|
{
|
|
private readonly ISqlSugarRepository<EqpRepairOutApply> _repository;
|
|
private readonly IUserManager _userManager;
|
|
|
|
public EqpRepairOutApplyService(ISqlSugarRepository<EqpRepairOutApply> repository,
|
|
IUserManager userManager)
|
|
{
|
|
_repository = repository;
|
|
_userManager = userManager;
|
|
}
|
|
|
|
public async Task<string> OutApply(RepairOutApplyInput input)
|
|
{
|
|
|
|
var db = _repository.AsSugarClient();
|
|
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
|
{
|
|
if (string.IsNullOrEmpty(input.id))
|
|
{
|
|
await _repository.InsertAsync(new EqpRepairOutApply
|
|
{
|
|
id = SnowflakeIdHelper.NextId(),
|
|
repair_apply_id = input.repair_apply_id,
|
|
equip_id = input.equip_id,
|
|
supplier_id = input.supplier_id,
|
|
estimated_cost = input.estimated_cost,
|
|
construction_period_requirement = input.construction_period_requirement,
|
|
out_apply_reason = input.out_apply_reason,
|
|
remark = input.remark,
|
|
create_id = _userManager.UserId,
|
|
create_time = DateTime.Now,
|
|
approve_status = RepairOutApplyStatus.TOBEAPPROVE,
|
|
});
|
|
}
|
|
else
|
|
{
|
|
await _repository.UpdateAsync(x=>new EqpRepairOutApply
|
|
{
|
|
repair_apply_id = input.repair_apply_id,
|
|
equip_id = input.equip_id,
|
|
supplier_id = input.supplier_id,
|
|
estimated_cost = input.estimated_cost,
|
|
construction_period_requirement = input.construction_period_requirement,
|
|
out_apply_reason = input.out_apply_reason,
|
|
remark = input.remark,
|
|
create_id = _userManager.UserId,
|
|
create_time = DateTime.Now,
|
|
approve_status = RepairOutApplyStatus.TOBEAPPROVE,
|
|
},x=>x.id==input.id);
|
|
}
|
|
|
|
await db.Updateable<EqpRepairApply>()
|
|
.SetColumns(x=>x.status == RepairApplyStatus.OUTAPPLYAPPROVE)
|
|
.Where(x=>x.id==input.repair_apply_id).ExecuteCommandAsync();
|
|
|
|
});
|
|
|
|
if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
|
|
return result.IsSuccess ? "操作成功" : result.ErrorMessage;
|
|
}
|
|
}
|
|
} |