@PostMapping({"/startArchive3"}) public JsonResult startArchive3(String workId ){ try { Map<String,String> params = new HashMap<>(); params.put("传数据工号",workId); organizationClient.addBasicLog(params); JsonResult handoverBasic = organizationClient.getHandoverBasicByNameOrWorkId(workId); List data1 = (List) handoverBasic.getData(); Map data2=null; if (data1.size()>0){ data2 = (Map) data1.get(0); } String instId = data2.get("instId").toString(); String interView = data2.get("leaveInterviewId").toString();

    List<BpmInstData> bpmInstDatas = bpmInstDataService.getByInstId(instId);
    Map<String,Object> params2 = new HashMap<>();

    Map<String,Object> params3 = new HashMap<>();

    if(bpmInstDatas.isEmpty()){
        //自定义表单为空,暂传空数据
        JsonResult jsonResult = new JsonResult(200);
        return jsonResult.setData(new BpmView());
    }
    BpmInstData bpmInstData = bpmInstDatas.get(0);
    JsonResult  result=formClient.getByAlias(bpmInstData.getBodefAlias(),bpmInstData.getPk(),true);
    JSONObject formData = new JSONObject(result.getData());

    BpmInstDetail detail=bpmInstService.getInstDetail(instId,"NO",false,"");
    List<BpmCheckHistory> history = bpmCheckHistoryService.getByInstId(instId);
    params2.put("id",interView);

    JsonResult jsonResult = organizationClient.queryInterview2(params2);
    params3.put("interview",jsonResult.getData());
    params3.put("detail",detail);
    params3.put("history",history);
    Object data = result.getData();
    params3.put("formData",result.getData());
    JsonResult jsonResult1 = archiveClient.addFirst2(params3);

    return jsonResult1;
} catch (Exception e) {     // 处理异常
    e.printStackTrace();     // 返回自定义错误信息
    return new JsonResult(500, "服务器错误");
}

}

Spring Boot @PostMapping 处理异常:使用 try-catch 块

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

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