@ -21,24 +21,42 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage ;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl ;
import com.epmet.commons.tools.constant.NumConstant ;
import com.epmet.commons.tools.exception.RenException ;
import com.epmet.commons.tools.page.PageData ;
import com.epmet.commons.tools.utils.ConvertUtils ;
import com.epmet.commons.tools.constant.FieldConstant ;
import com.epmet.commons.tools.utils.DateUtils ;
import com.epmet.commons.tools.utils.Result ;
import com.epmet.constant.ProjectConstant ;
import com.epmet.dao.ProjectCategoryDao ;
import com.epmet.dao.ProjectDao ;
import com.epmet.dao.ProjectSatisfactionStatisticsDao ;
import com.epmet.dto.ProjectSatisfactionStatisticsDTO ;
import com.epmet.dto.form.MassesDiscontentFormDTO ;
import com.epmet.dto.form.ProjectEvaluateScoreFormDTO ;
import com.epmet.dto.result.MassesDiscontentResultDTO ;
import com.epmet.dto.result.ProjectCategoryDisPoseResultDTO ;
import com.epmet.dto.result.ProjectEvaluateScoreResultDTO ;
import com.epmet.dto.result.ProjectScoreResultDTO ;
import com.epmet.entity.ProjectSatisfactionStatisticsEntity ;
import com.epmet.feign.GovIssueOpenFeignClient ;
import com.epmet.redis.ProjectSatisfactionStatisticsRedis ;
import com.epmet.resi.group.dto.topic.result.TopicInfoResultDTO ;
import com.epmet.resi.group.feign.ResiGroupOpenFeignClient ;
import com.epmet.service.ProjectSatisfactionStatisticsService ;
import com.github.pagehelper.PageHelper ;
import com.github.pagehelper.PageInfo ;
import org.apache.commons.lang3.StringUtils ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.stereotype.Service ;
import org.springframework.transaction.annotation.Transactional ;
import org.springframework.util.CollectionUtils ;
import java.util.ArrayList ;
import java.util.Arrays ;
import java.util.List ;
import java.util.Map ;
import java.util.stream.Collectors ;
/ * *
* 项目满意度调查统计表
@ -51,6 +69,14 @@ public class ProjectSatisfactionStatisticsServiceImpl extends BaseServiceImpl<Pr
@Autowired
private ProjectSatisfactionStatisticsRedis projectSatisfactionStatisticsRedis ;
@Autowired
private ProjectDao projectDao ;
@Autowired
private ProjectCategoryDao projectCategoryDao ;
@Autowired
private GovIssueOpenFeignClient issueOpenFeignClient ;
@Autowired
private ResiGroupOpenFeignClient resiGroupOpenFeignClient ;
@Override
public PageData < ProjectSatisfactionStatisticsDTO > page ( Map < String , Object > params ) {
@ -125,4 +151,80 @@ public class ProjectSatisfactionStatisticsServiceImpl extends BaseServiceImpl<Pr
return new ProjectEvaluateScoreResultDTO ( ( noEvalScore + realEvalScore ) / shouldEvaluateCount ) ;
}
/ * *
* @Description 群众不满
* @Param formDTO
* @author zxc
* @date 2021 / 5 / 14 10 : 46 上午
* /
@Override
public List < MassesDiscontentResultDTO > massesDiscontent ( MassesDiscontentFormDTO formDTO ) {
List < MassesDiscontentResultDTO > projectIds = projectDao . selectProjectIdByTime ( formDTO . getAgencyId ( ) , getDateId ( "yesterday" ) , getDateId ( formDTO . getTimeSection ( ) ) ) ;
if ( CollectionUtils . isEmpty ( projectIds ) ) {
return new ArrayList < > ( ) ;
}
PageInfo < MassesDiscontentResultDTO > pageInfo = PageHelper . startPage ( formDTO . getPageNo ( ) , formDTO . getPageSize ( ) ) . doSelectPageInfo ( ( ) - > baseDao . selectProjectByScore ( projectIds . stream ( ) . map ( m - > m . getProjectId ( ) ) . collect ( Collectors . toList ( ) ) , NumConstant . SEVENTY_FIVE , formDTO . getSortType ( ) ) ) ;
List < MassesDiscontentResultDTO > projects = pageInfo . getList ( ) ;
if ( CollectionUtils . isEmpty ( projects ) ) {
return new ArrayList < > ( ) ;
}
List < ProjectCategoryDisPoseResultDTO > projectCategoryDisPoseResultDTOS = projectCategoryDao . selectCategoryByIds ( projects . stream ( ) . map ( m - > m . getProjectId ( ) ) . collect ( Collectors . toList ( ) ) ) ;
List < ProjectCategoryDisPoseResultDTO > projectCategoryData = new ArrayList < > ( ) ;
if ( ! CollectionUtils . isEmpty ( projectCategoryDisPoseResultDTOS ) ) {
Result < List < ProjectCategoryDisPoseResultDTO > > projectCategory = issueOpenFeignClient . getProjectCategory ( projectCategoryDisPoseResultDTOS ) ;
if ( ! projectCategory . success ( ) ) {
throw new RenException ( "查询项目分类标签失败" . concat ( projectCategory . getMsg ( ) ) ) ;
}
projectCategoryData = projectCategory . getData ( ) ;
}
Result < List < TopicInfoResultDTO > > topicInfos = resiGroupOpenFeignClient . getTopicInfos ( projects . stream ( ) . map ( m - > m . getIssueId ( ) ) . collect ( Collectors . toList ( ) ) ) ;
if ( ! topicInfos . success ( ) ) {
throw new RenException ( "查询话题信息失败" . concat ( topicInfos . getMsg ( ) ) ) ;
}
List < ProjectCategoryDisPoseResultDTO > finalProjectCategoryData = projectCategoryData ;
projects . forEach ( p - > {
if ( ! CollectionUtils . isEmpty ( finalProjectCategoryData ) ) {
finalProjectCategoryData . forEach ( cate - > {
if ( p . getProjectId ( ) . equals ( cate . getProjectId ( ) ) ) {
p . setProjectCategory ( cate . getProjectCategory ( ) ) ;
}
} ) ;
}
if ( ! CollectionUtils . isEmpty ( topicInfos . getData ( ) ) ) {
topicInfos . getData ( ) . forEach ( t - > {
if ( p . getIssueId ( ) . equals ( t . getIssueId ( ) ) ) {
p . setGridName ( t . getGridName ( ) ) ;
p . setTopicContent ( t . getTopicContent ( ) ) ;
p . setPhotos ( t . getPhotos ( ) ) ;
}
} ) ;
}
} ) ;
return projects ;
}
/ * *
* @Description 处理时间
* @Param dateType
* @author zxc
* @date 2021 / 5 / 18 2 : 28 下午
* /
public Integer getDateId ( String dateType ) {
String beforeNDay = DateUtils . getBeforeNDay ( NumConstant . ONE ) ;
Integer result = Integer . valueOf ( beforeNDay ) ;
switch ( dateType ) {
case ProjectConstant . THREE_MONTH :
result = Integer . valueOf ( DateUtils . getBeforeNDay ( NumConstant . NINETY ) ) ;
break ;
case ProjectConstant . SIX_MONTH :
result = Integer . valueOf ( DateUtils . getBeforeNDay ( NumConstant . ONE_HUNDRED_AND_EIGHTY ) ) ;
break ;
case ProjectConstant . TWELVE_MONTH :
result = Integer . valueOf ( DateUtils . getBeforeNDay ( NumConstant . THREE_HUNDRED_AND_SIXTY_FIVE ) ) ;
break ;
default :
}
return result ;
}
}