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

商品档案选项查询调整

沈静伟 3 лет назад
Родитель
Сommit
6d04805364

+ 13 - 0
src/rest/openapi/restcontroller/wechatapp/titem/SQL/商品档案选项查询.sql

@@ -0,0 +1,13 @@
+select distinct 'fvalue1'field,fvalue1 as value from titem where siteid=$siteid$ and isnull(fvalue1,'')!=''
+union all
+select distinct 'fvalue2'field,fvalue2 as value from titem where siteid=$siteid$ and isnull(fvalue2,'')!=''
+union all
+select distinct 'fvalue3'field,fvalue3 as value from titem where siteid=$siteid$ and isnull(fvalue3,'')!=''
+union all
+select distinct 'fvalue4'field,fvalue4 as value from titem where siteid=$siteid$ and isnull(fvalue4,'')!=''
+union all
+select distinct 'fvalue5'field,fvalue5 as value from titem where siteid=$siteid$ and isnull(fvalue5,'')!=''
+union all
+select distinct 'fvalue6'field,fvalue6 as value from titem where siteid=$siteid$ and isnull(fvalue6,'')!=''
+union all
+select distinct 'fvalue7'field,fvalue7 as value from titem where siteid=$siteid$ and isnull(fvalue7,'')!=''

+ 12 - 7
src/rest/openapi/restcontroller/wechatapp/titem/Titem.java

@@ -18,6 +18,7 @@ import p2.util.P2Exception;
 import titem.icinvbalMsg;
 import titem.titem;
 
+import java.sql.SQLData;
 import java.util.Arrays;
 import java.util.HashMap;
 
@@ -229,7 +230,8 @@ public class Titem extends Controller {
             JSONObject whereObject = content.getJSONObject("where");
 
             if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
-                where = where + " and(t1.fitemname like'%" + whereObject.getString("condition") + "%' or t1.fspec like '%" + whereObject.getString("condition") + "%' or t1.fmodel like'%" + whereObject.getString("condition") + "%')";
+                //where = where + " and(t1.fitemname like'%" + whereObject.getString("condition") + "%' or t1.fspec like '%" + whereObject.getString("condition") + "%' or t1.fmodel like'%" + whereObject.getString("condition") + "%')";
+                where = where + " and(t1.fitemname like'%" + whereObject.getString("condition") + "%' or t1.fitemno='" + whereObject.getString("condition") + "' or t1.fspec like '%" + whereObject.getString("condition") + "%' or t1.fmodel like'%" + whereObject.getString("condition") + "%')";
             }
             if (whereObject.containsKey("fspec") && !"".equals(whereObject.getString("fspec"))) {
                 where = where + " and t1.fspec ='" + whereObject.getString("fspec") + "'";
@@ -369,7 +371,8 @@ public class Titem extends Controller {
             JSONObject whereObject = content.getJSONObject("where");
 
             if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
-                where = where + " and(t1.fitemname like'%" + whereObject.getString("condition") + "%' or t1.fspec like '%" + whereObject.getString("condition") + "%' or t1.fmodel like'%" + whereObject.getString("condition") + "%')";
+                // where = where + " and(t1.fitemname like'%" + whereObject.getString("condition") + "%' or t1.fspec like '%" + whereObject.getString("condition") + "%' or t1.fmodel like'%" + whereObject.getString("condition") + "%')";
+                where = where + " and(t1.fitemname like'%" + whereObject.getString("condition") + "%' or t1.fitemno='" + whereObject.getString("condition") + "' or t1.fspec like '%" + whereObject.getString("condition") + "%' or t1.fmodel like'%" + whereObject.getString("condition") + "%')";
             }
             if (whereObject.containsKey("fspec") && !"".equals(whereObject.getString("fspec"))) {
                 where = where + " and t1.fspec ='" + whereObject.getString("fspec") + "'";
@@ -1335,13 +1338,15 @@ public class Titem extends Controller {
     }
 
     public String query_itemvalueclass() {
-        String[] fieldlist = new String[]{"fvalue1", "fvalue2", "fvalue3", "fvalue4", "fvalue5", "fvalue6", "fvalue7"};
+        SQLFactory sqlFactory = new SQLFactory(this, "ÉÌÆ·µµ°¸Ñ¡Ïî²éѯ");
+        sqlFactory.addParameter("siteid", siteid);
 
-        JSONObject object = new JSONObject();
         DBConnect dbConnect = new DBConnect();
-        for (String field : fieldlist) {
-            Rows rows = dbConnect.runSqlQuery("select value from ps_databind_list where databindid='ITEM_" + field + "' and siteid='" + siteid + "'");
-            object.put(field, rows.toJsonArray("value"));
+        RowsMap rowsMap = dbConnect.runSqlQuery(sqlFactory.getSQL()).toRowsMap("field");
+
+        JSONObject object = new JSONObject();
+        for (String field : rowsMap.keySet()) {
+            object.put(field, rowsMap.get(field).toJsonArray("value"));
         }
         return getReturnObject_suc(object, true).toString();
     }