Browse Source

Merge branch 'dev_ic_mp' into develop

dev
wangxianzhang 4 years ago
parent
commit
037dcd1cec
  1. 1
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java
  2. 4
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/FactOriginExtractController.java
  3. 3
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/project/ProjectDao.java
  4. 13
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/ProjectExtractServiceImpl.java
  5. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/project/ProjectService.java
  6. 4
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/project/impl/ProjectServiceImpl.java
  7. 3
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/project/ProjectDao.xml
  8. 10
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetHeartOpenFeignClient.java
  9. 7
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/fallback/EpmetHeartOpenFeignClientFallback.java
  10. 14
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiVolunteerController.java
  11. 7
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/VolunteerInfoService.java
  12. 15
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/VolunteerInfoServiceImpl.java
  13. 2
      epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/AutoEvaluateDemandTask.java
  14. 5
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/redis/IssueVoteDetailRedis.java
  15. 2
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java
  16. 241
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/VolunteerServiceImpl.java

1
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java

@ -1112,6 +1112,7 @@ public class DemoController {
}else { }else {
screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectGridData(customerId,dateId); screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectGridData(customerId,dateId);
screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectOrgData(customerId,dateId); screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectOrgData(customerId,dateId);
result.add(dateId);
redisUtils.hSet(RedisKeys.getBackDoorbizExcuteResult("gridandorgdailynew"),customerId,result,3*24*60*60L); redisUtils.hSet(RedisKeys.getBackDoorbizExcuteResult("gridandorgdailynew"),customerId,result,3*24*60*60L);
} }
long end = System.currentTimeMillis(); long end = System.currentTimeMillis();

4
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/FactOriginExtractController.java

