Browse Source

规则、规则集Crud修改

JoeLazy 2 months ago
parent
commit
de05f6f9b3

+ 0 - 0
ehcache/.lock


+ 2 - 2
src/main/java/com/sundata/internalevaluation/configuration/controller/SysInterfaceController.java

@@ -87,8 +87,8 @@ public class SysInterfaceController {
 
         SysInterface sysInterface = sysReqInterfaceService.getById(sysReqInterface.getId());
         CalcTaskResult calc = CalcUtil.calc("interface:" + System.currentTimeMillis(),
-                new InterfaceCalcUnit(sysInterface.getId(), sysInterface.getInterfaceName(), CalcType.INTERFACE, Map.of(), sysInterface),
-                null);
+                new InterfaceCalcUnit(sysInterface.getId(), sysInterface.getInterfaceName(), CalcType.INTERFACE, Map.of("age",33), sysInterface),
+                Map.of("name","zhangsan"));
         return calc;
     }
     

+ 10 - 0
src/main/java/com/sundata/internalevaluation/configuration/model/SysReqRule.java

@@ -38,6 +38,8 @@ public class SysReqRule {
 
     private List<String> indexNoList;
 
+    private List<SysRuleIndex> ruleIndexList;
+
     public List<String> getIndexNoList() {
         return indexNoList;
     }
@@ -46,6 +48,14 @@ public class SysReqRule {
         this.indexNoList = indexNoList;
     }
 
+    public List<SysRuleIndex> getRuleIndexList() {
+        return ruleIndexList;
+    }
+
+    public void setRuleIndexList(List<SysRuleIndex> ruleIndexList) {
+        this.ruleIndexList = ruleIndexList;
+    }
+
     /**
      * 规则结论模板
      */

+ 10 - 0
src/main/java/com/sundata/internalevaluation/configuration/model/SysRuleIndex.java

@@ -13,6 +13,8 @@ public class SysRuleIndex {
 
     private String indexNo;
 
+    private String ruleLogicParam;
+
 
     public SysRuleIndex() {
     }
@@ -22,6 +24,14 @@ public class SysRuleIndex {
         this.indexNo = indexNo;
     }
 
+    public String getRuleLogicParam() {
+        return ruleLogicParam;
+    }
+
+    public void setRuleLogicParam(String ruleLogicParam) {
+        this.ruleLogicParam = ruleLogicParam;
+    }
+
     /**
      * 获取
      * @return ruleNo

+ 22 - 6
src/main/java/com/sundata/internalevaluation/configuration/mybatis/SysReqRuleMapper.xml

@@ -10,6 +10,13 @@
         <result column="RULE_RESULT" property="ruleResult"/>
         <result column="RULE_INDEX" property="ruleIndex"/>
         <result column="RULE_THRESHOLD" property="ruleThreshold"/>
+        <collection property="ruleIndexList" resultMap="ruleIndexBaseMap" />
+    </resultMap>
+
+    <resultMap id="ruleIndexBaseMap" type="com.sundata.internalevaluation.configuration.model.SysRuleIndex">
+        <result column="indexNo" property="indexNo"/>
+        <result column="ruleLogicParam" property="ruleLogicParam"/>
+        <result column="ruleNo" property="ruleNo"/>
     </resultMap>
 
     <!-- 表字段 -->
@@ -49,11 +56,20 @@
     </select>
 
     <!-- 根据主键获取单条记录 -->
-    <select id="getById" resultMap="BaseResultMap" parameterType="String">
-        SELECT
-        <include refid="baseColumns"/>
-        FROM SYS_REQ_RULE t
-        WHERE RULE_NO = #{ruleNo}
+    <select id="getById" resultMap="BaseResultMap" parameterType="string">
+        SELECT t.RULE_NO,
+               t.RULE_NAME,
+               t.RULE_TEMPLATE,
+               t.RULE_CONCLUSION_TEMPLATE,
+               t.TEMPLATE_DESC,
+               t.RULE_RESULT,
+               t.RULE_INDEX,
+               t.RULE_THRESHOLD,
+               ri.index_No AS indexNo,
+               ri.rule_Logic_Param AS ruleLogicParam,
+               ri.rule_No AS ruleNo
+        FROM SYS_REQ_RULE t left join SYS_REQ_RULE_INDEX ri on t.rule_No = ri.rule_No
+        WHERE t.RULE_NO = #{ruleNo}
     </select>
 
     <!-- 插入不为NULL的字段 -->
@@ -189,7 +205,7 @@
     <insert id="insertIndexList" parameterType="java.util.List">
         INSERT ALL
         <foreach collection="list" item="item" >
-            into SYS_REQ_RULE_INDEX (RULE_NO,INDEX_NO) values (#{item.ruleNo},#{item.indexNo})
+            into SYS_REQ_RULE_INDEX (RULE_NO,INDEX_NO,RULE_LOGIC_PARAM) values (#{item.ruleNo},#{item.indexNo},#{item.ruleLogicParam})
         </foreach>
         SELECT 1 FROM dual
     </insert>

+ 24 - 7
src/main/java/com/sundata/internalevaluation/configuration/service/SysReqRuleService.java

@@ -1,6 +1,7 @@
 package com.sundata.internalevaluation.configuration.service;
 
 import com.sundata.common.exception.BusinessException;
+import com.sundata.common.util.StringUtil;
 import com.sundata.internalevaluation.configuration.mapper.SysReqRuleMapper;
 import com.sundata.internalevaluation.configuration.mapper.SysReqRulesMapper;
 import com.sundata.internalevaluation.configuration.model.SysReqRule;
@@ -13,7 +14,6 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.util.List;
-import java.util.stream.Collectors;
 
 @Service
 public class SysReqRuleService {
@@ -58,15 +58,28 @@ public class SysReqRuleService {
      * @return 返回影响行数
      */
     public int insertIgnoreNull(SysReqRule sysReqRule) {
+        String ruleNo = sysReqRule.getRuleNo();
+        if (StringUtil.isEmpty(ruleNo)) {
+            throw new BusinessException("规则编码不能为空.");
+        }
         try {
-            sysReqRuleMapper.deleteIndexByRuleNo(sysReqRule.getRuleNo());
-            List<SysRuleIndex> list = sysReqRule.getIndexNoList().stream().map(indexNo -> new SysRuleIndex(sysReqRule.getRuleNo(), indexNo)).collect(Collectors.toList());
-            sysReqRuleMapper.insertIndexList(list);
+            sysReqRuleMapper.deleteIndexByRuleNo(ruleNo);
+            List<SysRuleIndex> ruleIndexList = sysReqRule.getRuleIndexList();
+            ruleIndexList.forEach(ruleIndex -> ruleIndex.setRuleNo(ruleNo));
+//            List<SysRuleIndex> list = sysReqRule.getIndexNoList().stream().map(indexNo -> new SysRuleIndex(sysReqRule.getRuleNo(), indexNo)).collect(Collectors.toList());
+            insertIndexList(ruleIndexList);
             return sysReqRuleMapper.insertIgnoreNull(sysReqRule);
         } catch (DuplicateKeyException e) {
             throw new BusinessException("规则编码已存在,请重新输入.");
         }
     }
+
+    public int insertIndexList(List<SysRuleIndex> list){
+        if (list == null || list.isEmpty()) {
+            return 0;
+        }
+        return sysReqRuleMapper.insertIndexList(list);
+    }
 	
 
 
@@ -79,9 +92,13 @@ public class SysReqRuleService {
     @Transactional
     public int updateIgnoreNull(SysReqRule sysReqRule) {
 
-        sysReqRuleMapper.deleteIndexByRuleNo(sysReqRule.getRuleNo());
-        List<SysRuleIndex> list = sysReqRule.getIndexNoList().stream().map(indexNo -> new SysRuleIndex(sysReqRule.getRuleNo(), indexNo)).collect(Collectors.toList());
-        sysReqRuleMapper.insertIndexList(list);
+        String ruleNo = sysReqRule.getRuleNo();
+        sysReqRuleMapper.deleteIndexByRuleNo(ruleNo);
+
+        List<SysRuleIndex> ruleIndexList = sysReqRule.getRuleIndexList();
+        ruleIndexList.forEach(ruleIndex -> ruleIndex.setRuleNo(ruleNo));
+//        List<SysRuleIndex> list = sysReqRule.getIndexNoList().stream().map(indexNo -> new SysRuleIndex(sysReqRule.getRuleNo(), indexNo)).collect(Collectors.toList());
+        insertIndexList(ruleIndexList);
         return sysReqRuleMapper.updateIgnoreNull(sysReqRule);
 
     }