Преглед изворни кода

协议承保规则的功能开发

dongxin пре 1 година
родитељ
комит
3cc7277997
21 измењених фајлова са 683 додато и 27 уклоњено
  1. 0 1
      commons/src/main/java/com/jzg/commons/entity/dto/AgreementEditParam.java
  2. 23 0
      commons/src/main/java/com/jzg/commons/entity/dto/AgreementRulesAddParam.java
  3. 26 0
      commons/src/main/java/com/jzg/commons/entity/dto/AgreementRulesEditParam.java
  4. 33 0
      commons/src/main/java/com/jzg/commons/entity/po/PtlAgreementUndwrtRules.java
  5. 51 0
      commons/src/main/java/com/jzg/commons/entity/po/PtlAgreementUndwrtRulesAttrLink.java
  6. 32 0
      commons/src/main/java/com/jzg/commons/entity/vo/AgreementRulesVo.java
  7. 6 6
      commons/src/main/java/com/jzg/commons/entity/vo/AgreementVo.java
  8. 5 9
      tenant/organization/src/main/java/com/jzg/organization/controller/AgreementController.java
  9. 60 0
      tenant/organization/src/main/java/com/jzg/organization/controller/AgreementRulesController.java
  10. 18 0
      tenant/organization/src/main/java/com/jzg/organization/mapper/PtlAgreementUndwrtRulesAttrLinkMapper.java
  11. 27 0
      tenant/organization/src/main/java/com/jzg/organization/mapper/PtlAgreementUndwrtRulesMapper.java
  12. 3 1
      tenant/organization/src/main/java/com/jzg/organization/service/PtlAgreementDeptService.java
  13. 13 0
      tenant/organization/src/main/java/com/jzg/organization/service/PtlAgreementUndwrtRulesAttrLinkService.java
  14. 51 0
      tenant/organization/src/main/java/com/jzg/organization/service/PtlAgreementUndwrtRulesService.java
  15. 19 10
      tenant/organization/src/main/java/com/jzg/organization/service/impl/PtlAgreementDeptServiceImpl.java
  16. 22 0
      tenant/organization/src/main/java/com/jzg/organization/service/impl/PtlAgreementUndwrtRulesAttrLinkServiceImpl.java
  17. 226 0
      tenant/organization/src/main/java/com/jzg/organization/service/impl/PtlAgreementUndwrtRulesServiceImpl.java
  18. 1 0
      tenant/organization/src/main/resources/application.yml
  19. 2 0
      tenant/organization/src/main/resources/mapper/PtlAgreementMapper.xml
  20. 30 0
      tenant/organization/src/main/resources/mapper/PtlAgreementUndwrtRulesAttrLinkMapper.xml
  21. 35 0
      tenant/organization/src/main/resources/mapper/PtlAgreementUndwrtRulesMapper.xml

+ 0 - 1
commons/src/main/java/com/jzg/commons/entity/dto/AgreementEditParam.java

