private void test(@RequestBody Map<String, Object> paramMap) {
List<Map<String, Object>> clientLogList = new ArrayList<Map<String, Object>>();
Map<String, Object> a1 = new HashMap<String, Object>();
a1.put("id", "001");
a1.put("aa1", "aa000011");
a1.put("aa2", "aa000021");
Map<String, Object> a2 = new HashMap<String, Object>();
a2.put("id", "002");
a2.put("aa1", "aa000012");
a2.put("aa2", "aa000022");
Map<String, Object> a3 = new HashMap<String, Object>();
a3.put("id", "002");
a3.put("aa1", "aa000013");
a3.put("aa2", "aa000023");
Map<String, Object> a4 = new HashMap<String, Object>();
a4.put("id", "003");
a4.put("aa1", "aa000014");
a4.put("aa2", "aa000024");
Map<String, Object> a5 = new HashMap<String, Object>();
a5.put("id", "003");
a5.put("aa1", "aa000015");
a5.put("aa2", "aa000025");
Map<String, Object> a6 = new HashMap<String, Object>();
a6.put("id", "003");
a6.put("aa1", "aa000016");
a6.put("aa2", "aa000026");
clientLogList.add(a1);
clientLogList.add(a2);
clientLogList.add(a3);
clientLogList.add(a4);
clientLogList.add(a5);
clientLogList.add(a6);
List<Map<String, Object>> firstLogList = new ArrayList<Map<String, Object>>();
Map<String, Object> b1 = new HashMap<String, Object>();
b1.put("id", "001");
b1.put("bb1", "bb000011");
b1.put("bb2", "bb000021");
Map<String, Object> b2 = new HashMap<String, Object>();
b2.put("id", "002");
b2.put("bb1", "bb000012");
b2.put("bb2", "bb000022");
Map<String, Object> b3 = new HashMap<String, Object>();
b3.put("id", "003");
b3.put("bb1", "bb000013");
b3.put("bb2", "bb000023");
firstLogList.add(b1);
firstLogList.add(b2);
firstLogList.add(b3);
A: for (Map<String, Object> clientLogMap:clientLogList) {
String clogUserid = (String) clientLogMap.get("id");
B: for (Map<String, Object> firstLog:firstLogList) {
String flogUserid = (String) firstLog.get("id");//去除两种空格格式
//4.4 当firstlog表的userid==clientlog表的userid时,将displayname和usercn封装到本次查询结果的clientLogMap中
if (flogUserid.equalsIgnoreCase(clogUserid)) {
clientLogMap.put("bb1", firstLog.get("bb1"));
clientLogMap.put("bb2", firstLog.get("bb2"));
break;// break语句对if-else的条件语句不起作用(continue对其起作用);在多层循环中, 一个break语句只向外跳一层。
}
}
}
}
小测试--多层循环跳出方式
最新推荐文章于 2022-02-20 11:47:07 发布