Browse Source

业绩目标逻辑优化

hu 2 years ago
parent
commit
101c377d30

+ 4 - 13
src/custom/restcontroller/sale/salestarget/enterprise.java

@@ -172,25 +172,16 @@ public class enterprise extends Controller {
             String where1=" 1=1 ";
             String where1=" 1=1 ";
             sqlFactory = new SQLFactory(this, "企业-收款");
             sqlFactory = new SQLFactory(this, "企业-收款");
             if(StringUtils.isNotBlank(statisticaldimension)){
             if(StringUtils.isNotBlank(statisticaldimension)){
-                if(isJSONArray(statisticaldimension)){
-                    JSONArray jsonArrayResult = JSONArray.parseArray(statisticaldimension);
-                    if(!jsonArrayResult.isEmpty()){
-                        where1=where1+" and (class in"+jsonArrayResult+" or subclass in"+jsonArrayResult+")";
+                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")+")";
                         where1 = where1.replace("[", "(").replace("]", ")");
                         where1 = where1.replace("[", "(").replace("]", ")");
                     }
                     }
 
 
                 }
                 }
             }
             }
-            if(StringUtils.isNotBlank(sa_accountclassids)){
-                if(isJSONArray(sa_accountclassids)){
-                    JSONArray jsonArrayResult = JSONArray.parseArray(sa_accountclassids);
-                    if(!jsonArrayResult.isEmpty()){
-                        where1=where1+ " and sa_accountclassid in"+jsonArrayResult;
-                        where1 = where1.replace("[", "(").replace("]", ")");
-                    }
 
 
-                }
-            }
             sqlFactory.addParameter_SQL("where1",where1);
             sqlFactory.addParameter_SQL("where1",where1);
     }
     }
         sqlFactory.addParameter_in("sys_enterpriseid", rows.toArrayList("sys_enterpriseid",new ArrayList<Long>()));
         sqlFactory.addParameter_in("sys_enterpriseid", rows.toArrayList("sys_enterpriseid",new ArrayList<Long>()));

+ 12 - 0
src/custom/restcontroller/webmanage/sale/salestarget/SQL/更新新年度.sql

@@ -0,0 +1,12 @@
+UPDATE sa_salestargetbill
+SET
+    assessmentindicators = $assessmentindicators$,
+    sa_accountclassids=$sa_accountclassids$,
+    assessmentindicators=$assessmentindicators$,
+    changeuserid=$userid$,
+    changeby=$username$
+WHERE sa_salestargetbillid = $sa_salestargetbillid$ and siteid=$siteid$
+
+
+
+

+ 14 - 4
src/custom/restcontroller/webmanage/sale/salestarget/enterprisetarget.java

@@ -65,6 +65,16 @@ public class enterprisetarget extends Controller {
 
 
                 sqlList.add(sqlFactory.getSQL());
                 sqlList.add(sqlFactory.getSQL());
             }
             }
+        }else{
+            SQLFactory sqlFactory = new SQLFactory(this, "更新新年度");
+            sqlFactory.addParameter("siteid", siteid);
+            sqlFactory.addParameter("sa_salestargetbillid", sa_salestargetbillid);
+            sqlFactory.addParameter("username", username);
+            sqlFactory.addParameter("userid", userid);
+            sqlFactory.addParameter("assessmentindicators", assessmentindicators);
+            sqlFactory.addParameter("statisticaldimension", statisticaldimension);
+            sqlFactory.addParameter("sa_accountclassids", sa_accountclassids);
+            sqlList.add(sqlFactory.getSQL());
         }
         }
 
 
 
 
