要将返回详情页面替换为返回上一个审批页面,可以按照以下步骤进行修改:

  1. 在方法的参数列表中添加一个名为"prevAction"的参数,用于接收上一个审批页面的action值。
  2. 在方法中判断如果"prevAction"不为空,即存在上一个审批页面,直接返回上一个审批页面的json对象。
  3. 如果"prevAction"为空,继续执行原有的逻辑。

修改后的代码如下:

@PostMapping(value="/getInfoByDefKeyInstId")
public  JSONObject getInfoByDefKeyInstId(@RequestParam(name = "type")String type,
                                         @RequestParam(name = "id",required = false)String id,
                                         @RequestParam(name = "action",required = false)String action,
                                         @RequestParam(name = "prevAction",required = false)String prevAction) throws Exception{
    //流程定义为空,实例为空
    if(StringUtils.isEmpty(type) || StringUtils.isEmpty(id)){
        JSONObject json=new JSONObject();
        json.put("success",false);
        json.put("message","没有输入参数");
        return json;
    }

    if(!typeList.contains(type)){
        JSONObject json=new JSONObject();
        json.put("success",false);
        json.put("message","输入类型无效!");
        return json;
    }
    //当类型为新建的时候
    if(TYPE_NEWDOC.equals(type)){
        BpmDef def= bpmDefService.getMainByKey(id);
        if(def==null){
            JSONObject json=new JSONObject();
            json.put("success",false);
            json.put("message","流程KEY无效");
            return json;
        }
        JSONObject json=new JSONObject();
        json.put("success",true);
        json.put("action","start");
        return json;
    }
    //解密instId
    JsonResult result=bpmInstService.getBpmInstDecrypt(id);
    if(!result.isSuccess()){
        JSONObject json=new JSONObject();
        json.put("success",false);
        json.put("message",result.getMessage());
        return json;
    }
    JSONObject resultJson=(JSONObject)result.getData();
    id=resultJson.getString("instId");
    boolean relType=resultJson.getBoolean("relType");
    //不是启动的情况,就是流程实例ID
    BpmInst bpmInst=bpmInstService.get(id);
    if(bpmInst==null){
        JSONObject json=new JSONObject();
        json.put("success",false);
        json.put("message","流程实例ID无效");
        return json;
    }

    String status=bpmInst.getStatus();
    //草稿状态。
    if(BpmInstStatus.DRAFTED.name().equals(status)){
        JSONObject json=new JSONObject();
        json.put("success",true);
        json.put("action","startDraft");
        json.put("relType",relType);
        json.put("defKey",bpmInst.getDefCode());
        json.put("instId",id);
        return json;
    }

    JPaasUser jPaasUser= (JPaasUser) ContextUtil.getCurrentUser();
    List<BpmTask> taskList= bpmTaskService.getByInstUserId(jPaasUser,id);
    if(BpmInstStatus.CANCEL.name().equals(status) ||
            BpmInstStatus.SUPSPEND.name().equals(status) ||
            taskList.size()==0 || "detail".equals(action)){
        JSONObject json=new JSONObject();
        json.put("success",true);
        json.put("relType",relType);
        json.put("action","detail");
        json.put("instId",id);
        return json;
    }

    BpmTask task=taskList.get(0);

    JSONObject json=new JSONObject();
    json.put("success",true);
    json.put("action","task");
    json.put("relType",relType);
    json.put("taskId",task.getTaskId());
    json.put("instId",id);
    return json;
}

在调用这个接口时,可以在请求参数中添加"prevAction"参数,传递上一个审批页面的action值。如果"prevAction"不为空,则返回上一个审批页面的json对象。如果"prevAction"为空,则继续执行原有的逻辑返回详情页面的json对象


原文地址: http://www.cveoy.top/t/topic/h7XQ 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录