From 4bf7eb73030e7d5bb05dc9ef252401f8af6fede1 Mon Sep 17 00:00:00 2001
From: zhangdaiscott <zhangdaiscott@163.com>
Date: Sun, 21 Feb 2021 15:49:26 +0800
Subject: [PATCH] 【严重问题】issues/I37PNL 微服务化后-cloud-demo项目导出无法和字典关联

---
 jeecg-boot/jeecg-boot-base/jeecg-boot-base-api/jeecg-system-local-api/src/main/java/org/jeecg/common/system/api/ISysBaseAPI.java | 18 +-----------------
 jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/api/CommonAPI.java                                | 21 +++++++++++++++++----
 jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/config/AutoPoiDictConfig.java                            | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/AutoPoiDictService.java                  | 65 -----------------------------------------------------------------
 4 files changed, 83 insertions(+), 86 deletions(-)
 create mode 100644 jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/config/AutoPoiDictConfig.java
 delete mode 100644 jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/AutoPoiDictService.java

diff --git a/jeecg-boot/jeecg-boot-base/jeecg-boot-base-api/jeecg-system-local-api/src/main/java/org/jeecg/common/system/api/ISysBaseAPI.java b/jeecg-boot/jeecg-boot-base/jeecg-boot-base-api/jeecg-system-local-api/src/main/java/org/jeecg/common/system/api/ISysBaseAPI.java
index 0694caf..0caa864 100644
--- a/jeecg-boot/jeecg-boot-base/jeecg-boot-base-api/jeecg-system-local-api/src/main/java/org/jeecg/common/system/api/ISysBaseAPI.java
+++ b/jeecg-boot/jeecg-boot-base/jeecg-boot-base-api/jeecg-system-local-api/src/main/java/org/jeecg/common/system/api/ISysBaseAPI.java
@@ -1,14 +1,11 @@
 package org.jeecg.common.system.api;
 
-import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import org.jeecg.common.api.CommonAPI;
 import org.jeecg.common.api.dto.OnlineAuthDTO;
 import org.jeecg.common.api.dto.message.*;
 import org.jeecg.common.system.vo.*;
 
-import java.util.Arrays;
 import java.util.List;
 import java.util.Set;
 
