Pārlūkot izejas kodu

Merge branch 'feature-2022.07.29' of https://git.flowbb.cn/RK-Dev/fqgz-server into feature-2022.07.29

humuyu 3 gadi atpakaļ
vecāks
revīzija
141703efb6

+ 63 - 25
eladmin-system/src/main/java/me/zhengjie/application/admin/controller/NotaryNoteController.java

@@ -1,40 +1,78 @@
 package me.zhengjie.application.admin.controller;
 
 import com.alibaba.fastjson.JSONObject;
-import me.zhengjie.base.AppBaseResponse;
-import me.zhengjie.application.admin.service.NotaryNoteService;
+import me.zhengjie.annotation.rest.AnonymousGetMapping;
 import me.zhengjie.application.admin.controller.vo.NotaryNoteVo;
+import me.zhengjie.application.admin.service.NotaryNoteService;
+import me.zhengjie.base.AppBaseResponse;
+import me.zhengjie.base.util.HtmlConvertPdf;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.validation.Valid;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
 
 @RestController
 @RequestMapping("/api/note")
 public class NotaryNoteController {
-	@Autowired
-	NotaryNoteService notaryNoteService;
-
-	/**
-	 * 查询面谈笔录
-	 * @param notary
-	 * @return
-	 */
-	@RequestMapping("/question")
-	public JSONObject question(@Valid @RequestBody NotaryNoteVo notary) {
-		return notaryNoteService.getNotaryNoteByType(notary);
-	}
-
-	/**
-	 * 保存面谈笔录
-	 * 
-	 * @param notary
-	 * @return
-	 */
-	@RequestMapping("/save")
-	public AppBaseResponse<?> save(@Valid @RequestBody NotaryNoteVo notary) {
-		return notaryNoteService.saveNotaryNote(notary);
-	}
+    @Autowired
+    NotaryNoteService notaryNoteService;
+
+    /**
+     * 查询面谈笔录
+     *
+     * @param notary
+     * @return
+     */
+    @RequestMapping("/question")
+    public JSONObject question(@Valid @RequestBody NotaryNoteVo notary) {
+        return notaryNoteService.getNotaryNoteByType(notary);
+    }
+
+    /**
+     * 保存面谈笔录
+     *
+     * @param notary
+     * @return
+     */
+    @RequestMapping("/save")
+    public AppBaseResponse<?> save(@Valid @RequestBody NotaryNoteVo notary) {
+        return notaryNoteService.saveNotaryNote(notary);
+    }
+
+    @AnonymousGetMapping("/test-pdf")
+    public String generateTestPdf(@RequestParam String modelId, @RequestParam String businessNo) {
+        return notaryNoteService.generateTestPdf(modelId, businessNo);
+    }
+
+    public static void main(String[] args) {
+        try {
+            String html = readString("/Users/sakuya/Downloads/notary-model.html");
+            HtmlConvertPdf.createPdfFile(html, "/Users/sakuya/Downloads/notary-model.pdf");
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    private static String readString(String filePath) {
+        String str = "";
+        File file = new File(filePath);
+        try {
+            FileInputStream in = new FileInputStream(file);
+            // size 为字串的长度 ,这里一次性读完
+            int size = in.available();
+            byte[] buffer = new byte[size];
+            in.read(buffer);
+            in.close();
+            str = new String(buffer, "UTF-8");
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return str;
+    }
 }

+ 2 - 0
eladmin-system/src/main/java/me/zhengjie/application/admin/service/NotaryNoteService.java

@@ -18,4 +18,6 @@ public interface NotaryNoteService {
 	JSONObject getNotaryNoteByType(NotaryNoteVo notary);
 
 	AppBaseResponse saveNotaryNote(NotaryNoteVo notary);
+
+	String generateTestPdf(String modelId, String businessNo);
 }

+ 10 - 0
eladmin-system/src/main/java/me/zhengjie/application/admin/service/impl/NotaryNoteServiceImpl.java

@@ -39,6 +39,7 @@ public class NotaryNoteServiceImpl implements NotaryNoteService {
 	private final ContractOrderRepository contractOrderRepository;
 	private final OrderFileRepository orderFileRepository;
 	private final ModelSynthesizerDomain modelSynthesizerDomain;
+	private final ModelMapper modelMapper;
 
 	@Override
 	public JSONObject getNotaryNoteByType(NotaryNoteVo notary) {
@@ -139,4 +140,13 @@ public class NotaryNoteServiceImpl implements NotaryNoteService {
 		fileEntity.setPdfUrl(pdfPath);
 		orderFileMapper.updateById(fileEntity);
 	}
+
+	@Override
+	public String generateTestPdf(String modelId, String businessNo) {
+		ModelEntity model = modelMapper.selectById(modelId);
+		ContractOrderEntity order = contractOrderRepository.getContractOrderWithBizNo(businessNo);
+		String content = modelSynthesizerDomain.composeNotarizationPreview(order, model.getContent());
+		String html = modelSynthesizerDomain.composeNotarizationTemplate(1000, content);
+		return FileUploadUtil.getPreviewUrl(FileUploadUtil.savePdf(html, businessNo));
+	}
 }

+ 1 - 1
eladmin-system/src/main/java/me/zhengjie/base/util/HtmlConvertPdf.java

@@ -76,7 +76,7 @@ public class HtmlConvertPdf {
 		// 设置字体的数据
 		int topValue = 10;
 		int leftValue = 10;
-		int rightValue = 0;
+		int rightValue = 10;
 		int bottomValue = 10;
 	
 		pdf.setPageInsetsMM(new Insets(topValue, leftValue, bottomValue, rightValue));

+ 2 - 2
eladmin-system/src/main/java/me/zhengjie/domain/model/ModelSynthesizerDomain.java

@@ -242,9 +242,9 @@ public class ModelSynthesizerDomain {
                 Map<String, String> jointMap = new HashMap<>();
                 if (order.getContractType() == OrderConstant.CONTRACT_TYPE_BORROWER) {
                     if (OrderConstant.PROD_ID_CD.equals(order.getProdId())) {
-                        partyMap.put("$Title$", "借款人(抵押人)");
+                        jointMap.put("$Title$", "借款人(抵押人)");
                     } else {
-                        partyMap.put("$Title$", "借款人");
+                        jointMap.put("$Title$", "借款人");
                     }
                 } else if (order.getContractType() == OrderConstant.CONTRACT_TYPE_MORTGAGE) {
                     jointMap.put("$Title$", "抵押人");