7 Commits 71107d91ca ... 136d5a143f

Autore SHA1 Messaggio Data
  zizg 136d5a143f 作者:张哲 1 anno fa
  zizg 044f7e2c92 作者:张哲 1 anno fa
  zizg 4a693686a8 作者:张哲 1 anno fa
  zizg f7c87f353d 作者:张哲 1 anno fa
  zizg eba980df93 作者:张哲 1 anno fa
  zizg 95b18cec5d 作者:张哲 1 anno fa
  zizg f0c553f1b9 作者:张哲 1 anno fa

+ 1 - 1
src/main/java/com/redxun/knowledge/album/mapper/AlbumInfoMapper.java

@@ -15,7 +15,7 @@ import java.util.Map;
 @Mapper
 public interface AlbumInfoMapper extends BaseDao<AlbumInfo> {
 
-    IPage findAllAlbumInfo(IPage<AlbumInfo> page, @Param("params") Map<String, Object> params, @Param("w") Map<String, Object> order);
+    List<AlbumInfo> findAllAlbumInfo(@Param("params") Map<String, Object> params, @Param("w") Map<String, Object> order);
 
     /**
      * 版本收入知识量

+ 81 - 59
src/main/java/com/redxun/knowledge/album/service/AlbumApproveServiceImpl.java

@@ -17,6 +17,7 @@ import com.redxun.knowledge.album.entity.enums.AlbumVersionEnum;
 import com.redxun.knowledge.album.entity.vo.AlbumApproveFlowVo;
 import com.redxun.knowledge.album.entity.vo.AlbumApproveListVo;
 import com.redxun.knowledge.album.entity.vo.AlbumApproveVo;
+import com.redxun.knowledge.album.entity.vo.AlbumYelpApproveListVo;
 import com.redxun.knowledge.album.mapper.*;
 import com.redxun.knowledge.common.UserService;
 import com.redxun.knowledge.entity.dao.KnowledgeApprove;
@@ -166,103 +167,124 @@ public class AlbumApproveServiceImpl extends SuperServiceImpl<AlbumApproveMapper
         //根据专辑Id进行数据分组
         Map<String, List<AlbumApprove>> albumApproveMap = albumApproveList.stream().collect(Collectors.groupingBy(AlbumApprove::getAlbumId));
         // 返回结果集
-        List<AlbumApproveListVo> albumApproveListVos = new ArrayList<>();
+        List<AlbumApprove> albumApproveVos = new ArrayList<>();
         // 遍历每组的数据
         Set<Map.Entry<String, List<AlbumApprove>>> entries = albumApproveMap.entrySet();
         for (Map.Entry<String, List<AlbumApprove>> entry : entries) {
             List<AlbumApprove> value = entry.getValue();
             for (int i = 0; i < value.size(); i++) {
-                //给结果集赋值
-                AlbumApproveListVo albumApproveListVo = new AlbumApproveListVo();
-                albumApproveListVo.setPkId(value.get(i).getAlbumInfo().getPkId());
-                albumApproveListVo.setAlbumName(value.get(i).getAlbumInfo().getName());
-                String categoryId = value.get(i).getAlbumInfo().getCategoryId();
-                AlbumCategory albumCategory = albumCategoryMapper.selectById(categoryId);
-                if (albumCategory.getGrade() == 1) {
-                    albumApproveListVo.setCategoryName(albumCategory.getName());
-                } else {
-                    AlbumCategory albumCategoryParent = albumCategoryMapper.
-                            selectOne(new LambdaQueryWrapper<AlbumCategory>().eq(AlbumCategory::getPkId, albumCategory.getParent()));
-                    albumApproveListVo.setCategoryName(albumCategoryParent.getName() + "|" + albumCategory.getName());
-                }
-                albumApproveListVo.setOwnerName(userService.queryOsUserDto(value.get(i).getAlbumInfo().getOwnerId()).getFullName());
-                albumApproveListVo.setCreateTime(value.get(i).getAlbumVersion().getCreateTime());
-                albumApproveListVo.setApprovalStateName(AlbumVersionApproveEnum.getMessage(value.get(i).getAlbumVersion().getApprovalState()));
-                albumApproveListVo.setApproverId(value.get(i).getApproverId());
-                albumApproveListVo.setVersionId(value.get(i).getAlbumVersion().getPkId());
-                albumApproveListVo.setApprovalId(value.get(i).getPkId());
-                albumApproveListVo.setApprovalState(value.get(i).getAlbumVersion().getApprovalState());
-                Integer knowledgeTotal = albumInfoMapper.selectCountKnowledge(value.get(i).getAlbumInfo().getPkId(), value.get(i).getAlbumVersion().getPkId());
-                albumApproveListVo.setKnowledgeTotal(knowledgeTotal);
-                //动作标记
-                String userId = userService.queryLoginUser();
-                String deptId = userService.queryLoginUserDeptId();
-                Integer count = albumApprovalNodeMapper.selectAllByDeptId(deptId, albumApproveListVo.getApproverId());
-                List<String> actionFlag = new ArrayList<>();
-                if ((userId.equals(albumApproveListVo.getApproverId()) || count > 0) &&
-                        (value.get(i).getAlbumVersion().getApprovalState() == 1 || value.get(i).getAlbumVersion().getApprovalState() == 2)) {
-                    actionFlag.add("approve");
-                } else {
-                    actionFlag.add("view");
-                }
-                albumApproveListVo.setActionFlag(actionFlag);
                 // 如果是最终审核通过,直接放入记录
                 if (value.get(i).getAlbumVersion().getApprovalState() == 5 && value.get(i).getIsFinal() == 1) {
-                    albumApproveListVo.setApprovalId(value.get(i).getPkId());
-                    //实际审核人姓名和实际审核人审核时间
-                    albumApproveListVo.setPreviousApproverName(value.get(i).getActualApproverName());
-                    albumApproveListVo.setPreviousApproverTime(value.get(i).getApprovalTime());
-                    albumApproveListVos.add(albumApproveListVo);
+                    albumApproveVos.add(value.get(i));
                     break;
                 }
                 // 判断审批结果是否为null(如果审批结果没有null,证明审批已结束;如果等于0,证明审批没通过)
                 if (value.get(i).getResult() == null || value.get(i).getResult() == 0) {
-                    if (i != 0) {
-                        // 如果不是第一条数据,取前一条数据的实际审核人姓名
-                        String actualApproverName = value.get(i - 1).getActualApproverName();
-                        albumApproveListVo.setPreviousApproverName(actualApproverName);
-                        // 如果不是第一条数据,取前一条数据的审批时间
-                        Date approvalTime = value.get(i - 1).getApprovalTime();
-                        albumApproveListVo.setPreviousApproverTime(approvalTime);
-                    } else {
-                        String actualApproverName = value.get(i).getActualApproverName();
-                        albumApproveListVo.setPreviousApproverName(actualApproverName);
-                        Date approvalTime = value.get(i).getApprovalTime();
-                        albumApproveListVo.setPreviousApproverTime(approvalTime);
-                    }
                     // 把该记录加到结果集中
-                    albumApproveListVos.add(albumApproveListVo);
+                    albumApproveVos.add(value.get(i));
                     break;
                 }
             }
         }
         if ("1".equals(type)){
-            List<AlbumApproveListVo> result = albumApproveListVos.stream().
+            List<AlbumApprove> result = albumApproveVos.stream().
                     sorted((t1, t2) -> t2.getCreateTime().compareTo(t1.getCreateTime())).collect(Collectors.toList());
             Page pageResult = PageListUtils.getPages(queryFilter.getPage().getCurrent(), queryFilter.getPage().getSize(), result);
+            List<AlbumApprove> records = pageResult.getRecords();
+            List<AlbumApproveListVo> collect = records.stream().map(this::pageInfo).collect(Collectors.toList());
+            pageResult.setRecords(collect);
             return pageResult;
         } else {
             //获取当前登录人的userId和deptId
             String userId = userService.queryLoginUser();
             String deptId = userService.queryLoginUserDeptId();
 
-            List<AlbumApproveListVo> albumApproveListVo1 = new ArrayList<>();
+            List<AlbumApprove> albumApproveListVo1 = new ArrayList<>();
             //根据部门Id获取子部门信息
             //过滤数据
-           albumApproveListVos.forEach(albumApproveListVo -> {
+           albumApproveVos.forEach(albumApproveListVo -> {
                Integer count = albumApprovalNodeMapper.selectAllByDeptId(deptId, albumApproveListVo.getApproverId());
                if ((userId.equals(albumApproveListVo.getApproverId()) || count > 0) &&
-                       (albumApproveListVo.getApprovalState() == 1 || albumApproveListVo.getApprovalState() == 2)) {
+                       (albumApproveListVo.getAlbumVersion().getApprovalState() == 1 || albumApproveListVo.getAlbumVersion().getApprovalState() == 2)) {
                     albumApproveListVo1.add(albumApproveListVo);
                 }
             });
-            List<AlbumApproveListVo> result = albumApproveListVo1.stream().
+            List<AlbumApprove> result = albumApproveListVo1.stream().
                     sorted((t1, t2) -> t2.getCreateTime().compareTo(t1.getCreateTime())).collect(Collectors.toList());
             Page pageResult = PageListUtils.getPages(queryFilter.getPage().getCurrent(), queryFilter.getPage().getSize(),result);
+            List<AlbumApprove> records = pageResult.getRecords();
+            List<AlbumApproveListVo> collect = records.stream().map(this::pageInfo).collect(Collectors.toList());
+            pageResult.setRecords(collect);
             return pageResult;
         }
     }
 
+
+    /**
+     * 返回值赋值
+     * @param albumApprove
+     * @return
+     */
+    private AlbumApproveListVo pageInfo(AlbumApprove albumApprove){
+        AlbumApproveListVo albumApproveListVo = new AlbumApproveListVo();
+        albumApproveListVo.setPkId(albumApprove.getAlbumInfo().getPkId());
+        albumApproveListVo.setAlbumName(albumApprove.getAlbumInfo().getName());
+        String categoryId = albumApprove.getAlbumInfo().getCategoryId();
+        AlbumCategory albumCategory = albumCategoryMapper.selectById(categoryId);
+        if (albumCategory.getGrade() == 1) {
+            albumApproveListVo.setCategoryName(albumCategory.getName());
+        } else {
+            AlbumCategory albumCategoryParent = albumCategoryMapper.
+                    selectOne(new LambdaQueryWrapper<AlbumCategory>().eq(AlbumCategory::getPkId, albumCategory.getParent()));
+            albumApproveListVo.setCategoryName(albumCategoryParent.getName() + "|" + albumCategory.getName());
+        }
+        albumApproveListVo.setOwnerName(userService.queryOsUserDto(albumApprove.getAlbumInfo().getOwnerId()).getFullName());
+        albumApproveListVo.setCreateTime(albumApprove.getAlbumVersion().getCreateTime());
+        albumApproveListVo.setApprovalStateName(AlbumVersionApproveEnum.getMessage(albumApprove.getAlbumVersion().getApprovalState()));
+        albumApproveListVo.setApproverId(albumApprove.getApproverId());
+        albumApproveListVo.setVersionId(albumApprove.getAlbumVersion().getPkId());
+        albumApproveListVo.setApprovalId(albumApprove.getPkId());
+        albumApproveListVo.setApprovalState(albumApprove.getAlbumVersion().getApprovalState());
+        Integer knowledgeTotal = albumInfoMapper.selectCountKnowledge(albumApprove.getAlbumInfo().getPkId(), albumApprove.getAlbumVersion().getPkId());
+        albumApproveListVo.setKnowledgeTotal(knowledgeTotal);
+        //动作标记
+        String userId = userService.queryLoginUser();
+        String deptId = userService.queryLoginUserDeptId();
+        Integer count = albumApprovalNodeMapper.selectAllByDeptId(deptId, albumApproveListVo.getApproverId());
+        List<String> actionFlag = new ArrayList<>();
+        if ((userId.equals(albumApproveListVo.getApproverId()) || count > 0) &&
+                (albumApprove.getAlbumVersion().getApprovalState() == 1 || albumApprove.getAlbumVersion().getApprovalState() == 2)) {
+            actionFlag.add("approve");
+        } else {
+            actionFlag.add("view");
+        }
+        albumApproveListVo.setActionFlag(actionFlag);
+        // 如果是最终审核通过(赋值实际审核人和审核时间)
+        if (albumApprove.getAlbumVersion().getApprovalState() == 5 || albumApprove.getAlbumVersion().getApprovalState() == 4
+                || albumApprove.getAlbumVersion().getApprovalState() == 3) {
+            String actualApproverName = albumApprove.getActualApproverName();
+            albumApproveListVo.setPreviousApproverName(actualApproverName);
+            Date approvalTime = albumApprove.getApprovalTime();
+            albumApproveListVo.setPreviousApproverTime(approvalTime);
+        } else {
+            //取前一条记录实际审核人和审核时间
+            QueryWrapper<AlbumApprove> queryWrapper = new QueryWrapper<>();
+            queryWrapper.eq("VERSION_ID",albumApprove.getVersionId());
+            queryWrapper.eq("ALBUM_ID",albumApprove.getAlbumId());
+            queryWrapper.eq("SORT",albumApprove.getSort() - 1);
+            queryWrapper.orderByAsc("SORT");
+            AlbumApprove albumApproveBySort = albumApproveMapper.selectOne(queryWrapper);
+            if (albumApproveBySort != null){
+                String actualApproverName = albumApproveBySort.getActualApproverName();
+                albumApproveListVo.setPreviousApproverName(actualApproverName);
+                Date approvalTime = albumApproveBySort.getApprovalTime();
+                albumApproveListVo.setPreviousApproverTime(approvalTime);
+            }
+        }
+        return albumApproveListVo;
+
+    }
+
     /**
      * 获取当前登陆人待审核的专辑数量
      *

+ 66 - 11
src/main/java/com/redxun/knowledge/album/service/AlbumInfoServiceImpl.java

@@ -21,6 +21,7 @@ import com.redxun.knowledge.album.entity.enums.AlbumInfoEnum;
 import com.redxun.knowledge.album.entity.enums.AlbumVersionEnum;
 import com.redxun.knowledge.album.entity.vo.*;
 import com.redxun.knowledge.album.mapper.*;
+import com.redxun.knowledge.analysis.entity.vo.KnowledgeCompanyVo;
 import com.redxun.knowledge.common.UserService;
 import com.redxun.knowledge.entity.dao.ActionLog;
 import com.redxun.knowledge.entity.dao.Knowledge;
@@ -171,13 +172,11 @@ public class AlbumInfoServiceImpl extends SuperServiceImpl<AlbumInfoMapper, Albu
                         ownerIdsList.addAll(albumInfoList);
                     }
                     List<AlbumInfo> collect = ownerIdsList.stream().distinct().collect(Collectors.toList());
-                    List<AlbumInfoVo> albumInfoVoListResult = pageInfo(collect);
-                    //不是我创建的专辑(状态设置为2 已发布)
-                    albumInfoVoListResult.stream().filter(e -> !e.getOwnerId().equals(userId)).forEach(h -> {
-                        h.setVersionState(2);
-                        h.setVersionStateName(AlbumVersionEnum.getMessage(2));
-                    });
-                    Page page2 = PageListUtils.getPages(queryFilter.getPage().getCurrent(), queryFilter.getPage().getSize(), albumInfoVoListResult);
+                    Page page2 = PageListUtils.getPages(queryFilter.getPage().getCurrent(), queryFilter.getPage().getSize(), collect);
+                    List<AlbumInfo> recordslist = page2.getRecords();
+                    List<AlbumInfoVo> albumInfoVoListResult = pageInfo(recordslist);
+                    albumInfoVoListResult.stream().filter(e -> !e.getOwnerId().equals(userId)).forEach(h -> h.setVersionState(2));
+                    page2.setRecords(albumInfoVoListResult);
                     return page2;
                 case "3":
                     //我点评的专辑(点评状态为审核中和审核通过)
@@ -194,11 +193,31 @@ public class AlbumInfoServiceImpl extends SuperServiceImpl<AlbumInfoMapper, Albu
                     return page3;
             }
         }
-        IPage page = albumInfoMapper.findAllAlbumInfo(queryFilter.getPage(), queryFilter.getParams(), params);
-        List<AlbumInfo> collect = page.getRecords();
+        List<AlbumInfo> collect = albumInfoMapper.findAllAlbumInfo(queryFilter.getParams(), params);
+        //List<AlbumInfo> collect = page.getRecords();
         List<AlbumInfoVo> albumInfoVoList = pageInfo(collect);
-        page.setRecords(albumInfoVoList);
-        return page;
+        if (queryFilter.getParams().containsKey("state")){
+            switch ((String) queryFilter.getParams().get("state")){
+                case "0":
+                    albumInfoVoList = albumInfoVoList.stream().filter(e -> e.getState() == 0).collect(Collectors.toList());
+                    break;
+                case "1":
+                    albumInfoVoList = albumInfoVoList.stream().filter(e -> e.getVersionState() == 1).collect(Collectors.toList());
+                    break;
+                case "2":
+                    albumInfoVoList = albumInfoVoList.stream().filter(e -> e.getVersionState() == 2).collect(Collectors.toList());
+                    break;
+                case "4":
+                    albumInfoVoList = albumInfoVoList.stream().filter(e -> e.getVersionState() == 4).collect(Collectors.toList());
+                    break;
+            }
+        }
+        //排序
+        if (StringUtils.isNotEmpty((String) queryFilter.getParams().get("orderBySql"))){
+            albumInfoVoList = albumInfoSort((String) queryFilter.getParams().get("orderBySql"),albumInfoVoList);
+        }
+        //page.setRecords(albumInfoVoList);
+        return PageListUtils.getPages(queryFilter.getPage().getCurrent(), queryFilter.getPage().getSize(),albumInfoVoList);
     }
 
     /**
@@ -310,6 +329,42 @@ public class AlbumInfoServiceImpl extends SuperServiceImpl<AlbumInfoMapper, Albu
         return albumInfoVoList;
     }
 
+    private List<AlbumInfoVo> albumInfoSort(String sort,List<AlbumInfoVo> albumInfoVoList){
+        switch (sort) {
+            case "knowledgeTotal desc":
+                albumInfoVoList = albumInfoVoList.stream().sorted((t1, t2) -> t2.getKnowledgeTotal().compareTo(t1.getKnowledgeTotal())).collect(Collectors.toList());
+                break;
+            case "knowledgeTotal asc":
+                albumInfoVoList = albumInfoVoList.stream().sorted(Comparator.comparing(AlbumInfoVo::getKnowledgeTotal)).collect(Collectors.toList());
+                break;
+            case "yelpTotal desc":
+                albumInfoVoList = albumInfoVoList.stream().sorted((t1, t2) -> t2.getYelpTotal().compareTo(t1.getYelpTotal())).collect(Collectors.toList());
+                break;
+            case "yelpTotal asc":
+                albumInfoVoList = albumInfoVoList.stream().sorted(Comparator.comparing(AlbumInfoVo::getYelpTotal)).collect(Collectors.toList());
+                break;
+            case "views desc":
+                albumInfoVoList = albumInfoVoList.stream().sorted((t1, t2) -> t2.getViews().compareTo(t1.getViews())).collect(Collectors.toList());
+                break;
+            case "views asc":
+                albumInfoVoList = albumInfoVoList.stream().sorted(Comparator.comparing(AlbumInfoVo::getViews)).collect(Collectors.toList());
+                break;
+            case "createTime desc":
+                albumInfoVoList = albumInfoVoList.stream().sorted((t1, t2) -> t2.getCreateTime().compareTo(t1.getCreateTime())).collect(Collectors.toList());
+                break;
+            case "createTime asc":
+                albumInfoVoList = albumInfoVoList.stream().sorted(Comparator.comparing(AlbumInfoVo::getCreateTime)).collect(Collectors.toList());
+                break;
+            case "updateTime desc":
+                albumInfoVoList = albumInfoVoList.stream().sorted((t1, t2) -> t2.getUpdateTime().compareTo(t1.getUpdateTime())).collect(Collectors.toList());
+                break;
+            case "updateTime asc":
+                albumInfoVoList = albumInfoVoList.stream().sorted(Comparator.comparing(AlbumInfoVo::getUpdateTime)).collect(Collectors.toList());
+                break;
+        }
+        return albumInfoVoList;
+    }
+
     /**
      * 专辑详情
      *

+ 3 - 3
src/main/java/com/redxun/knowledge/analysis/entity/consts/ComanyColumnsConst.java

@@ -20,12 +20,12 @@ public class ComanyColumnsConst {
         List<CompanyColumns> list = new ArrayList<>();
         list.add(new CompanyColumns("公司名称","company",""));
         list.add(new CompanyColumns("访问总量","total","total"));
-        list.add(new CompanyColumns("知识管理系统","zs","zs"));
+        list.add(new CompanyColumns("知识管理平台","zs","zs"));
         list.add(new CompanyColumns("EIP系统","eip","eip"));
-        list.add(new CompanyColumns("DCC管理系统","dcc","dcc"));
+        list.add(new CompanyColumns("DCC系统","dcc","dcc"));
         list.add(new CompanyColumns("工作管理系统","gz","gz"));
         list.add(new CompanyColumns("平展系统","pz","pz"));
-        list.add(new CompanyColumns("盘系统","wp","wp"));
+        list.add(new CompanyColumns("盘系统","wp","wp"));
         return list;
     }
 }

+ 3 - 3
src/main/java/com/redxun/knowledge/analysis/entity/consts/PlatformConst.java

@@ -16,12 +16,12 @@ public class PlatformConst {
 
     public static List<String> platformList(){
         List<String> list = new ArrayList<>();
-        list.add("知识管理系统");
+        list.add("知识管理平台");
         list.add("平展系统");
         list.add("工作管理系统");
         list.add("EIP系统");
-        list.add("盘系统");
-        list.add("DCC管理系统");
+        list.add("盘系统");
+        list.add("DCC系统");
         return list;
     }
 }

+ 10 - 19
src/main/java/com/redxun/knowledge/analysis/mapper/PvLogMapper.java

@@ -4,9 +4,11 @@ package com.redxun.knowledge.analysis.mapper;
 import com.redxun.common.base.db.BaseDao;
 import com.redxun.knowledge.analysis.entity.dao.PvLog;
 import com.redxun.knowledge.analysis.entity.vo.AlbumDetailVisitsVo;
+import com.redxun.knowledge.analysis.entity.vo.SearchVisitHistogramVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.Date;
 import java.util.List;
 
 
@@ -16,25 +18,6 @@ import java.util.List;
 @Mapper
 public interface PvLogMapper extends BaseDao<PvLog> {
 
-    /**
-     * 统计当前年的搜索访问总量
-     * @param firstYearDate
-     * @param lastYearDate
-     * @return
-     */
-    Integer selectYearTotal(@Param("firstYearDate") String firstYearDate, @Param("lastYearDate") String lastYearDate);
-
-    /**
-     * 根据月份查询各个业务系统访问量
-     * @param firstOfMonth
-     * @param lastOfMonth
-     * @param platform
-     * @return
-     */
-    Integer selectSearchVisitHistogramByMonth(@Param("firstOfMonth") String firstOfMonth,
-                                              @Param("lastOfMonth") String lastOfMonth,
-                                              @Param("platform") String platform);
-
     /**
      * 专辑详情Top访问量(pv)统计
      * @param firstDay
@@ -42,4 +25,12 @@ public interface PvLogMapper extends BaseDao<PvLog> {
      * @return
      */
     List<AlbumDetailVisitsVo> albumDetailVisits(@Param("firstDay") String firstDay,@Param("lastDay") String lastDay);
+
+    /**
+     * 获取搜索服务访问量分布柱状图数据,查看一次详情算一次PV
+     * @param firstOfYear
+     * @param lastOfYear
+     * @return
+     */
+    SearchVisitHistogramVo searchVisitHistogram(@Param("firstDay")String firstOfYear,@Param("lastDay") String lastOfYear);
 }

