فهرست منبع

fix 调度加默认。 一个保司只能有一条默认的调度。 如果设置了默认的调度 规则匹配不上的话 就走默认的调度。

liub 1 ماه پیش
والد
کامیت
4aa3c744c7

+ 4 - 1
commons/src/main/java/com/jzg/commons/entity/agreement/dispatch/dto/PtlAgreementDispatchAction.java

@@ -9,7 +9,6 @@ import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
 import java.io.Serializable;
-import java.util.Map;
 
 @Data
 @Schema(description = "协议调度动作实体")
@@ -34,6 +33,10 @@ public class PtlAgreementDispatchAction implements Serializable {
     @TableField(exist = false)
     private String actionName;
 
+    @ExcelIgnore
+    @Schema(description = "是否默认(0-否 1-是)")
+    private Integer isDefault;
+
     @ExcelIgnore
     @Schema(description = "是否删除")
     @TableLogic

+ 10 - 0
tenant/organization/src/main/java/com/jzg/organization/service/impl/PtlAgreementDispatchServiceImpl.java

@@ -78,9 +78,19 @@ public class PtlAgreementDispatchServiceImpl extends ServiceImpl<PtlAgreementDis
         rulesAttrLinkMapper.insert(ptlAgreementDispatchVo.getAttrLinks());
 
         if(CollUtil.isNotEmpty(ptlAgreementDispatchVo.getActions())){
+            // 同一调度下仅允许一个默认动作:多个默认只保留第一个,其余及未标记的均置为否(0)
+            boolean defaultAssigned = false;
             for (PtlAgreementDispatchAction action : ptlAgreementDispatchVo.getActions()){
                 action.setId(IdGenerate.nextId());
                 action.setDispatchId(dispatch.getId());
+                if (action.getIsDefault() != null && action.getIsDefault() == 1) {
+                    if (defaultAssigned) {
+                        action.setIsDefault(1);
+                    }
+                    defaultAssigned = true;
+                } else {
+                    action.setIsDefault(0);
+                }
             }
             actionMapper.insert(ptlAgreementDispatchVo.getActions());
         }

+ 5 - 4
tenant/organization/src/main/java/com/jzg/organization/service/impl/PtlSchemeServiceImpl.java

@@ -8,14 +8,12 @@ import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.fasterxml.jackson.databind.ObjectMapper;
 import com.jzg.commons.constants.ProductsType;
 import com.jzg.commons.core.base.BaseController;
 import com.jzg.commons.core.page.HttpResult;
 import com.jzg.commons.entity.action.enums.ActionEnum;
 import com.jzg.commons.entity.agreement.dispatch.dto.PtlAgreementDispatchAction;
 import com.jzg.commons.entity.agreement.dispatch.dto.PtlAgreementDispatchRulesAttrLink;
-import com.jzg.commons.entity.agreement.dispatch.vo.PtlAgreementDispatchQuery;
 import com.jzg.commons.entity.agreement.dispatch.vo.PtlAgreementDispatchVo;
 import com.jzg.commons.entity.agreement.dispatch.vo.ValidateDispatchRuleVo;
 import com.jzg.commons.entity.agreement.po.PtlAgreementAttribution;
@@ -53,7 +51,6 @@ import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
 import java.util.*;
-import java.util.function.Function;
 import java.util.stream.Collectors;
 
 
@@ -697,7 +694,11 @@ public class PtlSchemeServiceImpl extends ServiceImpl<PtlSchemeMapper, PtlScheme
                 company.setIsDispatch(0);
                 PtlAgreementDispatchVo.DispatchVo ptlAgreementDispatchVo = dispatchByCompany.get(company.getId());
                 if (ptlAgreementDispatchVo != null) {
-                    PtlAgreementDispatchAction action1 = ptlAgreementDispatchVo.getActions().stream().filter(action -> action.getActionCode().equals(ActionEnum.SPECIFY_AGREEMENT.getCode())).findFirst().orElse(null);
+                    PtlAgreementDispatchAction action1 = ptlAgreementDispatchVo.getActions().stream().filter(action -> action.getActionCode().equals(ActionEnum.SPECIFY_AGREEMENT.getCode())).findFirst()
+                            // 未匹配到指定协议动作时,回退取默认动作(isDefault=1)
+                            .orElseGet(() -> ptlAgreementDispatchVo.getActions().stream()
+                                    .filter(action -> action.getIsDefault() != null && action.getIsDefault() == 1)
+                                    .findFirst().orElse(null));
                     if (action1 != null) {
                         //将调度字段设为1
                         company.setIsDispatch(1);

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

@@ -10,6 +10,7 @@
         <result property="actionCode" column="action_code"/>
         <result property="actionJson" column="action_json"
                 typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler"/>
+        <result property="isDefault" column="is_default"/>
     </resultMap>
 
     <select id="getActions" resultMap="ActionMap">