Bläddra i källkod

作者:张哲
时间:2023/05/30
类型:需求变更
描述:里程碑(3) 综合统计

zizg 1 år sedan
förälder
incheckning
dd7af468a5

+ 2 - 2
src/main/java/com/redxun/knowledge/analysis/controller/AnalysisCommonController.java

@@ -308,7 +308,7 @@ public class AnalysisCommonController {
                                         @RequestParam("organizationId") String organizationId,
                                         @RequestParam(value = "createTime",required = false) String createTime,
                                         @RequestParam(value = "endTime",required = false) String  endTime) {
-        SynthesizeCompanyVo result = analysisSynthesizeService.organizationVisit(type, organizationId,createTime,endTime,null);
+        SynthesizeCompanyVo result = analysisSynthesizeService.organizationVisit(type, organizationId,createTime,endTime);
         return JsonResult.getSuccessResult(result);
     }
 
@@ -319,7 +319,7 @@ public class AnalysisCommonController {
         if (validResult.hasErrors()) {
             return jsonResult.setMessage("组织Id不能为空");
         }
-        SynthesizeCompanyVo result = analysisSynthesizeService.personVisit(personVisitDto);
+        List<SynthesizeCompanyVo> result = analysisSynthesizeService.personVisit(personVisitDto);
         return jsonResult.setData(result);
     }
 }

+ 12 - 1
src/main/java/com/redxun/knowledge/analysis/mapper/AnalysisSynthesizeMapper.java

@@ -3,6 +3,7 @@ package com.redxun.knowledge.analysis.mapper;
 import com.redxun.knowledge.analysis.entity.dto.PersonVisitDto;
 import com.redxun.knowledge.analysis.entity.vo.AlbumDetailVisitsVo;
 import com.redxun.knowledge.analysis.entity.vo.CreateUserViewLabel;
+import com.redxun.knowledge.analysis.entity.vo.MapCompanyVo;
 import com.redxun.knowledge.analysis.entity.vo.SynthesizeCompanyVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -67,7 +68,7 @@ public interface AnalysisSynthesizeMapper {
      * @param organizationId
      * @return
      */
-    SynthesizeCompanyVo organizationVisit(@Param("firstDay") String firstDay, @Param("lastDay") String lastDay, @Param("organizationId") String organizationId,@Param("personList") List<String> personId);
+    SynthesizeCompanyVo organizationVisit(@Param("firstDay") String firstDay, @Param("lastDay") String lastDay, @Param("organizationId") String organizationId);
 
     /**
      * 用户访问总量(按月查询)
@@ -79,4 +80,14 @@ public interface AnalysisSynthesizeMapper {
      * @return
      */
     List<CreateUserViewLabel> totalUserByMonthVisits(@Param("firstDay") String firstDay, @Param("lastDay") String lastDay, @Param("module") String module, @Param("type") String type);
+
+    /**
+     * 人员创建地图赋值
+     * @param id
+     * @param createTime
+     * @param endTime
+     * @param round
+     * @return
+     */
+    SynthesizeCompanyVo personSynthesizeValue(@Param("id") String id, @Param("firstDay")String createTime, @Param("lastDay")String endTime, @Param("round") Integer round);
 }

+ 63 - 19
src/main/java/com/redxun/knowledge/analysis/service/AnalysisSynthesizeServiceImpl.java

