|
@@ -1,6 +1,7 @@
|
|
package org.jeecg.modules.medical.ruleengine;
|
|
package org.jeecg.modules.medical.ruleengine;
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -10,6 +11,7 @@ import org.jeecg.common.util.SpringContextUtils;
|
|
import org.jeecg.modules.medical.Constant;
|
|
import org.jeecg.modules.medical.Constant;
|
|
import org.jeecg.modules.medical.EnchanceTypeEnum;
|
|
import org.jeecg.modules.medical.EnchanceTypeEnum;
|
|
import org.jeecg.modules.medical.SystemEventAttrConstant;
|
|
import org.jeecg.modules.medical.SystemEventAttrConstant;
|
|
|
|
+import org.jeecg.modules.medical.common.CommonUtil;
|
|
import org.jeecg.modules.medical.entity.AdvanceWarningAudit;
|
|
import org.jeecg.modules.medical.entity.AdvanceWarningAudit;
|
|
import org.jeecg.modules.medical.entity.AdvanceWarningAuditDetail;
|
|
import org.jeecg.modules.medical.entity.AdvanceWarningAuditDetail;
|
|
import org.jeecg.modules.medical.entity.AfterwardsAudit;
|
|
import org.jeecg.modules.medical.entity.AfterwardsAudit;
|
|
@@ -93,7 +95,6 @@ public class FactorEnchangeFactory {
|
|
|
|
|
|
public Map<Integer, List<FactorAttrRela>> factorEnhanceIdAndListMap = new HashMap<>();
|
|
public Map<Integer, List<FactorAttrRela>> factorEnhanceIdAndListMap = new HashMap<>();
|
|
|
|
|
|
- public static ThreadLocal<Map<String, Object>> currentThreadLocalMap = new ThreadLocal<>();
|
|
|
|
|
|
|
|
public void init() {
|
|
public void init() {
|
|
log.info("进入初始化FactorEnchangeFactory");
|
|
log.info("进入初始化FactorEnchangeFactory");
|
|
@@ -125,62 +126,59 @@ public class FactorEnchangeFactory {
|
|
}
|
|
}
|
|
Map<Integer, FactorEnchance> factorEnchanceMap = factorEnchanceList.stream().collect(Collectors.toMap(FactorEnchance::getId, v -> v, (v1, v2) -> v1));
|
|
Map<Integer, FactorEnchance> factorEnchanceMap = factorEnchanceList.stream().collect(Collectors.toMap(FactorEnchance::getId, v -> v, (v1, v2) -> v1));
|
|
boolean result = false;
|
|
boolean result = false;
|
|
- try {
|
|
|
|
- localMap.put(Constant.ADESC, localMap.getOrDefault(SystemEventAttrConstant.MEDICAL_PROJECT_NAME_KEY,""));
|
|
|
|
- currentThreadLocalMap.set(localMap);
|
|
|
|
- for (RuleFactorRela ruleFactorRela : ruleFactorRelaList) {
|
|
|
|
- Integer factorEnchanceId = ruleFactorRela.getFactorEnhanceId();
|
|
|
|
- FactorEnchance factorEnchance = factorEnchanceMap.get(factorEnchanceId);
|
|
|
|
- if (null == factorEnchance) {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
|
|
|
|
- EnchanceTypeEnum enchanceTypeEnum = EnchanceTypeEnum.getType(factorEnchance.getEnhanceType());
|
|
|
|
- switch (enchanceTypeEnum) {
|
|
|
|
- case SQL:
|
|
|
|
- Map<Integer, List<FactorAttrRela>> ioTypeMap = getIoMap(factorEnchanceId);
|
|
|
|
- sqlUtil.setSqlResultByFactorEnchance(localMap, ioTypeMap, factorEnchance, medicalInfoRuleInfoId);
|
|
|
|
- break;
|
|
|
|
- case EXPRESSION:
|
|
|
|
|
|
+ localMap.put(Constant.ADESC, localMap.getOrDefault(SystemEventAttrConstant.MEDICAL_PROJECT_NAME_KEY, ""));
|
|
|
|
+ for (RuleFactorRela ruleFactorRela : ruleFactorRelaList) {
|
|
|
|
+ Integer factorEnchanceId = ruleFactorRela.getFactorEnhanceId();
|
|
|
|
+ FactorEnchance factorEnchance = factorEnchanceMap.get(factorEnchanceId);
|
|
|
|
+ if (null == factorEnchance) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ EnchanceTypeEnum enchanceTypeEnum = EnchanceTypeEnum.getType(factorEnchance.getEnhanceType());
|
|
|
|
+ switch (enchanceTypeEnum) {
|
|
|
|
+ case SQL:
|
|
|
|
+ Map<Integer, List<FactorAttrRela>> ioTypeMap = getIoMap(factorEnchanceId);
|
|
|
|
+ sqlUtil.setSqlResultByFactorEnchance(localMap, ioTypeMap, factorEnchance, medicalInfoRuleInfoId);
|
|
|
|
+ break;
|
|
|
|
+ case EXPRESSION:
|
|
// setLogicalExpressionResultByFactorEnchance(localMap, ioTypeMap, factorEnchance, medicalInfoRuleInfoId);
|
|
// setLogicalExpressionResultByFactorEnchance(localMap, ioTypeMap, factorEnchance, medicalInfoRuleInfoId);
|
|
- break;
|
|
|
|
- case DICT:
|
|
|
|
- dictUtil.transferData(localMap, factorEnchance, medicalInfoRuleInfoId);
|
|
|
|
- break;
|
|
|
|
- case PLUGIN:
|
|
|
|
- Map<Integer, List<FactorAttrRela>> ioTypeMap1 = getIoMap(factorEnchanceId);
|
|
|
|
- PluginInterface pluginInterface = (PluginInterface) SpringContextUtils.getBean(factorEnchance.getEnhanceValue());
|
|
|
|
- pluginInterface.plugin(localMap, ioTypeMap1, factorEnchance, medicalInfoRuleInfoId);
|
|
|
|
- break;
|
|
|
|
- case CONSTANT:
|
|
|
|
- localMap.put(getParamName(factorEnchance.getEventAttrId()), factorEnchance.getExtAttr1());
|
|
|
|
- break;
|
|
|
|
- case LOGICAL_EXPRESSION:
|
|
|
|
- result = setLogicalExpressionResultByFactorEnchance(localMap, factorEnchance);
|
|
|
|
- if (Constant.WARING_EVENT_ATTR_ID == factorEnchance.getEventAttrId()) {
|
|
|
|
- if (result) {
|
|
|
|
- insertWarningDetail(localMap, medicalInsRuleInfo, audit, itemList);
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- localMap.put(getParamName(factorEnchance.getEventAttrId()), result);
|
|
|
|
|
|
+ break;
|
|
|
|
+ case DICT:
|
|
|
|
+ dictUtil.transferData(localMap, factorEnchance, medicalInfoRuleInfoId);
|
|
|
|
+ break;
|
|
|
|
+ case PLUGIN:
|
|
|
|
+ Map<Integer, List<FactorAttrRela>> ioTypeMap1 = getIoMap(factorEnchanceId);
|
|
|
|
+ PluginInterface pluginInterface = (PluginInterface) SpringContextUtils.getBean(factorEnchance.getEnhanceValue());
|
|
|
|
+ pluginInterface.plugin(localMap, ioTypeMap1, factorEnchance, medicalInfoRuleInfoId);
|
|
|
|
+ break;
|
|
|
|
+ case CONSTANT:
|
|
|
|
+ localMap.put(getParamName(factorEnchance.getEventAttrId()), factorEnchance.getExtAttr1());
|
|
|
|
+ break;
|
|
|
|
+ case LOGICAL_EXPRESSION:
|
|
|
|
+ result = setLogicalExpressionResultByFactorEnchance(localMap, factorEnchance);
|
|
|
|
+ if (Constant.WARING_EVENT_ATTR_ID == factorEnchance.getEventAttrId()) {
|
|
|
|
+ if (result) {
|
|
|
|
+ insertWarningDetail(localMap, medicalInsRuleInfo, audit, itemList);
|
|
}
|
|
}
|
|
- break;
|
|
|
|
- case PROPERTIES:
|
|
|
|
- Object valueTemp = localMap.get(getParamName(Integer.parseInt(factorEnchance.getExtAttr1())));
|
|
|
|
- if (null == valueTemp) {
|
|
|
|
- log.error("要素提取:{} 规则ID:{} 常量赋值:{} 配置的属性:{}无值", factorEnchance.getId(), medicalInfoRuleInfoId, factorEnchance.getRuleEnchanceName(), factorEnchance.getExtAttr1());
|
|
|
|
- } else {
|
|
|
|
- localMap.put(getParamName(factorEnchance.getEventAttrId()), valueTemp);
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- default:
|
|
|
|
- log.error("有配置的未处理类型");
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
|
|
+ } else {
|
|
|
|
+ localMap.put(getParamName(factorEnchance.getEventAttrId()), result);
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case PROPERTIES:
|
|
|
|
+ Object valueTemp = localMap.get(getParamName(Integer.parseInt(factorEnchance.getExtAttr1())));
|
|
|
|
+ if (null == valueTemp) {
|
|
|
|
+ log.error("要素提取:{} 规则ID:{} 常量赋值:{} 配置的属性:{}无值", factorEnchance.getId(), medicalInfoRuleInfoId, factorEnchance.getRuleEnchanceName(), factorEnchance.getExtAttr1());
|
|
|
|
+ } else {
|
|
|
|
+ localMap.put(getParamName(factorEnchance.getEventAttrId()), valueTemp);
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ log.error("有配置的未处理类型");
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
- } finally {
|
|
|
|
- currentThreadLocalMap.remove();
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -285,6 +283,12 @@ public class FactorEnchangeFactory {
|
|
if (priceObj != null) {
|
|
if (priceObj != null) {
|
|
afterwardsAuditDetail.setPrice(new BigDecimal(priceObj.toString()));
|
|
afterwardsAuditDetail.setPrice(new BigDecimal(priceObj.toString()));
|
|
}
|
|
}
|
|
|
|
+ Object projectUseTime = otherMap.get(SystemEventAttrConstant.PROJECT_USE_TIME);
|
|
|
|
+ if (null != projectUseTime) {
|
|
|
|
+ String projectUseTimeStr = DateUtil.formatDateTime((Date) projectUseTime);
|
|
|
|
+ afterwardsAuditDetail.setProjectUseTime(projectUseTimeStr);
|
|
|
|
+ }
|
|
|
|
+
|
|
afterwardsAuditDetail.setCreateBy("auto");
|
|
afterwardsAuditDetail.setCreateBy("auto");
|
|
afterwardsAuditDetail.setQuantity(otherMap.get(SystemEventAttrConstant.QUANTITY) != null ? Integer.parseInt(otherMap.get(SystemEventAttrConstant.QUANTITY).toString()) : 1);
|
|
afterwardsAuditDetail.setQuantity(otherMap.get(SystemEventAttrConstant.QUANTITY) != null ? Integer.parseInt(otherMap.get(SystemEventAttrConstant.QUANTITY).toString()) : 1);
|
|
afterwardsAuditDetail.setMedicalInsuranceMark(otherMap.get(Constant.MEDICAL_INSURANCE_MARK_KEY) != null ? otherMap.get(Constant.MEDICAL_INSURANCE_MARK_KEY).toString() : "0");
|
|
afterwardsAuditDetail.setMedicalInsuranceMark(otherMap.get(Constant.MEDICAL_INSURANCE_MARK_KEY) != null ? otherMap.get(Constant.MEDICAL_INSURANCE_MARK_KEY).toString() : "0");
|
|
@@ -450,7 +454,28 @@ public class FactorEnchangeFactory {
|
|
desc = descObject.toString();
|
|
desc = descObject.toString();
|
|
}
|
|
}
|
|
if (null != desc && desc.contains("#")) {
|
|
if (null != desc && desc.contains("#")) {
|
|
- Map<String,Object> itemMapTemp = currentThreadLocalMap.get();
|
|
|
|
|
|
+ Map<String, Object> itemMapTemp = new HashMap<>();
|
|
|
|
+ Object BProjectCode = SPELUtil.concurrentHashMap.get(Thread.currentThread().getName());
|
|
|
|
+ Object BProjectName = CommonUtil.getNameByCode(BProjectCode.toString());
|
|
|
|
+
|
|
|
|
+ if (null != BProjectName) {
|
|
|
|
+ itemMapTemp.put(Constant.BDESC, BProjectName);
|
|
|
|
+ } else {
|
|
|
|
+ List<String> projectCodeList = (List<String>) itemMap.get(SystemEventAttrConstant.MEDICAL_PROJECT_CODE_LSIT);
|
|
|
|
+ List<String> projectNameList = (List<String>) itemMap.get(SystemEventAttrConstant.MEDICAL_PROJECT_NAME_LIST);
|
|
|
|
+
|
|
|
|
+ for (int i = 0; i < projectCodeList.size(); i++) {
|
|
|
|
+ String projectCode = projectCodeList.get(i);
|
|
|
|
+ if (BProjectCode.toString().equals(projectCode)) {
|
|
|
|
+ BProjectName = projectNameList.get(i);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (null == BProjectName) {
|
|
|
|
+ BProjectName = BProjectCode;
|
|
|
|
+ }
|
|
|
|
+ itemMapTemp.put(Constant.BDESC, BProjectName);
|
|
|
|
+ }
|
|
|
|
+
|
|
Object descSpel = spelUtil.getExpressionStr(itemMapTemp, desc);
|
|
Object descSpel = spelUtil.getExpressionStr(itemMapTemp, desc);
|
|
return descSpel.toString();
|
|
return descSpel.toString();
|
|
}
|
|
}
|