浏览代码

Merge branch 'dev' of http://192.168.1.245:11111/jinjilong/onlineEducation-fwd into dev

honorfire 6 月之前
父节点
当前提交
b96cf7a382

+ 39 - 0
snowy-plugin/snowy-plugin-disk/snowy-plugin-disk-func/src/main/java/vip/xiaonuo/disk/controller/ResourceStatisticController.java

@@ -90,8 +90,47 @@ public class ResourceStatisticController {
 
 
 
+    /**
+     * 资源热门、推荐统计
+     *
+     * @author pans
+     * @date  2025/08/27 14:10
+     */
+    @ApiOperationSupport(order = 1)
+    @ApiOperation("资源公开分布")
+    @GetMapping("/hotStatistic")
+    public CommonResult<List<Map<String, Object>>> hotStatistic(String collegeId,String type) {
+        return CommonResult.data(resourceStatisticService.hotStatistic(collegeId,type));
+    }
+
 
 
+    /**
+     * 不同格式的文件数量
+     *
+     * @author pans
+     * @date  2025/08/27 14:10
+     */
+    @ApiOperationSupport(order = 1)
+    @ApiOperation("不同格式的文件数量")
+    @GetMapping("/formatStatistic")
+    public CommonResult<List<Map<String, Object>>> formatStatistic(String collegeId,String type) {
+        return CommonResult.data(resourceStatisticService.formatStatistic(collegeId,type));
+    }
+
+
+    /**
+     * 不同格式的文件数量
+     *
+     * @author pans
+     * @date  2025/08/27 14:10
+     */
+    @ApiOperationSupport(order = 1)
+    @ApiOperation("不同文件格式存储空间占用")
+    @GetMapping("/storageStatistic")
+    public CommonResult<List<Map<String, Object>>> storageStatistic(String collegeId,String type) {
+        return CommonResult.data(resourceStatisticService.storageStatistic(collegeId,type));
+    }
 
 
 

+ 6 - 0
snowy-plugin/snowy-plugin-disk/snowy-plugin-disk-func/src/main/java/vip/xiaonuo/disk/mapper/ResourceStatisticMapper.java

@@ -25,4 +25,10 @@ public interface ResourceStatisticMapper extends BaseMapper<Map<String, Object>>
     List<Map<String, Object>> collegeStatistic(@Param("collegeId") String collegeId,@Param("map") Map<String,Object> map);
 
     List<Map<String, Object>> resourcePublicStatistic(@Param("collegeId") String collegeId, @Param("map") Map<String, Object> map);
+
+    Map<String, Object> hotStatistic(@Param("collegeId") String collegeId,@Param("map") Map<String, Object> map);
+
+    List<Map<String, Object>> formatStatistic(@Param("collegeId") String collegeId ,@Param("map") Map<String, Object> map);
+
+    List<Map<String, Object>> storageStatistic(@Param("collegeId") String collegeId, @Param("map") Map<String, Object> map);
 }

+ 69 - 0
snowy-plugin/snowy-plugin-disk/snowy-plugin-disk-func/src/main/java/vip/xiaonuo/disk/mapper/mapping/ResourceStatisticMapper.xml

@@ -110,4 +110,73 @@
         </where>
         GROUP BY rr.VERIFY_STATUS
     </select>
