feat【资源库】首页统计增加上下架的过滤

This commit is contained in:
刘华中 2025-05-17 09:46:35 +08:00
parent ee97b24e51
commit 10e80dbf49
5 changed files with 40 additions and 20 deletions

View File

@ -23,7 +23,7 @@ public class BigScreenStatisticService {
Date[] days = DateUtil.getDays(0, 6); Date[] days = DateUtil.getDays(0, 6);
Map<String, Long> m = achievementsMapper.getAchievement(days[0], days[1], source) Map<String, Long> m = achievementsMapper.getAchievement(days[0], days[1], source)
.stream().collect(Collectors.toMap(KeyValVo::getK, KeyValVo::getV)); .stream().collect(Collectors.toMap(KeyValVo::getK, KeyValVo::getV));
List<String> dateStr = DateUtil.getDateStrYYYYMMDD(days[0], days[1]); List<String> dateStr = DateUtil.getDateStrMMDD(days[0], days[1]);
Date[] lastDays = DateUtil.getDays(7, 13); Date[] lastDays = DateUtil.getDays(7, 13);
long lastSum = Optional.ofNullable(achievementsMapper.countAchievementBySource(lastDays[0], lastDays[1], source)).orElse(0L); long lastSum = Optional.ofNullable(achievementsMapper.countAchievementBySource(lastDays[0], lastDays[1], source)).orElse(0L);
long sum = Optional.ofNullable(achievementsMapper.countAchievementBySource(null, null, source)).orElse(0L); long sum = Optional.ofNullable(achievementsMapper.countAchievementBySource(null, null, source)).orElse(0L);
@ -58,10 +58,17 @@ public class BigScreenStatisticService {
return achievementsMapper.getAchievementType(); return achievementsMapper.getAchievementType();
} }
public Map<String, List<KeyValueVo>> getAchievementActData() { public List<Map<String,Object>> getAchievementActData() {
List<KeyValueVo> list = achievementsMapper.getAchievementActData(); List<KeyValueVo> list = achievementsMapper.getAchievementActData();
Map<String, List<KeyValueVo>> res = list.stream().collect(Collectors.groupingBy(KeyValueVo::getKey)); Map<String, List<KeyValueVo>> res = list.stream().collect(Collectors.groupingBy(KeyValueVo::getKey));
return res; List<Map<String, Object>> r = new ArrayList<>();
res.forEach( (k, v) -> {
Map<String, Object> map = new HashMap<>();
map.put("key", k);
map.put("value", v);
r.add(map);
});
return r;
} }
public List<Map<String, Object>> getAchievementDomain() { public List<Map<String, Object>> getAchievementDomain() {

View File

@ -337,7 +337,7 @@ public class AchievementsServiceImpl implements IAchievementsService {
@Override @Override
public Map<String, Object> indexTaskStatistic() { public Map<String, Object> indexTaskStatistic() {
Map<String, Object> res = achievementsMapper.indexTaskStatistic(); Map<String, Object> res = achievementsMapper.indexTaskStatistic();
double convertedTaskAmount = taskResourceLibraryMapper.getConvertedTaskAmount(); double convertedTaskAmount = taskResourceLibraryMapper.getConvertedTaskAmount2();
res.put("convertedTaskAmount", convertedTaskAmount); res.put("convertedTaskAmount", convertedTaskAmount);
return res; return res;
} }

View File

@ -108,4 +108,6 @@ public interface TaskResourceLibraryMapper {
int delFavorite(Favorite favorite); int delFavorite(Favorite favorite);
int delWatcher(Watcher watcher); int delWatcher(Watcher watcher);
double getConvertedTaskAmount2();
} }

View File

@ -373,33 +373,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="indexProjectStatistic" resultType="java.util.Map"> <select id="indexProjectStatistic" resultType="java.util.Map">
select COUNT(*) as projectAchievementCount, select COUNT(*) as projectAchievementCount,
IFNULL(SUM(attachment_count), 0) as attachmentCount, IFNULL(SUM(attachment_count), 0) as attachmentCount,
(select count(1) from clickers c inner join achievements a ON a.id = c.click_id where click_type = 'Achievements' and a.source='1') as clickCount, (select count(1) from clickers c inner join achievements a ON a.id = c.click_id where click_type = 'Achievements' and a.source='1' and a.status=1) as clickCount,
(select COUNT(distinct project_id) from project_resource_library) as projectCount (select COUNT(distinct project_id) from project_resource_library) as projectCount
from achievements from achievements
where source = '1' where source = '1' and status='1'
</select> </select>
<select id="indexTaskStatistic" resultType="java.util.Map"> <select id="indexTaskStatistic" resultType="java.util.Map">
select (select count(distinct trl.task_id) from achievements a join task_resource_library trl on a.source_id = trl.id where a.source='2') as taskCount, select (select count(distinct trl.task_id) from achievements a join task_resource_library trl on a.source_id = trl.id where a.source='2' and a.status=1) as taskCount,
(select count(1) from clickers c inner join achievements a ON a.id = c.click_id where click_type = 'Achievements' and a.source='2') as clickCount, (select count(1) from clickers c inner join achievements a ON a.id = c.click_id where click_type = 'Achievements' and a.source='2' and a.status=1) as clickCount,
COUNT(*) as expertAuditCount COUNT(*) as expertAuditCount
from achievements from achievements
where source = '2' where source = '2' and status=1
</select> </select>
<select id="indexCompetitionStatistic" resultType="java.util.Map"> <select id="indexCompetitionStatistic" resultType="java.util.Map">
select COUNT(*) as CompetitionCountAchievementCount, select COUNT(*) as CompetitionCountAchievementCount,
(select COUNT(distinct crl.open_competition_id) from achievements a join competition_resource_library crl (select COUNT(distinct crl.open_competition_id) from achievements a join competition_resource_library crl
on a.source_id = crl.id where source = '3' and a.is_expert_audit = 1) as expertAuditCount, on a.source_id = crl.id where source = '3' and a.is_expert_audit = 1 and a.status='1') as expertAuditCount,
(select count(1) from clickers c inner join achievements a ON a.id = c.click_id where click_type = 'Achievements' and a.source='3') as clickCount, (select count(1) from clickers c inner join achievements a ON a.id = c.click_id where click_type = 'Achievements' and a.source='3' and a.status='1') as clickCount,
(select COUNT(distinct open_competition_id) from competition_resource_library) as CompetitionCount (select COUNT(distinct open_competition_id) from competition_resource_library crl inner join achievements a on a.source_id=crl.id where a.status='1') as CompetitionCount
from achievements from achievements
where source = '3' where source = '3' and status='1'
</select> </select>
<select id="indexSchoolEnterpriseStatistic" resultType="java.lang.Long"> <select id="indexSchoolEnterpriseStatistic" resultType="java.lang.Long">
select COUNT(*) select COUNT(*)
from achievements a from achievements a
where source = #{s} where source = #{s}
and a.status = '1'
<if test="t != null and t != ''"> <if test="t != null and t != ''">
and tags = #{t} and tags = #{t}
</if> </if>
@ -470,7 +471,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select count(*) select count(*)
from achievements from achievements
<where> <where>
<if test="source != null and source != ''">and `source` = #{source}</if> <if test="t != null and t != ''">and `source` = #{t}</if>
<if test="s != null">and create_time &gt;= #{s}</if> <if test="s != null">and create_time &gt;= #{s}</if>
<if test="e != null">and create_time &lt;= #{e}</if> <if test="e != null">and create_time &lt;= #{e}</if>
</where> </where>
@ -485,19 +486,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getAchievementType" resultType="java.util.Map"> <select id="getAchievementType" resultType="java.util.Map">
select achievement_type as 'k', count(*) as 'v' select achievement_type as 'k', count(*) as 'v'
from achievements from achievements where achievement_type is not null
group by achievement_type group by achievement_type
</select> </select>
<select id="getAchievementActData" resultType="com.microservices.dms.achievementLibrary.domain.KeyValueVo"> <select id="getAchievementActData" resultType="com.microservices.dms.achievementLibrary.domain.KeyValueVo">
select * from ( select * from (
select 'w' as `key`, DATE_FORMAT(created_at, '%Y') as name ,COUNT(*) as value from watchers where watchable_type = 'Achievements' group by DATE_FORMAT(created_at, '%Y') select '关注' as `key`, DATE_FORMAT(created_at, '%Y') as name ,COUNT(*) as value from watchers where watchable_type = 'Achievements' group by DATE_FORMAT(created_at, '%Y')
union all union all
select 'c' as `key`, DATE_FORMAT(created_at, '%Y') as name,COUNT(*) as value from clickers where click_type = 'Achievements' group by DATE_FORMAT(created_at, '%Y') select '浏览' as `key`, DATE_FORMAT(created_at, '%Y') as name,COUNT(*) as value from clickers where click_type = 'Achievements' group by DATE_FORMAT(created_at, '%Y')
union all union all
select 'd' as `key`, DATE_FORMAT(created_at, '%Y') as name,COUNT(*) as value from downloads where download_type = 'Achievements' group by DATE_FORMAT(created_at, '%Y') select '下载' as `key`, DATE_FORMAT(created_at, '%Y') as name,COUNT(*) as value from downloads where download_type = 'Achievements' group by DATE_FORMAT(created_at, '%Y')
union all union all
select 'f' as `key`, DATE_FORMAT(created_at, '%Y') as name,COUNT(*) as value from favorites where favorite_type = 'Achievements' group by DATE_FORMAT(created_at, '%Y'))t select '收藏' as `key`, DATE_FORMAT(created_at, '%Y') as name,COUNT(*) as value from favorites where favorite_type = 'Achievements' group by DATE_FORMAT(created_at, '%Y'))t
order by t.name order by t.name
</select> </select>
@ -517,7 +518,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
group by field_3) a group by field_3) a
group by a.domain_value group by a.domain_value
order by sum(a.countResult) desc) f order by sum(a.countResult) desc) f
right join categories c on c.id = f.name right join categories c on c.id = f.name where f.value is not null
</select> </select>

View File

@ -530,6 +530,16 @@
where is_transferred_to_results_library = 1) tmp where is_transferred_to_results_library = 1) tmp
</select> </select>
<select id="getConvertedTaskAmount2" resultType="java.lang.Double">
select IFNULL(SUM(bounty), 0)
from (select distinct t.id, t.bounty
from tasks t
join (select task_id from papers where status = 2) p on t.id = p.task_id
join task_resource_library on t.id = task_resource_library.task_id
join achievements a on a.source_id = task_resource_library.id and a.source='2' and a.status= '1'
where is_transferred_to_results_library = 1) tmp
</select>
<select id="getConvertedTasksCount" resultType="java.lang.Long"> <select id="getConvertedTasksCount" resultType="java.lang.Long">
select count(*) select count(*)
from tasks t from tasks t