List<AiPart> aiPartList = aiPartMapper.getAiPartsByCaseId(caseId);
/**
* 拼接成 List<InjuredReturnResult2>形式,一張圖片對應哪幾個配件。
*/
List<InjuredReturnResult2> injuredReturnResult2List = new ArrayList<>();
Map<String, List<AiPart>> groupBy2 = new HashMap<>();
List<AiPart> tempList = null;
for(AiPart aiPart : aiPartList ) {
if(groupBy2.containsKey(aiPart.getImageUrl())) {
tempList = groupBy2.get(aiPart.getImageUrl());
tempList.add(aiPart);
} else {
// 否則,第一次先構造一個list,在存入map
tempList = new ArrayList<>();
tempList.add(aiPart);
groupBy2.put(aiPart.getImageUrl(), tempList);
}
}
System.out.println("轉換參數:"+JSON.toJSONString(groupBy2));