使用新集合将两个List<实体>合并放入
List<WayAssetsVo> wayAssetsVoList = JSONObject.parseArray(dataResult, WayAssetsVo.class);
List<String> ageList = assetsData.stream().map(ReturnAssetsPO::getAssetsclass).distinct().collect(Collectors.toList());
List<AssetAllocationVo> stationDictVOS = assetsData.stream().map(ReturnAssetsPO -> {
AssetAllocationVo assetAllocationVo = new AssetAllocationVo();
assetAllocationVo.setCategory(ReturnAssetsPO.getAssetsclass());
return assetAllocationVo;
}).distinct().collect(Collectors.toList());
List<AssetsMergedVo> assetsMergedVos = new ArrayList<>();
if (CollectionUtil.isNotEmpty(ConfigList)) {
assetsMergedVos = ConfigList.stream().map(assetConfigVo -> {
AssetsMergedVo assetsMergedVo = new AssetsMergedVo();
assetsMergedVo.setA(assetConfigVo.getCategory());
assetsMergedVo.setB(assetConfigVo.getInvqty());
assetsMergedVo.setC(assetConfigVo.getConfigqty());
return assetsMergedVo;
}).collect(Collectors.toList());
}
int count = 0;
for (int i = 0; i < assetsMergedVos.size(); i++) {
for (int j = 0; j < wayAssetsVoList.size(); j++) {
if (assetsMergedVos.get(i).getA().equals(wayAssetsVoList.get(j).getAssetsTypeCode())) {
assetsMergedVos.get(i).setD(wayAssetsVoList.get(j).getNum());
count = Integer.parseInt(assetsMergedVos.get(i).getC()) - Integer.parseInt(assetsMergedVos.get(i).getB()) - Integer.parseInt(wayAssetsVoList.get(j).getNum());
assetsMergedVos.get(i).setRes(String.valueOf(count));
}
}
}