封装方法:
public Collection<AddLabourCostDetailReturnDto> echoData(String userId) {
List<AddLabourCostDetailDto> list = compactDao.echoData(userId);
if (list.size() == 0) {
return Collections.EMPTY_LIST;
}
Map<Integer, AddLabourCostDetailReturnDto> map = new HashMap();
for (AddLabourCostDetailDto dto : list) {
AddLabourCostDetailReturnDto rdto = map.get(dto.getEnterpriseId());
if (ValidateUtil.objectIsNull(rdto)) {
rdto = new AddLabourCostDetailReturnDto();
rdto.setEnterpriseName(dto.getEnterpriseName());
rdto.setEnterpriseId(dto.getEnterpriseId());
List<AddLabourCostDetailProjectsDto> projects = new ArrayList<>();
rdto.setProjects(projects);
map.put(dto.getEnterpriseId(),rdto);
}
rdto.getProjects().add(new AddLabourCostDetailProjectsDto(dto.getProjectId(),dto.getProjectName()));
}
Co