Răsfoiți Sursa

资源库统计bug处理

pans 6 luni în urmă
părinte
comite
28ab4c3ac5

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

@@ -105,6 +105,34 @@ public class ResourceStatisticController {
 
 
 
 
 
 
+    /**
+     * 不同格式的文件数量
+     *
+     * @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));
+    }
+
+
 
 
 
 
 
 

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

@@ -27,4 +27,8 @@ public interface ResourceStatisticMapper extends BaseMapper<Map<String, Object>>
     List<Map<String, Object>> resourcePublicStatistic(@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);
     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);
 }
 }

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

@@ -131,4 +131,52 @@
             </if>
             </if>
         </where>
         </where>
     </select>
     </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>
 </mapper>

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

@@ -24,4 +24,8 @@ public interface ResourceStatisticService extends IService<Map<String, Object>>
     List<Map<String, Object>> resourcePublicStatistic(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>> hotStatistic(String collegeId, String type);
+
+    List<Map<String, Object>> formatStatistic(String collegeId, String type);
+
+    List<Map<String, Object>> storageStatistic(String collegeId, String type);
 }
 }

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

@@ -118,6 +118,19 @@ public class ResourceStatisticServiceImpl extends ServiceImpl<ResourceStatisticM
 
 
         return newList;
         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
      * 创建统计信息Map
      * @param type 类型 1:推荐 2:热门 3:热门且推荐
      * @param type 类型 1:推荐 2:热门 3:热门且推荐