Browse Source

基础数据-涉及话题数据计算的重新调整查询规则

dev_shibei_match
sunyuchao 4 years ago
parent
commit
a54d1ce689
  1. 2
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/form/SubAgencyFormDTO.java
  2. 2
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/form/SubGridFormDTO.java
  3. 2
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/result/AgencyBasicDataResultDTO.java
  4. 18
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/datastats/DataStatsDao.java
  5. 45
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java
  6. 43
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/datastats/DatsStatsDao.xml

2
epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/form/SubAgencyFormDTO.java

@ -38,6 +38,8 @@ public class SubAgencyFormDTO implements Serializable {
public static class Topic implements Serializable { public static class Topic implements Serializable {
//组织Id //组织Id
private String agencyId; private String agencyId;
//话题总量
private Integer topicTotal;
//话题数量 //话题数量
private Integer topicCount; private Integer topicCount;
//话题状态 已关闭:closed、已屏蔽:hidden、 讨论中:discussing //话题状态 已关闭:closed、已屏蔽:hidden、 讨论中:discussing

2
epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/form/SubGridFormDTO.java

@ -38,6 +38,8 @@ public class SubGridFormDTO implements Serializable {
public static class Topic implements Serializable { public static class Topic implements Serializable {
//网格Id //网格Id
private String gridId; private String gridId;
//话题总量
private Integer topicTotal;
//话题数量 //话题数量
private Integer topicCount; private Integer topicCount;
//话题状态 已关闭:closed、已屏蔽:hidden、 讨论中:discussing //话题状态 已关闭:closed、已屏蔽:hidden、 讨论中:discussing

2
epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/result/AgencyBasicDataResultDTO.java

@ -81,6 +81,8 @@ public class AgencyBasicDataResultDTO implements Serializable {
@Data @Data
public static class Topic implements Serializable { public static class Topic implements Serializable {
//话题总量
private Integer topicTotal;
//话题数量 //话题数量
private Integer topicCount; private Integer topicCount;
//话题状态 已关闭:closed、已屏蔽:hidden、 讨论中:discussing //话题状态 已关闭:closed、已屏蔽:hidden、 讨论中:discussing

18
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/datastats/DataStatsDao.java

@ -58,6 +58,12 @@ public interface DataStatsDao {
*/ */
AgencyBasicDataResultDTO.Topic getAgencyTopicShiftIssue(@Param("agencyId") String agencyId, @Param("dateId") String dateId); AgencyBasicDataResultDTO.Topic getAgencyTopicShiftIssue(@Param("agencyId") String agencyId, @Param("dateId") String dateId);
/**
* @Description 热议中话题-机关日统计数据
* @author sun
*/
AgencyBasicDataResultDTO.Topic getAgencyTopicHotDiscuss(@Param("agencyId") String agencyId, @Param("dateId") String dateId);
/** /**
* @Description 查询组织下最新议题日统计数据 * @Description 查询组织下最新议题日统计数据
* @author sun * @author sun
@ -118,6 +124,12 @@ public interface DataStatsDao {
*/ */
List<SubAgencyFormDTO.Topic> getSubAgencyTopicShiftIssue(@Param("agencyIds") List<String> agencyIds, @Param("dateId") String dateId); List<SubAgencyFormDTO.Topic> getSubAgencyTopicShiftIssue(@Param("agencyIds") List<String> agencyIds, @Param("dateId") String dateId);
/**
* @Description 查询直属下级组织热议中话题-机关日统计数据
* @author sun
*/
List<SubAgencyFormDTO.Topic> getSubAgencyTopicHotDiscuss(@Param("agencyIds") List<String> agencyIds, @Param("dateId") String dateId);
/** /**
* @Description 查询网格层级状态话题-日统计数据 * @Description 查询网格层级状态话题-日统计数据
* @author sun * @author sun
@ -130,6 +142,12 @@ public interface DataStatsDao {
*/ */
List<SubGridFormDTO.Topic> getSubGridTopicShiftIssue(@Param("gridIds") List<String> gridIds, @Param("dateId") String dateId); List<SubGridFormDTO.Topic> getSubGridTopicShiftIssue(@Param("gridIds") List<String> gridIds, @Param("dateId") String dateId);
/**
* @Description 查询网格层级热议中话题-日统计数据
* @author sun
*/
List<SubGridFormDTO.Topic> getSubGridTopicHotDiscuss(@Param("gridIds") List<String> gridIds, @Param("dateId") String dateId);
/** /**
* @Description 查询直属下级组织议题日统计数据默认按议题总数降序 * @Description 查询直属下级组织议题日统计数据默认按议题总数降序
* @author sun * @author sun

45
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java

@ -78,29 +78,32 @@ public class DataStatsServiceImpl implements DataStatsService {
//3.查询组织下最新话题日统计数据 //3.查询组织下最新话题日统计数据
//状态话题-机关日统计数据表最新日期三种状态数据 //状态话题-机关日统计数据表最新日期三种状态数据
//机关日表里三种类型数据之和就是话题总量,讨论中数量与热议中不是一个概念,热议中=总量-关闭数-屏蔽数-转议题数 //机关日表里三种类型数据之和就是话题总量,讨论中数量与热议中不是一个概念
List<AgencyBasicDataResultDTO.Topic> topic = dataStatsDao.getAgencyTopic(formDTO.getAgencyId(), formDTO.getDateId()); List<AgencyBasicDataResultDTO.Topic> topic = dataStatsDao.getAgencyTopic(formDTO.getAgencyId(), formDTO.getDateId());
//转议题话题-机关日统计数据表 //转议题话题-机关日统计数据表
AgencyBasicDataResultDTO.Topic topicSHiftIssue = dataStatsDao.getAgencyTopicShiftIssue(formDTO.getAgencyId(), formDTO.getDateId()); AgencyBasicDataResultDTO.Topic topicSHiftIssue = dataStatsDao.getAgencyTopicShiftIssue(formDTO.getAgencyId(), formDTO.getDateId());
//热议中话题-机关日统计数据
AgencyBasicDataResultDTO.Topic hotdiscuss = dataStatsDao.getAgencyTopicHotDiscuss(formDTO.getAgencyId(), formDTO.getDateId());
AtomicReference<Integer> closedTotal = new AtomicReference<>(0); AtomicReference<Integer> closedTotal = new AtomicReference<>(0);
AtomicReference<Integer> hiddenTotal = new AtomicReference<>(0);
if (topic.size() > NumConstant.ZERO) { if (topic.size() > NumConstant.ZERO) {
resultDTO.setTopicTotal(topic.stream().collect(Collectors.summingInt(AgencyBasicDataResultDTO.Topic::getTopicCount))); resultDTO.setTopicTotal(topic.stream().collect(Collectors.summingInt(AgencyBasicDataResultDTO.Topic::getTopicCount)));
topic.forEach(t -> { topic.forEach(t -> {
if (t.getTopicStatus().equals("closed")) { if (t.getTopicStatus().equals("closed")) {
closedTotal.set(t.getTopicCount()); closedTotal.set(t.getTopicCount());
} }
if (t.getTopicStatus().equals("hidden")) {
hiddenTotal.set(t.getTopicCount());
}
}); });
} }
//转议题
if (null != topicSHiftIssue) { if (null != topicSHiftIssue) {
resultDTO.setShiftIssueTotal(topicSHiftIssue.getShiftedIssueTotal()); resultDTO.setShiftIssueTotal(topicSHiftIssue.getShiftedIssueTotal());
resultDTO.setShiftIssueRatio(resultDTO.getShiftIssueTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftIssueTotal() / (float) resultDTO.getTopicTotal()))); resultDTO.setShiftIssueRatio(resultDTO.getShiftIssueTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftIssueTotal() / (float) resultDTO.getTopicTotal())));
} }
resultDTO.setDiscussingTotal(resultDTO.getTopicTotal() - closedTotal.get() - hiddenTotal.get() - resultDTO.getShiftIssueTotal()); //热议中
if (null != hotdiscuss) {
resultDTO.setDiscussingTotal(hotdiscuss.getTopicCount());
resultDTO.setDiscussingRatio(resultDTO.getDiscussingTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getDiscussingTotal() / (float) resultDTO.getTopicTotal()))); resultDTO.setDiscussingRatio(resultDTO.getDiscussingTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getDiscussingTotal() / (float) resultDTO.getTopicTotal())));
}
//已处理
resultDTO.setClosedTopicTotal(closedTotal.get()); resultDTO.setClosedTopicTotal(closedTotal.get());
resultDTO.setClosedTopicRatio(resultDTO.getClosedTopicTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedTopicTotal() / (float) resultDTO.getTopicTotal()))); resultDTO.setClosedTopicRatio(resultDTO.getClosedTopicTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedTopicTotal() / (float) resultDTO.getTopicTotal())));
@ -404,16 +407,18 @@ public class DataStatsServiceImpl implements DataStatsService {
List<String> agencyIds = subAgencyList.stream().map(DimAgencyEntity::getId).collect(Collectors.toList()); List<String> agencyIds = subAgencyList.stream().map(DimAgencyEntity::getId).collect(Collectors.toList());
//2.查询直属下级组织状态话题-日统计数据 //2.查询直属下级组织状态话题-日统计数据
//机关日表里三种类型数据之和就是话题总量,讨论中数量与热议中不是一个概念,热议中=总量-关闭数-屏蔽数-转议题数 //机关日表里三种类型数据之和就是话题总量,讨论中数量与热议中不是一个概念
List<SubAgencyFormDTO.Topic> topic = dataStatsDao.getSubAgencyTopic(agencyIds, formDTO.getDateId()); List<SubAgencyFormDTO.Topic> topic = dataStatsDao.getSubAgencyTopic(agencyIds, formDTO.getDateId());
//查询直属下级组织转议题话题-日统计数据表 //查询直属下级组织转议题话题-日统计数据表
List<SubAgencyFormDTO.Topic> topicShiftIssue = dataStatsDao.getSubAgencyTopicShiftIssue(agencyIds, formDTO.getDateId()); List<SubAgencyFormDTO.Topic> topicShiftIssue = dataStatsDao.getSubAgencyTopicShiftIssue(agencyIds, formDTO.getDateId());
//查询直属下级组织热议中话题-机关日统计数据
List<SubAgencyFormDTO.Topic> hotdiscuss = dataStatsDao.getSubAgencyTopicHotDiscuss(agencyIds, formDTO.getDateId());
agencyIds.forEach(agencyId -> { agencyIds.forEach(agencyId -> {
SubAgencyTopicResultDTO resultDTO = new SubAgencyTopicResultDTO(); SubAgencyTopicResultDTO resultDTO = new SubAgencyTopicResultDTO();
AtomicInteger topicTotal = new AtomicInteger(0); AtomicInteger topicTotal = new AtomicInteger(0);
AtomicInteger closedTotal = new AtomicInteger(0); AtomicInteger closedTotal = new AtomicInteger(0);
AtomicInteger hiddenTotal = new AtomicInteger(0);
AtomicInteger shiftIssueTotal = new AtomicInteger(0); AtomicInteger shiftIssueTotal = new AtomicInteger(0);
AtomicInteger hotdiscussTotal = new AtomicInteger(0);
AtomicReference<String> agencyName = new AtomicReference<>(""); AtomicReference<String> agencyName = new AtomicReference<>("");
topic.forEach(t -> { topic.forEach(t -> {
if (t.getAgencyId().equals(agencyId)) { if (t.getAgencyId().equals(agencyId)) {
@ -421,9 +426,6 @@ public class DataStatsServiceImpl implements DataStatsService {
if (t.getTopicStatus().equals("closed")) { if (t.getTopicStatus().equals("closed")) {
closedTotal.set(t.getTopicCount()); closedTotal.set(t.getTopicCount());
} }
if (t.getTopicStatus().equals("hidden")) {
hiddenTotal.set(t.getTopicCount());
}
} }
}); });
topicShiftIssue.forEach(t -> { topicShiftIssue.forEach(t -> {
@ -431,6 +433,11 @@ public class DataStatsServiceImpl implements DataStatsService {
shiftIssueTotal.addAndGet(t.getShiftedIssueTotal()); shiftIssueTotal.addAndGet(t.getShiftedIssueTotal());
} }
}); });
hotdiscuss.forEach(t -> {
if (t.getAgencyId().equals(agencyId)) {
hotdiscussTotal.addAndGet(t.getTopicCount());
}
});
subAgencyList.forEach(sub -> { subAgencyList.forEach(sub -> {
if (agencyId.equals(sub.getId())) { if (agencyId.equals(sub.getId())) {
agencyName.set(sub.getAgencyName()); agencyName.set(sub.getAgencyName());
@ -440,7 +447,7 @@ public class DataStatsServiceImpl implements DataStatsService {
resultDTO.setAgencyId(agencyId); resultDTO.setAgencyId(agencyId);
resultDTO.setAgencyName(agencyName.get()); resultDTO.setAgencyName(agencyName.get());
resultDTO.setTopicTotal(topicTotal.get()); resultDTO.setTopicTotal(topicTotal.get());
resultDTO.setDiscussingTotal(topicTotal.get() - closedTotal.get() - hiddenTotal.get() - shiftIssueTotal.get()); resultDTO.setDiscussingTotal(hotdiscussTotal.get());
resultDTO.setDiscussingRatio(resultDTO.getDiscussingTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getDiscussingTotal() / (float) resultDTO.getTopicTotal()))); resultDTO.setDiscussingRatio(resultDTO.getDiscussingTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getDiscussingTotal() / (float) resultDTO.getTopicTotal())));
resultDTO.setClosedTopicTotal(closedTotal.get()); resultDTO.setClosedTopicTotal(closedTotal.get());
resultDTO.setClosedTopicRatio(resultDTO.getClosedTopicTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedTopicTotal() / (float) resultDTO.getTopicTotal()))); resultDTO.setClosedTopicRatio(resultDTO.getClosedTopicTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedTopicTotal() / (float) resultDTO.getTopicTotal())));
@ -504,12 +511,14 @@ public class DataStatsServiceImpl implements DataStatsService {
List<SubGridFormDTO.Topic> topic = dataStatsDao.getSubGridTopic(gridIds, formDTO.getDateId()); List<SubGridFormDTO.Topic> topic = dataStatsDao.getSubGridTopic(gridIds, formDTO.getDateId());
//查询网格层级转议题话题-日统计数据表 //查询网格层级转议题话题-日统计数据表
List<SubGridFormDTO.Topic> topicShiftIssue = dataStatsDao.getSubGridTopicShiftIssue(gridIds, formDTO.getDateId()); List<SubGridFormDTO.Topic> topicShiftIssue = dataStatsDao.getSubGridTopicShiftIssue(gridIds, formDTO.getDateId());
//查询网格层级热议中话题-日统计数据
List<SubGridFormDTO.Topic> hotdiscuss = dataStatsDao.getSubGridTopicHotDiscuss(gridIds, formDTO.getDateId());
gridIds.forEach(gridId -> { gridIds.forEach(gridId -> {
SubGridTopicResultDTO resultDTO = new SubGridTopicResultDTO(); SubGridTopicResultDTO resultDTO = new SubGridTopicResultDTO();
AtomicInteger topicTotal = new AtomicInteger(0); AtomicInteger topicTotal = new AtomicInteger(0);
AtomicInteger closedTotal = new AtomicInteger(0); AtomicInteger closedTotal = new AtomicInteger(0);
AtomicInteger hiddenTotal = new AtomicInteger(0);
AtomicInteger shiftIssueTotal = new AtomicInteger(0); AtomicInteger shiftIssueTotal = new AtomicInteger(0);
AtomicInteger hotdiscussTotal = new AtomicInteger(0);
AtomicReference<String> gridName = new AtomicReference<>(""); AtomicReference<String> gridName = new AtomicReference<>("");
topic.forEach(t -> { topic.forEach(t -> {
if (t.getGridId().equals(gridId)) { if (t.getGridId().equals(gridId)) {
@ -517,9 +526,6 @@ public class DataStatsServiceImpl implements DataStatsService {
if (t.getTopicStatus().equals("closed")) { if (t.getTopicStatus().equals("closed")) {
closedTotal.set(t.getTopicCount()); closedTotal.set(t.getTopicCount());
} }
if (t.getTopicStatus().equals("hidden")) {
hiddenTotal.set(t.getTopicCount());
}
} }
}); });
topicShiftIssue.forEach(t -> { topicShiftIssue.forEach(t -> {
@ -527,6 +533,11 @@ public class DataStatsServiceImpl implements DataStatsService {
shiftIssueTotal.addAndGet(t.getShiftedIssueTotal()); shiftIssueTotal.addAndGet(t.getShiftedIssueTotal());
} }
}); });
hotdiscuss.forEach(t -> {
if (t.getGridId().equals(gridId)) {
hotdiscussTotal.addAndGet(t.getTopicCount());
}
});
gridList.forEach(sub -> { gridList.forEach(sub -> {
if (gridId.equals(sub.getId())) { if (gridId.equals(sub.getId())) {
gridName.set(sub.getGridName()); gridName.set(sub.getGridName());
@ -536,7 +547,7 @@ public class DataStatsServiceImpl implements DataStatsService {
resultDTO.setGridId(gridId); resultDTO.setGridId(gridId);
resultDTO.setGridName(gridName.get()); resultDTO.setGridName(gridName.get());
resultDTO.setTopicTotal(topicTotal.get()); resultDTO.setTopicTotal(topicTotal.get());
resultDTO.setDiscussingTotal(topicTotal.get() - closedTotal.get() - hiddenTotal.get() - shiftIssueTotal.get()); resultDTO.setDiscussingTotal(hotdiscussTotal.get());
resultDTO.setDiscussingRatio(resultDTO.getDiscussingTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getDiscussingTotal() / (float) resultDTO.getTopicTotal()))); resultDTO.setDiscussingRatio(resultDTO.getDiscussingTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getDiscussingTotal() / (float) resultDTO.getTopicTotal())));
resultDTO.setClosedTopicTotal(closedTotal.get()); resultDTO.setClosedTopicTotal(closedTotal.get());
resultDTO.setClosedTopicRatio(resultDTO.getClosedTopicTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedTopicTotal() / (float) resultDTO.getTopicTotal()))); resultDTO.setClosedTopicRatio(resultDTO.getClosedTopicTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedTopicTotal() / (float) resultDTO.getTopicTotal())));

43
epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/datastats/DatsStatsDao.xml

@ -58,6 +58,19 @@
LIMIT 1 LIMIT 1
</select> </select>
<select id="getAgencyTopicHotDiscuss" resultType="com.epmet.dataaggre.dto.datastats.result.AgencyBasicDataResultDTO$Topic">
SELECT
IFNULL(topic_total, 0) AS topicTotal,
IFNULL(topic_count, 0) AS topicCount
FROM
fact_topic_hotdiscuss_agency_daily
WHERE
del_flag = '0'
AND agency_id = #{agencyId}
AND date_id = #{dateId}
LIMIT 1
</select>
<select id="getAgencyIssue" resultType="com.epmet.dataaggre.dto.datastats.result.AgencyBasicDataResultDTO"> <select id="getAgencyIssue" resultType="com.epmet.dataaggre.dto.datastats.result.AgencyBasicDataResultDTO">
SELECT SELECT
issue_total AS issueTotal, issue_total AS issueTotal,
@ -210,6 +223,21 @@
</foreach> </foreach>
</select> </select>
<select id="getSubAgencyTopicHotDiscuss" resultType="com.epmet.dataaggre.dto.datastats.form.SubAgencyFormDTO$Topic">
SELECT
agency_id AS agencyId,
topic_total AS topicTotal,
topic_count AS topicCount
FROM
fact_topic_hotdiscuss_agency_daily
WHERE
del_flag = '0'
AND date_id = #{dateId}
<foreach item="agencyId" collection="agencyIds" open="AND (" separator="or" close=")" index="">
agency_id = #{agencyId}
</foreach>
</select>
<select id="getSubGridTopic" resultType="com.epmet.dataaggre.dto.datastats.form.SubGridFormDTO$Topic"> <select id="getSubGridTopic" resultType="com.epmet.dataaggre.dto.datastats.form.SubGridFormDTO$Topic">
SELECT SELECT
grid_id AS gridId, grid_id AS gridId,
@ -240,6 +268,21 @@
</foreach> </foreach>
</select> </select>
<select id="getSubGridTopicHotDiscuss" resultType="com.epmet.dataaggre.dto.datastats.form.SubGridFormDTO$Topic">
SELECT
grid_id AS gridId,
topic_total AS topicTotal,
topic_count AS topicCount
FROM
fact_topic_hotdiscuss_grid_daily
WHERE
del_flag = '0'
AND date_id = #{dateId}
<foreach item="gridId" collection="gridIds" open="AND (" separator="or" close=")" index="">
grid_id = #{gridId}
</foreach>
</select>
<select id="getSubAgencyIssue" resultType="com.epmet.dataaggre.dto.datastats.result.SubAgencyIssueResultDTO"> <select id="getSubAgencyIssue" resultType="com.epmet.dataaggre.dto.datastats.result.SubAgencyIssueResultDTO">
SELECT SELECT
agency_id AS agencyId, agency_id AS agencyId,

Loading…
Cancel
Save