+ 6 - 39
src/main/java/com/redxun/knowledge/analysis/service/AnalysisCommonServiceImpl.java

@@ -90,46 +90,13 @@ public class AnalysisCommonServiceImpl {
      * @return
      */
     public SearchVisitHistogramVo searchVisitHistogram() {
-        SearchVisitHistogramVo searchVisitHistogramVo = new SearchVisitHistogramVo();
-        Calendar calendar = Calendar.getInstance();
-        int year = calendar.get(Calendar.YEAR);
         //统计当前年的搜索访问总量
-        int yearTotal = pvLogMapper.selectYearTotal(DateUtils.format(DateUtils.getFirstOfYear(year)),
-                DateUtils.format(DateUtils.getLastOfYear(year)));
-        //统计每月各个系统的搜索访问量
-        List<LablesVo> lablesVoList = new ArrayList<>();
-        for (int i = 1; i <= 12; i++) {
-            LablesVo lablesVo = new LablesVo();
-            List<Map<String, Object>> values = new ArrayList<>();
-            lablesVo.setName(i + "月");
-            //查询出全部的业务系统名称
-            List<String> platformList = PlatformConst.platformList();
-            //获取每月的第一天和最后一天
-            String firstOfMonth = DateUtils.getFirstOfMonth(year, i, 15);
-            String lastOfMonth = DateUtils.getLastOfMonth(year, i, 15);
-            Integer sumByMonth = pvLogMapper.selectSearchVisitHistogramByMonth(firstOfMonth, lastOfMonth, null);
-            //根据月份查询各个业务系统访问量
-            platformList.forEach(e -> {
-                Map<String, Object> map = new HashMap<>();
-                Integer count = pvLogMapper.selectSearchVisitHistogramByMonth(firstOfMonth, lastOfMonth, e);
-                map.put("legend", e);
-                map.put("value", count);
-                if (sumByMonth == 0) {
-                    map.put("percentage", 0.0000);
-                } else {
-                    double sum = count / (sumByMonth.doubleValue());
-                    BigDecimal bd = new BigDecimal(sum);
-                    double f1 = bd.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
-                    map.put("percentage", f1);
-                }
-                values.add(map);
-            });
-            lablesVo.setValues(values);
-            lablesVoList.add(lablesVo);
-        }
-        //返回值
-        searchVisitHistogramVo.setTotal(yearTotal);
-        searchVisitHistogramVo.setLables(lablesVoList);
+        String firstYear = DateUtils.format(DateUtils.getFirstOfYear(1));
+        String lastYear = DateUtils.format(DateUtils.getLastOfYear(1));
+        firstYear = firstYear.substring(0,firstYear.lastIndexOf("-"));
+        lastYear = lastYear.substring(0,lastYear.lastIndexOf("-"));
+        SearchVisitHistogramVo searchVisitHistogramVo = pvLogMapper.
+                searchVisitHistogram(firstYear,lastYear);
         return searchVisitHistogramVo;
     }
 

+ 9 - 0
src/main/java/com/redxun/knowledge/controller/CommonController.java

@@ -1,5 +1,6 @@
 package com.redxun.knowledge.controller;
 
+import com.alibaba.fastjson.JSONObject;
 import com.redxun.common.annotation.ClassDefine;
 import com.redxun.common.base.db.BaseService;
 import com.redxun.common.base.entity.JsonResult;
@@ -87,4 +88,12 @@ public class CommonController extends BaseController<CommonEntity> {
         return jsonResult.setData("");
     }
 
+    @ApiOperation("搜索关键字上报")
+    @PostMapping("searchKeywordTrack")
+    public JsonResult searchKeywordTrack(@RequestBody JSONObject keyword){
+        JsonResult jsonResult = JsonResult.getSuccessResult("");
+        systemService.searchKeywordTrack(keyword.getString("keyword"));
+        return jsonResult.setData("");
+    }
+
 }

