xuezizhuo 2 жил өмнө
parent
commit
27acfa2802

+ 7 - 8
ruoyi-admin/src/main/java/com/ruoyi/web/controller/dragForm/CommonController.java

@@ -87,15 +87,14 @@ public class CommonController extends BaseController {
 
     /**
      * 通用导出excel
-     *
-     * @param response
-     * @param tableName
-     * @param sqlKey
-     * @throws Exception
      */
-    @GetMapping("/export")
-    public void export(HttpServletResponse response, @RequestParam("tableName") String tableName, @RequestParam("sqlKey") String sqlKey) throws Exception {
-        commonService.export(response, tableName, sqlKey);
+//    @GetMapping("/export")
+//    public void export(HttpServletResponse response, @RequestParam("tableName") String tableName, @RequestParam("sqlKey") String sqlKey) throws Exception {
+//        commonService.export(response, tableName, sqlKey);
+//    }
+    @PostMapping("/export")
+    public void export(HttpServletResponse response,@RequestBody CommonEntity commonEntity) throws Exception {
+        commonService.export(response, commonEntity);
     }
 
     /**

+ 1 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/dragForm/CommonFileController.java

@@ -179,7 +179,7 @@ public class CommonFileController {
     }
 
     /**
-     * 导入execl数据(单个文件)
+     * 导入execl数据(单个文件)文件名即表名
      */
 
     @Anonymous

+ 1 - 1
ruoyi-system/src/main/java/com/ruoyi/system/entity/CommonEntity.java

@@ -41,7 +41,7 @@ public class CommonEntity extends BaseEntity {
     private Map<String, Object> commMap;
 
     /**
-     * 导入数据Map
+     * excelMap
      */
     private Map<String, Object> execlMap;
 

+ 1 - 1
ruoyi-system/src/main/java/com/ruoyi/system/service/ICommonService.java

@@ -38,7 +38,7 @@ public interface ICommonService {
     /**
      * 导出列表
      */
-    void export(HttpServletResponse response, String tableName, String sqlKey) throws Exception;
+    void export(HttpServletResponse response, CommonEntity commonEntity) throws Exception;
 
     /**
      * 导出模版

+ 17 - 5
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CommonServiceImpl.java

@@ -2,9 +2,7 @@ package com.ruoyi.system.service.impl;
 
 import com.alibaba.fastjson2.JSON;
 import com.alibaba.fastjson2.JSONObject;
-import com.ruoyi.common.core.domain.model.LoginUser;
 import com.ruoyi.common.utils.DateUtils;
-import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.system.entity.CommonEntity;
 import com.ruoyi.system.entity.TableSql;
 import com.ruoyi.system.mapper.CommonMapper;
@@ -14,6 +12,7 @@ import org.apache.poi.xssf.usermodel.XSSFRow;
 import org.apache.poi.xssf.usermodel.XSSFSheet;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
 
 import javax.annotation.Resource;
 import javax.servlet.ServletOutputStream;
@@ -105,12 +104,25 @@ public class CommonServiceImpl implements ICommonService {
     }
 
     @Override
-    public void export(HttpServletResponse response, String tableName, String sqlKey) throws Exception {
+    public void export(HttpServletResponse response, CommonEntity commonEntity) throws Exception {
+        String sqlKey = commonEntity.getQueryMap().get("sqlKey").toString();
+        String tableName = commonEntity.getQueryMap().get("tableName").toString();
         //查询标题信息
         TableSql tableSql = tableSqlMapper.selectTableSqlByTSqlKey(sqlKey);
         //查询列表信息
-        List<CommonEntity> commonEntities = commonMapper.selectList(tableName, new HashMap<>());
-
+//        List<CommonEntity> commonEntities = commonMapper.selectList(tableName, new HashMap<>());
+        List<CommonEntity> commonEntities = new ArrayList<>();
+        CommonEntity commonEntity1 = new CommonEntity();
+        //根据条件获取列表信息
+        if (StringUtils.hasLength(commonEntity.getExeclMap().get("dataList").toString())) {
+            for (CommonEntity dataList : (List<CommonEntity>) commonEntity.getExeclMap().get("dataList")) {
+                System.out.println(dataList);
+                commonEntities.add(dataList);
+            }
+        } else {
+            commonEntities = queryTableList(commonEntity, tableSql);
+        }
+        commonEntities.add(commonEntity1);
         //获取列表标题和字段
         Map<String, String> map = (Map) JSONObject.parseObject(tableSql.getTableExportField());
         // 创建Excel文档