wucl 7 months ago
parent
commit
68c8ce2dea
19 changed files with 206 additions and 207 deletions
  1. 4 4
      biz-base/src/main/java/com/dayou/controller/HouseGuarantyBaseController.java
  2. 1 1
      biz-base/src/main/java/com/dayou/controller/HouseGuarantyDocController.java
  3. 0 1
      biz-base/src/main/java/com/dayou/controller/HouseGuarantyTargetController.java
  4. 48 109
      common/src/main/java/com/dayou/utils/HouseDocumentUtil.java
  5. 2 0
      dao/src/main/java/com/dayou/mapper/HouseGuarantyBaseMapper.java
  6. 9 0
      dao/src/main/resources/mapper/HouseGuarantyBaseMapper.xml
  7. 10 5
      dao/src/main/resources/mapper/HouseTargetEntityMapper.xml
  8. 5 0
      domain/src/main/java/com/dayou/doc/house/GuarantyResultDO.java
  9. 24 0
      domain/src/main/java/com/dayou/entity/HouseGuarantyBase.java
  10. 2 22
      domain/src/main/java/com/dayou/entity/HouseGuarantyTarget.java
  11. 6 0
      domain/src/main/java/com/dayou/entity/HouseTargetEntity.java
  12. 2 0
      service/src/main/java/com/dayou/service/HouseGuarantyBaseService.java
  13. 1 1
      service/src/main/java/com/dayou/service/HouseGuarantyService.java
  14. 2 0
      service/src/main/java/com/dayou/service/HouseTargetEntityService.java
  15. 1 1
      service/src/main/java/com/dayou/service/TmplHouseParagraphService.java
  16. 9 1
      service/src/main/java/com/dayou/service/impl/HouseGuarantyBaseServiceImpl.java
  17. 52 47
      service/src/main/java/com/dayou/service/impl/HouseGuarantyServiceImpl.java
  18. 15 0
      service/src/main/java/com/dayou/service/impl/HouseTargetEntityServiceImpl.java
  19. 13 15
      service/src/main/java/com/dayou/service/impl/TmplHouseParagraphServiceImpl.java

+ 4 - 4
biz-base/src/main/java/com/dayou/controller/HouseGuarantyBaseController.java

