Просмотр исходного кода

存货类别查询速度优化

shenjingwei 1 неделя назад
Родитель
Сommit
34e2bf6e54

+ 0 - 5
src/custom/restcontroller/R.java

@@ -6726,11 +6726,6 @@ public class R {
         public static class v1 {
         }
     }
-
-    public static class ID2025092514095201 {
-        public static class v1 {
-        }
-    }
 }
 
 

+ 19 - 78
src/custom/restcontroller/webmanage/sale/itemclass/itemclass.java

@@ -224,7 +224,9 @@ public class itemclass extends Controller {
         }
 
         Rows rows = Enterprise.getBrands(this, sys_enterpriseid);
-
+        if (sa_brandid > 0) {
+            rows = rows.filter("sa_brandid", sa_brandid);
+        }
         for (Row row : rows) {
             //查询所有分类
 
@@ -235,87 +237,26 @@ public class itemclass extends Controller {
             sqlFactory.addParameter_SQL("where", where);
             sqlFactory.addParameter_SQL("where2", where2);
             Rows allrows = dbConnect.runSqlQuery(sqlFactory.getSQL());
-            /*
-             * 获取所有一级分类
-             */
-            RowsMap allrowsMap = allrows.toRowsMap("parentid");
-            Rows toprows = allrows.toRowsMap("parentid").get("0");
-            Collections.sort(toprows, new SortByNum());
-            /*
-             * 递归查询
-             */
-            for (Row row1 : toprows) {
-                Rows rows1 = getSubItemclass(row1, allrowsMap);
-                row1.put("subdep", rows1);
-            }
-            row.put("ttemclass", toprows);
-        }
-
-        if (sa_brandid > 0) {
-            Rows rows2 = new Rows();
-            if (!rows.isEmpty()) {
-                for (Row row : rows) {
-                    if (row.getLong("sa_brandid") == sa_brandid) {
-                        rows2.add(row);
-                    }
-                }
-            }
-            if (rows2.isNotEmpty()) {
-                if (((Rows) rows2.get(0).get("ttemclass")).isNotEmpty()) {
-                    Collections.sort((Rows) rows2.get(0).get("ttemclass"), new SortByNum());
-                }
-            }
-            return getSucReturnObject().setData(rows2).toString();
-        }
-        return getSucReturnObject().setData(rows).toString();
-    }
-
-    @API(title = "商品分类查询", apiversion = R.ID2025092514095201.v1.class)
-    @CACHEING(life = 10)
-    public String queryAllItemclass() throws YosException {
-        long sa_brandid = content.getLongValue("sa_brandid");
-        if (content.containsKey("sys_enterpriseid")) {
-            sys_enterpriseid = content.getLongValue("sys_enterpriseid");
-        }
-
-        String where = " 1=1 ";
-        String where2 = " 1=1 ";
-
-
-        if (content_where.containsKey("istool") && !"".equals(content_where.getString("istool"))) {
-            where = where + " and (ifnull(t1.istool,0) ='" + content_where.getString("istool") + "') ";
-            where2 = where2 + " and (ifnull(t2.istool,0) ='" + content_where.getString("istool") + "') ";
-        }
 
-        if (content_where.containsKey("ishide") && !"".equals(content_where.getString("ishide"))) {
-            where = where + " and (ifnull(t1.ishide,0) ='" + content_where.getString("ishide") + "') ";
-            where2 = where2 + " and (ifnull(t2.ishide,0) ='" + content_where.getString("ishide") + "') ";
-        }
-
-        if (sys_enterpriseid > 0 && content.getStringValue("classtype").equalsIgnoreCase("营销")) {
-            Row enterpriseRow = Enterprise.getEnterprise(this, sys_enterpriseid);
-            if (!enterpriseRow.isEmpty()) {
-                if (enterpriseRow.getBoolean("saleclassauth")) {
-                    where = where + " and t1.itemclassid in ( SELECT itemclassid from sys_enterprise_saleclass WHERE sys_enterpriseid = "
-                            + sys_enterpriseid + " and siteid='" + siteid + "')";
+            if (content.getBooleanValue("isnottree")) {
+                row.put("ttemclass", allrows);
+            } else {
+                /*
+                 * 获取所有一级分类
+                 */
+                RowsMap allrowsMap = allrows.toRowsMap("parentid");
+                Rows toprows = allrows.toRowsMap("parentid").get("0");
+                Collections.sort(toprows, new SortByNum());
+                /*
+                 * 递归查询
+                 */
+                for (Row row1 : toprows) {
+                    Rows rows1 = getSubItemclass(row1, allrowsMap);
+                    row1.put("subdep", rows1);
                 }
+                row.put("ttemclass", toprows);
             }
-        }
 
-        Rows rows = Enterprise.getBrands(this, sys_enterpriseid);
-        if (sa_brandid > 0) {
-            rows = rows.filter("sa_brandid", sa_brandid);
-        }
-        for (Row row : rows) {
-            //查询所有分类
-            SQLFactory sqlFactory = new SQLFactory(this, "查询所有分类");
-            sqlFactory.addParameter("siteid", siteid);
-            sqlFactory.addParameter("sa_brandid", row.getString("sa_brandid"));
-            sqlFactory.addParameter("classtype", content.getStringValue("classtype"));
-            sqlFactory.addParameter_SQL("where", where);
-            sqlFactory.addParameter_SQL("where2", where2);
-            Rows allrows = dbConnect.runSqlQuery(sqlFactory.getSQL());
-            row.put("itemclass", allrows);
         }
         return getSucReturnObject().setData(rows).toString();
     }