@ -7,6 +7,7 @@ import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.extract.form.ExtractOriginFormDTO; import com.epmet.dto.extract.form.ExtractOriginFormDTO;
import com.epmet.service.evaluationindex.extract.todata.*; import com.epmet.service.evaluationindex.extract.todata.*;
import com.epmet.service.stats.DimCustomerService; import com.epmet.service.stats.DimCustomerService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
@ -23,6 +24,7 @@ import java.util.List;
* @author yinzuomei@elink-cn.com * @author yinzuomei@elink-cn.com
* @date 2020/9/15 11:06 * @date 2020/9/15 11:06
*/ */
@Slf4j
@RestController @RestController
@RequestMapping("factorigin") @RequestMapping("factorigin")
public class FactOriginExtractController { public class FactOriginExtractController {
@ -95,6 +97,7 @@ public class FactOriginExtractController {
@PostMapping("project") @PostMapping("project")
public Result projectData(@RequestBody ExtractOriginFormDTO extractOriginFormDTO) { public Result projectData(@RequestBody ExtractOriginFormDTO extractOriginFormDTO) {
long start = System.currentTimeMillis();
if (StringUtils.isNotBlank(extractOriginFormDTO.getCustomerId())) { if (StringUtils.isNotBlank(extractOriginFormDTO.getCustomerId())) {
List<String> daysBetween; List<String> daysBetween;
if (StringUtils.isBlank(extractOriginFormDTO.getDateId())) { if (StringUtils.isBlank(extractOriginFormDTO.getDateId())) {
@ -115,6 +118,7 @@ public class FactOriginExtractController {
projectExtractService.saveOriginProjectDaily(dto); projectExtractService.saveOriginProjectDaily(dto);
}); });
} }
log.info("projectData end,cost:{}",System.currentTimeMillis() - start);
return new Result(); return new Result();
} }

3
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/project/ProjectDao.java

@ -200,7 +200,8 @@ public interface ProjectDao extends BaseDao<ProjectEntity> {
* 获取已转项目事件事件 * 获取已转项目事件事件
* *
* @param customerId * @param customerId
* @param projectId
* @return * @return
*/ */
List<ResiEventDTO> getEventList(@Param("customerId") String customerId); List<ResiEventDTO> getEventList(@Param("customerId") String customerId, @Param("projectId") String projectId);
} }

13
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/ProjectExtractServiceImpl.java

@ -131,7 +131,7 @@ public class ProjectExtractServiceImpl implements ProjectExtractService {
List<IssueDTO> issueList = new ArrayList<>(); List<IssueDTO> issueList = new ArrayList<>();
List<ResiTopicDTO> topicList = new ArrayList<>(); List<ResiTopicDTO> topicList = new ArrayList<>();
if (!CollectionUtils.isEmpty(projectList)) { if (!CollectionUtils.isEmpty(projectList)) {
Map<String, ResiEventDTO> projectEventMap = projectService.getEventList(customerId); Map<String, ResiEventDTO> projectEventMap = projectService.getEventList(customerId, projectId);
//提取议题ID //提取议题ID
List<String> issueIds = List<String> issueIds =
projectList.stream().filter(item -> ProjectConstant.ISSUE.equals(item.getOrigin())).map(ProjectDTO::getOriginId).collect(Collectors.toList()); projectList.stream().filter(item -> ProjectConstant.ISSUE.equals(item.getOrigin())).map(ProjectDTO::getOriginId).collect(Collectors.toList());
@ -241,7 +241,9 @@ public class ProjectExtractServiceImpl implements ProjectExtractService {
} }
//满意度 //满意度
long start = System.currentTimeMillis();
List<FactOriginProjectMainDailyEntity> satisfaction = projectService.getProjectSatisfaction(customerId, projectId); List<FactOriginProjectMainDailyEntity> satisfaction = projectService.getProjectSatisfaction(customerId, projectId);
log.info("saveOriginProjectDaily 满意度 cost:{}",System.currentTimeMillis()-start);
if (CollectionUtils.isNotEmpty(satisfaction)) { if (CollectionUtils.isNotEmpty(satisfaction)) {
factOriginProjectMainDailyService.updateBatchById(satisfaction); factOriginProjectMainDailyService.updateBatchById(satisfaction);
} }
@ -249,7 +251,9 @@ public class ProjectExtractServiceImpl implements ProjectExtractService {
final List<FactOriginProjectMainDailyEntity> mainList = list; final List<FactOriginProjectMainDailyEntity> mainList = list;
List<FactOriginProjectLogDailyEntity> logList = new ArrayList<>(); List<FactOriginProjectLogDailyEntity> logList = new ArrayList<>();
//节点发起人 部门流转退回结案 //节点发起人 部门流转退回结案
start = System.currentTimeMillis();
List<ProcessInfoDTO> processList = projectProcessService.getProcessListByCustomer(customerId, dateString, projectId); List<ProcessInfoDTO> processList = projectProcessService.getProcessListByCustomer(customerId, dateString, projectId);
log.info("saveOriginProjectDaily 节点发起人 部门流转退回结案 cost:{}",System.currentTimeMillis()-start);
if (!CollectionUtils.isEmpty(processList)) { if (!CollectionUtils.isEmpty(processList)) {
logList = processList.stream().map(process -> { logList = processList.stream().map(process -> {
//获取日期相关维度 //获取日期相关维度
@ -301,7 +305,9 @@ public class ProjectExtractServiceImpl implements ProjectExtractService {
}).collect(Collectors.toList()); }).collect(Collectors.toList());
} }
//节点发起人 响应 //节点发起人 响应
start = System.currentTimeMillis();
List<ProcessInfoDTO> responseList = projectProcessService.getResponseProcessList(customerId, dateString, projectId); List<ProcessInfoDTO> responseList = projectProcessService.getResponseProcessList(customerId, dateString, projectId);
log.info("saveOriginProjectDaily 节点发起人 响应 cost:{}",System.currentTimeMillis()-start);
if (!CollectionUtils.isEmpty(responseList)) { if (!CollectionUtils.isEmpty(responseList)) {
logList.addAll(responseList.stream().map(process -> { logList.addAll(responseList.stream().map(process -> {
//获取日期相关维度 //获取日期相关维度
@ -347,8 +353,9 @@ public class ProjectExtractServiceImpl implements ProjectExtractService {
} }
//项目评论人 //项目评论人
start = System.currentTimeMillis();
List<ProcessInfoDTO> satisfactionRecordList = projectProcessService.getSatisfactionRecord(customerId, dateString, projectId); List<ProcessInfoDTO> satisfactionRecordList = projectProcessService.getSatisfactionRecord(customerId, dateString, projectId);
log.info("saveOriginProjectDaily 项目评论人 cost:{}",System.currentTimeMillis()-start);
satisfactionRecordList.forEach(log -> mainList.stream().filter(project -> log.getProjectId().equals(project.getId())).forEach(main -> { satisfactionRecordList.forEach(log -> mainList.stream().filter(project -> log.getProjectId().equals(project.getId())).forEach(main -> {
//进行满意度评价的居民的所属机关的父机机关信息 //进行满意度评价的居民的所属机关的父机机关信息
log.setPid(main.getPid()); log.setPid(main.getPid());
@ -377,7 +384,9 @@ public class ProjectExtractServiceImpl implements ProjectExtractService {
//节点接收人 //节点接收人
start = System.currentTimeMillis();
List<ProcessInfoDTO> processStaffList = projectProcessService.getProcessStaffByCustomer(customerId, dateString, projectId); List<ProcessInfoDTO> processStaffList = projectProcessService.getProcessStaffByCustomer(customerId, dateString, projectId);
log.info("saveOriginProjectDaily 节点接收人 cost:{}",System.currentTimeMillis()-start);
logList.addAll(processStaffList.stream().map(process -> { logList.addAll(processStaffList.stream().map(process -> {
//获取日期相关维度 //获取日期相关维度
DimIdGenerator.DimIdBean dimId = DimIdGenerator.getDimIdBean(process.getCreatedTime()); DimIdGenerator.DimIdBean dimId = DimIdGenerator.getDimIdBean(process.getCreatedTime());

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/project/ProjectService.java

@ -202,5 +202,5 @@ public interface ProjectService extends BaseService<ProjectEntity> {
* @param projectId * @param projectId
* @return * @return
*/ */
Map<String, ResiEventDTO> getEventList(String customerId); Map<String, ResiEventDTO> getEventList(String customerId, String projectId);
} }

4
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/project/impl/ProjectServiceImpl.java

@ -249,8 +249,8 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectDao, ProjectEntit
} }
@Override @Override
public Map<String, ResiEventDTO> getEventList(String customerId) { public Map<String, ResiEventDTO> getEventList(String customerId, String projectId) {
List<ResiEventDTO> list = baseDao.getEventList(customerId); List<ResiEventDTO> list = baseDao.getEventList(customerId, projectId);
if (org.apache.commons.collections4.CollectionUtils.isEmpty(list)) { if (org.apache.commons.collections4.CollectionUtils.isEmpty(list)) {
return Collections.emptyMap(); return Collections.emptyMap();
} }

3
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/project/ProjectDao.xml

@ -259,6 +259,9 @@
from resi_event_report_org rero from resi_event_report_org rero
inner join resi_event re on rero.RESI_EVENT_ID = re.id and re.SHIFT_PROJECT = 1 and re.DEL_FLAG = '0' inner join resi_event re on rero.RESI_EVENT_ID = re.id and re.SHIFT_PROJECT = 1 and re.DEL_FLAG = '0'
where rero.del_flag = '0' where rero.del_flag = '0'
<if test="projectId != null and projectId != ''">
AND re.PROJECT_ID = #{projectId}
</if>
and rero.CUSTOMER_ID = #{customerId} and rero.CUSTOMER_ID = #{customerId}
</select> </select>

10
epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetHeartOpenFeignClient.java

@ -74,5 +74,13 @@ public interface EpmetHeartOpenFeignClient {
* @return * @return
*/ */
@PostMapping("/heart/residemand/autoevaluate") @PostMapping("/heart/residemand/autoevaluate")
Result AutoEvaluateDemand(@RequestBody AutoEvaluateDemandFormDTO formDTO); Result autoEvaluateDemand(@RequestBody AutoEvaluateDemandFormDTO formDTO);
/**
* 查询志愿者数量
* @param input
* @return
*/
@PostMapping("/heart/resi/volunteer/count")
Result<Integer> getVolunteerCount(@RequestBody VolunteerCommonFormDTO input);
} }

7
epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/fallback/EpmetHeartOpenFeignClientFallback.java

@ -68,7 +68,12 @@ public class EpmetHeartOpenFeignClientFallback implements EpmetHeartOpenFeignCli
* @return * @return
*/ */
@Override @Override
public Result AutoEvaluateDemand(AutoEvaluateDemandFormDTO formDTO) { public Result autoEvaluateDemand(AutoEvaluateDemandFormDTO formDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_HEART_SERVER, "autoEvaluate",formDTO); return ModuleUtils.feignConError(ServiceConstant.EPMET_HEART_SERVER, "autoEvaluate",formDTO);
} }
@Override
public Result<Integer> getVolunteerCount(VolunteerCommonFormDTO input) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_HEART_SERVER, "getVolunteerCount", input);
}
} }

14
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiVolunteerController.java

@ -145,4 +145,18 @@ public class ResiVolunteerController {
List<PageVolunteerInfoResultDTO> l = volunteerInfoService.queryVolunteerPage(customerId, pageNo, pageSize, superiorAgencyId); List<PageVolunteerInfoResultDTO> l = volunteerInfoService.queryVolunteerPage(customerId, pageNo, pageSize, superiorAgencyId);
return new Result<List<PageVolunteerInfoResultDTO>>().ok(l); return new Result<List<PageVolunteerInfoResultDTO>>().ok(l);
} }
/**
* 查询志愿者数量
* @param input
* @return
*/
@PostMapping("count")
public Result<Integer> getVolunteerCount(@RequestBody VolunteerCommonFormDTO input) {
String customerId = input.getCustomerId();
String pidsPrefix = input.getSuperiorAgencyId();
Integer volunteerCount = volunteerInfoService.getVolunteerCount(customerId, pidsPrefix);
return new Result<Integer>().ok(volunteerCount);
}
} }

7
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/VolunteerInfoService.java

@ -96,4 +96,11 @@ public interface VolunteerInfoService extends BaseService<VolunteerInfoEntity> {
List<OptionDTO> queryListVolunteer(String customerId,String staffId,String userRealName); List<OptionDTO> queryListVolunteer(String customerId,String staffId,String userRealName);
List<PageVolunteerInfoResultDTO> queryVolunteerPage(String customerId, Integer pageNo, Integer pageSize, String superiorAgencyId); List<PageVolunteerInfoResultDTO> queryVolunteerPage(String customerId, Integer pageNo, Integer pageSize, String superiorAgencyId);
/**
* 查询志愿者数量
* @param customerId
* @return
*/
Integer getVolunteerCount(String customerId, String pidsPrefix);
} }

15
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/VolunteerInfoServiceImpl.java

@ -390,4 +390,19 @@ public class VolunteerInfoServiceImpl extends BaseServiceImpl<VolunteerInfoDao,
return list; return list;
} }
@Override
public Integer getVolunteerCount(String customerId, String pidsPrefix) {
LambdaQueryWrapper<VolunteerInfoEntity> query = new LambdaQueryWrapper<>();
Optional.ofNullable(customerId).ifPresent((cId) -> {
query.eq(VolunteerInfoEntity::getCustomerId, cId);
});
Optional.ofNullable(pidsPrefix).ifPresent((pidsPrefixt) -> {
query.likeRight(VolunteerInfoEntity::getPids, pidsPrefixt);
});
return baseDao.selectCount(query);
}
} }

2
epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/AutoEvaluateDemandTask.java

@ -26,6 +26,6 @@ public class AutoEvaluateDemandTask implements ITask {
if (StringUtils.isNotBlank(params)) { if (StringUtils.isNotBlank(params)) {
formDTO = JSON.parseObject(params, AutoEvaluateDemandFormDTO.class); formDTO = JSON.parseObject(params, AutoEvaluateDemandFormDTO.class);
} }
Result result = heartOpenFeignClient.AutoEvaluateDemand(formDTO); Result result = heartOpenFeignClient.autoEvaluateDemand(formDTO);
} }
} }

5
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/redis/IssueVoteDetailRedis.java

@ -264,6 +264,11 @@ public class IssueVoteDetailRedis {
formDTO.setIssueId(issueId); formDTO.setIssueId(issueId);
formDTO.setGridId(issue.getGridId()); formDTO.setGridId(issue.getGridId());
voteCache = issueVoteDetailService.selectIssueVotingDetail(formDTO); voteCache = issueVoteDetailService.selectIssueVotingDetail(formDTO);
IssueVoteStatisticalDTO dto = ConvertUtils.sourceToTarget(voteCache, IssueVoteStatisticalDTO.class);
dto.setVotableCount(voteCache.getShouldVoteCount());
dto.setSupportCount(voteCache.getSupportAmount());
dto.setOppositionCount(voteCache.getOppositionAmount());
issueVoteStatisticalDao.updateBtIssueId(dto);
}else { }else {
// 状态是关闭,转议题的,直接从结果表查询 // 状态是关闭,转议题的,直接从结果表查询
voteCache = issueVoteStatisticalDao.selectVoteDetail(issueId); voteCache = issueVoteStatisticalDao.selectVoteDetail(issueId);

2
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java

@ -1136,7 +1136,7 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl<CustomerAgencyDao
if (o == null){ if (o == null){
ExtStaffPermissionResultDTO res = baseDao.selectAgencyAndGridById(rootAgency.getAgencyId()); ExtStaffPermissionResultDTO res = baseDao.selectAgencyAndGridById(rootAgency.getAgencyId());
convert2AgencyTreeResult(result,res.getSubAgencyList(),res.getGridList()); convert2AgencyTreeResult(result,res.getSubAgencyList(),res.getGridList());
redisUtils.set(orgTreeCacheKey,result, 60 * 60 * 24L); redisUtils.set(orgTreeCacheKey,result, RedisUtils.MINUTE_THIRTY_EXPIRE);
}else { }else {
result = (AgencyTreeResultDTO) o; result = (AgencyTreeResultDTO) o;
} }

241
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/VolunteerServiceImpl.java

@ -2,6 +2,7 @@ package com.epmet.service.impl;
import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.feign.ResultDataResolver; import com.epmet.commons.tools.feign.ResultDataResolver;
import com.epmet.dao.IcResiUserDao; import com.epmet.dao.IcResiUserDao;
import com.epmet.dao.UserBaseInfoDao; import com.epmet.dao.UserBaseInfoDao;
@ -16,7 +17,6 @@ import com.epmet.feign.GovOrgOpenFeignClient;
import com.epmet.feign.OperCustomizeOpenFeignClient; import com.epmet.feign.OperCustomizeOpenFeignClient;
import com.epmet.service.VolunteerService; import com.epmet.service.VolunteerService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -24,6 +24,8 @@ import org.springframework.stereotype.Service;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import java.util.*; import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -94,136 +96,157 @@ public class VolunteerServiceImpl implements VolunteerService, ResultDataResolve
* @return * @return
*/ */
public VolunteerDistributionResultDTO getVolunteerDistribution(String customerId, String agencyId) { public VolunteerDistributionResultDTO getVolunteerDistribution(String customerId, String agencyId) {
//epmetHeartOpenFeignClient.queryVolunteerPage() VolunteerDistributionResultDTO r = new VolunteerDistributionResultDTO();
// 1.==========分页查询出所有志愿者列表==========
String vcErrorMsg = "【志愿者分布】查询志愿者总数出错";
VolunteerCommonFormDTO volunteerCountForm = new VolunteerCommonFormDTO();
volunteerCountForm.setCustomerId(customerId);
volunteerCountForm.setSuperiorAgencyId(agencyId);
Integer volunteerCount = getResultDataOrThrowsException(epmetHeartOpenFeignClient.getVolunteerCount(volunteerCountForm),
ServiceConstant.EPMET_HEART_SERVER,
EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),
vcErrorMsg,
vcErrorMsg);
if (volunteerCount == null || volunteerCount == 0) {
// 没得志愿者,直接返回
return r;
}
// 1.分页查询出所有志愿者列表 // 计算页数
int pageNo = 1;
int pageSize = 200; int pageSize = 200;
int pageCount = volunteerCount / pageSize;
int lastPageItems = volunteerCount % pageSize;
pageCount = lastPageItems > 0 ? ++pageCount : pageCount;
// 志愿者epmet user id // 志愿者epmet user id 集合
List<String> volunteerEpmetUserIds = new ArrayList<>(); List<String> volunteerEpmetUserIds = new ArrayList<>();
// 分页查询志愿者的epmet user id // 分页查询志愿者的epmet user id
while (true) { List<CompletableFuture<Set<String>>> volsPageFutures = new ArrayList<>();
VolunteerCommonFormDTO volunteerForm = new VolunteerCommonFormDTO();
volunteerForm.setCustomerId(customerId);
volunteerForm.setSuperiorAgencyId(agencyId);
volunteerForm.setPageNo(pageNo);
volunteerForm.setPageSize(pageSize);
String errorMsg = "【志愿者分布】分页查询志愿者列表失败";
List<PageVolunteerInfoResultDTO> volunteerPage = getResultDataOrThrowsException(epmetHeartOpenFeignClient.queryVolunteerPage(volunteerForm),
ServiceConstant.EPMET_HEART_SERVER,
EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),
errorMsg,
errorMsg);
// 将本页userId添加到总集中去
volunteerEpmetUserIds.addAll(volunteerPage.stream().map(v -> v.getUserId()).collect(Collectors.toSet()));
if (volunteerPage.size() < pageSize) {
// 说明是最后一页了
break;
}
pageNo++; for (int pageNo = 1 ; pageNo <= pageCount ; pageNo ++) {
}
int pageNoTemp = pageNo;
CompletableFuture<Set<String>> future = CompletableFuture.supplyAsync(() -> {
return listVolunteersByPage(customerId, agencyId, pageNoTemp, pageSize)
.stream()
.map(v -> v.getUserId())
.collect(Collectors.toSet());
});
VolunteerDistributionResultDTO r = new VolunteerDistributionResultDTO(); volsPageFutures.add(future);
}
// 阻塞,等待子线程返回结果,然后添加到志愿者userId集合中去
for (CompletableFuture<Set<String>> future : volsPageFutures) {
try {
volunteerEpmetUserIds.addAll(future.get());
} catch (InterruptedException e) {
log.error("【志愿者分布】异步获取志愿者userId列表被中断:{}", ExceptionUtils.getErrorStackTrace(e));
} catch (ExecutionException e) {
log.error("【志愿者分布】异步获取志愿者userId列表失败:{}", ExceptionUtils.getErrorStackTrace(e));
}
}
log.info("【志愿者分布】查询到志愿者userId公{}个", volunteerEpmetUserIds.size()); log.info("【志愿者分布】查询到志愿者userId公{}个", volunteerEpmetUserIds.size());
// 2.填充ic居民信息 // 2.==========异步填充ic居民信息==========
List<CompletableFuture<List<VolunteerDistributionResultDTO.Distribution>>> volResiInfoFutures = new ArrayList<>();
// 将所有的userId按100固定分割成多个部分,循环用每个部分去查询,然后填充
List<List<String>> volunteerEpmetUserIdParts = Lists.partition(volunteerEpmetUserIds, 100); List<List<String>> volunteerEpmetUserIdParts = Lists.partition(volunteerEpmetUserIds, 100);
for (List<String> volunteerEpmetUserIdPart : volunteerEpmetUserIdParts) { for (List<String> volunteerEpmetUserIdPart : volunteerEpmetUserIdParts) {
List<VolunteerDistributionResultDTO.Distribution> icResiInfos = icResiUserDao.listIcResiInfosByUserIds(volunteerEpmetUserIdPart); log.info("【志愿者分布】查询ic居民信息,切割后,本组的userId个数:{}", volunteerEpmetUserIdPart.size());
// 填充志愿者类型
for (VolunteerDistributionResultDTO.Distribution icResiInfo : icResiInfos) {
// 将志愿者类型列表字符串,切割放到set中
Set<String> volunteerTypes = new HashSet();
String volunteerCategoriesStr = icResiInfo.getVolunteerCategoriesStr();
if (StringUtils.isNotEmpty(volunteerCategoriesStr)) {
String[] vTypes = volunteerCategoriesStr.split(",");
if (vTypes != null && vTypes.length > 0) {
volunteerTypes.addAll(Arrays.asList(vTypes));
}
icResiInfo.setVolunteerCategories(volunteerTypes);
} else {
icResiInfo.setVolunteerCategories(new HashSet<>());
}
// 填充建筑坐标 CompletableFuture<List<VolunteerDistributionResultDTO.Distribution>> future = CompletableFuture.supplyAsync(() -> {
String msg = "【志愿者分布】查询楼栋信息失败"; return listIcResiInfosByUserIds(volunteerEpmetUserIdPart);
IcBuildingDTO building = getResultDataOrThrowsException(govOrgOpenFeignClient.getBuildingById(icResiInfo.getBuildingId()), });
ServiceConstant.GOV_ORG_SERVER,
EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), msg, msg);
icResiInfo.setEpmetUserId(icResiInfo.getEpmetUserId()); volResiInfoFutures.add(future);
icResiInfo.setIcResiUserId(icResiInfo.getIcResiUserId()); }
Optional.of(building).ifPresent(b -> {
icResiInfo.setLongitude(b.getLongitude());
icResiInfo.setLatitude(b.getLatitude());
});
// 阻塞的,获取各个子线程计算结果
for (CompletableFuture<List<VolunteerDistributionResultDTO.Distribution>> volResiInfoFuture : volResiInfoFutures) {
try {
List<VolunteerDistributionResultDTO.Distribution> distributions = volResiInfoFuture.get();
r.getDistributions().addAll(distributions);
} catch (InterruptedException e) {
log.error("【志愿者分布】异步获取志愿者的居民信息被中断:{}", ExceptionUtils.getErrorStackTrace(e));
} catch (ExecutionException e) {
log.error("【志愿者分布】异步获取志愿者的居民信息失败:{}", ExceptionUtils.getErrorStackTrace(e));
} }
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<String> volunteerCategories = icResiUserDao.selectVolunteerByUserId(icResiUserInfo.getId());
// //if (CollectionUtils.isEmpty(volunteerCategories)) {
// // // 此人没有志愿者信息
// // continue;
// //}
//
// // 将志愿者类型列表字符串,切割放到set中
// Set<String> 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; return r;
} }
/**
* userId列表批量获取他们对应的志愿者信息
* @param volunteerEpmetUserIdPart
* @return
*/
private List<VolunteerDistributionResultDTO.Distribution> listIcResiInfosByUserIds(List<String> volunteerEpmetUserIdPart) {
List<VolunteerDistributionResultDTO.Distribution> icResiInfos = icResiUserDao.listIcResiInfosByUserIds(volunteerEpmetUserIdPart);
// 填充志愿者类型
for (VolunteerDistributionResultDTO.Distribution icResiInfo : icResiInfos) {
// 将志愿者类型列表字符串,切割放到set中
Set<String> volunteerTypes = new HashSet();
String volunteerCategoriesStr = icResiInfo.getVolunteerCategoriesStr();
if (StringUtils.isNotEmpty(volunteerCategoriesStr)) {
String[] vTypes = volunteerCategoriesStr.split(",");
if (vTypes != null && vTypes.length > 0) {
volunteerTypes.addAll(Arrays.asList(vTypes));
}
icResiInfo.setVolunteerCategories(volunteerTypes);
} else {
icResiInfo.setVolunteerCategories(new HashSet<>());
}
// 填充建筑坐标
String msg = "【志愿者分布】查询楼栋信息失败";
IcBuildingDTO building = getResultDataOrThrowsException(govOrgOpenFeignClient.getBuildingById(icResiInfo.getBuildingId()),
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());
});
}
return icResiInfos;
}
/**
* 分页查询志愿者列表
* @param customerId
* @param pageNo
* @param pageSize
* @return
*/
private List<PageVolunteerInfoResultDTO> listVolunteersByPage(String customerId, String agencyId, Integer pageNo, Integer pageSize) {
VolunteerCommonFormDTO volunteerForm = new VolunteerCommonFormDTO();
volunteerForm.setCustomerId(customerId);
volunteerForm.setSuperiorAgencyId(agencyId);
volunteerForm.setPageNo(pageNo);
volunteerForm.setPageSize(pageSize);
String errorMsg = "【志愿者分布】分页查询志愿者列表失败";
return getResultDataOrThrowsException(epmetHeartOpenFeignClient.queryVolunteerPage(volunteerForm),
ServiceConstant.EPMET_HEART_SERVER,
EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),
errorMsg,
errorMsg);
}
} }

Loading…
Cancel
Save