维修添加状态判断

This commit is contained in:
2023-10-25 11:16:38 +08:00
parent 6268f63b0e
commit 06349a3468
2 changed files with 180 additions and 114 deletions

View File

@@ -51,91 +51,66 @@ namespace Tnb.EquipMgr
[HttpPost]
public async Task<string> OutApply(RepairOutApplyInput input)
{
var db = _repository.AsSugarClient();
string id = string.IsNullOrEmpty(input.id) ? SnowflakeIdHelper.NextId() : input.id;
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
EqpRepairApply eqpRepairApply = await _repository.AsSugarClient().Queryable<EqpRepairApply>().SingleAsync(x=>x.id==input.repair_apply_id);
if (eqpRepairApply.status == RepairApplyStatus.TOBEOUTAPPLY ||
eqpRepairApply.status == RepairApplyStatus.APPROVENOTPASS)
{
if (string.IsNullOrEmpty(input.id))
var db = _repository.AsSugarClient();
string id = string.IsNullOrEmpty(input.id) ? SnowflakeIdHelper.NextId() : input.id;
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
{
// await _repository.InsertAsync(new EqpRepairOutApply
// {
// id = id,
// 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);
if (result.IsSuccess)
{
if (string.IsNullOrEmpty(input.id))
{
await _flowTaskService.Create(new FlowTaskSubmitModel()
if (string.IsNullOrEmpty(input.id))
{
flowId = flowId,
parentId = "0",
formData = new JObject()
{
{"id",id},
{"flowId",flowId},
{"repair_apply_id",input.repair_apply_id},
{"equip_id",input.equip_id},
{"create_id",_userManager.UserId},
{"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},
{"approve_status",RepairOutApplyStatus.TOBEAPPROVE},
}
});
}
else
{
var entity = await _repository.GetSingleAsync(x=>x.id==input.id);
if (entity != null)
// await _repository.InsertAsync(new EqpRepairOutApply
// {
// id = id,
// 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 _flowTaskService.Update("",new FlowTaskSubmitModel()
// 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);
if (result.IsSuccess)
{
if (string.IsNullOrEmpty(input.id))
{
await _flowTaskService.Create(new FlowTaskSubmitModel()
{
flowId = flowId,
parentId = "0",
id = entity?.flow_task_id??"",
formData = new JObject()
{
{"id",id},
@@ -153,9 +128,43 @@ namespace Tnb.EquipMgr
});
}
else
{
var entity = await _repository.GetSingleAsync(x=>x.id==input.id);
if (entity != null)
{
await _flowTaskService.Update("",new FlowTaskSubmitModel()
{
flowId = flowId,
parentId = "0",
id = entity?.flow_task_id??"",
formData = new JObject()
{
{"id",id},
{"flowId",flowId},
{"repair_apply_id",input.repair_apply_id},
{"equip_id",input.equip_id},
{"create_id",_userManager.UserId},
{"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},
{"approve_status",RepairOutApplyStatus.TOBEAPPROVE},
}
});
}
}
}
return result.IsSuccess ? "操作成功" : result.ErrorMessage;
}
return result.IsSuccess ? "操作成功" : result.ErrorMessage;
else
{
throw Oops.Bah("状态错误");
}
}
[HttpPost]