瀏覽代碼

导出模块调整

dzx 1 年之前
父節點
當前提交
e67d47bef5

+ 11 - 1
src/main/java/com/xjrsoft/module/dataexpert/controller/DataExpertTemplateController.java

@@ -151,6 +151,7 @@ public class DataExpertTemplateController {
         List<String> titleList = new ArrayList<>();
         List<DataExpertTemplateFieldVo> fieldList = dto.getFieldList();
         DataExpertSource expertSource;
+        String conditions = "";
         if(dto.getDataExpertSourceId() != null){
             expertSource = dataExpertSourceService.getById(dto.getDataExpertSourceId());
             for (int i = 0; i < fieldList.size(); i ++){
@@ -175,9 +176,18 @@ public class DataExpertTemplateController {
                 i ++;
             }
         }
+        if(dto.getIds() != null && !dto.getIds().isEmpty()){
+            String ids = dto.getIds().toString();
+            conditions += " and id in (" + ids.substring(1, ids.length() - 1) + ")";
+        }
+        if(dto.getConditions() != null && !dto.getConditions().isEmpty()){
+            for (String key : dto.getConditions().keySet()) {
+                conditions += " and " + key + " like '%" + dto.getConditions().get(key) + "%'";
+            }
+        }
 
         //查出导出的数据并进行组装
-        List<String[]> dataList = dataExpertTemplateService.getDataList(fields.toString().substring(1, fields.toString().length() - 1), expertSource.getViewName());
+        List<String[]> dataList = dataExpertTemplateService.getDataList(fields.toString().substring(1, fields.toString().length() - 1), expertSource.getViewName(), conditions);
 
         List<String[]> allDataList = new ArrayList<>();
         allDataList.add(titleList.toArray(new String[titleList.size()]));

+ 1 - 1
src/main/java/com/xjrsoft/module/dataexpert/service/IDataExpertTemplateService.java

@@ -21,5 +21,5 @@ public interface IDataExpertTemplateService extends MPJBaseService<DataExpertTem
     List<DataExpertTemplateFieldVo> getFieldList(Long id);
 
 
-    List<String[]> getDataList(String fields, String viewName) throws SQLException;
+    List<String[]> getDataList(String fields, String viewName, String conditions) throws SQLException;
 }

+ 2 - 2
src/main/java/com/xjrsoft/module/dataexpert/service/impl/DataExpertTemplateServiceImpl.java

@@ -43,10 +43,10 @@ public class DataExpertTemplateServiceImpl extends MPJBaseServiceImpl<DataExpert
     }
 
     @Override
-    public List<String[]> getDataList(String fields, String viewName) throws SQLException {
+    public List<String[]> getDataList(String fields, String viewName, String conditions) throws SQLException {
         DataSource datasource = DatasourceUtil.getDataSource(GlobalConstant.DEFAULT_DATASOURCE_KEY);
         Db use = Db.use(datasource);
-        String sql = "SELECT " + fields + " FROM " + viewName + " WHERE 1 = 1";
+        String sql = "SELECT " + fields + " FROM " + viewName + " WHERE 1 = 1 " + conditions;
         List<String[]> list = use.query(sql, String[].class);
         return list;
     }