添加报错信息
This commit is contained in:
		| @@ -0,0 +1,24 @@ | ||||
| package com.ruoyi.custom.page; | ||||
|  | ||||
| import java.io.Serializable; | ||||
|  | ||||
| public class PdfProcessInfo implements Serializable { | ||||
|     private int code; | ||||
|     private String msg; | ||||
|  | ||||
|     public int getCode() { | ||||
|         return code; | ||||
|     } | ||||
|  | ||||
|     public void setCode(int code) { | ||||
|         this.code = code; | ||||
|     } | ||||
|  | ||||
|     public String getMsg() { | ||||
|         return msg; | ||||
|     } | ||||
|  | ||||
|     public void setMsg(String msg) { | ||||
|         this.msg = msg; | ||||
|     } | ||||
| } | ||||
| @@ -1,19 +1,20 @@ | ||||
| package com.ruoyi.custom.service; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| import com.ruoyi.custom.domain.SysContract; | ||||
| import com.ruoyi.custom.page.PdfProcessInfo; | ||||
|  | ||||
| /** | ||||
|  * 合同Service接口 | ||||
|  *  | ||||
|  * | ||||
|  * @author wonder | ||||
|  * @date 2020-10-23 | ||||
|  */ | ||||
| public interface ISysContractService  | ||||
| { | ||||
| public interface ISysContractService { | ||||
|     /** | ||||
|      * 查询合同 | ||||
|      *  | ||||
|      * | ||||
|      * @param id 合同ID | ||||
|      * @return 合同 | ||||
|      */ | ||||
| @@ -21,7 +22,7 @@ public interface ISysContractService | ||||
|  | ||||
|     /** | ||||
|      * 查询合同列表 | ||||
|      *  | ||||
|      * | ||||
|      * @param sysContract 合同 | ||||
|      * @return 合同集合 | ||||
|      */ | ||||
| @@ -29,7 +30,7 @@ public interface ISysContractService | ||||
|  | ||||
|     /** | ||||
|      * 新增合同 | ||||
|      *  | ||||
|      * | ||||
|      * @param sysContract 合同 | ||||
|      * @return 结果 | ||||
|      */ | ||||
| @@ -37,7 +38,7 @@ public interface ISysContractService | ||||
|  | ||||
|     /** | ||||
|      * 修改合同 | ||||
|      *  | ||||
|      * | ||||
|      * @param sysContract 合同 | ||||
|      * @return 结果 | ||||
|      */ | ||||
| @@ -45,7 +46,7 @@ public interface ISysContractService | ||||
|  | ||||
|     /** | ||||
|      * 批量删除合同 | ||||
|      *  | ||||
|      * | ||||
|      * @param ids 需要删除的合同ID | ||||
|      * @return 结果 | ||||
|      */ | ||||
| @@ -53,11 +54,11 @@ public interface ISysContractService | ||||
|  | ||||
|     /** | ||||
|      * 删除合同信息 | ||||
|      *  | ||||
|      * | ||||
|      * @param id 合同ID | ||||
|      * @return 结果 | ||||
|      */ | ||||
|     public int deleteSysContractById(Long id); | ||||
|  | ||||
|     public boolean signContract(SysContract sysContract); | ||||
|     public PdfProcessInfo signContract(SysContract sysContract); | ||||
| } | ||||
|   | ||||
| @@ -6,6 +6,7 @@ import com.itextpdf.text.pdf.*; | ||||
| import com.ruoyi.common.utils.DateUtils; | ||||
| import com.ruoyi.custom.domain.SysContract; | ||||
| import com.ruoyi.custom.mapper.SysContractMapper; | ||||
| import com.ruoyi.custom.page.PdfProcessInfo; | ||||
| import com.ruoyi.custom.service.ISysContractService; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Service; | ||||
| @@ -99,7 +100,7 @@ public class SysContractServiceImpl implements ISysContractService { | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public boolean signContract(SysContract sysContract) { | ||||
|     public PdfProcessInfo signContract(SysContract sysContract) { | ||||
| //        String templatePath = "/Users/wonder/Documents/Workspaces/java/RuoYi-Vue/running/pdf/contract.pdf"; | ||||
| //        String filePath = "/Users/wonder/Documents/Workspaces/java/RuoYi-Vue/running" + sysContract.getPath(); | ||||
|         String templatePath = "/home/workspace/RuoYi-Vue/running/pdf/contract.pdf"; | ||||
| @@ -110,6 +111,8 @@ public class SysContractServiceImpl implements ISysContractService { | ||||
|         ByteArrayOutputStream bos; | ||||
|         PdfStamper stamper; | ||||
|  | ||||
|         PdfProcessInfo info = new PdfProcessInfo(); | ||||
|  | ||||
|         try { | ||||
|             out = new FileOutputStream(filePath);// 输出流到新的pdf,没有b2.pdf时会创建 | ||||
|             reader = new PdfReader(templatePath);// 读取pdf模板 | ||||
| @@ -143,14 +146,22 @@ public class SysContractServiceImpl implements ISysContractService { | ||||
|             } | ||||
|             doc.close(); | ||||
|  | ||||
|             return true; | ||||
|             info.setCode(1); | ||||
|             info.setMsg("success"); | ||||
|  | ||||
|         } catch (FileNotFoundException e) { | ||||
|             e.printStackTrace(); | ||||
|             info.setCode(0); | ||||
|             info.setMsg(e.getMessage()); | ||||
|         } catch (IOException e) { | ||||
|             e.printStackTrace(); | ||||
|             info.setCode(0); | ||||
|             info.setMsg(e.getMessage()); | ||||
|         } catch (DocumentException e) { | ||||
|             e.printStackTrace(); | ||||
|             info.setCode(0); | ||||
|             info.setMsg(e.getMessage()); | ||||
|         } | ||||
|         return false; | ||||
|         return info; | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user