@@ -80,12 +77,7 @@ public interface ISysBaseAPI extends CommonAPI {
      */
     List<String> getDepartNamesByUsername(String username);
 
-    /**
-     * 10获取数据字典
-     * @param code
-     * @return
-     */
-    public List<DictModel> queryDictItemsByCode(String code);
+
 
     /** 11查询所有的父级字典,按照create_time排序 */
     public List<DictModel> queryAllDict();
@@ -96,14 +88,6 @@ public interface ISysBaseAPI extends CommonAPI {
      */
     public List<SysCategoryModel> queryAllDSysCategory();
 
-    /**
-     * 13获取表数据字典
-     * @param table
-     * @param text
-     * @param code
-     * @return
-     */
-    List<DictModel> queryTableDictItemsByCode(String table, String text, String code);
 
     /**
      * 14查询所有部门 作为字典信息 id -->value,departName -->text
diff --git a/jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/api/CommonAPI.java b/jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/api/CommonAPI.java
index cfd2e6b..5a7665c 100644
--- a/jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/api/CommonAPI.java
+++ b/jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/api/CommonAPI.java
@@ -1,9 +1,6 @@
 package org.jeecg.common.api;
 
-import org.jeecg.common.system.vo.DynamicDataSourceModel;
-import org.jeecg.common.system.vo.LoginUser;
-import org.jeecg.common.system.vo.SysPermissionDataRuleModel;
-import org.jeecg.common.system.vo.SysUserCacheInfo;
+import org.jeecg.common.system.vo.*;
 
 import java.util.List;
 import java.util.Set;
@@ -81,4 +78,20 @@ public interface CommonAPI {
      */
     SysUserCacheInfo getCacheUser(String username);
 
+    /**
+     * 10获取数据字典
+     * @param code
+     * @return
+     */
+    public List<DictModel> queryDictItemsByCode(String code);
+
+    /**
+     * 13获取表数据字典
+     * @param table
+     * @param text
+     * @param code
+     * @return
+     */
+    List<DictModel> queryTableDictItemsByCode(String table, String text, String code);
+
 }
diff --git a/jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/config/AutoPoiDictConfig.java b/jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/config/AutoPoiDictConfig.java
new file mode 100644
index 0000000..d56f7b4
--- /dev/null
+++ b/jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/config/AutoPoiDictConfig.java
@@ -0,0 +1,65 @@
+package org.jeecg.config;
+
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.CommonAPI;
+import org.jeecg.common.system.vo.DictModel;
+import org.jeecg.common.util.oConvertUtils;
+import org.jeecgframework.dict.service.AutoPoiDictServiceI;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 描述:AutoPoi Excel注解支持字典参数设置
+ *  举例: @Excel(name = "性别", width = 15, dicCode = "sex")
+ * 1、导出的时候会根据字典配置,把值1,2翻译成:男、女;
+ * 2、导入的时候,会把男、女翻译成1,2存进数据库;
+ * 
+ * @Author:scott 
+ * @since:2019-04-09 
+ * @Version:1.0
+ */
+@Slf4j
+@Service
+public class AutoPoiDictConfig implements AutoPoiDictServiceI {
+	@Lazy
+	@Resource
+	private CommonAPI commonAPI;
+
+	/**
+	 * 通过字典查询easypoi,所需字典文本
+	 * 
+	 * @Author:scott 
+	 * @since:2019-04-09
+	 * @return
+	 */
+	@Override
+	public String[] queryDict(String dicTable, String dicCode, String dicText) {
+		List<String> dictReplaces = new ArrayList<String>();
+		List<DictModel> dictList = null;
+		// step.1 如果没有字典表则使用系统字典表
+		if (oConvertUtils.isEmpty(dicTable)) {
+			dictList = commonAPI.queryDictItemsByCode(dicCode);
+		} else {
+			try {
+				dicText = oConvertUtils.getString(dicText, dicCode);
+				dictList = commonAPI.queryTableDictItemsByCode(dicTable, dicText, dicCode);
+			} catch (Exception e) {
+				log.error(e.getMessage(),e);
+			}
+		}
+		for (DictModel t : dictList) {
+			if(t!=null){
+				dictReplaces.add(t.getText() + "_" + t.getValue());
+			}
+		}
+		if (dictReplaces != null && dictReplaces.size() != 0) {
+			log.info("---AutoPoi--Get_DB_Dict------"+ dictReplaces.toString());
+			return dictReplaces.toArray(new String[dictReplaces.size()]);
+		}
+		return null;
+	}
+}
diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/AutoPoiDictService.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/AutoPoiDictService.java
deleted file mode 100644
index b60e12a..0000000
--- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/AutoPoiDictService.java
+++ /dev/null
@@ -1,65 +0,0 @@
-package org.jeecg.modules.system.service.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.jeecg.common.system.vo.DictModel;
-import org.jeecg.common.util.oConvertUtils;
-import org.jeecg.modules.system.mapper.SysDictMapper;
-import org.jeecgframework.dict.service.AutoPoiDictServiceI;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import lombok.extern.slf4j.Slf4j;
-
-/**
- * 描述:AutoPoi Excel注解支持字典参数设置
- *  举例: @Excel(name = "性别", width = 15, dicCode = "sex")
- * 1、导出的时候会根据字典配置,把值1,2翻译成:男、女;
- * 2、导入的时候,会把男、女翻译成1,2存进数据库;
- * 
- * @Author:scott 
- * @since:2019-04-09 
- * @Version:1.0
- */
-@Slf4j
-@Service
-public class AutoPoiDictService implements AutoPoiDictServiceI {
-	@Autowired
-	private SysDictMapper sysDictMapper;
-
-	/**
-	 * 通过字典查询easypoi,所需字典文本
-	 * 
-	 * @Author:scott 
-	 * @since:2019-04-09
-	 * @return
-	 */
-	@Override
-	public String[] queryDict(String dicTable, String dicCode, String dicText) {
-		List<String> dictReplaces = new ArrayList<String>();
-		List<DictModel> dictList = null;
-		// step.1 如果没有字典表则使用系统字典表
-		if (oConvertUtils.isEmpty(dicTable)) {
-			dictList = sysDictMapper.queryDictItemsByCode(dicCode);
-		} else {
-			try {
-				dicText = oConvertUtils.getString(dicText, dicCode);
-				dictList = sysDictMapper.queryTableDictItemsByCode(dicTable, dicText, dicCode);
-			} catch (Exception e) {
-				log.error(e.getMessage(),e);
-			}
-		}
-		for (DictModel t : dictList) {
-			if(t!=null){
-				dictReplaces.add(t.getText() + "_" + t.getValue());
-			}
-		}
-		if (dictReplaces != null && dictReplaces.size() != 0) {
-			log.info("---AutoPoi--Get_DB_Dict------"+ dictReplaces.toString());
-			return dictReplaces.toArray(new String[dictReplaces.size()]);
-		}
-		return null;
-	}
-}
--
libgit2 0.22.2