Kaynağa Gözat

核心线程数优化

0027005599 1 yıl önce
ebeveyn
işleme
6fc33ea5a3

+ 5 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/Constant.java

@@ -184,4 +184,9 @@ public class Constant {
      * 规则年龄单位为天的字典key
      */
     public static final String DICT_RULE_ID_AGE_DAYS_KEY = "RULE_ID_AGE_DAYS";
+
+    /**
+     * SPEL引擎执行日志
+     */
+    public static final String SPEL_LOG = "SPEL_LOG";
 }

+ 29 - 30
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/ruleengine/RuleEngine.java

@@ -201,13 +201,22 @@ public class RuleEngine {
     public void initFactor(){
         LambdaQueryWrapper<RuleFactorRela> query = new LambdaQueryWrapper<RuleFactorRela>();
         query.eq(RuleFactorRela::getDelFlag, CommonConstant.DEL_FLAG_0);
-//        query.in(RuleFactorRela::getMedicalInsRuleInfoId, medicalInsRuleInfoIdList);
         query.orderByAsc(RuleFactorRela::getSeqNum);
         List<RuleFactorRela> ruleFactorRelaList = ruleFactorRelaService.list(query);
         ruleIdAndFatorEnchanceIdMap = ruleFactorRelaList.stream().collect(Collectors.groupingBy(RuleFactorRela::getMedicalInsRuleInfoId));
         Set<Integer> factorEnchangeIdList = ruleFactorRelaList.stream().map(RuleFactorRela::getFactorEnhanceId).collect(Collectors.toSet());
         List<FactorEnchance> factorEnchanceList = factorEnchanceService.listByIds(factorEnchangeIdList);
-        allEnchanceTypeMap = factorEnchanceList.stream().collect(Collectors.groupingBy(FactorEnchance::getFactorCatalog));
+        Map<Integer, FactorEnchance> integerFactorEnchanceMap = factorEnchanceList.stream().collect(Collectors.toMap(FactorEnchance::getId, v -> v, (v1, v2) -> v1));
+        for(RuleFactorRela ruleFactorRela : ruleFactorRelaList){
+            FactorEnchance factorEnchance = integerFactorEnchanceMap.get(ruleFactorRela.getFactorEnhanceId());
+            if(allEnchanceTypeMap.containsKey(ruleFactorRela.getMedicalInsRuleInfoId())){
+                allEnchanceTypeMap.get(ruleFactorRela.getMedicalInsRuleInfoId()).add(factorEnchance);
+            }else{
+                List<FactorEnchance> ruleIdFactorEnchanceList = new ArrayList<>();
+                ruleIdFactorEnchanceList.add(factorEnchance);
+                allEnchanceTypeMap.put(ruleFactorRela.getMedicalInsRuleInfoId(), ruleIdFactorEnchanceList);
+            }
+        }
 
     }
 
@@ -312,9 +321,7 @@ public class RuleEngine {
     }
 
 
-    //    public boolean initTestMedicalInsRule(String medicalProjectCode, AfterwardsAuditDetail afterwardsAuditDetail,List<MedicalInsRuleInfo> medicalInsRuleInfoList,Map<Integer, MedicalInsRuleInfo> medicalMap,Map<String, Boolean> codeDataMap) {
-//        return genItemCodeAndRuleIdMapTest(medicalProjectCode, medicalMap, afterwardsAuditDetail, medicalInsRuleInfoList);
-//    }
+
     public void genItemCodeAndRuleIdMapTest(String medicalProjectCode, AfterwardsAuditDetail afterwardsAuditDetail, List<MedicalInsRuleInfo> medicalInsRuleInfoList, Map<Integer, MedicalInsRuleInfo> medicalMap, Map<String, Boolean> codeDataMap) {
         try {
             List<Integer> ruleIdList = medicalInsRuleInfoList.stream().map(MedicalInsRuleInfo::getId).collect(Collectors.toList());
@@ -486,7 +493,8 @@ public class RuleEngine {
                 return Result.ok();
             }
             for (Integer medicalRuleInsInfoId : advanceWaringRuleIdList) {
-                MedicalInsRuleInfo medicalInsRuleInfo = medicalInsRuleInfoService.getById(medicalRuleInsInfoId);
+//                MedicalInsRuleInfo medicalInsRuleInfo = medicalInsRuleInfoService.getById(medicalRuleInsInfoId);
+                MedicalInsRuleInfo medicalInsRuleInfo = allMedicalMap.get(medicalRuleInsInfoId);
                 paramMap.put(SystemEventAttrConstant.PRE_ADVANCEWARNINGAUDIT_ID_KEY, advanceWarningAudit.getId());
                 runAdvanceWaringEngine(paramMap, medicalInsRuleInfo, advanceWarningAudit);
             }
@@ -677,7 +685,7 @@ public class RuleEngine {
                     if (CollectionUtil.isEmpty(diagnoseMedicalInsRuleInfoIdList)) {
                         medicalInsRuleProjectTempList = medicalInsRuleProjectService.getRuleProjectByDiagCode(diagnose.toString());
                         if(CollectionUtil.isEmpty(medicalInsRuleProjectTempList)){
-                            log.info("诊断编码未匹配到对应的医保规则:{} 在规则库数据库中未检索到数据,退出规则执行", diagnose);
+                            log.info("诊断编码未匹配到对应的医保规则:{} 在规则库数据库中未检索到数据", diagnose);
                         }
                         Set<Integer> medicalInsRuleInfoIdDiagSet = medicalInsRuleProjectTempList.stream().map(MedicalInsRuleProject::getMedicalInsRuleInfoId).collect(Collectors.toSet());
                         log.info("数据库检索到匹配规则ID列表:{} 诊断编码为:{}", medicalInsRuleInfoIdDiagSet, diagnose);
@@ -776,7 +784,7 @@ public class RuleEngine {
                 if (CollectionUtil.isEmpty(diagnoseMedicalInsRuleInfoIdList)) {
                     medicalInsRuleProjectTempList = medicalInsRuleProjectService.getRuleProjectByDiagCode(diagnose.toString());
                     if(CollectionUtil.isEmpty(medicalInsRuleProjectTempList)){
-                        log.info("诊断编码未匹配到对应的医保规则:{} 在规则库数据库中未检索到数据,退出规则执行", diagnose);
+                        log.info("诊断编码未匹配到对应的医保规则:{} 在规则库数据库中未检索到数据", diagnose);
                     }
                     Set<Integer> medicalInsRuleInfoIdDiagSet = medicalInsRuleProjectTempList.stream().map(MedicalInsRuleProject::getMedicalInsRuleInfoId).collect(Collectors.toSet());
                     log.info("数据库检索到匹配规则ID列表:{} 诊断编码为:{}", medicalInsRuleInfoIdDiagSet, diagnose);
@@ -1093,29 +1101,20 @@ public class RuleEngine {
             log.error("未有对应的规则,接口数据:{}", paramMap);
             return;
         }
-        LambdaQueryWrapper<RuleFactorRela> query = new LambdaQueryWrapper<RuleFactorRela>();
-        query.eq(RuleFactorRela::getDelFlag, CommonConstant.DEL_FLAG_0);
-        query.eq(RuleFactorRela::getMedicalInsRuleInfoId, medicalInsRuleInfo.getId());
-        query.orderByAsc(RuleFactorRela::getSeqNum);
-        List<RuleFactorRela> ruleFactorRelaList = ruleFactorRelaService.list(query);
-
-        if (CollectionUtil.isNotEmpty(ruleFactorRelaList)) {
-            Set<Integer> factorEnchangeIdList = ruleFactorRelaList.stream().map(RuleFactorRela::getFactorEnhanceId).collect(Collectors.toSet());
-            List<FactorEnchance> factorEnchanceList = factorEnchanceService.listByIds(factorEnchangeIdList);
-            Map<Integer, List<FactorEnchance>> enchanceTypeMap = factorEnchanceList.stream().collect(Collectors.groupingBy(FactorEnchance::getFactorCatalog));
-            for (Integer medicalRuleInsInfoId : enchanceTypeMap.keySet()) {
-                try {
-                    List<FactorEnchance> factorEnchanceListTemp = enchanceTypeMap.get(medicalRuleInsInfoId);
-                    paramMap.put(SystemEventAttrConstant.MEDICAL_INS_RULE_INFO_ID, medicalRuleInsInfoId);
-                    paramMap.put(SystemEventAttrConstant.MEDICAL_INS_RULE_INFO_CODE, medicalInsRuleInfo.getRuleCode());
-                    paramMap.put(SystemEventAttrConstant.MEDICAL_INS_RULE_INFO_NAME, medicalInsRuleInfo.getRuleName());
-                    paramMap.put(SystemEventAttrConstant.MEDICAL_INS_RULE_INFO_DESC, medicalInsRuleInfo.getDescription());
-                    factorEnchangeFactory.runFactorEnchange(medicalRuleInsInfoId, medicalInsRuleInfo, audit, paramMap, ruleFactorRelaList, factorEnchanceListTemp, null);
-                }catch (Exception e){
-                    log.error(e.getMessage(), e);
-                }
-            }
+        Integer medicalRuleInsInfoId = medicalInsRuleInfo.getId();
+        List<RuleFactorRela> ruleFactorRelaList = ruleIdAndFatorEnchanceIdMap.get(medicalRuleInsInfoId);
+        List<FactorEnchance> factorEnchanceList = allEnchanceTypeMap.get(medicalRuleInsInfoId);
+        try {
+            paramMap.put(SystemEventAttrConstant.MEDICAL_INS_RULE_INFO_ID, medicalRuleInsInfoId);
+            paramMap.put(SystemEventAttrConstant.MEDICAL_INS_RULE_INFO_CODE, medicalInsRuleInfo.getRuleCode());
+            paramMap.put(SystemEventAttrConstant.MEDICAL_INS_RULE_INFO_NAME, medicalInsRuleInfo.getRuleName());
+            paramMap.put(SystemEventAttrConstant.MEDICAL_INS_RULE_INFO_DESC, medicalInsRuleInfo.getDescription());
+            factorEnchangeFactory.runFactorEnchange(medicalRuleInsInfoId, medicalInsRuleInfo, audit, paramMap, ruleFactorRelaList, factorEnchanceList, null);
+        }catch (Exception e){
+            log.error(e.getMessage(), e);
         }
+
+
     }
 
     /**

+ 11 - 11
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/ruleengine/SPELUtil.java

@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
 import org.jeecg.modules.medical.ColumnTypeEnum;
+import org.jeecg.modules.medical.Constant;
 import org.jeecg.modules.medical.entity.EventAttr;
 import org.jeecg.modules.medical.entity.FactorCondRela;
 import org.jeecg.modules.medical.service.IEventAttrService;
@@ -135,22 +136,22 @@ public class SPELUtil {
         Object defResult = null;
         try {
             defResult = expression.getValue(ctx);
-        }catch (Exception e){
+        } catch (Exception e) {
             log.error("执行语句:{} 数据对象:{}", condStr, contentMap);
             log.error(e.getMessage(), e);
-            throw new Exception("执行失败el表达式:"+ condStr);
+            throw new Exception("执行失败el表达式:" + condStr);
         }
         log.info("执行语句:{} 执行结果:{}  ", condStr, defResult);
         log.info("执行语句:{} 执行结果:{} ", getCondStrAndParam(condStr, condStrParamName, contentMap), defResult);
-
+        contentMap.put(Constant.SPEL_LOG, getCondStrAndParam(condStr, condStrParamName, contentMap) + " " + defResult);
         return defResult;
     }
 
-    public static String getCondStrAndParam(String condStr, Set<String> condStrParamName,Map<String,Object> itemMap){
+    public static String getCondStrAndParam(String condStr, Set<String> condStrParamName, Map<String, Object> itemMap) {
 
-        for(String condStrParam : condStrParamName){
+        for (String condStrParam : condStrParamName) {
             Object replaceValue = itemMap.get(condStrParam);
-            if(null == replaceValue){
+            if (null == replaceValue) {
                 replaceValue = "[未找到该属性]";
             }
             condStr = condStr.replace(condStrParam, replaceValue.toString());
@@ -204,7 +205,7 @@ public class SPELUtil {
             Object inStr = inMap.get(mapKey);
             for (Map<String, Object> itemMap : memberList) {
                 Object itemValue = itemMap.get(listKey);
-                if(startWithKey(itemValue.toString(), inStr.toString())){
+                if (startWithKey(itemValue.toString(), inStr.toString())) {
                     return true;
                 }
             }
@@ -290,11 +291,10 @@ public class SPELUtil {
     }
 
 
-
     public static Boolean isMemberLeftObject(Object inValue, List<Object> memberList) {
 
         if (null != inValue && CollectionUtil.isNotEmpty(memberList)) {
-            if(inValue instanceof  List){
+            if (inValue instanceof List) {
                 List<Object> lList = (List<Object>) inValue;
                 for (Object value : lList) {
                     boolean flag = isMemberLeftObject(value, memberList);
@@ -306,8 +306,8 @@ public class SPELUtil {
             if (memberList.contains(inValue)) {
                 return true;
             }
-            for(Object member : memberList){
-                if(startWithKey(member.toString(), inValue.toString())){
+            for (Object member : memberList) {
+                if (startWithKey(member.toString(), inValue.toString())) {
                     return true;
                 }
             }

+ 4 - 4
jeecg-module-system/jeecg-system-start/src/main/resources/application-ybprod.yml

@@ -94,9 +94,9 @@ spring:
         enabled: true
     dynamic:
       druid:
-        initial-size: 5
-        min-idle: 5
-        maxActive: 20
+        initial-size: 20
+        min-idle: 20
+        maxActive: 120
         maxWait: 60000
         timeBetweenEvictionRunsMillis: 60000
         minEvictableIdleTimeMillis: 300000
@@ -228,7 +228,7 @@ third-app:
 cdr:
   threadpool:
     corePoolSize: 8
-    maxPoolSize: 20
+    maxPoolSize: 100
     keepAliveSeconds: 300
     queueCapacity: 100
     prefixName: async-service-

+ 1 - 4
jeecg-module-system/jeecg-system-start/src/main/resources/application.yml

@@ -8,7 +8,4 @@ cdr:
     corePoolSize: 6
     maxPoolSize: 100
     keepAliveSeconds: 60
-    queueCapacity: 500
-  record:
-    batchSize: 10000
-    bigFileSize: 10000
+    queueCapacity: 500