Browse Source

经销商业绩列表(区域经理)接口优化

hu 1 year ago
parent
commit
f38c83e6fa

+ 78 - 34
src/custom/restcontroller/webmanage/sale/salestarget/enterprisetarget.java

@@ -260,17 +260,63 @@ public class enterprisetarget extends Controller {
 
         Rows actualRows = new Rows();
         //开票
-//        if (assessmentindicators.equals("开票")) {
-//            sqlFactory = new SQLFactory(this, "企业-开票");
-//        }
-//        //订单
-//        if (assessmentindicators.equals("订单")) {
-//            sqlFactory = new SQLFactory(this, "企业-订单");
-//        }
-//        //出货
-//        if (assessmentindicators.equals("出货")) {
-//            sqlFactory = new SQLFactory(this, "企业-出货");
-//        }
+        if (assessmentindicators.equals("开票")) {
+            String where1=" 1=1 ";
+            sqlFactory = new SQLFactory(new enterprise(new JSONObject()), "企业-开票");
+            if(statisticaldimension.equals("订单审核")){
+                where1=where1+" and t2.status='审核' ";
+            }else{
+                where1=where1+" and t2.status='提交' ";
+            }
+            if(StringUtils.isNotBlank(sa_accountclassids)){
+                if(isJSONArray(sa_accountclassids)){
+                    JSONArray jsonArrayResult = JSONArray.parseArray(sa_accountclassids);
+                    if(!jsonArrayResult.isEmpty()){
+                        where1=where1+ " and t2.sa_accountclassid in"+jsonArrayResult;
+                        where1 = where1.replace("[", "(").replace("]", ")");
+                    }
+
+                }
+            }
+            sqlFactory.addParameter_SQL("where1",where1);
+        }
+        //订单
+        if (assessmentindicators.equals("订单")) {
+            String where1=" 1=1 ";
+            sqlFactory = new SQLFactory(new enterprise(new JSONObject()), "企业-订单");
+            if(statisticaldimension.equals("订单审核")){
+                where1=where1+" and t2.status='审核' ";
+            }else{
+                where1=where1+" and t2.status='提交' ";
+            }
+            if(StringUtils.isNotBlank(sa_accountclassids)){
+                if(isJSONArray(sa_accountclassids)){
+                    JSONArray jsonArrayResult = JSONArray.parseArray(sa_accountclassids);
+                    if(!jsonArrayResult.isEmpty()){
+                        where1=where1+ " and t2.sa_accountclassid in"+jsonArrayResult;
+                        where1 = where1.replace("[", "(").replace("]", ")");
+                    }
+
+                }
+            }
+            sqlFactory.addParameter_SQL("where1",where1);
+        }
+        //出货
+        if (assessmentindicators.equals("出货")) {
+            String where1=" 1=1 ";
+            sqlFactory = new SQLFactory(new enterprise(new JSONObject()), "企业-出货");
+            if(StringUtils.isNotBlank(sa_accountclassids)){
+                if(isJSONArray(sa_accountclassids)){
+                    JSONArray jsonArrayResult = JSONArray.parseArray(sa_accountclassids);
+                    if(!jsonArrayResult.isEmpty()){
+                        where1=where1+ " and t2.sa_accountclassid in"+jsonArrayResult;
+                        where1 = where1.replace("[", "(").replace("]", ")");
+                    }
+
+                }
+            }
+            sqlFactory.addParameter_SQL("where1",where1);
+        }
         //收款
         if (assessmentindicators.equals("收款")) {
             sqlFactory = new SQLFactory(new enterprise(new JSONObject()), "企业-收款");
@@ -303,31 +349,29 @@ public class enterprisetarget extends Controller {
         }
         for (Row row : rows) {
             //初始化
-            if (assessmentindicators.equals("收款")) {
-                row = addActualRow(row);
-                Long year = row.getLong("year");
-                Long sys_enterpriseid = row.getLong("sys_enterpriseid");
-                Row actualRow = new Row();
-                for (Row tempActualRow : actualRows) {
-                    if (tempActualRow.getLong("year") == year && tempActualRow.getLong("sys_enterpriseid")==sys_enterpriseid) {
-                        actualRow.putAll(tempActualRow);
-                    }
-                }
-                row.putAll(actualRow);
-                row.putAll(calculate(row, actualRow));
-                Rows monthRows = new Rows();
-                for (int i = 1; i < 13; i++) {
-                    Row monthRow = new Row();
-                    monthRow.put("l", row.getString("m" + i + "l"));
-                    monthRow.put("h", row.getString("m" + i + "h"));
-                    monthRow.put("a", row.getString("m" + i + "a"));
-                    monthRow.put("pl", row.getString("m" + i + "pl"));
-                    monthRow.put("ph", row.getString("m" + i + "ph"));
-                    monthRow.put("month", i);
-                    monthRows.add(monthRow);
+            row = addActualRow(row);
+            Long year = row.getLong("year");
+            Long sys_enterpriseid = row.getLong("sys_enterpriseid");
+            Row actualRow = new Row();
+            for (Row tempActualRow : actualRows) {
+                if (tempActualRow.getLong("year") == year && tempActualRow.getLong("sys_enterpriseid")==sys_enterpriseid) {
+                    actualRow.putAll(tempActualRow);
                 }
-                row.put("month", monthRows);
             }
+            row.putAll(actualRow);
+            row.putAll(calculate(row, actualRow));
+            Rows monthRows = new Rows();
+            for (int i = 1; i < 13; i++) {
+                Row monthRow = new Row();
+                monthRow.put("l", row.getString("m" + i + "l"));
+                monthRow.put("h", row.getString("m" + i + "h"));
+                monthRow.put("a", row.getString("m" + i + "a"));
+                monthRow.put("pl", row.getString("m" + i + "pl"));
+                monthRow.put("ph", row.getString("m" + i + "ph"));
+                monthRow.put("month", i);
+                monthRows.add(monthRow);
+            }
+            row.put("month", monthRows);
 
         }