Kaynağa Gözat

作者:张哲
时间:2023/04/12
类型:优化
描述:里程碑(3) xy轴图表补充年统计x轴信息

zizg 2 yıl önce
ebeveyn
işleme
c5e0ced48b

+ 4 - 3
src/main/java/com/redxun/knowledge/album/entity/dto/AlbumInfoDto.java

@@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotEmpty;
 import java.io.Serializable;
 import java.util.List;
 
@@ -21,15 +22,15 @@ import java.util.List;
 @Data
 public class AlbumInfoDto implements Serializable {
 
-    @NotBlank(message = "专辑名称不能为空")
+    @NotEmpty(message = "专辑名称不能为空")
     @ApiModelProperty("专辑名称")
     private String name;
 
-    @NotBlank(message = "专辑分类不能为空")
+    @NotEmpty(message = "专辑分类不能为空")
     @ApiModelProperty("专辑分类Id")
     private String categoryId;
 
-    @NotBlank(message = "专辑封面不能为空")
+    @NotEmpty(message = "专辑封面不能为空")
     @ApiModelProperty("专辑封面")
     private String cover;
 

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

@@ -58,7 +58,7 @@ public interface AnalysisAlbumMapper {
      * @param lastDay
      * @return
      */
-    List<CreateCountLabel> albumAmount(@Param("firstDay") String firstDay,@Param("lastDay") String lastDay);
+    List<CreateCountLabel> albumAmount(@Param("firstDay") String firstDay,@Param("lastDay") String lastDay,@Param("type")String type);
 
     String selectCategoryName(String categoryId);
 

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

@@ -54,5 +54,5 @@ public interface AnalysisMapMapper {
      * @param lastDay
      * @return
      */
-    List<CreateCountLabel> mapAmount(@Param("firstDay") String firstDay, @Param("lastDay") String lastDay);
+    List<CreateCountLabel> mapAmount(@Param("firstDay") String firstDay, @Param("lastDay") String lastDay,@Param("type") String type);
 }

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

@@ -53,15 +53,15 @@ public class AnalysisAlbumServiceImpl {
         Calendar calendar = Calendar.getInstance();
         int year = calendar.get(Calendar.YEAR);
         if (("total").equals(type)) {
-            createCountLabel = analysisAlbumMapper.albumAmount(null, null);
+            createCountLabel = analysisAlbumMapper.albumAmount(null, null,"total");
         } else if ("year".equals(type)) {
             createCountLabel = analysisAlbumMapper.albumAmount(DateUtils.format(DateUtils.getFirstOfYear(year)),
-                    DateUtils.format(DateUtils.getLastOfYear(year)));
+                    DateUtils.format(DateUtils.getLastOfYear(year)),"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);
+            createCountLabel = analysisAlbumMapper.albumAmount(firstOfMonth, lastOfMonth,"month");
         }
         int sum = createCountLabel.stream().mapToInt(CreateCountLabel::getValue).sum();
         createCountTotal.setTotal(sum);

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

@@ -52,15 +52,15 @@ public class AnalysisMapServiceImpl {
         Calendar calendar = Calendar.getInstance();
         int year = calendar.get(Calendar.YEAR);
         if (("total").equals(type)) {
-            createCountLabel = analysisMapMapper.mapAmount(null, null);
+            createCountLabel = analysisMapMapper.mapAmount(null, null,"total");
         } else if ("year".equals(type)) {
             createCountLabel = analysisMapMapper.mapAmount(DateUtils.format(DateUtils.getFirstOfYear(year)),
-                    DateUtils.format(DateUtils.getLastOfYear(year)));
+                    DateUtils.format(DateUtils.getLastOfYear(year)),"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);
+            createCountLabel = analysisMapMapper.mapAmount(firstOfMonth, lastOfMonth,"month");
         }
         int sum = createCountLabel.stream().mapToInt(CreateCountLabel::getValue).sum();
         createCountTotal.setTotal(sum);

+ 17 - 1
src/main/resources/mapper/knowledge/analysis/AnalysisAlbumMapper.xml

@@ -71,6 +71,9 @@
     </select>
 
     <select id="albumAmount" resultType="com.redxun.knowledge.analysis.entity.vo.CreateCountLabel">
+        <if test="type != null and type == 'year'">
+        select t2.name,nvl(value,0) value from (
+        </if>
         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) -
@@ -96,7 +99,20 @@
             group by to_char(CREATE_TIME_,'mm')
             order by to_char(CREATE_TIME_,'mm')
         </if>
-
+        <if test="type != null and type == 'year'">
+            ) t1
+            right join
+            (select concat(ltrim(to_char(monthlist, 'mm'), '0'), '月') name, monthlist
+            from (
+            SELECT ADD_MONTHS(TO_DATE(#{firstDay}, 'yyyy-MM-dd'), ROWNUM - 1) as monthlist
+            FROM DUAL
+            CONNECT BY ROWNUM &lt;=
+            months_between(to_date(#{lastDay}, 'yyyy-MM-dd'),
+            to_date(#{firstDay}, 'yyyy-MM-dd')) + 1
+            order by monthlist)) t2
+            on t1.name = t2.name
+            order by t2.monthlist
+        </if>
     </select>
 
     <select id="selectCategoryName" resultType="string">

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

@@ -66,6 +66,9 @@
     </select>
 
     <select id="mapAmount" resultType="com.redxun.knowledge.analysis.entity.vo.CreateCountLabel">
+        <if test="type != null and type == 'year'">
+            select t2.name,nvl(value,0) value from (
+        </if>
         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) -
@@ -91,6 +94,20 @@
             group by to_char(CREATE_TIME_,'mm')
             order by to_char(CREATE_TIME_,'mm')
         </if>
+        <if test="type != null and type == 'year'">
+            ) t1
+            right join
+            (select concat(ltrim(to_char(monthlist, 'mm'), '0'), '月') name, monthlist
+            from (
+            SELECT ADD_MONTHS(TO_DATE(#{firstDay}, 'yyyy-MM-dd'), ROWNUM - 1) as monthlist
+            FROM DUAL
+            CONNECT BY ROWNUM &lt;=
+            months_between(to_date(#{lastDay}, 'yyyy-MM-dd'),
+            to_date(#{firstDay}, 'yyyy-MM-dd')) + 1
+            order by monthlist)) t2
+            on t1.name = t2.name
+            order by t2.monthlist
+        </if>
     </select>
 
 </mapper>