+ 26 - 2
src/main/java/com/redxun/knowledge/service/CommonServiceImpl.java

@@ -1,23 +1,26 @@
 
 package com.redxun.knowledge.service;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.redxun.common.base.db.BaseDao;
 import com.redxun.common.base.db.BaseService;
 import com.redxun.common.base.entity.IUser;
 import com.redxun.common.service.impl.SuperServiceImpl;
 import com.redxun.common.tool.IdGenerator;
 import com.redxun.common.utils.ContextUtil;
-import com.redxun.datasource.DataSourceContextHolder;
 import com.redxun.dto.user.OsUserDto;
 import com.redxun.feign.sys.SystemClient;
 import com.redxun.knowledge.analysis.entity.dao.PvLog;
 import com.redxun.knowledge.analysis.entity.dto.SystemLogDto;
+import com.redxun.knowledge.analysis.entity.vo.KnowledgeTypeParse;
 import com.redxun.knowledge.analysis.mapper.PvLogMapper;
 import com.redxun.knowledge.common.UserService;
 import com.redxun.knowledge.entity.dao.CommonEntity;
 import com.redxun.knowledge.entity.vo.DicVo;
 import com.redxun.knowledge.entity.vo.PositionSequenceVo;
 import com.redxun.knowledge.mapper.CommonMapper;