@@ -38,7 +38,6 @@ public class AgreementEditParam {
     private Integer withTax;
 
     @Schema(description = "结算周期")
-    @Size(min=1,max=3,message = "结算周期长度不能大于3")
     @NotNull(message = "请输入结算周期")
     private Integer moneyTime;
 

+ 23 - 0
commons/src/main/java/com/jzg/commons/entity/dto/AgreementRulesAddParam.java

@@ -0,0 +1,23 @@
+package com.jzg.commons.entity.dto;
+
+import com.jzg.commons.entity.po.PtlAgreementUndwrtRulesAttrLink;
+import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotEmpty;
+import jakarta.validation.constraints.NotNull;
+import jakarta.validation.constraints.Size;
+import lombok.Data;
+
+import java.util.List;
+
+@Schema(description = "承保规则新增dto")
+@Data
+public class AgreementRulesAddParam {
+
+    @Schema(description = "协议id")
+    @NotNull(message = "协议id不能为空")
+    private String agreementId;
+
+    @Schema(description = "规则属性")
+    @NotEmpty(message = "规则属性不能为空")
+    private List<PtlAgreementUndwrtRulesAttrLink> rulesAttrList;
+}

+ 26 - 0
commons/src/main/java/com/jzg/commons/entity/dto/AgreementRulesEditParam.java

@@ -0,0 +1,26 @@
+package com.jzg.commons.entity.dto;
+
+import com.jzg.commons.entity.po.PtlAgreementUndwrtRulesAttrLink;
+import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotEmpty;
+import jakarta.validation.constraints.NotNull;
+import lombok.Data;
+
+import java.util.List;
+
+@Schema(description = "承保规则修改dto")
+@Data
+public class AgreementRulesEditParam {
+
+    @NotNull(message = "承保规则id不能为空")
+    @Schema(description = "承保规则id")
+    private String id;
+
+    @Schema(description = "协议id")
+    @NotNull(message = "协议id不能为空")
+    private String agreementId;
+
+    @Schema(description = "规则属性")
+    @NotEmpty(message = "规则属性不能为空")
+    private List<PtlAgreementUndwrtRulesAttrLink> rulesAttrList;
+}

+ 33 - 0
commons/src/main/java/com/jzg/commons/entity/po/PtlAgreementUndwrtRules.java

@@ -0,0 +1,33 @@
+package com.jzg.commons.entity.po;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import com.jzg.commons.core.base.BaseModel;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+/**
+ * 协议承保规则
+ * @TableName ptl_agreement_undwrt_rules
+ */
+@Schema(description = "协议承保规则表")
+@Data
+public class PtlAgreementUndwrtRules extends BaseModel {
+
+    /** 主键/自增 */
+    @Schema(description = "主键/自增")
+    private String id;
+
+    /** 协议id */
+    @Schema(description = "协议id")
+    private String agreementId;
+
+    /** 规则描述 */
+    @Schema(description = "规则描述")
+    private String ruleDescription;
+
+    /** 显示顺序 */
+    @Schema(description = "显示顺序")
+    private Integer orderNum;
+}

+ 51 - 0
commons/src/main/java/com/jzg/commons/entity/po/PtlAgreementUndwrtRulesAttrLink.java

@@ -0,0 +1,51 @@
+package com.jzg.commons.entity.po;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.jzg.commons.core.base.BaseModel;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+/**
+ * 协议承保规则属性关联表
+ * @TableName ptl_agreement_undwrt_rules_attr_link
+ */
+@Schema(description = "协议承保规则属性关联表表")
+@Data
+public class PtlAgreementUndwrtRulesAttrLink  extends BaseModel {
+
+    /** 主键/自增 */
+    @Schema(description = "主键/自增")
+    private String id;
+
+    /** 协议规则id */
+    @Schema(description = "协议规则id")
+    private String rulesId;
+
+    /** 协议属性id */
+    @Schema(description = "协议属性id")
+    private String attrId;
+
+    /** 协议code */
+    @Schema(description = "协议code")
+    private String attrCode;
+
+    /** 左操作符 */
+    @Schema(description = "左操作符")
+    private String min;
+
+    /** 运算符1.等于2.不等于3.小于等于4.大于等于 */
+    @Schema(description = "运算符1.等于2.不等于3.小于等于4.大于等于")
+    private String operator;
+
+    /** 右操作符 */
+    @Schema(description = "右操作符")
+    private String max;
+
+    @Schema(description = "左操作数数组")
+    @TableField(exist = false)
+    private String[] minArray;
+
+}

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

@@ -0,0 +1,32 @@
+package com.jzg.commons.entity.vo;
+
+import com.jzg.commons.core.base.BaseModel;
+import com.jzg.commons.entity.po.PtlAgreementUndwrtRulesAttr;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.util.List;
+
+@Schema(description = "协议规则列表VO")
+@Data
+public class AgreementRulesVo extends BaseModel {
+
+    /** 主键 */
+    @Schema(description = "主键")
+    private String id;
+
+    /** 协议id */
+    @Schema(description = "协议id")
+    private Long agreementId;
+
+    /** 规则描述 */
+    @Schema(description = "规则描述")
+    private String ruleDescription;
+
+    /** 显示顺序 */
+    @Schema(description = "显示顺序")
+    private Integer orderNum;
+
+    @Schema(description = "费用属性")
+    private List<PtlAgreementUndwrtRulesAttr> costsAttrLinks;
+}

+ 6 - 6
commons/src/main/java/com/jzg/commons/entity/vo/AgreementVo.java

@@ -17,7 +17,7 @@ public class AgreementVo extends BaseModel {
 
     /** 协议类型 1-平台协议-平台结算 2-私有协议-自行结算 3-网销协议-自行结算*/
     @Schema(description = "协议类型 1-平台协议-平台结算 2-私有协议-自行结算 3-网销协议-自行结算")
-    private Integer agreementType;
+    private String agreementType;
 
     /** 协议代码 */
     @Schema(description = "协议代码")
@@ -37,7 +37,7 @@ public class AgreementVo extends BaseModel {
 
     /** 协议状态 0-停用 1-在用 */
     @Schema(description = "协议状态 0-启用 1-停用")
-    private Integer isEnable;
+    private String isEnable;
 
     /** 关联-保险公司id */
     @Schema(description = "关联-保险公司id")
@@ -71,7 +71,7 @@ public class AgreementVo extends BaseModel {
 
     /** 是否含增值税结算 0-否 1-是 */
     @Schema(description = "是否含增值税结算 0-否 1-是")
-    private Integer withTax;
+    private String withTax;
 
     /** 佣金发放方式 */
     @Schema(description = "佣金发放方式")
@@ -91,7 +91,7 @@ public class AgreementVo extends BaseModel {
 
     /** 审核状态 0 申请审核 1 审核通过 2 审核不通过 */
     @Schema(description = "审核状态 0 申请审核 1 审核通过 2 审核不通过")
-    private Integer auditStatus;
+    private String auditStatus;
 
     /** 序号 */
     @Schema(description = "序号")
@@ -99,7 +99,7 @@ public class AgreementVo extends BaseModel {
 
     /** 审核方式 1 人工审核 2 自动审核 */
     @Schema(description = "审核方式 1 人工审核 2 自动审核")
-    private Integer auditType;
+    private String auditType;
 
     /** 协议归属 */
     @Schema(description = "协议归属id")
@@ -111,7 +111,7 @@ public class AgreementVo extends BaseModel {
 
     /** 是否是外部订单的费用  0 否 1 是 */
     @Schema(description = "是否是外部订单的费用  0 否 1 是")
-    private Integer isExternal;
+    private String isExternal;
 
     /** 对接管理人id */
     @Schema(description = "对接管理人id")

+ 5 - 9
tenant/organization/src/main/java/com/jzg/organization/controller/AgreementController.java

@@ -8,17 +8,13 @@ import com.jzg.commons.entity.dto.AgreementAuthParam;
 import com.jzg.commons.entity.dto.AgreementEditParam;
 import com.jzg.commons.entity.dto.AgreementParam;
 import com.jzg.commons.entity.enums.YesNoEnum;
-import com.jzg.commons.entity.po.EsmInsCompany;
 import com.jzg.commons.entity.vo.AgreementVo;
 import com.jzg.commons.entity.vo.UpAndDownVo;
 import com.jzg.commons.util.AssertionUtils;
-import com.jzg.commons.util.StringUtils;
-import com.jzg.organization.client.EsmInsCompanyClient;
 import com.jzg.organization.service.PtlAgreementDeptService;
 import com.jzg.organization.service.PtlAgreementService;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
-import jakarta.annotation.Resource;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
@@ -34,7 +30,7 @@ import java.util.List;
 @Tag(name="协议管理接口")
 @RestController
 @RequestMapping("/agreement")
-public class AgreementController  extends BaseController {
+public class AgreementController extends BaseController {
 
     @Autowired
     private PtlAgreementService agreementService;
@@ -43,7 +39,7 @@ public class AgreementController  extends BaseController {
     private PtlAgreementDeptService agreementDeptService;
 
     /**
-     * 消息列表分页
+     * 协议列表分页
      * @return
      */
     @PostMapping("/agreementList")
@@ -111,8 +107,8 @@ public class AgreementController  extends BaseController {
      */
     @GetMapping(value = { "/deptTree"})
     @Operation(summary = "协议授权机构查询")
-    public HttpResult deptTree(String id) {
-        return HttpResult.ok(agreementDeptService.deptTree(id));
+    public HttpResult deptTree(String id, String deptName) {
+        return HttpResult.ok(agreementDeptService.deptTree(id, deptName));
     }
 
     /**
@@ -158,6 +154,6 @@ public class AgreementController  extends BaseController {
     @Operation(summary = "启用/禁用协议")
     public HttpResult upAndDown(@RequestBody UpAndDownVo upAndDownVo) {
         agreementService.upAndDown(upAndDownVo);
-        return HttpResult.ok(YesNoEnum.YES.equals(upAndDownVo.getOpType())? "启用成功": "禁用成功");
+        return HttpResult.ok(YesNoEnum.YES.equals(upAndDownVo.getOpType())? "禁用成功":"启用成功" );
     }
 }

+ 60 - 0
tenant/organization/src/main/java/com/jzg/organization/controller/AgreementRulesController.java

@@ -0,0 +1,60 @@
+package com.jzg.organization.controller;
+
+import com.jzg.commons.core.base.BaseController;
+import com.jzg.commons.core.page.HttpResult;
+import com.jzg.commons.entity.dto.AgreementRulesAddParam;
+import com.jzg.commons.entity.dto.AgreementRulesEditParam;
+import com.jzg.commons.entity.vo.AgreementRulesVo;
+import com.jzg.organization.service.PtlAgreementUndwrtRulesService;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@Tag(name="协议承保规则管理接口")
+@RestController
+@RequestMapping("/agreementRules")
+public class AgreementRulesController extends BaseController {
+
+    @Autowired
+    private PtlAgreementUndwrtRulesService agreementRulesService;
+
+    @GetMapping("/rulesList")
+    @Operation(summary = "协议承保规则列表")
+    public HttpResult rulesList(String agreementId){
+        List<AgreementRulesVo> rulesVos = agreementRulesService.queryList(agreementId);
+        return HttpResult.ok(rulesVos);
+    }
+
+    @Operation(summary = "获取承保规则")
+    @GetMapping("/rulesGet")
+    public HttpResult rulesGet(String ruleId) {
+        AgreementRulesVo agreementRulesVo = agreementRulesService.rulesGet(ruleId);
+        return HttpResult.ok(agreementRulesVo);
+
+    }
+
+    @Operation(summary = "添加承保规则")
+    @PostMapping("/rulesAdd")
+    public HttpResult rulesAdd(@Validated @RequestBody AgreementRulesAddParam param) {
+        return agreementRulesService.rulesAdd(param) ?
+                HttpResult.ok("添加承保规则成功") : HttpResult.error("添加承保规则失败");
+    }
+
+    @Operation(summary = "修改承保规则")
+    @PostMapping("/rulesEdit")
+    public HttpResult rulesEdit(@RequestBody AgreementRulesEditParam param) {
+        return agreementRulesService.rulesEdit(param) ?
+                HttpResult.ok("修改承保规则成功") : HttpResult.error("修改承保规则失败");
+    }
+
+    @Operation(summary = "删除承保规则")
+    @DeleteMapping("/rulesDelete")
+    public HttpResult rulesDelete(String id) {
+        return HttpResult.ok(agreementRulesService.deleteById(id)? "删除成功":"删除失败");
+    }
+
+}

+ 18 - 0
tenant/organization/src/main/java/com/jzg/organization/mapper/PtlAgreementUndwrtRulesAttrLinkMapper.java

@@ -0,0 +1,18 @@
+package com.jzg.organization.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.jzg.commons.entity.po.PtlAgreementUndwrtRulesAttrLink;
+
+/**
+* @author dongxin
+* @description 针对表【ptl_agreement_undwrt_rules_attr_link(协议承保规则属性关联表)】的数据库操作Mapper
+* @createDate 2025-02-20 09:32:09
+* @Entity generator.domain.PtlAgreementUndwrtRulesAttrLink
+*/
+public interface PtlAgreementUndwrtRulesAttrLinkMapper extends BaseMapper<PtlAgreementUndwrtRulesAttrLink> {
+
+}
+
+
+
+

+ 27 - 0
tenant/organization/src/main/java/com/jzg/organization/mapper/PtlAgreementUndwrtRulesMapper.java

@@ -0,0 +1,27 @@
+package com.jzg.organization.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.jzg.commons.entity.po.PtlAgreementUndwrtRules;
+import com.jzg.commons.entity.vo.AgreementRulesVo;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+* @author dongxin
+* @description 针对表【ptl_agreement_undwrt_rules(协议承保规则)】的数据库操作Mapper
+* @createDate 2025-02-20 09:32:09
+* @Entity generator.domain.PtlAgreementUndwrtRules
+*/
+public interface PtlAgreementUndwrtRulesMapper extends BaseMapper<PtlAgreementUndwrtRules> {
+
+    /**
+     * 协议规则列表
+     * @return
+     */
+    List<AgreementRulesVo> queryList(@Param("agreementId") String agreementId);
+}
+
+
+
+

+ 3 - 1
tenant/organization/src/main/java/com/jzg/organization/service/PtlAgreementDeptService.java

@@ -23,10 +23,12 @@ public interface PtlAgreementDeptService extends IService<PtlAgreementDept> {
 
     /**
      * 获取协议授权机构树
+     *
      * @param id
+     * @param deptName
      * @return
      */
-    List<SysDeptVo> deptTree(String id);
+    List<SysDeptVo> deptTree(String id, String deptName);
 
     /**
      * 协议授权保存

+ 13 - 0
tenant/organization/src/main/java/com/jzg/organization/service/PtlAgreementUndwrtRulesAttrLinkService.java

@@ -0,0 +1,13 @@
+package com.jzg.organization.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.jzg.commons.entity.po.PtlAgreementUndwrtRulesAttrLink;
+
+/**
+* @author dongxin
+* @description 针对表【ptl_agreement_undwrt_rules_attr_link(协议承保规则属性关联表)】的数据库操作Service
+* @createDate 2025-02-20 09:32:09
+*/
+public interface PtlAgreementUndwrtRulesAttrLinkService extends IService<PtlAgreementUndwrtRulesAttrLink> {
+
+}

+ 51 - 0
tenant/organization/src/main/java/com/jzg/organization/service/PtlAgreementUndwrtRulesService.java

@@ -0,0 +1,51 @@
+package com.jzg.organization.service;
+
+import com.jzg.commons.entity.dto.AgreementRulesAddParam;
+import com.jzg.commons.entity.dto.AgreementRulesEditParam;
+import com.jzg.commons.entity.po.PtlAgreementUndwrtRules;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.jzg.commons.entity.vo.AgreementRulesVo;
+
+import java.util.List;
+
+/**
+* @author dongxin
+* @description 针对表【ptl_agreement_undwrt_rules(协议承保规则)】的数据库操作Service
+* @createDate 2025-02-20 09:32:09
+*/
+public interface PtlAgreementUndwrtRulesService extends IService<PtlAgreementUndwrtRules> {
+
+    /**
+     * 协议规则列表
+     * @return
+     */
+    List<AgreementRulesVo> queryList(String agreementId);
+
+    /**
+     * 承保规则新增
+     * @param param
+     * @return
+     */
+    boolean rulesAdd(AgreementRulesAddParam param);
+
+    /**
+     * 承保规则修改
+     * @param param
+     * @return
+     */
+    boolean rulesEdit(AgreementRulesEditParam param);
+
+    /**
+     * 承保规则详情
+     * @param ruleId
+     * @return
+     */
+    AgreementRulesVo rulesGet(String ruleId);
+
+    /**
+     * 删除承保规则
+     * @param id
+     * @return
+     */
+    boolean deleteById(String id);
+}

+ 19 - 10
tenant/organization/src/main/java/com/jzg/organization/service/impl/PtlAgreementDeptServiceImpl.java

@@ -1,21 +1,17 @@
 package com.jzg.organization.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.jzg.commons.core.base.BaseController;
 import com.jzg.commons.entity.dto.AgreementAuthParam;
 import com.jzg.commons.entity.po.PtlAgreementDept;
-import com.jzg.commons.entity.po.SysArea;
 import com.jzg.commons.entity.po.SysDept;
-import com.jzg.commons.entity.po.SysUserJzgInfo;
 import com.jzg.commons.entity.vo.SysDeptVo;
+import com.jzg.commons.util.StringUtils;
 import com.jzg.organization.mapper.PtlAgreementDeptMapper;
 import com.jzg.organization.mapper.SysDeptMapper;
 import com.jzg.organization.service.PtlAgreementDeptService;
-import com.jzg.organization.service.SysDeptService;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -48,7 +44,7 @@ public class PtlAgreementDeptServiceImpl extends ServiceImpl<PtlAgreementDeptMap
     }
 
     @Override
-    public List<SysDeptVo> deptTree(String id) {
+    public List<SysDeptVo> deptTree(String id, String deptName) {
         // 获取所有协议选中的机构id
         LambdaQueryWrapper<PtlAgreementDept> wrapper = new LambdaQueryWrapper<>();
         wrapper.eq(PtlAgreementDept::getAgreementId, id);
@@ -58,7 +54,20 @@ public class PtlAgreementDeptServiceImpl extends ServiceImpl<PtlAgreementDeptMap
         List<SysDeptVo> sysDepts = new ArrayList<>();
         SysDept sysDept = deptMapper.selectById(deptId);
         SysDeptVo sysDeptVo = new SysDeptVo(sysDept);
-        List<SysDept> depts = deptMapper.selectDeptVoList(deptId, null);
+        SysDept nameDept = null;
+        if(StringUtils.isNotEmpty(deptName)){
+            LambdaQueryWrapper<SysDept> deptWrapper = new LambdaQueryWrapper<>();
+            deptWrapper.eq(SysDept :: getName, deptName);
+            nameDept = deptMapper.selectOne(deptWrapper);
+        }
+
+        LambdaQueryWrapper<SysDept> allWrapper = new LambdaQueryWrapper<>();
+        allWrapper.like(SysDept :: getRoute, deptId)
+                .eq(SysDept :: getIsDelete, 0);
+        if (Objects.nonNull(nameDept)){
+            allWrapper.like(Objects.isNull(nameDept), SysDept :: getRoute, nameDept.getId());
+        }
+        List<SysDept> depts = deptMapper.selectList(allWrapper);
         List<SysDeptVo> voDept = new ArrayList<>();
         depts.forEach(item->{
             SysDeptVo sysDeptv = new SysDeptVo(item);
@@ -71,10 +80,10 @@ public class PtlAgreementDeptServiceImpl extends ServiceImpl<PtlAgreementDeptMap
         });
         Map<String, List<SysDeptVo>> map = voDept.stream().collect(Collectors.groupingBy(SysDeptVo::getParentId));
         voDept.forEach(i -> i.setChildren(map.getOrDefault(i.getId(), new ArrayList<>())));
-        if(!Objects.isNull(sysDept)) {
+        if (!Objects.isNull(nameDept)){
+            sysDepts = map.get(nameDept.getParentId());
+        } else if(!Objects.isNull(sysDept)) {
             sysDepts = map.get(sysDeptVo.getParentId());
-        }else{
-            sysDepts = map.get("0");
         }
         List<SysDeptVo> newResultDept = new ArrayList<>();
         newResultDept.addAll(sysDepts);

+ 22 - 0
tenant/organization/src/main/java/com/jzg/organization/service/impl/PtlAgreementUndwrtRulesAttrLinkServiceImpl.java

@@ -0,0 +1,22 @@
+package com.jzg.organization.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.jzg.commons.entity.po.PtlAgreementUndwrtRulesAttrLink;
+import com.jzg.organization.mapper.PtlAgreementUndwrtRulesAttrLinkMapper;
+import com.jzg.organization.service.PtlAgreementUndwrtRulesAttrLinkService;
+import org.springframework.stereotype.Service;
+
+/**
+* @author dongxin
+* @description 针对表【ptl_agreement_undwrt_rules_attr_link(协议承保规则属性关联表)】的数据库操作Service实现
+* @createDate 2025-02-20 09:32:09
+*/
+@Service
+public class PtlAgreementUndwrtRulesAttrLinkServiceImpl extends ServiceImpl<PtlAgreementUndwrtRulesAttrLinkMapper, PtlAgreementUndwrtRulesAttrLink>
+    implements PtlAgreementUndwrtRulesAttrLinkService {
+
+}
+
+
+
+

+ 226 - 0
tenant/organization/src/main/java/com/jzg/organization/service/impl/PtlAgreementUndwrtRulesServiceImpl.java

@@ -0,0 +1,226 @@
+package com.jzg.organization.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.jzg.commons.entity.dto.AgreementRulesAddParam;
+import com.jzg.commons.entity.dto.AgreementRulesEditParam;
+import com.jzg.commons.entity.po.PtlAgreementUndwrtRules;
+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.organization.mapper.PtlAgreementUndwrtRulesAttrLinkMapper;
+import com.jzg.organization.mapper.PtlAgreementUndwrtRulesAttrMapper;
+import com.jzg.organization.mapper.PtlAgreementUndwrtRulesMapper;
+import com.jzg.organization.service.PtlAgreementUndwrtRulesAttrLinkService;
+import com.jzg.organization.service.PtlAgreementUndwrtRulesAttrService;
+import com.jzg.organization.service.PtlAgreementUndwrtRulesService;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
+/**
+* @author dongxin
+* @description 针对表【ptl_agreement_undwrt_rules(协议承保规则)】的数据库操作Service实现
+* @createDate 2025-02-20 09:32:09
+*/
+@Service
+public class PtlAgreementUndwrtRulesServiceImpl extends ServiceImpl<PtlAgreementUndwrtRulesMapper, PtlAgreementUndwrtRules>
+    implements PtlAgreementUndwrtRulesService {
+
+    @Autowired
+    private PtlAgreementUndwrtRulesAttrLinkMapper agreementUndwrtRulesAttrLinkMapper;
+
+    @Autowired
+    private PtlAgreementUndwrtRulesAttrService agreementUndwrtRulesAttrService;
+
+    @Autowired
+    private PtlAgreementUndwrtRulesAttrLinkService agreementUndwrtRulesAttrLinkService;
+
+    @Override
+    public List<AgreementRulesVo> queryList(String agreementId) {
+        List<AgreementRulesVo> rulesVos = baseMapper.queryList(agreementId);
+        return rulesVos;
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public boolean rulesAdd(AgreementRulesAddParam param) {
+        // 根据协议id获取最大的序号
+        LambdaQueryWrapper<PtlAgreementUndwrtRules> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.orderByDesc(PtlAgreementUndwrtRules::getOrderNum);
+        queryWrapper.last("LIMIT 1"); // 只取一个结果
+        PtlAgreementUndwrtRules maxRules = baseMapper.selectOne(queryWrapper);
+        PtlAgreementUndwrtRules rules = new PtlAgreementUndwrtRules();
+        rules.setOrderNum(Objects.nonNull(maxRules) ? maxRules.getOrderNum() + 1 : 1);
+        rules.setAgreementId(param.getAgreementId());
+        baseMapper.insert(rules);
+        //遍历承保规则属性
+        List<PtlAgreementUndwrtRulesAttrLink> rulesAttrList = param.getRulesAttrList();
+        List<PtlAgreementUndwrtRulesAttrLink> costsAttrLink = new ArrayList<>();
+        rulesAttrList.forEach(attr -> {
+            attr.setRulesId(rules.getId());
+            costsAttrLink.add(attr);
+        });
+        agreementUndwrtRulesAttrLinkMapper.insert(costsAttrLink);
+        //获取费用属性
+        List<PtlAgreementUndwrtRulesAttr> undwrtRulesAttrList = agreementUndwrtRulesAttrService.getUndwrtRulesAttrList();
+        rules.setRuleDescription(buildDesc(costsAttrLink, undwrtRulesAttrList));
+        baseMapper.updateById(rules);
+        return true;
+    }
+
+    @Override
+    public boolean rulesEdit(AgreementRulesEditParam param) {
+        PtlAgreementUndwrtRules rules = new PtlAgreementUndwrtRules();
+        BeanUtils.copyProperties(param, rules);
+
+        // 删除费用因子
+        agreementUndwrtRulesAttrLinkService.remove(new LambdaQueryWrapper<PtlAgreementUndwrtRulesAttrLink>()
+                .eq(PtlAgreementUndwrtRulesAttrLink::getRulesId, rules.getId()));
+
+        List<PtlAgreementUndwrtRulesAttr> attrList = agreementUndwrtRulesAttrService.getUndwrtRulesAttrList();
+        //再添加属性值
+        List<PtlAgreementUndwrtRulesAttrLink> costsAttrLinks = param.getRulesAttrList();
+        List<PtlAgreementUndwrtRulesAttrLink> costsAttrLink = new ArrayList<>();
+        costsAttrLinks.forEach(link -> {
+            //转换数组
+            if (link.getMinArray() != null && link.getMinArray().length > 0) {
+                link.setMin(String.join(",", link.getMinArray()));
+            }
+
+            //处理中文逗号
+            if (link.getMin() != null && link.getMin().contains(",")) {
+                link.setMin(link.getMin().replace(",", ","));
+            }
+
+            PtlAgreementUndwrtRulesAttr ptlAgreementUndwrtRulesAttr = attrList.stream()
+                    .filter(attr -> attr.getAttrCode().equals(link.getAttrCode()))
+                    .findFirst().orElse(null);
+            //单独判断radio  radio中存在0的属性值
+            link.setRulesId(rules.getId());
+            link.setId("0");
+            costsAttrLink.add(link);
+        });
+        agreementUndwrtRulesAttrLinkService.saveBatch(costsAttrLink);
+
+        rules.setRuleDescription(buildDesc(costsAttrLink, attrList));
+        baseMapper.updateById(rules);
+        return true;
+    }
+
+    @Override
+    public AgreementRulesVo rulesGet(String ruleId) {
+        PtlAgreementUndwrtRules rules = baseMapper.selectById(ruleId);
+        AgreementRulesVo rulesVo = new AgreementRulesVo();
+        BeanUtils.copyProperties(rules, rulesVo);
+        List<PtlAgreementUndwrtRulesAttrLink> linkList = agreementUndwrtRulesAttrLinkService.list(
+                new LambdaQueryWrapper<PtlAgreementUndwrtRulesAttrLink>()
+                .eq(PtlAgreementUndwrtRulesAttrLink::getRulesId, ruleId));
+
+        // 获取费用因子属性
+        List<PtlAgreementUndwrtRulesAttr> attrList = agreementUndwrtRulesAttrService.getUndwrtRulesAttrList();
+
+        List<PtlAgreementUndwrtRulesAttr> newAttrList = new ArrayList<>();
+        attrList.forEach(attr -> {
+            //处理多选和下拉
+            if ("checkbox".equals(attr.getAttrType()) || "select".equals(attr.getAttrType())) {
+                linkList.stream().filter(link -> link.getAttrCode().equals(attr.getAttrCode()))
+                        .findFirst().ifPresent(z -> {
+                    if (null != z.getMin()) {
+                        attr.setId(z.getId());
+                        attr.setMinArray(z.getMin().split(","));
+                        attr.setMax(z.getMax());
+                        attr.setOperator(z.getOperator());
+                    }
+                });
+            }else{
+                linkList.stream().filter(link -> link.getAttrCode().equals(attr.getAttrCode()))
+                        .findFirst().ifPresent(z -> {
+                    attr.setId(z.getId());
+                    attr.setMin(z.getMin());
+                    attr.setMax(z.getMax());
+                    attr.setOperator(z.getOperator());
+                });
+            }
+            newAttrList.add(attr);
+        });
+        rulesVo.setCostsAttrLinks(newAttrList);
+        return rulesVo;
+    }
+
+    @Override
+    public boolean deleteById(String id) {
+        agreementUndwrtRulesAttrLinkService.remove(
+                new LambdaQueryWrapper<PtlAgreementUndwrtRulesAttrLink>()
+                        .eq(PtlAgreementUndwrtRulesAttrLink::getRulesId, id));
+        return baseMapper.deleteById(id) > 0;
+    }
+
+    /**
+     * 遍历费用属性描述文字
+     *
+     * @param linkList
+     * @param undwrtRulesAttrList
+     * @return
+     */
+    private String buildDesc(List<PtlAgreementUndwrtRulesAttrLink> linkList, List<PtlAgreementUndwrtRulesAttr> undwrtRulesAttrList) {
+        StringBuilder desc = new StringBuilder();
+        for (int i = 0; i < linkList.size(); i++) {
+            int finalI = i;
+            PtlAgreementUndwrtRulesAttr ptlAgreementUndwrtRulesAttr = undwrtRulesAttrList.stream()
+                    .filter(x -> x.getAttrCode().equals(linkList.get(finalI).getAttrCode()))
+                    .findAny()
+                    .get();
+            //数值范围判断
+
+            if ("inputNumber".equals(ptlAgreementUndwrtRulesAttr.getAttrType())) {
+                desc.append(inputNumberIdentifying(ptlAgreementUndwrtRulesAttr, linkList.get(i))).append("\n");
+            }
+            if ("radio".equals(ptlAgreementUndwrtRulesAttr.getAttrType())) {
+                desc.append(radioIdentifying(ptlAgreementUndwrtRulesAttr, linkList.get(i))).append("\n");
+            }
+            if ("checkbox".equals(ptlAgreementUndwrtRulesAttr.getAttrType()) || "select".equals(ptlAgreementUndwrtRulesAttr.getAttrType())) {
+                desc.append(ptlAgreementUndwrtRulesAttr.getAttrName()).append("包含").append(linkList.get(i).getMin()).append("\n");
+            }
+            if ("input".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");
+                } else {
+                    desc.append(ptlAgreementUndwrtRulesAttr.getAttrName()).append("不包含").append(linkList.get(i).getMin()).append("\n");
+                }
+            }
+        }
+        return desc.toString();
+    }
+
+    private String radioIdentifying(PtlAgreementUndwrtRulesAttr ptlAgreementUndwrtRulesAttr, PtlAgreementUndwrtRulesAttrLink ptlAgreementProductCostsAttrLink) {
+        PtlAgreementUndwrtRulesDictLabal ptlAgreementUndwrtRulesDictLabal = ptlAgreementUndwrtRulesAttr.getDictLabal().stream().filter(x -> x.getCode().equals(ptlAgreementProductCostsAttrLink.getMin())).findAny().get();
+        return ptlAgreementUndwrtRulesAttr.getAttrName() + "为" + ptlAgreementUndwrtRulesDictLabal.getName();
+    }
+
+    private String inputNumberIdentifying(PtlAgreementUndwrtRulesAttr ptlAgreementUndwrtRulesAttr, PtlAgreementUndwrtRulesAttrLink ptlAgreementProductCostsAttrLink) {
+        if ("1".equals(ptlAgreementProductCostsAttrLink.getOperator())) {
+            return ptlAgreementUndwrtRulesAttr.getAttrName() + "范围值" + ptlAgreementProductCostsAttrLink.getMin() + "到" + ptlAgreementProductCostsAttrLink.getMax();
+        } else if ("2".equals(ptlAgreementProductCostsAttrLink.getOperator())) {
+            return ptlAgreementUndwrtRulesAttr.getAttrName() + "小于" + ptlAgreementProductCostsAttrLink.getMin();
+        } else if ("3".equals(ptlAgreementProductCostsAttrLink.getOperator())) {
+            return ptlAgreementUndwrtRulesAttr.getAttrName() + "小于等于" + ptlAgreementProductCostsAttrLink.getMin();
+        } else if ("4".equals(ptlAgreementProductCostsAttrLink.getOperator())) {
+            return ptlAgreementUndwrtRulesAttr.getAttrName() + "大于" + ptlAgreementProductCostsAttrLink.getMax();
+        } else if ("5".equals(ptlAgreementProductCostsAttrLink.getOperator())) {
+            return ptlAgreementUndwrtRulesAttr.getAttrName() + "大于等于" + ptlAgreementProductCostsAttrLink.getMax();
+        }
+        return "";
+    }
+}
+
+
+
+

+ 1 - 0
tenant/organization/src/main/resources/application.yml

@@ -41,6 +41,7 @@ tenant:
     - sys_message_user
     - sys_notice_user
     - ptl_agreement_attribution
+    - ptl_agreement_dept
   ignoreLoginNames:
 
 data-scope:

+ 2 - 0
tenant/organization/src/main/resources/mapper/PtlAgreementMapper.xml

@@ -103,9 +103,11 @@
         select <include refid="Base_Column_List"/>
         FROM ptl_agreement pa
         LEFT JOIN ptl_agreement_attribution paa on pa.attribution_id = paa.id
+        LEFT JOIN sys_dept sdd on pa.dept_id = sdd.id
         LEFT JOIN sys_user_jzg_info suji on pa.custodian_id = suji.user_id
         LEFT JOIN sys_dept sd on suji.dept_id = sd.id
         LEFT JOIN sys_upload_files suf on pa.file_id = suf.id
+        LEFT JOIN esm_ins_company eic on pa.company_id = eic.id
         <where>
             <if test="id != null and id != ''">
                 and pa.id = #{id}

+ 30 - 0
tenant/organization/src/main/resources/mapper/PtlAgreementUndwrtRulesAttrLinkMapper.xml

@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.jzg.organization.mapper.PtlAgreementUndwrtRulesAttrLinkMapper">
+
+    <resultMap id="BaseResultMap" type="com.jzg.commons.entity.po.PtlAgreementUndwrtRulesAttrLink">
+            <id property="id" column="id" jdbcType="VARCHAR"/>
+            <result property="rulesId" column="rules_id" jdbcType="VARCHAR"/>
+            <result property="attrId" column="attr_id" jdbcType="VARCHAR"/>
+            <result property="attrCode" column="attr_code" jdbcType="VARCHAR"/>
+            <result property="min" column="min" jdbcType="VARCHAR"/>
+            <result property="operator" column="operator" jdbcType="VARCHAR"/>
+            <result property="max" column="max" jdbcType="VARCHAR"/>
+            <result property="systemCode" column="system_code" jdbcType="VARCHAR"/>
+            <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
+            <result property="createBy" column="create_by" jdbcType="VARCHAR"/>
+            <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
+            <result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
+            <result property="isDelete" column="is_delete" jdbcType="TINYINT"/>
+    </resultMap>
+
+    <sql id="Base_Column_List">
+        id,rules_id,attr_id,
+        attr_code,min,operator,
+        max,system_code,create_time,
+        create_by,update_time,update_by,
+        is_delete
+    </sql>
+</mapper>

+ 35 - 0
tenant/organization/src/main/resources/mapper/PtlAgreementUndwrtRulesMapper.xml

@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.jzg.organization.mapper.PtlAgreementUndwrtRulesMapper">
+
+    <resultMap id="BaseResultMap" type="com.jzg.commons.entity.po.PtlAgreementUndwrtRules">
+            <id property="id" column="id" jdbcType="VARCHAR"/>
+            <result property="agreementId" column="agreement_id" jdbcType="VARCHAR"/>
+            <result property="ruleDescription" column="rule_description" jdbcType="VARCHAR"/>
+            <result property="orderNum" column="order_num" jdbcType="INTEGER"/>
+            <result property="createBy" column="create_by" jdbcType="VARCHAR"/>
+            <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
+            <result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
+            <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
+            <result property="isDelete" column="is_delete" jdbcType="TINYINT"/>
+    </resultMap>
+
+    <sql id="Base_Column_List">
+        paur.id,paur.agreement_id,paur.rule_description,
+        paur.order_num,paur.create_by,paur.create_time,
+        paur.update_by,paur.update_time,paur.is_delete
+    </sql>
+    <select id="queryList" resultType="com.jzg.commons.entity.vo.AgreementRulesVo">
+        SELECT <include refid="Base_Column_List"/>
+        FROM ptl_agreement_undwrt_rules paur
+        <where>
+            paur.is_delete = 0
+            <if test="agreementId != null and agreementId != ''">
+                paur.agreement_id = #{agreementId}
+            </if>
+        </where>
+        ORDER BY paur.order_num ASC
+    </select>
+</mapper>