Browse Source

致委托人函后端接口优化

wucl 8 months ago
parent
commit
2706f936f0

+ 2 - 2
biz-base/src/main/java/com/dayou/controller/HouseGuarantyDocController.java

@@ -23,10 +23,10 @@ public class HouseGuarantyDocController {
      * 生成估价结果一览表的word文件
      * @param html
      * @param homePath
-     * @return
+     * @return 过程表id
      */
     @PostMapping("/targetTable")
-    public Result<String> genTargetsTableWord(String html,String homePath){
+    public Result<Long> genTargetsTableWord(String html,String homePath){
         return Result.build(houseGuarantyService.createTableWord(html,homePath));
     }
 

+ 1 - 1
biz-base/src/main/resources/application-local.yaml

@@ -1,7 +1,7 @@
 server:
   port: 9080
   servlet:
-    context-path: /productivity-platform/
+    context-path: /api
   error:
     include-exception: true
 spring:

+ 9 - 9
biz-base/src/test/java/com/dayou/FreeMarkTest.java

@@ -53,7 +53,7 @@ public class FreeMarkTest {
     @Test
     public void analysisTargetTable(){
         try {
-            Workbook workbook = new Workbook("/Users/wuwei/opt/temp/123.xlsx");
+            Workbook workbook = new Workbook("/Users/wuwei/opt/temp/collect1.xlsx");
             //原始json
             workbook.save("/Users/wuwei/opt/temp/123.json", SaveFormat.JSON);
             JSONArray array = JsonUtil.file2JsonArray("/Users/wuwei/opt/temp/123.json","估价结果一览表");
@@ -93,7 +93,7 @@ public class FreeMarkTest {
         JSONArray array = JsonUtil.file2JsonArray("/Users/wuwei/opt/temp/111.json");
 
         //读取基本信息
-        XSSFWorkbook workbook = new XSSFWorkbook("/Users/wuwei/opt/temp/123.xlsx");
+        XSSFWorkbook workbook = new XSSFWorkbook("/Users/wuwei/opt/temp/collect1.xlsx");
         Map<String, String> valueMap = EasyExcelUtil.getExcelCellValue(workbook, "基本信息");
         ConsignorLetterDO clDO = JSON.parseObject(JSON.toJSONString(valueMap), ConsignorLetterDO.class);
         clDO.setProjectName(HouseDocumentUtil.getProjectName(array));
@@ -116,12 +116,12 @@ public class FreeMarkTest {
         String ownShipUser = HouseDocumentUtil.getOwnShipUser(array);
 
         if (!"".equals(ownShipUser) && !ownShipUser.contains(clDO.getConsignor())){
-            clDO.setBlank("");
+            clDO.setOwnshipBlank("");
             clDO.setOwnship("不动产权利人:");
             clDO.setOwnshipUser(ownShipUser);
         }
         // 读取模板文件
-        byte[] tmplWordByte = Files.readAllBytes(Paths.get("/Users/wuwei/opt/temp/BASE.docx"));
+        byte[] tmplWordByte = Files.readAllBytes(Paths.get("/Users/wuwei/opt/temp/house/guaranty/temp/consignor_letter.docx"));
 
         // 获取填充数据后的文件(AsposeWordUtil是工具类,放在common中)
         byte[] resultWordByte = AsposeWordUtil.fillWordDataByDomain(tmplWordByte, clDO);
@@ -131,7 +131,7 @@ public class FreeMarkTest {
         FileOutputStream fos = new FileOutputStream(resultFile);
         fos.write(resultWordByte);
         fos.close();
-        insertTargetTable();
+        //insertTargetTable();
 
     }
 
@@ -160,11 +160,11 @@ public class FreeMarkTest {
 
 
         // 需要插入的word文件
-        Document subDoc = new Document("/Users/wuwei/opt/temp/1730958931701.docx");
+        //Document subDoc = new Document("/Users/wuwei/opt/temp/targets_table.docx");
 
-        mainDoc = AsposeWordUtil.insertDocumentAfterBookMark(mainDoc, subDoc, "targetTable", false);
-        // 保存文件
-        mainDoc.save("/Users/wuwei/opt/temp/gen2.docx");
+//        mainDoc = AsposeWordUtil.insertDocumentAfterBookMark(mainDoc, subDoc, "targetTable", false);
+//        // 保存文件
+//        mainDoc.save("/Users/wuwei/opt/temp/gen2.docx");
     }
 
 }

+ 3 - 0
dao/src/main/java/com/dayou/mapper/HouseGuarantyProcessMapper.java

@@ -2,6 +2,7 @@ package com.dayou.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.dayou.entity.HouseGuarantyProcess;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * <p>
@@ -12,4 +13,6 @@ import com.dayou.entity.HouseGuarantyProcess;
  * @since 2024-11-07
  */
 public interface HouseGuarantyProcessMapper extends BaseMapper<HouseGuarantyProcess> {
+
+    void updateDocNo(@Param("id") Long id, @Param("docNo") String docNo);
 }

+ 3 - 0
dao/src/main/resources/mapper/HouseGuarantyProcess.xml

@@ -2,5 +2,8 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.dayou.mapper.HouseGuarantyProcessMapper">
 
+    <update id="updateDocNo" >
+        update house_guaranty_process set doc_no = #{docNo} where id = #{id} and delete_status = 0
+    </update>
 
 </mapper>

+ 1 - 1
domain/src/main/java/com/dayou/doc/house/ConsignorLetterDO.java

@@ -32,7 +32,7 @@ public class ConsignorLetterDO {
 
     private String actDesc;
 
-    private String blank;
+    private String ownshipBlank;
 
     private String valueTiming;
 

+ 11 - 0
domain/src/main/java/com/dayou/entity/HouseGuarantyProcess.java

@@ -12,7 +12,18 @@ public class HouseGuarantyProcess extends BaseEntity implements Serializable {
 
     private static final long serialVersionUID=1L;
 
+    /**
+     * 文档编号
+     */
+    private String docNo;
+
+    /**
+     * docHome
+     */
     private String home;
 
+    /**
+     * 估价结果一览表代码
+     */
     private String targetsHtml;
 }

+ 1 - 1
service/src/main/java/com/dayou/service/HouseGuarantyService.java

@@ -9,7 +9,7 @@ public interface HouseGuarantyService {
      * @param html
      * @return
      */
-    String createTableWord(String html,String homePath);
+    Long createTableWord(String html,String homePath);
 
     /**
      * 解析表单1

+ 36 - 18
service/src/main/java/com/dayou/service/impl/HouseGuarantyServiceImpl.java

@@ -5,13 +5,12 @@ import cn.hutool.json.JSONObject;
 import com.alibaba.fastjson2.JSON;
 import com.aspose.cells.SaveFormat;
 import com.aspose.cells.Workbook;
-import com.aspose.words.Document;
-import com.aspose.words.DocumentBuilder;
-import com.aspose.words.Paragraph;
+import com.aspose.words.*;
 import com.dayou.config.FileNetConfig;
 import com.dayou.doc.house.ConsignorLetterDO;
 import com.dayou.entity.HouseGuarantyProcess;
 import com.dayou.exception.ErrorCode;
+import com.dayou.mapper.HouseGuarantyProcessMapper;
 import com.dayou.service.HouseGuarantyProcessService;
 import com.dayou.service.HouseGuarantyService;
 import com.dayou.utils.AsposeWordUtil;
@@ -49,14 +48,18 @@ public class HouseGuarantyServiceImpl implements HouseGuarantyService {
     @Autowired
     private FileNetConfig fileNetConfig;
 
+    @Autowired
+    private HouseGuarantyProcessMapper houseGuarantyProcessMapper;
+
     @Override
-    public String createTableWord(String html,String homePath) {
+    public Long createTableWord(String html,String homePath) {
         html = wordTableHelper.htmlTableFormat(html);
         HouseGuarantyProcess hgp = new HouseGuarantyProcess();
         hgp.setHome(homePath);
         hgp.setTargetsHtml(html);
         houseGuarantyProcessService.save(hgp);
-        return wordTableHelper.createTableWord(html, fileNetConfig.getBaseDir() + homePath);
+        wordTableHelper.createTableWord(html, fileNetConfig.getBaseDir() + homePath);
+        return hgp.getId();
     }
 
     @Override
@@ -89,6 +92,9 @@ public class HouseGuarantyServiceImpl implements HouseGuarantyService {
             //读取基本信息
             XSSFWorkbook workbook = new XSSFWorkbook(home + COLLECT1_XLSX);
             Map<String, String> valueMap = EasyExcelUtil.getExcelCellValue(workbook, BASE_INFO_ZH);
+            //更新文档编号
+            houseGuarantyProcessMapper.updateDocNo(id,valueMap.get("docNo"));
+
             ConsignorLetterDO clDO = JSON.parseObject(JSON.toJSONString(valueMap), ConsignorLetterDO.class);
             clDO.setProjectName(HouseDocumentUtil.getProjectName(array));
             Map<Object, List<Object>> collect = array.stream().collect(Collectors.groupingBy(x -> ((JSONObject) x).get(ID.getZhName())));
@@ -109,10 +115,12 @@ public class HouseGuarantyServiceImpl implements HouseGuarantyService {
             clDO.setActDesc(actDesc);
             String ownShipUser = HouseDocumentUtil.getOwnShipUser(array);
 
+            Boolean removeBlank = true;
             if (!"".equals(ownShipUser) && !ownShipUser.contains(clDO.getConsignor())){
-                clDO.setBlank("");
+                clDO.setOwnshipBlank("");
                 clDO.setOwnship("不动产权利人:");
                 clDO.setOwnshipUser(ownShipUser);
+                removeBlank = false;
             }
             byte[] tmplWordByte = Files.readAllBytes(Paths.get(fileNetConfig.getBaseDir()
                     + fileNetConfig.getHouseGuarantyTemplatePath() + CONSIGNOR_LETTER_TEMPLATE));
@@ -122,7 +130,7 @@ public class HouseGuarantyServiceImpl implements HouseGuarantyService {
             FileOutputStream fos = new FileOutputStream(resultFile);
             fos.write(resultWordByte);
             fos.close();
-            insetTargetTableWord(consignorLetterName,home + TARGETS_DOCX);
+            insetTargetTableWord(consignorLetterName,home + TARGETS_DOCX,removeBlank);
             return consignorLetterName;
         } catch (Exception e) {
             throw new RuntimeException(e);
@@ -135,20 +143,37 @@ public class HouseGuarantyServiceImpl implements HouseGuarantyService {
      * @param tableWordPath
      * @throws Exception
      */
-    private void insetTargetTableWord(String mainWordPath,String tableWordPath)  throws Exception{
+    private void insetTargetTableWord(String mainWordPath,String tableWordPath,Boolean removeBlank)  throws Exception{
         // 主word文件
         Document mainDoc = new Document(mainWordPath);
+        if (removeBlank){
+            removeBlank(mainDoc);
+        }
+        // 需要插入的word文件
+        Document subDoc = new Document(tableWordPath);
+
+        mainDoc = AsposeWordUtil.insertDocumentAfterBookMark(mainDoc, subDoc, "targetTable", false);
+        // 保存文件
+        mainDoc.save(mainWordPath);
+    }
 
+    /**
+     * 删除空白域
+     * @param mainDoc
+     * @throws Exception
+     */
+    private void removeBlank(Document mainDoc ) throws Exception {
         //删除空白行
         DocumentBuilder builder = new DocumentBuilder(mainDoc);
-        builder.moveToMergeField("blank");
-        Paragraph currentParagraph2 = builder.getCurrentParagraph();
+        builder.moveToMergeField("ownshipBlank");
+        Node currentParagraph2 = builder.getCurrentParagraph();
         if (currentParagraph2.getParentNode() != null){
             currentParagraph2.remove();
         }
         builder.moveToMergeField("ownship");
         Paragraph currentParagraph = builder.getCurrentParagraph();
-        if (currentParagraph.getParentNode() != null){
+        CompositeNode parentNode = currentParagraph.getParentNode();
+        if (parentNode != null){
             currentParagraph.remove();
         }
         builder.moveToMergeField("ownshipUser");
@@ -156,12 +181,5 @@ public class HouseGuarantyServiceImpl implements HouseGuarantyService {
         if (currentParagraph1.getParentNode() != null){
             currentParagraph1.remove();
         }
-
-        // 需要插入的word文件
-        Document subDoc = new Document(tableWordPath);
-
-        mainDoc = AsposeWordUtil.insertDocumentAfterBookMark(mainDoc, subDoc, "targetTable", false);
-        // 保存文件
-        mainDoc.save(mainWordPath);
     }
 }

+ 11 - 2
sql/update_sql.sql

@@ -186,7 +186,10 @@ ALTER TABLE tmpl_asset_calculate_section ADD COLUMN section_name VARCHAR(50) NOT
 ALTER TABLE tmpl_asset_calculate_section ADD COLUMN tmpl_code VARCHAR(50) NOT NULL COMMENT '模板code';
 ALTER TABLE tmpl_asset_calculate ADD COLUMN tmpl_code VARCHAR(50) NOT NULL COMMENT '模板code';
 
-
+/**
+    日期:2024-11-07
+    修改人:吴长林
+ */
 DROP TABLE IF EXISTS `house_guaranty_process`;
 CREATE TABLE `house_guaranty_process-platform`  (
                                                    `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键id',
@@ -196,4 +199,10 @@ CREATE TABLE `house_guaranty_process-platform`  (
                                                    `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
                                                    `delete_status` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除状态',
                                                    PRIMARY KEY (`id`) USING BTREE
-) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '房地产抵押过程表' ROW_FORMAT = Dynamic;
+) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '房地产抵押过程表' ROW_FORMAT = Dynamic;
+
+/**
+  日期:2024-11-08
+    修改人:吴长林
+ */
+ALTER TABLE house_guaranty_process ADD COLUMN doc_no VARCHAR(128) NOT NULL COMMENT '文档编号';