+
+
+    <select id="hotStatistic" resultType="map">
+        SELECT
+            sum(CASE WHEN IS_RECOMMEND=1 THEN 1 ELSE 0 END) AS  dNum,
+            sum(CASE WHEN IS_HOT=1 THEN 1 ELSE 0 END) AS  hotNum,
+            sum(CASE WHEN IS_HOT=1 AND  IS_RECOMMEND=1 THEN 1 ELSE 0 END) AS  hdNum
+        FROM
+            RESOURCE_RECORD
+        <where>
+            <if test="collegeId != null">
+                AND COLLEGE_ID = #{collegeId}
+            </if>
+            <if test="map.startTime != null">
+                AND create_time &gt;= #{map.startTime}
+            </if>
+            <if test="map.endTime != null">
+                AND create_time &lt;= #{map.endTime}
+            </if>
+        </where>
+    </select>
+
+    <select id="formatStatistic" resultType="map">
+        SELECT
+            b.EXTEND_NAME extendName,
+            count(a.id) num
+        FROM
+            RESOURCE_RECORD a
+        LEFT JOIN RESOURCE_USERFILE b ON  a.USERFILE_ID = b.USER_FILE_ID
+        <where>
+            b.EXTEND_NAME!=''
+            <if test="collegeId != null">
+                AND a.COLLEGE_ID = #{collegeId}
+            </if>
+            <if test="map.startTime != null">
+                AND a.create_time &gt;= #{map.startTime}
+            </if>
+            <if test="map.endTime != null">
+                AND a.create_time &lt;= #{map.endTime}
+            </if>
+        </where>
+        GROUP BY b.EXTEND_NAME
+    </select>
+
+    <select id="storageStatistic" resultType="map">
+        SELECT
+            b.EXTEND_NAME extendName,
+            count(a.id) num,
+            sum(c.FILE_SIZE) fileSize,
+            avg(c.FILE_SIZE) avgSize
+        FROM
+            RESOURCE_RECORD a
+        LEFT JOIN RESOURCE_USERFILE b ON 	a.USERFILE_ID = b.USER_FILE_ID
+        LEFT JOIN RESOURCE_FILE c ON 	b.FILE_ID = c.FILE_ID
+        <where>
+            b.EXTEND_NAME!=''
+            <if test="collegeId != null">
+                AND a.COLLEGE_ID = #{collegeId}
+            </if>
+            <if test="map.startTime != null">
+                AND a.create_time &gt;= #{map.startTime}
+            </if>
+            <if test="map.endTime != null">
+                AND a.create_time &lt;= #{map.endTime}
+            </if>
+        </where>
+        GROUP BY
+            b.EXTEND_NAME
+    </select>
 </mapper>

+ 6 - 0
snowy-plugin/snowy-plugin-disk/snowy-plugin-disk-func/src/main/java/vip/xiaonuo/disk/service/ResourceStatisticService.java

@@ -22,4 +22,10 @@ public interface ResourceStatisticService extends IService<Map<String, Object>>
     List<Map<String, Object>> collegeStatistic(String collegeId,String type);
 
     List<Map<String, Object>> resourcePublicStatistic(String collegeId, String type);
+
+    List<Map<String, Object>> hotStatistic(String collegeId, String type);
+
+    List<Map<String, Object>> formatStatistic(String collegeId, String type);
+
+    List<Map<String, Object>> storageStatistic(String collegeId, String type);
 }

+ 45 - 0
snowy-plugin/snowy-plugin-disk/snowy-plugin-disk-func/src/main/java/vip/xiaonuo/disk/service/impl/ResourceStatisticServiceImpl.java

@@ -3,6 +3,7 @@ package vip.xiaonuo.disk.service.impl;
 import cn.hutool.core.date.DateUtil;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.MapUtils;
 import org.springframework.stereotype.Service;
 import vip.xiaonuo.auth.core.util.StpLoginUserUtil;
 import vip.xiaonuo.disk.domain.ResourceFootprint;
@@ -98,4 +99,48 @@ public class ResourceStatisticServiceImpl extends ServiceImpl<ResourceStatisticM
         Map<String,Object> map=getTime(type);
         return resourceStatisticMapper.resourcePublicStatistic(collegeId,map);
     }
+
+    @Override
+    public List<Map<String, Object>> hotStatistic(String collegeId, String type) {
+        Map<String, Object> map = getTime(type);
+        Map<String, Object> rs = resourceStatisticMapper.hotStatistic(collegeId, map);
+
+        List<Map<String, Object>> newList = new ArrayList<>();
+
+        // 推荐资源
+        newList.add(createStatisticMap(1, MapUtils.getInteger(rs, "dNum", 0)));
+
+        // 热门资源
+        newList.add(createStatisticMap(2, MapUtils.getInteger(rs, "hotNum", 0)));
+
+        // 既是热门又是推荐的资源
+        newList.add(createStatisticMap(3, MapUtils.getInteger(rs, "hdNum", 0)));
+
+        return newList;
+    }
+
+    @Override
+    public List<Map<String, Object>> formatStatistic(String collegeId, String type) {
+        Map<String, Object> map = getTime(type);
+        return resourceStatisticMapper.formatStatistic(collegeId, map);
+    }
+
+    @Override
+    public List<Map<String, Object>> storageStatistic(String collegeId, String type) {
+        Map<String, Object> map = getTime(type);
+        return resourceStatisticMapper.storageStatistic(collegeId, map);
+    }
+
+    /**
+     * 创建统计信息Map
+     * @param type 类型 1:推荐 2:热门 3:热门且推荐
+     * @param num 数量
+     * @return 统计信息Map
+     */
+    private Map<String, Object> createStatisticMap(int type, int num) {
+        Map<String, Object> map = new HashMap<>(2);
+        map.put("type", type);
+        map.put("num", num);
+        return map;
+    }
 }