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

商品组查询商品逻辑修改

hu 3 лет назад
Родитель
Сommit
b341fd0755
1 измененных файлов с 140 добавлено и 87 удалено
  1. 140 87
      src/custom/restcontroller/sale/itemgroup/itemgroup.java

+ 140 - 87
src/custom/restcontroller/sale/itemgroup/itemgroup.java

@@ -450,32 +450,32 @@ public class itemgroup extends Controller {
                 }
             }
         } else if (listParmBlank == null || listParmBlank.size() == 0) {
-            for (Row row : rows) {
-                for (String value : listParmNotBlank) {
-                    if (value.equals("color")) {
-                        JSONObject jsonObject =new JSONObject();
-                        jsonObject.put("parm", row.getString("color"));
-                        jsonObject.put("flag", true);
-                        colormap.add(jsonObject);
-                    } else if (value.equals("spec")) {
-                        JSONObject jsonObject =new JSONObject();
-                        jsonObject.put("parm", row.getString("spec"));
-                        jsonObject.put("flag", true);
-                        specmap.add(jsonObject);
-                    } else if (value.equals("material")) {
-                        JSONObject jsonObject =new JSONObject();
-                        jsonObject.put("parm", row.getString("material"));
-                        jsonObject.put("flag", true);
-                        materialmap.add(jsonObject);
-                    } else if (value.equals("cheek")) {
-                        JSONObject jsonObject =new JSONObject();
-                        jsonObject.put("parm", row.getString("cheek"));
-                        jsonObject.put("flag", true);
-                        cheekmap.add(jsonObject);
-                    }
-
-                }
-            }
+//            for (Row row : rows) {
+//                for (String value : listParmNotBlank) {
+//                    if (value.equals("color")) {
+//                        JSONObject jsonObject =new JSONObject();
+//                        jsonObject.put("parm", row.getString("color"));
+//                        jsonObject.put("flag", true);
+//                        colormap.add(jsonObject);
+//                    } else if (value.equals("spec")) {
+//                        JSONObject jsonObject =new JSONObject();
+//                        jsonObject.put("parm", row.getString("spec"));
+//                        jsonObject.put("flag", true);
+//                        specmap.add(jsonObject);
+//                    } else if (value.equals("material")) {
+//                        JSONObject jsonObject =new JSONObject();
+//                        jsonObject.put("parm", row.getString("material"));
+//                        jsonObject.put("flag", true);
+//                        materialmap.add(jsonObject);
+//                    } else if (value.equals("cheek")) {
+//                        JSONObject jsonObject =new JSONObject();
+//                        jsonObject.put("parm", row.getString("cheek"));
+//                        jsonObject.put("flag", true);
+//                        cheekmap.add(jsonObject);
+//                    }
+//
+//                }
+//            }
             String colorwhere = "";
             String specwhere = "";
             String materialwhere = "";
@@ -491,68 +491,121 @@ public class itemgroup extends Controller {
                     cheekwhere = " and " + value + "='" + content.getString(value) + "' ";
                 }
             }
