dzx 1 рік тому
батько
коміт
578ab78138

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

@@ -180,9 +180,22 @@ public class DataExpertTemplateController {
             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) + "%'";
+        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(int k = 0; k < keyValues.length; k ++){
+                        if(k > 0){
+                            conditions += ",";
+                        }
+                        conditions += "'" + keyValues[k] + "'";
+                    }
+                    conditions += ")";
+                }
             }
         }
 

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

@@ -1,5 +1,6 @@
 package com.xjrsoft.module.dataexpert.dto;
 
+import com.google.gson.JsonArray;
 import com.xjrsoft.module.dataexpert.vo.DataExpertTemplateFieldVo;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -29,7 +30,7 @@ public class DataExpertDto {
     @ApiModelProperty("数据行id")
     private List<String> ids;
 
-    @ApiModelProperty("条件")
-    private Map<String, String> conditions;
+    @ApiModelProperty("条件(json)")
+    private JsonArray conditions;
 
 }