Browse Source

用lambda 进行List 转map报错. 改成for循环

v2
蟑螂恶霸 2 years ago
parent
commit
02fdb63a79
  1. 11
      lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/impl/EnterpriseMerchantAuthorizationServiceImpl.java

11
lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/impl/EnterpriseMerchantAuthorizationServiceImpl.java

@ -1,5 +1,6 @@
package com.zdxt.code.service.impl;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
@ -63,8 +64,14 @@ public class EnterpriseMerchantAuthorizationServiceImpl implements IEnterpriseMe
List<EnterpriseInformation> enterpriseInformations =
enterpriseInformationMapper.selectEnterpriseInformationList(enterpriseInformation);
//list转Map
Map<String, EnterpriseInformation> collect1 =
enterpriseInformations.stream().collect(Collectors.toMap(EnterpriseInformation::getEnterpriseNumber, Function.identity()));
// Map<String, EnterpriseInformation> collect1 =
// enterpriseInformations.stream().collect(Collectors.toMap(EnterpriseInformation::getEnterpriseNumber, Function.identity()));
Map<String, EnterpriseInformation> collect1 = new HashMap<>();
for (EnterpriseInformation entity : enterpriseInformations) {
if (entity.getEnterpriseNumber() != null) {
collect1.put(entity.getEnterpriseNumber(), entity);
}
}
//赋值企业名称
enterpriseMerchantAuthorizations.forEach(res ->{
EnterpriseInformation enterpriseInformation1 = collect1.get(res.getEnterpriseNumber());

Loading…
Cancel
Save