维修添加状态判断
This commit is contained in:
@@ -111,23 +111,48 @@ namespace Tnb.EquipMgr
|
|||||||
{
|
{
|
||||||
string id = dic["id"];
|
string id = dic["id"];
|
||||||
string repairerId = dic["repairerId"];
|
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,
|
await _repository.UpdateAsync(x => new EqpRepairApply()
|
||||||
status = RepairApplyStatus.TOBERECEIVED,
|
{
|
||||||
}, x => x.id == id);
|
repairer_id = repairerId,
|
||||||
return "指派成功";
|
status = RepairApplyStatus.TOBERECEIVED,
|
||||||
|
}, x => x.id == id);
|
||||||
|
return "指派成功";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw Oops.Bah("状态错误");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<string> Receive(Dictionary<string, string> dic)
|
public async Task<string> Receive(Dictionary<string, string> dic)
|
||||||
{
|
{
|
||||||
string id = dic["id"];
|
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,
|
if (_userManager.UserId == eqpRepairApply.repairer_id)
|
||||||
}, x => x.id == id);
|
{
|
||||||
return "接收成功";
|
await _repository.UpdateAsync(x => new EqpRepairApply()
|
||||||
|
{
|
||||||
|
status = RepairApplyStatus.RECEIVED,
|
||||||
|
}, x => x.id == id);
|
||||||
|
return "接收成功";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw Oops.Bah("该任务没有指派给您,无法接收");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw Oops.Bah("状态错误");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
@@ -138,21 +163,37 @@ namespace Tnb.EquipMgr
|
|||||||
var db = _repository.AsSugarClient();
|
var db = _repository.AsSugarClient();
|
||||||
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
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,
|
if (_userManager.UserId == eqpRepairApply.repairer_id)
|
||||||
}, x => x.id == id);
|
{
|
||||||
EqpRepairRefuse eqpRepairRefuse = new EqpRepairRefuse()
|
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,
|
throw Oops.Bah("状态错误");
|
||||||
reason = reason,
|
}
|
||||||
create_id = _userManager.UserId,
|
|
||||||
create_time = DateTime.Now,
|
|
||||||
org_id = _userManager.GetUserInfo().Result.organizeId
|
|
||||||
};
|
|
||||||
await db.Insertable<EqpRepairRefuse>(eqpRepairRefuse).ExecuteCommandAsync();
|
|
||||||
});
|
});
|
||||||
if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
|
if(!result.IsSuccess) throw Oops.Oh(result.ErrorMessage);
|
||||||
return "拒绝成功";
|
return "拒绝成功";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,23 +207,39 @@ namespace Tnb.EquipMgr
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<string> Register(RepairApplyRegisterInput input)
|
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,
|
if (_userManager.UserId == eqpRepairApply.repairer_id)
|
||||||
is_complete = input.is_complete,
|
{
|
||||||
complete_time = input.complete_time,
|
string status = input.is_out_apply==1 ? RepairApplyStatus.TOBEOUTAPPLY : RepairApplyStatus.COMPLETED;
|
||||||
repair_take_time = input.repair_take_time,
|
await _repository.UpdateAsync(x => new EqpRepairApply()
|
||||||
is_halt = input.is_halt,
|
{
|
||||||
halt_take_time = input.halt_take_time,
|
fault_id = input.fault_id,
|
||||||
repair_description = input.repair_description,
|
is_complete = input.is_complete,
|
||||||
repair_img = input.repair_img,
|
complete_time = input.complete_time,
|
||||||
is_out_apply = input.is_out_apply,
|
repair_take_time = input.repair_take_time,
|
||||||
status = status,
|
is_halt = input.is_halt,
|
||||||
}, x => x.id == input.id);
|
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]
|
[HttpPost]
|
||||||
|
|||||||
@@ -51,91 +51,66 @@ namespace Tnb.EquipMgr
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<string> OutApply(RepairOutApplyInput input)
|
public async Task<string> OutApply(RepairOutApplyInput input)
|
||||||
{
|
{
|
||||||
|
EqpRepairApply eqpRepairApply = await _repository.AsSugarClient().Queryable<EqpRepairApply>().SingleAsync(x=>x.id==input.repair_apply_id);
|
||||||
var db = _repository.AsSugarClient();
|
if (eqpRepairApply.status == RepairApplyStatus.TOBEOUTAPPLY ||
|
||||||
string id = string.IsNullOrEmpty(input.id) ? SnowflakeIdHelper.NextId() : input.id;
|
eqpRepairApply.status == RepairApplyStatus.APPROVENOTPASS)
|
||||||
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
|
||||||
{
|
{
|
||||||
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
|
if (string.IsNullOrEmpty(input.id))
|
||||||
// {
|
|
||||||
// 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()
|
|
||||||
{
|
{
|
||||||
flowId = flowId,
|
// await _repository.InsertAsync(new EqpRepairOutApply
|
||||||
parentId = "0",
|
// {
|
||||||
formData = new JObject()
|
// id = id,
|
||||||
{
|
// repair_apply_id = input.repair_apply_id,
|
||||||
{"id",id},
|
// equip_id = input.equip_id,
|
||||||
{"flowId",flowId},
|
// supplier_id = input.supplier_id,
|
||||||
{"repair_apply_id",input.repair_apply_id},
|
// estimated_cost = input.estimated_cost,
|
||||||
{"equip_id",input.equip_id},
|
// construction_period_requirement = input.construction_period_requirement,
|
||||||
{"create_id",_userManager.UserId},
|
// out_apply_reason = input.out_apply_reason,
|
||||||
{"supplier_id",input.supplier_id},
|
// remark = input.remark,
|
||||||
{"estimated_cost",input.estimated_cost},
|
// create_id = _userManager.UserId,
|
||||||
{"construction_period_requirement",input.construction_period_requirement},
|
// create_time = DateTime.Now,
|
||||||
{"out_apply_reason",input.out_apply_reason},
|
// approve_status = RepairOutApplyStatus.TOBEAPPROVE,
|
||||||
{"remark",input.remark},
|
// });
|
||||||
{"approve_status",RepairOutApplyStatus.TOBEAPPROVE},
|
}
|
||||||
}
|
else
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var entity = await _repository.GetSingleAsync(x=>x.id==input.id);
|
|
||||||
if (entity != null)
|
|
||||||
{
|
{
|
||||||
|
// await _repository.UpdateAsync(x=>new EqpRepairOutApply
|
||||||
await _flowTaskService.Update("",new FlowTaskSubmitModel()
|
// {
|
||||||
|
// 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,
|
flowId = flowId,
|
||||||
parentId = "0",
|
parentId = "0",
|
||||||
id = entity?.flow_task_id??"",
|
|
||||||
formData = new JObject()
|
formData = new JObject()
|
||||||
{
|
{
|
||||||
{"id",id},
|
{"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]
|
[HttpPost]
|
||||||
|
|||||||
Reference in New Issue
Block a user