@@ -206,11 +206,7 @@ public class AnalysisSynthesizeServiceImpl {
      * @param organizationId
      * @return
      */
-    public SynthesizeCompanyVo organizationVisit(String type, String organizationId,String createTime,String endTime,List<String> personId) {
-        //存在人员,统计人员
-        if (!CollectionUtils.isEmpty(personId)){
-            organizationId = null;
-        }
+    public SynthesizeCompanyVo organizationVisit(String type, String organizationId,String createTime,String endTime) {
         //开始时间和结束时间都不为空,按照选中时间过滤,忽略type
         if (!StringUtils.isEmpty(createTime) && !StringUtils.isEmpty(endTime)){
             type = null;
@@ -219,20 +215,20 @@ public class AnalysisSynthesizeServiceImpl {
         int year = calendar.get(Calendar.YEAR);
         SynthesizeCompanyVo result;
         if ("total".equals(type)) {
-            result = analysisSynthesizeMapper.organizationVisit(null, null, organizationId,personId);
+            result = analysisSynthesizeMapper.organizationVisit(null, null, organizationId);
         } else if ("year".equals(type)) {
             result = analysisSynthesizeMapper.organizationVisit(DateUtils.format(DateUtils.getFirstOfYear(year)),
-                    DateUtils.format(DateUtils.getLastOfYear(year)), organizationId,personId);
+                    DateUtils.format(DateUtils.getLastOfYear(year)), organizationId);
         } else if ("month".equals(type)) {
             int month = calendar.get(Calendar.MONTH);
             String firstOfMonth = DateUtils.getFirstOfMonth(year, month + 1, 15);
             String lastOfMonth = DateUtils.getLastOfMonth(year, month + 1, 15);
-            result = analysisSynthesizeMapper.organizationVisit(firstOfMonth, lastOfMonth, organizationId,personId);
+            result = analysisSynthesizeMapper.organizationVisit(firstOfMonth, lastOfMonth, organizationId);
         } else {
-            result = analysisSynthesizeMapper.organizationVisit(createTime, endTime, organizationId,personId);
+            result = analysisSynthesizeMapper.organizationVisit(createTime, endTime, organizationId);
         }
         //人员是空,查出来一定是部门信息
-        if (CollectionUtils.isEmpty(personId)){
+
             String deptPath = pvLogMapper.findAllDeptIdByDeptId(organizationId);
             if (StringUtils.isNotEmpty(deptPath)) {
                 deptPath = deptPath.substring(deptPath.indexOf(".") + 1);
@@ -246,10 +242,7 @@ public class AnalysisSynthesizeServiceImpl {
                     result.setOrganization(organization);
                 }
             }
-        } else {
-            String fullName = personId.parallelStream().map(e -> userService.queryOsUserDto(e).getFullName()).collect(Collectors.joining(","));
-            result.setOrganization(fullName);
-        }
+
         return result;
     }
 
@@ -258,10 +251,61 @@ public class AnalysisSynthesizeServiceImpl {
      * @param personVisitDto
      * @return
      */
-    public SynthesizeCompanyVo personVisit(PersonVisitDto personVisitDto) {
-        //如果组织id不为空,人员id为空情况下,显示组织访问量
-        SynthesizeCompanyVo synthesizeCompanyVo  = this.organizationVisit(personVisitDto.getType(), personVisitDto.getOrganizationId(),
-                personVisitDto.getCreateTime(),personVisitDto.getEndTime(),personVisitDto.getPersonId());
-        return synthesizeCompanyVo;
+    public List<SynthesizeCompanyVo> personVisit(PersonVisitDto personVisitDto) {
+        List<SynthesizeCompanyVo> synthesizeCompanyVos = new ArrayList<>();
+        //开始时间和结束时间都不为空,按照选中时间过滤,忽略type
+        if (!StringUtils.isEmpty(personVisitDto.getCreateTime()) && !StringUtils.isEmpty(personVisitDto.getEndTime())){
+            personVisitDto.setType(null);
+        }
+        //查询人员
+        if (!CollectionUtils.isEmpty(personVisitDto.getPersonId())){
+            personVisitDto.setOrganizationId(null);
+            synthesizeCompanyVos = personSynthesizeValue(personVisitDto.getPersonId(),personVisitDto.getType(),personVisitDto.getCreateTime(),personVisitDto.getEndTime(),1);
+        } else {
+            //查询部门
+            String[] split = personVisitDto.getOrganizationId().split(",");
+            List<String> organizationIdList = Arrays.asList(split);
+            synthesizeCompanyVos = personSynthesizeValue(organizationIdList,personVisitDto.getType(),personVisitDto.getCreateTime(),personVisitDto.getEndTime(),2);
+        }
+        return synthesizeCompanyVos;
+    }
+
+
+
+    /**
+     * 综合统计赋值
+     * @param list
+     * @return
+     */
+    private List<SynthesizeCompanyVo> personSynthesizeValue(List<String> list,String type,String createTime,String endTime,Integer round){
+
+        List<SynthesizeCompanyVo> result = list.parallelStream().map(e -> {
+            //获取当前年
+            Calendar calendar = Calendar.getInstance();
+            int year = calendar.get(Calendar.YEAR);
+            SynthesizeCompanyVo synthesizeCompanyVo = new SynthesizeCompanyVo();
+            //查询知识分类下创建的知识数量(纬度:年 最近1个月 全部)
+            if (type.equals("total")) {
+                synthesizeCompanyVo = analysisSynthesizeMapper.personSynthesizeValue(e, null, null,round);
+            } else if (type.equals("year")) {
+                synthesizeCompanyVo = analysisSynthesizeMapper.personSynthesizeValue(e, DateUtils.format(DateUtils.getFirstOfYear(year)),
+                        DateUtils.format(DateUtils.getLastOfYear(year)),round);
+            } else if (type.equals("month")) {
+                int month = calendar.get(Calendar.MONTH);
+                String firstOfMonth = DateUtils.getFirstOfMonth(year, month + 1, 15);
+                String lastOfMonth = DateUtils.getLastOfMonth(year, month + 1, 15);
+                synthesizeCompanyVo = analysisSynthesizeMapper.personSynthesizeValue(e, firstOfMonth, lastOfMonth,round);
+            } else {
+                synthesizeCompanyVo = analysisSynthesizeMapper.personSynthesizeValue(e,createTime, endTime, round);
+            }
+            if (round == 1){
+                synthesizeCompanyVo.setOrganization(userService.queryOsUserDto(e).getFullName());
+            } else {
+                synthesizeCompanyVo.setOrganization(userService.findDeptByDeptId(e).getName());
+            }
+            return synthesizeCompanyVo;
+        }).collect(Collectors.toList());
+        return result;
+
     }
 }

+ 59 - 6
src/main/resources/mapper/knowledge/analysis/AnalysisSynthesizeMapper.xml

@@ -226,12 +226,6 @@
             )
             )
         </if>
-        <if test="personList != null and personList.size > 0">
-            USER_ID IN
-            <foreach collection="personList" item="id" open="(" close=")" separator=",">
-                #{id}
-            </foreach>
-        </if>
         <if test="firstDay != null and lastDay != null">
             and TO_CHAR(CREATE_TIME_, 'yyyy-mm-dd') &gt;= #{firstDay}
             and TO_CHAR(CREATE_TIME_, 'yyyy-mm-dd') &lt;= #{lastDay}
@@ -312,4 +306,63 @@
         ORDER BY day asc) s2 on s1.name = s2.name order by s2.day
     </select>
 
+    <sql id="personSynthesizeValue">
+        <if test="round == 2">
+            COMPANY_ID in (
+            select GROUP_ID_
+            from LEARNING_USER_DEV.OS_GROUP
+            where GROUP_ID_ in (
+            SELECT GROUP_ID_
+            FROM LEARNING_USER_DEV.OS_GROUP c
+            START WITH c.GROUP_ID_ = #{id}
+            CONNECT BY PRIOR c.GROUP_ID_ = c.PARENT_ID_
+            )
+            )
+        </if>
+        <if test="round == 1">
+            USER_ID  = #{id}
+        </if>
+        <if test="firstDay != null and lastDay != null">
+            and TO_CHAR(CREATE_TIME_, 'yyyy-mm-dd') &gt;= #{firstDay}
+            and TO_CHAR(CREATE_TIME_, 'yyyy-mm-dd') &lt;= #{lastDay}
+        </if>
+    </sql>
+    <select id="personSynthesizeValue" resultType="com.redxun.knowledge.analysis.entity.vo.SynthesizeCompanyVo">
+        select
+        NVL(total, 0) as total,NVL(knowledge, 0) as knowledge,NVL(map, 0) as
+        map,
+        NVL(album, 0) as album,NVL(search, 0) as search
+        from
+        (select sum(count(*)) over () total
+        from KM_PV_LOG
+        <where>
+            <include refid="personSynthesizeValue"/> and MODULE != '其他'
+        </where>
+        ) total,
+        (select sum(count(*)) over () knowledge
+        from KM_PV_LOG
+        <where>
+            <include refid="personSynthesizeValue"/> and MODULE = '知识仓库'
+        </where>
+        ) knowledge,
+        (select sum(count(*)) over () map
+        from KM_PV_LOG
+        <where>
+            <include refid="personSynthesizeValue"/> and MODULE = '知识地图'
+        </where>
+        ) map,
+        (select sum(count(*)) over () album
+        from KM_PV_LOG
+        <where>
+            <include refid="personSynthesizeValue"/> and MODULE = '知识专辑'
+        </where>
+        ) album,
+        (select sum(count(*)) over () search
+        from KM_PV_LOG
+        <where>
+            <include refid="personSynthesizeValue"/> and MODULE = '搜索服务'
+        </where>
+        ) search
+    </select>
+
 </mapper>