Bladeren bron

资源库统计bug处理

pans 6 maanden geleden
bovenliggende
commit
6059f6f80b

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

@@ -148,7 +148,44 @@ public class ResourceStatisticController {
     }
 
 
+    /**
+     * 各资源平均观看人数
+     *
+     * @author pans
+     * @date  2025/08/27 14:10
+     */
+    @ApiOperationSupport(order = 1)
+    @ApiOperation("各资源平均观看人数")
+    @GetMapping("/selectResourceCans")
+    public CommonResult<List<Map<String, Object>>> selectResourceCans(String collegeId,String type) {
+        return CommonResult.data(resourceStatisticService.selectResourceCans(collegeId,type));
+    }
+
+    /**
+     * 资源使用情况统计
+     *
+     * @author pans
+     * @date  2025/08/27 14:10
+     */
+    @ApiOperationSupport(order = 1)
+    @ApiOperation("资源使用情况统计")
+    @GetMapping("/selectResourceUse")
+    public CommonResult<List<Map<String, Object>>> selectResourceUse(String collegeId,String type) {
+        return CommonResult.data(resourceStatisticService.selectResourceUse(collegeId,type));
+    }
 
 
+    /**
+     * 资源上传和访问趋势
+     *
+     * @author pans
+     * @date  2025/08/27 14:10
+     */
+    @ApiOperationSupport(order = 1)
+    @ApiOperation("资源上传和访问趋势")
+    @GetMapping("/selectResourceUpload")
+    public CommonResult<List<Map<String, Object>>> selectResourceUpload(String collegeId,String type) {
+        return CommonResult.data(resourceStatisticService.selectResourceUpload(collegeId,type));
+    }
 
 }

+ 5 - 0
snowy-plugin/snowy-plugin-disk/snowy-plugin-disk-func/src/main/java/vip/xiaonuo/disk/domain/CourseStudentBurialpoint.java

@@ -113,4 +113,9 @@ public class CourseStudentBurialpoint {
 
 
     private String chapterId;
+
+    /** 资源文件id */
+    private String userFileId;
+
+    private String resourceRecord;
 }

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

@@ -33,4 +33,14 @@ public interface ResourceStatisticMapper extends BaseMapper<Map<String, Object>>
     List<Map<String, Object>> storageStatistic(@Param("collegeId") String collegeId, @Param("map") Map<String, Object> map);
 
     List<Map<String, Object>> selectOrgList();
+
+    List<Map<String, Object>> selectResourceCans(@Param("collegeId") String collegeId, @Param("map") Map<String, Object> map);
+
+    Integer selectResourceSee(@Param("collegeId") String collegeId, @Param("map") Map<String, Object> map);
+
+    Integer selectResourceCollect(@Param("collegeId") String collegeId, @Param("map") Map<String, Object> map);
+
+    Integer selectResourceShare(@Param("collegeId") String collegeId, @Param("map") Map<String, Object> map);
+
+    Map<String, Object> selectResourceUpload(@Param("collegeId") String collegeId, @Param("map") Map<String, Object> map);
 }

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

@@ -64,6 +64,7 @@
             <if test="map.endTime != null">
                 AND rr.create_time &lt;= #{map.endTime}
             </if>
+           and  rr.DELETE_FLAG = 'NOT_DELETE'
         </where>
         GROUP BY
             rr.RESOURCE_TYPE,rt.name
@@ -86,6 +87,7 @@
             <if test="map.endTime != null">
                 AND rr.create_time &lt;= #{map.endTime}
             </if>
+            and  rr.DELETE_FLAG = 'NOT_DELETE'
         </where>
         GROUP BY
             rr.COLLEGE_ID,so.name
@@ -107,6 +109,7 @@
             <if test="map.endTime != null">
                 AND rr.create_time &lt;= #{map.endTime}
             </if>
+            and  rr.DELETE_FLAG = 'NOT_DELETE'
         </where>
         GROUP BY rr.VERIFY_STATUS
     </select>
@@ -129,13 +132,14 @@
             <if test="map.endTime != null">
                 AND create_time &lt;= #{map.endTime}
             </if>
+            and  rr.DELETE_FLAG = 'NOT_DELETE'
         </where>
     </select>
 
     <select id="formatStatistic" resultType="map">
         SELECT
             b.EXTEND_NAME extendName,
-            count(a.id) num
+            count(distinct a.id) num
         FROM
             RESOURCE_RECORD a
         LEFT JOIN RESOURCE_USERFILE b ON  a.USERFILE_ID = b.USER_FILE_ID
@@ -150,6 +154,7 @@
             <if test="map.endTime != null">
                 AND a.create_time &lt;= #{map.endTime}
             </if>
+            and  a.DELETE_FLAG = 'NOT_DELETE'
         </where>
         GROUP BY b.EXTEND_NAME
     </select>
@@ -157,7 +162,7 @@
     <select id="storageStatistic" resultType="map">
         SELECT
             b.EXTEND_NAME extendName,
-            count(a.id) num,
+            count(distinct a.id) num,
             sum(c.FILE_SIZE) fileSize,
             avg(c.FILE_SIZE) avgSize
         FROM
@@ -175,6 +180,7 @@
             <if test="map.endTime != null">
                 AND a.create_time &lt;= #{map.endTime}
             </if>
+            and  a.DELETE_FLAG = 'NOT_DELETE'
         </where>
         GROUP BY
             b.EXTEND_NAME
@@ -183,4 +189,111 @@
     <select id="selectOrgList" resultType="map">
         SELECT id,name FROM sys_org WHERE "CATEGORY" !='student' AND PARENT_ID =0
     </select>
