维修添加状态判断
This commit is contained in:
@@ -111,23 +111,48 @@ namespace Tnb.EquipMgr
|
||||
{
|
||||
string id = dic["id"];
|
||||
string repairerId = dic["repairerId"];
|
||||
await _repository.UpdateAsync(x => new EqpRepairApply()
|
||||
EqpRepairApply eqpRepairApply = await _repository.GetSingleAsync(x=>x.id==id);
|
||||
if (eqpRepairApply.status == RepairApplyStatus.TOBEEXECUTED ||
|
||||
eqpRepairApply.status == RepairApplyStatus.REFUSE)
|
||||
{
|
||||
repairer_id = repairerId,
|
||||
status = RepairApplyStatus.TOBERECEIVED,
|
||||
}, x => x.id == id);
|
||||
return "指派成功";
|
||||
await _repository.UpdateAsync(x => new EqpRepairApply()
|
||||
{
|
||||
repairer_id = repairerId,
|
||||
status = RepairApplyStatus.TOBERECEIVED,
|
||||
}, x => x.id == id);
|
||||
return "指派成功";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw Oops.Bah("状态错误");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<string> Receive(Dictionary<string, string> dic)
|
||||
{
|
||||
string id = dic["id"];
|
||||
await _repository.UpdateAsync(x => new EqpRepairApply()
|
||||
EqpRepairApply eqpRepairApply = await _repository.GetSingleAsync(x=>x.id==id);
|
||||
if (eqpRepairApply.status == RepairApplyStatus.TOBERECEIVED)
|
||||
{
|
||||
status = RepairApplyStatus.RECEIVED,
|
||||
}, x => x.id == id);
|
||||
return "接收成功";
|
||||
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]
|
||||
@@ -138,21 +163,37 @@ namespace Tnb.EquipMgr
|
||||
var db = _repository.AsSugarClient();
|
||||
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
await _repository.UpdateAsync(x => new EqpRepairApply()
|
||||
EqpRepairApply eqpRepairApply = await _repository.GetSingleAsync(x=>x.id==id);
|
||||
if (eqpRepairApply.status == RepairApplyStatus.TOBERECEIVED)
|
||||
{
|
||||
status = RepairApplyStatus.REFUSE,
|
||||
}, x => x.id == id);
|
||||
EqpRepairRefuse eqpRepairRefuse = new EqpRepairRefuse()
|
||||
if (_userManager.UserId == eqpRepairApply.repairer_id)
|
||||
{
|
||||
await _repository.UpdateAsync(x => new EqpRepairApply()
|
||||
{
|
||||
status = RepairApplyStatus.REFUSE,
|
||||
}, x => x.id == id);
|
||||
EqpRepairRefuse eqpRepairRefuse = new EqpRepairRefuse()
|
||||
{
|
||||
repair_apply_id = id,
|
||||
reason = reason,
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now,
|
||||
org_id = _userManager.GetUserInfo().Result.organizeId
|
||||
};
|
||||
await db.Insertable<EqpRepairRefuse>(eqpRepairRefuse).ExecuteCommandAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw Oops.Bah("该任务没有指派给您,无法拒绝");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
repair_apply_id = id,
|
||||
reason = reason,
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now,
|
||||
org_id = _userManager.GetUserInfo().Result.organizeId
|
||||
};
|
||||
await db.Insertable<EqpRepairRefuse>(eqpRepairRefuse).ExecuteCommandAsync();
|
||||
throw Oops.Bah("状态错误");
|
||||
}
|
||||
|
||||
});
|
||||
if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
|
||||
if(!result.IsSuccess) throw Oops.Oh(result.ErrorMessage);
|
||||
return "拒绝成功";
|
||||
}
|
||||
|
||||
@@ -166,23 +207,39 @@ namespace Tnb.EquipMgr
|
||||
[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()
|
||||
EqpRepairApply eqpRepairApply = await _repository.GetSingleAsync(x=>x.id==input.id);
|
||||
if (eqpRepairApply.status == RepairApplyStatus.TOBERECEIVED)
|
||||
{
|
||||
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,
|
||||
repair_img = input.repair_img,
|
||||
is_out_apply = input.is_out_apply,
|
||||
status = status,
|
||||
}, x => x.id == input.id);
|
||||
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,
|
||||
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,
|
||||
repair_img = input.repair_img,
|
||||
is_out_apply = input.is_out_apply,
|
||||
status = status,
|
||||
}, x => x.id == input.id);
|
||||
return "登记成功";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw Oops.Bah("您不是责任人");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw Oops.Bah("状态错误");
|
||||
}
|
||||
|
||||
return "登记成功";
|
||||
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user