14 changed files with 916 additions and 0 deletions
			
			
		@ -0,0 +1,30 @@ | 
				
			|||
package com.epmet.topic.constant; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * @Author zxc | 
				
			|||
 * @CreateTime 2020/6/20 17:19 | 
				
			|||
 */ | 
				
			|||
public interface TopicConstant { | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 讨论中 | 
				
			|||
     */ | 
				
			|||
    String DISCUSSING = "discussing"; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 已屏蔽 | 
				
			|||
     */ | 
				
			|||
    String HIDDEN = "hidden"; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 已关闭 | 
				
			|||
     */ | 
				
			|||
    String CLOSED = "closed"; | 
				
			|||
 | 
				
			|||
    String RATIO = "%"; | 
				
			|||
 | 
				
			|||
    String SHIFTED = "已转议题"; | 
				
			|||
 | 
				
			|||
    String MONTH = "month"; | 
				
			|||
    String DATE = "date"; | 
				
			|||
} | 
				
			|||
@ -0,0 +1,24 @@ | 
				
			|||
package com.epmet.topic.dto.form; | 
				
			|||
 | 
				
			|||
import lombok.Data; | 
				
			|||
 | 
				
			|||
import javax.validation.constraints.NotBlank; | 
				
			|||
import java.io.Serializable; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * @Author zxc | 
				
			|||
 * @CreateTime 2020/6/20 16:24 | 
				
			|||
 */ | 
				
			|||
@Data | 
				
			|||
public class TopicIncrTrendFormDTO implements Serializable { | 
				
			|||
 | 
				
			|||
    private static final long serialVersionUID = -4929038359220814068L; | 
				
			|||
 | 
				
			|||
    public interface TopicIncr{} | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 类型  month:代表月   date:代表日 | 
				
			|||
     */ | 
				
			|||
    @NotBlank(message = "month / date 类型不能为空",groups = {TopicIncr.class}) | 
				
			|||
    private String type; | 
				
			|||
} | 
				
			|||
@ -0,0 +1,30 @@ | 
				
			|||
package com.epmet.topic.dto.result; | 
				
			|||
 | 
				
			|||
import lombok.Data; | 
				
			|||
 | 
				
			|||
import java.io.Serializable; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * @Author zxc | 
				
			|||
 * @CreateTime 2020/6/20 16:09 | 
				
			|||
 */ | 
				
			|||
@Data | 
				
			|||
public class TopicIncrTrendResultDTO implements Serializable { | 
				
			|||
 | 
				
			|||
    private static final long serialVersionUID = 6905657684644153197L; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 日期 | 
				
			|||
     */ | 
				
			|||
    private String date; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 值 | 
				
			|||
     */ | 
				
			|||
    private Integer value; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 类型 | 
				
			|||
     */ | 
				
			|||
    private String type; | 
				
			|||
} | 
				
			|||
@ -0,0 +1,25 @@ | 
				
			|||
package com.epmet.topic.dto.result; | 
				
			|||
 | 
				
			|||
import lombok.Data; | 
				
			|||
 | 
				
			|||
import java.io.Serializable; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * @Author zxc | 
				
			|||
 * @CreateTime 2020/6/20 17:32 | 
				
			|||
 */ | 
				
			|||
@Data | 
				
			|||
public class TopicShiftedCountResultDTO implements Serializable { | 
				
			|||
 | 
				
			|||
    private static final long serialVersionUID = -7470748727678087785L; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 已转议题数量 | 
				
			|||
     */ | 
				
			|||
    private Integer shiftedIssueCount; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 数据更新至 时间 | 
				
			|||
     */ | 
				
			|||
    private String deadline; | 
				
			|||
} | 
				
			|||
@ -0,0 +1,25 @@ | 
				
			|||
package com.epmet.topic.dto.result; | 
				
			|||
 | 
				
			|||
import lombok.Data; | 
				
			|||
 | 
				
			|||
import java.io.Serializable; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * @Author zxc | 
				
			|||
 * @CreateTime 2020/6/20 17:10 | 
				
			|||
 */ | 
				
			|||
@Data | 
				
			|||
public class TopicStatusResultDTO implements Serializable { | 
				
			|||
 | 
				
			|||
    private static final long serialVersionUID = -6461755954651271901L; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 话题数量 | 
				
			|||
     */ | 
				
			|||
    private Integer topicCount; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 话题状态   已关闭:closed、已屏蔽:hidden、 讨论中:discussing | 
				
			|||
     */ | 
				
			|||
    private String topicStatus; | 
				
			|||
} | 
				
			|||
@ -0,0 +1,35 @@ | 
				
			|||
package com.epmet.topic.dto.result; | 
				
			|||
 | 
				
			|||
import lombok.Data; | 
				
			|||
 | 
				
			|||
import java.io.Serializable; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * @Author zxc | 
				
			|||
 * @CreateTime 2020/6/20 16:13 | 
				
			|||
 */ | 
				
			|||
@Data | 
				
			|||
public class TopicSubAgencyResultDTO implements Serializable { | 
				
			|||
 | 
				
			|||
    private static final long serialVersionUID = 70586943923355457L; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 名称 | 
				
			|||
     */ | 
				
			|||
    private String name; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 值 | 
				
			|||
     */ | 
				
			|||
    private Integer value; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 类型 | 
				
			|||
     */ | 
				
			|||
    private String type; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 机关Id | 
				
			|||
     */ | 
				
			|||
    private String agencyId; | 
				
			|||
} | 
				
			|||
@ -0,0 +1,35 @@ | 
				
			|||