@@ -30,11 +30,11 @@ public class HouseGuarantyBaseController {
 
     /**
      * 根据id查询
-     * @param id
+     * @param docId
      * @return
      */
-    @GetMapping("/{id}")
-    public Result<HouseGuarantyBase> getById(@PathVariable("id") Long id){
-        return Result.build(houseGuarantyBaseService.getById(id));
+    @GetMapping("/{docId}")
+    public Result<HouseGuarantyBase> getByDocId(@PathVariable("docId") Long docId){
+        return Result.build(houseGuarantyBaseService.getByDocId(docId));
     }
 }

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

@@ -107,7 +107,7 @@ public class HouseGuarantyDocController {
      * @return
      */
     @GetMapping("/result/{id}")
-    public Result<String> genResultLetter(@PathVariable("id") Long id){
+    public Result<Boolean> genResultLetter(@PathVariable("id") Long id){
         return Result.build(houseGuarantyService.genResultLetter(id));
     }
 

+ 0 - 1
biz-base/src/main/java/com/dayou/controller/HouseGuarantyTargetController.java

@@ -5,7 +5,6 @@ import com.dayou.entity.HouseGuarantyTarget;
 import com.dayou.result.Result;
 import com.dayou.service.HouseGuarantyAimService;
 import com.dayou.service.HouseGuarantyTargetService;
-import com.dayou.vo.HouseTargetVO;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;

+ 48 - 109
common/src/main/java/com/dayou/utils/HouseDocumentUtil.java

@@ -11,6 +11,7 @@ import com.dayou.dto.HouseRightsDTO;
 import com.dayou.entity.HouseGuarantyAim;
 import com.dayou.entity.*;
 import com.dayou.enums.HouseTargetTableColumn;
+import com.dayou.exception.BusinessException;
 import com.dayou.exception.ErrorCode;
 import com.dayou.table.HouseAreaTable;
 
@@ -197,7 +198,7 @@ public class HouseDocumentUtil {
 
         Set<String> landType = aims.stream().map(HouseGuarantyAim::getLandType).collect(Collectors.toSet());
 
-        List<Object> outerAcreage = aims.stream().map(HouseGuarantyAim::getOuterAcreage).collect(Collectors.toList());
+        List<Object> outerAcreage = aims.stream().filter(x->!"/".equals(x.getOuterAcreage())).map(HouseGuarantyAim::getOuterAcreage).collect(Collectors.toList());
 
         Set<String> useTo = aims.stream().map(HouseGuarantyAim::getUseTo).collect(Collectors.toSet());
 
@@ -271,7 +272,7 @@ public class HouseDocumentUtil {
      * @param list
      * @return
      */
-    public static BigDecimal sumList(List<Object> list){
+    public static BigDecimal sumList(List<Object> list) {
         BigDecimal sum = null;
         try {
             sum = (BigDecimal) list.stream().reduce(BigDecimal.ZERO, (a, b) -> {
@@ -991,36 +992,28 @@ public class HouseDocumentUtil {
      * @param tmplParagraph
      * @return
      */
-    public static String isOldPledgeToNewPledge(List<HouseGuarantyTarget> targets, TmplHouseParagraph tmplParagraph) {
+    public static String isOldPledgeToNewPledge(TmplHouseParagraph tmplParagraph,HouseGuarantyBase base) {
         StringBuilder result = new StringBuilder();
         String paragraph = tmplParagraph.getParagraph();
-        if (CollectionUtil.isNotEmpty(targets)){
-            List<HouseGuarantyTarget> collect = targets.stream().filter(x -> (x.getHasPledge()!=null &&
-                    x.getHasPledge() && StrUtil.isNotBlank(x.getPledgeType())
-                    && StrUtil.isNotBlank(x.getPledgeUser()) && StrUtil.isNotBlank(x.getPledgeValue())
-                    && StrUtil.isNotBlank(x.getNewPledgeUser()))).collect(Collectors.toList());
-            if (CollectionUtil.isNotEmpty(collect)){
-                for (int i = 0; i < collect.size(); i++){
-                    String replace = getString(collect.get(i), paragraph);
-                    result.append(replace);
-                    if (i != collect.size()-1){
-                        result.append("\n");
-                    }
-                }
-            }
+        if (base.getHasPledge()){
+//            List<HouseGuarantyTarget> collect = targets.stream().filter(x -> (x.getHasPledge()!=null &&
+//                    x.getHasPledge() && StrUtil.isNotBlank(x.getPledgeType())
+//                    && StrUtil.isNotBlank(x.getPledgeUser()) && StrUtil.isNotBlank(x.getPledgeValue())
+//                    && StrUtil.isNotBlank(x.getNewPledgeUser()))).collect(Collectors.toList());
+
+            String replace = getString(paragraph,base);
+            result.append(replace);
             return result.toString();
         }
         return null;
     }
 
-    private static String getString(HouseGuarantyTarget target, String paragraph) {
-        String pledgeType = target.getPledgeType();
-        String pledgeUser = target.getPledgeUser();
-        String pledgeValue = target.getPledgeValue();
-        String newPledgeUser = target.getNewPledgeUser();
-        String tId = target.getTid();
-        return paragraph.replace("{tId}", tId)
-                .replace("{tId}", tId).replace("{pledgeType}", pledgeType).replace("{pledgeType}", pledgeType)
+    private static String getString(String paragraph,HouseGuarantyBase base) {
+        String pledgeType = base.getPledgeType();
+        String pledgeUser = base.getPledgeUser();
+        String pledgeValue = base.getPledgeValue();
+        String newPledgeUser = base.getNewPledgeUser();
+        return paragraph.replace("{pledgeType}", pledgeType).replace("{pledgeType}", pledgeType)
                 .replace("{pledgeUser}", pledgeUser).replace("{pledgeValue}",
                         pledgeValue).replace("{newPledgeUser}", newPledgeUser);
     }
@@ -1052,27 +1045,18 @@ public class HouseDocumentUtil {
 
     /**
      * 限制条件 适用于原抵押权未注销,现拟设立最高额抵押权,同一抵押权人
-     * @param targets
      * @param tmplParagraph
      * @return
      */
-    public static String isOldPledgeToOldPledge(List<HouseGuarantyTarget> targets, TmplHouseParagraph tmplParagraph) {
+    public static String isOldPledgeToOldPledge( TmplHouseParagraph tmplParagraph,HouseGuarantyBase base) {
         StringBuilder result = new StringBuilder();
         String paragraph = tmplParagraph.getParagraph();
-        if (CollectionUtil.isNotEmpty(targets)){
-            List<HouseGuarantyTarget> collect = targets.stream().filter(x -> x.getHasPledge()!=null &&
-                    x.getHasPledge() && StrUtil.isNotBlank(x.getPledgeType())
-                    && x.getSamePledgeHigh()!=null &&x.getSamePledgeHigh()).collect(Collectors.toList());
-            if (CollectionUtil.isNotEmpty(collect)){
-                for (int i = 0; i < collect.size(); i++){
-                    String tId = collect.get(i).getTid();
-                    String pledgeUser = collect.get(i).getPledgeUser();
-                    result.append(paragraph.replace("{tId}", tId).replace("{tId}",tId).replace("{pledgeUser}",pledgeUser));
-                    if (i != collect.size()-1){
-                        result.append("\n");
-                    }
-                }
-            }
+        if (base.getHasPledge()){
+//            List<HouseGuarantyTarget> collect = targets.stream().filter(x -> x.getHasPledge()!=null &&
+//                    x.getHasPledge() && StrUtil.isNotBlank(x.getPledgeType())
+//                    && x.getSamePledgeHigh()!=null &&x.getSamePledgeHigh()).collect(Collectors.toList());
+            String pledgeUser = base.getPledgeUser();
+            result.append(paragraph.replace("{pledgeUser}",pledgeUser));
             return result.toString();
         }
         return null;
@@ -1100,11 +1084,10 @@ public class HouseDocumentUtil {
 
     /**
      * 限制条件 是否提供技术报告
-     * @param targets
      * @param tmplParagraph
      * @return
      */
-    public static String isProvideTechReport(List<HouseGuarantyTarget> targets, TmplHouseParagraph tmplParagraph,Boolean hasTechReport) {
+    public static String isProvideTechReport(TmplHouseParagraph tmplParagraph,Boolean hasTechReport) {
         String paragraph = tmplParagraph.getParagraph();
         if (hasTechReport){
             return paragraph.replace("{hasTechReport}","、“估价技术报告”");
@@ -1132,18 +1115,12 @@ public class HouseDocumentUtil {
 
     /**
      * 估价中的特殊处理事项 无法定优先受偿款
-     * @param targets
      * @param tmplParagraph
      * @return
      */
-    public static String isNoFirstMoney(List<HouseGuarantyTarget> targets, TmplHouseParagraph tmplParagraph) {
-        if (CollectionUtil.isNotEmpty(targets)){
-            List<HouseGuarantyTarget> collect = targets.stream().filter(x -> StrUtil.isBlank(x.getFirstMoney())).collect(Collectors.toList());
-            if (CollectionUtil.isNotEmpty(collect)){
-                List<String> tIds = collect.stream().map(HouseGuarantyTarget::getTid).collect(Collectors.toList());
-                String paragraph = tmplParagraph.getParagraph();
-                return paragraph.replace("{tIds}", CollectionUtil.formatDotAndRemoveMiddle(tIds));
-            }
+    public static String isNoFirstMoney(TmplHouseParagraph tmplParagraph,HouseGuarantyBase base) {
+        if (StrUtil.isNotBlank(base.getFirstMoney())){
+            return tmplParagraph.getParagraph();
         }
         return null;
     }
@@ -1154,17 +1131,10 @@ public class HouseDocumentUtil {
      * @param tmplParagraph
      * @return
      */
-    public static String isSamePledgeUserContinue(List<HouseGuarantyTarget> targets, TmplHouseParagraph tmplParagraph) {
-        if (CollectionUtil.isNotEmpty(targets)){
-            List<HouseGuarantyTarget> collect = targets.stream().filter(x -> x.getSamePledgeContinue()!=null &&
-                    x.getSamePledgeContinue() && StrUtil.isNotBlank(x.getPledgeType())).collect(Collectors.toList());
-            if (CollectionUtil.isNotEmpty(collect)){
-                List<String> tIds = collect.stream().map(HouseGuarantyTarget::getTid).collect(Collectors.toList());
-                Set<String> pledgeTypes = collect.stream().map(HouseGuarantyTarget::getPledgeType).collect(Collectors.toSet());
+    public static String isSamePledgeUserContinue(TmplHouseParagraph tmplParagraph,HouseGuarantyBase base) {
+        if (base.getSamePledgeContinue()!=null && base.getSamePledgeContinue() && StrUtil.isNotBlank(base.getPledgeType())){
                 String paragraph = tmplParagraph.getParagraph();
-                return paragraph.replace("{tIds}", CollectionUtil.formatDotAndRemoveMiddle(tIds))
-                        .replace("{pledgeTypes}",CollectionUtil.formatDotAndRemoveMiddle(pledgeTypes));
-            }
+                return paragraph.replace("{pledgeTypes}",base.getPledgeType());
         }
         return null;
     }
@@ -1175,24 +1145,13 @@ public class HouseDocumentUtil {
      * @param tmplParagraph
      * @return
      */
-    public static String isOldPledgeToNewPledgeSpecial(List<HouseGuarantyTarget> targets, TmplHouseParagraph tmplParagraph) {
+    public static String isOldPledgeToNewPledgeSpecial(TmplHouseParagraph tmplParagraph,HouseGuarantyBase base) {
         StringBuilder result = new StringBuilder();
         String paragraph = tmplParagraph.getParagraph();
-        if (CollectionUtil.isNotEmpty(targets)){
-            List<HouseGuarantyTarget> collect = targets.stream().filter(x -> StrUtil.isNotBlank(x.getPledgeType())
-                    && StrUtil.isNotBlank(x.getNewPledgeUser())).collect(Collectors.toList());
-            if (CollectionUtil.isNotEmpty(collect)){
-                for (int i = 0; i < collect.size(); i++){
-                    String tId = collect.get(i).getTid();
-                    String pledgeType = collect.get(i).getPledgeType();
-                    String newPledgeUser = collect.get(i).getNewPledgeUser();
-                    result.append(paragraph.replace("{tId}", tId)
-                            .replace("{pledgeType}", pledgeType).replace("{newPledgeUser}",newPledgeUser));
-                    if (i != collect.size()-1){
-                        result.append("\n");
-                    }
-                }
-            }
+        if (StrUtil.isNotBlank(base.getPledgeType()) && StrUtil.isNotBlank(base.getNewPledgeUser())){
+            String pledgeType = base.getPledgeType();
+            String newPledgeUser = base.getNewPledgeUser();
+            result.append(paragraph.replace("{pledgeType}", pledgeType).replace("{newPledgeUser}",newPledgeUser));
             return result.toString();
         }
         return null;
@@ -1200,27 +1159,17 @@ public class HouseDocumentUtil {
 
     /**
      * 估价中的特殊处理事项 适用于原已设立抵押权,现拟设立最高额抵押权,同一抵押权人
-     * @param targets
      * @param tmplParagraph
      * @return
      */
-    public static String isNormalPledgeToHighPledge(List<HouseGuarantyTarget> targets, TmplHouseParagraph tmplParagraph) {
+    public static String isNormalPledgeToHighPledge(TmplHouseParagraph tmplParagraph,HouseGuarantyBase base) {
         StringBuilder result = new StringBuilder();
         String paragraph = tmplParagraph.getParagraph();
-        if (CollectionUtil.isNotEmpty(targets)){
-            List<HouseGuarantyTarget> collect = targets.stream().filter(x -> x.getHasPledge()!=null &&
-                    x.getHasPledge() && StrUtil.isNotBlank(x.getPledgeType()) && x.getSamePledgeHigh()!=null &&
-                    x.getSamePledgeHigh()).collect(Collectors.toList());
-            if (CollectionUtil.isNotEmpty(collect)){
-                for (int i = 0; i < collect.size(); i++){
-                    String tId = collect.get(i).getTid();
-                    String pledgeUser = collect.get(i).getPledgeUser();
-                    result.append(paragraph.replace("{tId}", tId).replace("{tId}",tId).replace("{pledgeUser}",pledgeUser));
-                    if (i != collect.size()-1){
-                        result.append("\n");
-                    }
-                }
-            }
+        if (base.getHasPledge()!=null &&
+            base.getHasPledge() && StrUtil.isNotBlank(base.getPledgeType()) && base.getSamePledgeHigh()!=null &&
+            base.getSamePledgeHigh()){
+            String pledgeUser = base.getPledgeUser();
+            result.append(paragraph.replace("{pledgeUser}",pledgeUser));
             return result.toString();
         }
         return null;
@@ -1228,26 +1177,16 @@ public class HouseDocumentUtil {
 
     /**
      * 估价中的特殊处理事项 适用于已设立最高额抵押权,抵押未到期
-     * @param targets
      * @param tmplParagraph
      * @return
      */
-    public static String isHighPledgeNotExpire(List<HouseGuarantyTarget> targets, TmplHouseParagraph tmplParagraph) {
+    public static String isHighPledgeNotExpire( TmplHouseParagraph tmplParagraph,HouseGuarantyBase base) {
         StringBuilder result = new StringBuilder();
         String paragraph = tmplParagraph.getParagraph();
-        if (CollectionUtil.isNotEmpty(targets)){
-            List<HouseGuarantyTarget> collect = targets.stream().filter(x -> x.getHasPledge()!=null && x.getHasPledge()
-                    &&  x.getHighPledgeNotExpire()!=null && x.getHighPledgeNotExpire()).collect(Collectors.toList());
-            if (CollectionUtil.isNotEmpty(collect)){
-                for (int i = 0; i < collect.size(); i++){
-                    String tId = collect.get(i).getTid();
-                    String pledgeUser = collect.get(i).getPledgeUser();
-                    result.append(paragraph.replace("{tId}", tId).replace("{tId}",tId).replace("{pledgeUser}",pledgeUser));
-                    if (i != collect.size()-1){
-                        result.append("\n");
-                    }
-                }
-            }
+        if (base.getHasPledge()!=null && base.getHasPledge()
+                &&  base.getHighPledgeNotExpire()!=null && base.getHighPledgeNotExpire()){
+            String pledgeUser = base.getPledgeUser();
+            result.append(paragraph.replace("{pledgeUser}",pledgeUser));
             return result.toString();
         }
         return null;

+ 2 - 0
dao/src/main/java/com/dayou/mapper/HouseGuarantyBaseMapper.java

@@ -2,7 +2,9 @@ package com.dayou.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.dayou.entity.HouseGuarantyBase;
+import org.apache.ibatis.annotations.Param;
 
 public interface HouseGuarantyBaseMapper extends BaseMapper<HouseGuarantyBase> {
 
+    HouseGuarantyBase getByDocId(@Param("docId") Long docId);
 }

+ 9 - 0
dao/src/main/resources/mapper/HouseGuarantyBaseMapper.xml

@@ -2,5 +2,14 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.dayou.mapper.HouseGuarantyBaseMapper">
 
+    <select id="getByDocId" parameterType="java.lang.Long" resultType="com.dayou.entity.HouseGuarantyBase">
+        SELECT
+            *
+        FROM
+            house_guaranty_base
+        WHERE
+            id = ( SELECT base_id FROM house_guaranty_process WHERE id = ( SELECT business_id FROM document_production WHERE id = #{docId} AND delete_status = 0 ) AND delete_status = 0 )
+          AND delete_status = 0
+    </select>
 
 </mapper>

+ 10 - 5
dao/src/main/resources/mapper/HouseTargetEntityMapper.xml

@@ -4,6 +4,10 @@
 
     <select id="getListById" parameterType="java.lang.Long" resultType="com.dayou.entity.HouseTargetEntity">
         SELECT
+            hga.id as xId,
+            hga.doc_id as xDodId,
+            hga.tid as xTid,
+            hga.tno as xTno,
             hte.*,
             clu.location as landLocation,
             clu.acreage as landAcreage,
@@ -20,18 +24,19 @@
             hgt.land_use_to as targetLandUseTo,
             hgt.land_use_type as targetLandUseType
         FROM
-            house_target_entity hte
-                LEFT JOIN (select business_id,tid,tno,certificate_no,location,acreage,use_to,use_type,expire_date from certificate_land_use where delete_status = 0) clu ON (
+            house_guaranty_aim hga left join
+                (select * from house_target_entity where delete_status = 0 ) hte on (hga.doc_id = hte.doc_id and hga.tid = hte.tid and hga.tno = hte.tno)
+                                   LEFT JOIN (select business_id,tid,tno,certificate_no,location,acreage,use_to,use_type,expire_date from certificate_land_use where delete_status = 0) clu ON (
                 hte.doc_id = clu.business_id
                     AND hte.tid = clu.tid
                     AND hte.tno = clu.tno)
-                left join  (select business_id,tid,tno,certificate_no,location,acreage_desc,use_to,own_ship_nature,expire_date_desc from certificate_fixed_assets where delete_status = 0) cfa on (
+                                   left join  (select business_id,tid,tno,certificate_no,location,acreage_desc,use_to,own_ship_nature,expire_date_desc from certificate_fixed_assets where delete_status = 0) cfa on (
                 hte.doc_id = cfa.business_id
                     AND hte.tid = cfa.tid
                     AND hte.tno = cfa.tno
                 )
-                left join (select tid,doc_id,land_use_to ,land_use_type from house_guaranty_target where delete_status = 0) hgt on (hgt.doc_id = hte.doc_id and hgt.tid = hte.tid)
-        where hte.delete_status=0 and hte.doc_id = #{docId}
+                                   left join (select tid,doc_id,land_use_to ,land_use_type from house_guaranty_target where delete_status = 0) hgt on (hgt.doc_id = hte.doc_id and hgt.tid = hte.tid)
+        where hga.delete_status=0 and hga.doc_id = #{docId}
         order by hte.tid asc ,hte.tno asc
     </select>
 

+ 5 - 0
domain/src/main/java/com/dayou/doc/house/GuarantyResultDO.java

@@ -55,4 +55,9 @@ public class GuarantyResultDO {
      */
     private String landInfo;
 
+    /**
+     * 价值时点
+     */
+    private String valueTiming;
+
 }

+ 24 - 0
domain/src/main/java/com/dayou/entity/HouseGuarantyBase.java

@@ -108,6 +108,30 @@ public class HouseGuarantyBase extends BaseEntity {
      */
     private String creditCode;
 
+    private Boolean hasPledge;
+
+    private String pledgeUser;
+
+    private String pledgeType;
+
+    private String pledgeValue;
+
+    private Boolean samePledgeContinue;
+
+    private String newPledgeUser;
+
+    private Boolean highPledgeNotExpire;
+
+    private Boolean samePledgeHigh;
+
+    private String firstMoney;
+
+    private String debtMoney;
+
+    private Boolean isTakeOutFirstMoney;
+
+
+
 
     /**
      * 权利

+ 2 - 22
domain/src/main/java/com/dayou/entity/HouseGuarantyTarget.java

@@ -72,29 +72,7 @@ public class HouseGuarantyTarget extends BaseEntity implements Serializable {
 
     private String rentUser;
 
-    private Boolean hasPledge;
 
-    private String pledgeUser;
-
-    private String pledgeType;
-
-    private String pledgeValue;
-
-    private Boolean samePledgeContinue;
-
-    private String newPledgeUser;
-
-    private Boolean highPledgeNotExpire;
-
-    private Boolean samePledgeHigh;
-
-    private String firstMoney;
-
-    private String debtMoney;
-
-    private Boolean isTakeOutFirstMoney;
-
-    private Boolean isCostingShareMethod;
 
     private Boolean noBuildingHouseNos;
 
@@ -118,6 +96,8 @@ public class HouseGuarantyTarget extends BaseEntity implements Serializable {
 
     private String landUseRightTo;
 
+    private Boolean isCostingShareMethod;
+
     @TableField(exist = false)
     private List<HouseGuarantyAim> aims;
 

+ 6 - 0
domain/src/main/java/com/dayou/entity/HouseTargetEntity.java

@@ -87,4 +87,10 @@ public class HouseTargetEntity extends BaseEntity {
     private String targetLandUseTo;
     @TableField(exist = false)
     private String targetLandUseType;
+    @TableField(exist = false)
+    private Long xId;
+    @TableField(exist = false)
+    private String xTid;
+    @TableField(exist = false)
+    private String xTno;
 }

+ 2 - 0
service/src/main/java/com/dayou/service/HouseGuarantyBaseService.java

@@ -6,4 +6,6 @@ import com.dayou.entity.HouseGuarantyBase;
 public interface HouseGuarantyBaseService extends IService<HouseGuarantyBase> {
 
     Long add(HouseGuarantyBase base);
+
+    HouseGuarantyBase getByDocId(Long docId);
 }

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

@@ -59,7 +59,7 @@ public interface HouseGuarantyService {
      * @param id
      * @return
      */
-    String genResultLetter(Long id);
+    Boolean genResultLetter(Long id);
 
     /**
      * 获取权属证书组合类型

+ 2 - 0
service/src/main/java/com/dayou/service/HouseTargetEntityService.java

@@ -15,4 +15,6 @@ public interface HouseTargetEntityService extends IService<HouseTargetEntity> {
     Boolean copyHouseTargetEntity(Long id);
 
     List<HouseRightsDTO> getHouseRightsDTOList(Long businessId);
+
+    List<HouseTargetEntity> getListById(Long id);
 }

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

@@ -59,5 +59,5 @@ public interface TmplHouseParagraphService extends IService<TmplHouseParagraph>
      * @param targets
      * @return
      */
-    String findSpecialHandle(List<HouseGuarantyTarget> targets);
+    String findSpecialHandle(List<HouseGuarantyTarget> targets,HouseGuarantyBase base);
 }

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

@@ -1,6 +1,5 @@
 package com.dayou.service.impl;
 
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.dayou.common.BaseEntity;
@@ -17,6 +16,10 @@ public class HouseGuarantyBaseServiceImpl extends ServiceImpl<HouseGuarantyBaseM
 
     @Autowired
     private HouseGuarantyProcessService houseGuarantyProcessService;
+
+    @Autowired
+    private HouseGuarantyBaseMapper houseGuarantyBaseMapper;
+
     @Override
     public Long add(HouseGuarantyBase base) {
         this.saveOrUpdate(base);
@@ -26,4 +29,9 @@ public class HouseGuarantyBaseServiceImpl extends ServiceImpl<HouseGuarantyBaseM
         }
         return base.getId();
     }
+
+    @Override
+    public HouseGuarantyBase getByDocId(Long docId) {
+        return houseGuarantyBaseMapper.getByDocId(docId);
+    }
 }

+ 52 - 47
service/src/main/java/com/dayou/service/impl/HouseGuarantyServiceImpl.java

@@ -1,10 +1,7 @@
 package com.dayou.service.impl;
 
-import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONArray;
-import cn.hutool.json.JSONObject;
-import cn.hutool.json.JSONUtil;
-import com.alibaba.fastjson2.JSON;
 import com.aspose.cells.SaveFormat;
 import com.aspose.cells.Workbook;
 import com.aspose.words.*;
@@ -34,6 +31,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.io.File;
+import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.nio.file.Files;
@@ -126,6 +124,9 @@ public class HouseGuarantyServiceImpl implements HouseGuarantyService {
         String projectName = HouseDocumentUtil.getProjectName(houseGuarantyAims);
 
         HouseGuarantyBase base = houseGuarantyBaseService.getById(process.getBaseId());
+        if (base==null || StrUtil.isBlank(base.getConsignor())){
+            ErrorCode.throwBusinessException(ErrorCode.CUSTOM_ERROR,"请先完善基本信息");
+        }
         DocumentProduction dp = buildDocumentProduction(processId, projectName, base.getDocNo(), base.getConsignor());
         documentProductionService.save(dp);
 
@@ -153,7 +154,8 @@ public class HouseGuarantyServiceImpl implements HouseGuarantyService {
 
             //读取基本信息
             HouseGuarantyBase base = houseGuarantyBaseService.getById(process.getBaseId());
-
+            String projectName = HouseDocumentUtil.getProjectName(aims);
+            base.setProjectName(projectName);
             Map<String, List<HouseGuarantyAim>> collect = aims.stream().collect(Collectors.groupingBy(HouseGuarantyAim::getTid));
             String actDesc = HouseDocumentUtil.combinationTargetDescription(collect);
             base.setActDesc(actDesc);
@@ -179,6 +181,11 @@ public class HouseGuarantyServiceImpl implements HouseGuarantyService {
             return houseGuarantyProcessService.update(new LambdaUpdateWrapper<HouseGuarantyProcess>().set(HouseGuarantyProcess::getDocUrl, consignorLetterName)
                     .eq(BaseEntity::getId, pId));
 
+        }
+        catch (FileNotFoundException e) {
+            throw new RuntimeException(e);
+        } catch (IOException e) {
+            throw new RuntimeException(e);
         } catch (Exception e) {
             throw new RuntimeException(e);
         }
@@ -263,7 +270,7 @@ public class HouseGuarantyServiceImpl implements HouseGuarantyService {
             conditionDO.setSYBGSM(useReportExplain);
 
             //组合估价中的特殊处理事项内容
-            String specialHandles = tmplHouseParagraphService.findSpecialHandle(targets);
+            String specialHandles = tmplHouseParagraphService.findSpecialHandle(targets,base);
             conditionDO.setTSSXCL(specialHandles);
 
             byte[] tmplWordByte = Files.readAllBytes(Paths.get(baseDir
@@ -300,37 +307,41 @@ public class HouseGuarantyServiceImpl implements HouseGuarantyService {
     }
 
     @Override
-    public String genResultLetter(Long id) {
+    public Boolean genResultLetter(Long id) {
         DocumentProduction dp = documentProductionService.getById(id);
         HouseGuarantyProcess process = houseGuarantyProcessService.getById(dp.getBusinessId());
         String baseDir = fileNetConfig.getBaseDir();
 
-        try {
-            //读取估价对象数组
-            List<HouseGuarantyAim> aims = houseGuarantyAimService.list(new LambdaQueryWrapper<HouseGuarantyAim>().eq(HouseGuarantyAim::getDocId, id));
-            HouseGuarantyBase base = houseGuarantyBaseService.getById(process.getBaseId());
-//            JSONArray array = JsonUtil.file2JsonArray(home + TARGETS_JSON);
-//            JSONObject jsonObject = JsonUtil.file2JsonObject(home + BASE_INFO_JSON);
-
-            //替换字段
-            GuarantyResultDO guarantyResultDO = new GuarantyResultDO();
-            guarantyResultDO.setDocNo(base.getDocNo());
-            guarantyResultDO.setConsignor(base.getConsignor());
-            guarantyResultDO.setConsignorType(base.getConsignorType());
-            guarantyResultDO.setConsignorAddress(base.getConsignorAddress());
-            guarantyResultDO.setConsignorPerson(base.getConsignorPerson());
-            guarantyResultDO.setConsignorMoney(base.getConsignorMoney());
-            guarantyResultDO.setCreditCode(base.getCreditCode());
-
-            Map<String, List<HouseGuarantyAim>> collect = aims.stream().collect(Collectors.groupingBy(HouseGuarantyAim::getTid));
-
-            guarantyResultDO.setTargetScope(HouseDocumentUtil.combinationTargetDescription(collect));
+        //读取估价对象数组
+        List<HouseGuarantyAim> aims = houseGuarantyAimService.list(new LambdaQueryWrapper<HouseGuarantyAim>().eq(HouseGuarantyAim::getDocId, id));
 
-            List<HouseTargetEntity> entities = houseTargetEntityMapper.getListById(id);
-
-            //土地实物状况描述
-            guarantyResultDO.setLandInfo(HouseDocumentUtil.getLandInfoDesc(entities));
+        //获取基本信息
+        HouseGuarantyBase base = houseGuarantyBaseService.getById(process.getBaseId());
 
+        //实物状况描述
+        List<HouseTargetEntity> entities = houseTargetEntityService.getListById(id);
+
+        //获取权属信息数据源
+        List<HouseRightsDTO> houseRightsDTOList = houseTargetEntityService.getHouseRightsDTOList(id);
+
+        //获取区位状况数据源
+        List<HouseGuarantyArea> areas = houseGuarantyAreaService.getAreasList(id);
+
+        Map<String, List<HouseGuarantyAim>> collect = aims.stream().collect(Collectors.groupingBy(HouseGuarantyAim::getTid));
+
+        //替换字段
+        GuarantyResultDO guarantyResultDO = new GuarantyResultDO();
+        guarantyResultDO.setValueTiming(base.getValueTiming());
+        guarantyResultDO.setDocNo(base.getDocNo());
+        guarantyResultDO.setConsignor(base.getConsignor());
+        guarantyResultDO.setConsignorType(base.getConsignorType());
+        guarantyResultDO.setConsignorAddress(base.getConsignorAddress());
+        guarantyResultDO.setConsignorPerson(base.getConsignorPerson());
+        guarantyResultDO.setConsignorMoney(base.getConsignorMoney());
+        guarantyResultDO.setCreditCode(base.getCreditCode());
+        guarantyResultDO.setTargetScope(HouseDocumentUtil.combinationTargetDescription(collect));
+        guarantyResultDO.setLandInfo(HouseDocumentUtil.getLandInfoDesc(entities));
+        try {
             byte[] tmplWordByte = Files.readAllBytes(Paths.get(baseDir
                     + fileNetConfig.getHouseGuarantyTemplatePath() + GUARANTY_RESULT_TEMPLATE));
 
@@ -345,18 +356,12 @@ public class HouseGuarantyServiceImpl implements HouseGuarantyService {
             //替换完成,此处开始动态创建内容
             //获取替换后的文档
             Document doc = new Document(baseDir + guarantyResultName);
-
-            //获取权属信息数据源
-            List<HouseRightsDTO> houseRightsDTOList = houseTargetEntityService.getHouseRightsDTOList(id);
+            //创作权属信息段落
             HouseDocumentUtil.getRightsDesc(doc,houseRightsDTOList,
                     base.getIsCheckOriginCertificate());
-
-            //获取区位状况数据源
-            List<HouseGuarantyArea> areas = houseGuarantyAreaService.getAreasList(id);
+            //创作区位信息段落
             HouseDocumentUtil.getAreaDesc(doc,areas);
-            //生成文档中的表格
             //建筑物实物状况表格
-
             List<HouseEntityTable> entityTables = entities.stream().map(x -> {
                 String location = UNKNOWN;
                 String acreage = UNKNOWN;
@@ -391,12 +396,9 @@ public class HouseGuarantyServiceImpl implements HouseGuarantyService {
                         .location(location).desc(HouseDocumentUtil.targetEntityDesc(location, useTo, acreage, x)).build();
                 return entityTable;
             }).collect(Collectors.toList());
-
+            //生成文档中的表格
             AsposeWordUtil.createTable(doc, HouseEntityTable.class, entityTables, "buildingInfo");
             doc.save(baseDir + guarantyResultName);
-
-
-
             //更新过程文档url
             HouseGuarantyProcess houseGuarantyProcess = new HouseGuarantyProcess();
             houseGuarantyProcess.setProcessName(GUARANTY_RESULT_REPORT.getMsg());
@@ -404,11 +406,14 @@ public class HouseGuarantyServiceImpl implements HouseGuarantyService {
             houseGuarantyProcess.setHome(process.getHome());
             houseGuarantyProcess.setParentId(process.getId());
             houseGuarantyProcessService.save(houseGuarantyProcess);
-            return guarantyResultName;
-        }catch (Exception e){
-            e.printStackTrace();
+            return true;
+        } catch (FileNotFoundException e) {
+            throw new RuntimeException(e);
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        } catch (Exception e) {
+            throw new RuntimeException(e);
         }
-        return "";
     }
 
     /**

+ 15 - 0
service/src/main/java/com/dayou/service/impl/HouseTargetEntityServiceImpl.java

@@ -5,14 +5,18 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.dayou.entity.HouseGuarantyAim;
 import com.dayou.dto.HouseRightsDTO;
 import com.dayou.entity.*;
+import com.dayou.exception.ErrorCode;
 import com.dayou.mapper.HouseTargetEntityMapper;
 import com.dayou.service.*;
+import com.dayou.utils.CollectionUtil;
 import org.springframework.beans.BeanUtils;
 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 java.util.stream.Collectors;
 
 import static com.dayou.enums.BusinessEnum.HouseSubBusiness.GUARANTY;
 
@@ -123,4 +127,15 @@ public class HouseTargetEntityServiceImpl extends ServiceImpl<HouseTargetEntityM
         }
         return rights;
     }
+
+    @Override
+    public List<HouseTargetEntity> getListById(Long id) {
+        List<HouseTargetEntity> entities = houseTargetEntityMapper.getListById(id);
+        List<HouseTargetEntity> collect = entities.stream().filter(x -> x.getId() == null).collect(Collectors.toList());
+        if (CollectionUtil.isNotEmpty(collect)){
+            ErrorCode.throwBusinessException(ErrorCode.CUSTOM_ERROR,
+                    "估价对象"+collect.get(0).getXTid()+"序号"+collect.get(0).getXTno()+"实物状况信息缺失。");
+        }
+        return entities;
+    }
 }

+ 13 - 15
service/src/main/java/com/dayou/service/impl/TmplHouseParagraphServiceImpl.java

@@ -277,24 +277,22 @@ public class TmplHouseParagraphServiceImpl extends ServiceImpl<TmplHouseParagrap
             if (StrUtil.isNotBlank(rule)){
                 if (IS_NOT_PLEDGE.getCode().equals(rule)){
                     //todo
-                    for (HouseGuarantyTarget target : targets){
-                        String notPledge = HouseDocumentUtil.isNotPledge(paragraph,target.getHasPledge());
-                        if (StrUtil.isNotBlank(notPledge)){
-                            result.append(i).append(". ").append(notPledge);
-                            i++;
-                        }
+                    String notPledge = HouseDocumentUtil.isNotPledge(paragraph,base.getHasPledge());
+                    if (StrUtil.isNotBlank(notPledge)){
+                        result.append(i).append(". ").append(notPledge);
+                        i++;
                     }
 
                 }
                 if (IS_OLD_PLEDGE_TO_NEW_PLEDGE.getCode().equals(rule)){
-                    String oldPledgeToNewPledge = HouseDocumentUtil.isOldPledgeToNewPledge(targets,paragraph);
+                    String oldPledgeToNewPledge = HouseDocumentUtil.isOldPledgeToNewPledge(paragraph,base);
                     if (StrUtil.isNotBlank(oldPledgeToNewPledge)){
                         result.append(i).append(". ").append(oldPledgeToNewPledge);
                         i++;
                     }
                 }
                 if (IS_OLD_PLEDGE_TO_OLD_PLEDGE.getCode().equals(rule)){
-                    String oldPledgeToOldPledge = HouseDocumentUtil.isOldPledgeToOldPledge(targets,paragraph);
+                    String oldPledgeToOldPledge = HouseDocumentUtil.isOldPledgeToOldPledge(paragraph,base);
                     if (StrUtil.isNotBlank(oldPledgeToOldPledge)){
                         result.append(i).append(". ").append(oldPledgeToOldPledge);
                         i++;
@@ -317,7 +315,7 @@ public class TmplHouseParagraphServiceImpl extends ServiceImpl<TmplHouseParagrap
                     }
                 }
                 if (IS_PROVIDE_TECH_REPORT.getCode().equals(rule)){
-                    String provideTechReport = HouseDocumentUtil.isProvideTechReport(targets,paragraph,base.getHasTechReport());
+                    String provideTechReport = HouseDocumentUtil.isProvideTechReport(paragraph,base.getHasTechReport());
                     if (StrUtil.isNotBlank(provideTechReport)){
                         result.append(i).append(". ").append(provideTechReport);
                         i++;
@@ -373,7 +371,7 @@ public class TmplHouseParagraphServiceImpl extends ServiceImpl<TmplHouseParagrap
     }
 
     @Override
-    public String findSpecialHandle(List<HouseGuarantyTarget> targets) {
+    public String findSpecialHandle(List<HouseGuarantyTarget> targets,HouseGuarantyBase base) {
         List<TmplHouseParagraph> paragraphTemps = this.list(new LambdaQueryWrapper<TmplHouseParagraph>()
                 .eq(TmplHouseParagraph::getDocMold, GUARANTY).eq(TmplHouseParagraph::getChapter, SPECIAL_HANDLE).orderByAsc(TmplHouseParagraph::getSort));
         StringBuilder result = new StringBuilder();
@@ -382,35 +380,35 @@ public class TmplHouseParagraphServiceImpl extends ServiceImpl<TmplHouseParagrap
             String rule = paragraph.getRule();
             if (StrUtil.isNotBlank(rule)){
                 if (IS_NO_FIRST_MONEY.getCode().equals(rule)){
-                    String noFirstMoney = HouseDocumentUtil.isNoFirstMoney(targets,paragraph);
+                    String noFirstMoney = HouseDocumentUtil.isNoFirstMoney(paragraph,base);
                     if (StrUtil.isNotBlank(noFirstMoney)){
                         result.append(i).append(". ").append(noFirstMoney);
                         i++;
                     }
                 }
                 if (IS_SAME_PLEDGE_USER_CONTINUE.getCode().equals(rule)){
-                    String samePledgeUserContinue = HouseDocumentUtil.isSamePledgeUserContinue(targets,paragraph);
+                    String samePledgeUserContinue = HouseDocumentUtil.isSamePledgeUserContinue(paragraph,base);
                     if (StrUtil.isNotBlank(samePledgeUserContinue)){
                         result.append(i).append(". ").append(samePledgeUserContinue);
                         i++;
                     }
                 }
                 if (IS_OLD_PLEDGE_TO_NEW_PLEDGE_SPECIAL.getCode().equals(rule)){
-                    String oldPledgeToNewPledgeSpecial = HouseDocumentUtil.isOldPledgeToNewPledgeSpecial(targets,paragraph);
+                    String oldPledgeToNewPledgeSpecial = HouseDocumentUtil.isOldPledgeToNewPledgeSpecial(paragraph,base);
                     if (StrUtil.isNotBlank(oldPledgeToNewPledgeSpecial)){
                         result.append(i).append(". ").append(oldPledgeToNewPledgeSpecial);
                         i++;
                     }
                 }
                 if (IS_NORMAL_PLEDGE_TO_HIGH_PLEDGE.getCode().equals(rule)){
-                    String normalPledgeToHighPledge = HouseDocumentUtil.isNormalPledgeToHighPledge(targets,paragraph);
+                    String normalPledgeToHighPledge = HouseDocumentUtil.isNormalPledgeToHighPledge(paragraph,base);
                     if (StrUtil.isNotBlank(normalPledgeToHighPledge)){
                         result.append(i).append(". ").append(normalPledgeToHighPledge);
                         i++;
                     }
                 }
                 if (IS_HIGH_PLEDGE_NOT_EXPIRE.getCode().equals(rule)){
-                    String highPledgeNotExpire = HouseDocumentUtil.isHighPledgeNotExpire(targets,paragraph);
+                    String highPledgeNotExpire = HouseDocumentUtil.isHighPledgeNotExpire(paragraph,base);
                     if (StrUtil.isNotBlank(highPledgeNotExpire)){
                         result.append(i).append(". ").append(highPledgeNotExpire);
                         i++;