소스 검색

作者:张哲
时间:2023/03/24
类型:开发
描述:里程碑(3)专辑创建总量和地图创建总量统计

zizg 2 년 전
부모
커밋
495bd39452

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

@@ -102,7 +102,7 @@ public class AnalysisCommonController {
     @ApiOperation("专辑创建总量")
     @GetMapping("albumAmount")
     public JsonResult albumAmount(@RequestParam("type") String type){
-        Map<String ,Object> result = analysisAlbumService.albumAmount(type);
+        CreateCountTotal result = analysisAlbumService.albumAmount(type);
         return JsonResult.getSuccessResult(result);
     }
 
@@ -133,8 +133,9 @@ public class AnalysisCommonController {
 
     @ApiOperation("地图创建总量")
     @GetMapping("mapAmount")
-    public JsonResult mapAmount(){
-        return JsonResult.getSuccessResult(null);
+    public JsonResult mapAmount(@RequestParam("type") String type){
+        CreateCountTotal result = analysisMapService.mapAmount(type);
+        return JsonResult.getSuccessResult(result);
     }
 
     @ApiOperation("各类型地图创建数量")

+ 22 - 0
src/main/java/com/redxun/knowledge/analysis/entity/vo/CreateCountLabel.java

@@ -0,0 +1,22 @@
+package com.redxun.knowledge.analysis.entity.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 文件名: CreateCountLabel
+ * 作者: zizg
+ * 时间: 2023/3/24
+ * 描述:
+ * 修改人:
+ * 修改时间:
+ * 修改内容:
+ */
+@Data
+public class CreateCountLabel implements Serializable {
+
+    private String name;
+
+    private String value;
+}

+ 28 - 0
src/main/java/com/redxun/knowledge/analysis/entity/vo/CreateCountTotal.java

@@ -0,0 +1,28 @@
+package com.redxun.knowledge.analysis.entity.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 文件名: CreateCountTotal
+ * 作者: zizg
+ * 时间: 2023/3/24
+ * 描述:
+ * 修改人:
+ * 修改时间:
+ * 修改内容:
+ */
+@ApiModel("创建总量统计 (专辑、地图)")
+@Data
+public class CreateCountTotal implements Serializable {
+
+    @ApiModelProperty("创建总量")
+    private Integer total;
+
+    @ApiModelProperty("标签取值")
+    private List<CreateCountLabel> lables;
+}

+ 9 - 0
src/main/java/com/redxun/knowledge/analysis/mapper/AnalysisAlbumMapper.java

@@ -2,6 +2,7 @@ package com.redxun.knowledge.analysis.mapper;
 
 
 import com.redxun.knowledge.analysis.entity.vo.AlbumCompanyVo;
+import com.redxun.knowledge.analysis.entity.vo.CreateCountLabel;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -50,4 +51,12 @@ public interface AnalysisAlbumMapper {
      * @return
      */
     List<AlbumCompanyVo> organizationAlbums(@Param("firstDay") String firstDay, @Param("lastDay") String lastDay);
+
+    /**
+     * 专辑创建总量
+     * @param firstDay
+     * @param lastDay
+     * @return
+     */
+    List<CreateCountLabel> albumAmount(@Param("firstDay") String firstDay,@Param("lastDay") String lastDay);
 }

+ 9 - 4
src/main/java/com/redxun/knowledge/analysis/mapper/AnalysisMapMapper.java

@@ -1,9 +1,6 @@
 package com.redxun.knowledge.analysis.mapper;
 
-import com.redxun.knowledge.analysis.entity.vo.AlbumCompanyVo;
-import com.redxun.knowledge.analysis.entity.vo.MapCompanyVo;
-import com.redxun.knowledge.analysis.entity.vo.MapPagePvVo;
-import com.redxun.knowledge.analysis.entity.vo.MapTypeCountVo;
+import com.redxun.knowledge.analysis.entity.vo.*;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -50,4 +47,12 @@ public interface AnalysisMapMapper {
      * @return
      */
     List<MapCompanyVo> organizationMaps(@Param("firstDay") String firstDay, @Param("lastDay") String lastDay);
+
+    /**
+     * 地图创建总量
+     * @param firstDay
+     * @param lastDay
+     * @return
+     */
+    List<CreateCountLabel> mapAmount(@Param("firstDay") String firstDay, @Param("lastDay") String lastDay);
 }

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

@@ -3,9 +3,7 @@ package com.redxun.knowledge.analysis.service;
 
 import com.redxun.common.tool.StringUtils;
 import com.redxun.knowledge.album.mapper.AlbumCategoryMapper;
-import com.redxun.knowledge.analysis.entity.vo.AlbumCategoryVo;
-import com.redxun.knowledge.analysis.entity.vo.AlbumCompanyVo;
-import com.redxun.knowledge.analysis.entity.vo.AlbumDetailVisitsVo;
+import com.redxun.knowledge.analysis.entity.vo.*;
 import com.redxun.knowledge.analysis.mapper.AnalysisAlbumMapper;
 import com.redxun.knowledge.analysis.mapper.PvLogMapper;
 import com.redxun.knowledge.common.UserService;
@@ -49,8 +47,26 @@ public class AnalysisAlbumServiceImpl {
      * @param type
      * @return
      */
-    public Map<String, Object> albumAmount(String type) {
-        return null;
+    public CreateCountTotal albumAmount(String type) {
+        CreateCountTotal createCountTotal = new CreateCountTotal();
+        List<CreateCountLabel> createCountLabel = new ArrayList<>();
+        Calendar calendar = Calendar.getInstance();
+        int year = calendar.get(Calendar.YEAR);
+        if (("total").equals(type)) {
+            createCountLabel = analysisAlbumMapper.albumAmount(null, null);
+        } else if ("year".equals(type)) {
+            createCountLabel = analysisAlbumMapper.albumAmount(DateUtils.format(DateUtils.getFirstOfYear(year)),
+                    DateUtils.format(DateUtils.getLastOfYear(year)));
+        } 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);
+            createCountLabel = analysisAlbumMapper.albumAmount(firstOfMonth, lastOfMonth);
+        }
+        int sum = createCountLabel.stream().mapToInt(e -> Integer.parseInt(e.getValue())).sum();
+        createCountTotal.setTotal(sum);
+        createCountTotal.setLables(createCountLabel);
+        return createCountTotal;
     }
 
     /**

+ 29 - 4
src/main/java/com/redxun/knowledge/analysis/service/AnalysisMapServiceImpl.java

@@ -1,9 +1,6 @@
 package com.redxun.knowledge.analysis.service;
 
-import com.redxun.knowledge.analysis.entity.vo.AlbumCompanyVo;
-import com.redxun.knowledge.analysis.entity.vo.MapCompanyVo;
-import com.redxun.knowledge.analysis.entity.vo.MapPagePvVo;
-import com.redxun.knowledge.analysis.entity.vo.MapTypeCountVo;
+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;
@@ -39,6 +36,34 @@ public class AnalysisMapServiceImpl {
     private UserService userService;
 
 
+
+    /**
+     * 地图创建总量
+     * @param type
+     * @return
+     */
+    public CreateCountTotal mapAmount(String type) {
+        CreateCountTotal createCountTotal = new CreateCountTotal();
+        List<CreateCountLabel> createCountLabel = new ArrayList<>();
+        Calendar calendar = Calendar.getInstance();
+        int year = calendar.get(Calendar.YEAR);
+        if (("total").equals(type)) {
+            createCountLabel = analysisMapMapper.mapAmount(null, null);
+        } else if ("year".equals(type)) {
+            createCountLabel = analysisMapMapper.mapAmount(DateUtils.format(DateUtils.getFirstOfYear(year)),
+                    DateUtils.format(DateUtils.getLastOfYear(year)));
+        } 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);
+            createCountLabel = analysisMapMapper.mapAmount(firstOfMonth, lastOfMonth);
+        }
+        int sum = createCountLabel.stream().mapToInt(e -> Integer.parseInt(e.getValue())).sum();
+        createCountTotal.setTotal(sum);
+        createCountTotal.setLables(createCountLabel);
+        return createCountTotal;
+    }
+
     /**
      * 各类型地图创建数量
      * @param type

+ 0 - 2
src/main/java/com/redxun/knowledge/common/UserService.java

@@ -11,12 +11,10 @@ import com.redxun.feign.org.UserClient;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
-import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Component;
 
 import java.io.IOException;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 
 /**

+ 29 - 0
src/main/resources/mapper/knowledge/analysis/AnalysisAlbumMapper.xml

@@ -71,5 +71,34 @@
         order by album desc
     </select>
 
+    <select id="albumAmount" resultType="com.redxun.knowledge.analysis.entity.vo.CreateCountLabel">
+        select
+        <if test="firstDay == null and lastDay == null">
+            concat(concat(substr(to_char(CREATE_TIME_,'yyyy-mm'),1,instr(to_char(CREATE_TIME_,'yyyy-mm'),'-',-1) -
+            1),'年'),
+            concat(ltrim(SUBSTR( to_char(CREATE_TIME_,'yyyy-mm'), INSTR( to_char(CREATE_TIME_,'yyyy-mm'), '-', 1 ) + 1
+            ),'0'),'月')) name
+        </if>
+        <if test="firstDay != null and lastDay != null">
+            concat(ltrim(to_char(CREATE_TIME_,'mm'),'0'),'月') name
+        </if>
+        ,count(*) value from KM_ALBUM_INFO
+        <where>
+            <if test="firstDay != null and lastDay != null">
+                TO_CHAR(CREATE_TIME_,'yyyy-mm-dd') &gt;= #{firstDay}
+                and TO_CHAR(CREATE_TIME_,'yyyy-mm-dd') &lt;= #{lastDay}
+            </if>
+        </where>
+        <if test="firstDay == null and lastDay == null">
+            group by to_char(CREATE_TIME_,'yyyy-mm')
+            order by to_char(CREATE_TIME_,'yyyy-mm')
+        </if>
+        <if test="firstDay != null and lastDay != null">
+            group by to_char(CREATE_TIME_,'mm')
+            order by to_char(CREATE_TIME_,'mm')
+        </if>
+
+    </select>
+
 
 </mapper>

+ 28 - 0
src/main/resources/mapper/knowledge/analysis/AnalysisMapMapper.xml

@@ -63,4 +63,32 @@
         order by map desc
     </select>
 
+    <select id="mapAmount" resultType="com.redxun.knowledge.analysis.entity.vo.CreateCountLabel">
+        select
+        <if test="firstDay == null and lastDay == null">
+            concat(concat(substr(to_char(CREATE_TIME_,'yyyy-mm'),1,instr(to_char(CREATE_TIME_,'yyyy-mm'),'-',-1) -
+            1),'年'),
+            concat(ltrim(SUBSTR( to_char(CREATE_TIME_,'yyyy-mm'), INSTR( to_char(CREATE_TIME_,'yyyy-mm'), '-', 1 ) + 1
+            ),'0'),'月')) name
+        </if>
+        <if test="firstDay != null and lastDay != null">
+            concat(ltrim(to_char(CREATE_TIME_,'mm'),'0'),'月') name
+        </if>
+        ,count(*) value from KM_MAP
+        <where>
+            <if test="firstDay != null and lastDay != null">
+                TO_CHAR(CREATE_TIME_,'yyyy-mm-dd') &gt;= #{firstDay}
+                and TO_CHAR(CREATE_TIME_,'yyyy-mm-dd') &lt;= #{lastDay}
+            </if>
+        </where>
+        <if test="firstDay == null and lastDay == null">
+            group by to_char(CREATE_TIME_,'yyyy-mm')
+            order by to_char(CREATE_TIME_,'yyyy-mm')
+        </if>
+        <if test="firstDay != null and lastDay != null">
+            group by to_char(CREATE_TIME_,'mm')
+            order by to_char(CREATE_TIME_,'mm')
+        </if>
+    </select>
+
 </mapper>