+import com.redxun.search.service.impl.SearchServiceImpl;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -46,6 +49,9 @@ public class CommonServiceImpl extends SuperServiceImpl<CommonMapper, CommonEnti
     @Autowired
     private PvLogMapper pvLogMapper;
 
+    @Autowired
+    private SearchServiceImpl searchService;
+
     @Resource
     @Lazy
     SystemClient systemClient;
@@ -110,9 +116,18 @@ public class CommonServiceImpl extends SuperServiceImpl<CommonMapper, CommonEnti
     public void pageTrack(SystemLogDto systemLogDto) {
         IUser users = ContextUtil.getCurrentUser();
         PvLog pvLog = new PvLog();
+        //专辑详情&地图详情补充字段处理
+        if (("知识专辑").equals(systemLogDto.getModule()) && ("详情").equals(systemLogDto.getSubModule()) ||
+                ("知识地图").equals(systemLogDto.getModule()) && ("详情").equals(systemLogDto.getSubModule())){
+            String ussd = systemLogDto.getUssd();
+            KnowledgeTypeParse knowledgeTypeParse = JSON.parseObject(ussd, KnowledgeTypeParse.class);
+            String id = knowledgeTypeParse.getId();
+            systemLogDto.setUssd(id);
+        }
         BeanUtils.copyProperties(systemLogDto,pvLog);
         pvLog.setPkId(IdGenerator.getIdStr());
-        pvLog.setCompanyId(systemLogDto.getCompanyId());
+        OsUserDto osUserDto = userService.queryOsUserDto(users.getUserId());
+        pvLog.setCompanyId(osUserDto.getCompanyId());
         pvLog.setCreateDepId(users.getDeptId());
         pvLog.setTenantId(users.getTenantId());
         pvLog.setCreateBy(users.getUserId());
@@ -121,4 +136,13 @@ public class CommonServiceImpl extends SuperServiceImpl<CommonMapper, CommonEnti
         pvLog.setUpdateTime(new Date());
         pvLogMapper.insert(pvLog);
     }