package com.epmet.topic.dto.result; | 
				
			|||
 | 
				
			|||
import lombok.Data; | 
				
			|||
 | 
				
			|||
import java.io.Serializable; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * @Author zxc | 
				
			|||
 * @CreateTime 2020/6/20 16:13 | 
				
			|||
 */ | 
				
			|||
@Data | 
				
			|||
public class TopicSubGridResultDTO implements Serializable { | 
				
			|||
 | 
				
			|||
    private static final long serialVersionUID = -7251687622455341118L; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 名称 | 
				
			|||
     */ | 
				
			|||
    private String name; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 值 | 
				
			|||
     */ | 
				
			|||
    private Integer value; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 类型 | 
				
			|||
     */ | 
				
			|||
    private String type; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 网格Id | 
				
			|||
     */ | 
				
			|||
    private String gridId; | 
				
			|||
} | 
				
			|||
@ -0,0 +1,30 @@ | 
				
			|||
package com.epmet.topic.dto.result; | 
				
			|||
 | 
				
			|||
import lombok.Data; | 
				
			|||
 | 
				
			|||
import java.io.Serializable; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * @Author zxc | 
				
			|||
 * @CreateTime 2020/6/20 16:14 | 
				
			|||
 */ | 
				
			|||
@Data | 
				
			|||
public class TopicSummaryInfoResultDTO implements Serializable { | 
				
			|||
 | 
				
			|||
    private static final long serialVersionUID = 1103298182001744033L; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 名称 | 
				
			|||
     */ | 
				
			|||
    private String name; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 值 | 
				
			|||
     */ | 
				
			|||
    private Integer value; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 百分比 | 
				
			|||
     */ | 
				
			|||
    private String ratio; | 
				
			|||
} | 
				
			|||
@ -0,0 +1,45 @@ | 
				
			|||
package com.epmet.topic.dto.result; | 
				
			|||
 | 
				
			|||
import lombok.Data; | 
				
			|||
 | 
				
			|||
import java.io.Serializable; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * @Author zxc | 
				
			|||
 * @CreateTime 2020/6/20 16:04 | 
				
			|||
 */ | 
				
			|||
@Data | 
				
			|||
public class TopicSummaryResultDTO implements Serializable { | 
				
			|||
 | 
				
			|||
    private static final long serialVersionUID = -6051892596892952025L; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 话题总数 | 
				
			|||
     */ | 
				
			|||
    private Integer topicTotalCount; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 讨论中话题数量 | 
				
			|||
     */ | 
				
			|||
    private Integer talkingTotalCount; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 已关闭话题数量 | 
				
			|||
     */ | 
				
			|||
    private Integer closedTotalCount; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 已屏蔽话题数量 | 
				
			|||
     */ | 
				
			|||
    private Integer shieldedTotalCount; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 话题已转议题数量 | 
				
			|||
     */ | 
				
			|||
    private Integer shiftedTotalCount; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 数据更新至 时间 | 
				
			|||
     */ | 
				
			|||
    private String deadline; | 
				
			|||
} | 
				
			|||
@ -0,0 +1,81 @@ | 
				
			|||
package com.epmet.module.topic.controller; | 
				
			|||
 | 
				
			|||
import com.epmet.commons.tools.annotation.LoginUser; | 
				
			|||
import com.epmet.commons.tools.security.dto.TokenDto; | 
				
			|||
import com.epmet.commons.tools.utils.Result; | 
				
			|||
import com.epmet.commons.tools.validator.ValidatorUtils; | 
				
			|||
import com.epmet.module.topic.service.TopicService; | 
				
			|||
import com.epmet.topic.dto.form.TopicIncrTrendFormDTO; | 
				
			|||
import com.epmet.topic.dto.result.*; | 
				
			|||
import org.springframework.beans.factory.annotation.Autowired; | 
				
			|||
import org.springframework.web.bind.annotation.PostMapping; | 
				
			|||
import org.springframework.web.bind.annotation.RequestBody; | 
				
			|||
import org.springframework.web.bind.annotation.RequestMapping; | 
				
			|||
import org.springframework.web.bind.annotation.RestController; | 
				
			|||
 | 
				
			|||
import java.util.List; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * @Author zxc | 
				
			|||
 * @CreateTime 2020/6/20 15:55 | 
				
			|||
 */ | 
				
			|||
@RestController | 
				
			|||
@RequestMapping("topic") | 
				
			|||
public class TopicController { | 
				
			|||
 | 
				
			|||
    @Autowired | 
				
			|||
    private TopicService topicService; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * @Description  话题:话题总数、讨论中话题数量、已关闭话题数量、已屏蔽话题数量、话题已转议题数量、数据更新至2020-06-17 | 
				
			|||
     * @param tokenDto | 
				
			|||
     * @author zxc | 
				
			|||
     */ | 
				
			|||
    @PostMapping("topicsummary") | 
				
