Переглянути джерело

费用规则与前端联调

xuqiang 1 рік тому
батько
коміт
a075a0559e
23 змінених файлів з 608 додано та 155 видалено
  1. 6 0
      authentication/dependency-reduced-pom.xml
  2. 2 2
      commons/src/main/java/com/jzg/commons/constants/Constants.java
  3. 33 0
      commons/src/main/java/com/jzg/commons/entity/dto/CostAdd.java
  4. 56 0
      commons/src/main/java/com/jzg/commons/entity/dto/CostManagementVo.java
  5. 0 28
      commons/src/main/java/com/jzg/commons/entity/dto/CostTypeEntity.java
  6. 4 6
      commons/src/main/java/com/jzg/commons/entity/dto/PtlAgreementCostAdd.java
  7. 18 9
      commons/src/main/java/com/jzg/commons/entity/dto/PtlAgreementCostEnd.java
  8. 44 0
      commons/src/main/java/com/jzg/commons/entity/dto/PtlAgreementCostParam.java
  9. 6 2
      commons/src/main/java/com/jzg/commons/entity/po/PtlAgreementCost.java
  10. 1 1
      commons/src/main/java/com/jzg/commons/entity/po/PtlAgreementCostType.java
  11. 1 1
      commons/src/main/java/com/jzg/commons/entity/vo/AgreementRulesVo.java
  12. 21 0
      commons/src/main/java/com/jzg/commons/entity/vo/CostListVo.java
  13. 17 0
      commons/src/main/java/com/jzg/commons/entity/vo/PtlAgreementCostRuleVo.java
  14. 1 1
      commons/src/main/java/com/jzg/commons/entity/vo/PtlAgreementCostTypeVo.java
  15. 7 11
      commons/src/main/java/com/jzg/commons/entity/vo/PtlAgreementCostVo.java
  16. 75 0
      commons/src/main/java/com/jzg/commons/util/BuildDescUtils.java
  17. 1 1
      gateway/src/main/resources/application-dev.yml
  18. 11 12
      tenant/organization/src/main/java/com/jzg/organization/controller/PtlAgreementCostController.java
  19. 12 0
      tenant/organization/src/main/java/com/jzg/organization/mapper/PtlAgreementCostMapper.java
  20. 9 8
      tenant/organization/src/main/java/com/jzg/organization/service/PtlAgreementCostService.java
  21. 79 49
      tenant/organization/src/main/java/com/jzg/organization/service/impl/PtlAgreementCostServiceImpl.java
  22. 7 6
      tenant/organization/src/main/java/com/jzg/organization/service/impl/PtlAgreementUndwrtRulesServiceImpl.java
  23. 197 18
      tenant/organization/src/main/resources/mapper/PtlAgreementCostMapper.xml

+ 6 - 0
authentication/dependency-reduced-pom.xml

@@ -102,6 +102,12 @@
       <version>3.23.3</version>
       <scope>provided</scope>
     </dependency>
+    <dependency>
+      <groupId>com.alibaba.cloud</groupId>
+      <artifactId>spring-cloud-starter-alibaba-seata</artifactId>
+      <version>2022.0.0.0</version>
+      <scope>provided</scope>
+    </dependency>
     <dependency>
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter-test</artifactId>

+ 2 - 2
commons/src/main/java/com/jzg/commons/constants/Constants.java

@@ -95,12 +95,12 @@ public class Constants
     /**
      * 启用
      */
-    public static final boolean ENABLE = true;
+    public static final int ENABLE = 0;
 
     /**
      * 禁用
      */
-    public static final boolean DISABLE = false;
+    public static final int DISABLE = 1;
 
 
 }

+ 33 - 0
commons/src/main/java/com/jzg/commons/entity/dto/CostAdd.java

@@ -0,0 +1,33 @@
+package com.jzg.commons.entity.dto;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotBlank;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+@Schema(description = "协议费用管理新增")
+public class CostAdd {
+
+
+    @Schema(description = "协议ID")
+    @NotBlank(message = "协议ID不能为空")
+    private String ptlAgreementId;
+
+    @Schema(description = "险种")
+    @NotBlank(message = "险种不能为空")
+    private String productName;
+
+    @Schema(description = "险种ID")
+    @NotBlank(message = "险种ID不能为空")
+    private String productId;
+
+    @Schema(description = "承保规则ID")
+    @NotBlank(message = "承保规则ID不能为空")
+    private String coverRuleId;
+
+
+    private List<PtlAgreementCostAdd> ptlAgreementCostAddList;
+
+}

+ 56 - 0
commons/src/main/java/com/jzg/commons/entity/dto/CostManagementVo.java