@@ -265,10 +275,10 @@ public class enterprisetarget extends Controller {
             sqlFactory = new SQLFactory(new enterprise(new JSONObject()), "企业-收款");
             sqlFactory = new SQLFactory(new enterprise(new JSONObject()), "企业-收款");
             String where1=" 1=1 ";
             String where1=" 1=1 ";
             if(StringUtils.isNotBlank(statisticaldimension)){
             if(StringUtils.isNotBlank(statisticaldimension)){
-                if(isJSONArray(statisticaldimension)){
-                    JSONArray jsonArrayResult = JSONArray.parseArray(statisticaldimension);
-                    if(!jsonArrayResult.isEmpty()){
-                        where1=where1+" and (class in"+jsonArrayResult+" or subclass in"+jsonArrayResult+")";
+                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")+")";
                         where1 = where1.replace("[", "(").replace("]", ")");
                         where1 = where1.replace("[", "(").replace("]", ")");
                     }
                     }
 
 

+ 13 - 0
src/custom/restcontroller/webmanage/sale/salestarget/personnel.java

@@ -73,6 +73,16 @@ public class personnel extends Controller {
             String sql = saleareahrsqlFactory.getSQL();
             String sql = saleareahrsqlFactory.getSQL();
             Rows saleareahrrows = dbConnect.runSqlQuery(sql);
             Rows saleareahrrows = dbConnect.runSqlQuery(sql);
             salesArray=saleareahrrows.toJsonArray();
             salesArray=saleareahrrows.toJsonArray();
+        }else{
+            SQLFactory sqlFactory = new SQLFactory(this, "更新新年度");
+            sqlFactory.addParameter("siteid", siteid);
+            sqlFactory.addParameter("sa_salestargetbillid", sa_salestargetbillid);
+            sqlFactory.addParameter("username", username);
+            sqlFactory.addParameter("userid", userid);
+            sqlFactory.addParameter("assessmentindicators", assessmentindicators);
+            sqlFactory.addParameter("statisticaldimension", statisticaldimension);
+            sqlFactory.addParameter("sa_accountclassids", sa_accountclassids);
+            sqlList.add(sqlFactory.getSQL());
         }
         }
 
 
 
 
@@ -220,6 +230,9 @@ public class personnel extends Controller {
             if(isJSONArray(row.getString("statisticaldimension"))){
             if(isJSONArray(row.getString("statisticaldimension"))){
                 row.put("statisticaldimension",JSONArray.parseArray(row.getString("statisticaldimension")));
                 row.put("statisticaldimension",JSONArray.parseArray(row.getString("statisticaldimension")));
             }
             }
+            if(isJSONObject(row.getString("statisticaldimension"))){
+                row.put("statisticaldimension",JSONObject.parseObject(row.getString("statisticaldimension")));
+            }
             if(isJSONArray(row.getString("sa_accountclassids"))){
             if(isJSONArray(row.getString("sa_accountclassids"))){
                 JSONArray sa_accountclassids =JSONArray.parseArray(row.getString("sa_accountclassids"));
                 JSONArray sa_accountclassids =JSONArray.parseArray(row.getString("sa_accountclassids"));
                 for (Object object:sa_accountclassids) {
                 for (Object object:sa_accountclassids) {

+ 14 - 12
src/custom/restcontroller/webmanage/sale/salestarget/personnelstatistics.java

@@ -293,10 +293,10 @@ public class personnelstatistics extends Controller {
             sqlFactory.addParameter("sa_salestargetbillid", sa_salestargetbillid);
             sqlFactory.addParameter("sa_salestargetbillid", sa_salestargetbillid);
             sqlFactory.addParameter_SQL("where", where);
             sqlFactory.addParameter_SQL("where", where);
             if(StringUtils.isNotBlank(statisticaldimension)){
             if(StringUtils.isNotBlank(statisticaldimension)){
-                if(isJSONArray(statisticaldimension)){
-                    JSONArray jsonArrayResult = JSONArray.parseArray(statisticaldimension);
-                    if(!jsonArrayResult.isEmpty()){
-                        where1= where1+ " and (t1.class in"+jsonArrayResult+" or t1.subclass in"+jsonArrayResult+")";
+                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")+")";
                         where1 = where1.replace("[", "(").replace("]", ")");
                         where1 = where1.replace("[", "(").replace("]", ")");
                     }
                     }
 
 
@@ -543,15 +543,16 @@ public class personnelstatistics extends Controller {
             sqlFactory.addParameter("sa_salestargetbillid", sa_salestargetbillid);
             sqlFactory.addParameter("sa_salestargetbillid", sa_salestargetbillid);
             sqlFactory.addParameter_SQL("where", where);
             sqlFactory.addParameter_SQL("where", where);
             if(StringUtils.isNotBlank(statisticaldimension)){
             if(StringUtils.isNotBlank(statisticaldimension)){
-                if(isJSONArray(statisticaldimension)){
-                    JSONArray jsonArrayResult = JSONArray.parseArray(statisticaldimension);
-                    if(!jsonArrayResult.isEmpty()){
-                        where1= where1+ " and (t1.class in"+jsonArrayResult+" or t1.subclass in"+jsonArrayResult+")";
+                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")+")";
                         where1 = where1.replace("[", "(").replace("]", ")");
                         where1 = where1.replace("[", "(").replace("]", ")");
                     }
                     }
 
 
                 }
                 }
             }
             }
+
             if(StringUtils.isNotBlank(sa_accountclassids)){
             if(StringUtils.isNotBlank(sa_accountclassids)){
                 if(isJSONArray(sa_accountclassids)){
                 if(isJSONArray(sa_accountclassids)){
                     JSONArray jsonArrayResult = JSONArray.parseArray(sa_accountclassids);
                     JSONArray jsonArrayResult = JSONArray.parseArray(sa_accountclassids);
@@ -784,15 +785,16 @@ public class personnelstatistics extends Controller {
             sqlFactory.addParameter("sa_salestargetbillid", sa_salestargetbillid);
             sqlFactory.addParameter("sa_salestargetbillid", sa_salestargetbillid);
             sqlFactory.addParameter_SQL("where", where);
             sqlFactory.addParameter_SQL("where", where);
             if(StringUtils.isNotBlank(statisticaldimension)){
             if(StringUtils.isNotBlank(statisticaldimension)){
-                if(isJSONArray(statisticaldimension)){
-                    JSONArray jsonArrayResult = JSONArray.parseArray(statisticaldimension);
-                    if(!jsonArrayResult.isEmpty()){
-                        where1= where1+ " and (t1.class in"+jsonArrayResult+" or t1.subclass in"+jsonArrayResult+")";
+                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")+")";
                         where1 = where1.replace("[", "(").replace("]", ")");
                         where1 = where1.replace("[", "(").replace("]", ")");
                     }
                     }
 
 
                 }
                 }
             }
             }
+
             if(StringUtils.isNotBlank(sa_accountclassids)){
             if(StringUtils.isNotBlank(sa_accountclassids)){
                 if(isJSONArray(sa_accountclassids)){
                 if(isJSONArray(sa_accountclassids)){
                     JSONArray jsonArrayResult = JSONArray.parseArray(sa_accountclassids);
                     JSONArray jsonArrayResult = JSONArray.parseArray(sa_accountclassids);