|
|
@ -1,13 +1,30 @@ |
|
|
|
package com.epmet.modules.person.service.impl; |
|
|
|
|
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.dto.form.MyPartIssuesFormDTO; |
|
|
|
import com.epmet.dto.result.AllGridsByUserIdResultDTO; |
|
|
|
import com.epmet.dto.result.MyPartIssuesResultDTO; |
|
|
|
import com.epmet.dto.result.MyPartProjectsResultDTO; |
|
|
|
import com.epmet.feign.GovIssueOpenFeignClient; |
|
|
|
import com.epmet.feign.GovOrgOpenFeignClient; |
|
|
|
import com.epmet.feign.GovProjectOpenFeignClient; |
|
|
|
import com.epmet.modules.person.service.IssueService; |
|
|
|
import com.epmet.resi.group.dto.topic.result.IssueGridResultDTO; |
|
|
|
import com.epmet.resi.group.feign.ResiGroupOpenFeignClient; |
|
|
|
import com.epmet.resi.mine.dto.from.MyPartProjectsFormDTO; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.logging.Log; |
|
|
|
import org.apache.commons.logging.LogFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Author zxc |
|
|
@ -17,6 +34,17 @@ import java.util.List; |
|
|
|
@Slf4j |
|
|
|
public class IssueServiceImpl implements IssueService { |
|
|
|
|
|
|
|
private final Log logger = LogFactory.getLog(getClass()); |
|
|
|
@Autowired |
|
|
|
private GovIssueOpenFeignClient issueOpenFeignClient; |
|
|
|
@Autowired |
|
|
|
private ResiGroupOpenFeignClient resiGroupOpenFeignClient; |
|
|
|
@Autowired |
|
|
|
private GovProjectOpenFeignClient govProjectOpenFeignClient; |
|
|
|
@Autowired |
|
|
|
private GovOrgOpenFeignClient govOrgOpenFeignClient; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 个人中心-我参与的议题列表 |
|
|
|
* @Param tokenDto |
|
|
@ -27,6 +55,73 @@ public class IssueServiceImpl implements IssueService { |
|
|
|
public List<MyPartIssuesResultDTO> myPartIssues(TokenDto tokenDto) { |
|
|
|
MyPartIssuesFormDTO form = new MyPartIssuesFormDTO(); |
|
|
|
form.setUserId(tokenDto.getUserId()); |
|
|
|
return null; |
|
|
|
Result<List<MyPartIssuesResultDTO>> listResult = issueOpenFeignClient.myPartIssues(form); |
|
|
|
if (!listResult.success()){ |
|
|
|
throw new RenException("查询我参与的议题列表失败......"); |
|
|
|
} |
|
|
|
if (CollectionUtils.isEmpty(listResult.getData())){ |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
return listResult.getData(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 个人中心-我参与的项目列表 |
|
|
|
* @author sun |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<MyPartProjectsResultDTO> myPartProjects(MyPartProjectsFormDTO formDTO) { |
|
|
|
List<MyPartProjectsResultDTO> resultList = new ArrayList<>(); |
|
|
|
//1.查询用户评论过的且以转成议题的议题信息,不包含自己发表的且已转成议题的话题
|
|
|
|
Result<List<IssueGridResultDTO>> result = resiGroupOpenFeignClient.topicToIssueList(formDTO); |
|
|
|
if (!result.success()) { |
|
|
|
logger.error(String.format("我参与的项目列表->查询用户参与的议题数据失败,用户Id:%s", formDTO.getUserId())); |
|
|
|
throw new RenException("获取用户参与的议题数据失败"); |
|
|
|
} |
|
|
|
List<IssueGridResultDTO> issueGridList = result.getData(); |
|
|
|
if (issueGridList.size() < NumConstant.ONE) { |
|
|
|
return resultList; |
|
|
|
} |
|
|
|
//议题Id集合
|
|
|
|
List<String> issueIdList = issueGridList.stream().map(IssueGridResultDTO::getIssueId).collect(Collectors.toList()); |
|
|
|
issueIdList = issueIdList.stream().distinct().collect(Collectors.toList()); |
|
|
|
//网格Id集合
|
|
|
|
List<String> gridIdList = issueGridList.stream().map(IssueGridResultDTO::getGridId).collect(Collectors.toList()); |
|
|
|
gridIdList = gridIdList.stream().distinct().collect(Collectors.toList()); |
|
|
|
|
|
|
|
//2.根据议题Id集合查询对应的项目信息
|
|
|
|
formDTO.setIssueList(issueIdList); |
|
|
|
Result<List<MyPartProjectsResultDTO>> projectResult = govProjectOpenFeignClient.issueToProjectList(formDTO); |
|
|
|
if (!projectResult.success()) { |
|
|
|
logger.error(String.format("我参与的项目列表->查询用户参与的项目数据失败,用户Id:%s", formDTO.getUserId())); |
|
|
|
throw new RenException("获取用户参与的项目数据失败"); |
|
|
|
} |
|
|
|
if (projectResult.getData().size() < NumConstant.ONE) { |
|
|
|
return resultList; |
|
|
|
} |
|
|
|
resultList = projectResult.getData(); |
|
|
|
|
|
|
|
//3.根据网格Id集合查询网格信息
|
|
|
|
Result<List<AllGridsByUserIdResultDTO>> gridResult = govOrgOpenFeignClient.getGridListByGridIds(gridIdList); |
|
|
|
if (!gridResult.success()) { |
|
|
|
logger.error("我参与的项目列表->获取网格信息失败"); |
|
|
|
throw new RenException("获取用户参与的项目数据失败"); |
|
|
|
} |
|
|
|
List<AllGridsByUserIdResultDTO> gridList = gridResult.getData(); |
|
|
|
|
|
|
|
//4.封装数据并返回
|
|
|
|
resultList.forEach(re -> { |
|
|
|
issueGridList.forEach(is -> { |
|
|
|
if (re.getIssueId().equals(is.getIssueId())) { |
|
|
|
gridList.forEach(g -> { |
|
|
|
if (is.getGridId().equals(g.getGridId())) { |
|
|
|
re.setTopicReleaseGridName(g.getGridName()); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
return resultList; |
|
|
|
} |
|
|
|
} |
|
|
|