浏览代码

作者:张哲
时间:2023/03/27
类型:开发
描述:里程碑(3) 公司统计修改(分页修改)

zizg 1 年之前
父节点
当前提交
cc070534df

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

@@ -124,12 +124,12 @@ public class AnalysisCommonController {
     }
 
     @ApiOperation("组织创建和访问专辑数量")
-    @GetMapping("organizationAlbums")
-    public JsonResult organizationAlbums(@RequestParam("type") String type,
-                                         @RequestParam(value = "tops",required = false,defaultValue = "10") Integer tops,
-                                         @RequestParam(value = "sort",required = false) String sort){
-        List<AlbumCompanyVo> result = analysisAlbumService.organizationAlbums(type,tops,sort);
-        return JsonResult.getSuccessResult(result);
+    @PostMapping("organizationAlbums")
+    public JsonPageResult organizationAlbums(@RequestBody QueryData queryData){
+        JsonPageResult jsonResult = JsonPageResult.getSuccess("");
+        IPage result = analysisAlbumService.organizationAlbums(queryData);
+        jsonResult.setPageData(result);
+        return jsonResult;
     }
 
     @ApiOperation("地图创建总量")
@@ -154,12 +154,12 @@ public class AnalysisCommonController {
     }
 
     @ApiOperation("组织创建和访问地图数量")
-    @GetMapping("organizationMaps")
-    public JsonResult organizationMaps(@RequestParam("type") String type,
-                                       @RequestParam(value = "tops",required = false,defaultValue = "10") Integer tops,
-                                       @RequestParam(value = "sort",required = false) String sort){
-        List<MapCompanyVo> result = analysisMapService.organizationMaps(type,tops,sort);
-        return JsonResult.getSuccessResult(result);
+    @PostMapping("organizationMaps")
+    public JsonPageResult organizationMaps(@RequestBody QueryData queryData){
+        JsonPageResult jsonResult = JsonPageResult.getSuccess("");
+        IPage result = analysisMapService.organizationMaps(queryData);
+        jsonResult.setPageData(result);
+        return jsonResult;
     }
 
     @ApiOperation("各业务系统分布")
@@ -170,11 +170,11 @@ public class AnalysisCommonController {
     }
 
     @ApiOperation("组织访问量")
-    @GetMapping("organizationSearchs")
-    public JsonResult organizationSearchs(@RequestParam("type") String type,
-                                          @RequestParam(value = "tops",required = false,defaultValue = "10") Integer tops,
-                                          @RequestParam(value = "sort",required = false) String sort){
-        List<SystemCompanyVo> result = analysisSearchService.organizationSearchs(type,tops,sort);
-        return  JsonResult.getSuccessResult(result);
+    @PostMapping("organizationSearchs")
+    public JsonPageResult organizationSearchs(@RequestBody QueryData queryData){
+        JsonPageResult jsonResult = JsonPageResult.getSuccess("");
+        IPage result = analysisSearchService.organizationSearchs(queryData);
+        jsonResult.setPageData(result);
+        return jsonResult;
     }
 }

+ 21 - 17
src/main/java/com/redxun/knowledge/analysis/service/AnalysisAlbumServiceImpl.java

@@ -1,6 +1,8 @@
 package com.redxun.knowledge.analysis.service;
 
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.redxun.common.base.entity.QueryData;
 import com.redxun.common.tool.StringUtils;
 import com.redxun.knowledge.album.mapper.AlbumCategoryMapper;
 import com.redxun.knowledge.analysis.entity.vo.*;
@@ -8,6 +10,7 @@ import com.redxun.knowledge.analysis.mapper.AnalysisAlbumMapper;
 import com.redxun.knowledge.analysis.mapper.PvLogMapper;
 import com.redxun.knowledge.common.UserService;
 import com.redxun.knowledge.utils.DateUtils;
+import com.redxun.knowledge.utils.PageListUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -35,9 +38,6 @@ public class AnalysisAlbumServiceImpl {
     @Autowired
     private AnalysisAlbumMapper analysisAlbumMapper;
 
-    @Autowired
-    private AlbumCategoryMapper albumCategoryMapper;
-
     @Autowired
     private UserService userService;
 
@@ -160,48 +160,52 @@ public class AnalysisAlbumServiceImpl {
 
     /**
      * 组织创建和访问专辑数量
-     *
-     * @param type
-     * @param tops
-     * @param sort
+     * @param queryData
      * @return
      */
-    public List<AlbumCompanyVo> organizationAlbums(String type, Integer tops, String sort) {
+    public IPage organizationAlbums(QueryData queryData) {
         //创建过专辑的公司Id集合
         Calendar calendar = Calendar.getInstance();
         int year = calendar.get(Calendar.YEAR);
         List<AlbumCompanyVo> result = new ArrayList<>();
-        if ("total".equals(type)) {
+        if ("total".equals(queryData.getParams().get("type"))) {
             result = analysisAlbumMapper.organizationAlbums(null, null);
-        } else if ("year".equals(type)) {
+        } else if ("year".equals(queryData.getParams().get("type"))) {
             result = analysisAlbumMapper.organizationAlbums(DateUtils.format(DateUtils.getFirstOfYear(year)),
                     DateUtils.format(DateUtils.getLastOfYear(year)));
-        } else if ("month".equals(type)) {
+        } else if ("month".equals(queryData.getParams().get("type"))) {
             int month = calendar.get(Calendar.MONTH);
             String firstOfMonth = DateUtils.getFirstOfMonth(year, month + 1, 15);
             String lastOfMonth = DateUtils.getLastOfMonth(year, month + 1, 15);
             result = analysisAlbumMapper.organizationAlbums(firstOfMonth, lastOfMonth);
         }
         //排序
+        String sort = queryData.getSortField();
         if (sort != null) {
+            sort = sort + queryData.getSortOrder();
             switch (sort) {
-                case "albumDesc":
+                case "albumdesc":
                     result = result.stream().sorted((t1, t2) -> t2.getAlbum().compareTo(t1.getAlbum())).collect(Collectors.toList());
                     break;
-                case "albumAsc":
+                case "albumasc":
                     result = result.stream().sorted(Comparator.comparing(AlbumCompanyVo::getAlbum)).collect(Collectors.toList());
                     break;
-                case "pvDesc":
+                case "pvdesc":
                     result = result.stream().sorted((t1, t2) -> t2.getPv().compareTo(t1.getPv())).collect(Collectors.toList());
                     break;
-                case "pvAsc":
+                case "pvasc":
                     result = result.stream().sorted(Comparator.comparing(AlbumCompanyVo::getPv)).collect(Collectors.toList());
                     break;
             }
         }
         //取tops10
-        result = result.stream().limit(tops).collect(Collectors.toList());
+        String tops = queryData.getParams().get("tops");
+        if(StringUtils.isNotEmpty(tops)){
+            result = result.stream().limit(Long.parseLong(tops)).collect(Collectors.toList());
+        } else {
+            result = result.stream().limit(10).collect(Collectors.toList());
+        }
         result.forEach(e -> e.setCompany(userService.findDeptByDeptId(e.getCompany()).getName()));
-        return result;
+        return PageListUtils.getPages(queryData.getPageNo(),queryData.getPageSize(),result);
     }
 }

+ 3 - 4
src/main/java/com/redxun/knowledge/analysis/service/AnalysisCommonServiceImpl.java

@@ -303,12 +303,11 @@ public class AnalysisCommonServiceImpl {
 
         //获取top10公司数据
         String tops = queryData.getParams().get("tops");
-        List<KnowledgeCompanyVo> resultTop = new ArrayList<>();
         if (StringUtils.isNotEmpty(tops)){
-            resultTop = result.stream().limit(Long.parseLong(tops)).collect(Collectors.toList());
+            result = result.stream().limit(Long.parseLong(tops)).collect(Collectors.toList());
         } else {
-            resultTop = result.stream().limit(10).collect(Collectors.toList());
+            result = result.stream().limit(10).collect(Collectors.toList());
         }
-        return PageListUtils.getPages(queryData.getPageNo(),queryData.getPageSize(),resultTop);
+        return PageListUtils.getPages(queryData.getPageNo(),queryData.getPageSize(),result);
     }
 }

+ 22 - 13
src/main/java/com/redxun/knowledge/analysis/service/AnalysisMapServiceImpl.java

@@ -1,11 +1,15 @@
 package com.redxun.knowledge.analysis.service;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.redxun.common.base.entity.QueryData;
+import com.redxun.common.tool.StringUtils;
 import com.redxun.knowledge.analysis.entity.vo.*;
 import com.redxun.knowledge.analysis.mapper.AnalysisMapMapper;
 import com.redxun.knowledge.common.UserService;
 import com.redxun.knowledge.entity.vo.DicVo;
 import com.redxun.knowledge.mapper.CommonMapper;
 import com.redxun.knowledge.utils.DateUtils;
+import com.redxun.knowledge.utils.PageListUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -117,47 +121,52 @@ public class AnalysisMapServiceImpl {
 
     /**
      * 组织创建和访问地图数量
-     * @param type
-     * @param tops
-     * @param sort
+     * @param queryData
      * @return
      */
-    public List<MapCompanyVo> organizationMaps(String type, Integer tops, String sort) {
+    public IPage organizationMaps(QueryData queryData) {
         //创建过专辑的公司Id集合
         Calendar calendar = Calendar.getInstance();
         int year = calendar.get(Calendar.YEAR);
         List<MapCompanyVo> result = new ArrayList<>();
-        if ("total".equals(type)) {
+        if ("total".equals(queryData.getParams().get("type"))) {
             result = analysisMapMapper.organizationMaps(null, null);
-        } else if ("year".equals(type)) {
+        } else if ("year".equals(queryData.getParams().get("type"))) {
             result = analysisMapMapper.organizationMaps(DateUtils.format(DateUtils.getFirstOfYear(year)),
                     DateUtils.format(DateUtils.getLastOfYear(year)));
-        } else if ("month".equals(type)) {
+        } else if ("month".equals(queryData.getParams().get("type"))) {
             int month = calendar.get(Calendar.MONTH);
             String firstOfMonth = DateUtils.getFirstOfMonth(year, month + 1, 15);
             String lastOfMonth = DateUtils.getLastOfMonth(year, month + 1, 15);
             result = analysisMapMapper.organizationMaps(firstOfMonth, lastOfMonth);
         }
         //排序
+        String sort = queryData.getSortField();
         if (sort != null) {
+            sort = sort + queryData.getSortOrder();
             switch (sort) {
-                case "mapDesc":
+                case "mapdesc":
                     result = result.stream().sorted((t1, t2) -> t2.getMap().compareTo(t1.getMap())).collect(Collectors.toList());
                     break;
-                case "mapAsc":
+                case "mapasc":
                     result = result.stream().sorted(Comparator.comparing(MapCompanyVo::getMap)).collect(Collectors.toList());
                     break;
-                case "pvDesc":
+                case "pvdesc":
                     result = result.stream().sorted((t1, t2) -> t2.getPv().compareTo(t1.getPv())).collect(Collectors.toList());
                     break;
-                case "pvAsc":
+                case "pvasc":
                     result = result.stream().sorted(Comparator.comparing(MapCompanyVo::getPv)).collect(Collectors.toList());
                     break;
             }
         }
         //取tops10
-        result = result.stream().limit(tops).collect(Collectors.toList());
+        String tops = queryData.getParams().get("tops");
+        if (StringUtils.isNotEmpty(tops)){
+            result = result.stream().limit(Long.parseLong(tops)).collect(Collectors.toList());
+        } else {
+            result = result.stream().limit(10).collect(Collectors.toList());
+        }
         result.forEach(e -> e.setCompany(userService.findDeptByDeptId(e.getCompany()).getName()));
-        return result;
+        return PageListUtils.getPages(queryData.getPageNo(),queryData.getPageSize(),result);
     }
 }

+ 21 - 9
src/main/java/com/redxun/knowledge/analysis/service/AnalysisSearchServiceImpl.java

@@ -1,11 +1,15 @@
 package com.redxun.knowledge.analysis.service;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.redxun.common.base.entity.QueryData;
+import com.redxun.common.tool.StringUtils;
 import com.redxun.knowledge.analysis.entity.enums.SystemDetailVisitsEnum;
 import com.redxun.knowledge.analysis.entity.vo.SystemCompanyVo;
 import com.redxun.knowledge.analysis.entity.vo.SystemDetailVisitsVo;
 import com.redxun.knowledge.analysis.mapper.AnalysisSearchMapper;
 import com.redxun.knowledge.common.UserService;
 import com.redxun.knowledge.utils.DateUtils;
+import com.redxun.knowledge.utils.PageListUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -59,29 +63,37 @@ public class AnalysisSearchServiceImpl {
 
     /**
      * 组织访问量
-     * @param type
-     * @param tops
-     * @param sort
+     * @param queryData
      * @return
      */
-    public List<SystemCompanyVo> organizationSearchs(String type, Integer tops, String sort) {
+    public IPage organizationSearchs(QueryData queryData) {
+        //获取排序规则
+        String sort = queryData.getSortField();
+        if (sort != null){
+            sort = sort + queryData.getSortOrder();
+        }
         Calendar calendar = Calendar.getInstance();
         int year = calendar.get(Calendar.YEAR);
         List<SystemCompanyVo> result = new ArrayList<>();
-        if (("total").equals(type)){
+        if (("total").equals(queryData.getParams().get("type"))){
             result = analysisSearchMapper.organizationSearchs(null,null,sort);
-        } else if (("year").equals(type)){
+        } else if (("year").equals(queryData.getParams().get("type"))){
             result = analysisSearchMapper.organizationSearchs(DateUtils.format(DateUtils.getFirstOfYear(year)),
                     DateUtils.format(DateUtils.getLastOfYear(year)),sort);
-        } else if (("month").equals(type)){
+        } else if (("month").equals(queryData.getParams().get("type"))){
             int month = calendar.get(Calendar.MONTH);
             String firstOfMonth = DateUtils.getFirstOfMonth(year, month + 1, 15);
             String lastOfMonth = DateUtils.getLastOfMonth(year, month + 1, 15);
             result = analysisSearchMapper.organizationSearchs(firstOfMonth, lastOfMonth,sort);
         }
-        result = result.stream().limit(tops).collect(Collectors.toList());
+        String tops = queryData.getParams().get("tops");
+        if(StringUtils.isNotEmpty(tops)){
+            result = result.stream().limit(Long.parseLong(tops)).collect(Collectors.toList());
+        } else {
+            result = result.stream().limit(10).collect(Collectors.toList());
+        }
         //公司名称赋值
         result.forEach(e -> e.setCompany(userService.findDeptByDeptId(e.getCompany()).getName()));
-        return result;
+        return PageListUtils.getPages(queryData.getPageNo(),queryData.getPageSize(),result);
     }
 }

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

@@ -104,46 +104,46 @@
         <if test="sort == null">
             order by total desc
         </if>
-        <if test="sort == 'totalDesc'">
+        <if test="sort == 'totaldesc'">
             order by total desc
         </if>
-        <if test="sort == 'totalAsc'">
+        <if test="sort == 'totalasc'">
             order by total
         </if>
-        <if test="sort == 'zsDesc'">
+        <if test="sort == 'zsdesc'">
             order by zs desc
         </if>
-        <if test="sort == 'zsAsc'">
+        <if test="sort == 'zsasc'">
             order by zs
         </if>
-        <if test="sort == 'eipDesc'">
+        <if test="sort == 'eipdesc'">
             order by eip desc
         </if>
-        <if test="sort == 'eipAsc'">
+        <if test="sort == 'eipasc'">
             order by eip
         </if>
-        <if test="sort == 'dccDesc'">
+        <if test="sort == 'dccdesc'">
             order by dcc desc
         </if>
-        <if test="sort == 'dccAsc'">
+        <if test="sort == 'dccasc'">
             order by dcc
         </if>
-        <if test="sort == 'gzDesc'">
+        <if test="sort == 'gzdesc'">
             order by gz desc
         </if>
-        <if test="sort == 'gzAsc'">
+        <if test="sort == 'gzasc'">
             order by gz
         </if>
-        <if test="sort == 'pzDesc'">
+        <if test="sort == 'pzdesc'">
             order by pz desc
         </if>
-        <if test="sort == 'pzAsc'">
+        <if test="sort == 'pzasc'">
             order by pz
         </if>
-        <if test="sort == 'wpDesc'">
+        <if test="sort == 'wpdesc'">
             order by wp desc
         </if>
-        <if test="sort == 'wpAsc'">
+        <if test="sort == 'wpasc'">
             order by wp
         </if>
     </select>