			|||
    public Result<TopicSummaryResultDTO> topicSummary(@LoginUser TokenDto tokenDto){ | 
				
			|||
        return new Result<TopicSummaryResultDTO>().ok(topicService.topicSummary(tokenDto)); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * @Description  话题——话题分析 | 
				
			|||
     * @param tokenDto | 
				
			|||
     * @param formDTO | 
				
			|||
     * @author zxc | 
				
			|||
     */ | 
				
			|||
    @PostMapping("incrtrend") | 
				
			|||
    public Result<List<TopicIncrTrendResultDTO>> topicIncrTrend(@LoginUser TokenDto tokenDto, @RequestBody TopicIncrTrendFormDTO formDTO){ | 
				
			|||
        ValidatorUtils.validateEntity(formDTO, TopicIncrTrendFormDTO.TopicIncr.class); | 
				
			|||
        return new Result<List<TopicIncrTrendResultDTO>>().ok(topicService.topicIncrTrend(tokenDto,formDTO)); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * @Description  话题——直属网格话题数 | 
				
			|||
     * @param tokenDto | 
				
			|||
     * @author zxc | 
				
			|||
     */ | 
				
			|||
    @PostMapping("subgrid") | 
				
			|||
    public Result<List<TopicSubGridResultDTO>> topicSubGrid(@LoginUser TokenDto tokenDto){ | 
				
			|||
        return new Result<List<TopicSubGridResultDTO>>().ok(topicService.topicSubGrid(tokenDto)); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * @Description  话题——下级机关话题数 | 
				
			|||
     * @param tokenDto | 
				
			|||
     * @author zxc | 
				
			|||
     */ | 
				
			|||
    @PostMapping("subagency") | 
				
			|||
    public Result<List<TopicSubAgencyResultDTO>> topicSubAgency(@LoginUser TokenDto tokenDto){ | 
				
			|||
        return new Result<List<TopicSubAgencyResultDTO>>().ok(topicService.topicSubAgency(tokenDto)); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * @Description  话题——话题分析表 | 
				
			|||
     * @param tokenDto | 
				
			|||
     * @author zxc | 
				
			|||
     */ | 
				
			|||
    @PostMapping("summaryinfo") | 
				
			|||
    public Result<List<TopicSummaryInfoResultDTO>> topicSummaryInfo(@LoginUser TokenDto tokenDto){ | 
				
			|||
        return new Result<List<TopicSummaryInfoResultDTO>>().ok(topicService.topicSummaryInfo(tokenDto)); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
} | 
				
			|||
@ -0,0 +1,108 @@ | 
				
			|||
package com.epmet.module.topic.dao; | 
				
			|||
 | 
				
			|||
import com.epmet.group.dto.result.GroupIncrTrendResultDTO; | 
				
			|||
import com.epmet.topic.dto.result.*; | 
				
			|||
import org.apache.ibatis.annotations.Mapper; | 
				
			|||
import org.apache.ibatis.annotations.Param; | 
				
			|||
 | 
				
			|||
import java.util.List; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * @Author zxc | 
				
			|||
 * @CreateTime 2020/6/20 15:55 | 
				
			|||
 */ | 
				
			|||
@Mapper | 
				
			|||
public interface TopicDao { | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * @Description  获取话题数量及状态 | 
				
			|||
     * @param agencyId | 
				
			|||
     * @author zxc | 
				
			|||
     */ | 
				
			|||
    List<TopicStatusResultDTO> getTopicStatus(@Param("agencyId")String agencyId); | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * @Description  获取机关下已转议题数量 | 
				
			|||
     * @param agencyId | 
				
			|||
     * @author zxc | 
				
			|||
     */ | 
				
			|||
    TopicShiftedCountResultDTO getShiftedCount(@Param("agencyId")String agencyId); | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * @Description  获取话题信息(状态,数量,百分比) | 
				
			|||
     * @param agencyId | 
				
			|||
     * @author zxc | 
				
			|||
     */ | 
				
			|||
    List<TopicSummaryInfoResultDTO> topicSummaryInfo(@Param("agencyId")String agencyId); | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * @Description  根据当前机关判断是否有下级机关 | 
				
			|||
     * @param agencyId | 
				
			|||
     * @author zxc | 
				
			|||
     */ | 
				
			|||
    List<String> getSubAgencyIdList(@Param("agencyId")String agencyId); | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * @Description  获取最后一天的所有话题数据 【fact_topic_status_agency_daily】 | 
				
			|||
     * @param | 
				
			|||
     * @author zxc | 
				
			|||
     */ | 
				
			|||
    List<TopicSubAgencyResultDTO> getAllTopicInfoLastDay(); | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * @Description  获取最后一天的所有话题已转议题数据 | 
				
			|||
     * @param | 
				
			|||
     * @author zxc | 
				
			|||
     */ | 
				
			|||
    List<TopicSubAgencyResultDTO> getAllTopicShiftedInfoLastDay(); | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * @Description  校验机关下是否存在直属网格 | 
				
			|||
     * @param agencyId | 
				
			|||
     * @author zxc | 
				
			|||
     */ | 
				
			|||
    List<String> getSubGridIdList(@Param("agencyId")String agencyId); | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * @Description  获取最后一天的所有话题数据 【fact_topic_status_grid_daily】【grid】 | 
				
			|||
     * @param | 
				
			|||
     * @author zxc | 
				
			|||
     */ | 
				
			|||
    List<TopicSubGridResultDTO> getGridAllTopicInfoLastDay(); | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * @Description  获取最后一天的所有话题已转议题数据【grid】 | 
				
			|||
     * @param | 
				
			|||
     * @author zxc | 
				
			|||
     */ | 
				
			|||
    List<TopicSubGridResultDTO> getGridAllTopicShiftedInfoLastDay(); | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * @Description  话题日增长 | 
				
			|||
     * @param agencyId | 
				
			|||
     * @author zxc | 
				
			|||
     */ | 
				
			|||
    List<TopicIncrTrendResultDTO> getTopicIncrDaily(@Param("agencyId") String agencyId); | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * @Description  话题转议题日增长 | 
				
			|||
     * @param agencyId | 
				
			|||
     * @author zxc | 
				
			|||
     */ | 
				
			|||
    List<TopicIncrTrendResultDTO> getTopicShiftedIncrDaily(@Param("agencyId") String agencyId); | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * @Description  话题月增长 | 
				
			|||
     * @param agencyId | 
				
			|||
     * @author zxc | 
				
			|||
     */ | 
				
			|||
    List<TopicIncrTrendResultDTO> getTopicIncrMonthly(@Param("agencyId") String agencyId); | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * @Description  话题转议题月增长 | 
				
			|||
     * @param agencyId | 
				
			|||
     * @author zxc | 
				
			|||
     */ | 
				
			|||
    List<TopicIncrTrendResultDTO> getTopicShiftedIncrMonthly(@Param("agencyId") String agencyId); | 
				
			|||
 | 
				
			|||
} | 
				
			|||
@ -0,0 +1,51 @@ | 
				
			|||
package com.epmet.module.topic.service; | 
				
			|||
 | 
				
			|||
import com.epmet.commons.tools.security.dto.TokenDto; | 
				
			|||
import com.epmet.topic.dto.form.TopicIncrTrendFormDTO; | 
				
			|||
import com.epmet.topic.dto.result.*; | 
				
			|||
 | 
				
			|||
import java.util.List; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * @Author zxc | 
				
			|||
 * @CreateTime 2020/6/20 15:58 | 
				
			|||
 */ | 
				
			|||
public interface TopicService { | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * @Description  话题:话题总数、讨论中话题数量、已关闭话题数量、已屏蔽话题数量、话题已转议题数量、数据更新至2020-06-17 | 
				
			|||
     * @param tokenDto | 
				
			|||
     * @author zxc | 
				
			|||
     */ | 
				
			|||
    TopicSummaryResultDTO topicSummary(TokenDto tokenDto); | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * @Description  话题——话题分析 | 
				
			|||
     * @param tokenDto | 
				
			|||
     * @param formDTO | 
				
			|||
     * @author zxc | 
				
			|||
     */ | 
				
			|||
    List<TopicIncrTrendResultDTO> topicIncrTrend(TokenDto tokenDto, TopicIncrTrendFormDTO formDTO); | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * @Description  话题——直属网格话题数 | 
				
			|||
     * @param tokenDto | 
				
			|||
     * @author zxc | 
				
			|||
     */ | 
				
			|||
    List<TopicSubGridResultDTO> topicSubGrid( TokenDto tokenDto); | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * @Description  话题——下级机关话题数 | 
				
			|||
     * @param tokenDto | 
				
			|||
     * @author zxc | 
				
			|||
     */ | 
				
			|||
    List<TopicSubAgencyResultDTO> topicSubAgency(TokenDto tokenDto); | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * @Description  话题——话题分析表 | 
				
			|||
     * @param tokenDto | 
				
			|||
     * @author zxc | 
				
			|||
     */ | 
				
			|||
    List<TopicSummaryInfoResultDTO> topicSummaryInfo(TokenDto tokenDto); | 
				
			|||
 | 
				
			|||
} | 
				
			|||
@ -0,0 +1,182 @@ | 
				
			|||
package com.epmet.module.topic.service.impl; | 
				
			|||
 | 
				
			|||
import com.epmet.commons.tools.constant.NumConstant; | 
				
			|||
import com.epmet.commons.tools.security.dto.TokenDto; | 
				
			|||
import com.epmet.dto.form.LoginUserDetailsFormDTO; | 
				
			|||
import com.epmet.dto.result.LoginUserDetailsResultDTO; | 
				
			|||
import com.epmet.feign.EpmetUserOpenFeignClient; | 
				
			|||
import com.epmet.module.topic.dao.TopicDao; | 
				
			|||
import com.epmet.module.topic.service.TopicService; | 
				
			|||
import com.epmet.topic.constant.TopicConstant; | 
				
			|||
import com.epmet.topic.dto.form.TopicIncrTrendFormDTO; | 
				
			|||
import com.epmet.topic.dto.result.*; | 
				
			|||
import org.springframework.beans.BeanUtils; | 
				
			|||
import org.springframework.beans.factory.annotation.Autowired; | 
				
			|||
import org.springframework.stereotype.Service; | 
				
			|||
 | 
				
			|||
import java.util.ArrayList; | 
				
			|||
import java.util.Comparator; | 
				
			|||
import java.util.List; | 
				
			|||
import java.util.stream.Collectors; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * @Author zxc | 
				
			|||
 * @CreateTime 2020/6/20 15:58 | 
				
			|||
 */ | 
				
			|||
@Service | 
				
			|||
public class TopicServiceImpl implements TopicService { | 
				
			|||
 | 
				
			|||
    @Autowired | 
				
			|||
    private TopicDao topicDao; | 
				
			|||
    @Autowired | 
				
			|||
    private EpmetUserOpenFeignClient epmetUserOpenFeignClient; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * @Description  话题:话题总数、讨论中话题数量、已关闭话题数量、已屏蔽话题数量、话题已转议题数量、数据更新至2020-06-17 | 
				
			|||
     * @param tokenDto | 
				
			|||
     * @author zxc | 
				
			|||
     */ | 
				
			|||
    @Override | 
				
			|||
    public TopicSummaryResultDTO topicSummary(TokenDto tokenDto) { | 
				
			|||
        TopicSummaryResultDTO result = new TopicSummaryResultDTO(); | 
				
			|||
        String agencyId = this.getLoginUserDetails(tokenDto); | 
				
			|||
        List<TopicStatusResultDTO> topicStatus = topicDao.getTopicStatus(agencyId); | 
				
			|||
        if (topicStatus.size() != NumConstant.ZERO){ | 
				
			|||
            topicStatus.forEach(topic -> { | 
				
			|||
                if (topic.getTopicStatus().equals(TopicConstant.DISCUSSING)){ | 
				
			|||
                    result.setTalkingTotalCount(topic.getTopicCount()); | 
				
			|||
                }else if (topic.getTopicStatus().equals(TopicConstant.CLOSED)){ | 
				
			|||
                    result.setClosedTotalCount(topic.getTopicCount()); | 
				
			|||
                }else { | 
				
			|||
                    result.setShieldedTotalCount(topic.getTopicCount()); | 
				
			|||
                } | 
				
			|||
            }); | 
				
			|||
            result.setTopicTotalCount(topicStatus.stream().collect(Collectors.summingInt(TopicStatusResultDTO::getTopicCount))); | 
				
			|||
        } | 
				
			|||
        TopicShiftedCountResultDTO shiftedCount = topicDao.getShiftedCount(agencyId); | 
				
			|||
        if (shiftedCount != null){ | 
				
			|||
            result.setShiftedTotalCount(shiftedCount.getShiftedIssueCount()); | 
				
			|||
            result.setDeadline(shiftedCount.getDeadline()); | 
				
			|||
        } | 
				
			|||
        return result; | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * @Description  话题——话题分析 | 
				
			|||
     * @param tokenDto | 
				
			|||
     * @param formDTO | 
				
			|||
     * @author zxc | 
				
			|||
     */ | 
				
			|||
    @Override | 
				
			|||
    public List<TopicIncrTrendResultDTO> topicIncrTrend(TokenDto tokenDto, TopicIncrTrendFormDTO formDTO) { | 
				
			|||
        String agencyId = this.getLoginUserDetails(tokenDto); | 
				
			|||
        List<TopicIncrTrendResultDTO> result = new ArrayList<>(); | 
				
			|||
        if (formDTO.getType().equals(TopicConstant.DATE)){ | 
				
			|||
            List<TopicIncrTrendResultDTO> topicIncrDaily = topicDao.getTopicIncrDaily(agencyId); | 
				
			|||
            List<TopicIncrTrendResultDTO> topicShiftedIncrDaily = topicDao.getTopicShiftedIncrDaily(agencyId); | 
				
			|||
            topicIncrDaily.addAll(topicShiftedIncrDaily); | 
				
			|||
            result = topicIncrDaily.stream().sorted(Comparator.comparing(TopicIncrTrendResultDTO::getDate).reversed()).collect(Collectors.toList()); | 
				
			|||
        }else { | 
				
			|||
            List<TopicIncrTrendResultDTO> topicIncrMonthly = topicDao.getTopicIncrMonthly(agencyId); | 
				
			|||
            List<TopicIncrTrendResultDTO> topicShiftedIncrMonthly = topicDao.getTopicShiftedIncrMonthly(agencyId); | 
				
			|||
            topicIncrMonthly.addAll(topicShiftedIncrMonthly); | 
				
			|||
            result = topicIncrMonthly.stream().sorted(Comparator.comparing(TopicIncrTrendResultDTO::getDate).reversed()).collect(Collectors.toList()); | 
				
			|||
        } | 
				
			|||
        return result; | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * @Description  话题——直属网格话题数 | 
				
			|||
     * @param tokenDto | 
				
			|||
     * @author zxc | 
				
			|||
     */ | 
				
			|||
    @Override | 
				
			|||
    public List<TopicSubGridResultDTO> topicSubGrid(TokenDto tokenDto) { | 
				
			|||
        String agencyId = this.getLoginUserDetails(tokenDto); | 
				
			|||
        List<TopicSubGridResultDTO> result = new ArrayList<>(); | 
				
			|||
        List<String> subGridIdList = topicDao.getSubGridIdList(agencyId); | 
				
			|||
        if (subGridIdList.size() != NumConstant.ZERO){ | 
				
			|||
            List<TopicSubGridResultDTO> gridAllTopicInfoLastDay = topicDao.getGridAllTopicInfoLastDay(); | 
				
			|||
            List<TopicSubGridResultDTO> gridAllTopicShiftedInfoLastDay = topicDao.getGridAllTopicShiftedInfoLastDay(); | 
				
			|||
            subGridIdList.forEach(gridId -> { | 
				
			|||
                gridAllTopicInfoLastDay.forEach(gridTopic -> { | 
				
			|||
                    if (gridId.equals(gridTopic.getGridId())){ | 
				
			|||
                        result.add(gridTopic); | 
				
			|||
                    } | 
				
			|||
                }); | 
				
			|||
                gridAllTopicShiftedInfoLastDay.forEach(gridShift -> { | 
				
			|||
                    if (gridId.equals(gridShift.getGridId())){ | 
				
			|||
                        result.add(gridShift); | 
				
			|||
                    } | 
				
			|||
                }); | 
				
			|||
            }); | 
				
			|||
            return result; | 
				
			|||
        } | 
				
			|||
        return new ArrayList<>(); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * @Description  话题——下级机关话题数 | 
				
			|||
     * @param tokenDto | 
				
			|||
     * @author zxc | 
				
			|||
     */ | 
				
			|||
    @Override | 
				
			|||
    public List<TopicSubAgencyResultDTO> topicSubAgency(TokenDto tokenDto) { | 
				
			|||
        String agencyId = this.getLoginUserDetails(tokenDto); | 
				
			|||
        List<TopicSubAgencyResultDTO> result = new ArrayList<>(); | 
				
			|||
        List<String> subAgencyIdList = topicDao.getSubAgencyIdList(agencyId); | 
				
			|||
        //存在下级机关
 | 
				
			|||
        if (subAgencyIdList.size() != NumConstant.ZERO){ | 
				
			|||
            List<TopicSubAgencyResultDTO> allTopicInfoLastDay = topicDao.getAllTopicInfoLastDay(); | 
				
			|||
            List<TopicSubAgencyResultDTO> allTopicShiftedInfoLastDay = topicDao.getAllTopicShiftedInfoLastDay(); | 
				
			|||
            //话题状态为 已关闭、讨论中、已屏蔽
 | 
				
			|||
            subAgencyIdList.forEach(agencyIdOne -> { | 
				
			|||
                allTopicInfoLastDay.forEach(agency -> { | 
				
			|||
                    if (agencyIdOne.equals(agency.getAgencyId())){ | 
				
			|||
                        result.add(agency); | 
				
			|||
                    } | 
				
			|||
                }); | 
				
			|||
                allTopicShiftedInfoLastDay.forEach(shiftTopic -> { | 
				
			|||
                    if (agencyIdOne.equals(shiftTopic.getAgencyId())){ | 
				
			|||
                        result.add(shiftTopic); | 
				
			|||
                    } | 
				
			|||
                }); | 
				
			|||
            }); | 
				
			|||
            return result; | 
				
			|||
        } | 
				
			|||
        //不存在
 | 
				
			|||
        return new ArrayList<>(); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * @Description  话题——话题分析表 | 
				
			|||
     * @param tokenDto | 
				
			|||
     * @author zxc | 
				
			|||
     */ | 
				
			|||
    @Override | 
				
			|||
    public List<TopicSummaryInfoResultDTO> topicSummaryInfo(TokenDto tokenDto) { | 
				
			|||
        String agencyId = this.getLoginUserDetails(tokenDto); | 
				
			|||
        List<TopicSummaryInfoResultDTO> topicSummaryInfo = topicDao.topicSummaryInfo(agencyId); | 
				
			|||
        TopicShiftedCountResultDTO shiftedCount = topicDao.getShiftedCount(agencyId); | 
				
			|||
        int i = (shiftedCount.getShiftedIssueCount() / topicSummaryInfo.stream().collect(Collectors.summingInt(TopicSummaryInfoResultDTO::getValue))) * NumConstant.ONE_HUNDRED; | 
				
			|||
        String ratio = String.valueOf(i) + TopicConstant.RATIO; | 
				
			|||
        TopicSummaryInfoResultDTO result = new TopicSummaryInfoResultDTO(); | 
				
			|||
        result.setName(TopicConstant.SHIFTED); | 
				
			|||
        result.setRatio(ratio); | 
				
			|||
        result.setValue(shiftedCount.getShiftedIssueCount()); | 
				
			|||
        topicSummaryInfo.add(result); | 
				
			|||
        return topicSummaryInfo; | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * @Description  获取机关ID | 
				
			|||
     * @param tokenDto | 
				
			|||
     * @author zxc | 
				
			|||
     */ | 
				
			|||
    public String getLoginUserDetails(TokenDto tokenDto){ | 
				
			|||
        LoginUserDetailsFormDTO dto = new LoginUserDetailsFormDTO(); | 
				
			|||
        BeanUtils.copyProperties(tokenDto,dto); | 
				
			|||
        LoginUserDetailsResultDTO data = epmetUserOpenFeignClient.getLoginUserDetails(dto).getData(); | 
				
			|||
        return data.getAgencyId(); | 
				
			|||
    } | 
				
			|||
} | 
				
			|||
@ -0,0 +1,215 @@ | 
				
			|||
<?xml version="1.0" encoding="UTF-8"?> | 
				
			|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | 
				
			|||
 | 
				
			|||
<mapper namespace="com.epmet.module.topic.dao.TopicDao"> | 
				
			|||
 | 
				
			|||
    <!--获取话题数量及状态--> | 
				
			|||
    <select id="getTopicStatus" parameterType="java.lang.String" resultType="com.epmet.topic.dto.result.TopicStatusResultDTO"> | 
				
			|||
        SELECT | 
				
			|||
            topic_count AS topicCount, | 
				
			|||
            topic_status_id AS topicStatus | 
				
			|||
        FROM | 
				
			|||
            fact_topic_status_agency_daily | 
				
			|||
        WHERE | 
				
			|||
            del_flag = '0' | 
				
			|||
            AND agency_id = #{agencyId} | 
				
			|||
        GROUP BY | 
				
			|||
            topic_status_id | 
				
			|||
        ORDER BY | 
				
			|||
            date_id DESC | 
				
			|||
    </select> | 
				
			|||
 | 
				
			|||
    <!--获取机关下已转议题数量--> | 
				
			|||
    <select id="getShiftedCount" parameterType="java.lang.String" resultType="com.epmet.topic.dto.result.TopicShiftedCountResultDTO"> | 
				
			|||
        SELECT | 
				
			|||
            issue_total AS shiftedIssueCount, | 
				
			|||
            DATE_FORMAT( date_id, '%Y-%m-%d' ) AS deadline | 
				
			|||
        FROM | 
				
			|||
            fact_topic_issue_agency_daily | 
				
			|||
        WHERE | 
				
			|||
            del_flag = '0' | 
				
			|||
            AND agency_id = #{agencyId} | 
				
			|||
        ORDER BY | 
				
			|||
            date_id DESC | 
				
			|||
        LIMIT 1 | 
				
			|||
    </select> | 
				
			|||
 | 
				
			|||
    <!-- 获取话题信息(状态,数量,百分比) --> | 
				
			|||
    <select id="topicSummaryInfo" parameterType="java.lang.String" resultType="com.epmet.topic.dto.result.TopicSummaryInfoResultDTO"> | 
				
			|||
        SELECT | 
				
			|||
            topic_count AS value, | 
				
			|||
            (case WHEN topic_status_id = 'discussing' THEN '讨论中' | 
				
			|||
            WHEN topic_status_id = 'hidden' THEN '已屏蔽' | 
				
			|||
            WHEN topic_status_id = 'closed' THEN '已关闭' | 
				
			|||
            ELSE '无' END) AS name, | 
				
			|||
            topic_proportion AS ratio | 
				
			|||
        FROM | 
				
			|||
            fact_topic_status_agency_daily | 
				
			|||
        WHERE | 
				
			|||
            del_flag = '0' | 
				
			|||
            AND agency_id = #{agencyId} | 
				
			|||
        GROUP BY | 
				
			|||
            topic_status_id | 
				
			|||
        ORDER BY | 
				
			|||
            date_id DESC | 
				
			|||
    </select> | 
				
			|||
 | 
				
			|||
    <!--根据当前机关判断是否有下级机关--> | 
				
			|||
    <select id="getSubAgencyIdList" parameterType="java.lang.String" resultType="java.lang.String"> | 
				
			|||
        SELECT | 
				
			|||
            id AS agencyId | 
				
			|||
        FROM | 
				
			|||
            dim_agency | 
				
			|||
        WHERE | 
				
			|||
            del_flag = '0' | 
				
			|||
            AND pid = #{agencyId} | 
				
			|||
    </select> | 
				
			|||
 | 
				
			|||
    <!--获取最后一天的所有话题数据--> | 
				
			|||
    <select id="getAllTopicInfoLastDay" resultType="com.epmet.topic.dto.result.TopicSubAgencyResultDTO"> | 
				
			|||
        SELECT | 
				
			|||
			ftsad.agency_id AS agencyId, | 
				
			|||
            ftsad.topic_count AS value, | 
				
			|||
            (case WHEN ftsad.topic_status_id = 'discussing' THEN '讨论中' | 
				
			|||
            WHEN ftsad.topic_status_id = 'hidden' THEN '已屏蔽' | 
				
			|||
            WHEN ftsad.topic_status_id = 'closed' THEN '已关闭' | 
				
			|||
            ELSE '无' END) AS type, | 
				
			|||
			da.agency_name AS name | 
				
			|||
        FROM | 
				
			|||
            fact_topic_status_agency_daily ftsad | 
				
			|||
			LEFT JOIN dim_agency da ON da.id = ftsad.agency_id AND da.del_flag = '0' | 
				
			|||
        WHERE | 
				
			|||
            ftsad.del_flag = '0' | 
				
			|||
        GROUP BY | 
				
			|||
            ftsad.topic_status_id | 
				
			|||
        ORDER BY | 
				
			|||
            ftsad.date_id DESC | 
				
			|||
    </select> | 
				
			|||
 | 
				
			|||
    <!--获取最后一天的所有话题已转议题数据--> | 
				
			|||
    <select id="getAllTopicShiftedInfoLastDay" resultType="com.epmet.topic.dto.result.TopicSubAgencyResultDTO"> | 
				
			|||
        SELECT | 
				
			|||
            ftiad.issue_total AS value, | 
				
			|||
			'已转议题' AS type, | 
				
			|||
            ftiad.agency_id AS agencyId, | 
				
			|||
			da.agency_name AS name | 
				
			|||
        FROM | 
				
			|||
            fact_topic_issue_agency_daily ftiad | 
				
			|||
			LEFT JOIN dim_agency da ON da.id = ftiad.agency_id AND da.del_flag = '0' | 
				
			|||
        WHERE | 
				
			|||
            ftiad.del_flag = '0' | 
				
			|||
		GROUP BY ftiad.agency_id | 
				
			|||
        ORDER BY ftiad.date_id DESC | 
				
			|||
    </select> | 
				
			|||
 | 
				
			|||
    <!--校验机关下是否存在直属网格--> | 
				
			|||
    <select id="getSubGridIdList" parameterType="java.lang.String" resultType="java.lang.String"> | 
				
			|||
        SELECT | 
				
			|||
            id AS gridId | 
				
			|||
        FROM | 
				
			|||
            dim_grid | 
				
			|||
        WHERE | 
				
			|||
            del_flag = '0' | 
				
			|||
            AND agency_id = #{agencyId} | 
				
			|||
    </select> | 
				
			|||
 | 
				
			|||
    <!--获取最后一天的所有话题数据--> | 
				
			|||
    <select id="getGridAllTopicInfoLastDay" resultType="com.epmet.topic.dto.result.TopicSubGridResultDTO"> | 
				
			|||
        SELECT | 
				
			|||
			ftsad.grid_id AS gridId, | 
				
			|||
            ftsad.topic_count AS value, | 
				
			|||
            (case WHEN ftsad.topic_status_id = 'discussing' THEN '讨论中' | 
				
			|||
            WHEN ftsad.topic_status_id = 'hidden' THEN '已屏蔽' | 
				
			|||
            WHEN ftsad.topic_status_id = 'closed' THEN '已关闭' | 
				
			|||
            ELSE '无' END) AS type, | 
				
			|||
			dg.grid_name AS name | 
				
			|||
        FROM | 
				
			|||
            fact_topic_status_grid_daily ftsad | 
				
			|||
			LEFT JOIN dim_grid dg ON dg.id = ftsad.grid_id AND dg.del_flag = '0' | 
				
			|||
        WHERE | 
				
			|||
            ftsad.del_flag = '0' | 
				
			|||
        GROUP BY | 
				
			|||
            ftsad.topic_status_id | 
				
			|||
        ORDER BY | 
				
			|||
            ftsad.date_id DESC | 
				
			|||
    </select> | 
				
			|||
 | 
				
			|||
    <!--获取最后一天的所有话题已转议题数据--> | 
				
			|||
    <select id="getGridAllTopicShiftedInfoLastDay" resultType="com.epmet.topic.dto.result.TopicSubGridResultDTO"> | 
				
			|||
        SELECT | 
				
			|||
            ftiad.issue_total AS value, | 
				
			|||
			'已转议题' AS type, | 
				
			|||
            ftiad.grid_id AS gridId, | 
				
			|||
			da.grid_name AS name | 
				
			|||
        FROM | 
				
			|||
            fact_topic_issue_grid_daily ftiad | 
				
			|||
			LEFT JOIN dim_grid da ON da.id = ftiad.grid_id AND da.del_flag = '0' | 
				
			|||
        WHERE | 
				
			|||
            ftiad.del_flag = '0' | 
				
			|||
		GROUP BY ftiad.grid_id | 
				
			|||
        ORDER BY ftiad.date_id DESC | 
				
			|||
    </select> | 
				
			|||
 | 
				
			|||
    <!--话题日增长--> | 
				
			|||
    <select id="getTopicIncrDaily" parameterType="java.lang.String" resultType="com.epmet.topic.dto.result.TopicIncrTrendResultDTO"> | 
				
			|||
        SELECT | 
				
			|||
            DATE_FORMAT( date_id, '%Y/%m/%d' ) AS date, | 
				
			|||
            topic_increment AS value, | 
				
			|||
            (case WHEN topic_status_id = 'discussing' THEN '讨论中' | 
				
			|||
            WHEN topic_status_id = 'hidden' THEN '已屏蔽' | 
				
			|||
            WHEN topic_status_id = 'closed' THEN '已关闭' | 
				
			|||
            ELSE '无' END) AS type | 
				
			|||
        FROM | 
				
			|||
            fact_topic_status_agency_daily | 
				
			|||
        WHERE | 
				
			|||
            del_flag = '0' | 
				
			|||
            AND agency_id = #{agencyId} | 
				
			|||
        ORDER BY | 
				
			|||
            date_id DESC | 
				
			|||
    </select> | 
				
			|||
     | 
				
			|||
    <!--话题转议题--> | 
				
			|||
    <select id="getTopicShiftedIncrDaily" parameterType="java.lang.String" resultType="com.epmet.topic.dto.result.TopicIncrTrendResultDTO"> | 
				
			|||
        SELECT | 
				
			|||
            DATE_FORMAT( date_id, '%Y/%m/%d' ) AS date, | 
				
			|||
            issue_incr AS value, | 
				
			|||
			'已转议题' AS type | 
				
			|||
        FROM | 
				
			|||
            fact_topic_issue_agency_daily | 
				
			|||
        WHERE | 
				
			|||
            del_flag = '0' | 
				
			|||
			AND agency_id = #{agencyId} | 
				
			|||
        ORDER BY date_id DESC | 
				
			|||
    </select> | 
				
			|||
 | 
				
			|||
    <select id="getTopicIncrMonthly" parameterType="java.lang.String" resultType="com.epmet.topic.dto.result.TopicIncrTrendResultDTO"> | 
				
			|||
        SELECT | 
				
			|||
            CONCAT(SUBSTRING(month_id,1,4),'/',SUBSTRING(month_id,5,6)) AS date, | 
				
			|||
            topic_incr AS value, | 
				
			|||
            (case WHEN topic_status_id = 'discussing' THEN '讨论中' | 
				
			|||
            WHEN topic_status_id = 'hidden' THEN '已屏蔽' | 
				
			|||
            WHEN topic_status_id = 'closed' THEN '已关闭' | 
				
			|||
            ELSE '无' END) AS type | 
				
			|||
        FROM | 
				
			|||
            fact_topic_status_agency_monthly | 
				
			|||
        WHERE | 
				
			|||
            del_flag = '0' | 
				
			|||
            AND agency_id = #{agencyId} | 
				
			|||
        ORDER BY | 
				
			|||
            month_id DESC | 
				
			|||
    </select> | 
				
			|||
 | 
				
			|||
    <select id="getTopicShiftedIncrMonthly" parameterType="java.lang.String" resultType="com.epmet.topic.dto.result.TopicIncrTrendResultDTO"> | 
				
			|||
        SELECT | 
				
			|||
            CONCAT(SUBSTRING(month_id,1,4),'/',SUBSTRING(month_id,5,6)) AS date, | 
				
			|||
            issue_incr AS value, | 
				
			|||
			'已转议题' AS type | 
				
			|||
        FROM | 
				
			|||
            fact_topic_issue_agency_monthly | 
				
			|||
        WHERE | 
				
			|||
            del_flag = '0' | 
				
			|||
			AND agency_id = #{agencyId} | 
				
			|||
        ORDER BY month_id DESC | 
				
			|||
    </select> | 
				
			|||
     | 
				
			|||
</mapper> | 
				
			|||
					Loading…
					
					
				
		Reference in new issue