首页类型统计

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());
}
/**
* 资源使用排行榜
*/
@GetMapping("/oss/type")
public R<List<StatisticNumVo>> getOssType() {
return R.ok(statisticService.getOssType());
}
}

View File

@ -1,17 +1,25 @@
package org.dromara.system.mapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.dromara.system.domain.vo.StatisticNumVo;
import java.util.List;
@Mapper
public interface StatisticMapper {
int selectGradeNum(String tenantId);
int selectCalssNum(String tenantId);
int selectTeacherNum(String tenantId);
int selectOssNum(String tenantId);
int selectGradeNum(@Param("tenantId") 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();
List<StatisticNumVo> getOssUseRank();
List<StatisticNumVo> getOssType();
}

View File

@ -23,31 +23,53 @@ public class StatisticServiceImpl implements IStatisticService {
@Override
public int getGradeNum() {
String tenantId = TenantHelper.getTenantId();
String tenantId = getTenantId();
return statisticMapper.selectGradeNum(tenantId);
}
@Override
public int getCalssNum() {
String tenantId = TenantHelper.getTenantId();
String tenantId = getTenantId();
return statisticMapper.selectCalssNum(tenantId);
}
@Override
public int getTeacherNum() {
String tenantId = TenantHelper.getTenantId();
String tenantId = getTenantId();
return statisticMapper.selectTeacherNum(tenantId);
}
@Override
public int getOssNum() {
String tenantId = TenantHelper.getTenantId();
return statisticMapper.selectOssNum(tenantId);
String tenantId = getTenantId();
int textbookNum = statisticMapper.selectTextbookNum(tenantId);
int resourceNum = statisticMapper.selectResourceNum(tenantId);
return textbookNum + resourceNum;
}
@Override
public List<StatisticNumVo> getOssUseRank() {
String tenantId = TenantHelper.getTenantId();
String tenantId = getTenantId();
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 count(*)
from sys_dept
where tenant_id = #{tenantId}
and parent_id = 100
where parent_id = 100
<if test="tenantId != null and tenantId != ''">
and tenant_id = #{tenantId}
</if>
</select>
<select id="selectCalssNum" resultType="int">
select count(*)
from sys_dept d
left join sys_dept p on d.parent_id = p.dept_id
where d.tenant_id = #{tenantId}
and p.parent_id = 100
where p.parent_id = 100
<if test="tenantId != null and tenantId != ''">
and d.tenant_id = #{tenantId}
</if>
</select>
<select id="selectTeacherNum" resultType="int">
select count(*)
from sys_teacher
where tenant_id = #{tenantId}
<where>
<if test="tenantId != null and tenantId != ''">
and tenant_id = #{tenantId}
</if>
</where>
</select>
<select id="selectOssNum" resultType="int">
select t.tNum + r.rNum
from (select count(*) as tNum from sys_oss_textbook where tenant_id = #{tenantId}) as t,
(select count(*) as rNum from sys_oss_resource where tenant_id = #{tenantId}) as r
<select id="selectTextbookNum" resultType="int">
select count(*)
from sys_oss_textbook
<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 id="selectOssUse" resultType="org.dromara.system.domain.vo.StatisticNumVo">
@ -35,13 +57,39 @@
from (select download_num as value,
CONCAT(file_path, '/', file_name) as name
from sys_oss_resource
where tenant_id = #{tenantId}
<where>
<if test="tenantId != null and tenantId != ''">
and tenant_id = #{tenantId}
</if>
</where>
union all
select download_num as value,
CONCAT(file_path, '/', file_name) as name
from sys_oss_textbook
where tenant_id = #{tenantId}) t
<where>
<if test="tenantId != null and tenantId != ''">
and tenant_id = #{tenantId}
</if>
</where>
) t
order by t.value desc
limit 10
</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>