@@ -0,0 +1,56 @@
+package com.jzg.commons.entity.dto;
+
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.jzg.commons.entity.vo.PtlAgreementCostRuleVo;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+@Schema(description = "费用管理")
+public class CostManagementVo {
+
+    @Schema(description = "协议ID")
+    private String ptlAgreementId;
+
+    @Schema(description = "协议代码")
+    private String agreementCode;
+
+    @Schema(description = "协议简称")
+    private String agreementAbbreviation;
+
+    @Schema(description = "0-启用 1-禁用 ")
+    private String isEnabled;
+
+    @Schema(description = "审核状态 0 申请审核 1 审核通过 2 审核不通过")
+    private String approved;
+
+    @Schema(description = "规则描述")
+    private String ruleDescription;
+
+    @Schema(description = "险种ID")
+    private String productId;
+
+    @Schema(description = "险种")
+    private String productName;
+
+    @Schema(description = "费用规则")
+    private String costRules;
+
+    @Schema(description = "生效时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private String effectiveTime;
+
+    @Schema(description = "失效时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private String failureTime;
+
+    @Schema(description = "费用主键ID")
+    private String costId;
+
+    @Schema(description = "规则条件集合")
+    private List<PtlAgreementCostRuleVo> ruleConditions;
+
+}

+ 0 - 28
commons/src/main/java/com/jzg/commons/entity/dto/CostTypeEntity.java

@@ -1,28 +0,0 @@
-package com.jzg.commons.entity.dto;
-
-import io.swagger.v3.oas.annotations.media.Schema;
-import lombok.Data;
-
-import java.math.BigDecimal;
-
-@Data
-public class CostTypeEntity {
-
-
-    @Schema(description = "费用类型1-交强险2-商业险3-驾意险")
-    private int costType;
-
-    @Schema(description = "入口比例")
-    private BigDecimal inlet;
-
-    @Schema(description = "出口比例")
-    private BigDecimal export;
-
-    @Schema(description = "手续费")
-    private BigDecimal commission;
-
-    @Schema(description = "加投比例")
-    private BigDecimal addThrow;
-
-
-}

+ 4 - 6
commons/src/main/java/com/jzg/commons/entity/dto/PtlAgreementCostAdd.java

@@ -1,6 +1,7 @@
 package com.jzg.commons.entity.dto;
 
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.v3.oas.annotations.media.Schema;
 import jakarta.validation.constraints.NotBlank;
 import jakarta.validation.constraints.NotNull;
@@ -15,11 +16,9 @@ import java.util.List;
 public class PtlAgreementCostAdd {
 
     @Schema(description = "协议ID")
-    @NotBlank(message = "协议ID不能为空")
     private String ptlAgreementId;
 
     @Schema(description = "险种")
-    @NotBlank(message = "险种不能为空")
     private String productName;
 
     @Schema(description = "险种ID")
@@ -30,10 +29,12 @@ public class PtlAgreementCostAdd {
 
     @Schema(description = "生效时间")
     @NotNull(message = "生效时间不能为空")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private Date effectiveTime;
 
     @Schema(description = "失效时间")
     @NotNull(message = "失效时间不能为空")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private Date failureTime;
 
     @Schema(description = "审核方式0-自动审核;1-手动审核")
@@ -64,9 +65,6 @@ public class PtlAgreementCostAdd {
     @Schema(description = "规则条件集合描述")
     public static class RuleConditionDto {
 
-        @Schema(description = "费用管理ID")
-        private Long ptlAgreementCostId;
-
         @Schema(description = "承包规则id")
         private String rulesId;
 
@@ -93,7 +91,7 @@ public class PtlAgreementCostAdd {
     public static class PtlAgreementCostTypeDto {
 
         @Schema(description = "费用类型1-交强险2-商业险3-驾意险")
-        private int costType;
+        private String costType;
 
         @Schema(description = "入口比例")
         private BigDecimal inlet;

+ 18 - 9
commons/src/main/java/com/jzg/commons/entity/dto/PtlAgreementCostEnd.java

@@ -1,6 +1,7 @@
 package com.jzg.commons.entity.dto;
 
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.v3.oas.annotations.media.Schema;
 import jakarta.validation.constraints.NotBlank;
 import jakarta.validation.constraints.NotNull;
@@ -34,10 +35,12 @@ public class PtlAgreementCostEnd {
 
     @Schema(description = "生效时间")
     @NotNull(message = "生效时间不能为空")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private Date effectiveTime;
 
     @Schema(description = "失效时间")
     @NotNull(message = "失效时间不能为空")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private Date failureTime;
 
     @Schema(description = "审核方式0-自动审核;1-手动审核")
@@ -68,17 +71,23 @@ public class PtlAgreementCostEnd {
     @Schema(description = "规则条件集合描述")
     public static class RuleConditionDto {
 
-        @Schema(description = "费用管理ID")
-        private String ptlAgreementCostId;
+        @Schema(description = "承包规则id")
+        private String rulesId;
 
-        @Schema(description = "规则ID")
-        private String ruleId;
+        @Schema(description = "属性id")
+        private String attrId;
 
-        @Schema(description = "运算符")
-        private String operator;
+        @Schema(description = "属性编码")
+        private String attrCode;
+
+        @Schema(description = "左操作数")
+        private String min;
 
-        @Schema(description = "值")
-        private String dataValue;
+        @Schema(description = "右操作数")
+        private String max;
+
+        @Schema(description = "操作符")
+        private String operator;
 
     }
 
@@ -87,7 +96,7 @@ public class PtlAgreementCostEnd {
     public static class PtlAgreementCostTypeDto {
 
         @Schema(description = "费用类型1-交强险2-商业险3-驾意险")
-        private int costType;
+        private String costType;
 
         @Schema(description = "入口比例")
         private BigDecimal inlet;

+ 44 - 0
commons/src/main/java/com/jzg/commons/entity/dto/PtlAgreementCostParam.java

@@ -0,0 +1,44 @@
+package com.jzg.commons.entity.dto;
+
+
+import com.jzg.commons.core.base.PageRequest;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+@Schema(description = "协议费用管理参数")
+public class PtlAgreementCostParam extends PageRequest {
+
+
+    @Schema(description = "输入代码,名称,简称查找")
+    private String agreement;
+
+    @Schema(description = "险种id")
+    private String productId;
+
+    @Schema(description = "承保规则")
+    private String rulesName;
+
+    @Schema(description = "费用规则")
+    private String costRules;
+
+    @Schema(description = "协议状态")
+    private String agreementStatus;
+
+    @Schema(description = "审核状态")
+    private String auditStatus;
+
+    @Schema(description = "有效状态")
+    private String validState;
+
+    @Schema(description = "生效时间")
+    private List<String> effectiveTime;
+
+    @Schema(description = "失效时间")
+    private List<String> failureTime;
+
+
+
+}

+ 6 - 2
commons/src/main/java/com/jzg/commons/entity/po/PtlAgreementCost.java

@@ -40,8 +40,12 @@ public class PtlAgreementCost extends BaseModel {
 
     private String reviewDescription;
 
-    private Boolean isValid;
+    private int isValid;
 
-    private Boolean isEnabled;
+    private int isEnabled;
+
+    private String reviewDescription;
+
+    private String costRules;
 
 }

+ 1 - 1
commons/src/main/java/com/jzg/commons/entity/po/PtlAgreementCostType.java

@@ -18,7 +18,7 @@ public class PtlAgreementCostType extends BaseModel {
 
     private String ptlAgreementCostId;
 
-    private int costType;
+    private String costType;
 
     private BigDecimal inlet;
 

+ 1 - 1
commons/src/main/java/com/jzg/commons/entity/vo/AgreementRulesVo.java

@@ -31,6 +31,6 @@ public class AgreementRulesVo extends BaseModel {
     private List<PtlAgreementUndwrtRulesAttr>  costsAttrLinks;
 
     @Schema(description = "费用列表")
-    private List<PtlAgreementCostVo> costVoList;
+    private List<CostListVo> costVoList;
 
 }

+ 21 - 0
commons/src/main/java/com/jzg/commons/entity/vo/CostListVo.java

@@ -0,0 +1,21 @@
+package com.jzg.commons.entity.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.util.List;
+
+
+@Data
+@Schema(description = "费用列表VO")
+public class CostListVo {
+
+    private String ids;
+
+    private String productName;
+
+    private String productId;
+
+    private List<PtlAgreementCostVo> ptlAgreementCostVoList;
+
+}

+ 17 - 0
commons/src/main/java/com/jzg/commons/entity/vo/PtlAgreementCostRuleVo.java

@@ -1,8 +1,12 @@
 package com.jzg.commons.entity.vo;
 
+import com.jzg.commons.entity.po.PtlAgreementUndwrtRulesAttr;
+import com.jzg.commons.entity.po.PtlAgreementUndwrtRulesDictLabal;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
+import java.util.List;
+
 @Schema(description = "规则条件集合")
 @Data
 public class PtlAgreementCostRuleVo{
@@ -18,6 +22,14 @@ public class PtlAgreementCostRuleVo{
 
     private String attrCode;
 
+    private String attrType;
+
+    private String attrGroup;
+
+    private String attrName;
+
+    private String dictId;
+
     private String min;
 
     private String max;
@@ -26,5 +38,10 @@ public class PtlAgreementCostRuleVo{
 
     private String batch;
 
+    private List<PtlAgreementUndwrtRulesDictLabal> dictLabal;
+
+    private List<String> minArray;
+
+    private PtlAgreementUndwrtRulesAttr rulesAttr;
 
 }

+ 1 - 1
commons/src/main/java/com/jzg/commons/entity/vo/PtlAgreementCostTypeVo.java

@@ -15,7 +15,7 @@ public class PtlAgreementCostTypeVo{
     private String ptlAgreementCostId;
 
     @Schema(description = "费用类型1-交强险2-商业险3-驾意险")
-    private int costType;
+    private String costType;
 
     @Schema(description = "入口比例")
     private BigDecimal inlet;

+ 7 - 11
commons/src/main/java/com/jzg/commons/entity/vo/PtlAgreementCostVo.java

@@ -38,11 +38,14 @@ public class PtlAgreementCostVo {
     @Schema(description = "0-未审核1-审核通过2-审核未通过")
     private int approved;
 
-    @Schema(description = "是否有效0-无效;1-有效")
-    private boolean isValid;
+    @Schema(description = "是否有效")
+    private int isValid;
 
-    @Schema(description = "是否启用0-禁用;1-启用")
-    private boolean isEnabled;
+    @Schema(description = "是否启用")
+    private int isEnabled;
+
+    @Schema(description = "费用规则")
+    private String costRules;
 
     @Schema(description = "费用描述")
     private String costDescribe;
@@ -53,11 +56,4 @@ public class PtlAgreementCostVo {
     @Schema(description = "规则条件集合")
     private List<PtlAgreementCostRuleVo> ruleConditions;
 
-
-    @Schema(description = "规则条件集合")
-    private List<String> rulesList;
-
-
-
-
 }

+ 75 - 0
commons/src/main/java/com/jzg/commons/util/BuildDescUtils.java

@@ -0,0 +1,75 @@
+package com.jzg.commons.util;
+
+import com.jzg.commons.entity.po.PtlAgreementUndwrtRulesAttr;
+import com.jzg.commons.entity.po.PtlAgreementUndwrtRulesDictLabal;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+public class BuildDescUtils {
+
+
+    public static String buildDesc(List<PtlAgreementUndwrtRulesAttr> linkList, List<PtlAgreementUndwrtRulesAttr> undwrtRulesAttrList) {
+        StringBuilder desc = new StringBuilder();
+        Map<String, PtlAgreementUndwrtRulesAttr> attrMap = undwrtRulesAttrList.stream()
+                .collect(Collectors.toMap(PtlAgreementUndwrtRulesAttr::getAttrCode, Function.identity()));
+
+        for (PtlAgreementUndwrtRulesAttr link : linkList) {
+            PtlAgreementUndwrtRulesAttr ptlAgreementUndwrtRulesAttr = attrMap.get(link.getAttrCode());
+
+            if (ptlAgreementUndwrtRulesAttr == null) {
+                continue;
+            }
+
+            String attrType = ptlAgreementUndwrtRulesAttr.getAttrType();
+
+            if ("inputNumber".equals(attrType)) {
+                desc.append(inputNumberIdentifying(ptlAgreementUndwrtRulesAttr, link)).append(",");
+            } else if ("radio".equals(attrType)) {
+                desc.append(radioIdentifying(ptlAgreementUndwrtRulesAttr, link)).append(",");
+            } else if ("checkbox".equals(attrType) || "select".equals(attrType)) {
+                desc.append(ptlAgreementUndwrtRulesAttr.getAttrName()).append("包含").append(link.getMin()).append(",");
+            } else if ("inputTag".equals(attrType)) {
+                if (link.getOperator() != null && "1".equals(link.getOperator())) {
+                    desc.append(ptlAgreementUndwrtRulesAttr.getAttrName()).append("包含").append(link.getMin()).append(",");
+                } else {
+                    desc.append(ptlAgreementUndwrtRulesAttr.getAttrName()).append("不包含").append(link.getMin()).append(",");
+                }
+            }
+        }
+        return desc.toString();
+    }
+
+    private static String radioIdentifying(PtlAgreementUndwrtRulesAttr ptlAgreementUndwrtRulesAttr, PtlAgreementUndwrtRulesAttr link) {
+        Optional<PtlAgreementUndwrtRulesDictLabal> dictLabel = Optional.ofNullable(
+                        ptlAgreementUndwrtRulesAttr.getDictLabal())
+                .flatMap(list -> list.stream().filter(x -> x.getCode().equals(link.getMin())).findFirst());
+
+        return dictLabel.map(dl -> ptlAgreementUndwrtRulesAttr.getAttrName() + "为" + dl.getName())
+                .orElse("");
+    }
+
+    private static String inputNumberIdentifying(PtlAgreementUndwrtRulesAttr ptlAgreementUndwrtRulesAttr, PtlAgreementUndwrtRulesAttr link) {
+        String operator = link.getOperator();
+        switch (operator) {
+            case "1":
+                return ptlAgreementUndwrtRulesAttr.getAttrName() + "范围值" + link.getMin() + "到" + link.getMax();
+            case "2":
+                return ptlAgreementUndwrtRulesAttr.getAttrName() + "小于" + link.getMin();
+            case "3":
+                return ptlAgreementUndwrtRulesAttr.getAttrName() + "小于等于" + link.getMin();
+            case "4":
+                return ptlAgreementUndwrtRulesAttr.getAttrName() + "大于" + link.getMax();
+            case "5":
+                return ptlAgreementUndwrtRulesAttr.getAttrName() + "大于等于" + link.getMax();
+            default:
+                return ptlAgreementUndwrtRulesAttr.getAttrName() + "未知操作符";
+        }
+    }
+
+
+
+}

+ 1 - 1
gateway/src/main/resources/application-dev.yml

@@ -28,6 +28,6 @@ spring:
         - id: tenant_route
           uri: http://localhost:8084/
           predicates:
-            - Path=/tenant/**,/dept/**,/area/**,/dict/**,/userInfo/**,/sysOrganization/**,/activity/**,/message/**,/messageNotice/**,/poster/**,/agreement/**,/pltAgreement/**,/agreementRules/**,/plt/areaLicense/**
+            - Path=/tenant/**,/dept/**,/area/**,/dict/**,/userInfo/**,/sysOrganization/**,/activity/**,/message/**,/messageNotice/**,/poster/**,/agreement/**,/pltAgreement/**,/agreementRules/**,/plt/areaLicense/**,/ptlAgreementCost/**
 
 

+ 11 - 12
tenant/organization/src/main/java/com/jzg/organization/controller/PtlAgreementCostController.java

@@ -2,9 +2,7 @@ package com.jzg.organization.controller;
 
 
 import com.jzg.commons.core.page.HttpResult;
-import com.jzg.commons.entity.dto.CostAgreementParam;
-import com.jzg.commons.entity.dto.PtlAgreementCostAdd;
-import com.jzg.commons.entity.dto.PtlAgreementCostEnd;
+import com.jzg.commons.entity.dto.*;
 import com.jzg.commons.request.RequestSingleParam;
 import com.jzg.organization.service.PtlAgreementCostService;
 import io.swagger.v3.oas.annotations.Operation;
@@ -12,6 +10,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
 import jakarta.validation.Valid;
 import jakarta.validation.constraints.NotEmpty;
 import jakarta.validation.constraints.NotNull;
+import org.ehcache.shadow.org.terracotta.offheapstore.paging.Page;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
@@ -29,14 +28,14 @@ public class PtlAgreementCostController {
 
     @Operation(summary = "协议费用管理新增")
     @PostMapping("save")
-    public HttpResult add(@RequestBody @Valid List<PtlAgreementCostAdd> costAddList){
+    public HttpResult add(@RequestBody @Valid List<CostAdd> costAddList){
         return ptlAgreementCostService.save(costAddList);
     }
 
 
     @Operation(summary = "协议费用管理修改")
     @PostMapping("update")
-    public HttpResult update(@RequestBody @Valid List<PtlAgreementCostEnd> costEndList){
+    public HttpResult update(@RequestBody @Valid PtlAgreementCostEnd costEndList){
         return ptlAgreementCostService.update(costEndList);
     }
 
@@ -62,8 +61,8 @@ public class PtlAgreementCostController {
 
     @Operation(summary = "通过协议ID与规则ID查询")
     @PostMapping("queryByAgreementId")
-    public HttpResult queryByAgreementId(@RequestBody CostAgreementParam costAgreementParam){
-        return HttpResult.ok(ptlAgreementCostService.queryByAgreementId(costAgreementParam));
+    public HttpResult queryByAgreementIdAndCoverRuleId(@RequestBody CostAgreementParam costAgreementParam){
+        return HttpResult.ok(ptlAgreementCostService.queryByAgreementIdAndCoverRuleId(costAgreementParam));
     }
 
     @Operation(summary = "协议费用管理审核成功")
@@ -79,10 +78,10 @@ public class PtlAgreementCostController {
     }
 
 
-//    @Schema(description = "协议费用管理分页列表")
-//    @PostMapping("pageList")
-//    public HttpResult pageList(@Validated PtlAgreementCostAdd ptlAgreementCostAdd){
-//        return ptlAgreementCostService.pageList(ptlAgreementCostAdd);
-//    }
+    @Operation(summary = "费用管理分页列表")
+    @PostMapping("pageList")
+    public HttpResult<CostManagementVo> pageList(@RequestBody PtlAgreementCostParam costParam){
+        return ptlAgreementCostService.pageList(costParam);
+    }
 
 }

+ 12 - 0
tenant/organization/src/main/java/com/jzg/organization/mapper/PtlAgreementCostMapper.java

@@ -1,8 +1,13 @@
 package com.jzg.organization.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.jzg.commons.entity.dto.CostAgreementParam;
+import com.jzg.commons.entity.dto.CostManagementVo;
+import com.jzg.commons.entity.dto.PtlAgreementCostParam;
 import com.jzg.commons.entity.po.PtlAgreementCost;
+import com.jzg.commons.entity.vo.CostListVo;
+import com.jzg.commons.entity.vo.PtlAgreementCostTypeVo;
 import com.jzg.commons.entity.vo.PtlAgreementCostVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -16,4 +21,11 @@ public interface PtlAgreementCostMapper extends BaseMapper<PtlAgreementCost> {
 
     List<PtlAgreementCostVo> queryByAgreementId(CostAgreementParam costAgreementParam);
 
+    List<CostListVo> queryByAgreementIdAndCoverRuleId(CostAgreementParam costAgreementParam);
+
+
+    Page<CostManagementVo> pageList(Page page,@Param("costParam") PtlAgreementCostParam costParam);
+
+
+
 }

+ 9 - 8
tenant/organization/src/main/java/com/jzg/organization/service/PtlAgreementCostService.java

@@ -2,36 +2,37 @@ package com.jzg.organization.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.jzg.commons.core.page.HttpResult;
+import com.jzg.commons.entity.dto.CostAdd;
 import com.jzg.commons.entity.dto.CostAgreementParam;
-import com.jzg.commons.entity.dto.PtlAgreementCostAdd;
 import com.jzg.commons.entity.dto.PtlAgreementCostEnd;
+import com.jzg.commons.entity.dto.PtlAgreementCostParam;
 import com.jzg.commons.entity.po.PtlAgreementCost;
-import com.jzg.commons.entity.vo.PtlAgreementCostVo;
+import com.jzg.commons.entity.vo.CostListVo;
 import jakarta.validation.constraints.NotNull;
-
 import java.util.List;
-import java.util.Map;
 
 public interface PtlAgreementCostService extends IService<PtlAgreementCost> {
 
-    HttpResult save(List<PtlAgreementCostAdd> costAddList);
+    HttpResult save(List<CostAdd> costAddList);
 
 
-    HttpResult update(List<PtlAgreementCostEnd> costEndList);
+    HttpResult update(PtlAgreementCostEnd costEndList);
 
 
     HttpResult queryById(@NotNull(message = "id不能为空") Long id);
 
-    List<PtlAgreementCostVo> queryByAgreementId(CostAgreementParam costAgreementParam);
+    List<CostListVo> queryByAgreementIdAndCoverRuleId(CostAgreementParam costAgreementParam);
 
     HttpResult enableDisableByIds(List<String> ids,Boolean isEnabled);
 
-
     void updateAuditMethod(List<Long> ids);
 
     boolean auditSuccess(List<String> ids);
 
     boolean auditFailed(List<String> ids,String reason);
 
+    HttpResult pageList(PtlAgreementCostParam costParam);
+
+
 
 }

+ 79 - 49
tenant/organization/src/main/java/com/jzg/organization/service/impl/PtlAgreementCostServiceImpl.java

@@ -8,21 +8,21 @@ import com.jzg.commons.constants.Constants;
 import com.jzg.commons.constants.ReturnInformation;
 import com.jzg.commons.core.base.StateResult;
 import com.jzg.commons.core.page.HttpResult;
-import com.jzg.commons.entity.dto.CostAgreementParam;
-import com.jzg.commons.entity.dto.PtlAgreementCostAdd;
-import com.jzg.commons.entity.dto.PtlAgreementCostEnd;
-import com.jzg.commons.entity.po.PtlAgreementCost;
-import com.jzg.commons.entity.po.PtlAgreementCostRule;
-import com.jzg.commons.entity.po.PtlAgreementCostType;
-import com.jzg.commons.entity.po.RuleConditionsVerify;
+import com.jzg.commons.entity.dto.*;
+import com.jzg.commons.entity.po.*;
+import com.jzg.commons.entity.vo.CostListVo;
 import com.jzg.commons.entity.vo.PtlAgreementCostRuleVo;
+import com.jzg.commons.entity.vo.PtlAgreementCostTypeVo;
 import com.jzg.commons.entity.vo.PtlAgreementCostVo;
+import com.jzg.commons.util.BuildDescUtils;
 import com.jzg.commons.exception.SystemException;
 import com.jzg.commons.util.ListUtils;
+import com.jzg.commons.util.StringUtils;
 import com.jzg.organization.mapper.PtlAgreementCostMapper;
 import com.jzg.organization.service.PtlAgreementCostRuleService;
 import com.jzg.organization.service.PtlAgreementCostService;
 import com.jzg.organization.service.PtlAgreementCostTypeService;
+import com.jzg.organization.service.PtlAgreementUndwrtRulesAttrService;
 import com.jzg.organization.state.CostState;
 import com.jzg.organization.state.UserState;
 import com.jzg.organization.state.listener.CostStateListener;
@@ -34,6 +34,8 @@ import org.springframework.statemachine.StateMachine;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
+
+import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -52,6 +54,10 @@ public class PtlAgreementCostServiceImpl extends ServiceImpl<PtlAgreementCostMap
     @Resource
     private PtlAgreementCostMapper ptlAgreementCostMapper;
 
+    @Resource
+    private PtlAgreementUndwrtRulesAttrService agreementUndwrtRulesAttrService;
+
+
 
 
     @Autowired
@@ -63,54 +69,60 @@ public class PtlAgreementCostServiceImpl extends ServiceImpl<PtlAgreementCostMap
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public HttpResult save(List<PtlAgreementCostAdd> costAddList) {
+    public HttpResult save(List<CostAdd> costAddList) {
         if (costAddList.isEmpty()) {
             return HttpResult.error("保存数据不能为空");
         }
-        for (PtlAgreementCostAdd ptlAgreementCostAdd : costAddList){
-            if (ListUtils.hasDuplicates(ptlAgreementCostAdd.getRuleConditions())){
-                return HttpResult.error("存在相同费用规则,请检查");
-            }
-            boolean verify = verify(ptlAgreementCostAdd);
-            if (verify){
-                return HttpResult.error("已存在相同且有效的费用规则,请检查");
-            }
-            PtlAgreementCost ptlAgreementCost = BeanUtil.copyProperties(ptlAgreementCostAdd, PtlAgreementCost.class);
-            ptlAgreementCost.setIsEnabled(Constants.ENABLE);
-            ptlAgreementCost.setIsValid(Constants.ENABLE);
-            if (baseMapper.insert(ptlAgreementCost) <= 0) {
-                log.error("插入操作失败");
-                throw new RuntimeException(ReturnInformation.FAILURE_MESSAGE);
-            }
-            if (!CollectionUtils.isEmpty(ptlAgreementCostAdd.getPtlAgreementCostTypeList())) {
-                costTypeService.saveOrUpdateCostType(BeanUtil.copyToList(ptlAgreementCostAdd.getPtlAgreementCostTypeList(), PtlAgreementCostType.class), ptlAgreementCost.getId());
-            }
-            if (!CollectionUtils.isEmpty(ptlAgreementCostAdd.getRuleConditions())) {
-                costRuleService.saveOrUpdateCostRule(BeanUtil.copyToList(ptlAgreementCostAdd.getRuleConditions(), PtlAgreementCostRule.class), ptlAgreementCost.getId());
+        List<PtlAgreementUndwrtRulesAttr> undwrtRulesAttrList = agreementUndwrtRulesAttrService.getUndwrtRulesAttrList();
+        for (CostAdd costAdd : costAddList) {
+            for (PtlAgreementCostAdd ptlAgreementCostAdd : costAdd.getPtlAgreementCostAddList()){
+                if (ListUtils.hasDuplicates(ptlAgreementCostAdd.getRuleConditions())){
+                    return HttpResult.error("存在相同费用规则,请检查");
+                }
+                ptlAgreementCostAdd.setPtlAgreementId(costAdd.getPtlAgreementId());
+                ptlAgreementCostAdd.setProductId(costAdd.getProductId());
+                ptlAgreementCostAdd.setProductName(costAdd.getProductName());
+                ptlAgreementCostAdd.setCoverRuleId(costAdd.getCoverRuleId());
+                boolean verify = verify(ptlAgreementCostAdd);
+                if (verify){
+                    return HttpResult.error("已存在相同且有效的费用规则,请检查");
+                }
+                PtlAgreementCost ptlAgreementCost = BeanUtil.copyProperties(ptlAgreementCostAdd, PtlAgreementCost.class);
+                ptlAgreementCost.setCostRules(BuildDescUtils.buildDesc(BeanUtil.copyToList(ptlAgreementCostAdd.getRuleConditions(), PtlAgreementUndwrtRulesAttr.class), undwrtRulesAttrList));
+                if (baseMapper.insert(ptlAgreementCost) <= 0) {
+                    log.error("插入操作失败");
+                    throw new RuntimeException(ReturnInformation.FAILURE_MESSAGE);
+                }
+                if (!CollectionUtils.isEmpty(ptlAgreementCostAdd.getPtlAgreementCostTypeList())) {
+                    costTypeService.saveOrUpdateCostType(BeanUtil.copyToList(ptlAgreementCostAdd.getPtlAgreementCostTypeList(), PtlAgreementCostType.class), ptlAgreementCost.getId());
+                }
+                if (!CollectionUtils.isEmpty(ptlAgreementCostAdd.getRuleConditions())) {
+                    costRuleService.saveOrUpdateCostRule(BeanUtil.copyToList(ptlAgreementCostAdd.getRuleConditions(), PtlAgreementCostRule.class), ptlAgreementCost.getId());
+                }
+                log.info("保存成功");
             }
-            log.info("保存成功");
         }
         return HttpResult.ok(ReturnInformation.SUCCESS_MESSAGE);
     }
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public HttpResult update(List<PtlAgreementCostEnd> costEndList) {
-        for (PtlAgreementCostEnd ptlAgreementCostEnd : costEndList) {
-            if (ListUtils.hasDuplicates(ptlAgreementCostEnd.getRuleConditions())){
-                return HttpResult.error("已存在相同且有效的费用规则,请检查");
-            }
-            PtlAgreementCost ptlAgreementCost = BeanUtil.copyProperties(ptlAgreementCostEnd, PtlAgreementCost.class);
-            if (baseMapper.updateById(ptlAgreementCost) <= 0) {
-                throw new RuntimeException(ReturnInformation.UPDATE_FAILED);
-            }
-            if (!CollectionUtils.isEmpty(ptlAgreementCostEnd.getPtlAgreementCostTypeList())) {
-                costTypeService.saveOrUpdateCostType(BeanUtil.copyToList(ptlAgreementCostEnd.getPtlAgreementCostTypeList(), PtlAgreementCostType.class), ptlAgreementCost.getId());
-            }
-            if (!CollectionUtils.isEmpty(ptlAgreementCostEnd.getRuleConditions())) {
-                costRuleService.saveOrUpdateCostRule(BeanUtil.copyToList(ptlAgreementCostEnd.getRuleConditions(), PtlAgreementCostRule.class), ptlAgreementCost.getId());
-            }
+    public HttpResult update(PtlAgreementCostEnd ptlAgreementCostEnd) {
+
+//        if (ListUtils.hasDuplicates(ptlAgreementCostEnd.getRuleConditions())){
+//            return HttpResult.error("已存在相同且有效的费用规则,请检查");
+//        }
+        PtlAgreementCost ptlAgreementCost = BeanUtil.copyProperties(ptlAgreementCostEnd, PtlAgreementCost.class);
+        if (baseMapper.updateById(ptlAgreementCost) <= 0) {
+            throw new RuntimeException(ReturnInformation.UPDATE_FAILED);
+        }
+        if (!CollectionUtils.isEmpty(ptlAgreementCostEnd.getPtlAgreementCostTypeList())) {
+            costTypeService.saveOrUpdateCostType(BeanUtil.copyToList(ptlAgreementCostEnd.getPtlAgreementCostTypeList(), PtlAgreementCostType.class), ptlAgreementCost.getId());
+        }
+        if (!CollectionUtils.isEmpty(ptlAgreementCostEnd.getRuleConditions())) {
+            costRuleService.saveOrUpdateCostRule(BeanUtil.copyToList(ptlAgreementCostEnd.getRuleConditions(), PtlAgreementCostRule.class), ptlAgreementCost.getId());
         }
+
         return HttpResult.ok(ReturnInformation.UPDATE_SUCCESS);
     }
 
@@ -123,7 +135,7 @@ public class PtlAgreementCostServiceImpl extends ServiceImpl<PtlAgreementCostMap
             return false;
         }
         // 先比较规则是否相同
-        Map<String, List<PtlAgreementCostVo>> listMap = voList.stream().filter(v -> v.isEnabled() && v.isValid()).collect(Collectors.groupingBy(PtlAgreementCostVo::getProductId));
+        Map<String, List<PtlAgreementCostVo>> listMap = voList.stream().filter(v -> Constants.ENABLE == v.getIsEnabled() && Constants.NOT_DELETED == v.getIsValid()).collect(Collectors.groupingBy(PtlAgreementCostVo::getProductId));
         List<PtlAgreementCostVo> ptlAgreementCostVos = listMap.get(ptlAgreementCostAdd.getProductId());
         if (CollectionUtils.isEmpty(ptlAgreementCostVos)){
             return false;
@@ -144,23 +156,36 @@ public class PtlAgreementCostServiceImpl extends ServiceImpl<PtlAgreementCostMap
     @Override
     public HttpResult queryById(Long id) {
         PtlAgreementCostVo ptlAgreementCostVo = ptlAgreementCostMapper.queryById(id);
-        ptlAgreementCostVo.setRulesList(ptlAgreementCostVo.getRuleConditions().stream().map(PtlAgreementCostRuleVo::getAttrId).collect(Collectors.toList()));
+        if (ObjectUtil.isEmpty(ptlAgreementCostVo)){
+            return HttpResult.ok(ptlAgreementCostVo);
+        }
+        for (PtlAgreementCostRuleVo ruleCondition : ptlAgreementCostVo.getRuleConditions()) {
+            if (StringUtils.isNotEmpty(ruleCondition.getMin()) && ruleCondition.getMin().contains(",")){
+                ruleCondition.setMinArray(Arrays.asList(ruleCondition.getMin().split(",")));
+            }
+        }
         return HttpResult.ok(ptlAgreementCostVo);
     }
 
     @Override
-    public List<PtlAgreementCostVo> queryByAgreementId(CostAgreementParam costAgreementParam) {
+    public List<CostListVo> queryByAgreementIdAndCoverRuleId(CostAgreementParam costAgreementParam) {
+        return ptlAgreementCostMapper.queryByAgreementIdAndCoverRuleId(costAgreementParam);
+    }
+
+
+    private List<PtlAgreementCostVo> queryByAgreementId(CostAgreementParam costAgreementParam){
         return ptlAgreementCostMapper.queryByAgreementId(costAgreementParam);
     }
 
+
     @Override
     public HttpResult enableDisableByIds(List<String> ids,Boolean isEnabled) {
         if (CollectionUtils.isEmpty(ids)){
             return HttpResult.error("参数不能为空");
         }
         PtlAgreementCost ptlAgreementCost = new PtlAgreementCost();
-        ptlAgreementCost.setIsEnabled(isEnabled);
-        ptlAgreementCost.setIsValid(isEnabled);
+        ptlAgreementCost.setIsEnabled(isEnabled ? 0 : 1);
+        ptlAgreementCost.setIsValid(isEnabled ? 0 : 1);
         return baseMapper.update(ptlAgreementCost,new LambdaQueryWrapper<>(PtlAgreementCost.class)
                 .in(PtlAgreementCost::getId,ids)) > 0 ?
                 HttpResult.ok(isEnabled ? "启用成功" : "禁用成功") : HttpResult.error(isEnabled ? "启用失败" : "禁用失败");
@@ -224,5 +249,10 @@ public class PtlAgreementCostServiceImpl extends ServiceImpl<PtlAgreementCostMap
         return true;
     }
 
+    @Override
+    public HttpResult pageList(PtlAgreementCostParam costParam) {
+        return HttpResult.ok(baseMapper.pageList(costParam.getPage(),costParam));
+    }
+
 
 }

+ 7 - 6
tenant/organization/src/main/java/com/jzg/organization/service/impl/PtlAgreementUndwrtRulesServiceImpl.java

@@ -11,6 +11,7 @@ import com.jzg.commons.entity.po.PtlAgreementUndwrtRulesAttr;
 import com.jzg.commons.entity.po.PtlAgreementUndwrtRulesAttrLink;
 import com.jzg.commons.entity.po.PtlAgreementUndwrtRulesDictLabal;
 import com.jzg.commons.entity.vo.AgreementRulesVo;
+import com.jzg.commons.entity.vo.CostListVo;
 import com.jzg.commons.entity.vo.PtlAgreementCostVo;
 import com.jzg.organization.mapper.PtlAgreementUndwrtRulesAttrLinkMapper;
 import com.jzg.organization.mapper.PtlAgreementUndwrtRulesAttrMapper;
@@ -60,7 +61,7 @@ public class PtlAgreementUndwrtRulesServiceImpl extends ServiceImpl<PtlAgreement
                 CostAgreementParam param = new CostAgreementParam();
                 param.setPtlAgreementId(agreementId);
                 param.setCoverRuleId(rulesVo.getId());
-                List<PtlAgreementCostVo> costVos = ptlAgreementCostService.queryByAgreementId(param);
+                List<CostListVo> costVos = ptlAgreementCostService.queryByAgreementIdAndCoverRuleId(param);
                 if(CollUtil.isNotEmpty(costVos)){
                     rulesVo.setCostVoList(costVos);
                 }
@@ -201,19 +202,19 @@ public class PtlAgreementUndwrtRulesServiceImpl extends ServiceImpl<PtlAgreement
             //数值范围判断
 
             if ("inputNumber".equals(ptlAgreementUndwrtRulesAttr.getAttrType())) {
-                desc.append(inputNumberIdentifying(ptlAgreementUndwrtRulesAttr, linkList.get(i))).append("\n");
+                desc.append(inputNumberIdentifying(ptlAgreementUndwrtRulesAttr, linkList.get(i))).append("");
             }
             if ("radio".equals(ptlAgreementUndwrtRulesAttr.getAttrType())) {
-                desc.append(radioIdentifying(ptlAgreementUndwrtRulesAttr, linkList.get(i))).append("\n");
+                desc.append(radioIdentifying(ptlAgreementUndwrtRulesAttr, linkList.get(i))).append("");
             }
             if ("checkbox".equals(ptlAgreementUndwrtRulesAttr.getAttrType()) || "select".equals(ptlAgreementUndwrtRulesAttr.getAttrType())) {
-                desc.append(ptlAgreementUndwrtRulesAttr.getAttrName()).append("包含").append(linkList.get(i).getMin()).append("\n");
+                desc.append(ptlAgreementUndwrtRulesAttr.getAttrName()).append("包含").append(linkList.get(i).getMin()).append("");
             }
             if ("inputTag".equals(ptlAgreementUndwrtRulesAttr.getAttrType())) {
                 if (linkList.get(i).getOperator() != null && linkList.get(i).getOperator().equals("1")) {
-                    desc.append(ptlAgreementUndwrtRulesAttr.getAttrName()).append("包含").append(linkList.get(i).getMin()).append("\n");
+                    desc.append(ptlAgreementUndwrtRulesAttr.getAttrName()).append("包含").append(linkList.get(i).getMin()).append("");
                 } else {
-                    desc.append(ptlAgreementUndwrtRulesAttr.getAttrName()).append("不包含").append(linkList.get(i).getMin()).append("\n");
+                    desc.append(ptlAgreementUndwrtRulesAttr.getAttrName()).append("不包含").append(linkList.get(i).getMin()).append("");
                 }
             }
         }

+ 197 - 18
tenant/organization/src/main/resources/mapper/PtlAgreementCostMapper.xml

@@ -20,10 +20,35 @@
         <collection property="ruleConditions" column="{costId=id}" ofType="com.jzg.commons.entity.vo.PtlAgreementCostRuleVo" select="selectCostRule" />
     </resultMap>
 
+    <resultMap id="RulesDictLabalMap" type="com.jzg.commons.entity.po.PtlAgreementUndwrtRulesDictLabal">
+        <id column="id" property="id" jdbcType="BIGINT"/>
+        <result column="dict_id" property="dictId" jdbcType="INTEGER"/>
+        <result column="name" property="name" jdbcType="VARCHAR"/>
+        <result column="code" property="code" jdbcType="VARCHAR"/>
+        <result column="sort" property="sort" jdbcType="VARCHAR"/>
+    </resultMap>
+
+    <resultMap id="CostResultMap" type="com.jzg.commons.entity.vo.PtlAgreementCostVo">
+        <id column="id" property="id" jdbcType="BIGINT"/>
+        <result column="ptl_agreement_id" property="ptlAgreementId" jdbcType="VARCHAR"/>
+        <result column="product_name" property="productName" jdbcType="VARCHAR"/>
+        <result column="product_id" property="productId" jdbcType="VARCHAR"/>
+        <result column="effective_time" property="effectiveTime" jdbcType="TIMESTAMP"/>
+        <result column="failure_time" property="failureTime" jdbcType="TIMESTAMP"/>
+        <result column="audit_method" property="auditMethod" jdbcType="VARCHAR"/>
+        <result column="cost_describe" property="costDescribe" jdbcType="VARCHAR"/>
+        <result column="cost_rules" property="costRules" jdbcType="VARCHAR"/>
+        <result column="approved" property="approved" jdbcType="VARCHAR"/>
+        <result column="is_valid" property="isValid" jdbcType="VARCHAR"/>
+        <result column="is_enabled" property="isEnabled" jdbcType="VARCHAR"/>
+        <collection property="ptlAgreementCostTypeList" column="{costId=id}" ofType="com.jzg.commons.entity.vo.PtlAgreementCostTypeVo" select="selectCostType" />
+    </resultMap>
+
+
     <resultMap id="costType" type="com.jzg.commons.entity.vo.PtlAgreementCostTypeVo">
         <id column="id" property="id" jdbcType="BIGINT"/>
         <result column="ptl_agreement_cost_id" property="ptlAgreementCostId" jdbcType="INTEGER"/>
-        <result column="cost_type" property="costType" jdbcType="INTEGER"/>
+        <result column="cost_type" property="costType" jdbcType="VARCHAR"/>
         <result column="inlet" property="inlet" jdbcType="DECIMAL"/>
         <result column="export" property="export" jdbcType="DECIMAL"/>
         <result column="commission" property="commission" jdbcType="DECIMAL"/>
@@ -34,16 +59,86 @@
     <resultMap id="costRule" type="com.jzg.commons.entity.vo.PtlAgreementCostRuleVo">
         <id column="id" property="id" jdbcType="BIGINT"/>
         <result column="ptl_agreement_cost_id" property="ptlAgreementCostId" jdbcType="INTEGER"/>
-        <result column="rules_id" property="rulesId" jdbcType="INTEGER"/>
-        <result column="attr_Id" property="attrId" jdbcType="INTEGER"/>
-        <result column="attr_code" property="attrCode" jdbcType="INTEGER"/>
-        <result column="min" property="min" jdbcType="INTEGER"/>
-        <result column="max" property="max" jdbcType="INTEGER"/>
-        <result column="operator" property="operator" jdbcType="INTEGER"/>
-        <result column="batch" property="batch" jdbcType="INTEGER"/>
+        <result column="rules_id" property="rulesId" jdbcType="VARCHAR"/>
+        <result column="attr_Id" property="attrId" jdbcType="VARCHAR"/>
+        <result column="attr_code" property="attrCode" jdbcType="VARCHAR"/>
+        <result column="attr_type" property="attrType" jdbcType="VARCHAR"/>
+        <result column="attr_group" property="attrGroup" jdbcType="VARCHAR"/>
+        <result column="attr_name" property="attrName" jdbcType="VARCHAR"/>
+        <result column="dict_id" property="dictId" jdbcType="VARCHAR"/>
+        <result column="min" property="min" jdbcType="VARCHAR"/>
+        <result column="max" property="max" jdbcType="VARCHAR"/>
+        <result column="operator" property="operator" jdbcType="VARCHAR"/>
+        <result column="batch" property="batch" jdbcType="VARCHAR"/>
+        <collection property="dictLabal" column="{dictId = dict_id}" ofType="com.jzg.commons.entity.po.PtlAgreementUndwrtRulesDictLabal" select="selectDictLabal"/>
     </resultMap>
 
 
+
+    <resultMap id="CostListMap" type="com.jzg.commons.entity.vo.CostListVo">
+        <result column="ids" property="ids" jdbcType="VARCHAR"/>
+        <result column="product_name" property="productName" jdbcType="VARCHAR"/>
+        <result column="product_id" property="productId" jdbcType="VARCHAR"/>
+        <collection property="ptlAgreementCostVoList" column="{costId = ids}" ofType="com.jzg.commons.entity.vo.PtlAgreementCostVo" select="selectCostById" />
+    </resultMap>
+
+
+    <resultMap id="CostManagementVoMap" type="com.jzg.commons.entity.dto.CostManagementVo">
+        <result column="ptlAgreementId" property="ptlAgreementId" jdbcType="VARCHAR"/>
+        <result column="agreement_code" property="agreementCode" jdbcType="VARCHAR"/>
+        <result column="agreement_abbreviation" property="agreementAbbreviation" jdbcType="VARCHAR"/>
+        <result column="is_enabled" property="isEnabled" jdbcType="VARCHAR"/>
+        <result column="approved" property="approved" jdbcType="VARCHAR"/>
+        <result column="rule_description" property="ruleDescription" jdbcType="VARCHAR"/>
+        <result column="product_id" property="productId" jdbcType="VARCHAR"/>
+        <result column="product_name" property="productName" jdbcType="VARCHAR"/>
+        <result column="cost_rules" property="costRules" jdbcType="VARCHAR"/>
+        <result column="effective_time" property="effectiveTime" jdbcType="VARCHAR"/>
+        <result column="failure_time" property="failureTime" jdbcType="VARCHAR"/>
+        <result column="costId" property="costId" jdbcType="VARCHAR"/>
+        <collection property="ruleConditions" column="{costId=costId}" ofType="com.jzg.commons.entity.vo.PtlAgreementCostTypeVo" select="selectCostType" />
+     </resultMap>
+
+
+    <select id="queryByAgreementIdAndCoverRuleId" resultMap="CostListMap">
+        SELECT
+        c.product_name,
+        c.product_id,
+        GROUP_CONCAT(c.id) as ids
+        FROM
+        ptl_agreement_cost c
+        <where>
+            c.is_delete = 0
+            <if test="ptlAgreementId != null">
+                AND c.ptl_agreement_id = #{ptlAgreementId}
+            </if>
+            <if test="coverRuleId != null">
+                AND c.cover_rule_id = #{coverRuleId}
+            </if>
+        </where>
+        GROUP BY c.product_id, c.product_name
+    </select>
+
+    <select id="selectCostById"  resultMap="CostResultMap">
+        SELECT
+            t.id,
+            t.ptl_agreement_id,
+            t.product_name,
+            t.product_id,
+            t.effective_time,
+            t.failure_time,
+            t.audit_method,
+            t.cost_rules,
+            t.cost_describe,
+            t.approved,
+            t.is_valid,
+            t.is_enabled
+        FROM
+            ptl_agreement_cost t
+        WHERE t.id IN (${costId})
+    </select>
+
+
     <select id="queryById" resultMap="BaseResultMap">
         SELECT
             t.id,
@@ -104,19 +199,103 @@
 
 
     <select id="selectCostRule" resultMap="costRule">
-        select tr.id ,tr.ptl_agreement_cost_id,tr.rules_id,tr.attr_id,tr.attr_code,tr.min,tr.max,tr.operator,tr.batch
-        from ptl_agreement_cost_rule tr where tr.ptl_agreement_cost_id = #{costId}
+        SELECT
+            tr.id,
+            tr.ptl_agreement_cost_id,
+            tr.rules_id,
+            tr.attr_id,
+            tr.attr_code,
+            tr.min,
+            tr.max,
+            tr.operator,
+            tr.batch,
+            a.attr_name,
+            a.attr_type,
+            a.attr_group,
+            a.dict_id
+        FROM
+            ptl_agreement_cost_rule tr
+            left join ptl_agreement_undwrt_rules_attr a on tr.attr_code = a.attr_code
+        WHERE
+            tr.ptl_agreement_cost_id = #{costId}
     </select>
 
     <select id="selectCostType" resultMap="costType">
-            select   tt.id ,
-                     tt.ptl_agreement_cost_id,
-                     tt.cost_type,
-                     tt.inlet,
-                     tt.export,
-                     tt.commission,
-                     tt.add_throw
-            from ptl_agreement_cost_type tt where tt.ptl_agreement_cost_id = #{costId}
+        SELECT
+            tt.id,
+            tt.ptl_agreement_cost_id,
+            tt.cost_type,
+            tt.inlet,
+            tt.export,
+            tt.commission,
+            tt.add_throw
+        FROM
+            ptl_agreement_cost_type tt
+        WHERE
+            tt.ptl_agreement_cost_id = #{costId}
+    </select>
+
+
+    <select id="selectDictLabal" resultMap="RulesDictLabalMap">
+        <if test="dictId != null and dictId != ''">
+            select * from  ptl_agreement_undwrt_rules_dict_labal where dict_id = #{dictId}
+        </if>
+    </select>
+
+
+    <select id="pageList" resultMap="CostManagementVoMap">
+        SELECT
+            pc.product_id,
+            pc.product_name,
+            pc.cost_rules,
+            pc.effective_time,
+            pc.failure_time,
+            pc.id costId,
+            pc.ptl_agreement_id,
+            pc.cover_rule_id,
+            pc.approved,
+            pc.is_enabled,
+            pa.agreement_code,
+            pa.agreement_title,
+            pa.agreement_abbreviation,
+            pa.id as ptlAgreementId,
+            pr.rule_description
+        FROM
+            ptl_agreement_cost pc
+                LEFT JOIN ptl_agreement pa ON pa.id = pc.ptl_agreement_id
+                LEFT JOIN ptl_agreement_undwrt_rules pr ON pr.id = pc.cover_rule_id AND pr.agreement_id = pc.ptl_agreement_id
+        <where>
+            pc.is_delete = 0 and pa.is_delete = 0 and pr.is_delete = 0
+            <if test="costParam.agreement != null and costParam.agreement != ''">
+                AND (pa.agreement_title  like concat('%',#{costParam.agreement},'%') or
+                     pa.agreement_code  like concat('%',#{costParam.agreement},'%') or
+                     pa.agreement_abbreviation  like concat('%',#{costParam.agreement},'%'))
+            </if>
+            <if test="costParam.productId != null and costParam.productId != ''">
+                AND pc.product_id = #{costParam.productId}
+            </if>
+            <if test="costParam.rulesName != null and costParam.rulesName != ''">
+                AND pr.rule_description  like concat('%',#{costParam.rulesName},'%')
+            </if>
+            <if test="costParam.costRules != null and costParam.costRules != ''">
+                AND pc.cost_rules  like concat('%',#{costParam.costRules},'%')
+            </if>
+            <if test="costParam.agreementStatus != null and costParam.agreementStatus != ''">
+                AND pc.is_enabled = #{costParam.agreementStatus}
+            </if>
+            <if test="costParam.auditStatus != null and costParam.auditStatus != ''">
+                AND pc.approved = #{costParam.auditStatus}
+            </if>
+            <if test="costParam.validState != null and costParam.validState != ''">
+                AND pc.is_valid = #{costParam.validState}
+            </if>
+            <if test="costParam.effectiveTime != null and costParam.effectiveTime.size() > 0">
+                AND pc.effective_time BETWEEN #{costParam.effectiveTime[0]} AND #{costParam.effectiveTime[1]}
+            </if>
+            <if test="costParam.failureTime != null and costParam.failureTime.size() > 0">
+                AND pc.failure_time BETWEEN #{costParam.failureTime[0]} AND #{costParam.failureTime[1]}
+            </if>
+        </where>
     </select>