map做判断

判断多种状态的时候 一定要用map 关联!在这里插入图片描述
if (attrInfoList != null && attrInfoList.size() > 0) {
for (int i = 0; i < materialModelInfoListNew.size(); i++) {
String ss = “”;
String ss1 = “”;
ss2 = “”;
Map<String, Object> modelMap = materialModelInfoListNew.get(i).getData();
List fieldList = attrInfoList.get(0).getFieldList();
for (int j = 0; j < fieldList.size(); j++) {
if (j == 0) {
ss = “”;
}else {
ss = “_”;
}
if (fieldList.get(j).getType()==1&&!fieldList.get(j).getCode().equals(“FLD_CODE”)){
for (Map.Entry<String, Object> entryN : modelMap.entrySet()) {
if (entryN.getKey().equals(fieldList.get(j).getCode())){
ss1 = ss1+ss+String.valueOf(entryN.getValue()) ;
}
}
} else if (fieldList.get(j).getCode().equals(“FLD_CODE”)) {
for (Map.Entry<String, Object> entryN : modelMap.entrySet()) {
if (entryN.getKey().equals(“FLD_CODE”)){
code2= String.valueOf(entryN.getValue());
}
}
}
}
String substring = ss1.substring(1, ss1.length());
arrS.put(substring,code2);
}

                for (Map.Entry<String, String> entryN : arrS.entrySet()) {
                    if ((entryN.getKey().equals(materialModelString)&&entryN.getValue().equals(code))||
                            (!entryN.getKey().equals(materialModelString)&&!entryN.getValue().equals(code))){
                        dataMap.put("materialModelString", "1");
                    }
                    if (entryN.getKey().equals(materialModelString)&&!entryN.getValue().equals(code)){
                        dataMap.put("materialModelString", "2");//该型号已经存在,是否选取已有型号
                        if (attrInfoList != null && attrInfoList.size() > 0) {
                            for (int i = 0; i < materialModelInfoListNew.size(); i++) {
                                String ss = "";
                                String ss1 = "";
                                Map<String, Object> modelMap = materialModelInfoListNew.get(i).getData();
                                List<CustomAttrField> fieldList = attrInfoList.get(0).getFieldList();
                                for (int h = 0; h < fieldList.size(); h++) {
                                    if (h == 0) {
                                        ss = "";
                                    }else {
                                        ss = "_";
                                    }
                                    if (fieldList.get(h).getType()==1&&!fieldList.get(h).getCode().equals("FLD_CODE")){
                                        for (Map.Entry<String, Object> entryN1 : modelMap.entrySet()) {
                                            if (entryN1.getKey().equals(fieldList.get(h).getCode())){
                                                ss1 = ss1+ss+String.valueOf(entryN1.getValue()) ;
                                            }
                                        }
                                    }
                                }
                                String substring = ss1.substring(1, ss1.length());
                                if (substring.equals(materialModelString)){
                                    code= materialModelInfoListNew.get(i).getCode();
                                }

                            }
                        }
                        dataMap.put("materialModelCode", code);
                    }
                    if (!entryN.getKey().equals(materialModelString)&&entryN.getValue().equals(code)){
                        dataMap.put("materialModelString", "3");//该编号已存在,请修改编号
                    }
                }
已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页