Kaynağa Gözat

存货类别查询速度优化

shenjingwei 2 hafta önce
ebeveyn
işleme
2cdc33c0b5

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

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

+ 51 - 0
src/custom/restcontroller/webmanage/sale/itemclass/itemclass.java

@@ -270,6 +270,57 @@ public class itemclass extends Controller {
         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 + "')";
+                }
+            }
+        }
+
+        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();
+    }
+
+
     /**
      * 递归查询下级产品类别
      *