维修添加状态判断
This commit is contained in:
@@ -111,6 +111,10 @@ namespace Tnb.EquipMgr
|
||||
{
|
||||
string id = dic["id"];
|
||||
string repairerId = dic["repairerId"];
|
||||
EqpRepairApply eqpRepairApply = await _repository.GetSingleAsync(x=>x.id==id);
|
||||
if (eqpRepairApply.status == RepairApplyStatus.TOBEEXECUTED ||
|
||||
eqpRepairApply.status == RepairApplyStatus.REFUSE)
|
||||
{
|
||||
await _repository.UpdateAsync(x => new EqpRepairApply()
|
||||
{
|
||||
repairer_id = repairerId,
|
||||
@@ -118,17 +122,38 @@ namespace Tnb.EquipMgr
|
||||
}, x => x.id == id);
|
||||
return "指派成功";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw Oops.Bah("状态错误");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<string> Receive(Dictionary<string, string> dic)
|
||||
{
|
||||
string id = dic["id"];
|
||||
EqpRepairApply eqpRepairApply = await _repository.GetSingleAsync(x=>x.id==id);
|
||||
if (eqpRepairApply.status == RepairApplyStatus.TOBERECEIVED)
|
||||
{
|
||||
if (_userManager.UserId == eqpRepairApply.repairer_id)
|
||||
{
|
||||
await _repository.UpdateAsync(x => new EqpRepairApply()
|
||||
{
|
||||
status = RepairApplyStatus.RECEIVED,
|
||||
}, x => x.id == id);
|
||||
return "接收成功";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw Oops.Bah("该任务没有指派给您,无法接收");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw Oops.Bah("状态错误");
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<string> Refuse(Dictionary<string, string> dic)
|
||||
@@ -137,6 +162,11 @@ namespace Tnb.EquipMgr
|
||||
string reason = dic["reason"];
|
||||
var db = _repository.AsSugarClient();
|
||||
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
EqpRepairApply eqpRepairApply = await _repository.GetSingleAsync(x=>x.id==id);
|
||||
if (eqpRepairApply.status == RepairApplyStatus.TOBERECEIVED)
|
||||
{
|
||||
if (_userManager.UserId == eqpRepairApply.repairer_id)
|
||||
{
|
||||
await _repository.UpdateAsync(x => new EqpRepairApply()
|
||||
{
|
||||
@@ -151,8 +181,19 @@ namespace Tnb.EquipMgr
|
||||
org_id = _userManager.GetUserInfo().Result.organizeId
|
||||
};
|
||||
await db.Insertable<EqpRepairRefuse>(eqpRepairRefuse).ExecuteCommandAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw Oops.Bah("该任务没有指派给您,无法拒绝");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw Oops.Bah("状态错误");
|
||||
}
|
||||
|
||||
});
|
||||
if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
|
||||
if(!result.IsSuccess) throw Oops.Oh(result.ErrorMessage);
|
||||
return "拒绝成功";
|
||||
}
|
||||
|
||||
@@ -166,8 +207,13 @@ namespace Tnb.EquipMgr
|
||||
[HttpPost]
|
||||
public async Task<string> Register(RepairApplyRegisterInput input)
|
||||
{
|
||||
string status = input.is_out_apply==1 ? RepairApplyStatus.TOBEOUTAPPLY : RepairApplyStatus.COMPLETED;
|
||||
|
||||
EqpRepairApply eqpRepairApply = await _repository.GetSingleAsync(x=>x.id==input.id);
|
||||
if (eqpRepairApply.status == RepairApplyStatus.TOBERECEIVED)
|
||||
{
|
||||
if (_userManager.UserId == eqpRepairApply.repairer_id)
|
||||
{
|
||||
string status = input.is_out_apply==1 ? RepairApplyStatus.TOBEOUTAPPLY : RepairApplyStatus.COMPLETED;
|
||||
await _repository.UpdateAsync(x => new EqpRepairApply()
|
||||
{
|
||||
fault_id = input.fault_id,
|
||||
@@ -181,9 +227,20 @@ namespace Tnb.EquipMgr
|
||||
is_out_apply = input.is_out_apply,
|
||||
status = status,
|
||||
}, x => x.id == input.id);
|
||||
|
||||
return "登记成功";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw Oops.Bah("您不是责任人");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw Oops.Bah("状态错误");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<RepairApplyDetailOutput> GetRepairApplyDetail(Dictionary<string, string> dic)
|
||||
|
||||
@@ -51,7 +51,10 @@ namespace Tnb.EquipMgr
|
||||
[HttpPost]
|
||||
public async Task<string> OutApply(RepairOutApplyInput input)
|
||||
{
|
||||
|
||||
EqpRepairApply eqpRepairApply = await _repository.AsSugarClient().Queryable<EqpRepairApply>().SingleAsync(x=>x.id==input.repair_apply_id);
|
||||
if (eqpRepairApply.status == RepairApplyStatus.TOBEOUTAPPLY ||
|
||||
eqpRepairApply.status == RepairApplyStatus.APPROVENOTPASS)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
string id = string.IsNullOrEmpty(input.id) ? SnowflakeIdHelper.NextId() : input.id;
|
||||
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||
@@ -157,6 +160,12 @@ namespace Tnb.EquipMgr
|
||||
}
|
||||
return result.IsSuccess ? "操作成功" : result.ErrorMessage;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw Oops.Bah("状态错误");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<string> Register(RepairApplyOutRegisterInput input)
|
||||
|
||||
Reference in New Issue
Block a user