Sfoglia il codice sorgente

费用规则与前端联调

xuqiang 1 anno fa
parent
commit
fc35e5deae

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

@@ -103,4 +103,15 @@ public class Constants
     public static final int DISABLE = 1;
 
 
+    /**
+     * 有效
+     */
+    public static final int EFFECTIVE = 0;
+
+    /**
+     * 失效
+     */
+    public static final int LOSE_EFFICACY = 1;
+
+
 }

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

@@ -15,6 +15,9 @@ public class CostManagementVo {
     @Schema(description = "协议ID")
     private String ptlAgreementId;
 
+    @Schema(description = "协议名称")
+    private String agreementTitle;
+
     @Schema(description = "协议代码")
     private String agreementCode;
 

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

@@ -24,7 +24,7 @@ public class PtlAgreementCostParam extends PageRequest {
     @Schema(description = "费用规则")
     private String costRules;
 
-    @Schema(description = "协议状态")
+    @Schema(description = "费用状态")
     private String agreementStatus;
 
     @Schema(description = "审核状态")

+ 18 - 10
tenant/organization/src/main/java/com/jzg/organization/service/impl/PtlAgreementCostServiceImpl.java

@@ -28,6 +28,7 @@ import com.jzg.organization.state.UserState;
 import com.jzg.organization.state.listener.CostStateListener;
 import jakarta.annotation.Resource;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.poi.ss.formula.functions.T;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.statemachine.StateMachine;
@@ -73,11 +74,10 @@ public class PtlAgreementCostServiceImpl extends ServiceImpl<PtlAgreementCostMap
         if (costAddList.isEmpty()) {
             return HttpResult.error("保存数据不能为空");
         }
-        List<PtlAgreementUndwrtRulesAttr> undwrtRulesAttrList = agreementUndwrtRulesAttrService.getUndwrtRulesAttrList();
         for (CostAdd costAdd : costAddList) {
             for (PtlAgreementCostAdd ptlAgreementCostAdd : costAdd.getPtlAgreementCostAddList()){
                 if (ListUtils.hasDuplicates(ptlAgreementCostAdd.getRuleConditions())){
-                    return HttpResult.error("存在相同费用规则,请检查");
+                    throw new SystemException("添加数据存在相同费用规则,请检查");
                 }
                 ptlAgreementCostAdd.setPtlAgreementId(costAdd.getPtlAgreementId());
                 ptlAgreementCostAdd.setProductId(costAdd.getProductId());
@@ -85,10 +85,10 @@ public class PtlAgreementCostServiceImpl extends ServiceImpl<PtlAgreementCostMap
                 ptlAgreementCostAdd.setCoverRuleId(costAdd.getCoverRuleId());
                 boolean verify = verify(ptlAgreementCostAdd);
                 if (verify){
-                    return HttpResult.error("已存在相同且有效的费用规则,请检查");
+                    throw new SystemException("已存在相同且有效的费用规则,请检查");
                 }
                 PtlAgreementCost ptlAgreementCost = BeanUtil.copyProperties(ptlAgreementCostAdd, PtlAgreementCost.class);
-                ptlAgreementCost.setCostRules(BuildDescUtils.buildDesc(BeanUtil.copyToList(ptlAgreementCostAdd.getRuleConditions(), PtlAgreementUndwrtRulesAttr.class), undwrtRulesAttrList));
+                ptlAgreementCost.setCostRules(buildDescString(ptlAgreementCostAdd.getRuleConditions()));
                 if (baseMapper.insert(ptlAgreementCost) <= 0) {
                     log.error("插入操作失败");
                     throw new RuntimeException(ReturnInformation.FAILURE_MESSAGE);
@@ -108,11 +108,12 @@ public class PtlAgreementCostServiceImpl extends ServiceImpl<PtlAgreementCostMap
     @Override
     @Transactional(rollbackFor = Exception.class)
     public HttpResult update(PtlAgreementCostEnd ptlAgreementCostEnd) {
+        if (ListUtils.hasDuplicates(ptlAgreementCostEnd.getRuleConditions())){
+            return HttpResult.error("已存在相同且有效的费用规则,请检查");
+        }
 
-//        if (ListUtils.hasDuplicates(ptlAgreementCostEnd.getRuleConditions())){
-//            return HttpResult.error("已存在相同且有效的费用规则,请检查");
-//        }
         PtlAgreementCost ptlAgreementCost = BeanUtil.copyProperties(ptlAgreementCostEnd, PtlAgreementCost.class);
+        ptlAgreementCost.setCostRules(buildDescString(ptlAgreementCostEnd.getRuleConditions()));
         if (baseMapper.updateById(ptlAgreementCost) <= 0) {
             throw new RuntimeException(ReturnInformation.UPDATE_FAILED);
         }
@@ -122,10 +123,17 @@ public class PtlAgreementCostServiceImpl extends ServiceImpl<PtlAgreementCostMap
         if (!CollectionUtils.isEmpty(ptlAgreementCostEnd.getRuleConditions())) {
             costRuleService.saveOrUpdateCostRule(BeanUtil.copyToList(ptlAgreementCostEnd.getRuleConditions(), PtlAgreementCostRule.class), ptlAgreementCost.getId());
         }
-
         return HttpResult.ok(ReturnInformation.UPDATE_SUCCESS);
     }
 
+
+    public String buildDescString(List<?> list){
+        if (CollectionUtils.isEmpty(list)){
+            return null;
+        }
+        return BuildDescUtils.buildDesc(BeanUtil.copyToList(list, PtlAgreementUndwrtRulesAttr.class), agreementUndwrtRulesAttrService.getUndwrtRulesAttrList());
+    }
+
     public boolean verify(PtlAgreementCostAdd ptlAgreementCostAdd){
         CostAgreementParam costAgreementParam = new CostAgreementParam();
         costAgreementParam.setPtlAgreementId(ptlAgreementCostAdd.getPtlAgreementId());
@@ -134,8 +142,8 @@ public class PtlAgreementCostServiceImpl extends ServiceImpl<PtlAgreementCostMap
         if (CollectionUtils.isEmpty(voList)){
             return false;
         }
-        // 先比较规则是否相同
-        Map<String, List<PtlAgreementCostVo>> listMap = voList.stream().filter(v -> Constants.ENABLE == v.getIsEnabled() && Constants.NOT_DELETED == v.getIsValid()).collect(Collectors.groupingBy(PtlAgreementCostVo::getProductId));
+        // 比较规则是否相同
+        Map<String, List<PtlAgreementCostVo>> listMap = voList.stream().filter(v -> Constants.ENABLE == v.getIsEnabled() && Constants.EFFECTIVE == v.getIsValid()).collect(Collectors.groupingBy(PtlAgreementCostVo::getProductId));
         List<PtlAgreementCostVo> ptlAgreementCostVos = listMap.get(ptlAgreementCostAdd.getProductId());
         if (CollectionUtils.isEmpty(ptlAgreementCostVos)){
             return false;

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

@@ -86,6 +86,7 @@
     <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_title" property="agreementTitle" 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"/>