Browse Source

业绩目标收款类型或明细为空时查询报错修复

hu 1 year ago
parent
commit
cf4d41248e

+ 8 - 1
src/custom/restcontroller/sale/salestarget/enterprise.java

@@ -175,7 +175,14 @@ public class enterprise extends Controller {
                 if(isJSONObject(statisticaldimension)){
                     JSONObject jsonObjectResult = JSONObject.parseObject(statisticaldimension);
                     if(!jsonObjectResult.isEmpty()){
-                        where1= where1+ " and (class in"+ jsonObjectResult.get("type")+" or subclass in"+ jsonObjectResult.get("mx")+")";
+                        StringBuffer stringBuffer= new StringBuffer();
+                        if(!((JSONArray)jsonObjectResult.get("type")).isEmpty()){
+                            stringBuffer.append(" or class in"+ jsonObjectResult.get("type"));
+                        }
+                        if(!((JSONArray)jsonObjectResult.get("mx")).isEmpty()){
+                            stringBuffer.append(" or subclass in"+ jsonObjectResult.get("mx"));
+                        }
+                        where1= where1+ " and ("+(stringBuffer.toString()).replaceFirst("or", "")+")";
                         where1 = where1.replace("[", "(").replace("]", ")");
                     }
 

+ 8 - 1
src/custom/restcontroller/webmanage/sale/salestarget/enterprisetarget.java

@@ -337,7 +337,14 @@ public class enterprisetarget extends Controller {
                 if(isJSONObject(statisticaldimension)){
                     JSONObject jsonObjectResult = JSONObject.parseObject(statisticaldimension);
                     if(!jsonObjectResult.isEmpty()){
-                        where1= where1+ " and (class in"+ jsonObjectResult.get("type")+" or subclass in"+ jsonObjectResult.get("mx")+")";
+                        StringBuffer stringBuffer= new StringBuffer();
+                        if(!((JSONArray)jsonObjectResult.get("type")).isEmpty()){
+                            stringBuffer.append(" or class in"+ jsonObjectResult.get("type"));
+                        }
+                        if(!((JSONArray)jsonObjectResult.get("mx")).isEmpty()){
+                            stringBuffer.append(" or subclass in"+ jsonObjectResult.get("mx"));
+                        }
+                        where1= where1+ " and ("+(stringBuffer.toString()).replaceFirst("or", "")+")";
                         where1 = where1.replace("[", "(").replace("]", ")");
                     }
 

+ 24 - 3
src/custom/restcontroller/webmanage/sale/salestarget/personnelstatistics.java

@@ -307,7 +307,14 @@ public class personnelstatistics extends Controller {
                 if(isJSONObject(statisticaldimension)){
                     JSONObject jsonObjectResult = JSONObject.parseObject(statisticaldimension);
                     if(!jsonObjectResult.isEmpty()){
-                        where1= where1+ " and (t1.class in"+ jsonObjectResult.get("type")+" or t1.subclass in"+ jsonObjectResult.get("mx")+")";
+                        StringBuffer stringBuffer= new StringBuffer();
+                        if(!((JSONArray)jsonObjectResult.get("type")).isEmpty()){
+                            stringBuffer.append(" or t1.class in"+ jsonObjectResult.get("type"));
+                        }
+                        if(!((JSONArray)jsonObjectResult.get("mx")).isEmpty()){
+                            stringBuffer.append(" or t1.subclass in"+ jsonObjectResult.get("mx"));
+                        }
+                        where1= where1+ " and ("+(stringBuffer.toString()).replaceFirst("or", "")+")";
                         where1 = where1.replace("[", "(").replace("]", ")");
                     }
 
@@ -575,7 +582,14 @@ public class personnelstatistics extends Controller {
                 if(isJSONObject(statisticaldimension)){
                     JSONObject jsonObjectResult = JSONObject.parseObject(statisticaldimension);
                     if(!jsonObjectResult.isEmpty()){
-                        where1= where1+ " and (t1.class in"+ jsonObjectResult.get("type")+" or t1.subclass in"+ jsonObjectResult.get("mx")+")";
+                        StringBuffer stringBuffer= new StringBuffer();
+                        if(!((JSONArray)jsonObjectResult.get("type")).isEmpty()){
+                            stringBuffer.append(" or t1.class in"+ jsonObjectResult.get("type"));
+                        }
+                        if(!((JSONArray)jsonObjectResult.get("mx")).isEmpty()){
+                            stringBuffer.append(" or t1.subclass in"+ jsonObjectResult.get("mx"));
+                        }
+                        where1= where1+ " and ("+(stringBuffer.toString()).replaceFirst("or", "")+")";
                         where1 = where1.replace("[", "(").replace("]", ")");
                     }
 
@@ -817,7 +831,14 @@ public class personnelstatistics extends Controller {
                 if(isJSONObject(statisticaldimension)){
                     JSONObject jsonObjectResult = JSONObject.parseObject(statisticaldimension);
                     if(!jsonObjectResult.isEmpty()){
-                        where1= where1+ " and (t1.class in"+ jsonObjectResult.get("type")+" or t1.subclass in"+ jsonObjectResult.get("mx")+")";
+                        StringBuffer stringBuffer= new StringBuffer();
+                        if(!((JSONArray)jsonObjectResult.get("type")).isEmpty()){
+                            stringBuffer.append(" or t1.class in"+ jsonObjectResult.get("type"));
+                        }
+                        if(!((JSONArray)jsonObjectResult.get("mx")).isEmpty()){
+                            stringBuffer.append(" or t1.subclass in"+ jsonObjectResult.get("mx"));
+                        }
+                        where1= where1+ " and ("+(stringBuffer.toString()).replaceFirst("or", "")+")";
                         where1 = where1.replace("[", "(").replace("]", ")");
                     }