维修管理
This commit is contained in:
118
EquipMgr/Tnb.EquipMgr/EqpRepairApplyService.cs
Normal file
118
EquipMgr/Tnb.EquipMgr/EqpRepairApplyService.cs
Normal file
@@ -0,0 +1,118 @@
|
||||
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 EqpRepairApplyService : IEqpRepairApplyService, IDynamicApiController, ITransient
|
||||
{
|
||||
private readonly ISqlSugarRepository<EqpRepairApply> _repository;
|
||||
private readonly IUserManager _userManager;
|
||||
|
||||
public EqpRepairApplyService(ISqlSugarRepository<EqpRepairApply> repository,
|
||||
IUserManager userManager)
|
||||
{
|
||||
_repository = repository;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<string> Repeal(Dictionary<string, string> dic)
|
||||
{
|
||||
string id = dic["id"];
|
||||
await _repository.UpdateAsync(x => new EqpRepairApply()
|
||||
{
|
||||
status = RepairApplyStatus.REPEAL
|
||||
}, x => x.id == id);
|
||||
return "作废成功";
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<string> Close(Dictionary<string, string> dic)
|
||||
{
|
||||
string id = dic["id"];
|
||||
await _repository.UpdateAsync(x => new EqpRepairApply()
|
||||
{
|
||||
status = RepairApplyStatus.CLOSE
|
||||
}, x => x.id == id);
|
||||
return "关闭成功";
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<string> Assign(Dictionary<string, string> dic)
|
||||
{
|
||||
string id = dic["id"];
|
||||
string repairerId = dic["repairerId"];
|
||||
await _repository.UpdateAsync(x => new EqpRepairApply()
|
||||
{
|
||||
repairer_id = repairerId,
|
||||
status = RepairApplyStatus.TOBERECEIVED,
|
||||
}, x => x.id == id);
|
||||
return "指派成功";
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<string> Receive(Dictionary<string, string> dic)
|
||||
{
|
||||
string id = dic["id"];
|
||||
await _repository.UpdateAsync(x => new EqpRepairApply()
|
||||
{
|
||||
status = RepairApplyStatus.RECEIVED,
|
||||
}, x => x.id == id);
|
||||
return "接收成功";
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<string> Refuse(Dictionary<string, string> dic)
|
||||
{
|
||||
string id = dic["id"];
|
||||
await _repository.UpdateAsync(x => new EqpRepairApply()
|
||||
{
|
||||
status = RepairApplyStatus.REFUSE,
|
||||
}, x => x.id == id);
|
||||
return "拒绝成功";
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<EqpRepairApply> GetInfo(Dictionary<string, string> dic)
|
||||
{
|
||||
string id = dic["id"];
|
||||
return await _repository.GetSingleAsync(x => x.id == id);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<string> Register(RepairApplyRegisterInput input)
|
||||
{
|
||||
string status = input.is_out_apply==1 ? RepairApplyStatus.TOBEOUTAPPLY : RepairApplyStatus.COMPLETED;
|
||||
|
||||
await _repository.UpdateAsync(x => new EqpRepairApply()
|
||||
{
|
||||
fault_id = input.fault_id,
|
||||
is_complete = input.is_complete,
|
||||
complete_time = input.complete_time,
|
||||
repair_take_time = input.repair_take_time,
|
||||
is_halt = input.is_halt,
|
||||
halt_take_time = input.halt_take_time,
|
||||
repair_description = input.repair_description,
|
||||
attachment = input.attachment,
|
||||
is_out_apply = input.is_out_apply,
|
||||
status = status,
|
||||
}, x => x.id == input.id);
|
||||
|
||||
return "登记成功";
|
||||
}
|
||||
}
|
||||
}
|
||||
68
EquipMgr/Tnb.EquipMgr/EqpRepairDelayService.cs
Normal file
68
EquipMgr/Tnb.EquipMgr/EqpRepairDelayService.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
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>
|
||||
/// <param name="dic"></param>
|
||||
[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 EqpRepairDelay()
|
||||
{
|
||||
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();
|
||||
});
|
||||
|
||||
if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
|
||||
return result.IsSuccess ? "延期成功" : result.ErrorMessage;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
82
EquipMgr/Tnb.EquipMgr/EqpRepairOutApplyService.cs
Normal file
82
EquipMgr/Tnb.EquipMgr/EqpRepairOutApplyService.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user