去重:
public AjaxResult inertProInfoList(@RequestParam("ebeln") String orignStr){
String resultStr[] = orignStr.split("\n");/*传来的数据是以回车为分隔符,将其转换为String数组*/
List<String> resultStrList = Arrays.asList(resultStr);
/*下载数据*/
List<ProInfo> list = SAPConnUtils.getProInfoList(DoConnect.doConnectTest(),resultStrList);
Map<String,ProInfo> map = new HashMap<>();
List<ProInfo> resultProInfoList = new ArrayList<>();
/*去重操作*/
for(ProInfo proinfo:list){
String key = proinfo.getEbeln();
if(!map.containsKey(key)){
map.put(key,proinfo);
resultProInfoList.add(map.get(key));/*将非重元素放到新List中*/
}
}
/*将List转为Json格式*/
String jsonString = JSON.toJSONString(resultProInfoList);
return proInfoFeignClientService.inertProInfoList(jsonString);
}
分类:
public Map<String,List<PriceWithTime>> selectPriceWithTimeById(String matnrid){
List<PriceWithTime> priceWithTimes = vMatnrPriceInfoMapper.selectPriceWithTimeById(matnrid);
Map<String,List<PriceWithTime>> map = new HashMap();
for(PriceWithTime priceWithTime :priceWithTimes){
String key = priceWithTime.getLifnrid();
if(map.containsKey(key)){
map.get(key).add(priceWithTime);
}else {
List<PriceWithTime> priceWithTimesList = new ArrayList<>();
priceWithTimesList.add(priceWithTime);
map.put(key,priceWithTimesList);
}
}
return map;
}