import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.commons.lang3.StringUtils;
import org.junit.Test;
public class MapTestCase {
@Test
public void test(){
//A 表字段2
String[] array = {"张三,王五", "李四,王五", "张三,李四"};
//B 表
Map<String, String> dictMap = new HashMap<>(3);
dictMap.put("A", "张三");
dictMap.put("B", "李四");
dictMap.put("C", "王五");
//A表
Map<String, String> resultMap = new HashMap<>(3);
for (int i = 0; i < array.length; i++) {
List<String> list = new ArrayList<>(2);
String[] arr = array[i].split("\\,");
for (int j = 0; j < arr.length; j++) {
String name = arr[j];
for (Entry<String, String> entry : dictMap.entrySet()) {
if(name.equals(entry.getValue())){
list.add(entry.getKey());
}
}
}
String newKey = StringUtils.join(list, ",");
resultMap.put(newKey, array[i]);
}
System.out.println(resultMap.toString());
}
}