流程撤回优化管理员admin可以撤回任何流程
parent
8512b630c3
commit
23c87187de
|
@ -36,6 +36,7 @@ import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
|
@ -325,10 +326,7 @@ public class ProcessController {
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@GetMapping("/{id}")
|
@GetMapping("/{id}")
|
||||||
public ProjectProcessDetail get(@PathVariable int id) {
|
public ProjectProcessDetail get(@PathVariable int id) {
|
||||||
ProjectProcess process = processService.getById(id);
|
ProjectProcess process = obtainProjectProcess(id);
|
||||||
if (process == null) {
|
|
||||||
throw ErrorMessageException.failed("流程不存在");
|
|
||||||
}
|
|
||||||
|
|
||||||
ProjectProcessDetail detail = new ProjectProcessDetail();
|
ProjectProcessDetail detail = new ProjectProcessDetail();
|
||||||
detail.setProcessId(id);
|
detail.setProcessId(id);
|
||||||
|
@ -476,10 +474,7 @@ public class ProcessController {
|
||||||
@PutMapping("/{id}")
|
@PutMapping("/{id}")
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void update(@PathVariable int id, @RequestBody @Valid ProcessUpdateForm form) throws Exception {
|
public void update(@PathVariable int id, @RequestBody @Valid ProcessUpdateForm form) throws Exception {
|
||||||
ProjectProcess entity = processService.getById(id);
|
ProjectProcess entity = obtainProjectProcess(id);
|
||||||
if (entity == null) {
|
|
||||||
throw ErrorMessageException.failed("流程不存在");
|
|
||||||
}
|
|
||||||
|
|
||||||
Integer processId = entity.getId();
|
Integer processId = entity.getId();
|
||||||
ProcessType processType = entity.getProcessType();
|
ProcessType processType = entity.getProcessType();
|
||||||
|
@ -647,7 +642,29 @@ public class ProcessController {
|
||||||
@PostMapping("/revoke/{id}")
|
@PostMapping("/revoke/{id}")
|
||||||
public void revoke(@PathVariable("id") int id) {
|
public void revoke(@PathVariable("id") int id) {
|
||||||
// TODO 发起申请的人,在第一个人还没审批的情况下可以撤回
|
// 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
|
@ResponseBody
|
||||||
|
@ -657,7 +674,7 @@ public class ProcessController {
|
||||||
Integer applyUserId = admin.getId();
|
Integer applyUserId = admin.getId();
|
||||||
int update = jdbcTemplate.update("delete from project_process where id =? and apply_person_id=?", id, applyUserId);
|
int update = jdbcTemplate.update("delete from project_process where id =? and apply_person_id=?", id, applyUserId);
|
||||||
if (update != 1) {
|
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);
|
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查询销售合同
|
* 根据流程ID查询销售合同
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue