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

商品校验必填项代码

eganwu 1 рік тому
батько
коміт
bf4bbda0b8
1 змінених файлів з 71 додано та 34 видалено
  1. 71 34
      src/custom/restcontroller/webmanage/sale/item/Item.java

+ 71 - 34
src/custom/restcontroller/webmanage/sale/item/Item.java

@@ -649,40 +649,77 @@ public class Item extends Controller {
                     return getErrReturnObject().setErrMsg("审核失败,请先维护营销分类").toString();
                 }
             }
-//            Rows tradefields = dbConnect.runSqlQuery("SELECT * from plm_item_tradefield WHERE itemid=" + id + " and siteid='" + siteid + "'");
-//            if (tradefields.isEmpty()) {
-//                return getErrReturnObject().setErrMsg("领域栏位未维护,请维护完整后再试!").toString();
-//            }
-//            Row item = dbConnect.runSqlQuery(0, "SELECT * from plm_item WHERE itemid=" + id + " and siteid='" + siteid + "'");
-//
-//            if (item.getLong("sa_customschemeid") == 0) {
-//                return getErrReturnObject().setErrMsg("选项方案栏位未维护,请维护完整后再试!").toString();
-//            }
-//            if (StringUtils.isBlank(item.getString("spec"))) {
-//                return getErrReturnObject().setErrMsg("尺寸栏位未维护,请维护完整后再试!").toString();
-//            }
-//            Rows itemextends = dbConnect.runSqlQuery("SELECT * from plm_itemextend WHERE itemid=" + id + " and siteid='" + siteid + "'");
-//            if (itemextends.isEmpty()) {
-//                return getErrReturnObject().setErrMsg("选项栏位未维护,请维护完整后再试!").toString();
-//            }
-//            if (itemextends.isNotEmpty() && StringUtils.isBlank(itemextends.get(0).getString("material"))) {
-//                return getErrReturnObject().setErrMsg("选项栏位未维护,请维护完整后再试!").toString();
-//            }
-//            if (StringUtils.isBlank(item.getString("cheek"))) {
-//                return getErrReturnObject().setErrMsg("工艺栏位未维护,请维护完整后再试!").toString();
-//            }
-//            if (StringUtils.isBlank(item.getString("color"))) {
-//                return getErrReturnObject().setErrMsg("颜色栏位未维护,请维护完整后再试!").toString();
-//            }
-//
-//            if (item.getBoolean("iscustomsize")) {
-//                if (item.getLong("lengthschemeid") == 0) {
-//                    return getErrReturnObject().setErrMsg("长栏位未维护,请维护完整后再试!").toString();
-//                }
-//                if (item.getLong("widthschemeid") == 0) {
-//                    return getErrReturnObject().setErrMsg("宽栏位未维护,请维护完整后再试!").toString();
-//                }
-//            }
+            Rows tradefields = dbConnect.runSqlQuery("SELECT * from plm_item_tradefield WHERE itemid=" + id + " and siteid='" + siteid + "'");
+            if (tradefields.isEmpty()) {
+                return getErrReturnObject().setErrMsg("领域栏位未维护,请维护完整后再试!").toString();
+            }
+            Row item = dbConnect.runSqlQuery(0, "SELECT * from plm_item WHERE itemid=" + id + " and siteid='" + siteid + "'");
+            Long sa_customschemeid = item.getLong("sa_customschemeid");
+            if (sa_customschemeid == 0) {
+                return getErrReturnObject().setErrMsg("选项方案栏位未维护,请维护完整后再试!").toString();
+            }
+
+            RowsMap customschemeItemsRowsMap = dbConnect.runSqlQuery("SELECT * from sa_customscheme_items WHERE sa_customschemeid=" + sa_customschemeid + " and siteid='" + siteid + "'").toRowsMap("value");
+
+            if (customschemeItemsRowsMap.containsKey("spec")) {
+                String description = customschemeItemsRowsMap.get("spec").get(0).getString("description");
+                String spec = item.getString("spec");
+                if (StringUtils.isBlank(spec)) {
+                    return getErrReturnObject().setErrMsg(description + "栏位未维护,请维护完整后再试!").toString();
+                }
+                if (spec.equals("custom") && item.getBoolean("iscustomsize")) {
+                    if (item.getLong("lengthschemeid") == 0) {
+                        return getErrReturnObject().setErrMsg("长栏位未维护,请维护完整后再试!").toString();
+                    }
+                    if (item.getLong("widthschemeid") == 0) {
+                        return getErrReturnObject().setErrMsg("宽栏位未维护,请维护完整后再试!").toString();
+                    }
+                }
+            }
+            if (customschemeItemsRowsMap.containsKey("material")) {
+                String description = customschemeItemsRowsMap.get("material").get(0).getString("description");
+                Rows itemextends = dbConnect.runSqlQuery("SELECT * from plm_itemextend WHERE itemid=" + id + " and siteid='" + siteid + "'");
+                String material = itemextends.get(0).getString("material");
+                if (itemextends.isEmpty()) {
+                    return getErrReturnObject().setErrMsg(description + "栏位未维护,请维护完整后再试!").toString();
+                }
+                if (itemextends.isNotEmpty() && StringUtils.isBlank(material)) {
+                    return getErrReturnObject().setErrMsg(description + "栏位未维护,请维护完整后再试!").toString();
+                }
+                if (material.equals("custom") && item.getBoolean("iscustomsize")) {
+                    if (item.getLong("materialschemeid") == 0) {
+                        return getErrReturnObject().setErrMsg(description + "栏位未维护,请维护完整后再试!").toString();
+                    }
+
+                }
+            }
+            if (customschemeItemsRowsMap.containsKey("cheek")) {
+                String description = customschemeItemsRowsMap.get("cheek").get(0).getString("description");
+                String cheek = item.getString("cheek");
+                if (StringUtils.isBlank(cheek)) {
+                    return getErrReturnObject().setErrMsg(description+"栏位未维护,请维护完整后再试!").toString();
+                }
+                if (cheek.equals("custom") && item.getBoolean("iscustomsize")) {
+                    if (item.getLong("cheekschemeid") == 0) {
+                        return getErrReturnObject().setErrMsg(description + "栏位未维护,请维护完整后再试!").toString();
+                    }
+
+                }
+            }
+
+            if (customschemeItemsRowsMap.containsKey("color")) {
+                String description = customschemeItemsRowsMap.get("color").get(0).getString("description");
+                String color = item.getString("color");
+                if (StringUtils.isBlank(color)) {
+                    return getErrReturnObject().setErrMsg(color+"栏位未维护,请维护完整后再试!").toString();
+                }
+                if (color.equals("custom") && item.getBoolean("iscustomsize")) {
+                    if (item.getLong("colorschemeid") == 0) {
+                        return getErrReturnObject().setErrMsg(description + "栏位未维护,请维护完整后再试!").toString();
+                    }
+
+                }
+            }
 
 
             SQLFactory sqlFactory = new SQLFactory(this, "货品档案审核");