结构化表单生成方法添加异常捕捉返回

master
jiangwl 2 years ago
parent ee4a3f8708
commit c754435378

@ -21,6 +21,7 @@ import org.springframework.util.ResourceUtils;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.List;
@ -105,6 +106,13 @@ public class GenerateFileServiceImpl implements GenerateFileService {
path = FileContentUtil.pdfOut(getData(object, img), getModelPath(templatePath), fileUtil, getNewPath(templatePath, dto.getExamCode()), (Integer) type.get("page_num"));
} catch (FileNotFoundException e) {
e.printStackTrace();
return ResponseVO.error(e.toString());
} catch (IOException e) {
e.printStackTrace();
return ResponseVO.error(e.toString());
} catch (Exception e) {
e.printStackTrace();
return ResponseVO.error(e.toString());
}
mapper.update(path, dto.getExamCode());
mapper.updateDoc(templatePath + ",", path + ",", dto.getExamCode());

@ -15,7 +15,7 @@ import java.util.Map;
**/
public class FileContentUtil {
public static String pdfOut(DataVo data, InputStream templatePath, FileUtil fileUtil, String newPath, Integer pageNum) {
public static String pdfOut(DataVo data, InputStream templatePath, FileUtil fileUtil, String newPath, Integer pageNum) throws Exception {
PdfReader reader;
FileOutputStream out;
ByteArrayOutputStream bos;
@ -67,7 +67,10 @@ public class FileContentUtil {
return upload(fileUtil, newPath);
} catch (IOException | DocumentException e) {
e.printStackTrace();
return "";
throw new IOException(e);
} catch (Exception e){
e.printStackTrace();
throw new Exception(e);
}
}

Loading…
Cancel
Save