Bläddra i källkod

事后处理日志优化

0027005599 1 år sedan
förälder
incheckning
b5a476d626

+ 3 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/entity/AfterIncidentDetailLog.java

@@ -328,6 +328,9 @@ public class AfterIncidentDetailLog implements Serializable {
     @JsonProperty("medicalDiagnoseNameStr")
     @JSONField(name = "medicalDiagnoseNameStr")
     private java.lang.String medicalDiagnoseNameStr;
+
+
+    private java.lang.String errorDescription;
 	/**状态;WAITING,DEALING,SUCCESS,FAIL*/
 	@Excel(name = "状态;WAITING,DEALING,SUCCESS,FAIL", width = 15)
     @ApiModelProperty(value = "状态;WAITING,DEALING,SUCCESS,FAIL")

+ 4 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/ruleengine/FactorEnchangeFactory.java

@@ -13,6 +13,7 @@ import org.jeecg.modules.medical.EnchanceTypeEnum;
 import org.jeecg.modules.medical.SystemEventAttrConstant;
 import org.jeecg.modules.medical.entity.AdvanceWarningAudit;
 import org.jeecg.modules.medical.entity.AdvanceWarningAuditDetail;
+import org.jeecg.modules.medical.entity.AfterIncidentDetailLog;
 import org.jeecg.modules.medical.entity.AfterwardsAudit;
 import org.jeecg.modules.medical.entity.AfterwardsAuditDetail;
 import org.jeecg.modules.medical.entity.EventAttr;
@@ -26,6 +27,7 @@ import org.jeecg.modules.medical.entity.MidIncidentWarningVO;
 import org.jeecg.modules.medical.entity.RuleFactorRela;
 import org.jeecg.modules.medical.ruleengine.dict.DictUtil;
 import org.jeecg.modules.medical.service.IAdvanceWarningAuditDetailService;
+import org.jeecg.modules.medical.service.IAfterIncidentDetailLogService;
 import org.jeecg.modules.medical.service.IAfterwardsAuditDetailService;
 import org.jeecg.modules.medical.service.IAfterwardsAuditService;
 import org.jeecg.modules.medical.service.IEventAttrService;
@@ -79,6 +81,8 @@ public class FactorEnchangeFactory {
     @Autowired
     IAdvanceWarningAuditDetailService advanceWarningAuditDetailService;
     @Autowired
+    IAfterIncidentDetailLogService afterIncidentDetailLogService;
+    @Autowired
     SqlUtil sqlUtil;
     @Autowired
     RedisTemplate redisTemplate;

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

@@ -40,6 +40,7 @@ import org.jeecg.modules.medical.ruleengine.dict.DictUtil;
 import org.jeecg.modules.medical.ruleengine.plugin.InterfItemListPlugin;
 import org.jeecg.modules.medical.service.IAdvanceWarningAuditDetailService;
 import org.jeecg.modules.medical.service.IAdvanceWarningAuditService;
+import org.jeecg.modules.medical.service.IAfterIncidentDetailLogService;
 import org.jeecg.modules.medical.service.IAfterwardsAuditDetailService;
 import org.jeecg.modules.medical.service.IAfterwardsAuditService;
 import org.jeecg.modules.medical.service.IAfterwardsIncidentAuditDiagnoseService;
@@ -61,10 +62,6 @@ import org.jeecg.modules.message.websocket.WebSocket;
 import org.jeecg.modules.system.service.ISysDictService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
-import org.springframework.context.annotation.Conditional;
-import org.springframework.context.annotation.Profile;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Component;
@@ -138,6 +135,8 @@ public class RuleEngine {
     IDiagnoseItemsService diagnoseItemsService;
     @Autowired
     ISysDictService sysDictService;
+    @Autowired
+    IAfterIncidentDetailLogService afterIncidentDetailLogService;
 
     @Value("${cache.auto:false}")
     private Boolean cacheAutoInit;
@@ -184,21 +183,21 @@ public class RuleEngine {
 
     @PostConstruct
     public void initMedicalInsRuleAuto() {
-        if(cacheAutoInit) {
+        if (cacheAutoInit) {
             initMedicalInsRule();
         }
     }
 
-    public void initRuleDaysSet(){
+    public void initRuleDaysSet() {
         List<DictModel> ruleList = sysDictService.getDictItems(Constant.DICT_RULE_ID_AGE_DAYS_KEY);
-        if(CollectionUtil.isNotEmpty(ruleList)){
-            for(DictModel dictModel : ruleList){
+        if (CollectionUtil.isNotEmpty(ruleList)) {
+            for (DictModel dictModel : ruleList) {
                 daysRuleIdSet.add(Integer.parseInt(dictModel.getValue()));
             }
         }
     }
 
-    public void initFactor(){
+    public void initFactor() {
         LambdaQueryWrapper<RuleFactorRela> query = new LambdaQueryWrapper<RuleFactorRela>();
         query.eq(RuleFactorRela::getDelFlag, CommonConstant.DEL_FLAG_0);
         query.orderByAsc(RuleFactorRela::getSeqNum);
@@ -207,11 +206,11 @@ public class RuleEngine {
         Set<Integer> factorEnchangeIdList = ruleFactorRelaList.stream().map(RuleFactorRela::getFactorEnhanceId).collect(Collectors.toSet());
         List<FactorEnchance> factorEnchanceList = factorEnchanceService.listByIds(factorEnchangeIdList);
         Map<Integer, FactorEnchance> integerFactorEnchanceMap = factorEnchanceList.stream().collect(Collectors.toMap(FactorEnchance::getId, v -> v, (v1, v2) -> v1));
-        for(RuleFactorRela ruleFactorRela : ruleFactorRelaList){
+        for (RuleFactorRela ruleFactorRela : ruleFactorRelaList) {
             FactorEnchance factorEnchance = integerFactorEnchanceMap.get(ruleFactorRela.getFactorEnhanceId());
-            if(allEnchanceTypeMap.containsKey(ruleFactorRela.getMedicalInsRuleInfoId())){
+            if (allEnchanceTypeMap.containsKey(ruleFactorRela.getMedicalInsRuleInfoId())) {
                 allEnchanceTypeMap.get(ruleFactorRela.getMedicalInsRuleInfoId()).add(factorEnchance);
-            }else{
+            } else {
                 List<FactorEnchance> ruleIdFactorEnchanceList = new ArrayList<>();
                 ruleIdFactorEnchanceList.add(factorEnchance);
                 allEnchanceTypeMap.put(ruleFactorRela.getMedicalInsRuleInfoId(), ruleIdFactorEnchanceList);
@@ -321,7 +320,6 @@ public class RuleEngine {
     }
 
 
-
     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());
@@ -566,13 +564,13 @@ public class RuleEngine {
                 if (CollectionUtil.isEmpty(medicalInsRuleInfoIdList)) {
                     log.error("项目编码未匹配到对应的医保规则:{} 再次从数据库检索", itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY));
                     medicalInsRuleProjectList = medicalInsRuleProjectService.getRuleProjectByMedicalProjectCode(itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY).toString());
-                    if(CollectionUtil.isEmpty(medicalInsRuleProjectList)){
+                    if (CollectionUtil.isEmpty(medicalInsRuleProjectList)) {
                         log.error("项目编码未匹配到对应的医保规则:{} 在规则库数据库中未检索到数据", itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY));
-                    }else {
+                    } else {
                         medicalInsRuleInfoIdList = medicalInsRuleProjectList.stream().map(MedicalInsRuleProject::getMedicalInsRuleInfoId).collect(Collectors.toSet());
                         log.info("数据库检索到匹配规则ID列表:{}", medicalInsRuleInfoIdList);
                     }
-                }else{
+                } else {
                     medicalInsRuleProjectList = medicalInsRuleProjectService.getRuleProjectByRuleIdAndProjectCode(new ArrayList<>(medicalInsRuleInfoIdList), itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY).toString());
                 }
 
@@ -583,39 +581,39 @@ public class RuleEngine {
                     List<MedicalInsRuleProject> medicalInsRuleProjectTempList = null;
                     if (CollectionUtil.isEmpty(diagnoseMedicalInsRuleInfoIdList)) {
                         medicalInsRuleProjectTempList = medicalInsRuleProjectService.getRuleProjectByDiagCode(diagnose.toString());
-                        if(CollectionUtil.isEmpty(medicalInsRuleProjectTempList)){
+                        if (CollectionUtil.isEmpty(medicalInsRuleProjectTempList)) {
                             log.info("诊断编码未匹配到对应的医保规则:{} 在规则库数据库中未检索到数据", diagnose);
                         }
                         Set<Integer> medicalInsRuleInfoIdDiagSet = medicalInsRuleProjectTempList.stream().map(MedicalInsRuleProject::getMedicalInsRuleInfoId).collect(Collectors.toSet());
                         log.info("数据库检索到匹配规则ID列表:{} 诊断编码为:{}", medicalInsRuleInfoIdDiagSet, diagnose);
-                    }else{
+                    } else {
                         medicalInsRuleProjectTempList = medicalInsRuleProjectService.getRuleProjectByRuleIdAndDiagCode(new ArrayList<>(diagnoseMedicalInsRuleInfoIdList), diagnose.toString());
                     }
-                    if(CollectionUtil.isNotEmpty(medicalInsRuleProjectTempList)){
-                        if(CollectionUtil.isEmpty(medicalInsRuleProjectList)){
+                    if (CollectionUtil.isNotEmpty(medicalInsRuleProjectTempList)) {
+                        if (CollectionUtil.isEmpty(medicalInsRuleProjectList)) {
                             medicalInsRuleProjectList = new ArrayList<>();
                         }
-                        for(MedicalInsRuleProject medicalInsRuleProject : medicalInsRuleProjectTempList){
+                        for (MedicalInsRuleProject medicalInsRuleProject : medicalInsRuleProjectTempList) {
                             MedicalInsRuleInfo projectRuleInfo = allMedicalMap.get(medicalInsRuleProject.getMedicalInsRuleInfoId());
                             String selectedRoles = projectRuleInfo.getSelectedRoles();
                             if (StringUtils.isNotBlank(selectedRoles)) {
                                 String[] selectedRolesArr = selectedRoles.split(",");
                                 boolean diagnoseFlag = Arrays.stream(selectedRolesArr).anyMatch(attr -> attr.equals("medicalDiagnoseCode"));
                                 boolean projectCodeFlag = Arrays.stream(selectedRolesArr).anyMatch(attr -> attr.equals("projectCode"));
-                                if(diagnoseFlag && !projectCodeFlag){
+                                if (diagnoseFlag && !projectCodeFlag) {
                                     medicalInsRuleProjectList.add(medicalInsRuleProject);
                                 }
                             }
                         }
                     }
                 }
-                if(CollectionUtil.isEmpty(medicalInsRuleProjectList)){
+                if (CollectionUtil.isEmpty(medicalInsRuleProjectList)) {
                     log.error("项目编码未匹配到对应的医保规则:{} 在规则库数据库中未检索到数据,退出规则执行", itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY));
                     continue;
                 }
-                Map<Integer,List<MedicalInsRuleProject>> ruleAndProjectMap = medicalInsRuleProjectList.stream().collect(Collectors.groupingBy(MedicalInsRuleProject::getMedicalInsRuleInfoId));
+                Map<Integer, List<MedicalInsRuleProject>> ruleAndProjectMap = medicalInsRuleProjectList.stream().collect(Collectors.groupingBy(MedicalInsRuleProject::getMedicalInsRuleInfoId));
                 paramMap.put(SystemEventAttrConstant.ADVICE_DETAILS_LIST_KEY, itemList);
-                for(Integer medicalInsRuleInfoId : ruleAndProjectMap.keySet()){
+                for (Integer medicalInsRuleInfoId : ruleAndProjectMap.keySet()) {
                     List<String> medicalInsCorrProjectCodeList = ruleAndProjectMap.get(medicalInsRuleInfoId).stream().map(MedicalInsRuleProject::getCorrelationProjectCode).collect(Collectors.toList());
                     MedicalInsRuleProject medicalInsRuleProject = ruleAndProjectMap.get(medicalInsRuleInfoId).get(0);
                     setProjectToLocalMap(itemMap, medicalInsRuleProject);
@@ -624,7 +622,7 @@ public class RuleEngine {
                     boolean sendFlagTemp = false;
                     try {
                         sendFlagTemp = runMidEngine(itemMap, medicalInsRuleInfoId, midIncidentAudit, itemList);
-                    }catch (Exception e){
+                    } catch (Exception e) {
                         log.error(e.getMessage(), e);
                     }
                     sendFlag = sendFlagTemp || sendFlag;
@@ -668,13 +666,13 @@ public class RuleEngine {
                 if (CollectionUtil.isEmpty(medicalInsRuleInfoIdList)) {
                     log.error("项目编码未匹配到对应的医保规则:{} 再次从数据库检索", itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY));
                     medicalInsRuleProjectList = medicalInsRuleProjectService.getRuleProjectByMedicalProjectCode(itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY).toString());
-                    if(CollectionUtil.isEmpty(medicalInsRuleProjectList)){
+                    if (CollectionUtil.isEmpty(medicalInsRuleProjectList)) {
                         log.error("项目编码未匹配到对应的医保规则:{} 在规则库数据库中未检索到数据", itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY));
-                    }else {
+                    } else {
                         medicalInsRuleInfoIdList = medicalInsRuleProjectList.stream().map(MedicalInsRuleProject::getMedicalInsRuleInfoId).collect(Collectors.toSet());
                         log.info("数据库检索到匹配规则ID列表:{}", medicalInsRuleInfoIdList);
                     }
-                }else{
+                } else {
                     medicalInsRuleProjectList = medicalInsRuleProjectService.getRuleProjectByRuleIdAndProjectCode(new ArrayList<>(medicalInsRuleInfoIdList), itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY).toString());
                 }
                 Object diagnose = itemMap.get(Constant.MEDICAL_DIAGNOSE_CODE_KEY);
@@ -684,39 +682,39 @@ public class RuleEngine {
                     List<MedicalInsRuleProject> medicalInsRuleProjectTempList = null;
                     if (CollectionUtil.isEmpty(diagnoseMedicalInsRuleInfoIdList)) {
                         medicalInsRuleProjectTempList = medicalInsRuleProjectService.getRuleProjectByDiagCode(diagnose.toString());
-                        if(CollectionUtil.isEmpty(medicalInsRuleProjectTempList)){
+                        if (CollectionUtil.isEmpty(medicalInsRuleProjectTempList)) {
                             log.info("诊断编码未匹配到对应的医保规则:{} 在规则库数据库中未检索到数据", diagnose);
                         }
                         Set<Integer> medicalInsRuleInfoIdDiagSet = medicalInsRuleProjectTempList.stream().map(MedicalInsRuleProject::getMedicalInsRuleInfoId).collect(Collectors.toSet());
                         log.info("数据库检索到匹配规则ID列表:{} 诊断编码为:{}", medicalInsRuleInfoIdDiagSet, diagnose);
-                    }else{
+                    } else {
                         medicalInsRuleProjectTempList = medicalInsRuleProjectService.getRuleProjectByRuleIdAndDiagCode(new ArrayList<>(diagnoseMedicalInsRuleInfoIdList), diagnose.toString());
                     }
-                    if(CollectionUtil.isNotEmpty(medicalInsRuleProjectTempList)){
-                        if(CollectionUtil.isEmpty(medicalInsRuleProjectList)){
+                    if (CollectionUtil.isNotEmpty(medicalInsRuleProjectTempList)) {
+                        if (CollectionUtil.isEmpty(medicalInsRuleProjectList)) {
                             medicalInsRuleProjectList = new ArrayList<>();
                         }
-                        for(MedicalInsRuleProject medicalInsRuleProject : medicalInsRuleProjectTempList){
+                        for (MedicalInsRuleProject medicalInsRuleProject : medicalInsRuleProjectTempList) {
                             MedicalInsRuleInfo projectRuleInfo = allMedicalMap.get(medicalInsRuleProject.getMedicalInsRuleInfoId());
                             String selectedRoles = projectRuleInfo.getSelectedRoles();
                             if (StringUtils.isNotBlank(selectedRoles)) {
                                 String[] selectedRolesArr = selectedRoles.split(",");
                                 boolean diagnoseFlag = Arrays.stream(selectedRolesArr).anyMatch(attr -> attr.equals("medicalDiagnoseCode"));
                                 boolean projectCodeFlag = Arrays.stream(selectedRolesArr).anyMatch(attr -> attr.equals("projectCode"));
-                                if(diagnoseFlag && !projectCodeFlag){
+                                if (diagnoseFlag && !projectCodeFlag) {
                                     medicalInsRuleProjectList.add(medicalInsRuleProject);
                                 }
                             }
                         }
                     }
                 }
-                if(CollectionUtil.isEmpty(medicalInsRuleProjectList)){
+                if (CollectionUtil.isEmpty(medicalInsRuleProjectList)) {
                     log.error("项目编码未匹配到对应的医保规则:{} 在规则库数据库中未检索到数据,退出规则执行", itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY));
                     continue;
                 }
-                Map<Integer,List<MedicalInsRuleProject>> ruleAndProjectMap = medicalInsRuleProjectList.stream().collect(Collectors.groupingBy(MedicalInsRuleProject::getMedicalInsRuleInfoId));
+                Map<Integer, List<MedicalInsRuleProject>> ruleAndProjectMap = medicalInsRuleProjectList.stream().collect(Collectors.groupingBy(MedicalInsRuleProject::getMedicalInsRuleInfoId));
                 paramMap.put(SystemEventAttrConstant.ADVICE_DETAILS_LIST_KEY, itemList);
-                for(Integer medicalInsRuleInfoId : ruleAndProjectMap.keySet()){
+                for (Integer medicalInsRuleInfoId : ruleAndProjectMap.keySet()) {
                     List<String> medicalInsCorrProjectCodeList = ruleAndProjectMap.get(medicalInsRuleInfoId).stream().map(MedicalInsRuleProject::getCorrelationProjectCode).collect(Collectors.toList());
                     MedicalInsRuleProject medicalInsRuleProject = ruleAndProjectMap.get(medicalInsRuleInfoId).get(0);
                     setProjectToLocalMap(itemMap, medicalInsRuleProject);
@@ -725,7 +723,7 @@ public class RuleEngine {
                     boolean sendFlagTemp = false;
                     try {
                         sendFlagTemp = runMidEngine(itemMap, medicalInsRuleInfoId, midIncidentAudit, itemList);
-                    }catch (Exception e){
+                    } catch (Exception e) {
                         log.error(e.getMessage(), e);
                     }
                     sendFlag = sendFlagTemp || sendFlag;
@@ -767,13 +765,13 @@ public class RuleEngine {
             if (CollectionUtil.isEmpty(medicalInsRuleInfoIdList)) {
                 log.error("项目编码未匹配到对应的医保规则:{} 再次从数据库检索", itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY));
                 medicalInsRuleProjectList = medicalInsRuleProjectService.getRuleProjectByMedicalProjectCode(itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY).toString());
-                if(CollectionUtil.isEmpty(medicalInsRuleProjectList)){
+                if (CollectionUtil.isEmpty(medicalInsRuleProjectList)) {
                     log.error("项目编码未匹配到对应的医保规则:{} 在规则库数据库中未检索到数据", itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY));
-                }else {
+                } else {
                     medicalInsRuleInfoIdList = medicalInsRuleProjectList.stream().map(MedicalInsRuleProject::getMedicalInsRuleInfoId).collect(Collectors.toSet());
                     log.info("数据库检索到匹配规则ID列表:{}", medicalInsRuleInfoIdList);
                 }
-            }else{
+            } else {
                 medicalInsRuleProjectList = medicalInsRuleProjectService.getRuleProjectByRuleIdAndProjectCode(new ArrayList<>(medicalInsRuleInfoIdList), itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY).toString());
             }
             Object diagnose = itemMap.get(Constant.MEDICAL_DIAGNOSE_CODE_KEY);
@@ -783,47 +781,60 @@ public class RuleEngine {
                 List<MedicalInsRuleProject> medicalInsRuleProjectTempList = null;
                 if (CollectionUtil.isEmpty(diagnoseMedicalInsRuleInfoIdList)) {
                     medicalInsRuleProjectTempList = medicalInsRuleProjectService.getRuleProjectByDiagCode(diagnose.toString());
-                    if(CollectionUtil.isEmpty(medicalInsRuleProjectTempList)){
+                    if (CollectionUtil.isEmpty(medicalInsRuleProjectTempList)) {
                         log.info("诊断编码未匹配到对应的医保规则:{} 在规则库数据库中未检索到数据", diagnose);
                     }
                     Set<Integer> medicalInsRuleInfoIdDiagSet = medicalInsRuleProjectTempList.stream().map(MedicalInsRuleProject::getMedicalInsRuleInfoId).collect(Collectors.toSet());
                     log.info("数据库检索到匹配规则ID列表:{} 诊断编码为:{}", medicalInsRuleInfoIdDiagSet, diagnose);
-                }else{
+                } else {
                     medicalInsRuleProjectTempList = medicalInsRuleProjectService.getRuleProjectByRuleIdAndDiagCode(new ArrayList<>(diagnoseMedicalInsRuleInfoIdList), diagnose.toString());
                 }
-                if(CollectionUtil.isNotEmpty(medicalInsRuleProjectTempList)){
-                    if(CollectionUtil.isEmpty(medicalInsRuleProjectList)){
+                if (CollectionUtil.isNotEmpty(medicalInsRuleProjectTempList)) {
+                    if (CollectionUtil.isEmpty(medicalInsRuleProjectList)) {
                         medicalInsRuleProjectList = new ArrayList<>();
                     }
-                    for(MedicalInsRuleProject medicalInsRuleProject : medicalInsRuleProjectTempList){
+                    for (MedicalInsRuleProject medicalInsRuleProject : medicalInsRuleProjectTempList) {
                         MedicalInsRuleInfo projectRuleInfo = allMedicalMap.get(medicalInsRuleProject.getMedicalInsRuleInfoId());
                         String selectedRoles = projectRuleInfo.getSelectedRoles();
                         if (StringUtils.isNotBlank(selectedRoles)) {
                             String[] selectedRolesArr = selectedRoles.split(",");
                             boolean diagnoseFlag = Arrays.stream(selectedRolesArr).anyMatch(attr -> attr.equals("medicalDiagnoseCode"));
                             boolean projectCodeFlag = Arrays.stream(selectedRolesArr).anyMatch(attr -> attr.equals("projectCode"));
-                            if(diagnoseFlag && !projectCodeFlag){
+                            if (diagnoseFlag && !projectCodeFlag) {
                                 medicalInsRuleProjectList.add(medicalInsRuleProject);
                             }
                         }
                     }
                 }
             }
-            if(CollectionUtil.isEmpty(medicalInsRuleProjectList)){
+            if (CollectionUtil.isEmpty(medicalInsRuleProjectList)) {
                 log.error("项目编码未匹配到对应的医保规则:{} 在规则库数据库中未检索到数据,退出执行规则", itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY));
+                afterIncidentDetailLogService.lambdaUpdate().set(AfterIncidentDetailLog::getErrorDescription, "项目编码未匹配到对应的医保规则 在规则库数据库中未检索到数据,退出执行规则")
+                        .set(AfterIncidentDetailLog::getState, Constant.FAIL)
+                        .eq(AfterIncidentDetailLog::getId, afterIncidentDetailLog.getId()).update();
                 return;
             }
-            Map<Integer,List<MedicalInsRuleProject>> ruleAndProjectMap = medicalInsRuleProjectList.stream().collect(Collectors.groupingBy(MedicalInsRuleProject::getMedicalInsRuleInfoId));
+            Map<Integer, List<MedicalInsRuleProject>> ruleAndProjectMap = medicalInsRuleProjectList.stream().collect(Collectors.groupingBy(MedicalInsRuleProject::getMedicalInsRuleInfoId));
             log.info("明细记录ID:{} 匹配到规则:{}", afterIncidentDetailLog.getId(), ruleAndProjectMap.keySet());
-            for(Integer medicalInsRuleInfoId : ruleAndProjectMap.keySet()){
+            for (Integer medicalInsRuleInfoId : ruleAndProjectMap.keySet()) {
                 List<String> medicalInsCorrProjectCodeList = ruleAndProjectMap.get(medicalInsRuleInfoId).stream().map(MedicalInsRuleProject::getCorrelationProjectCode).collect(Collectors.toList());
                 MedicalInsRuleProject medicalInsRuleProject = ruleAndProjectMap.get(medicalInsRuleInfoId).get(0);
                 setProjectToLocalMap(itemMap, medicalInsRuleProject);
                 itemMap.put(SystemEventAttrConstant.MEDICAL_INS_CORRELATIONMEDICALDIAGNOSECODE, medicalInsCorrProjectCodeList);
                 setItemCodeListToItemMap(itemList, itemMap);
-                runAfterEngine(itemMap, medicalInsRuleInfoId, afterwardsAudit, itemList);
+                MedicalInsRuleInfo medicalInsRuleInfo = allMedicalMap.get(medicalInsRuleInfoId);
+                boolean auditFlag = runAfterEngine(itemMap, medicalInsRuleInfoId, afterwardsAudit, itemList);
+                if (Constant.VALIDATION_HANDER_METHOD_RETURN.equals(medicalInsRuleInfo.getViolationHandingMethod()) && auditFlag) {
+                    log.error("事后提醒数据:{} 规则名:{} 触发诊断类规则,直接全金额,后续规则无需再跑", itemMap, medicalInsRuleInfo);
+                    String description = "触发诊断类规则,直接全金额,后续规则无需再跑,规则ID:" + medicalInsRuleInfo.getId();
+                    itemMap.put(Constant.SPEL_LOG, description);
+                    break;
+                }
             }
-
+            Object description = itemMap.get(Constant.SPEL_LOG);
+            afterIncidentDetailLogService.lambdaUpdate().set(AfterIncidentDetailLog::getErrorDescription, description)
+                    .set(AfterIncidentDetailLog::getState, Constant.SUCCESS)
+                    .eq(AfterIncidentDetailLog::getId, afterIncidentDetailLog.getId()).update();
         } catch (Exception e) {
             log.error(e.getMessage(), e);
         }
@@ -833,11 +844,11 @@ public class RuleEngine {
     /**
      * 把当前明细记录的主单下的所有项目编码设置到当前项目记录
      */
-    public void setItemCodeListToItemMap(List<Map<String,Object>> itemList, Map<String,Object> itemMap){
+    public void setItemCodeListToItemMap(List<Map<String, Object>> itemList, Map<String, Object> itemMap) {
         List<String> medicalProjectCodeList = new ArrayList<>();
-        for(Map<String,Object> itemTempMap : itemList){
+        for (Map<String, Object> itemTempMap : itemList) {
             Object medicalProjectCode = itemTempMap.get(SystemEventAttrConstant.MEDICAL_PROJECT_CODE_KEY);
-            if(null != medicalProjectCode){
+            if (null != medicalProjectCode) {
                 medicalProjectCodeList.add(medicalProjectCode.toString());
             }
         }
@@ -846,23 +857,22 @@ public class RuleEngine {
 
 
     /**
-     *
      * @param itemMap
      * @param medicalInsRuleProject
      */
-    public void setProjectToLocalMap(Map<String,Object> itemMap, MedicalInsRuleProject medicalInsRuleProject){
-        if(null != medicalInsRuleProject.getAge()){
-            if(daysRuleIdSet.contains(medicalInsRuleProject.getMedicalInsRuleInfoId())){
+    public void setProjectToLocalMap(Map<String, Object> itemMap, MedicalInsRuleProject medicalInsRuleProject) {
+        if (null != medicalInsRuleProject.getAge()) {
+            if (daysRuleIdSet.contains(medicalInsRuleProject.getMedicalInsRuleInfoId())) {
                 medicalInsRuleProject.setAgeDays(Double.valueOf(medicalInsRuleProject.getAge()));
-            }else{
-                if(null != medicalInsRuleProject.getAge()){
+            } else {
+                if (null != medicalInsRuleProject.getAge()) {
                     medicalInsRuleProject.setAgeDays(Double.valueOf(medicalInsRuleProject.getAge() * 365));
                 }
             }
         }
         String jsonStr = JSON.toJSONString(medicalInsRuleProject);
         JSONObject jsonObject = JSONObject.parseObject(jsonStr);
-        Map<String,Object> transferMedicalMap = filterMap(jsonObject);
+        Map<String, Object> transferMedicalMap = filterMap(jsonObject);
         itemMap.putAll(transferMedicalMap);
     }
 
@@ -1110,7 +1120,7 @@ public class RuleEngine {
             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){
+        } catch (Exception e) {
             log.error(e.getMessage(), e);
         }
 
@@ -1148,7 +1158,7 @@ public class RuleEngine {
                         log.error("事后统计数据:{} 规则名:{} 触发诊断类规则,直接全金额,后续规则无需再跑", paramMap, medicalInsRuleInfo);
                         return;
                     }
-                }catch (Exception e){
+                } catch (Exception e) {
                     log.error(e.getMessage(), e);
                 }
             }
@@ -1161,10 +1171,10 @@ public class RuleEngine {
      *
      * @param paramMap
      */
-    public void runAfterEngine(Map<String, Object> paramMap, Integer medicalRuleInsInfoId, AfterwardsAudit afterIncidentAudit, List<Map<String, Object>> itemList) throws Exception {
+    public boolean runAfterEngine(Map<String, Object> paramMap, Integer medicalRuleInsInfoId, AfterwardsAudit afterIncidentAudit, List<Map<String, Object>> itemList) throws Exception {
         if (null == medicalRuleInsInfoId) {
             log.error("未有对应的规则,接口数据:{}", paramMap);
-            return;
+            return false;
         }
         if (allEnchanceTypeMap.containsKey(medicalRuleInsInfoId)) {
             MedicalInsRuleInfo medicalInsRuleInfo = allMedicalMap.get(medicalRuleInsInfoId);
@@ -1176,13 +1186,12 @@ public class RuleEngine {
             getRuleProjectIntoMap(medicalInsRuleInfo, paramMap);
             paramMap.put(SystemEventAttrConstant.ADVICE_DETAILS_LIST_KEY, itemList);
             boolean auditFlag = factorEnchangeFactory.runFactorEnchange(medicalRuleInsInfoId, medicalInsRuleInfo, afterIncidentAudit, paramMap, ruleFactorRelaSortList, factorEnchanceListTemp, itemList);
-            if (Constant.VALIDATION_HANDER_METHOD_RETURN.equals(medicalInsRuleInfo.getViolationHandingMethod()) && auditFlag) {
-                log.error("事后提醒数据:{} 规则名:{} 触发诊断类规则,直接全金额,后续规则无需再跑", paramMap, medicalInsRuleInfo);
-                return;
-            }
-        }else{
+            return auditFlag;
+        } else {
             log.error("该医保规则ID:{} 未有配置医保规则处理流程-请到规则配置页面进行配置", medicalRuleInsInfoId);
+            paramMap.put(Constant.SPEL_LOG, "项目编码未匹配到对应的医保规则 在规则库数据库中未检索到数据,退出执行规则");
         }
+        return false;
     }
 
     /**
@@ -1211,7 +1220,7 @@ public class RuleEngine {
                 log.error("事后提醒数据:{} 规则名:{} 触发诊断类规则,直接全金额,后续规则无需再跑", paramMap, medicalInsRuleInfo);
                 return auditFlag;
             }
-        }else{
+        } else {
             log.error("该医保规则ID:{} 未有配置医保规则处理流程-请到规则配置页面进行配置", medicalRuleInsInfoId);
         }
         return auditFlag;
@@ -1236,11 +1245,11 @@ public class RuleEngine {
                     conditionFlag = true;
                 }
                 medicalInsRuleProjectDiagnoseList = medicalInsRuleProjectDiagnoseService.lambdaQuery().eq(MedicalInsRuleProjectDiagnose::getMedicalInsRuleInfoId, medicalInsRuleInfo.getId())
-                        .eq(MedicalInsRuleProjectDiagnose::getProjectCodeType, 1).last(conditionFlag, " and INSTR('"+projectCode+"', medical_ins_project_code)").list();
+                        .eq(MedicalInsRuleProjectDiagnose::getProjectCodeType, 1).last(conditionFlag, " and INSTR('" + projectCode + "', medical_ins_project_code)").list();
                 if (CollectionUtil.isNotEmpty(medicalInsRuleProjectDiagnoseList)) {
                     List<String> medicalDiagnoseStrList = medicalInsRuleProjectDiagnoseList.stream().map(MedicalInsRuleProjectDiagnose::getMedicalDiagnoseCode).collect(Collectors.toList());
                     itemMap.put(SystemEventAttrConstant.MEDICAL_INS_MEDICALDIAGNOSECODELIST, medicalDiagnoseStrList);
-                }else{
+                } else {
                     log.error("配置了诊断编码规则属性,但是具体规则参数未配置,请管理员尽快配置 医保规则:{}", medicalInsRuleInfo);
                     itemMap.put(SystemEventAttrConstant.MEDICAL_INS_MEDICALDIAGNOSECODELIST, new ArrayList<>());
                 }
@@ -1249,16 +1258,16 @@ public class RuleEngine {
             if (correlationDiagnoseFlag) {
                 List<MedicalInsRuleProjectDiagnose> medicalInsRuleProjectDiagnoseList = null;
                 boolean conditionFlag = false;
-                String collectionProjectCode = itemMap.getOrDefault(SystemEventAttrConstant.MEDICAL_INS_CORRELATIONMEDICALDIAGNOSECODE,"").toString();
+                String collectionProjectCode = itemMap.getOrDefault(SystemEventAttrConstant.MEDICAL_INS_CORRELATIONMEDICALDIAGNOSECODE, "").toString();
                 if (StringUtils.isNotBlank(collectionProjectCode)) {
                     conditionFlag = true;
                 }
                 medicalInsRuleProjectDiagnoseList = medicalInsRuleProjectDiagnoseService.lambdaQuery().eq(MedicalInsRuleProjectDiagnose::getMedicalInsRuleInfoId, medicalInsRuleInfo.getId())
-                        .eq(MedicalInsRuleProjectDiagnose::getProjectCodeType, 2).last(conditionFlag, " and INSTR('"+projectCode+"', medical_ins_project_code)").list();
+                        .eq(MedicalInsRuleProjectDiagnose::getProjectCodeType, 2).last(conditionFlag, " and INSTR('" + projectCode + "', medical_ins_project_code)").list();
                 if (CollectionUtil.isNotEmpty(medicalInsRuleProjectDiagnoseList)) {
                     List<String> medicalDiagnoseStrList = medicalInsRuleProjectDiagnoseList.stream().map(MedicalInsRuleProjectDiagnose::getMedicalDiagnoseCode).collect(Collectors.toList());
                     itemMap.put(SystemEventAttrConstant.MEDICAL_INS_CORRELATIONMEDICALDIAGNOSECODE, medicalDiagnoseStrList);
-                }else{
+                } else {
                     log.error("配置了关联诊断编码规则属性,但是具体规则参数未配置,请管理员尽快配置 医保规则:{}", medicalInsRuleInfo);
                     itemMap.put(SystemEventAttrConstant.MEDICAL_INS_CORRELATIONMEDICALDIAGNOSECODE, new ArrayList<>());
                 }

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

@@ -139,6 +139,7 @@ public class SPELUtil {
         } catch (Exception e) {
             log.error("执行语句:{} 数据对象:{}", condStr, contentMap);
             log.error(e.getMessage(), e);
+            contentMap.put(Constant.SPEL_LOG, getCondStrAndParam(condStr, condStrParamName, contentMap) + " " + e.getMessage());
             throw new Exception("执行失败el表达式:" + condStr);
         }
         log.info("执行语句:{} 执行结果:{}  ", condStr, defResult);