+
+    <select id="selectResourceCans" resultType="map">
+        SELECT
+            a.RESOURCE_TYPE resourceType,
+            rt.NAME resourceName,
+            count(distinct b."user_id") num
+        FROM
+            RESOURCE_RECORD a
+        LEFT JOIN RESOURCE_FOOTPRINT b ON a.id = b.RESOURCE_RECORD_ID
+        LEFT JOIN "resource_type" rt  ON a.RESOURCE_TYPE =rt.id
+        <where>
+            <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>
+            and  a.DELETE_FLAG = 'NOT_DELETE'
+        </where>
+        GROUP BY a.RESOURCE_TYPE,rt.NAME
+    </select>
+
+    <select id="selectResourceSee" resultType="integer">
+        SELECT
+            count(distinct b."user_id") num
+        FROM
+            RESOURCE_RECORD a
+        LEFT JOIN RESOURCE_FOOTPRINT b ON a.id = b.RESOURCE_RECORD_ID
+        <where>
+            <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>
+            and  a.DELETE_FLAG = 'NOT_DELETE'
+        </where>
+    </select>
+
+    <select id="selectResourceCollect" resultType="integer">
+        SELECT
+            count(distinct b."user_id")
+        FROM
+            RESOURCE_RECORD a
+        LEFT JOIN resource_collect b ON a.id = b.resource_id
+        <where>
+            <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>
+            and  a.DELETE_FLAG = 'NOT_DELETE'
+        </where>
+    </select>
+
+    <select id="selectResourceShare" resultType="integer">
+        SELECT
+            count(distinct b."user_id")
+        FROM
+            RESOURCE_RECORD a
+        LEFT JOIN COURSE_STUDENT_BURIALPOINT b ON a.id = b.resource_record
+        <where>
+            <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>
+            and  a.DELETE_FLAG = 'NOT_DELETE' AND  b.FUNC_TYPE='3' AND b.TYPE='5'
+        </where>
+    </select>
+    <select id="selectResourceUpload" resultType="map">
+
+        SELECT
+            count(distinct a.id) uploadNum,
+            count(distinct b."user_id") seeNum
+        FROM
+            RESOURCE_RECORD a
+        LEFT JOIN RESOURCE_FOOTPRINT b ON a.id = b.RESOURCE_RECORD_ID
+        <where>
+            <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>
+            and  a.DELETE_FLAG = 'NOT_DELETE'
+        </where>
+    </select>
+
+
 </mapper>

+ 4 - 2
snowy-plugin/snowy-plugin-disk/snowy-plugin-disk-func/src/main/java/vip/xiaonuo/disk/param/coursestudentprogress/CourseStudentProgressAddParam.java

@@ -75,7 +75,6 @@ public class CourseStudentProgressAddParam {
 
     /** 课时id */
     @ApiModelProperty(value = "课时id", position = 3)
-    @NotBlank(message = "课时id不能为空")
     private String hourId;
 
     /** 课时名称 */
@@ -90,5 +89,8 @@ public class CourseStudentProgressAddParam {
     /** 文件id */
     private String fileId;
 
-
+    /** 资源文件id */
+    private String userFileId;
+    /** 资源记录id */
+    private String resourceRecord;
 }

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

@@ -30,4 +30,10 @@ public interface ResourceStatisticService extends IService<Map<String, Object>>
     List<Map<String, Object>> storageStatistic(String collegeId, String type);
 
     List<Map<String, Object>> selectOrgList();
+
+    List<Map<String, Object>> selectResourceCans(String collegeId, String type);
+
+    List<Map<String, Object>> selectResourceUse(String collegeId, String type);
+
+    List<Map<String, Object>> selectResourceUpload(String collegeId, String type);
 }

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

@@ -136,6 +136,48 @@ public class ResourceStatisticServiceImpl extends ServiceImpl<ResourceStatisticM
         return resourceStatisticMapper.selectOrgList();
     }
 
+    @Override
+    public List<Map<String, Object>> selectResourceCans(String collegeId, String type) {
+        Map<String, Object> map = getTime(type);
+        return resourceStatisticMapper.selectResourceCans(collegeId,map);
+    }
+
+    @Override
+    public List<Map<String, Object>> selectResourceUse(String collegeId, String type) {
+        List<Map<String, Object>> list = new ArrayList<>(3);
+        Map<String, Object> map = getTime(type);
+        //资源观看
+        Integer seeNum=resourceStatisticMapper.selectResourceSee(collegeId,map);
+        Map<String,Object> newMap=new HashMap<>(2);
+        newMap.put("type",1);
+        newMap.put("num",seeNum);
+        list.add(newMap);
+        //资源收藏
+        Integer collectNum=resourceStatisticMapper.selectResourceCollect(collegeId,map);
+        newMap=new HashMap<>(2);
+        newMap.put("type",2);
+        newMap.put("num",collectNum);
+        list.add(newMap);
+        //资源分享
+        Integer shareNum=resourceStatisticMapper.selectResourceShare(collegeId,map);
+        newMap=new HashMap<>(2);
+        newMap.put("type",3);
+        newMap.put("num",shareNum);
+        list.add(newMap);
+        return list;
+    }
+
+    @Override
+    public List<Map<String, Object>> selectResourceUpload(String collegeId, String type) {
+        Map<String, Object> map = getTime(type);
+        Map<String,Object>  rs=resourceStatisticMapper.selectResourceUpload(collegeId,map);
+        List<Map<String, Object>> newList = new ArrayList<>();
+        newList.add(createStatisticMap(1, MapUtils.getInteger(rs, "uploadNum", 0)));
+        newList.add(createStatisticMap(2, MapUtils.getInteger(rs, "seeNum", 0)));
+        return newList;
+    }
+
+
     /**
      * 创建统计信息Map
      * @param type 类型 1:推荐 2:热门 3:热门且推荐