|
|
@@ -0,0 +1,68 @@
|
|
|
+package org.jeecg.modules.medical.ruleengine.plugin;
|
|
|
+
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import org.jeecg.modules.medical.Constant;
|
|
|
+import org.jeecg.modules.medical.SystemEventAttrConstant;
|
|
|
+import org.jeecg.modules.medical.entity.FactorAttrRela;
|
|
|
+import org.jeecg.modules.medical.entity.FactorEnchance;
|
|
|
+import org.jeecg.modules.medical.ruleengine.PluginInterface;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 对费用类别进行分组统计,并设置
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@Component("groupbyExpenseCategoryPlugin")
|
|
|
+public class GroupbyExpenseCategoryPlugin implements PluginInterface {
|
|
|
+ @Override
|
|
|
+ public void plugin(Map<String, Object> localMap, Map<Integer, List<FactorAttrRela>> ioTypeMap, FactorEnchance factorEnchance, Integer medicalInsRuleInfoId) {
|
|
|
+ try {
|
|
|
+ Object adviceList = localMap.get(SystemEventAttrConstant.ADVICE_DETAILS_LIST_KEY);
|
|
|
+ if (null != adviceList) {
|
|
|
+ List<Map<String, Object>> adviceMapList = (List<Map<String, Object>>) adviceList;
|
|
|
+ Map<String, Integer> expenseCategoryIntMap = new HashMap<>();
|
|
|
+ Map<String, List<String>> expenseCategoryProjectCodeMap = new HashMap<>();
|
|
|
+ for (Map<String, Object> adviceMap : adviceMapList) {
|
|
|
+ String expenseCategory = adviceMap.getOrDefault(SystemEventAttrConstant.EXPENSE_CATEGORY, "").toString();
|
|
|
+ String expenseCategoryKey = SystemEventAttrConstant.EXPENSE_CATEGORY_COUNT + "_" + expenseCategory;
|
|
|
+ String expenseCategoryProjectCodeKey = SystemEventAttrConstant.EXPENSE_CATEGORY_GROUP+"_"+expenseCategory;
|
|
|
+ if (StringUtils.isNotBlank(expenseCategory)) {
|
|
|
+ if (expenseCategoryIntMap.containsKey(expenseCategoryKey)) {
|
|
|
+ int exInt = expenseCategoryIntMap.get(expenseCategoryKey).intValue() + 1;
|
|
|
+ expenseCategoryIntMap.put(expenseCategoryKey, exInt);
|
|
|
+ } else {
|
|
|
+ expenseCategoryIntMap.put(expenseCategoryKey, 1);
|
|
|
+ }
|
|
|
+ if(null != adviceMap.get(Constant.PROJECT_CODE_KEY)) {
|
|
|
+ if (expenseCategoryProjectCodeMap.containsKey(expenseCategory)) {
|
|
|
+ expenseCategoryProjectCodeMap.get(expenseCategoryProjectCodeKey).add(adviceMap.get(Constant.PROJECT_CODE_KEY).toString());
|
|
|
+ } else {
|
|
|
+ List tempList = new ArrayList();
|
|
|
+ tempList.add(adviceMap.get(Constant.PROJECT_CODE_KEY).toString());
|
|
|
+ expenseCategoryProjectCodeMap.put(expenseCategoryProjectCodeKey, tempList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ if (CollectionUtil.isNotEmpty(expenseCategoryIntMap)) {
|
|
|
+ localMap.putAll(expenseCategoryIntMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (CollectionUtil.isNotEmpty(expenseCategoryProjectCodeMap)) {
|
|
|
+ localMap.putAll(expenseCategoryProjectCodeMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|