diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/VolunteerDistributionResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/VolunteerDistributionResultDTO.java index 94a4d4ac88..99f04a4b8d 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/VolunteerDistributionResultDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/VolunteerDistributionResultDTO.java @@ -28,6 +28,8 @@ public class VolunteerDistributionResultDTO { @Data public static class Distribution { private Set volunteerCategories; + private String volunteerCategoriesStr; + private String buildingId; private String epmetUserId; private String icResiUserId; private String longitude; diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java index c3f1da8654..f1822e93f2 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java @@ -226,4 +226,6 @@ public interface IcResiUserDao extends BaseDao { */ List getPartyMemberEducationList(@Param("orgType") String orgType, @Param("orgId") String orgId, @Param("code") String code); + + List listIcResiInfosByUserIds(@Param("userIds") List userIds); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/VolunteerServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/VolunteerServiceImpl.java index 917268c8cb..e383f91664 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/VolunteerServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/VolunteerServiceImpl.java @@ -7,10 +7,8 @@ import com.epmet.dao.IcResiUserDao; import com.epmet.dao.UserBaseInfoDao; import com.epmet.dto.IcBuildingDTO; import com.epmet.dto.IcFormItemOptionsDTO; -import com.epmet.dto.IcResiUserDTO; import com.epmet.dto.form.IcFormOptionsQueryFormDTO; import com.epmet.dto.form.resi.VolunteerCommonFormDTO; -import com.epmet.dto.result.ResiUserBaseInfoResultDTO; import com.epmet.dto.result.VolunteerDistributionResultDTO; import com.epmet.dto.result.resi.PageVolunteerInfoResultDTO; import com.epmet.feign.EpmetHeartOpenFeignClient; @@ -18,10 +16,11 @@ import com.epmet.feign.GovOrgOpenFeignClient; import com.epmet.feign.OperCustomizeOpenFeignClient; import com.epmet.service.VolunteerService; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import com.google.common.collect.Lists; + import java.util.*; import java.util.stream.Collectors; @@ -100,7 +99,7 @@ public class VolunteerServiceImpl implements VolunteerService, ResultDataResolve int pageSize = 100; // 志愿者epmet user id - Set volunteerEpmetUserIds = new HashSet<>(); + List volunteerEpmetUserIds = new ArrayList<>(); // 分页查询志愿者的epmet user id while (true) { @@ -131,54 +130,89 @@ public class VolunteerServiceImpl implements VolunteerService, ResultDataResolve VolunteerDistributionResultDTO r = new VolunteerDistributionResultDTO(); + log.info("【志愿者分布】查询到志愿者userId公{}个", volunteerEpmetUserIds.size()); + // 2.填充ic居民信息 - for (String volunteerEpmetUserId : volunteerEpmetUserIds) { - - VolunteerDistributionResultDTO.Distribution distribution = new VolunteerDistributionResultDTO.Distribution(); - - ResiUserBaseInfoResultDTO userBaseInfo = userBaseInfoDao.selecUserBaseInfoByUserId(volunteerEpmetUserId); - if (userBaseInfo == null || StringUtils.isBlank(userBaseInfo.getIdNum())){ - log.warn("getVolunteerDistribution selecUserBaseInfoByUserId return null or idCard is null,volunteerEpmetUserId:{}", volunteerEpmetUserId); - continue; - } - //使用身份证号查询ic resi信息 - IcResiUserDTO icResiUserInfo = icResiUserDao.selectIdByIdCard(customerId, userBaseInfo.getIdNum(), null); - if (icResiUserInfo == null) { - continue; - } - - // 查询志愿者类别 - List volunteerCategories = icResiUserDao.selectVolunteerByUserId(icResiUserInfo.getId()); - //if (CollectionUtils.isEmpty(volunteerCategories)) { - // // 此人没有志愿者信息 - // continue; - //} - - // 将志愿者类型列表字符串,切割放到set中 - Set volunteerTypes = new HashSet(); - for (String vTypesString : volunteerCategories) { - String[] vTypes = vTypesString.split(","); + List> volunteerEpmetUserIdParts = Lists.partition(volunteerEpmetUserIds, 100); + for (List volunteerEpmetUserIdPart : volunteerEpmetUserIdParts) { + + List icResiInfos = icResiUserDao.listIcResiInfosByUserIds(volunteerEpmetUserIdPart); + + // 填充志愿者类型 + for (VolunteerDistributionResultDTO.Distribution icResiInfo : icResiInfos) { + // 将志愿者类型列表字符串,切割放到set中 + Set volunteerTypes = new HashSet(); + String[] vTypes = icResiInfo.getVolunteerCategoriesStr().split(","); if (vTypes != null && vTypes.length > 0) { volunteerTypes.addAll(Arrays.asList(vTypes)); } - } + icResiInfo.setVolunteerCategories(volunteerTypes); + // 填充建筑坐标 + String msg = "【志愿者分布】查询楼栋信息失败"; + IcBuildingDTO building = getResultDataOrThrowsException(govOrgOpenFeignClient.getBuildingById(icResiInfo.getBuildingId()), + ServiceConstant.GOV_ORG_SERVER, + EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), msg, msg); - String msg = "【志愿者分布】查询楼栋信息失败"; - IcBuildingDTO building = getResultDataOrThrowsException(govOrgOpenFeignClient.getBuildingById(icResiUserInfo.getBuildId()), - ServiceConstant.GOV_ORG_SERVER, - EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), msg, msg); + icResiInfo.setEpmetUserId(icResiInfo.getEpmetUserId()); + icResiInfo.setIcResiUserId(icResiInfo.getIcResiUserId()); + Optional.of(building).ifPresent(b -> { + icResiInfo.setLongitude(b.getLongitude()); + icResiInfo.setLatitude(b.getLatitude()); + }); - distribution.setVolunteerCategories(volunteerTypes); - distribution.setEpmetUserId(userBaseInfo.getUserId()); - distribution.setIcResiUserId(icResiUserInfo.getId()); - Optional.of(building).ifPresent(b -> { - distribution.setLongitude(b.getLongitude()); - distribution.setLatitude(b.getLatitude()); - }); - - r.getDistributions().add(distribution); + } + r.getDistributions().addAll(icResiInfos); } + + // 就有代码,稳定之后可以删掉 + //for (String volunteerEpmetUserId : volunteerEpmetUserIds) { + // + // VolunteerDistributionResultDTO.Distribution distribution = new VolunteerDistributionResultDTO.Distribution(); + // + // ResiUserBaseInfoResultDTO userBaseInfo = userBaseInfoDao.selecUserBaseInfoByUserId(volunteerEpmetUserId); + // if (userBaseInfo == null || StringUtils.isBlank(userBaseInfo.getIdNum())){ + // log.warn("getVolunteerDistribution selecUserBaseInfoByUserId return null or idCard is null,volunteerEpmetUserId:{}", volunteerEpmetUserId); + // continue; + // } + // //使用身份证号查询ic resi信息 + // IcResiUserDTO icResiUserInfo = icResiUserDao.selectIdByIdCard(customerId, userBaseInfo.getIdNum(), null); + // if (icResiUserInfo == null) { + // continue; + // } + // + // // 查询志愿者类别 + // List volunteerCategories = icResiUserDao.selectVolunteerByUserId(icResiUserInfo.getId()); + // //if (CollectionUtils.isEmpty(volunteerCategories)) { + // // // 此人没有志愿者信息 + // // continue; + // //} + // + // // 将志愿者类型列表字符串,切割放到set中 + // Set volunteerTypes = new HashSet(); + // for (String vTypesString : volunteerCategories) { + // String[] vTypes = vTypesString.split(","); + // if (vTypes != null && vTypes.length > 0) { + // volunteerTypes.addAll(Arrays.asList(vTypes)); + // } + // } + // + // + // String msg = "【志愿者分布】查询楼栋信息失败"; + // IcBuildingDTO building = getResultDataOrThrowsException(govOrgOpenFeignClient.getBuildingById(icResiUserInfo.getBuildId()), + // ServiceConstant.GOV_ORG_SERVER, + // EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), msg, msg); + // + // distribution.setVolunteerCategories(volunteerTypes); + // distribution.setEpmetUserId(userBaseInfo.getUserId()); + // distribution.setIcResiUserId(icResiUserInfo.getId()); + // Optional.of(building).ifPresent(b -> { + // distribution.setLongitude(b.getLongitude()); + // distribution.setLatitude(b.getLatitude()); + // }); + // + // r.getDistributions().add(distribution); + //} return r; } diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml index b10e6e259f..6b07136f1c 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml @@ -489,4 +489,21 @@ GROUP BY CULTURE + +