xuqiang il y a 1 an
Parent
commit
fd177aa6a1
24 fichiers modifiés avec 285 ajouts et 87 suppressions
  1. 10 0
      commons/src/main/java/com/jzg/commons/constants/Constants.java
  2. 7 0
      commons/src/main/java/com/jzg/commons/constants/ReturnInformation.java
  3. 5 1
      commons/src/main/java/com/jzg/commons/entity/dto/PtlAgreementCostAdd.java
  4. 8 2
      commons/src/main/java/com/jzg/commons/entity/po/PtlAgreementCost.java
  5. 5 0
      commons/src/main/java/com/jzg/commons/entity/po/PtlAgreementCostRule.java
  6. 3 0
      commons/src/main/java/com/jzg/commons/entity/po/PtlAgreementUndwrtRulesAttr.java
  7. 13 0
      commons/src/main/java/com/jzg/commons/entity/vo/PtlAgreementCostVo.java
  8. 1 1
      gateway/src/main/resources/application-dev.yml
  9. 23 6
      tenant/organization/src/main/java/com/jzg/organization/controller/PtlAgreementCostController.java
  10. 15 6
      tenant/organization/src/main/java/com/jzg/organization/controller/PtlNewAgreementController.java
  11. 4 0
      tenant/organization/src/main/java/com/jzg/organization/mapper/PtlAgreementCostRuleMapper.java
  12. 3 0
      tenant/organization/src/main/java/com/jzg/organization/mapper/PtlAgreementCostTypeMapper.java
  13. 1 1
      tenant/organization/src/main/java/com/jzg/organization/service/PtlAgreementCostRuleService.java
  14. 13 1
      tenant/organization/src/main/java/com/jzg/organization/service/PtlAgreementCostService.java
  15. 1 1
      tenant/organization/src/main/java/com/jzg/organization/service/PtlAgreementCostTypeService.java
  16. 5 0
      tenant/organization/src/main/java/com/jzg/organization/service/PtlAgreementUndwrtRulesAttrService.java
  17. 2 0
      tenant/organization/src/main/java/com/jzg/organization/service/PtlAgreementUndwrtRulesDictService.java
  18. 6 4
      tenant/organization/src/main/java/com/jzg/organization/service/impl/PtlAgreementCostRuleServiceImpl.java
  19. 84 30
      tenant/organization/src/main/java/com/jzg/organization/service/impl/PtlAgreementCostServiceImpl.java
  20. 5 6
      tenant/organization/src/main/java/com/jzg/organization/service/impl/PtlAgreementCostTypeServiceImpl.java
  21. 56 26
      tenant/organization/src/main/java/com/jzg/organization/service/impl/PtlAgreementUndwrtRulesAttrServiceImpl.java
  22. 4 2
      tenant/organization/src/main/java/com/jzg/organization/service/impl/PtlAgreementUndwrtRulesDictServiceImpl.java
  23. 3 0
      tenant/organization/src/main/resources/application.yml
  24. 8 0
      tenant/organization/src/main/resources/mapper/PtlAgreementCostMapper.xml

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

@@ -92,5 +92,15 @@ public class Constants
      */
     public static final String DEFAULT_PARENT_ID = "0";
 
+    /**
+     * 启用
+     */
+    public static final boolean ENABLE = true;
+
+    /**
+     * 禁用
+     */
+    public static final boolean DISABLE = false;
+
 
 }

+ 7 - 0
commons/src/main/java/com/jzg/commons/constants/ReturnInformation.java

@@ -7,4 +7,11 @@ public class ReturnInformation {
 
     public static final String FAILURE_MESSAGE = "保存失败";
 
+
+
+    public static final String UPDATE_SUCCESS = "修改成功";
+
+
+    public static final String UPDATE_FAILED = "修改失败";
+
 }

+ 5 - 1
commons/src/main/java/com/jzg/commons/entity/dto/PtlAgreementCostAdd.java

