Pārlūkot izejas kodu

其他权利状况描述(流式文本创作)

wucl 7 mēneši atpakaļ
vecāks
revīzija
1ecbf70d92

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

@@ -25,8 +25,8 @@ public class HouseTargetEntityController {
      * @return
      */
     @PostMapping("")
-    public Result<Boolean> addHouseTargetEntity(@RequestBody HouseTargetEntity houseTargetEntity) {
-        Boolean ret = houseTargetEntityService.addHouseTargetEntity(houseTargetEntity);
+    public Result<Long> addHouseTargetEntity(@RequestBody HouseTargetEntity houseTargetEntity) {
+        Long ret = houseTargetEntityService.addHouseTargetEntity(houseTargetEntity);
         return Result.build(ret);
     }
 

+ 20 - 0
biz-base/src/test/java/com/dayou/WordSimpleTests.java

@@ -364,4 +364,24 @@ public class WordSimpleTests {
 
     }
 
+    @Test
+    void streamCreateContent() throws Exception {
+        Document doc = new Document("/Users/wuwei/opt/temp/ct.docx");
+        DocumentBuilder builder = new DocumentBuilder(doc);
+        builder.moveToBookmark("stream", true, false);
+        //builder.moveToDocumentEnd();
+        builder.getFont().setName("宋体");
+        // 是否加粗
+        builder.getFont().setBold(false);
+        builder.getFont().setSize(12);
+        builder.writeln("这是一个测试段落");
+        // 设置信息
+        SimpleWordTableData data1 = SimpleWordTableData.builder().id("1").pledger("张三").contractNum("合同阿巴阿巴阿巴阿巴").guarantyStyle("担保").amount("1000万").build();
+        SimpleWordTableData data2 = SimpleWordTableData.builder().id("2").pledger("李四").contractNum("合同呜呼呜呼呜呼芜湖").guarantyStyle("抵押").amount("200028万").build();
+        List<SimpleWordTableData> contractList = Arrays.asList(data1, data2);
+        AsposeWordUtil.createTable(builder, SimpleWordTableData.class, contractList);
+        doc.save("/Users/wuwei/opt/temp/ct1.docx");
+
+    }
+
 }

+ 88 - 0
common/src/main/java/com/dayou/utils/AsposeWordUtil.java

@@ -374,6 +374,15 @@ public class AsposeWordUtil {
         return doc;
     }
 
+    /**
+     * 向书签位置插入表格
+     * @param doc
+     * @param clazz
+     * @param list
+     * @param bookmark
+     * @return
+     * @throws Exception
+     */
     public static Document createTable(Document doc, Class<?> clazz, List<?> list, String bookmark) throws Exception {
         // Aspose文档构造器
         DocumentBuilder builder = new DocumentBuilder(doc);
@@ -449,4 +458,83 @@ public class AsposeWordUtil {
 
         return doc;
     }
+
+    /**
+     * 向光标当前所在位置创建表格
+     * @param builder
+     * @param clazz
+     * @param list
+     * @return
+     * @throws Exception
+     */
+    public static void createTable(DocumentBuilder builder, Class<?> clazz, List<?> list) throws Exception {
+        // 创建table
+        Table table = builder.startTable();
+        // 获取所有字段
+        Field[] fields = clazz.getDeclaredFields();
+
+        // 创建表头
+        for (Field field : fields) {
+            // 检查字段是否有自定义注解
+            if (field.isAnnotationPresent(WordTableColumn.class)) {
+                // 获取注解实例
+                WordTableColumn annotation = field.getAnnotation(WordTableColumn.class);
+                // 检查isCreate属性是否为true
+                if (annotation.isCreate()) {
+                    builder.insertCell();
+                    builder.getCellFormat().setVerticalAlignment(CellVerticalAlignment.CENTER);
+                    ParagraphFormat paragraphFormat = builder.getParagraphFormat();
+                    paragraphFormat.setAlignment(ParagraphAlignment.CENTER);
+                    paragraphFormat.setFirstLineIndent(0);
+                    paragraphFormat.setLineSpacing(0);
+                    // 字体宋体
+                    builder.getFont().setName("宋体");
+                    // 是否加粗
+                    //builder.getFont().setBold(true);
+                    // 字号(9是小五字号)
+                    builder.getFont().setSize(9);
+
+                    builder.write(annotation.name());
+                }
+            }
+        }
+        // 结束行
+        builder.endRow();
+
+        // 创建内容行
+        for (Object obj : list){
+            for (Field field : fields) {
+                // 检查字段是否有自定义注解
+                if (field.isAnnotationPresent(WordTableColumn.class)) {
+                    // 获取注解实例
+                    WordTableColumn annotation = field.getAnnotation(WordTableColumn.class);
+                    // 检查isCreate属性是否为true
+                    if (annotation.isCreate()) {
+                        field.setAccessible(true);
+                        builder.insertCell();
+                        builder.getCellFormat().setVerticalAlignment(CellVerticalAlignment.CENTER);
+                        ParagraphFormat paragraphFormat = builder.getParagraphFormat();
+                        paragraphFormat.setFirstLineIndent(0);
+                        paragraphFormat.setAlignment(ParagraphAlignment.CENTER);
+                        paragraphFormat.setLineSpacing(0);
+                        // 字体宋体
+                        builder.getFont().setName("宋体");
+                        // 是否加粗
+                        builder.getFont().setBold(false);
+                        // 字号(9是小五字号)
+                        builder.getFont().setSize(9);
+                        builder.write((String) field.get(obj));
+                    }
+                }
+            }
+            // 结束行
+            builder.endRow();
+        }
+
+        // 自动调整列宽
+        table.autoFit(AutoFitBehavior.AUTO_FIT_TO_WINDOW);
+        // 设置居中
+        table.setAlignment(CellVerticalAlignment.CENTER);
+        builder.endTable();
+    }
 }

+ 134 - 8
common/src/main/java/com/dayou/utils/HouseDocumentUtil.java

@@ -3,13 +3,13 @@ package com.dayou.utils;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.*;
 import com.alibaba.fastjson2.JSON;
+import com.aspose.words.Document;
+import com.aspose.words.DocumentBuilder;
+import com.aspose.words.Font;
 import com.dayou.dto.Address;
+import com.dayou.dto.HouseRightsDTO;
 import com.dayou.dto.HouseGuarantyTargetDTO;
-import com.dayou.dto.HousePledgeDTO;
-import com.dayou.entity.CertificateLandUse;
-import com.dayou.entity.HouseGuarantyTarget;
-import com.dayou.entity.HouseTargetEntity;
-import com.dayou.entity.TmplHouseParagraph;
+import com.dayou.entity.*;
 import com.dayou.enums.HouseTargetTableColumn;
 import com.dayou.exception.ErrorCode;
 
@@ -1443,6 +1443,9 @@ public class HouseDocumentUtil {
         StringBuilder resultDesc = new StringBuilder();
         if (CollectionUtil.isNotEmpty(entities)){
             for (HouseTargetEntity entity : entities){
+                if (entity.getCertCombination()==null){
+                    continue;
+                }
                 //第一段
                 StringBuilder p = new StringBuilder("估价对象"+entity.getTid()+"序号"+entity.getTno()+"\n");
                 if (entity.getCertCombination()==5 || entity.getCertCombination()==6){
@@ -1452,11 +1455,11 @@ public class HouseDocumentUtil {
                             .append(entity.getWestWay()).append(",南临").append(entity.getSouthWay())
                             .append(",北临").append(entity.getNorthWay()).append("。");
                 }else if (entity.getCertCombination() == 4){
-                    p.append("土地开发程度:经注册房地产估价师实地查勘,至价值时点,估价对象所在宗地上已修建")
+                    p.append("(1)土地开发程度:经注册房地产估价师实地查勘,至价值时点,估价对象所在宗地上已修建")
                             .append(entity.getUseTo()).append("用房,土地开发程度为").append(entity.getLandDeep())
                             .append(";根据委托人提供的资料,估价对象所在宗地接城市供水、排水系统,雨水、污水分流处理,供电接城市电网,固定电话、网络接城市通讯网,移动讯号全覆盖。");
                 }else if (entity.getCertCombination() == 2 || entity.getCertCombination() == 3){
-                    p.append("估价对象土地坐落、用途、面积、使用权类型、土地使用年期:根据估价对象权利人提供的")
+                    p.append("(1)估价对象土地坐落、用途、面积、使用权类型、土地使用年期:根据估价对象权利人提供的")
                             .append(entity.getLandCertificateNo()).append("《国有土地使用证》记载,估价对象所在宗地位于")
                             .append(entity.getLandLocation()).append(",估价对象占用").append(entity.getLandUseType())
                             .append(entity.getLandUseTo()).append("土地使用权面积:").append(entity.getLandAcreage())
@@ -1465,7 +1468,7 @@ public class HouseDocumentUtil {
                             .append(entity.getWestWay()).append(",南临").append(entity.getSouthWay())
                             .append(",北临").append(entity.getNorthWay()).append("。");
                 }else{
-                    p.append("估价对象土地坐落、用途、面积、使用权类型、土地使用年期:根据估价对象权利人提供的")
+                    p.append("(1)估价对象土地坐落、用途、面积、使用权类型、土地使用年期:根据估价对象权利人提供的")
                             .append(entity.getAssetsCertificateNo()).append("《不动产权证书》记载,估价对象所在宗地位于")
                             .append(entity.getAssetsLocation()).append(",估价对象占用").append(entity.getAssetsUseType())
                             .append(entity.getAssetsUseTo()).append("土地使用权面积:").append(entity.getAssetsAcreage())
@@ -1489,4 +1492,127 @@ public class HouseDocumentUtil {
         return resultDesc.toString();
     }
 
+    /**
+     * 组合估价对象权益状况描述
+     * @param doc
+     * @param rights
+     * @return
+     */
+     public static void getRightsDesc(Document doc,List<HouseRightsDTO> rights,Boolean checkOriginCerts) throws Exception {
+         //构造 builder
+         DocumentBuilder builder = new DocumentBuilder(doc);
+         //将 光标移动到指定书签处,准备创作
+         builder.moveToBookmark("rightsInfo", true, false);
+
+         String copys = checkOriginCerts?"":"(复印件)";
+
+         Map<String, List<HouseRightsDTO>> rightsMap = rights.stream().collect(Collectors.groupingBy(HouseRightsDTO::getTid));
+
+         for (Map.Entry<String, List<HouseRightsDTO>> entry : rightsMap.entrySet()){
+             //设置字体样式
+             Font font = builder.getFont();
+             font.setName("宋体");
+             font.setSize(14);
+
+             for (int i=0; i<entry.getValue().size() ; i++){
+                 HouseRightsDTO right = entry.getValue().get(i);
+                 CertificateFixedAssets assetsCert = right.getAssetsCert();
+                 CertificateHouseOwn houseOwnCert = right.getHouseOwnCert();
+                 CertificateLandUse landUseCert = right.getLandUseCert();
+
+                 //用途
+                 String useTo = "";
+
+                 builder.writeln("估价对象"+entry.getKey()+"序号"+right.getTno());
+                 int j = 1;
+                 if (assetsCert != null){
+                     useTo = right.getAssetsCert().getUseTo();
+                         builder.writeln(j+".不动产权属状况");
+                         builder.writeln("根据委托人提供的《不动产权证书》"+copys+",估价对象不动产权属登记状况如下:");
+                     AsposeWordUtil.createTable(builder, CertificateFixedAssets.class, Collections.singletonList(right.getAssetsCert()));
+                     j++;
+                 }
+                 if (houseOwnCert != null){
+                     useTo = right.getHouseOwnCert().getUseTo();
+                         builder.writeln(j+".房屋权属状况");
+                         builder.writeln("根据委托人提供的《房屋所有权证》" + copys + ",估价对象房屋权益登记状况如下:");
+                     builder.writeln("序号"+ right.getTno()+":");
+                     AsposeWordUtil.createTable(builder, CertificateHouseOwn.class, Collections.singletonList(right.getHouseOwnCert()));
+                     j++;
+                 }
+                 if (landUseCert != null){
+                         builder.writeln(j+".土地权属状况");
+                         builder.writeln("根据委托人提供的《国有土地使用证》"+copys+",估价对象土地权属登记状况如下:");
+                     builder.writeln("序号"+ right.getTno()+":");
+                     AsposeWordUtil.createTable(builder, CertificateLandUse.class, Collections.singletonList(right.getLandUseCert()));
+                     j++;
+                 }
+
+                 builder.writeln(j+".担保物权状况");
+                 //是否设置抵押权
+                 Boolean hasPledge = right.getHasPledge();
+
+                 if (hasPledge != null && !hasPledge){
+                     builder.writeln("根据估价对象权利人提供的《房地产评估委托、确认书》《估价对象权利状况、法定优先受偿款调查说明及承诺书》,经注册房地产估价师实地查勘,至价值时点,估价对象未设定抵押等他项权利。");
+                     j++;
+                 }
+
+                 if (hasPledge != null && hasPledge){
+                     builder.writeln("根据估价对象权利人介绍和提供的“房地产评估委托、确认书”、“估价对象权利状况、法定优先受偿款调查说明及承诺书”,经注册房地产估价师实地查勘,至价值时点,估价对象已设立了"
+                             +right.getPledgeType()+","+(right.getPledgeType().equals("一般抵押权")?"抵押权利价值为":"最高债权额为")+right.getPledgeValue()+"万元,抵押权人为"+right.getPledgeUser()+"。");
+                     j++;
+                 }
+
+                 builder.writeln(j+".用益物权状况");
+
+                 Boolean hasLandUseRight = right.getHasLandUseRight();
+                 Boolean hasLivingRight = right.getHasLivingRight();
+                 if (hasLandUseRight!=null && hasLivingRight!=null){
+                     if (!hasLandUseRight && !hasLivingRight && "住宅".equals(useTo)){
+                         builder.writeln("根据估价对象权利人提供的 “估价对象权利状况、法定优先受偿款调查说明及承诺书”,至价值时点,估价对象未设立居住权、地役权。");
+                         j++;
+                     }else if(hasLandUseRight && !hasLivingRight && "住宅".equals(useTo)){
+                         String landUseRightFrom = right.getLandUseRightFrom();
+                         String landUseRightTo = right.getLandUseRightTo();
+                         builder.writeln("根据估价对象权利人提供的 “估价对象权利状况、法定优先受偿款调查说明及承诺书”,至价值时点,估价对象用益物权已设立地役权,供役地权利人为"+landUseRightFrom+",需役地权利人为"+landUseRightTo+",当事人双方已订立地役权合同。估价对象未设置居住权。");
+                         j++;
+                     }else if (!hasLandUseRight && hasLivingRight && "住宅".equals(useTo)){
+                         builder.writeln("根据估价对象权利人提供的“估价对象权利状况、法定优先受偿款调查说明及承诺书”,至价值时点,估价对象用益物权已设立居住权,当事人双方已订立居住权合同,并已向登记机构登记。估价对象未设置地役权。");
+                         j++;
+                     }else if (!hasLandUseRight && !"住宅".equals(useTo)){
+                         builder.writeln("根据估价对象权利人提供的“估价对象权利状况、法定优先受偿款调查说明及承诺书”,至价值时点,估价对象未设立地役权。");
+                         j++;
+                     }else if (hasLandUseRight && !"住宅".equals(useTo)){
+                         String landUseRightFrom = right.getLandUseRightFrom();
+                         String landUseRightTo = right.getLandUseRightTo();
+                         builder.writeln("根据估价对象权利人提供的 “估价对象权利状况、法定优先受偿款调查说明及承诺书”,至价值时点,估价对象用益物权已设立地役权,供役地权利人为"+landUseRightFrom+",需役地权利人为"+landUseRightTo+",当事人双方已订立地役权合同。");
+                         j++;
+                     }else if (hasLandUseRight && hasLivingRight && "住宅".equals(useTo)){
+                         String landUseRightFrom = right.getLandUseRightFrom();
+                         String landUseRightTo = right.getLandUseRightTo();
+                         builder.writeln("根据估价对象权利人提供的 “估价对象权利状况、法定优先受偿款调查说明及承诺书”,至价值时点,估价对象用益物权已设立地役权,供役地权利人为"+landUseRightFrom+",需役地权利人为"+landUseRightTo+",当事人双方已订立地役权合同。估价对象用益物权已设立居住权,当事人双方已订立居住权合同,并已向登记机构登记。");
+                         j++;
+                     }else {
+
+                     }
+
+                 }
+
+                 builder.writeln(j+".租赁或占用情况");
+
+                 if (hasPledge != null && !hasPledge){
+                     builder.writeln("根据估价对象权利人介绍和提供的“估价对象权利状况、法定优先受偿款调查说明及承诺书”、“估价对象权利状况说明及承诺书”,经注册房地产估价师实地查勘,至价值时点,估价对象未出租,目前为"+right.getUseInfo()+"。");
+                 }
+
+                 Boolean hasRentOutContract = right.getHasRentOutContract();
+                 if (hasPledge != null && hasPledge && hasRentOutContract!=null && hasRentOutContract){
+                     builder.writeln("根据估价对象权利人提供的“房地产评估委托、确认书”、“估价对象权利状况、法定优先受偿款调查说明及承诺书”,经注册房地产估价师实地查勘,至价值时点,估价对象已出租,承租方为"+right.getRentUser()+"租赁期限:"+right.getRentStartDate()+"至"+right.getRentEndDate()+",至价值时点的租金为"+right.getRentMoney()+"元/㎡·月。");
+                 }
+                 if (hasPledge != null && hasPledge && hasRentOutContract!=null && !hasRentOutContract){
+                     builder.writeln("根据估价对象权利人提供的“房地产评估委托、确认书”、“估价对象权利状况、法定优先受偿款调查说明及承诺书”,经注册房地产估价师实地查勘,至价值时点,估价对象已出租,但估价对象权利人未提供估价对象租赁合同。");
+                 }
+
+             }
+         }
+     }
 }

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

@@ -1,6 +1,7 @@
 package com.dayou.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.dayou.dto.HouseRightsDTO;
 import com.dayou.entity.HouseTargetEntity;
 import org.apache.ibatis.annotations.Param;
 
@@ -9,4 +10,6 @@ import java.util.List;
 public interface HouseTargetEntityMapper extends BaseMapper<HouseTargetEntity> {
 
     List<HouseTargetEntity> getListById(@Param("docId") Long docId);
+
+    List<HouseRightsDTO> getHouseRightsDTOList(@Param("docId")Long docId);
 }

+ 25 - 2
dao/src/main/resources/mapper/HouseTargetEntityMapper.xml

@@ -31,8 +31,31 @@
                     AND hte.tno = cfa.tno
                 )
                 left join (select t_id,doc_id,land_use_to ,land_use_type from house_guaranty_target where delete_status = 0) hgt on (hgt.doc_id = hte.business_id and hgt.t_id = hte.tid)
-        where hte.delete_status=0
-        order by hte.id asc
+        where hte.delete_status=0 and hte.business_id = #{docId}
+        order by hte.tid asc ,hte.tno asc
+    </select>
+
+    <select id="getHouseRightsDTOList" parameterType="java.lang.Long" resultType="com.dayou.dto.HouseRightsDTO">
+        SELECT
+            hte.business_id,
+            hte.tid,
+            hte.tno,
+            hte.use_info,
+            hte.cert_combination as certType,
+            hgt.*
+        FROM
+            house_target_entity hte
+                LEFT JOIN ( SELECT t_id, doc_id, is_rent_out, has_rent_out_contract,
+                                   rent_end_date, rent_start_date, rent_money, rent_user,
+                                   has_pledge, pledge_user, pledge_type, pledge_value ,
+                                   has_land_use_right,has_living_right,land_use_right_from,
+                                   land_use_right_to FROM house_guaranty_target
+                                WHERE delete_status = 0 ) hgt ON (
+                hgt.doc_id = hte.business_id
+                    AND hgt.t_id = hte.tid)
+        where hte.delete_status=0 and hte.business_id = #{docId}
+        order by hte.tid asc ,hte.tno asc
+
     </select>
 
 </mapper>

+ 58 - 0
domain/src/main/java/com/dayou/dto/HouseRightsDTO.java

@@ -0,0 +1,58 @@
+package com.dayou.dto;
+
+import com.dayou.entity.CertificateFixedAssets;
+import com.dayou.entity.CertificateHouseOwn;
+import com.dayou.entity.CertificateLandUse;
+import lombok.Data;
+
+/**
+ * 估价对象权益状况所需数据源
+ */
+@Data
+public class HouseRightsDTO {
+
+    private Long businessId;
+
+    private String tid;
+
+    private String tno;
+
+    private Boolean hasPledge;
+
+    private String pledgeType;
+
+    private String pledgeValue;
+
+    private String pledgeUser;
+
+    private Boolean hasLandUseRight;
+
+    private Boolean hasLivingRight;
+
+    private String landUseRightFrom;
+
+    private String landUseRightTo;
+
+    private Boolean hasRentOutContract;
+
+    private String useInfo;
+
+    private Boolean isRentOut;
+
+    private String rentUser;
+
+    private String rentStartDate;
+
+    private String rentEndDate;
+
+    private String rentMoney;
+
+    private Integer certType;
+
+    private CertificateFixedAssets assetsCert;
+
+    private CertificateHouseOwn houseOwnCert;
+
+    private CertificateLandUse landUseCert;
+
+}

+ 25 - 0
domain/src/main/java/com/dayou/entity/CertificateFixedAssets.java

@@ -1,5 +1,6 @@
 package com.dayou.entity;
 
+import com.dayou.annotation.WordTableColumn;
 import com.dayou.common.BaseEntity;
 import lombok.Data;
 
@@ -10,18 +11,42 @@ public class CertificateFixedAssets extends BaseEntity {
     private Long businessId;
     private String tid;
     private String tno;
+    @WordTableColumn(name = "不动产权证书号")
     private String certificateNo;
+
+    @WordTableColumn(name = "权利人")
     private String ownShipUser;
+
+    @WordTableColumn(name = "共有情况")
     private String ownShipInfo;
+
+    @WordTableColumn(name = "坐落")
     private String location;
+
+    @WordTableColumn(name = "不动产单元号")
     private String unitNo;
+
+    @WordTableColumn(name = "权利类型")
     private String ownShipType;
+
+    @WordTableColumn(name = "权利性质")
     private String ownShipNature;
+
+    @WordTableColumn(name = "用途")
     private String useTo;
+
+    @WordTableColumn(name = "面积")
     private String acreageDesc;
+
+    @WordTableColumn(name = "使用期限")
     private String expireDateDesc;
+
+    @WordTableColumn(name = "其他权利状况")
     private String ownShipOtherInfo;
+
+    @WordTableColumn(name = "附记")
     private String attachInfo;
+
     private Long createUserId;
 
 }

+ 22 - 0
domain/src/main/java/com/dayou/entity/CertificateHouseOwn.java

@@ -1,5 +1,6 @@
 package com.dayou.entity;
 
+import com.dayou.annotation.WordTableColumn;
 import com.dayou.common.BaseEntity;
 import lombok.Data;
 
@@ -11,18 +12,39 @@ public class CertificateHouseOwn extends BaseEntity {
     private String tid;
     private String tno;
     private Boolean isNew;
+    @WordTableColumn(name = "房屋所有权证号")
     private String certificateNo;
+
+    @WordTableColumn(name = "房屋所有权人")
     private String ownShipUser;
+
+    @WordTableColumn(name = "共有情况")
     private String ownShipInfo;
+
+    @WordTableColumn(name = "房屋坐落")
     private String location;
+
+    @WordTableColumn(name = "登记日期")
     private String registerDate;
+
     private String houseNature;
+
+    @WordTableColumn(name = "用途")
     private String useTo;
+
+    @WordTableColumn(name = "总层数")
     private String allFloor;
+
+    @WordTableColumn(name = "建筑面积(㎡)")
     private String acreage;
+
+    @WordTableColumn(name = "套内建筑面积(㎡)")
     private String innerAcreage;
+
+    @WordTableColumn(name = "附记")
     private String attachInfo;
     private String areaNo;
+
     private String ownShipType;
     private String buildingNo;
     private String houseNo;

+ 19 - 0
domain/src/main/java/com/dayou/entity/CertificateLandUse.java

@@ -1,5 +1,6 @@
 package com.dayou.entity;
 
+import com.dayou.annotation.WordTableColumn;
 import com.dayou.common.BaseEntity;
 import lombok.Data;
 
@@ -13,16 +14,34 @@ public class CertificateLandUse extends BaseEntity {
     private String tid;
     private String tno;
     private Boolean isNew;
+
+    @WordTableColumn(name = "国有土地使用证号")
     private String certificateNo;
+
+    @WordTableColumn(name = "土地使用权人")
     private String landUseUser;
+
+    @WordTableColumn(name = "座落")
     private String location;
+
+    @WordTableColumn(name = "地号")
     private String landNo;
     private String imageNo;
+
+    @WordTableColumn(name = "地类(用途)")
     private String useTo;
     private String takePrice;
+
+    @WordTableColumn(name = "使用权类型")
     private String useType;
+
+    @WordTableColumn(name = "终止日期")
     private String expireDate;
+
+    @WordTableColumn(name = "使用权面积(㎡)")
     private String acreage;
+
+    @WordTableColumn(name = "其中分摊面积(㎡)")
     private String outterAcreage;
     private String attachInfo;
     private String landLevel;

+ 9 - 0
domain/src/main/java/com/dayou/entity/HouseGuarantyTarget.java

@@ -109,4 +109,13 @@ public class HouseGuarantyTarget extends BaseEntity implements Serializable {
     private Boolean houseGetLandInfo;
 
     private String landUseType;
+
+    private Boolean hasLandUseRight;
+
+    private Boolean hasLivingRight;
+
+    private String landUseRightFrom;
+
+    private String landUseRightTo;
+
 }

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

@@ -2,7 +2,6 @@ package com.dayou.service;
 
 
 import com.dayou.dto.HouseGuarantyTableDTO;
-import com.dayou.dto.HouseGuarantyTargetDTO;
 import com.dayou.vo.HouseTargetVO;
 
 import java.io.IOException;
@@ -59,4 +58,13 @@ public interface HouseGuarantyService {
      * @return
      */
     String genResultLetter(Long id);
+
+    /**
+     * 获取权属证书组合类型
+     * @param businessId
+     * @param tid
+     * @param tno
+     * @return
+     */
+    Integer getCertificateCombination(Long businessId,String tid,String tno);
 }

+ 6 - 1
service/src/main/java/com/dayou/service/HouseTargetEntityService.java

@@ -1,13 +1,18 @@
 package com.dayou.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.dayou.dto.HouseRightsDTO;
 import com.dayou.entity.HouseTargetEntity;
 
+import java.util.List;
+
 public interface HouseTargetEntityService extends IService<HouseTargetEntity> {
 
-    Boolean addHouseTargetEntity(HouseTargetEntity houseTargetEntity);
+    Long addHouseTargetEntity(HouseTargetEntity houseTargetEntity);
 
     HouseTargetEntity getHouseTargetEntityById(Long businessId, String tid, String tno);
 
     Boolean copyHouseTargetEntity(Long id);
+
+    List<HouseRightsDTO> getHouseRightsDTOList(Long businessId);
 }

+ 4 - 0
service/src/main/java/com/dayou/service/impl/CertificateFixedAssetsServiceImpl.java

@@ -5,13 +5,17 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.dayou.entity.CertificateFixedAssets;
 import com.dayou.mapper.CertificateFixedAssetsMapper;
 import com.dayou.service.CertificateFixedAssetsService;
+import com.dayou.service.HouseGuarantyService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.List;
 
 @Service
 public class CertificateFixedAssetsServiceImpl extends ServiceImpl<CertificateFixedAssetsMapper, CertificateFixedAssets> implements CertificateFixedAssetsService {
 
+
     @Override
     public Boolean add(CertificateFixedAssets certificateFixedAssets) {
         return this.saveOrUpdate(certificateFixedAssets);

+ 5 - 0
service/src/main/java/com/dayou/service/impl/CertificateHouseOwnServiceImpl.java

@@ -5,7 +5,11 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.dayou.entity.CertificateHouseOwn;
 import com.dayou.mapper.CertificateHouseOwnMapper;
 import com.dayou.service.CertificateHouseOwnService;
+import com.dayou.service.HouseGuarantyService;
+import com.dayou.service.HouseTargetEntityService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.Collections;
 import java.util.List;
@@ -13,6 +17,7 @@ import java.util.List;
 @Service
 public class CertificateHouseOwnServiceImpl extends ServiceImpl<CertificateHouseOwnMapper, CertificateHouseOwn> implements CertificateHouseOwnService {
 
+
     @Override
     public Boolean add(CertificateHouseOwn certificateHouseOwn) {
         return this.saveOrUpdate(certificateHouseOwn);

+ 16 - 6
service/src/main/java/com/dayou/service/impl/HouseGuarantyServiceImpl.java

@@ -17,6 +17,7 @@ import com.dayou.doc.house.GuarantyResultDO;
 import com.dayou.dto.HouseGuarantyTableDTO;
 import com.dayou.dto.HouseGuarantyTargetDTO;
 import com.dayou.dto.HousePledgeDTO;
+import com.dayou.dto.HouseRightsDTO;
 import com.dayou.entity.*;
 import com.dayou.enums.DocumentType;
 import com.dayou.enums.BusinessEnum;
@@ -328,9 +329,9 @@ public class HouseGuarantyServiceImpl implements HouseGuarantyService {
         try {
             //读取估价对象数组
             JSONArray array = JsonUtil.file2JsonArray(home + TARGETS_JSON);
-
             JSONObject jsonObject = JsonUtil.file2JsonObject(home + BASE_INFO_JSON);
 
+            //替换字段
             GuarantyResultDO guarantyResultDO = new GuarantyResultDO();
             guarantyResultDO.setDocNo((String) jsonObject.get("报告号"));
             guarantyResultDO.setConsignor((String) jsonObject.get("委托人"));
@@ -360,12 +361,18 @@ public class HouseGuarantyServiceImpl implements HouseGuarantyService {
             fos.write(resultWordByte);
             fos.close();
 
-            Thread.sleep(1000);
+            //替换完成,此处开始动态创建内容
+            //获取替换后的文档
+            Document doc = new Document(baseDir + guarantyResultName);
 
-            //生成文档中的表格
-            //1. 实物状况表格
+            //获取权属信息数据源
+            List<HouseRightsDTO> houseRightsDTOList = houseTargetEntityService.getHouseRightsDTOList(id);
+            HouseDocumentUtil.getRightsDesc(doc,houseRightsDTOList,
+                    HouseDocumentUtil.checkBoolean((String) jsonObject.get("是否审核权属原件")));
 
-            Document doc = new Document(baseDir + guarantyResultName);
+
+            //生成文档中的表格
+            //建筑物实物状况表格
 
             List<HouseEntityTable> entityTables = entities.stream().map(x -> {
                 String location = UNKNOWN;
@@ -405,6 +412,8 @@ public class HouseGuarantyServiceImpl implements HouseGuarantyService {
             AsposeWordUtil.createTable(doc, HouseEntityTable.class, entityTables, "buildingInfo");
             doc.save(baseDir + guarantyResultName);
 
+
+
             //更新过程文档url
             HouseGuarantyProcess houseGuarantyProcess = new HouseGuarantyProcess();
             houseGuarantyProcess.setProcessName(GUARANTY_RESULT_REPORT.getMsg());
@@ -507,7 +516,8 @@ public class HouseGuarantyServiceImpl implements HouseGuarantyService {
      * @param tno
      * @return
      */
-    private Integer getCertificateCombination(Long businessId,String tid,String tno){
+    @Override
+    public Integer getCertificateCombination(Long businessId,String tid,String tno){
         int imm = certificateFixedAssetsService.count(new LambdaQueryWrapper<CertificateFixedAssets>()
                 .eq(CertificateFixedAssets::getBusinessType, GUARANTY)
                 .eq(CertificateFixedAssets::getBusinessId, businessId)

+ 79 - 10
service/src/main/java/com/dayou/service/impl/HouseTargetEntityServiceImpl.java

@@ -3,12 +3,12 @@ package com.dayou.service.impl;
 import com.alibaba.fastjson2.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.dayou.common.BaseEntity;
 import com.dayou.dto.HouseGuarantyTargetDTO;
-import com.dayou.entity.HouseGuarantyTarget;
-import com.dayou.entity.HouseTargetEntity;
+import com.dayou.dto.HouseRightsDTO;
+import com.dayou.entity.*;
 import com.dayou.mapper.HouseTargetEntityMapper;
-import com.dayou.service.HouseGuarantyTargetService;
-import com.dayou.service.HouseTargetEntityService;
+import com.dayou.service.*;
 import com.dayou.utils.JsonUtil;
 import com.fasterxml.jackson.databind.util.BeanUtil;
 import org.springframework.beans.BeanUtils;
@@ -16,25 +16,45 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
+import static com.dayou.enums.BusinessEnum.HouseSubBusiness.GUARANTY;
+
 @Service
 public class HouseTargetEntityServiceImpl extends ServiceImpl<HouseTargetEntityMapper, HouseTargetEntity> implements HouseTargetEntityService {
 
     @Autowired
     private HouseGuarantyTargetService houseGuarantyTargetService;
 
+    @Autowired
+    private HouseGuarantyService houseGuarantyService;
+
+    @Autowired
+    private HouseTargetEntityMapper houseTargetEntityMapper;
+
+    @Autowired
+    private CertificateFixedAssetsService fixedAssetsService;
+
+    @Autowired
+    private CertificateHouseOwnService houseOwnService;
+
+    @Autowired
+    private CertificateLandUseService landUseService;
+
     @Override
-    public Boolean addHouseTargetEntity(HouseTargetEntity houseTargetEntity) {
-        return this.saveOrUpdate(houseTargetEntity);
+    public Long addHouseTargetEntity(HouseTargetEntity houseTargetEntity) {
+        Integer certificateCombination = houseGuarantyService.getCertificateCombination(houseTargetEntity.getBusinessId(), houseTargetEntity.getTid(), houseTargetEntity.getTno());
+        houseTargetEntity.setCertCombination(certificateCombination);
+        this.saveOrUpdate(houseTargetEntity);
+        return houseTargetEntity.getId();
     }
 
     @Override
     public HouseTargetEntity getHouseTargetEntityById(Long businessId, String tid, String tno) {
-        HouseTargetEntity entity = this.getOne(new LambdaQueryWrapper<HouseTargetEntity>()
+        return this.getOne(new LambdaQueryWrapper<HouseTargetEntity>()
                 .eq(HouseTargetEntity::getBusinessId, businessId)
                 .eq(HouseTargetEntity::getTid, tid).eq(HouseTargetEntity::getTno, tno));
-        return entity;
     }
 
     @Override
@@ -54,15 +74,64 @@ public class HouseTargetEntityServiceImpl extends ServiceImpl<HouseTargetEntityM
                 if (targetDTO.getNo().equals(originEntity.getTno())
                         && target.getTId().equals(originEntity.getTid())){
                 }else {
-                    HouseTargetEntity targetEntity = new HouseTargetEntity();
+                    HouseTargetEntity targetEntity = this.getOne(new LambdaQueryWrapper<HouseTargetEntity>()
+                            .eq(HouseTargetEntity::getBusinessId, originEntity.getBusinessId())
+                            .eq(HouseTargetEntity::getTid, targetDTO.getId())
+                            .eq(HouseTargetEntity::getTno, targetDTO.getNo()));
+                    if (targetEntity == null){
+                        targetEntity = new HouseTargetEntity();
+                    }
                     BeanUtils.copyProperties(originEntity,targetEntity);
+                    targetEntity.setId(null);
                     targetEntity.setTid(target.getTId());
                     targetEntity.setTno(targetDTO.getNo());
+                    targetEntity.setCertCombination(houseGuarantyService.getCertificateCombination(originEntity.getBusinessId(), targetDTO.getId(), targetDTO.getNo()));
                     targetEntities.add(targetEntity);
                 }
             }
 
         }
-        return this.saveBatch(targetEntities);
+        return this.saveOrUpdateBatch(targetEntities);
+    }
+
+    @Override
+    public List<HouseRightsDTO> getHouseRightsDTOList(Long businessId) {
+        List<HouseRightsDTO> rights = houseTargetEntityMapper.getHouseRightsDTOList(businessId);
+        //完善权属证件信息
+        for (HouseRightsDTO rightsDTO : rights) {
+            if (rightsDTO.getCertType()==0){
+                //只有不动产证
+                CertificateFixedAssets fixedAssets = fixedAssetsService.getOne(new LambdaQueryWrapper<CertificateFixedAssets>()
+                        .eq(CertificateFixedAssets::getBusinessId, businessId)
+                        .eq(CertificateFixedAssets::getTid, rightsDTO.getTid())
+                        .eq(CertificateFixedAssets::getTno, rightsDTO.getTno())
+                        .eq(CertificateFixedAssets::getBusinessType, GUARANTY.name()));
+                rightsDTO.setAssetsCert(fixedAssets);
+            } else if (rightsDTO.getCertType()==5 || rightsDTO.getCertType()==6){
+                //只有房地产证
+                CertificateHouseOwn houseOwn = houseOwnService.getOne(new LambdaQueryWrapper<CertificateHouseOwn>()
+                        .eq(CertificateHouseOwn::getBusinessId, businessId)
+                        .eq(CertificateHouseOwn::getTid, rightsDTO.getTid())
+                        .eq(CertificateHouseOwn::getTno, rightsDTO.getTno())
+                        .eq(CertificateHouseOwn::getBusinessType, GUARANTY.name()));
+                rightsDTO.setHouseOwnCert(houseOwn);
+            } else {
+                //房地产证
+                CertificateHouseOwn houseOwn = houseOwnService.getOne(new LambdaQueryWrapper<CertificateHouseOwn>()
+                        .eq(CertificateHouseOwn::getBusinessId, businessId)
+                        .eq(CertificateHouseOwn::getTid, rightsDTO.getTid())
+                        .eq(CertificateHouseOwn::getTno, rightsDTO.getTno())
+                        .eq(CertificateHouseOwn::getBusinessType, GUARANTY.name()));
+                rightsDTO.setHouseOwnCert(houseOwn);
+                //土地证
+                CertificateLandUse landUse = landUseService.getOne(new LambdaQueryWrapper<CertificateLandUse>()
+                        .eq(CertificateLandUse::getBusinessId, businessId)
+                        .eq(CertificateLandUse::getTid, rightsDTO.getTid())
+                        .eq(CertificateLandUse::getTno, rightsDTO.getTno())
+                        .eq(CertificateLandUse::getBusinessType, GUARANTY.name()));
+                rightsDTO.setLandUseCert(landUse);
+            }
+        }
+        return rights;
     }
 }