Переглянути джерело

Merge branch 'develop' into develop2

hu 9 місяців тому
батько
коміт
184d996206
1 змінених файлів з 316 додано та 5 видалено
  1. 316 5
      src/custom/restcontroller/sale/itemgroup/itemgroup.java

+ 316 - 5
src/custom/restcontroller/sale/itemgroup/itemgroup.java

@@ -480,6 +480,8 @@ public class itemgroup extends Controller {
         }
         factory.addParameter_SQL("where1", where1);
         Rows customschemeItems = dbConnect.runSqlQuery("select * from (select distinct value,description,isonlydisplay,sequence from sa_customscheme_items where  sa_customschemeid in(select t2.sa_customschemeid from sa_itemgroupmx t1 left join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid where t1.siteid='" + siteid + "' and t1.sa_itemgroupid=" + content.getString("sa_itemgroupid") + "))t order by t.sequence asc");
+        Rows customschemeItems1 = dbConnect.runSqlQuery("select * from (select distinct value,description,isonlydisplay,sequence from sa_customscheme_items where isonlydisplay=1 and sa_customschemeid in(select t2.sa_customschemeid from sa_itemgroupmx t1 left join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid where t1.siteid='" + siteid + "' and t1.sa_itemgroupid=" + content.getString("sa_itemgroupid") + "))t order by t.sequence asc");
+        RowsMap customschemeItems1RowsMap = customschemeItems1.toRowsMap("value");
         if (!customschemeItems.isEmpty()) {
             for (Row row : customschemeItems) {
 
@@ -702,7 +704,7 @@ public class itemgroup extends Controller {
             }
 
             factory.addParameter_SQL("where", " 1=1 " + colorwhere + specwhere + materialwhere + cheekwhere);
-        } else {
+        } else if(listParmNotBlank.size()==1){
             String where = " 1=1 ";
             for (String value : listParmNotBlank) {
                 if (value.equals("color")) {
@@ -820,7 +822,7 @@ public class itemgroup extends Controller {
                 if (!isexistParm) {
                     JSONObject jsonObject = new JSONObject();
                     jsonObject.put("parm", firstcolor);
-                    jsonObject.put("flag", false);
+                    jsonObject.put("flag", true);
                     colormap.add(jsonObject);
                 }
             }
@@ -836,7 +838,7 @@ public class itemgroup extends Controller {
                 if (!isexistParm) {
                     JSONObject jsonObject = new JSONObject();
                     jsonObject.put("parm", firstspec);
-                    jsonObject.put("flag", false);
+                    jsonObject.put("flag", true);
                     specmap.add(jsonObject);
                 }
             }
@@ -852,7 +854,7 @@ public class itemgroup extends Controller {
                 if (!isexistParm) {
                     JSONObject jsonObject = new JSONObject();
                     jsonObject.put("parm", firstmaterial);
-                    jsonObject.put("flag", false);
+                    jsonObject.put("flag", true);
                     materialmap.add(jsonObject);
                 }
             }
@@ -868,10 +870,319 @@ public class itemgroup extends Controller {
                 if (!isexistParm) {
                     JSONObject jsonObject = new JSONObject();
                     jsonObject.put("parm", firstcheek);
-                    jsonObject.put("flag", false);
+                    jsonObject.put("flag", true);
                     cheekmap.add(jsonObject);
                 }
             }
+        }else {
+            String where = " 1=1 ";
+            for (String value : listParmNotBlank) {
+                if (value.equals("color")) {
+                    JSONObject jsonObject = new JSONObject();
+                    jsonObject.put("parm", content.getString("color"));
+                    jsonObject.put("flag", true);
+                    colormap.add(jsonObject);
+//                    for (String firstcolor : firstcolorList) {
+//                        JSONObject jsonObject1 =new JSONObject();
+//                        if (!firstcolor.equals(content.getString("color"))) {
+//                            jsonObject1.put("parm",firstcolor);
+//                            jsonObject1.put("flag", true);
+//                            colormap.add(jsonObject1);
+//                        }
+//                    }
+                } else if (value.equals("spec")) {
+                    JSONObject jsonObject = new JSONObject();
+                    jsonObject.put("parm", content.getString("spec"));
+                    jsonObject.put("flag", true);
+                    specmap.add(jsonObject);
+//                    for (String firstspec : firstspecList) {
+//                        JSONObject jsonObject1 =new JSONObject();
+//                        if (!firstspec.equals(content.getString("spec"))) {
+//                            jsonObject1.put("parm",firstspec);
+//                            jsonObject1.put("flag", true);
+//                            specmap.add(jsonObject1);
+//                        }
+//                    }
+                } else if (value.equals("material")) {
+                    JSONObject jsonObject = new JSONObject();
+                    jsonObject.put("parm", content.getString("material"));
+                    jsonObject.put("flag", true);
+                    materialmap.add(jsonObject);
+//                    for (String firstmaterial : firstmaterialList) {
+//                        JSONObject jsonObject1 =new JSONObject();
+//                        if (!firstmaterial.equals(content.getString("material"))) {
+//                            jsonObject1.put("parm",firstmaterial);
+//                            jsonObject1.put("flag", true);
+//                            materialmap.add(jsonObject1);
+//                        }
+//                    }
+                } else if (value.equals("cheek")) {
+                    JSONObject jsonObject = new JSONObject();
+                    jsonObject.put("parm", content.getString("cheek"));
+                    jsonObject.put("flag", true);
+                    cheekmap.add(jsonObject);
+//                    for (String firstcheek : firstcheekList) {
+//                        JSONObject jsonObject1 =new JSONObject();
+//                        if (!firstcheek.equals(content.getString("cheek"))) {
+//                            jsonObject1.put("parm", firstcheek);
+//                            jsonObject1.put("flag", true);
+//                            cheekmap.add(jsonObject1);
+//                        }
+//                    }
+                }
+                where = where + " and " + value + "='" + content.getString(value) + "' ";
+            }
+            factory.addParameter_SQL("where", where);
+            for (String value : listAll) {
+                if (value.equals("color")) {
+                    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")) {
+                    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")) {
+                    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")) {
+                    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);
+                        }
+                    }
+                }
+
+            }
+
+            if(customschemeItems1RowsMap.containsKey("color")){
+                for (String value : listParmNotBlank) {
+                    if(!value.equals("color")){
+                        where=" 1=1 ";
+                        where = where + " and " + value + "='" + content.getString(value) + "' ";
+                    }
+                }
+                factory.addParameter_SQL("where", where);
+                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);
+                    }
+                }
+                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);
+                    }
+                }
+            }else{
+                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);
+                    }
+                }
+            }
+            if(customschemeItems1RowsMap.containsKey("spec")){
+                for (String value : listParmNotBlank) {
+                    if(!value.equals("spec")){
+                        where=" 1=1 ";
+                        where = where + " and " + value + "='" + content.getString(value) + "' ";
+                    }
+                }
+                factory.addParameter_SQL("where", where);
+                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);
+                        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);
+                    }
+                }
+            }else{
+                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);
+                    }
+                }
+            }
+            if(customschemeItems1RowsMap.containsKey("material")){
+                for (String value : listParmNotBlank) {
+                    if(!value.equals("material")){
+                        where=" 1=1 ";
+                        where = where + " and " + value + "='" + content.getString(value) + "' ";
+                    }
+                }
+                factory.addParameter_SQL("where", where);
+                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);
+                        colormap.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);
+                    }
+                }
+            }else{
+                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);
+                    }
+                }
+            }
+            if(customschemeItems1RowsMap.containsKey("cheek")){
+                for (String value : listParmNotBlank) {
+                    if(!value.equals("cheek")){
+                        where=" 1=1 ";
+                        where = where + " and " + value + "='" + content.getString(value) + "' ";
+                    }
+                }
+                factory.addParameter_SQL("where", where);
+                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);
+                        colormap.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);
+                    }
+                }
+            }else{
+                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);
+                    }
+                }
+            }
         }