首页类型统计

This commit is contained in:
cjw 2024-06-19 10:41:38 +08:00
parent 2cc30e4315
commit 39d2e1e27c
5 changed files with 113 additions and 26 deletions

View File

@ -65,4 +65,11 @@ public class StatisticController extends BaseController {
return R.ok(statisticService.getOssUseRank()); return R.ok(statisticService.getOssUseRank());
} }
/**
* 资源使用排行榜
*/
@GetMapping("/oss/type")
public R<List<StatisticNumVo>> getOssType() {
return R.ok(statisticService.getOssType());
}
} }

View File

@ -1,17 +1,25 @@
package org.dromara.system.mapper; package org.dromara.system.mapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.dromara.system.domain.vo.StatisticNumVo; import org.dromara.system.domain.vo.StatisticNumVo;
import java.util.List; import java.util.List;
@Mapper @Mapper
public interface StatisticMapper { public interface StatisticMapper {
int selectGradeNum(String tenantId); int selectGradeNum(@Param("tenantId") String tenantId);
int selectCalssNum(String tenantId);
int selectTeacherNum(String tenantId);
int selectOssNum(String tenantId);
List<StatisticNumVo> selectOssUse(String tenantId); int selectCalssNum(@Param("tenantId") String tenantId);
int selectTeacherNum(@Param("tenantId") String tenantId);
int selectTextbookNum(@Param("tenantId") String tenantId);
int selectResourceNum(@Param("tenantId") String tenantId);
List<StatisticNumVo> selectOssUse(@Param("tenantId") String tenantId);
List<StatisticNumVo> selectOssType4Textbook(@Param("tenantId") String tenantId);
} }

View File

@ -14,4 +14,6 @@ public interface IStatisticService {
int getOssNum(); int getOssNum();
List<StatisticNumVo> getOssUseRank(); List<StatisticNumVo> getOssUseRank();
List<StatisticNumVo> getOssType();
} }

View File

@ -23,31 +23,53 @@ public class StatisticServiceImpl implements IStatisticService {
@Override @Override
public int getGradeNum() { public int getGradeNum() {
String tenantId = TenantHelper.getTenantId(); String tenantId = getTenantId();
return statisticMapper.selectGradeNum(tenantId); return statisticMapper.selectGradeNum(tenantId);
} }
@Override @Override
public int getCalssNum() { public int getCalssNum() {
String tenantId = TenantHelper.getTenantId(); String tenantId = getTenantId();
return statisticMapper.selectCalssNum(tenantId); return statisticMapper.selectCalssNum(tenantId);
} }
@Override @Override
public int getTeacherNum() { public int getTeacherNum() {
String tenantId = TenantHelper.getTenantId(); String tenantId = getTenantId();
return statisticMapper.selectTeacherNum(tenantId); return statisticMapper.selectTeacherNum(tenantId);
} }
@Override @Override
public int getOssNum() { public int getOssNum() {
String tenantId = TenantHelper.getTenantId(); String tenantId = getTenantId();
return statisticMapper.selectOssNum(tenantId); int textbookNum = statisticMapper.selectTextbookNum(tenantId);
int resourceNum = statisticMapper.selectResourceNum(tenantId);
return textbookNum + resourceNum;
} }
@Override @Override
public List<StatisticNumVo> getOssUseRank() { public List<StatisticNumVo> getOssUseRank() {
String tenantId = TenantHelper.getTenantId(); String tenantId = getTenantId();
return statisticMapper.selectOssUse(tenantId); return statisticMapper.selectOssUse(tenantId);
} }
@Override
public List<StatisticNumVo> getOssType() {
String tenantId = getTenantId();
List<StatisticNumVo> statisticNumVos = statisticMapper.selectOssType4Textbook(tenantId);
int resourceNum = statisticMapper.selectResourceNum(tenantId);
StatisticNumVo resource = new StatisticNumVo();
resource.setName("专题资源");
resource.setValue(resourceNum);
statisticNumVos.add(resource);
return statisticNumVos;
}
private String getTenantId() {
String tenantId = TenantHelper.getTenantId();
if ("000000".equals(tenantId)) {
tenantId = null;
}
return tenantId;
}
} }

View File

@ -6,28 +6,50 @@
<select id="selectGradeNum" resultType="int"> <select id="selectGradeNum" resultType="int">
select count(*) select count(*)
from sys_dept from sys_dept
where tenant_id = #{tenantId} where parent_id = 100
and parent_id = 100 <if test="tenantId != null and tenantId != ''">
and tenant_id = #{tenantId}
</if>
</select> </select>
<select id="selectCalssNum" resultType="int"> <select id="selectCalssNum" resultType="int">
select count(*) select count(*)
from sys_dept d from sys_dept d
left join sys_dept p on d.parent_id = p.dept_id left join sys_dept p on d.parent_id = p.dept_id
where d.tenant_id = #{tenantId} where p.parent_id = 100
and p.parent_id = 100 <if test="tenantId != null and tenantId != ''">
and d.tenant_id = #{tenantId}
</if>
</select> </select>
<select id="selectTeacherNum" resultType="int"> <select id="selectTeacherNum" resultType="int">
select count(*) select count(*)
from sys_teacher from sys_teacher
where tenant_id = #{tenantId} <where>
<if test="tenantId != null and tenantId != ''">
and tenant_id = #{tenantId}
</if>
</where>
</select> </select>
<select id="selectOssNum" resultType="int"> <select id="selectTextbookNum" resultType="int">
select t.tNum + r.rNum select count(*)
from (select count(*) as tNum from sys_oss_textbook where tenant_id = #{tenantId}) as t, from sys_oss_textbook
(select count(*) as rNum from sys_oss_resource where tenant_id = #{tenantId}) as r <where>
<if test="tenantId != null and tenantId != ''">
and tenant_id = #{tenantId}
</if>
</where>
</select>
<select id="selectResourceNum" resultType="int">
select count(*) as rNum
from sys_oss_resource
<where>
<if test="tenantId != null and tenantId != ''">
and tenant_id = #{tenantId}
</if>
</where>
</select> </select>
<select id="selectOssUse" resultType="org.dromara.system.domain.vo.StatisticNumVo"> <select id="selectOssUse" resultType="org.dromara.system.domain.vo.StatisticNumVo">
@ -35,13 +57,39 @@
from (select download_num as value, from (select download_num as value,
CONCAT(file_path, '/', file_name) as name CONCAT(file_path, '/', file_name) as name
from sys_oss_resource from sys_oss_resource
where tenant_id = #{tenantId} <where>
union all <if test="tenantId != null and tenantId != ''">
select download_num as value, and tenant_id = #{tenantId}
CONCAT(file_path, '/', file_name) as name </if>
from sys_oss_textbook </where>
where tenant_id = #{tenantId}) t union all
select download_num as value,
CONCAT(file_path, '/', file_name) as name
from sys_oss_textbook
<where>
<if test="tenantId != null and tenantId != ''">
and tenant_id = #{tenantId}
</if>
</where>
) t
order by t.value desc order by t.value desc
limit 10 limit 10
</select> </select>
<select id="selectOssType4Textbook" resultType="org.dromara.system.domain.vo.StatisticNumVo">
select count(*) as `value`,
case type
when 1 then '课件'
when 2 then '精品课堂'
when 3 then '作业'
when 4 then '试卷'
end as `name`
from sys_oss_textbook
<where>
<if test="tenantId != null and tenantId != ''">
and tenant_id = #{tenantId}
</if>
</where>
group by type
</select>
</mapper> </mapper>