+
+    /**
+     * 搜索关键字上报
+     * @param keyword
+     */
+    public void searchKeywordTrack(String keyword) {
+        IUser users = ContextUtil.getCurrentUser();
+        searchService.keywordParticiple(keyword,users);
+    }
 }

+ 1 - 1
src/main/java/com/redxun/knowledge/utils/DateUtils.java

@@ -45,7 +45,7 @@ public class DateUtils {
      */
     public static Date getFirstOfYear(int year){
         LocalDateTime nowYear = LocalDateTime.now();
-        nowYear = nowYear.minus(1, ChronoUnit.YEARS);
+        nowYear = nowYear.minus(1, ChronoUnit.YEARS).plus(1, ChronoUnit.MONTHS);
         Date date = Date.from(nowYear.atZone(ZoneId.systemDefault()).toInstant());
         return date;
 

+ 3 - 9
src/main/java/com/redxun/search/service/impl/SearchServiceImpl.java

@@ -52,9 +52,6 @@ public class SearchServiceImpl implements SearchService {
     @Autowired
     private SearchParticipleLogMapper searchParticipleLogMapper;
 
-    @Autowired
-    private ThreadPoolExecutor threadPoolExecutor;
-
     @SneakyThrows
     @Override
     public Map<String,Object> search(String keyword, Integer pageIndex, Integer pageSize,
@@ -81,9 +78,6 @@ public class SearchServiceImpl implements SearchService {
         headerMap.put("businessKey", httpServletRequest.getHeader("businessKey"));
         String userId = userService.queryLoginUser();
         headerMap.put("userId",userId);
-        //获取关键字存入分词表中(用于统计高频搜索词)
-        IUser users = ContextUtil.getCurrentUser();
-        CompletableFuture.runAsync(() -> keywordParticiple(keyword,users),threadPoolExecutor);
         //发送搜索请求
         JSONObject respone = HttpRequestHelper.sendRequest(headerMap,paramMap,searchUrl+"/api-kmsearch/search/search");
         if(null != respone && 200 == respone.getIntValue("code")) {
@@ -167,12 +161,12 @@ public class SearchServiceImpl implements SearchService {
         if(null != respone && 200 == respone.getIntValue("code")) {
             result.put("code",respone.getIntValue("code"));
             result.put("message",respone.getString("message"));
-            result.put("data",respone.getString("data"));
+            result.put("data",respone.getJSONObject("data"));
         } else {
             assert respone != null;
             result.put("code",respone.getIntValue("code"));
             result.put("message",respone.getString("message"));
-            result.put("data",respone.getString("data"));
+            result.put("data",respone.getJSONObject("data"));
         }
         return result;
     }
@@ -268,7 +262,7 @@ public class SearchServiceImpl implements SearchService {
         return result;
     }
 
-    private void keywordParticiple(String keyword, IUser users){
+    public void keywordParticiple(String keyword, IUser users){
         try {
             Map<String, Object> headerMap = new HashMap<>();
             Map<String, Object> paramMap = new HashMap<>();

+ 1 - 4
src/main/resources/mapper/knowledge/album/AlbumInfoMapper.xml

@@ -77,10 +77,7 @@
             </if>
             and ai.IS_DEL = 0
         </where>
-        <if test="@rx.Ognl@isNotEmpty(params.orderBySql)">
-            ORDER BY ai.${w.orderBySql},ai.CREATE_TIME_ DESC
-        </if>
-        <if test="@rx.Ognl@isEmpty(params.orderBySql)">
+        <if test="@rx.Ognl@isEmpty(w.orderBySql)">
             ORDER BY ai.STATE DESC, ai.CREATE_TIME_ DESC
         </if>
     </select>

+ 3 - 3
src/main/resources/mapper/knowledge/analysis/AnalysisSearchMapper.xml

@@ -68,7 +68,7 @@
         (select COMPANY_ID as companyId, count(*) wp
         from KM_PV_LOG
         <where>
-            PLATFORM = '盘系统'
+            PLATFORM = '盘系统'
             <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}
@@ -80,7 +80,7 @@
         (select COMPANY_ID as companyId, count(*) zs
         from KM_PV_LOG
         <where>
-            PLATFORM = '知识管理系统'
+            PLATFORM = '知识管理平台'
             <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}
@@ -92,7 +92,7 @@
         (select COMPANY_ID as companyId, count(*) dcc
         from KM_PV_LOG
         <where>
-            PLATFORM = 'DCC管理系统'
+            PLATFORM = 'DCC系统'
             <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}

+ 50 - 15
src/main/resources/mapper/knowledge/analysis/PvLogMapper.xml

@@ -50,23 +50,58 @@
                 #{updateTime})
     </insert>
 
-    <select id="selectYearTotal" resultType="int">
-        select count(*) from KM_PV_LOG
-        where
-        TO_CHAR(CREATE_TIME_,'yyyy-mm-dd') &gt;= #{firstYearDate}
-        and TO_CHAR(CREATE_TIME_,'yyyy-mm-dd') &lt;= #{lastYearDate}
-    </select>
+    <resultMap id="searchVisitHistogram" type="com.redxun.knowledge.analysis.entity.vo.SearchVisitHistogramVo">
+        <result column="total" property="total"/>
+        <collection property="lables" resultMap="lablesVo"/>
+    </resultMap>
 
-    <select id="selectSearchVisitHistogramByMonth" resultType="int">
-        select count(*)
+    <resultMap id="lablesVo" type="com.redxun.knowledge.analysis.entity.vo.LablesVo">
+        <result property="name" column="name"/>
+        <collection property="values" ofType="map">
+            <result column="legend" property="legend"/>
+            <result column="value" property="value"/>
+            <result column="percentage" property="percentage"/>
+        </collection>
+    </resultMap>
+    <select id="searchVisitHistogram" resultMap="searchVisitHistogram">
+        select nvl(value,0) value , s2.name, s2.legend, nvl(percentage,0.00) percentage,sum(value) over () total
+        from (
+        select value, concat(ltrim(to_char(dates, 'mm'), '0'), '月') name, legend, percentage
+        from (
+        select nvl(value, 0) value, to_date(monthlist, 'yyyy-mm') dates, legend, percentage
+        from (
+        select count(*)                         value,
+        round(count(*) / sum(count(*)) over (partition by to_char(CREATE_TIME_, 'yyyy-mm')),
+        2)                         percentage,
+        to_char(CREATE_TIME_, 'yyyy-mm') name,
+        PLATFORM                         legend
         from KM_PV_LOG
-        <where>
-            TO_CHAR(CREATE_TIME_,'yyyy-mm-dd') &gt;= #{firstOfMonth}
-            and TO_CHAR(CREATE_TIME_,'yyyy-mm-dd') &lt;= #{lastOfMonth}
-            <if test="platform != null">
-                and PLATFORM = #{platform}
-            </if>
-        </where>
+        where to_char(CREATE_TIME_, 'yyyy-mm') &lt;= #{lastDay}
+        and to_char(CREATE_TIME_, 'yyyy-mm') &gt;= #{firstDay}
+        group by to_char(CREATE_TIME_, 'yyyy-mm'), PLATFORM
+        ) t1
+        right join (SELECT TO_CHAR(ADD_MONTHS(TO_DATE(#{firstDay}, 'yyyy-MM'), ROWNUM - 1),
+        'yyyy-MM') as monthlist
+        FROM DUAL
+        CONNECT BY ROWNUM &lt;=
+        months_between(to_date(#{lastDay}, 'yyyy-MM'),
+        to_date(#{firstDay}, 'yyyy-MM')) + 1) t2
+        on t1.name = t2.monthlist
+        order by dates)) s1
+        right join (
+        select concat(ltrim(to_char(monthlist, 'mm'), '0'), '月') name, legend,monthlist
+        from (
+        SELECT ADD_MONTHS(TO_DATE(#{firstDay}, 'yyyy-MM'), ROWNUM - 1) as monthlist
+        FROM DUAL
+        CONNECT BY ROWNUM &lt;=
+        months_between(to_date(#{lastDay}, 'yyyy-MM'),
+        to_date(#{firstDay}, 'yyyy-MM')) + 1 order by monthlist),
+        (SELECT dic.NAME_  legend,
+        dic.VALUE_ legendValue
+        FROM LEARNING_SYSTEM_DEV.SYS_TREE tree
+        INNER JOIN LEARNING_SYSTEM_DEV.SYS_DIC dic ON tree.TREE_ID_ = dic.TREE_ID_
+        WHERE ALIAS_ = 'KNOWLEDGE_PLATFORM') order by monthlist
+        ) s2 on s1.name = s2.name and s1.legend = s2.legend order by s2.monthlist
     </select>
 
     <select id="albumDetailVisits" resultType="com.redxun.knowledge.analysis.entity.vo.AlbumDetailVisitsVo">