@@ -32,6 +32,10 @@ public class PtlAgreementCostAdd {
     @NotNull(message = "生效时间不能为空")
     private Date effectiveTime;
 
+    @Schema(description = "手动审核截止日期")
+    @NotNull(message = "手动审核截止日期不能为空")
+    private Date deadlineTime;
+
     @Schema(description = "失效时间")
     @NotNull(message = "失效时间不能为空")
     private Date failureTime;
@@ -65,7 +69,7 @@ public class PtlAgreementCostAdd {
     public static class RuleConditionDto {
 
         @Schema(description = "费用管理ID")
-        private String ptlAgreementCostId;
+        private Long ptlAgreementCostId;
 
         @Schema(description = "规则ID")
         private String ruleId;

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

@@ -28,14 +28,20 @@ public class PtlAgreementCost extends BaseModel {
 
     private Long productId;
 
+    private Date deadlineTime;
+
     private Date effectiveTime;
 
     private Date failureTime;
 
-    private Long auditMethod;
+    private int auditMethod;
 
     private String costDescribe;
 
-    private int approved;
+    private Integer approved;
+
+    private Boolean isValid;
+
+    private Boolean isEnabled;
 
 }

+ 5 - 0
commons/src/main/java/com/jzg/commons/entity/po/PtlAgreementCostRule.java

@@ -17,5 +17,10 @@ public class PtlAgreementCostRule {
 
     private Long ptlAgreementCostId;
 
+    private Long ruleId;
+
+    private String operator;
+
+    private String dataValue;
 
 }

+ 3 - 0
commons/src/main/java/com/jzg/commons/entity/po/PtlAgreementUndwrtRulesAttr.java

@@ -55,6 +55,9 @@ public class PtlAgreementUndwrtRulesAttr extends BaseModel {
     @TableField(exist = false)
     private String max;
 
+    @TableField(exist = false)
+    private List<SysDict> rulesDict;
+
     @TableField(exist = false)
     private List<PtlAgreementUndwrtRulesDictLabal> dictLabal;
 }

+ 13 - 0
commons/src/main/java/com/jzg/commons/entity/vo/PtlAgreementCostVo.java

@@ -28,9 +28,22 @@ public class PtlAgreementCostVo {
     @Schema(description = "失效时间")
     private Date failureTime;
 
+    @Schema(description = "手动审核截止日期(超过设置的截日期,审核会变为自动审核)")
+    private Date deadlineTime;
+
     @Schema(description = "审核方式0-自动审核;1-手动审核")
     private String auditMethod;
 
+    @Schema(description = "0-未审核1-审核通过2-审核未通过")
+    private int approved;
+
+    @Schema(description = "是否有效0-无效;1-有效")
+    private boolean isValid;
+
+    @Schema(description = "是否启用0-禁用;1-启用")
+    private boolean isEnabled;
+
+
     @Schema(description = "费用描述")
     private String costDescribe;
 

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

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

+ 23 - 6
tenant/organization/src/main/java/com/jzg/organization/controller/PtlAgreementCostController.java

@@ -4,9 +4,12 @@ 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.organization.service.PtlAgreementCostService;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
+import jakarta.validation.Valid;
+import jakarta.validation.constraints.NotEmpty;
 import jakarta.validation.constraints.NotNull;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
@@ -14,8 +17,8 @@ import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
 
-@Validated
 @Tag(name="协议费用管理")
+@Validated
 @RestController
 @RequestMapping("/ptlAgreementCost")
 public class PtlAgreementCostController {
@@ -25,14 +28,22 @@ public class PtlAgreementCostController {
 
     @Operation(summary = "协议费用管理新增")
     @PostMapping("save")
-    public HttpResult add(@Validated @RequestBody List<PtlAgreementCostAdd> costAddList){
+    public HttpResult add(@RequestBody @Valid List<PtlAgreementCostAdd> costAddList){
         return ptlAgreementCostService.save(costAddList);
     }
 
-    @Operation(summary = "协议费用管理删除")
-    @PostMapping("deleteById")
-    public HttpResult deleteById(@NotNull(message = "id不能为空") Long id){
-        return ptlAgreementCostService.removeById(id) ? HttpResult.ok("删除成功") : HttpResult.error("删除失败");
+
+    @Operation(summary = "协议费用管理修改")
+    @PostMapping("update")
+    public HttpResult update(@RequestBody @Valid List<PtlAgreementCostEnd> costEndList){
+        return ptlAgreementCostService.update(costEndList);
+    }
+
+
+    @Operation(summary = "协议费用管理批量删除")
+    @PostMapping("deleteByIds")
+    public HttpResult deleteById(@RequestBody @NotEmpty(message = "id不能为空") List<String> ids){
+        return ptlAgreementCostService.removeBatchByIds(ids) ? HttpResult.ok("删除成功") : HttpResult.error("删除失败");
     }
 
     @Operation(summary = "协议费用管理查询")
@@ -42,6 +53,12 @@ public class PtlAgreementCostController {
     }
 
 
+    @Operation(summary = "协议费用管理批量禁用/启用")
+    @PostMapping("enableDisableByIds")
+    public HttpResult enableDisableByIds(@RequestBody @NotEmpty(message = "id不能为空") List<String> ids, @NotNull(message = "状态不能为空") Boolean isEnabled){
+        return ptlAgreementCostService.enableDisableByIds(ids,isEnabled);
+    }
+
     @Operation(summary = "通过协议ID与规则ID查询")
     @PostMapping("queryByAgreementId")
     public HttpResult queryByAgreementId(@RequestBody CostAgreementParam costAgreementParam){

+ 15 - 6
tenant/organization/src/main/java/com/jzg/organization/controller/PtlNewAgreementController.java

@@ -2,14 +2,13 @@ package com.jzg.organization.controller;
 
 
 import com.jzg.commons.core.page.HttpResult;
+import com.jzg.commons.entity.dto.RulesAttParam;
 import com.jzg.commons.entity.po.PtlAgreementUndwrtRulesAttr;
 import com.jzg.organization.service.PtlAgreementUndwrtRulesAttrService;
-import io.swagger.v3.oas.annotations.media.Schema;
+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.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
 
@@ -18,7 +17,7 @@ import java.util.List;
  * @description: 协议controller
  * @create: 2024-2-22 15:44:29
  */
-@Tag(name = "协议controller")
+@Tag(name = "协议承保规则属性")
 @RequestMapping("/pltAgreement")
 @RestController
 public class PtlNewAgreementController {
@@ -26,11 +25,21 @@ public class PtlNewAgreementController {
     @Autowired
     private PtlAgreementUndwrtRulesAttrService ptlAgreementUndwrtRulesAttrService;
 
-    @Schema(defaultValue = "协议承保规则属性列表")
+    @Operation(summary = "协议承保规则属性列表")
     @GetMapping("/attr/list")
     public HttpResult<List<PtlAgreementUndwrtRulesAttr>> list() {
         List<PtlAgreementUndwrtRulesAttr> undwrtRulesAttrList = ptlAgreementUndwrtRulesAttrService.getUndwrtRulesAttrList();
         return HttpResult.ok(undwrtRulesAttrList);
     }
 
+
+
+    @Operation(summary = "协议承保规则分组属性列表")
+    @PostMapping("/attr/attrGroup")
+    public HttpResult  listMap(@RequestBody RulesAttParam param) {
+        return HttpResult.ok(ptlAgreementUndwrtRulesAttrService.attrGroup(param));
+    }
+
+
+
 }

+ 4 - 0
tenant/organization/src/main/java/com/jzg/organization/mapper/PtlAgreementCostRuleMapper.java

@@ -2,8 +2,12 @@ package com.jzg.organization.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.jzg.commons.entity.po.PtlAgreementCostRule;
+import org.apache.ibatis.annotations.Delete;
 import org.apache.ibatis.annotations.Mapper;
 
 @Mapper
 public interface PtlAgreementCostRuleMapper extends BaseMapper<PtlAgreementCostRule> {
+
+    @Delete("delete from ptl_agreement_cost_rule where ptl_agreement_cost_id = #{id}")
+    void deleteByPtlAgreementCostId(Long id);
 }

+ 3 - 0
tenant/organization/src/main/java/com/jzg/organization/mapper/PtlAgreementCostTypeMapper.java

@@ -3,6 +3,7 @@ package com.jzg.organization.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.jzg.commons.entity.po.PtlAgreementCostType;
+import org.apache.ibatis.annotations.Delete;
 import org.apache.ibatis.annotations.Mapper;
 
 
@@ -10,4 +11,6 @@ import org.apache.ibatis.annotations.Mapper;
 @Mapper
 public interface PtlAgreementCostTypeMapper extends BaseMapper<PtlAgreementCostType> {
 
+    @Delete("DELETE FROM ptl_agreement_cost_type WHERE ptl_agreement_cost_id = #{id}")
+    void deleteByPtlAgreementCostId(Long id);
 }

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

@@ -9,6 +9,6 @@ import java.util.List;
 public interface PtlAgreementCostRuleService extends IService<PtlAgreementCostRule> {
 
 
-    void saveOrUpdateCostRule(List<PtlAgreementCostAdd.RuleConditionDto> ruleConditions, Long id);
+    void saveOrUpdateCostRule(List<PtlAgreementCostRule> ruleConditions, Long id);
 
 }

+ 13 - 1
tenant/organization/src/main/java/com/jzg/organization/service/PtlAgreementCostService.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
 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.vo.PtlAgreementCostVo;
 import jakarta.validation.constraints.NotNull;
@@ -15,8 +16,19 @@ public interface PtlAgreementCostService extends IService<PtlAgreementCost> {
 
     HttpResult save(List<PtlAgreementCostAdd> costAddList);
 
+
+    HttpResult update(List<PtlAgreementCostEnd> costEndList);
+
+
     HttpResult queryById(@NotNull(message = "id不能为空") Long id);
 
-    Map<String, List<PtlAgreementCostVo>> queryByAgreementId(CostAgreementParam costAgreementParam);
+    List<PtlAgreementCostVo> queryByAgreementId(CostAgreementParam costAgreementParam);
+
+    HttpResult enableDisableByIds(List<String> ids,Boolean isEnabled);
+
+
+    void updateAuditMethod(List<Long> ids);
+
+
 
 }

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

@@ -12,6 +12,6 @@ public interface PtlAgreementCostTypeService extends IService<PtlAgreementCostTy
 
     List<PtlAgreementCostTypeVo> queryByCostId(Long costId);
 
-    void saveOrUpdateCostType(List<PtlAgreementCostAdd.PtlAgreementCostTypeDto> ptlAgreementCostTypeList, Long id);
+    void saveOrUpdateCostType(List<PtlAgreementCostType> ptlAgreementCostTypeList, Long id);
 
 }

+ 5 - 0
tenant/organization/src/main/java/com/jzg/organization/service/PtlAgreementUndwrtRulesAttrService.java

@@ -1,9 +1,11 @@
 package com.jzg.organization.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.jzg.commons.entity.dto.RulesAttParam;
 import com.jzg.commons.entity.po.PtlAgreementUndwrtRulesAttr;
 
 import java.util.List;
+import java.util.Map;
 
 public interface PtlAgreementUndwrtRulesAttrService extends IService<PtlAgreementUndwrtRulesAttr> {
 
@@ -13,4 +15,7 @@ public interface PtlAgreementUndwrtRulesAttrService extends IService<PtlAgreemen
      */
     List<PtlAgreementUndwrtRulesAttr> getUndwrtRulesAttrList();
 
+    Map<String, List<PtlAgreementUndwrtRulesAttr>> attrGroup(RulesAttParam param);
+
+
 }

+ 2 - 0
tenant/organization/src/main/java/com/jzg/organization/service/PtlAgreementUndwrtRulesDictService.java

@@ -20,5 +20,7 @@ public interface PtlAgreementUndwrtRulesDictService extends IService<PtlAgreemen
      */
     List<PtlAgreementUndwrtRulesDictLabal> getUndwrtRulesDictList();
 
+
+
 }
 

+ 6 - 4
tenant/organization/src/main/java/com/jzg/organization/service/impl/PtlAgreementCostRuleServiceImpl.java

@@ -1,6 +1,7 @@
 package com.jzg.organization.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.jzg.commons.entity.dto.PtlAgreementCostAdd;
 import com.jzg.commons.entity.po.PtlAgreementCostRule;
@@ -15,13 +16,14 @@ import java.util.List;
 public class PtlAgreementCostRuleServiceImpl extends ServiceImpl<PtlAgreementCostRuleMapper, PtlAgreementCostRule> implements PtlAgreementCostRuleService {
 
 
+
     @Override
-    public void saveOrUpdateCostRule(List<PtlAgreementCostAdd.RuleConditionDto> ruleConditions, Long id) {
-        List<PtlAgreementCostRule> ptlAgreementCostRules = BeanUtil.copyToList(ruleConditions, PtlAgreementCostRule.class);
-        for (PtlAgreementCostRule ptlAgreementCostRule : ptlAgreementCostRules) {
+    public void saveOrUpdateCostRule(List<PtlAgreementCostRule> ruleConditions, Long id) {
+        baseMapper.deleteByPtlAgreementCostId(id);
+        for (PtlAgreementCostRule ptlAgreementCostRule : ruleConditions) {
             ptlAgreementCostRule.setPtlAgreementCostId(id);
         }
-        this.saveBatch(ptlAgreementCostRules);
+        this.saveBatch(ruleConditions);
     }
 
 }

+ 84 - 30
tenant/organization/src/main/java/com/jzg/organization/service/impl/PtlAgreementCostServiceImpl.java

@@ -1,25 +1,30 @@
 package com.jzg.organization.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.util.ObjectUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.jzg.commons.constants.Constants;
 import com.jzg.commons.constants.ReturnInformation;
 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.vo.PtlAgreementCostTypeVo;
+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.vo.PtlAgreementCostVo;
-
+import com.jzg.commons.util.ListUtils;
 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 jakarta.annotation.Resource;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
-
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -29,62 +34,92 @@ import java.util.stream.Collectors;
 @Service
 public class PtlAgreementCostServiceImpl extends ServiceImpl<PtlAgreementCostMapper, PtlAgreementCost> implements PtlAgreementCostService {
 
-    @Autowired
+    @Resource
     private PtlAgreementCostTypeService costTypeService;
 
-    @Autowired
+    @Resource
     private PtlAgreementCostRuleService costRuleService;
 
-    @Autowired
+    @Resource
     private PtlAgreementCostMapper ptlAgreementCostMapper;
 
     @Override
     @Transactional(rollbackFor = Exception.class)
     public HttpResult save(List<PtlAgreementCostAdd> 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(ptlAgreementCostAdd.getPtlAgreementCostTypeList(), ptlAgreementCost.getId());
+                costTypeService.saveOrUpdateCostType(BeanUtil.copyToList(ptlAgreementCostAdd.getPtlAgreementCostTypeList(), PtlAgreementCostType.class), ptlAgreementCost.getId());
             }
             if (!CollectionUtils.isEmpty(ptlAgreementCostAdd.getRuleConditions())) {
-                costRuleService.saveOrUpdateCostRule(ptlAgreementCostAdd.getRuleConditions(), ptlAgreementCost.getId());
+                costRuleService.saveOrUpdateCostRule(BeanUtil.copyToList(ptlAgreementCostAdd.getRuleConditions(), PtlAgreementCostRule.class), ptlAgreementCost.getId());
             }
             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());
+            }
+        }
+        return HttpResult.ok(ReturnInformation.UPDATE_SUCCESS);
+    }
+
     public boolean verify(PtlAgreementCostAdd ptlAgreementCostAdd){
         CostAgreementParam costAgreementParam = new CostAgreementParam();
         costAgreementParam.setPtlAgreementId(ptlAgreementCostAdd.getPtlAgreementId());
         costAgreementParam.setCoverRuleId(ptlAgreementCostAdd.getCoverRuleId());
-        Map<String, List<PtlAgreementCostVo>> listMap = queryByAgreementId(costAgreementParam);
-        if (CollectionUtils.isEmpty(listMap)){
-            return true;
+        List<PtlAgreementCostVo> voList = queryByAgreementId(costAgreementParam);
+        if (CollectionUtils.isEmpty(voList)){
+            return false;
         }
         // 先比较规则是否相同
+        Map<String, List<PtlAgreementCostVo>> listMap = voList.stream().filter(v -> v.isEnabled() && v.isValid()).collect(Collectors.groupingBy(PtlAgreementCostVo::getProductId));
         List<PtlAgreementCostVo> ptlAgreementCostVos = listMap.get(ptlAgreementCostAdd.getProductId());
+        if (CollectionUtils.isEmpty(ptlAgreementCostVos)){
+            return false;
+        }
+        List<RuleConditionsVerify> ruleConditionsVerifies = BeanUtil.copyToList(ptlAgreementCostAdd.getRuleConditions(), RuleConditionsVerify.class);
+        if (CollectionUtils.isEmpty(ruleConditionsVerifies)){
+            return false;
+        }
         for (PtlAgreementCostVo ptlAgreementCostVo : ptlAgreementCostVos) {
-            List<PtlAgreementCostTypeVo> ptlAgreementCostTypeList = ptlAgreementCostVo.getPtlAgreementCostTypeList();
-            for (PtlAgreementCostAdd.PtlAgreementCostTypeDto dto : ptlAgreementCostAdd.getPtlAgreementCostTypeList()) {
-                for (PtlAgreementCostTypeVo ptlAgreementCostTypeVo : ptlAgreementCostTypeList) {
-                    if (dto.getCostType() == ptlAgreementCostTypeVo.getCostType()){
-                        if (dto.getInlet().compareTo(ptlAgreementCostTypeVo.getInlet()) != 0){
-                            return false;
-                        }
-                        if (dto.getExport().compareTo(ptlAgreementCostTypeVo.getExport()) != 0){                    }
-                    }
-                }
-            }
-
-
+            List<RuleConditionsVerify> verifies = BeanUtil.copyToList(ptlAgreementCostVo.getRuleConditions(), RuleConditionsVerify.class);
+            if (ObjectUtil.equals(verifies,ruleConditionsVerifies)){
+                return true;
+            };
         }
-
-
         return false;
     }
 
@@ -94,9 +129,28 @@ public class PtlAgreementCostServiceImpl extends ServiceImpl<PtlAgreementCostMap
     }
 
     @Override
-    public Map<String, List<PtlAgreementCostVo>> queryByAgreementId(CostAgreementParam costAgreementParam) {
-        return ptlAgreementCostMapper.queryByAgreementId(costAgreementParam)
-                .stream().collect(Collectors.groupingBy(PtlAgreementCostVo::getProductId));
+    public 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);
+        return baseMapper.update(ptlAgreementCost,new LambdaQueryWrapper<>(PtlAgreementCost.class)
+                .in(PtlAgreementCost::getId,ids)) > 0 ?
+                HttpResult.ok(isEnabled ? "启用成功" : "禁用成功") : HttpResult.error(isEnabled ? "启用失败" : "禁用失败");
+    }
+
+    @Override
+    public void updateAuditMethod(List<Long> ids) {
+        PtlAgreementCost ptlAgreementCost = new PtlAgreementCost();
+        ptlAgreementCost.setAuditMethod(0);
+        baseMapper.update(ptlAgreementCost,new LambdaQueryWrapper<>(PtlAgreementCost.class).in(PtlAgreementCost::getId,ids));
     }
 
 

+ 5 - 6
tenant/organization/src/main/java/com/jzg/organization/service/impl/PtlAgreementCostTypeServiceImpl.java

@@ -4,10 +4,8 @@ import cn.hutool.core.bean.BeanUtil;
 import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.jzg.commons.constants.Constants;
-import com.jzg.commons.entity.dto.PtlAgreementCostAdd;
 import com.jzg.commons.entity.po.PtlAgreementCostType;
 import com.jzg.commons.entity.vo.PtlAgreementCostTypeVo;
-
 import com.jzg.organization.mapper.PtlAgreementCostTypeMapper;
 import com.jzg.organization.service.PtlAgreementCostTypeService;
 import org.springframework.stereotype.Service;
@@ -18,6 +16,7 @@ import java.util.List;
 @Service
 public class PtlAgreementCostTypeServiceImpl extends ServiceImpl<PtlAgreementCostTypeMapper, PtlAgreementCostType> implements PtlAgreementCostTypeService {
 
+
     @Override
     public List<PtlAgreementCostTypeVo> queryByCostId(Long costId) {
         return BeanUtil.copyToList(baseMapper.selectList(new LambdaQueryChainWrapper<>(PtlAgreementCostType.class)
@@ -26,11 +25,11 @@ public class PtlAgreementCostTypeServiceImpl extends ServiceImpl<PtlAgreementCos
     }
 
     @Override
-    public void saveOrUpdateCostType(List<PtlAgreementCostAdd.PtlAgreementCostTypeDto> ptlAgreementCostTypeList, Long id) {
-        List<PtlAgreementCostType> ptlAgreementCostTypes = BeanUtil.copyToList(ptlAgreementCostTypeList, PtlAgreementCostType.class);
-        for (PtlAgreementCostType ptlAgreementCostType : ptlAgreementCostTypes) {
+    public void saveOrUpdateCostType(List<PtlAgreementCostType> ptlAgreementCostTypeList, Long id) {
+        baseMapper.deleteByPtlAgreementCostId(id);
+        for (PtlAgreementCostType ptlAgreementCostType : ptlAgreementCostTypeList) {
             ptlAgreementCostType.setPtlAgreementCostId(id);
         }
-        this.saveBatch(ptlAgreementCostTypes);
+        this.saveBatch(ptlAgreementCostTypeList);
     }
 }

+ 56 - 26
tenant/organization/src/main/java/com/jzg/organization/service/impl/PtlAgreementUndwrtRulesAttrServiceImpl.java

@@ -1,60 +1,90 @@
 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.RulesAttParam;
 import com.jzg.commons.entity.po.PtlAgreementUndwrtRulesAttr;
 import com.jzg.commons.entity.po.PtlAgreementUndwrtRulesDictLabal;
+import com.jzg.commons.entity.po.SysDict;
+import com.jzg.commons.util.StringUtils;
 import com.jzg.organization.mapper.PtlAgreementUndwrtRulesAttrMapper;
 import com.jzg.organization.service.PtlAgreementUndwrtRulesAttrService;
 import com.jzg.organization.service.PtlAgreementUndwrtRulesDictService;
+import com.jzg.organization.service.PtlAreaLicenseService;
+import org.redisson.api.RList;
+import org.redisson.api.RedissonClient;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-
-import java.util.ArrayList;
+import org.springframework.util.CollectionUtils;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
 
+import static com.jzg.commons.constants.RedisKeyConstants.DICT_REDIS_KEY;
+
 @Service
 public class PtlAgreementUndwrtRulesAttrServiceImpl extends ServiceImpl<PtlAgreementUndwrtRulesAttrMapper, PtlAgreementUndwrtRulesAttr>
         implements PtlAgreementUndwrtRulesAttrService {
 
-
     @Autowired
     PtlAgreementUndwrtRulesDictService ptlAgreementUndwrtRulesDictService;
 
+    @Autowired
+    RedissonClient redissonClient;
 
     @Override
     public List<PtlAgreementUndwrtRulesAttr> getUndwrtRulesAttrList() {
-        // 获取字典列表
-        List<PtlAgreementUndwrtRulesDictLabal> undwrtRulesDictList = ptlAgreementUndwrtRulesDictService.getUndwrtRulesDictList();
-        // 检查是否为空
-        if (undwrtRulesDictList == null || undwrtRulesDictList.isEmpty()) {
-            return this.list();
+        try {
+
+            // 获取属性列表
+            List<PtlAgreementUndwrtRulesAttr> list = this.list();
+            if (CollectionUtils.isEmpty(list)) {
+                return Collections.emptyList();
+            }
+            // 获取字典列表
+            List<PtlAgreementUndwrtRulesDictLabal> undwrtRulesDictList = ptlAgreementUndwrtRulesDictService.getUndwrtRulesDictList();
+            Map<Integer, List<PtlAgreementUndwrtRulesDictLabal>> dictMap = undwrtRulesDictList.stream()
+                    .collect(Collectors.groupingBy(PtlAgreementUndwrtRulesDictLabal::getDictId));
+            initializeAttributes(list, dictMap);
+            return list;
+        } catch (Exception e) {
+            // 处理异常
+            throw new RuntimeException("Error occurred while processing getUndwrtRulesAttrList", e);
         }
-        Map<Integer, List<PtlAgreementUndwrtRulesDictLabal>> dictMap = undwrtRulesDictList.stream()
-                .collect(Collectors.groupingBy(PtlAgreementUndwrtRulesDictLabal::getDictId));
-        // 获取属性列表
-        List<PtlAgreementUndwrtRulesAttr> list = this.list();
+    }
+
+    private void initializeAttributes(List<PtlAgreementUndwrtRulesAttr> list, Map<Integer, List<PtlAgreementUndwrtRulesDictLabal>> dictMap) {
+        RList<SysDict> rules = redissonClient.getList(DICT_REDIS_KEY + "rule_operator");
         list.forEach(attr -> {
-            // 获取对应的字典标签列表
-            List<PtlAgreementUndwrtRulesDictLabal> dictLabalList = dictMap.getOrDefault(attr.getDictId(), Collections.emptyList());
-            // 初始化 minArray 和 dictLabal
-            if (attr.getMinArray() == null) {
-                attr.setMinArray(new String[]{});
-            }
-            if (attr.getDictLabal() == null) {
-                attr.setDictLabal(new ArrayList<>());
-            }
+            attr.setRulesDict(rules);
             // 设置字典标签列表
-            attr.setDictLabal(new ArrayList<>(dictLabalList));
+            List<PtlAgreementUndwrtRulesDictLabal> dictLabalList = dictMap.getOrDefault(attr.getDictId(), Collections.emptyList());
+            attr.setDictLabal(dictLabalList);
         });
-        return list;
     }
 
-
-
-
+    @Override
+    public Map<String, List<PtlAgreementUndwrtRulesAttr>> attrGroup(RulesAttParam param) {
+        try {
+            LambdaQueryWrapper<PtlAgreementUndwrtRulesAttr> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+            lambdaQueryWrapper.like(StringUtils.isNotEmpty(param.getAttrName()), PtlAgreementUndwrtRulesAttr::getAttrName, param.getAttrName());
+            lambdaQueryWrapper.orderByAsc(PtlAgreementUndwrtRulesAttr::getSort);
+            List<PtlAgreementUndwrtRulesAttr> list = this.list(lambdaQueryWrapper);
+            if (CollectionUtils.isEmpty(list)) {
+                return Collections.emptyMap();
+            }
+            // 获取字典列表
+            List<PtlAgreementUndwrtRulesDictLabal> undwrtRulesDictList = ptlAgreementUndwrtRulesDictService.getUndwrtRulesDictList();
+            Map<Integer, List<PtlAgreementUndwrtRulesDictLabal>> dictMap = undwrtRulesDictList.stream()
+                    .collect(Collectors.groupingBy(PtlAgreementUndwrtRulesDictLabal::getDictId));
+            initializeAttributes(list, dictMap);
+            return list.stream().collect(Collectors.groupingBy(PtlAgreementUndwrtRulesAttr::getAttrGroup));
+        } catch (Exception e) {
+            // 处理异常
+            throw new RuntimeException("Error occurred while processing attrGroup", e);
+        }
+    }
 
 
 }

+ 4 - 2
tenant/organization/src/main/java/com/jzg/organization/service/impl/PtlAgreementUndwrtRulesDictServiceImpl.java

@@ -1,5 +1,7 @@
 package com.jzg.organization.service.impl;
+import com.google.common.collect.Lists;
 
+import com.alibaba.fastjson2.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.jzg.commons.entity.po.PtlAgreementUndwrtRulesDict;
@@ -10,6 +12,8 @@ import com.jzg.organization.service.PtlAgreementUndwrtRulesDictService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -38,6 +42,4 @@ public class PtlAgreementUndwrtRulesDictServiceImpl extends ServiceImpl<PtlAgree
     }
 
 
-
-
 }

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

@@ -43,6 +43,9 @@ tenant:
     - ptl_agreement_attribution
     - sys_dept
     - ptl_agreement_dept
+    - ptl_agreement_undwrt_rules_attr
+    - ptl_agreement_undwrt_rules_dict_labal
+    - ptl_area_license
   ignoreLoginNames:
 
 data-scope:

+ 8 - 0
tenant/organization/src/main/resources/mapper/PtlAgreementCostMapper.xml

@@ -13,6 +13,10 @@
         <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="deadline_time" property="deadlineTime" 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" />
         <collection property="ruleConditions" column="{costId=id}" ofType="com.jzg.commons.entity.vo.PtlAgreementCostRuleVo" select="selectCostRule" />
     </resultMap>
@@ -71,10 +75,14 @@
         t.product_id,
         t.cover_rule_id,
         t.effective_time,
+        t.deadline_time,
         t.failure_time,
         t.audit_method,
         t.cost_describe,
         t.is_delete,
+        t.approved,
+        t.is_valid,
+        t.is_enabled,
         t.create_by,
         t.create_time,
         t.update_by,