ソースを参照

商品列表支持领域筛选

郭齐峰 3 年 前
コミット
dd651d31b3

+ 4 - 9
src/custom/restcontroller/webmanage/sale/item/Item.java

@@ -363,15 +363,10 @@ public class Item extends Controller {
                 }
                 }
             }
             }
 
 
-            if (whereObject.containsKey("tradefield") && !whereObject.getJSONArray("tradefield").isEmpty()) {
-                String where1 = " 1=1 ";
-                if (whereObject.getJSONArray("tradefield").size() > 0) {
-                    for (Object object : whereObject.getJSONArray("tradefield")) {
-                        String str = String.valueOf(object);
-                        where1 = where1 + " or tradefield ='" + str + "' ";
-                    }
-                }
-                where.append("and t1.itemid in (SELECT itemid from plm_item_tradefield WHERE (" + where1 + ") and siteid = '" + siteid + "')");
+            if (whereObject.containsKey("tradefield") && !whereObject.getString("tradefield").isEmpty()) {
+                where.append(" and exists(");
+                where.append(" select 1 from plm_item_tradefield t3 where t3.siteid=t1.siteid and t3.itemid=t1.itemid and t3.tradefield='").append(whereObject.getString("tradefield")).append("' ");
+                where.append(")");
             }
             }
 
 
         }
         }

+ 2 - 2
src/custom/restcontroller/webmanage/sale/item/SQL/货品档案列表.sql

@@ -30,7 +30,7 @@ SELECT t1.itemid,
        t1.cheek,
        t1.cheek,
        t1.delistingstatus,
        t1.delistingstatus,
        t6.auxunitid,
        t6.auxunitid,
-       t6.	unitgroupname,
+       t6.unitgroupname,
        t7.unitname axunitname,
        t7.unitname axunitname,
        t8.caliber,
        t8.caliber,
        t8.pressure,
        t8.pressure,
@@ -51,6 +51,6 @@ FROM plm_item t1
          LEFT JOIN plm_unit t2 ON t2.unitid = t1.unitid AND t2.siteid = t1.siteid
          LEFT JOIN plm_unit t2 ON t2.unitid = t1.unitid AND t2.siteid = t1.siteid
          LEFT JOIN plm_unitgroup t6 ON t6.unitgroupid = t1.unitgroupid
          LEFT JOIN plm_unitgroup t6 ON t6.unitgroupid = t1.unitgroupid
          LEFT JOIN plm_unit t7 ON t7.unitid = t6.unitid AND t7.siteid = t6.siteid
          LEFT JOIN plm_unit t7 ON t7.unitid = t6.unitid AND t7.siteid = t6.siteid
-         LEFT JOIN plm_itemextend t8 ON t8.itemid= t1.itemid AND t8.siteid = t1.siteid
+         LEFT JOIN plm_itemextend t8 ON t8.itemid = t1.itemid AND t8.siteid = t1.siteid
 WHERE t1.siteid = $siteid$
 WHERE t1.siteid = $siteid$
   and $where$
   and $where$