Selaa lähdekoodia

解决导出报错

dzx 1 vuosi sitten
vanhempi
commit
a29695cff5

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

@@ -16,6 +16,7 @@ import com.xjrsoft.common.page.ConventPage;
 import com.xjrsoft.common.page.PageOutput;
 import com.xjrsoft.common.utils.VoToColumnUtil;
 import com.xjrsoft.module.dataexpert.dto.AddDataExpertTemplateDto;
+import com.xjrsoft.module.dataexpert.dto.DataExpertConditionsDto;
 import com.xjrsoft.module.dataexpert.dto.DataExpertDto;
 import com.xjrsoft.module.dataexpert.dto.DataExpertTemplateListDto;
 import com.xjrsoft.module.dataexpert.dto.DataExpertTemplatePageDto;
@@ -177,17 +178,16 @@ public class DataExpertTemplateController {
             }
         }
         if(dto.getIds() != null && !dto.getIds().isEmpty()){
-            String ids = dto.getIds().toString();
-            conditions += " and id in (" + ids.substring(1, ids.length() - 1) + ")";
+            String ids = dto.getIds().toString().substring(1, dto.getIds().size() - 1).replaceAll(",","','");
+            conditions += " and id in ('" + ids + "')";
         }
         if(dto.getConditions() != null && dto.getConditions().size() != 0){
-            for (JsonElement condition : dto.getConditions()) {
-                JsonObject jsonObject = condition.getAsJsonObject();
-                if(jsonObject.get("keyType").getAsInt() == 1){
-                    conditions += " and " + jsonObject.get("keyName").getAsString() + " like '%" + jsonObject.get("keyValue").getAsString() + "%'";
-                }else if(jsonObject.get("keyType").getAsInt() == 2){
-                    conditions += " and " + jsonObject.get("keyName") + " in (";
-                    String[] keyValues = jsonObject.get("keyValue").getAsString().split(",");
+            for (DataExpertConditionsDto condition : dto.getConditions()) {
+                if(condition.getKeyType() == 1){
+                    conditions += " and " + condition.getKeyName() + " like '%" + condition.getKeyValue() + "%'";
+                }else if(condition.getKeyType() == 2 && condition.getKeyValue() != null && !"".equals(condition.getKeyValue())){
+                    conditions += " and " + condition.getKeyName() + " in (";
+                    String[] keyValues = condition.getKeyValue().split(",");
                     for(int k = 0; k < keyValues.length; k ++){
                         if(k > 0){
                             conditions += ",";

+ 27 - 0
src/main/java/com/xjrsoft/module/dataexpert/dto/DataExpertConditionsDto.java

@@ -0,0 +1,27 @@
+package com.xjrsoft.module.dataexpert.dto;
+
+import com.xjrsoft.module.dataexpert.vo.DataExpertTemplateFieldVo;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+
+/**
+* @title: 数据导出-数据源设置字段查询入参
+* @Author dzx
+* @Date: 2024-04-19
+* @Version 1.0
+*/
+@Data
+public class DataExpertConditionsDto {
+
+    @ApiModelProperty("keyName")
+    private String keyName;
+
+    @ApiModelProperty("keyValue")
+    private String keyValue;
+
+    @ApiModelProperty("keyType")
+    private Integer keyType;
+}

+ 1 - 1
src/main/java/com/xjrsoft/module/dataexpert/dto/DataExpertDto.java

@@ -31,6 +31,6 @@ public class DataExpertDto {
     private List<String> ids;
 
     @ApiModelProperty("条件(json)")
-    private JsonArray conditions;
+    private List<DataExpertConditionsDto> conditions;
 
 }