+            for (String value : listAll) {
+                if (value.equals("color")) {
+                    factory.addParameter_SQL("where", " 1=1 " + specwhere + materialwhere + cheekwhere);
+                     System.out.println(" 1=1 " + specwhere + materialwhere + cheekwhere);
+                    rows = dbConnect.runSqlQuery(factory.getSQL());
+                    if (!rows.isEmpty()) {
+                        for (Row row : rows) {
+                            JSONObject jsonObject =new JSONObject();
+                            jsonObject.put("parm", row.getString("color"));
+                            jsonObject.put("flag", true);
+                            colormap.add(jsonObject);
+                        }
+                    }
+                } else if (value.equals("spec")) {
+                    factory.addParameter_SQL("where", " 1=1 " + colorwhere + materialwhere + cheekwhere);
+                    rows = dbConnect.runSqlQuery(factory.getSQL());
+                    if (!rows.isEmpty()) {
+                        for (Row row : rows) {
+                            JSONObject jsonObject =new JSONObject();
+                            jsonObject.put("parm", row.getString("spec"));
+                            jsonObject.put("flag", true);
+                            specmap.add(jsonObject);
+                        }
+                    }
+                } else if (value.equals("material")) {
+                    factory.addParameter_SQL("where", " 1=1 " + colorwhere + specwhere + cheekwhere);
+                    rows = dbConnect.runSqlQuery(factory.getSQL());
+                    if (!rows.isEmpty()) {
+                        for (Row row : rows) {
+                            JSONObject jsonObject =new JSONObject();
+                            jsonObject.put("parm", row.getString("material"));
+                            jsonObject.put("flag", true);
+                            materialmap.add(jsonObject);
+                        }
+                    }
+                } else if (value.equals("cheek")) {
+                    factory.addParameter_SQL("where", " 1=1 " + colorwhere + specwhere + materialwhere);
+                    rows = dbConnect.runSqlQuery(factory.getSQL());
+                    if (!rows.isEmpty()) {
+                        for (Row row : rows) {
+                            JSONObject jsonObject =new JSONObject();
+                            jsonObject.put("parm", row.getString("cheek"));
+                            jsonObject.put("flag", true);
+                            cheekmap.add(jsonObject);
+                        }
+                    }
+                }
+            }
+
+            for (String firstcolor : firstcolorList) {
+                boolean isexistParm=false;
+                for (Object object:colormap) {
+                    JSONObject jsonObject = (JSONObject) object;
+                    if(jsonObject.getString("parm").equals(firstcolor)){
+                        isexistParm=true;
+                        break;
+                    }
+                }
+                if (!isexistParm) {
+                    JSONObject jsonObject =new JSONObject();
+                    jsonObject.put("parm", firstcolor);
+                    jsonObject.put("flag", false);
+                    colormap.add(jsonObject);
+                }
+            }
+            for (String firstspec : firstspecList) {
+                boolean isexistParm=false;
+                for (Object object:specmap) {
+                    JSONObject jsonObject = (JSONObject) object;
+                    if(jsonObject.getString("parm").equals(firstspec)){
+                        isexistParm=true;
+                        break;
+                    }
+                }
+                if (!isexistParm) {
+                    JSONObject jsonObject =new JSONObject();
+                    jsonObject.put("parm", firstspec);
+                    jsonObject.put("flag", false);
+                    specmap.add(jsonObject);
+                }
+            }
+            for (String firstmaterial : firstmaterialList) {
+                boolean isexistParm=false;
+                for (Object object:materialmap) {
+                    JSONObject jsonObject = (JSONObject) object;
+                    if(jsonObject.getString("parm").equals(firstmaterial)){
+                        isexistParm=true;
+                        break;
+                    }
+                }
+                if (!isexistParm) {
+                    JSONObject jsonObject =new JSONObject();
+                    jsonObject.put("parm", firstmaterial);
+                    jsonObject.put("flag", false);
+                    materialmap.add(jsonObject);
+                }
+            }
+            for (String firstcheek : firstcheekList) {
+                boolean isexistParm=false;
+                for (Object object:cheekmap) {
+                    JSONObject jsonObject = (JSONObject) object;
+                    if(jsonObject.getString("parm").equals(firstcheek)){
+                        isexistParm=true;
+                        break;
+                    }
+                }
+                if (!isexistParm) {
+                    JSONObject jsonObject =new JSONObject();
+                    jsonObject.put("parm", firstcheek);
+                    jsonObject.put("flag", false);
+                    cheekmap.add(jsonObject);
+                }
+            }
+
             factory.addParameter_SQL("where", " 1=1 " + colorwhere + specwhere + materialwhere+cheekwhere);
-//             System.out.println("listParmBlank");
-
-//            for (String value : listAll) {
-//                if (value.equals("color")) {
-//                    factory.addParameter_SQL("where", " 1=1 " + specwhere + materialwhere + cheekwhere);
-//                     System.out.println(" 1=1 " + specwhere + materialwhere + cheekwhere);
-//                    rows = dbConnect.runSqlQuery(factory.getSQL());
-//                    if (!rows.isEmpty()) {
-//                        for (Row row : rows) {
-//                            colormap.put(row.getString("color"), true);
-//                        }
-//                    }
-//                } else if (value.equals("spec")) {
-//                    factory.addParameter_SQL("where", " 1=1 " + colorwhere + materialwhere + cheekwhere);
-//                    rows = dbConnect.runSqlQuery(factory.getSQL());
-//                    if (!rows.isEmpty()) {
-//                        for (Row row : rows) {
-//                            specmap.put(row.getString("spec"), true);
-//                        }
-//                    }
-//                } else if (value.equals("material")) {
-//                    factory.addParameter_SQL("where", " 1=1 " + colorwhere + specwhere + cheekwhere);
-//                    rows = dbConnect.runSqlQuery(factory.getSQL());
-//                    if (!rows.isEmpty()) {
-//                        for (Row row : rows) {
-//                            materialmap.put(row.getString("material"), true);
-//                        }
-//                    }
-//                } else if (value.equals("cheek")) {
-//                    factory.addParameter_SQL("where", " 1=1 " + colorwhere + specwhere + materialwhere);
-//                    rows = dbConnect.runSqlQuery(factory.getSQL());
-//                    if (!rows.isEmpty()) {
-//                        for (Row row : rows) {
-//                            cheekmap.put(row.getString("cheek"), true);
-//                        }
-//                    }
-//                }
-//            }
-//
-//            for (String firstcolor : firstcolorList) {
-//                if (!colormap.containsKey(firstcolor)) {
-//                    colormap.put(firstcolor, false);
-//                }
-//            }
-//            for (String firstspec : firstspecList) {
-//                if (!specmap.containsKey(firstspec)) {
-//                    specmap.put(firstspec, false);
-//                }
-//            }
-//            for (String firstmaterial : firstmaterialList) {
-//                if (!materialmap.containsKey(firstmaterial)) {
-//                    materialmap.put(firstmaterial, false);
-//                }
-//            }
-//            for (String firstcheek : firstcheekList) {
-//                if (!cheekmap.containsKey(firstcheek)) {
-//                    cheekmap.put(firstcheek, false);
-//                }
-//            }
-//
-//            factory.addParameter_SQL("where", " 1=1 " + colorwhere + specwhere + materialwhere+cheekwhere);
         } else {
             String where = " 1=1 ";
             for (String value : listParmNotBlank) {