流程撤回优化管理员admin可以撤回任何流程
parent
8512b630c3
commit
23c87187de
|
@ -36,6 +36,7 @@ import java.util.Date;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
|
@ -325,10 +326,7 @@ public class ProcessController {
|
|||
@ResponseBody
|
||||
@GetMapping("/{id}")
|
||||
public ProjectProcessDetail get(@PathVariable int id) {
|
||||
ProjectProcess process = processService.getById(id);
|
||||
if (process == null) {
|
||||
throw ErrorMessageException.failed("流程不存在");
|
||||
}
|
||||
ProjectProcess process = obtainProjectProcess(id);
|
||||
|
||||
ProjectProcessDetail detail = new ProjectProcessDetail();
|
||||
detail.setProcessId(id);
|
||||
|
@ -476,10 +474,7 @@ public class ProcessController {
|
|||
@PutMapping("/{id}")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(@PathVariable int id, @RequestBody @Valid ProcessUpdateForm form) throws Exception {
|
||||
ProjectProcess entity = processService.getById(id);
|
||||
if (entity == null) {
|
||||
throw ErrorMessageException.failed("流程不存在");
|
||||
}
|
||||
ProjectProcess entity = obtainProjectProcess(id);
|
||||
|
||||
Integer processId = entity.getId();
|
||||
ProcessType processType = entity.getProcessType();
|
||||
|
@ -647,7 +642,29 @@ public class ProcessController {
|
|||
@PostMapping("/revoke/{id}")
|
||||
public void revoke(@PathVariable("id") int id) {
|
||||
// TODO 发起申请的人,在第一个人还没审批的情况下可以撤回
|
||||
processService.updateProcessStatus(id, ProcessStatus.draft);
|
||||
Admin admin = InterfaceUtil.getAdmin();
|
||||
if (admin == null) {
|
||||
throw ErrorMessageException.failed("权限不足");
|
||||
}
|
||||
if (Objects.equals("admin", admin.getUserName())) {
|
||||
processService.revoke(id);
|
||||
}
|
||||
else {
|
||||
ProjectProcess process = obtainProjectProcess(id);
|
||||
Integer applyPersonId = process.getApplyPersonId();
|
||||
if (!Objects.equals(admin.getId(), applyPersonId)) {
|
||||
throw ErrorMessageException.failed("流程不属于自己");
|
||||
}
|
||||
processService.revoke(id);
|
||||
}
|
||||
}
|
||||
|
||||
private ProjectProcess obtainProjectProcess(int id) {
|
||||
ProjectProcess projectProcess = processService.getById(id);
|
||||
if (projectProcess == null) {
|
||||
throw ErrorMessageException.failed("流程不存在");
|
||||
}
|
||||
return projectProcess;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
|
@ -657,7 +674,7 @@ public class ProcessController {
|
|||
Integer applyUserId = admin.getId();
|
||||
int update = jdbcTemplate.update("delete from project_process where id =? and apply_person_id=?", id, applyUserId);
|
||||
if (update != 1) {
|
||||
throw new RuntimeException("删除的流程不存在或者不属于自己");
|
||||
throw ErrorMessageException.failed("删除的流程不存在或者不属于自己");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -165,6 +165,16 @@ public class ProjectProcessService {
|
|||
jdbcTemplate.update("update project_process set `status`=? where id=?", status.getValue(), processId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 撤回流程
|
||||
*
|
||||
* @param processId 撤回的ID
|
||||
*/
|
||||
public void revoke(int processId) {
|
||||
jdbcTemplate.update("update project_process set current_audit=?, current_audit_id=?, `status`=? where id=?",
|
||||
null, null, ProcessStatus.draft.getValue(), processId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据流程ID查询销售合同
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue